| @@ -1,136 +1,136 @@ | | | @@ -1,136 +1,136 @@ |
1 | /* $NetBSD: bus.h,v 1.16.10.1 2009/09/29 23:53:14 snj Exp $ */ | | 1 | /* $NetBSD: bus.h,v 1.16.10.2 2009/09/29 23:54:36 snj Exp $ */ |
2 | | | 2 | |
3 | /*- | | 3 | /*- |
4 | * Copyright (c) 1996, 1997, 1998, 2001 The NetBSD Foundation, Inc. | | 4 | * Copyright (c) 1996, 1997, 1998, 2001 The NetBSD Foundation, Inc. |
5 | * All rights reserved. | | 5 | * All rights reserved. |
6 | * | | 6 | * |
7 | * This code is derived from software contributed to The NetBSD Foundation | | 7 | * This code is derived from software contributed to The NetBSD Foundation |
8 | * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility, | | 8 | * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility, |
9 | * NASA Ames Research Center. | | 9 | * NASA Ames Research Center. |
10 | * | | 10 | * |
11 | * Redistribution and use in source and binary forms, with or without | | 11 | * Redistribution and use in source and binary forms, with or without |
12 | * modification, are permitted provided that the following conditions | | 12 | * modification, are permitted provided that the following conditions |
13 | * are met: | | 13 | * are met: |
14 | * 1. Redistributions of source code must retain the above copyright | | 14 | * 1. Redistributions of source code must retain the above copyright |
15 | * notice, this list of conditions and the following disclaimer. | | 15 | * notice, this list of conditions and the following disclaimer. |
16 | * 2. Redistributions in binary form must reproduce the above copyright | | 16 | * 2. Redistributions in binary form must reproduce the above copyright |
17 | * notice, this list of conditions and the following disclaimer in the | | 17 | * notice, this list of conditions and the following disclaimer in the |
18 | * documentation and/or other materials provided with the distribution. | | 18 | * documentation and/or other materials provided with the distribution. |
19 | * | | 19 | * |
20 | * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS | | 20 | * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS |
21 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | | 21 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED |
22 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | | 22 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
23 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | | 23 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS |
24 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | | 24 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
25 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | | 25 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
26 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | | 26 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
27 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | | 27 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
28 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | | 28 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
29 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | | 29 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
30 | * POSSIBILITY OF SUCH DAMAGE. | | 30 | * POSSIBILITY OF SUCH DAMAGE. |
31 | */ | | 31 | */ |
32 | | | 32 | |
33 | /* | | 33 | /* |
34 | * Copyright (c) 1996 Charles M. Hannum. All rights reserved. | | 34 | * Copyright (c) 1996 Charles M. Hannum. All rights reserved. |
35 | * Copyright (c) 1996 Christopher G. Demetriou. All rights reserved. | | 35 | * Copyright (c) 1996 Christopher G. Demetriou. All rights reserved. |
36 | * | | 36 | * |
37 | * Redistribution and use in source and binary forms, with or without | | 37 | * Redistribution and use in source and binary forms, with or without |
38 | * modification, are permitted provided that the following conditions | | 38 | * modification, are permitted provided that the following conditions |
39 | * are met: | | 39 | * are met: |
40 | * 1. Redistributions of source code must retain the above copyright | | 40 | * 1. Redistributions of source code must retain the above copyright |
41 | * notice, this list of conditions and the following disclaimer. | | 41 | * notice, this list of conditions and the following disclaimer. |
42 | * 2. Redistributions in binary form must reproduce the above copyright | | 42 | * 2. Redistributions in binary form must reproduce the above copyright |
43 | * notice, this list of conditions and the following disclaimer in the | | 43 | * notice, this list of conditions and the following disclaimer in the |
44 | * documentation and/or other materials provided with the distribution. | | 44 | * documentation and/or other materials provided with the distribution. |
45 | * 3. All advertising materials mentioning features or use of this software | | 45 | * 3. All advertising materials mentioning features or use of this software |
46 | * must display the following acknowledgement: | | 46 | * must display the following acknowledgement: |
47 | * This product includes software developed by Christopher G. Demetriou | | 47 | * This product includes software developed by Christopher G. Demetriou |
48 | * for the NetBSD Project. | | 48 | * for the NetBSD Project. |
49 | * 4. The name of the author may not be used to endorse or promote products | | 49 | * 4. The name of the author may not be used to endorse or promote products |
50 | * derived from this software without specific prior written permission | | 50 | * derived from this software without specific prior written permission |
51 | * | | 51 | * |
52 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR | | 52 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
53 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | | 53 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
54 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. | | 54 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
55 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, | | 55 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
56 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | | 56 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
57 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | | 57 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
58 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | | 58 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
59 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | | 59 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
60 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | | 60 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
61 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | | 61 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
62 | */ | | 62 | */ |
63 | | | 63 | |
64 | #ifndef _X86_BUS_H_ | | 64 | #ifndef _X86_BUS_H_ |
65 | #define _X86_BUS_H_ | | 65 | #define _X86_BUS_H_ |
66 | | | 66 | |
67 | #include <x86/busdefs.h> | | 67 | #include <x86/busdefs.h> |
68 | | | 68 | |
69 | #ifdef BUS_SPACE_DEBUG | | 69 | #ifdef BUS_SPACE_DEBUG |
70 | #define BUS_SPACE_ALIGNED_ADDRESS(p, t) \ | | 70 | #define BUS_SPACE_ALIGNED_ADDRESS(p, t) \ |
71 | ((((u_long)(p)) & (sizeof(t)-1)) == 0) | | 71 | ((((u_long)(p)) & (sizeof(t)-1)) == 0) |
72 | #define BUS_SPACE_ALIGNED_POINTER(p, t) BUS_SPACE_ALIGNED_ADDRESS(p, t) | | 72 | #define BUS_SPACE_ALIGNED_POINTER(p, t) BUS_SPACE_ALIGNED_ADDRESS(p, t) |
73 | #else | | 73 | #else |
74 | #define BUS_SPACE_ALIGNED_POINTER(p, t) ALIGNED_POINTER(p, t) | | 74 | #define BUS_SPACE_ALIGNED_POINTER(p, t) ALIGNED_POINTER(p, t) |
75 | #endif /* BUS_SPACE_DEBUG */ | | 75 | #endif /* BUS_SPACE_DEBUG */ |
76 | | | 76 | |
77 | /* | | 77 | /* |
78 | * Bus address and size types | | 78 | * Bus address and size types |
79 | */ | | 79 | */ |
80 | typedef paddr_t bus_addr_t; | | 80 | typedef paddr_t bus_addr_t; |
81 | typedef paddr_t bus_size_t; | | 81 | typedef size_t bus_size_t; |
82 | | | 82 | |
83 | typedef int bus_space_tag_t; | | 83 | typedef int bus_space_tag_t; |
84 | typedef vaddr_t bus_space_handle_t; | | 84 | typedef vaddr_t bus_space_handle_t; |
85 | | | 85 | |
86 | int _x86_memio_map(bus_space_tag_t t, bus_addr_t addr, | | 86 | int _x86_memio_map(bus_space_tag_t t, bus_addr_t addr, |
87 | bus_size_t size, int flags, bus_space_handle_t *bshp); | | 87 | bus_size_t size, int flags, bus_space_handle_t *bshp); |
88 | void _x86_memio_unmap(bus_space_tag_t t, bus_space_handle_t bsh, | | 88 | void _x86_memio_unmap(bus_space_tag_t t, bus_space_handle_t bsh, |
89 | bus_size_t size, bus_addr_t *); | | 89 | bus_size_t size, bus_addr_t *); |
90 | | | 90 | |
91 | typedef struct x86_bus_dma_tag *bus_dma_tag_t; | | 91 | typedef struct x86_bus_dma_tag *bus_dma_tag_t; |
92 | typedef struct x86_bus_dmamap *bus_dmamap_t; | | 92 | typedef struct x86_bus_dmamap *bus_dmamap_t; |
93 | | | 93 | |
94 | #define BUS_DMA_TAG_VALID(t) ((t) != (bus_dma_tag_t)0) | | 94 | #define BUS_DMA_TAG_VALID(t) ((t) != (bus_dma_tag_t)0) |
95 | | | 95 | |
96 | /* | | 96 | /* |
97 | * bus_dma_segment_t | | 97 | * bus_dma_segment_t |
98 | * | | 98 | * |
99 | * Describes a single contiguous DMA transaction. Values | | 99 | * Describes a single contiguous DMA transaction. Values |
100 | * are suitable for programming into DMA registers. | | 100 | * are suitable for programming into DMA registers. |
101 | */ | | 101 | */ |
102 | typedef struct x86_bus_dma_segment { | | 102 | typedef struct x86_bus_dma_segment { |
103 | bus_addr_t ds_addr; /* DMA address */ | | 103 | bus_addr_t ds_addr; /* DMA address */ |
104 | bus_size_t ds_len; /* length of transfer */ | | 104 | bus_size_t ds_len; /* length of transfer */ |
105 | } bus_dma_segment_t; | | 105 | } bus_dma_segment_t; |
106 | | | 106 | |
107 | /* | | 107 | /* |
108 | * bus_dmamap_t | | 108 | * bus_dmamap_t |
109 | * | | 109 | * |
110 | * Describes a DMA mapping. XXX exposing structure to LKM. | | 110 | * Describes a DMA mapping. XXX exposing structure to LKM. |
111 | */ | | 111 | */ |
112 | struct x86_bus_dmamap { | | 112 | struct x86_bus_dmamap { |
113 | /* | | 113 | /* |
114 | * PRIVATE MEMBERS: not for use by machine-independent code. | | 114 | * PRIVATE MEMBERS: not for use by machine-independent code. |
115 | */ | | 115 | */ |
116 | bus_size_t _dm_size; /* largest DMA transfer mappable */ | | 116 | bus_size_t _dm_size; /* largest DMA transfer mappable */ |
117 | int _dm_segcnt; /* number of segs this map can map */ | | 117 | int _dm_segcnt; /* number of segs this map can map */ |
118 | bus_size_t _dm_maxmaxsegsz; /* fixed largest possible segment */ | | 118 | bus_size_t _dm_maxmaxsegsz; /* fixed largest possible segment */ |
119 | bus_size_t _dm_boundary; /* don't cross this */ | | 119 | bus_size_t _dm_boundary; /* don't cross this */ |
120 | bus_addr_t _dm_bounce_thresh; /* bounce threshold; see tag */ | | 120 | bus_addr_t _dm_bounce_thresh; /* bounce threshold; see tag */ |
121 | int _dm_flags; /* misc. flags */ | | 121 | int _dm_flags; /* misc. flags */ |
122 | | | 122 | |
123 | void *_dm_cookie; /* cookie for bus-specific functions */ | | 123 | void *_dm_cookie; /* cookie for bus-specific functions */ |
124 | | | 124 | |
125 | /* | | 125 | /* |
126 | * PUBLIC MEMBERS: these are used by machine-independent code. | | 126 | * PUBLIC MEMBERS: these are used by machine-independent code. |
127 | */ | | 127 | */ |
128 | bus_size_t dm_maxsegsz; /* largest possible segment */ | | 128 | bus_size_t dm_maxsegsz; /* largest possible segment */ |
129 | bus_size_t dm_mapsize; /* size of the mapping */ | | 129 | bus_size_t dm_mapsize; /* size of the mapping */ |
130 | int dm_nsegs; /* # valid segments in mapping */ | | 130 | int dm_nsegs; /* # valid segments in mapping */ |
131 | bus_dma_segment_t dm_segs[1]; /* segments; variable length */ | | 131 | bus_dma_segment_t dm_segs[1]; /* segments; variable length */ |
132 | }; | | 132 | }; |
133 | | | 133 | |
134 | #include <sys/bus_proto.h> | | 134 | #include <sys/bus_proto.h> |
135 | | | 135 | |
136 | #endif /* _X86_BUS_H_ */ | | 136 | #endif /* _X86_BUS_H_ */ |