btvmeivar.h revision 1.1 1 /* $NetBSD: btvmeivar.h,v 1.1 1999/06/30 17:45:39 drochner 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. All advertising materials mentioning features or use of this software
16 * must display the following acknowledgement:
17 * This product includes software developed for the NetBSD Project
18 * by Matthias Drochner.
19 * 4. The name of the author may not be used to endorse or promote products
20 * derived from this software without specific prior written permission.
21 *
22 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
23 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
24 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
25 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
26 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
27 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
31 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 *
33 */
34
35 struct b3_617_vmeintrhand {
36 TAILQ_ENTRY(b3_617_vmeintrhand) ih_next;
37 int (*ih_fun) __P((void*));
38 void *ih_arg;
39 int ih_level;
40 int ih_vector;
41 int ih_prior;
42 u_long ih_count;
43 };
44
45 struct b3_617_softc {
46 struct device sc_dev;
47
48 /* tags passed in from PCI */
49 pci_chipset_tag_t sc_pc;
50 bus_space_tag_t csrt, mapt;
51 bus_space_handle_t csrh, maph;
52 bus_addr_t vmepbase; /* physical PCI address */
53 bus_dma_tag_t sc_dmat;
54 void *sc_ih;
55
56 bus_space_tag_t sc_vmet;
57
58 struct vme_range csrwindow, dmawindow24, dmawindow32;
59
60 /* tags passed to VME devices */
61 struct vme_chipset_tag sc_vct;
62
63 /* list of VME interrupt handlers */
64 TAILQ_HEAD(, b3_617_vmeintrhand) intrhdls;
65 int strayintrs;
66
67 /*
68 * management of adapter mapping tables
69 */
70 /* max fragmentation of scatter tables */
71 #define NVMEMAP 20
72
73 struct extent *vmeext;
74 char vmemap[EXTENT_FIXED_STORAGE_SIZE(NVMEMAP)];
75 };
76
77 #define read_csr_byte(sc, reg) \
78 bus_space_read_1(sc->csrt, sc->csrh, reg)
79 #define write_csr_byte(sc, reg, val) \
80 bus_space_write_1(sc->csrt, sc->csrh, reg, val)
81 #define read_csr_word(sc, reg) \
82 bus_space_read_2(sc->csrt, sc->csrh, reg)
83 #define write_csr_word(sc, reg, val) \
84 bus_space_write_2(sc->csrt, sc->csrh, reg, val)
85
86 #define write_mapmem(sc, ofs, val) \
87 bus_space_write_4(sc->mapt, sc->maph, ofs, val)
88 #define read_mapmem(sc, ofs) \
89 bus_space_read_4(sc->mapt, sc->maph, ofs)
90
91 #define VME_PAGESIZE 0x1000
92 #define PCI_PAGESIZE 0x1000
93 #define DMA_PAGESIZE 0x1000
94
95 /* shared between driver parts */
96 int b3_617_reset __P((struct b3_617_softc*));
97 int b3_617_init __P((struct b3_617_softc*));
98 #ifdef notyet /* for detach */
99 void b3_617_halt __P((struct b3_617_softc*));
100 #endif
101 int b3_617_intr __P((void*));
102 #if 0
103 void b3_617_cntlrdma_done __P((struct b3_617_softc*));
104 #endif
105
106 /* exported via tag structs */
107 int b3_617_map_vme __P((void *, vme_addr_t, vme_size_t,
108 vme_am_t, vme_datasize_t, vme_swap_t,
109 bus_space_tag_t *, bus_space_handle_t *, vme_mapresc_t*));
110 void b3_617_unmap_vme __P((void *, vme_mapresc_t));
111
112 int b3_617_vme_probe __P((void *, vme_addr_t, vme_size_t, vme_am_t,
113 vme_datasize_t,
114 int (*)(void *, bus_space_tag_t, bus_space_handle_t),
115 void *));
116
117 int b3_617_map_vmeint __P((void *, int, int, vme_intr_handle_t *));
118 void *b3_617_establish_vmeint __P((void *, vme_intr_handle_t, int,
119 int (*)(void *), void *));
120 void b3_617_disestablish_vmeint __P((void *, void *));
121
122 int b3_617_dmamap_create __P((void *, vme_size_t,
123 vme_am_t, vme_datasize_t, vme_swap_t,
124 int, vme_size_t, vme_addr_t,
125 int, bus_dmamap_t *));
126 void b3_617_dmamap_destroy __P((void *, bus_dmamap_t));
127
128 int b3_617_dmamem_alloc __P((void *, vme_size_t,
129 vme_am_t, vme_datasize_t, vme_swap_t,
130 bus_dma_segment_t *, int, int *, int));
131 void b3_617_dmamem_free __P((void *, bus_dma_segment_t *, int));
132