diff options
author | marcel <marcel@FreeBSD.org> | 2015-06-08 22:01:34 +0000 |
---|---|---|
committer | marcel <marcel@FreeBSD.org> | 2015-06-08 22:01:34 +0000 |
commit | 81fc71b09027deb3faed44719f7c83b71aee7062 (patch) | |
tree | b42070f2fbff23f88db3cd2194e9b56394e817f4 /tools | |
parent | 21b395f61276e9d47940a84cb4c9055ce8713596 (diff) | |
download | FreeBSD-src-81fc71b09027deb3faed44719f7c83b71aee7062.zip FreeBSD-src-81fc71b09027deb3faed44719f7c83b71aee7062.tar.gz |
Map the allocated DMA memory into the address space.
Diffstat (limited to 'tools')
-rw-r--r-- | tools/bus_space/busdma.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/tools/bus_space/busdma.c b/tools/bus_space/busdma.c index 2b1b7ff..4c6e37c 100644 --- a/tools/bus_space/busdma.c +++ b/tools/bus_space/busdma.c @@ -61,7 +61,9 @@ struct obj { unsigned long datarate; } tag; struct { - } md; + unsigned long physaddr; + void *virtaddr; + } mem; } u; }; @@ -260,6 +262,10 @@ bd_mem_alloc(int tid, u_int flags) md->parent = tag; tag->refcnt++; md->key = ioc.result; + md->u.mem.physaddr = ioc.u.mem.physaddr; + md->u.mem.virtaddr = mmap(NULL, tag->u.tag.maxsz, + PROT_READ | PROT_WRITE, MAP_NOCORE | MAP_SHARED, md->fd, + md->u.mem.physaddr); return (md->oid); } @@ -273,6 +279,8 @@ bd_mem_free(int mdid) if (md == NULL) return (errno); + if (md->u.mem.virtaddr != MAP_FAILED) + munmap(md->u.mem.virtaddr, md->parent->u.tag.maxsz); memset(&ioc, 0, sizeof(ioc)); ioc.request = PROTO_IOC_BUSDMA_MEM_FREE; ioc.key = md->key; |