Remove unnecessary initialization and fix a GCC-4.x run-time linking issue
[dragonfly/vkernel-mp.git] / sys / bus / usb / usb_mem.h
blob07f7c9d1e053ee04a7cd712548ce0038950ca1df
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 16:17:26 joerg Exp $
5 */
7 /*
8 * Copyright (c) 1998 The NetBSD Foundation, Inc.
9 * All rights reserved.
11 * This code is derived from software contributed to The NetBSD Foundation
12 * by Lennart Augustsson (lennart@augustsson.net) at
13 * Carlstedt Research & Technology.
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.
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.
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;
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)))
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 *);