diff options
author | Russell King <rmk@arm.linux.org.uk> | 2013-06-23 09:19:22 +0100 |
---|---|---|
committer | Russell King <rmk@arm.linux.org.uk> | 2013-06-23 12:01:51 +0100 |
commit | 2f9be2b33130e780a72826598c5bb0a927bc867f (patch) | |
tree | 6bf8349f560c846f634ddc16a3868d5784db4903 /bmm_lib.c | |
parent | 955fec6d52229bfd78514739300b6f754dcc40a3 (diff) |
Add bmm_malloc_aligned_phys() API
Vmeta really wants the physical and virtual address of the buffer.
Adjust the BMM API to give that to it.
Diffstat (limited to 'bmm_lib.c')
-rw-r--r-- | bmm_lib.c | 18 |
1 files changed, 14 insertions, 4 deletions
@@ -213,7 +213,8 @@ void bmm_exit() bmm_fd = -1; } -void *bmm_malloc_aligned(unsigned long size, int attr, unsigned align) +void *bmm_malloc_aligned_phys(unsigned long size, int attr, unsigned align, + unsigned long *paddr) { struct bmm_buffer *buf; int ret; @@ -230,7 +231,8 @@ void *bmm_malloc_aligned(unsigned long size, int attr, unsigned align) if (!buf) return NULL; - pr_debug("%s(size=%lu,attr=%x,align=%u)\n", __FUNCTION__, size, attr, align); + pr_debug("%s(size=%lu,attr=%x,align=%u,paddr=%p)\n", + __FUNCTION__, size, attr, align, paddr); /* obsolete, only for back-compatible */ if ((attr & BMM_ATTR_NONBUFFERABLE)&&(attr & BMM_ATTR_NONCACHEABLE)) @@ -247,12 +249,15 @@ void *bmm_malloc_aligned(unsigned long size, int attr, unsigned align) if (ret < 0 || io.output == 0) goto err_free_buf; - pr_debug("bmm_malloc return paddr = 0x%08lx\n", io.output); + pr_debug("%s return paddr = 0x%08lx\n", __FUNCTION__, io.output); vaddr = mmap(0, size, PROT_READ | PROT_WRITE, MAP_SHARED, bmm_fd, io.output); if ((int)vaddr == -1) goto err_free_bmm; + if (paddr) + *paddr = io.output; + buf->vaddr = vaddr; buf->paddr = io.output; buf->size = size; @@ -278,9 +283,14 @@ void *bmm_malloc_aligned(unsigned long size, int attr, unsigned align) return NULL; } +void *bmm_malloc_aligned(unsigned long size, int attr, unsigned align) +{ + return bmm_malloc_aligned_phys(size, attr, align, NULL); +} + void *bmm_malloc(unsigned long size, int attr) { - return bmm_malloc_aligned(size, attr, sizeof(int)); + return bmm_malloc_aligned_phys(size, attr, sizeof(int), NULL); } void bmm_free(void *vaddr) |