I have a requirement in kernel space wherein i have to program device register with 64K aligned address. Currently i am using kmalloc() to allocate memory but not sure how to align this 64K. Does linux provide a API which does this? Do i need to write my own code to do the same?
Try following approach:
First calling kmem_cache_create(...) function to create a cache pool for your structure which should be 64K aligned like following:
buff_64k_cachep = kmem_cache_create("buff_64k_cache",
sizeof(struct test_struct),
1<<16, /* 64k alignment */
flags,
);
Then calling kmem_cache_alloc(...) and kmem_cache_free(...) to allocate and free the buffers you needed.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.