Document MAKEOBJDIRPREFIX.
[dragonfly.git] / sys / bus / usb / usb_mem.h
1 /*
2  * $NetBSD: usb_mem.h,v 1.18 2002/05/28 17:45:17 augustss Exp $
3  * $FreeBSD: src/sys/dev/usb/usb_mem.h,v 1.20 2003/09/01 01:07:24 jmg Exp $
4  * $DragonFly: src/sys/bus/usb/usb_mem.h,v 1.4 2004/02/11 15:17:26 joerg Exp $
5  */
6
7 /*
8  * Copyright (c) 1998 The NetBSD Foundation, Inc.
9  * All rights reserved.
10  *
11  * This code is derived from software contributed to The NetBSD Foundation
12  * by Lennart Augustsson (lennart@augustsson.net) at
13  * Carlstedt Research & Technology.
14  *
15  * Redistribution and use in source and binary forms, with or without
16  * modification, are permitted provided that the following conditions
17  * are met:
18  * 1. Redistributions of source code must retain the above copyright
19  *    notice, this list of conditions and the following disclaimer.
20  * 2. Redistributions in binary form must reproduce the above copyright
21  *    notice, this list of conditions and the following disclaimer in the
22  *    documentation and/or other materials provided with the distribution.
23  * 3. All advertising materials mentioning features or use of this software
24  *    must display the following acknowledgement:
25  *        This product includes software developed by the NetBSD
26  *        Foundation, Inc. and its contributors.
27  * 4. Neither the name of The NetBSD Foundation nor the names of its
28  *    contributors may be used to endorse or promote products derived
29  *    from this software without specific prior written permission.
30  *
31  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
32  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
33  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
34  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
35  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
36  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
37  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
38  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
39  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
40  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41  * POSSIBILITY OF SUCH DAMAGE.
42  */
43
44 typedef struct usb_dma_block {
45         bus_dma_tag_t tag;
46         bus_dmamap_t map;
47 #if defined(__FreeBSD__) || defined(__DragonFly__)
48         void *kaddr;
49 #else
50         caddr_t kaddr;
51 #endif
52         bus_dma_segment_t segs[1];
53         int nsegs;
54         size_t size;
55         size_t align;
56         int fullblock;
57         LIST_ENTRY(usb_dma_block) next;
58 } usb_dma_block_t;
59
60 #if defined(__FreeBSD__)  || defined(__DragonFly__)
61 #define DMAADDR(dma, o) ((dma)->block->segs[0].ds_addr + (dma)->offs + (o))
62 #else
63 #define DMAADDR(dma, o) (((char *)(dma)->block->map->dm_segs[0].ds_addr) + (dma)->offs + (o))
64 #endif
65 #define KERNADDR(dma, o) \
66         ((void *)((char *)((dma)->block->kaddr) + (dma)->offs + (o)))
67
68 usbd_status     usb_allocmem(usbd_bus_handle,size_t,size_t, usb_dma_t *);
69 void            usb_freemem(usbd_bus_handle, usb_dma_t *);