xref: /freebsd/sys/dev/proto/proto_busdma.h (revision 95ee2897e98f5d444f26ed2334cc7c439f9c16c6)
14f027abdSMarcel Moolenaar /*-
2*9f011bcaSMarcel Moolenaar  * Copyright (c) 2015, 2019 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 
274f027abdSMarcel Moolenaar #ifndef _DEV_PROTO_BUSDMA_H_
284f027abdSMarcel Moolenaar #define _DEV_PROTO_BUSDMA_H_
294f027abdSMarcel Moolenaar 
305dcca8e8SMarcel Moolenaar struct proto_md;
315dcca8e8SMarcel Moolenaar 
324f027abdSMarcel Moolenaar struct proto_tag {
335dcca8e8SMarcel Moolenaar 	LIST_ENTRY(proto_tag)	tags;
344f027abdSMarcel Moolenaar 	struct proto_tag	*parent;
355dcca8e8SMarcel Moolenaar 	LIST_ENTRY(proto_tag)	peers;
365dcca8e8SMarcel Moolenaar 	LIST_HEAD(,proto_tag)	children;
375dcca8e8SMarcel Moolenaar 	LIST_HEAD(,proto_md)	mds;
385dcca8e8SMarcel Moolenaar 	bus_addr_t		align;
395dcca8e8SMarcel Moolenaar 	bus_addr_t		bndry;
405dcca8e8SMarcel Moolenaar 	bus_addr_t		maxaddr;
415dcca8e8SMarcel Moolenaar 	bus_size_t		maxsz;
425dcca8e8SMarcel Moolenaar 	bus_size_t		maxsegsz;
435dcca8e8SMarcel Moolenaar 	u_int			nsegs;
445dcca8e8SMarcel Moolenaar 	u_int			datarate;
455dcca8e8SMarcel Moolenaar };
465dcca8e8SMarcel Moolenaar 
475dcca8e8SMarcel Moolenaar struct proto_md {
485dcca8e8SMarcel Moolenaar 	LIST_ENTRY(proto_md)	mds;
495dcca8e8SMarcel Moolenaar 	LIST_ENTRY(proto_md)	peers;
505dcca8e8SMarcel Moolenaar 	struct proto_tag	*tag;
51cff0f135SMarcel Moolenaar 	void			*virtaddr;
52cff0f135SMarcel Moolenaar 	vm_paddr_t		physaddr;
535dcca8e8SMarcel Moolenaar 	bus_dma_tag_t		bd_tag;
545dcca8e8SMarcel Moolenaar 	bus_dmamap_t		bd_map;
554f027abdSMarcel Moolenaar };
564f027abdSMarcel Moolenaar 
574f027abdSMarcel Moolenaar struct proto_busdma {
584f027abdSMarcel Moolenaar 	LIST_HEAD(,proto_tag)	tags;
595dcca8e8SMarcel Moolenaar 	LIST_HEAD(,proto_md)	mds;
605dcca8e8SMarcel Moolenaar 	bus_dma_tag_t		bd_roottag;
61*9f011bcaSMarcel Moolenaar 	struct sx		sxlck;
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 *,
7089abdea8SMarcel Moolenaar     struct proto_ioc_busdma *, struct thread *);
714f027abdSMarcel Moolenaar 
72cff0f135SMarcel Moolenaar int proto_busdma_mmap_allowed(struct proto_busdma *, vm_paddr_t);
73cff0f135SMarcel Moolenaar 
744f027abdSMarcel Moolenaar #endif /* _DEV_PROTO_BUSDMA_H_ */
75