xref: /freebsd/sys/dev/proto/proto_busdma.h (revision 5dcca8e800ee0bd6bede91a193c54681acff7f48)
14f027abdSMarcel Moolenaar /*-
24f027abdSMarcel Moolenaar  * Copyright (c) 2015 Marcel Moolenaar
34f027abdSMarcel Moolenaar  * All rights reserved.
44f027abdSMarcel Moolenaar  *
54f027abdSMarcel Moolenaar  * Redistribution and use in source and binary forms, with or without
64f027abdSMarcel Moolenaar  * modification, are permitted provided that the following conditions
74f027abdSMarcel Moolenaar  * are met:
84f027abdSMarcel Moolenaar  *
94f027abdSMarcel Moolenaar  * 1. Redistributions of source code must retain the above copyright
104f027abdSMarcel Moolenaar  *    notice, this list of conditions and the following disclaimer.
114f027abdSMarcel Moolenaar  * 2. Redistributions in binary form must reproduce the above copyright
124f027abdSMarcel Moolenaar  *    notice, this list of conditions and the following disclaimer in the
134f027abdSMarcel Moolenaar  *    documentation and/or other materials provided with the distribution.
144f027abdSMarcel Moolenaar  *
154f027abdSMarcel Moolenaar  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
164f027abdSMarcel Moolenaar  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
174f027abdSMarcel Moolenaar  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
184f027abdSMarcel Moolenaar  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
194f027abdSMarcel Moolenaar  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
204f027abdSMarcel Moolenaar  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
214f027abdSMarcel Moolenaar  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
224f027abdSMarcel Moolenaar  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
234f027abdSMarcel Moolenaar  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
244f027abdSMarcel Moolenaar  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
254f027abdSMarcel Moolenaar  *
264f027abdSMarcel Moolenaar  * $FreeBSD$
274f027abdSMarcel Moolenaar  */
284f027abdSMarcel Moolenaar 
294f027abdSMarcel Moolenaar #ifndef _DEV_PROTO_BUSDMA_H_
304f027abdSMarcel Moolenaar #define _DEV_PROTO_BUSDMA_H_
314f027abdSMarcel Moolenaar 
32*5dcca8e8SMarcel Moolenaar struct proto_md;
33*5dcca8e8SMarcel Moolenaar 
344f027abdSMarcel Moolenaar struct proto_tag {
35*5dcca8e8SMarcel Moolenaar 	LIST_ENTRY(proto_tag)	tags;
364f027abdSMarcel Moolenaar 	struct proto_tag	*parent;
37*5dcca8e8SMarcel Moolenaar 	LIST_ENTRY(proto_tag)	peers;
38*5dcca8e8SMarcel Moolenaar 	LIST_HEAD(,proto_tag)	children;
39*5dcca8e8SMarcel Moolenaar 	LIST_HEAD(,proto_md)	mds;
40*5dcca8e8SMarcel Moolenaar 	bus_addr_t		align;
41*5dcca8e8SMarcel Moolenaar 	bus_addr_t		bndry;
42*5dcca8e8SMarcel Moolenaar 	bus_addr_t		maxaddr;
43*5dcca8e8SMarcel Moolenaar 	bus_size_t		maxsz;
44*5dcca8e8SMarcel Moolenaar 	bus_size_t		maxsegsz;
45*5dcca8e8SMarcel Moolenaar 	u_int			nsegs;
46*5dcca8e8SMarcel Moolenaar 	u_int			datarate;
47*5dcca8e8SMarcel Moolenaar };
48*5dcca8e8SMarcel Moolenaar 
49*5dcca8e8SMarcel Moolenaar struct proto_md {
50*5dcca8e8SMarcel Moolenaar 	LIST_ENTRY(proto_md)	mds;
51*5dcca8e8SMarcel Moolenaar 	LIST_ENTRY(proto_md)	peers;
52*5dcca8e8SMarcel Moolenaar 	struct proto_tag	*tag;
53*5dcca8e8SMarcel Moolenaar 	void			*kva;
54*5dcca8e8SMarcel Moolenaar 	bus_dma_tag_t		bd_tag;
55*5dcca8e8SMarcel Moolenaar 	bus_dmamap_t		bd_map;
564f027abdSMarcel Moolenaar };
574f027abdSMarcel Moolenaar 
584f027abdSMarcel Moolenaar struct proto_busdma {
594f027abdSMarcel Moolenaar 	LIST_HEAD(,proto_tag)	tags;
60*5dcca8e8SMarcel Moolenaar 	LIST_HEAD(,proto_md)	mds;
61*5dcca8e8SMarcel Moolenaar 	bus_dma_tag_t		bd_roottag;
624f027abdSMarcel Moolenaar };
634f027abdSMarcel Moolenaar 
644f027abdSMarcel Moolenaar struct proto_busdma *proto_busdma_attach(struct proto_softc *);
654f027abdSMarcel Moolenaar int proto_busdma_detach(struct proto_softc *, struct proto_busdma *);
664f027abdSMarcel Moolenaar 
674f027abdSMarcel Moolenaar int proto_busdma_cleanup(struct proto_softc *, struct proto_busdma *);
684f027abdSMarcel Moolenaar 
694f027abdSMarcel Moolenaar int proto_busdma_ioctl(struct proto_softc *, struct proto_busdma *,
704f027abdSMarcel Moolenaar     struct proto_ioc_busdma *);
714f027abdSMarcel Moolenaar 
724f027abdSMarcel Moolenaar #endif /* _DEV_PROTO_BUSDMA_H_ */
73