diff options
author | Marcel Moolenaar <marcel@FreeBSD.org> | 2015-06-11 03:02:40 +0000 |
---|---|---|
committer | Marcel Moolenaar <marcel@FreeBSD.org> | 2015-06-11 03:02:40 +0000 |
commit | cc6064789ffae519717a8e4f125876337c8a547d (patch) | |
tree | 899e80dd4c8ad46725550110001c6e815cdf616f /tools/bus_space/C | |
parent | a0be738b206eb9602bddb8ad7c745ec012fc5f43 (diff) | |
download | src-cc6064789ffae519717a8e4f125876337c8a547d.tar.gz src-cc6064789ffae519717a8e4f125876337c8a547d.zip |
Add accessor functions for iterating over segments. A segment
can be in bus address space, physical memory space or virtual
memory space.
Notes
Notes:
svn path=/head/; revision=284253
Diffstat (limited to 'tools/bus_space/C')
-rw-r--r-- | tools/bus_space/C/lang.c | 37 | ||||
-rw-r--r-- | tools/bus_space/C/libbus.h | 11 |
2 files changed, 48 insertions, 0 deletions
diff --git a/tools/bus_space/C/lang.c b/tools/bus_space/C/lang.c index bbb2bc7faa91..345957efdbe7 100644 --- a/tools/bus_space/C/lang.c +++ b/tools/bus_space/C/lang.c @@ -155,3 +155,40 @@ busdma_mem_free(busdma_md_t md) return (bd_mem_free(md)); } + +busdma_seg_t +busdma_md_first_seg(busdma_md_t md, int space) +{ + busdma_seg_t seg; + + seg = bd_md_first_seg(md, space); + return (seg); +} + +busdma_seg_t +busdma_md_next_seg(busdma_md_t md, busdma_seg_t seg) +{ + + seg = bd_md_next_seg(md, seg); + return (seg); +} + +bus_addr_t +busdma_seg_get_addr(busdma_seg_t seg) +{ + u_long addr; + int error; + + error = bd_seg_get_addr(seg, &addr); + return ((error) ? ~0UL : addr); +} + +bus_size_t +busdma_seg_get_size(busdma_seg_t seg) +{ + u_long size; + int error; + + error = bd_seg_get_size(seg, &size); + return ((error) ? ~0UL : size); +} diff --git a/tools/bus_space/C/libbus.h b/tools/bus_space/C/libbus.h index 357437246f8d..76ab40225145 100644 --- a/tools/bus_space/C/libbus.h +++ b/tools/bus_space/C/libbus.h @@ -43,6 +43,7 @@ typedef unsigned long bus_addr_t; typedef unsigned long bus_size_t; typedef int busdma_tag_t; typedef int busdma_md_t; +typedef int busdma_seg_t; int busdma_tag_create(const char *dev, bus_addr_t align, bus_addr_t bndry, bus_addr_t maxaddr, bus_size_t maxsz, u_int nsegs, @@ -57,4 +58,14 @@ int busdma_tag_destroy(busdma_tag_t tag); int busdma_mem_alloc(busdma_tag_t tag, u_int flags, busdma_md_t *out_p); int busdma_mem_free(busdma_md_t md); +#define BUSDMA_MD_BUS_SPACE 0 +#define BUSDMA_MD_PHYS_SPACE 1 +#define BUSDMA_MD_VIRT_SPACE 2 + +int busdma_md_first_seg(busdma_md_t, int space); +int busdma_md_next_seg(busdma_md_t, busdma_seg_t seg); + +bus_addr_t busdma_seg_get_addr(busdma_seg_t seg); +bus_size_t busdma_seg_get_size(busdma_seg_t seg); + #endif /* _LIBBUS_SPACE_H_ */ |