xref: /netbsd-src/sys/dev/dtv/dtv_scatter.h (revision ef3e32e573af0b6fb7f9dc10137b592db13c017e)
1 /* $NetBSD: dtv_scatter.h,v 1.1 2011/07/09 14:46:56 jmcneill Exp $ */
2 
3 /*-
4  * Copyright (c) 2011 Jared D. McNeill <jmcneill@invisible.ca>
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  * 1. Redistributions of source code must retain the above copyright
11  *    notice, this list of conditions and the following disclaimer.
12  * 2. Redistributions in binary form must reproduce the above copyright
13  *    notice, this list of conditions and the following disclaimer in the
14  *    documentation and/or other materials provided with the distribution.
15  * 3. All advertising materials mentioning features or use of this software
16  *    must display the following acknowledgement:
17  *        This product includes software developed by Jared D. McNeill.
18  * 4. Neither the name of The NetBSD Foundation nor the names of its
19  *    contributors may be used to endorse or promote products derived
20  *    from this software without specific prior written permission.
21  *
22  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
23  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
24  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
25  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
26  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
27  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
30  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32  * POSSIBILITY OF SUCH DAMAGE.
33  */
34 
35 #ifndef _DEV_DTV_DTV_SCATTER_H
36 #define _DEV_DTV_DTV_SCATTER_H
37 
38 #include <sys/pool.h>
39 
40 struct dtv_scatter_buf {
41 	pool_cache_t	sb_pool;
42 	size_t		sb_size;    /* size in bytes */
43 	size_t		sb_npages;  /* number of pages */
44 	uint8_t		**sb_page_ary; /* array of page pointers */
45 };
46 
47 struct dtv_scatter_io {
48 	struct dtv_scatter_buf *sio_buf;
49 	off_t		sio_offset;
50 	size_t		sio_resid;
51 };
52 
53 void	dtv_scatter_buf_init(struct dtv_scatter_buf *);
54 void	dtv_scatter_buf_destroy(struct dtv_scatter_buf *);
55 int	dtv_scatter_buf_set_size(struct dtv_scatter_buf *, size_t);
56 paddr_t	dtv_scatter_buf_map(struct dtv_scatter_buf *, off_t);
57 
58 bool	dtv_scatter_io_init(struct dtv_scatter_buf *, off_t, size_t,
59 			    struct dtv_scatter_io *);
60 bool	dtv_scatter_io_next(struct dtv_scatter_io *, void **, size_t *);
61 void	dtv_scatter_io_undo(struct dtv_scatter_io *, size_t);
62 void	dtv_scatter_io_copyin(struct dtv_scatter_io *, const void *);
63 /* void	dtv_scatter_io_copyout(struct dtv_scatter_io *, void *); */
64 int	dtv_scatter_io_uiomove(struct dtv_scatter_io *, struct uio *);
65 
66 #endif /* !_DEV_DTV_DTV_SCATTER_H */
67