summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRussell King <rmk@arm.linux.org.uk>2013-06-23 09:19:22 +0100
committerRussell King <rmk@arm.linux.org.uk>2013-06-23 12:01:51 +0100
commit2f9be2b33130e780a72826598c5bb0a927bc867f (patch)
tree6bf8349f560c846f634ddc16a3868d5784db4903
parent955fec6d52229bfd78514739300b6f754dcc40a3 (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.
-rw-r--r--bmm_lib.c18
-rw-r--r--bmm_lib.h2
2 files changed, 16 insertions, 4 deletions
diff --git a/bmm_lib.c b/bmm_lib.c
index 64a11e7..6e6f5b5 100644
--- a/bmm_lib.c
+++ b/bmm_lib.c
@@ -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)
diff --git a/bmm_lib.h b/bmm_lib.h
index 1c4bbec..56d9d50 100644
--- a/bmm_lib.h
+++ b/bmm_lib.h
@@ -42,6 +42,8 @@ int bmm_init();
void bmm_exit();
void *bmm_malloc(unsigned long size, int attr);
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);
void bmm_free(void *vaddr);
void *bmm_attach(unsigned long paddr, unsigned long len);
void bmm_detach(void *vaddr, unsigned long len);