diff options
author | Russell King <rmk@arm.linux.org.uk> | 2012-10-25 11:57:26 +0100 |
---|---|---|
committer | Russell King <rmk@arm.linux.org.uk> | 2012-10-25 12:14:42 +0100 |
commit | c82b518135f55a8fd075b4df20c04b78c2475c53 (patch) | |
tree | 253512589f53d45b89324a2d1af597e7396aa98b /bmm_lib.c | |
parent | 28ee15c339a4e893e95cac5b8c6fbf2730e0149e (diff) |
Add aligned malloc function [new kernel required]
vmeta wants to allocate memory with specific alignments. Rather than
having vmeta request more memory of bmm, and then doing alignment on
the result, provide a proper API to do this task. This requires an
updated kernel.
Diffstat (limited to 'bmm_lib.c')
-rw-r--r-- | bmm_lib.c | 14 |
1 files changed, 11 insertions, 3 deletions
@@ -51,7 +51,7 @@ void bmm_exit() bmm_fd = -1; } -void *bmm_malloc(unsigned long size, int attr) +void *bmm_malloc_aligned(unsigned long size, int attr, unsigned align) { int ret; void *vaddr; @@ -63,6 +63,8 @@ void *bmm_malloc(unsigned long size, int attr) if(bmm_init() < 0) return NULL; + pr_debug("%s(size=%lu,attr=%x,align=%u)\n", __FUNCTION__, size, attr, align); + /* obsolete, only for back-compatible */ if ((attr & BMM_ATTR_NONBUFFERABLE)&&(attr & BMM_ATTR_NONCACHEABLE)) attr = BMM_ATTR_NONCACHED; @@ -70,10 +72,11 @@ void *bmm_malloc(unsigned long size, int attr) if ((!(attr & BMM_ATTR_NONBUFFERABLE))&&(attr & BMM_ATTR_NONCACHEABLE)) attr = BMM_ATTR_WRITECOMBINE; - io.input = size; + io.input = align; + io.length = size; io.output = 0; io.arg = attr; - ret = ioctl(bmm_fd, BMM_MALLOC, &io); + ret = ioctl(bmm_fd, BMM_MALLOC_ALIGNED, &io); if(ret < 0 || io.output == 0) return NULL; @@ -83,6 +86,11 @@ void *bmm_malloc(unsigned long size, int attr) return ((int)vaddr == -1) ? NULL : vaddr; } +void *bmm_malloc(unsigned long size, int attr) +{ + return bmm_malloc_aligned(size, attr, sizeof(int)); +} + void bmm_free(void *vaddr) { unsigned long size; |