1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-12-16 10:20:30 +00:00

Map the allocated DMA memory into the address space.

This commit is contained in:
Marcel Moolenaar 2015-06-08 22:01:34 +00:00
parent cff0f135c1
commit cbb052dd3e
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=284169

View File

@ -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;