Lines Matching full:md
70 } md; member
252 bd_md_add_seg(struct obj *md, int type, u_long addr, u_long size) in bd_md_add_seg() argument
260 seg->parent = md; in bd_md_add_seg()
264 md->u.md.seg[type] = seg; in bd_md_add_seg()
265 md->u.md.nsegs[type] = 1; in bd_md_add_seg()
270 bd_md_del_segs(struct obj *md, int type, int unmap) in bd_md_del_segs() argument
274 for (seg = md->u.md.seg[type]; seg != NULL; seg = seg0) { in bd_md_del_segs()
287 struct obj *md, *tag; in bd_md_create() local
293 md = obj_alloc(OBJ_TYPE_MD); in bd_md_create()
294 if (md == NULL) in bd_md_create()
299 ioc.u.md.tag = tag->key; in bd_md_create()
300 ioc.u.md.flags = flags; in bd_md_create()
302 obj_free(md); in bd_md_create()
306 md->refcnt = 1; in bd_md_create()
307 md->fd = tag->fd; in bd_md_create()
308 md->parent = tag; in bd_md_create()
310 md->key = ioc.result; in bd_md_create()
311 return (md->oid); in bd_md_create()
318 struct obj *md; in bd_md_destroy() local
320 md = obj_lookup(mdid, OBJ_TYPE_MD); in bd_md_destroy()
321 if (md == NULL) in bd_md_destroy()
326 ioc.key = md->key; in bd_md_destroy()
327 if (ioctl(md->fd, PROTO_IOC_BUSDMA, &ioc) == -1) in bd_md_destroy()
330 md->parent->refcnt--; in bd_md_destroy()
331 obj_free(md); in bd_md_destroy()
339 struct obj *md; in bd_md_load() local
342 md = obj_lookup(mdid, OBJ_TYPE_MD); in bd_md_load()
343 if (md == NULL) in bd_md_load()
348 ioc.key = md->key; in bd_md_load()
349 ioc.u.md.flags = flags; in bd_md_load()
350 ioc.u.md.virt_addr = (uintptr_t)buf; in bd_md_load()
351 ioc.u.md.virt_size = len; in bd_md_load()
352 if (ioctl(md->fd, PROTO_IOC_BUSDMA, &ioc) == -1) in bd_md_load()
355 error = bd_md_add_seg(md, BUSDMA_MD_VIRT, ioc.u.md.virt_addr, len); in bd_md_load()
356 error = bd_md_add_seg(md, BUSDMA_MD_PHYS, ioc.u.md.phys_addr, len); in bd_md_load()
357 error = bd_md_add_seg(md, BUSDMA_MD_BUS, ioc.u.md.bus_addr, len); in bd_md_load()
365 struct obj *md; in bd_md_unload() local
368 md = obj_lookup(mdid, OBJ_TYPE_MD); in bd_md_unload()
369 if (md == NULL) in bd_md_unload()
374 ioc.key = md->key; in bd_md_unload()
375 if (ioctl(md->fd, PROTO_IOC_BUSDMA, &ioc) == -1) in bd_md_unload()
378 bd_md_del_segs(md, BUSDMA_MD_VIRT, 0); in bd_md_unload()
379 bd_md_del_segs(md, BUSDMA_MD_PHYS, 0); in bd_md_unload()
380 bd_md_del_segs(md, BUSDMA_MD_BUS, 0); in bd_md_unload()
388 struct obj *md, *tag; in bd_mem_alloc() local
396 md = obj_alloc(OBJ_TYPE_MD); in bd_mem_alloc()
397 if (md == NULL) in bd_mem_alloc()
402 ioc.u.md.tag = tag->key; in bd_mem_alloc()
403 ioc.u.md.flags = flags; in bd_mem_alloc()
405 obj_free(md); in bd_mem_alloc()
409 md->refcnt = 1; in bd_mem_alloc()
410 md->fd = tag->fd; in bd_mem_alloc()
411 md->parent = tag; in bd_mem_alloc()
413 md->key = ioc.result; in bd_mem_alloc()
416 assert(ioc.u.md.phys_nsegs == 1); in bd_mem_alloc()
417 assert(ioc.u.md.bus_nsegs == 1); in bd_mem_alloc()
418 error = bd_md_add_seg(md, BUSDMA_MD_PHYS, ioc.u.md.phys_addr, in bd_mem_alloc()
420 error = bd_md_add_seg(md, BUSDMA_MD_BUS, ioc.u.md.bus_addr, in bd_mem_alloc()
424 MAP_NOCORE | MAP_SHARED, md->fd, ioc.u.md.phys_addr); in bd_mem_alloc()
427 error = bd_md_add_seg(md, BUSDMA_MD_VIRT, addr, tag->u.tag.maxsz); in bd_mem_alloc()
429 return (md->oid); in bd_mem_alloc()
434 ioc.key = md->key; in bd_mem_alloc()
435 ioctl(md->fd, PROTO_IOC_BUSDMA, &ioc); in bd_mem_alloc()
436 md->parent->refcnt--; in bd_mem_alloc()
437 obj_free(md); in bd_mem_alloc()
445 struct obj *md; in bd_mem_free() local
447 md = obj_lookup(mdid, OBJ_TYPE_MD); in bd_mem_free()
448 if (md == NULL) in bd_mem_free()
453 ioc.key = md->key; in bd_mem_free()
454 if (ioctl(md->fd, PROTO_IOC_BUSDMA, &ioc) == -1) in bd_mem_free()
457 bd_md_del_segs(md, BUSDMA_MD_VIRT, 1); in bd_mem_free()
458 bd_md_del_segs(md, BUSDMA_MD_PHYS, 0); in bd_mem_free()
459 bd_md_del_segs(md, BUSDMA_MD_BUS, 0); in bd_mem_free()
460 md->parent->refcnt--; in bd_mem_free()
461 obj_free(md); in bd_mem_free()
468 struct obj *md, *seg; in bd_md_first_seg() local
470 md = obj_lookup(mdid, OBJ_TYPE_MD); in bd_md_first_seg()
471 if (md == NULL) in bd_md_first_seg()
479 seg = md->u.md.seg[space]; in bd_md_first_seg()
540 struct obj *md; in bd_sync() local
542 md = obj_lookup(mdid, OBJ_TYPE_MD); in bd_sync()
543 if (md == NULL) in bd_sync()
548 ioc.key = md->key; in bd_sync()
552 if (ioctl(md->fd, PROTO_IOC_BUSDMA, &ioc) == -1) in bd_sync()