diff options
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) |