/*- * * XXX: Copyright * * $FreeBSD$ */ /* * A scatter/gather list describes a group of physical address ranges. * Each physical address range consists of a starting address and a * length. */ #ifndef __SGLIST_H__ #define __SGLIST_H__ #include struct sglist_seg { vm_paddr_t ss_paddr; size_t ss_len; }; struct sglist { struct sglist_seg *sg_segs; int sg_refs; u_short sg_nseg; u_short sg_maxseg; }; struct mbuf; struct uio; #define SGLIST_INIT(sgl, maxsegs, segs) do { \ (sgl)->sg_segs = (segs); \ (sgl)->sg_nseg = 0; \ (sgl)->sg_maxseg = (maxsegs); \ refcount_init(&(sgl)->sg_refs, 1); \ } while (0) static __inline void sglist_reset(struct sglist *sg) { sg->sg_nseg = 0; } static __inline struct sglist * sglist_hold(struct sglist *sg) { refcount_acquire(&sg->sg_refs); return (sg); } struct sglist *sglist_alloc(int nsegs, int mflags); int sglist_append(struct sglist *sg, void *buf, size_t len); int sglist_append_mbuf(struct sglist *sg, struct mbuf *m0); int sglist_append_phys(struct sglist *sg, vm_paddr_t paddr, size_t len); int sglist_append_uio(struct sglist *sg, struct uio *uio); int sglist_append_user(struct sglist *sg, void *buf, size_t len, struct thread *td); struct sglist *sglist_build(void *buf, size_t len, int mflags); struct sglist *sglist_clone(struct sglist *sg, int mflags); int sglist_consume_uio(struct sglist *sg, struct uio *uio, int resid); int sglist_count(void *buf, size_t len); void sglist_free(struct sglist *sg); int sglist_join(struct sglist *first, struct sglist *second); size_t sglist_length(struct sglist *sg); int sglist_slice(struct sglist *original, struct sglist **slice, size_t offset, size_t length, int mflags); int sglist_split(struct sglist *original, struct sglist **head, size_t length, int mflags); #endif /* !__SGLIST_H__ */