Expand PMF_FN_* macros.
[netbsd-mini2440.git] / sys / dev / vme / vmevar.h
blob74149f35abda6f9190a4cab6f0e5011d51ccf551
1 /* $NetBSD: vmevar.h,v 1.12 2005/12/11 12:24:07 christos Exp $ */
3 /*
4 * Copyright (c) 1999
5 * Matthias Drochner. All rights reserved.
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.
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.
31 #ifndef _VMEVAR_H_
32 #define _VMEVAR_H_
34 typedef u_int32_t vme_addr_t, vme_size_t;
35 typedef int vme_am_t;
37 typedef enum {
38 VME_D8 = 1,
39 VME_D16 = 2,
40 VME_D32 = 4
41 } vme_datasize_t;
43 typedef int vme_swap_t; /* hardware swap capabilities,
44 placeholder - contents to be specified */
46 #ifdef _KERNEL
49 * Generic placeholder for any resources needed for a mapping,
50 * overloaded by bus interface driver
52 typedef void *vme_mapresc_t;
54 /* Describes interrupt mapping, opaque to MI drivers */
55 typedef void *vme_intr_handle_t;
58 * Tag structure passed to VME bus devices;
59 * contains the bus dependent functions, accessed via macros below.
61 typedef struct vme_chipset_tag {
62 void *cookie;
64 int (*vct_map)(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)(void *, vme_mapresc_t);
70 int (*vct_probe)(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 *);
75 int (*vct_int_map)(void *, int, int, vme_intr_handle_t *);
76 const struct evcnt *(*vct_int_evcnt)(void *, vme_intr_handle_t);
77 void *(*vct_int_establish)(void *, vme_intr_handle_t, int,
78 int (*)(void *), void *);
79 void (*vct_int_disestablish)(void *, void *);
81 int (*vct_dmamap_create)(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)(void *, bus_dmamap_t);
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".
93 int (*vct_dmamem_alloc)(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)(void *, bus_dma_segment_t *, int);
98 struct vmebus_softc *bus;
99 } *vme_chipset_tag_t;
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
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))
113 * probe: check readability or call callback.
115 #define vme_probe(vc, vmeaddr, len, am, datasize, callback, cbarg) \
116 (*((vc)->vct_probe))((vc)->cookie, (vmeaddr), (len), (am), \
117 (datasize), (callback), (cbarg))
120 * install / deinstall VME interrupt handler.
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))
133 * Create DMA map (which is later used by bus independent DMA functions).
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))
143 * Allocate memory directly accessible from VME.
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))
153 * Autoconfiguration data structures.
156 struct vme_attach_args;
157 typedef void (*vme_slaveconf_callback)(device_t,
158 struct vme_attach_args *);
160 struct vmebus_attach_args {
161 vme_chipset_tag_t va_vct;
162 bus_dma_tag_t va_bdt;
164 vme_slaveconf_callback va_slaveconfig;
167 struct extent;
169 struct vmebus_softc {
170 struct device sc_dev;
172 vme_chipset_tag_t sc_vct;
173 bus_dma_tag_t sc_bdt;
175 vme_slaveconf_callback slaveconfig;
177 struct extent *vme32ext, *vme24ext, *vme16ext;
180 #define VME_MAXCFRANGES 3
182 struct vme_range {
183 vme_addr_t offset;
184 vme_size_t size;
185 vme_am_t am;
188 struct vme_attach_args {
189 vme_chipset_tag_t va_vct;
190 bus_dma_tag_t va_bdt;
192 int ivector, ilevel;
193 int numcfranges;
194 struct vme_range r[VME_MAXCFRANGES];
198 * Address space accounting.
200 int _vme_space_alloc(struct vmebus_softc *, vme_addr_t, vme_size_t, vme_am_t);
201 void _vme_space_free(struct vmebus_softc *, vme_addr_t, vme_size_t, vme_am_t);
202 int _vme_space_get(struct vmebus_softc *, vme_size_t, vme_am_t,
203 u_long, vme_addr_t*);
205 #define vme_space_alloc(tag, addr, size, ams) \
206 _vme_space_alloc(tag->bus, addr, size, ams)
208 #define vme_space_free(tag, addr, size, ams) \
209 _vme_space_free(tag->bus, addr, size, ams)
211 #define vme_space_get(tag, size, ams, align, addr) \
212 _vme_space_get(tag->bus, size, ams, align, addr)
214 #endif /* KERNEL */
215 #endif /* _VMEVAR_H_ */