FreeBSD/Linux Kernel Cross Reference
sys/dev/vme/vmevar.h
1 /* $NetBSD: vmevar.h,v 1.9 2000/06/25 00:23:13 pk Exp $ */
2
3 /*
4 * Copyright (c) 1999
5 * Matthias Drochner. All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. The name of the author may not be used to endorse or promote products
16 * derived from this software without specific prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
19 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
20 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
22 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
23 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 *
29 */
30
31 #ifndef _VMEVAR_H_
32 #define _VMEVAR_H_
33
34 typedef u_int32_t vme_addr_t, vme_size_t;
35 typedef int vme_am_t;
36
37 typedef enum {
38 VME_D8 = 1,
39 VME_D16 = 2,
40 VME_D32 = 4
41 } vme_datasize_t;
42
43 typedef int vme_swap_t; /* hardware swap capabilities,
44 placeholder - contents to be specified */
45
46 #ifdef _KERNEL
47
48 /*
49 * Generic placeholder for any resources needed for a mapping,
50 * overloaded by bus interface driver
51 */
52 typedef void *vme_mapresc_t;
53
54 /* Describes interrupt mapping, opaque to MI drivers */
55 typedef void *vme_intr_handle_t;
56
57 /*
58 * Tag structure passed to VME bus devices;
59 * contains the bus dependent functions, accessed via macros below.
60 */
61 typedef struct vme_chipset_tag {
62 void *cookie;
63
64 int (*vct_map) __P((void *, vme_addr_t, vme_size_t,
65 vme_am_t, vme_datasize_t, vme_swap_t,
66 bus_space_tag_t *, bus_space_handle_t *,
67 vme_mapresc_t *));
68 void (*vct_unmap) __P((void *, vme_mapresc_t));
69
70 int (*vct_probe) __P((void *, vme_addr_t, vme_size_t,
71 vme_am_t, vme_datasize_t,
72 int (*)(void *, bus_space_tag_t, bus_space_handle_t),
73 void *));
74
75 int (*vct_int_map) __P((void *, int, int, vme_intr_handle_t *));
76 const struct evcnt *(*vct_int_evcnt) __P((void *, vme_intr_handle_t));
77 void *(*vct_int_establish) __P((void *, vme_intr_handle_t, int,
78 int (*)(void *), void *));
79 void (*vct_int_disestablish) __P((void *, void *));
80
81 int (*vct_dmamap_create) __P((void *, vme_size_t,
82 vme_am_t, vme_datasize_t, vme_swap_t,
83 int, vme_size_t, vme_addr_t,
84 int, bus_dmamap_t *));
85 void (*vct_dmamap_destroy) __P((void *, bus_dmamap_t));
86
87 /*
88 * This sucks: we have to give all the VME specific arguments
89 * twice - for dmamem_alloc and for dmamem_create. Perhaps
90 * give a "dmamap" argument here, meaning: "allocate memory which
91 * can be accessed through this DMA map".
92 */
93 int (*vct_dmamem_alloc) __P((void *, vme_size_t,
94 vme_am_t, vme_datasize_t, vme_swap_t,
95 bus_dma_segment_t *, int, int *, int));
96 void (*vct_dmamem_free) __P((void *, bus_dma_segment_t *, int));
97
98 struct vmebus_softc *bus;
99 } *vme_chipset_tag_t;
100
101 /*
102 * map / unmap: map VME address ranges into kernel address space
103 * XXX should have mapping to CPU only to allow user mmap() without
104 * wasting kvm
105 */
106 #define vme_space_map(vc, vmeaddr, len, am, datasize, swap, tag, handle, resc) \
107 (*((vc)->vct_map))((vc)->cookie, (vmeaddr), (len), (am), (datasize), \
108 (swap), (tag), (handle), (resc))
109 #define vme_space_unmap(vc, resc) \
110 (*((vc)->vct_unmap))((vc)->cookie, (resc))
111
112 /*
113 * probe: check readability or call callback.
114 */
115 #define vme_probe(vc, vmeaddr, len, am, datasize, callback, cbarg) \
116 (*((vc)->vct_probe))((vc)->cookie, (vmeaddr), (len), (am), \
117 (datasize), (callback), (cbarg))
118
119 /*
120 * install / deinstall VME interrupt handler.
121 */
122 #define vme_intr_map(vc, level, vector, handlep) \
123 (*((vc)->vct_int_map))((vc)->cookie, (level), (vector), (handlep))
124 #define vme_intr_evcnt(vc, handle) \
125 (*((vc)->vct_int_evcnt))((vc)->cookie, (handle))
126 #define vme_intr_establish(vc, handle, prio, func, arg) \
127 (*((vc)->vct_int_establish))((vc)->cookie, \
128 (handle), (prio), (func), (arg))
129 #define vme_intr_disestablish(vc, cookie) \
130 (*((vc)->vct_int_unmap))((vc)->cookie, (cookie))
131
132 /*
133 * Create DMA map (which is later used by bus independent DMA functions).
134 */
135 #define vme_dmamap_create(vc, size, am, datasize, swap, nsegs, segsz, bound, \
136 flags, map) \
137 (*((vc)->vct_dmamap_create))((vc)->cookie, (size), (am), (datasize), \
138 (swap), (nsegs), (segsz), (bound), (flags), (map))
139 #define vme_dmamap_destroy(vc, map) \
140 (*((vc)->vct_dmamap_destroy))((vc)->cookie, (map))
141
142 /*
143 * Allocate memory directly accessible from VME.
144 */
145 #define vme_dmamem_alloc(vc, size, am, datasize, swap, \
146 segs, nsegs, rsegs, flags) \
147 (*((vc)->vct_dmamem_alloc))((vc)->cookie, (size), (am), (datasize), (swap), \
148 (segs), (nsegs), (rsegs), (flags))
149 #define vme_dmamem_free(vc, segs, nsegs) \
150 (*((vc)->vct_dmamem_free))((vc)->cookie, (segs), (nsegs))
151
152 /*
153 * Autoconfiguration data structures.
154 */
155
156 struct vme_attach_args;
157 typedef void (*vme_slaveconf_callback) __P((struct device *,
158 struct vme_attach_args *));
159
160 struct vmebus_attach_args {
161 vme_chipset_tag_t va_vct;
162 bus_dma_tag_t va_bdt;
163
164 vme_slaveconf_callback va_slaveconfig;
165 };
166
167 struct extent;
168
169 struct vmebus_softc {
170 struct device sc_dev;
171
172 vme_chipset_tag_t sc_vct;
173 bus_dma_tag_t sc_bdt;
174
175 vme_slaveconf_callback slaveconfig;
176
177 struct extent *vme32ext, *vme24ext, *vme16ext;
178 };
179
180 #define VME_MAXCFRANGES 3
181
182 struct vme_range {
183 vme_addr_t offset;
184 vme_size_t size;
185 vme_am_t am;
186 };
187
188 struct vme_attach_args {
189 vme_chipset_tag_t va_vct;
190 bus_dma_tag_t va_bdt;
191
192 int ivector, ilevel;
193 int numcfranges;
194 struct vme_range r[VME_MAXCFRANGES];
195 };
196
197 /*
198 * Address space accounting.
199 */
200 int _vme_space_alloc __P((struct vmebus_softc *, vme_addr_t,
201 vme_size_t, vme_am_t));
202 void _vme_space_free __P((struct vmebus_softc *, vme_addr_t,
203 vme_size_t, vme_am_t));
204 int _vme_space_get __P((struct vmebus_softc *, vme_size_t, vme_am_t,
205 u_long, vme_addr_t*));
206
207 #define vme_space_alloc(tag, addr, size, ams) \
208 _vme_space_alloc(tag->bus, addr, size, ams)
209
210 #define vme_space_free(tag, addr, size, ams) \
211 _vme_space_free(tag->bus, addr, size, ams)
212
213 #define vme_space_get(tag, size, ams, align, addr) \
214 _vme_space_get(tag->bus, size, ams, align, addr)
215
216 #endif /* KERNEL */
217 #endif /* _VMEVAR_H_ */
Cache object: d8f7ae25e9bdd6e5deadc429ccab80ef
|