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 * $FreeBSD$ 274f027abdSMarcel Moolenaar */ 284f027abdSMarcel Moolenaar 294f027abdSMarcel Moolenaar #ifndef _DEV_PROTO_BUSDMA_H_ 304f027abdSMarcel Moolenaar #define _DEV_PROTO_BUSDMA_H_ 314f027abdSMarcel Moolenaar 325dcca8e8SMarcel Moolenaar struct proto_md; 335dcca8e8SMarcel Moolenaar 344f027abdSMarcel Moolenaar struct proto_tag { 355dcca8e8SMarcel Moolenaar LIST_ENTRY(proto_tag) tags; 364f027abdSMarcel Moolenaar struct proto_tag *parent; 375dcca8e8SMarcel Moolenaar LIST_ENTRY(proto_tag) peers; 385dcca8e8SMarcel Moolenaar LIST_HEAD(,proto_tag) children; 395dcca8e8SMarcel Moolenaar LIST_HEAD(,proto_md) mds; 405dcca8e8SMarcel Moolenaar bus_addr_t align; 415dcca8e8SMarcel Moolenaar bus_addr_t bndry; 425dcca8e8SMarcel Moolenaar bus_addr_t maxaddr; 435dcca8e8SMarcel Moolenaar bus_size_t maxsz; 445dcca8e8SMarcel Moolenaar bus_size_t maxsegsz; 455dcca8e8SMarcel Moolenaar u_int nsegs; 465dcca8e8SMarcel Moolenaar u_int datarate; 475dcca8e8SMarcel Moolenaar }; 485dcca8e8SMarcel Moolenaar 495dcca8e8SMarcel Moolenaar struct proto_md { 505dcca8e8SMarcel Moolenaar LIST_ENTRY(proto_md) mds; 515dcca8e8SMarcel Moolenaar LIST_ENTRY(proto_md) peers; 525dcca8e8SMarcel Moolenaar struct proto_tag *tag; 53cff0f135SMarcel Moolenaar void *virtaddr; 54cff0f135SMarcel Moolenaar vm_paddr_t physaddr; 555dcca8e8SMarcel Moolenaar bus_dma_tag_t bd_tag; 565dcca8e8SMarcel Moolenaar bus_dmamap_t bd_map; 574f027abdSMarcel Moolenaar }; 584f027abdSMarcel Moolenaar 594f027abdSMarcel Moolenaar struct proto_busdma { 604f027abdSMarcel Moolenaar LIST_HEAD(,proto_tag) tags; 615dcca8e8SMarcel Moolenaar LIST_HEAD(,proto_md) mds; 625dcca8e8SMarcel Moolenaar bus_dma_tag_t bd_roottag; 63*9f011bcaSMarcel Moolenaar struct sx sxlck; 644f027abdSMarcel Moolenaar }; 654f027abdSMarcel Moolenaar 664f027abdSMarcel Moolenaar struct proto_busdma *proto_busdma_attach(struct proto_softc *); 674f027abdSMarcel Moolenaar int proto_busdma_detach(struct proto_softc *, struct proto_busdma *); 684f027abdSMarcel Moolenaar 694f027abdSMarcel Moolenaar int proto_busdma_cleanup(struct proto_softc *, struct proto_busdma *); 704f027abdSMarcel Moolenaar 714f027abdSMarcel Moolenaar int proto_busdma_ioctl(struct proto_softc *, struct proto_busdma *, 7289abdea8SMarcel Moolenaar struct proto_ioc_busdma *, struct thread *); 734f027abdSMarcel Moolenaar 74cff0f135SMarcel Moolenaar int proto_busdma_mmap_allowed(struct proto_busdma *, vm_paddr_t); 75cff0f135SMarcel Moolenaar 764f027abdSMarcel Moolenaar #endif /* _DEV_PROTO_BUSDMA_H_ */ 77