maplevar.h revision 1.4.18.2 1 1.4.18.2 thorpej /* $NetBSD: maplevar.h,v 1.4.18.2 2002/12/11 05:58:27 thorpej Exp $ */
2 1.4.18.2 thorpej
3 1.4.18.2 thorpej /*-
4 1.4.18.2 thorpej * Copyright (c) 2002 The NetBSD Foundation, Inc.
5 1.4.18.2 thorpej * All rights reserved.
6 1.4.18.2 thorpej *
7 1.4.18.2 thorpej * This code is derived from software contributed to The NetBSD Foundation
8 1.4.18.2 thorpej * by ITOH Yasufumi.
9 1.4.18.2 thorpej *
10 1.4.18.2 thorpej * Redistribution and use in source and binary forms, with or without
11 1.4.18.2 thorpej * modification, are permitted provided that the following conditions
12 1.4.18.2 thorpej * are met:
13 1.4.18.2 thorpej * 1. Redistributions of source code must retain the above copyright
14 1.4.18.2 thorpej * notice, this list of conditions and the following disclaimer.
15 1.4.18.2 thorpej * 2. Redistributions in binary form must reproduce the above copyright
16 1.4.18.2 thorpej * notice, this list of conditions and the following disclaimer in the
17 1.4.18.2 thorpej * documentation and/or other materials provided with the distribution.
18 1.4.18.2 thorpej * 3. All advertising materials mentioning features or use of this software
19 1.4.18.2 thorpej * must display the following acknowledgement:
20 1.4.18.2 thorpej * This product includes software developed by the NetBSD
21 1.4.18.2 thorpej * Foundation, Inc. and its contributors.
22 1.4.18.2 thorpej * 4. Neither the name of The NetBSD Foundation nor the names of its
23 1.4.18.2 thorpej * contributors may be used to endorse or promote products derived
24 1.4.18.2 thorpej * from this software without specific prior written permission.
25 1.4.18.2 thorpej *
26 1.4.18.2 thorpej * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
27 1.4.18.2 thorpej * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
28 1.4.18.2 thorpej * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29 1.4.18.2 thorpej * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
30 1.4.18.2 thorpej * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31 1.4.18.2 thorpej * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
32 1.4.18.2 thorpej * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
33 1.4.18.2 thorpej * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
34 1.4.18.2 thorpej * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
35 1.4.18.2 thorpej * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36 1.4.18.2 thorpej * POSSIBILITY OF SUCH DAMAGE.
37 1.4.18.2 thorpej */
38 1.4.18.2 thorpej
39 1.4.18.2 thorpej /*-
40 1.4.18.2 thorpej * Copyright (c) 2001 Marcus Comstedt
41 1.4.18.2 thorpej * All rights reserved.
42 1.4.18.2 thorpej *
43 1.4.18.2 thorpej * Redistribution and use in source and binary forms, with or without
44 1.4.18.2 thorpej * modification, are permitted provided that the following conditions
45 1.4.18.2 thorpej * are met:
46 1.4.18.2 thorpej * 1. Redistributions of source code must retain the above copyright
47 1.4.18.2 thorpej * notice, this list of conditions and the following disclaimer.
48 1.4.18.2 thorpej * 2. Redistributions in binary form must reproduce the above copyright
49 1.4.18.2 thorpej * notice, this list of conditions and the following disclaimer in the
50 1.4.18.2 thorpej * documentation and/or other materials provided with the distribution.
51 1.4.18.2 thorpej * 3. All advertising materials mentioning features or use of this software
52 1.4.18.2 thorpej * must display the following acknowledgement:
53 1.4.18.2 thorpej * This product includes software developed by Marcus Comstedt.
54 1.4.18.2 thorpej * 4. Neither the name of The NetBSD Foundation nor the names of its
55 1.4.18.2 thorpej * contributors may be used to endorse or promote products derived
56 1.4.18.2 thorpej * from this software without specific prior written permission.
57 1.4.18.2 thorpej *
58 1.4.18.2 thorpej * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
59 1.4.18.2 thorpej * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
60 1.4.18.2 thorpej * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
61 1.4.18.2 thorpej * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
62 1.4.18.2 thorpej * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
63 1.4.18.2 thorpej * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
64 1.4.18.2 thorpej * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
65 1.4.18.2 thorpej * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
66 1.4.18.2 thorpej * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
67 1.4.18.2 thorpej * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
68 1.4.18.2 thorpej * POSSIBILITY OF SUCH DAMAGE.
69 1.4.18.2 thorpej */
70 1.4.18.2 thorpej
71 1.4.18.2 thorpej #include <sys/queue.h>
72 1.4.18.2 thorpej
73 1.4.18.2 thorpej #define MAPLE_PORTS 4
74 1.4.18.2 thorpej #define MAPLE_SUBUNITS 6
75 1.4.18.2 thorpej
76 1.4.18.2 thorpej #define MAPLE_NFUNC 32
77 1.4.18.2 thorpej
78 1.4.18.2 thorpej struct maple_func {
79 1.4.18.2 thorpej int f_funcno;
80 1.4.18.2 thorpej struct maple_unit *f_unit;
81 1.4.18.2 thorpej struct device *f_dev;
82 1.4.18.2 thorpej
83 1.4.18.2 thorpej /* callback */
84 1.4.18.2 thorpej void (*f_callback)(void *, struct maple_response *,
85 1.4.18.2 thorpej int /*len*/, int /*flags*/);
86 1.4.18.2 thorpej void *f_arg;
87 1.4.18.2 thorpej
88 1.4.18.2 thorpej u_int32_t f_work; /* for periodic GETCOND and ping */
89 1.4.18.2 thorpej
90 1.4.18.2 thorpej /* periodic command request */
91 1.4.18.2 thorpej enum maple_periodic_stat {
92 1.4.18.2 thorpej MAPLE_PERIODIC_NONE,
93 1.4.18.2 thorpej MAPLE_PERIODIC_INQ,
94 1.4.18.2 thorpej MAPLE_PERIODIC_DEFERED
95 1.4.18.2 thorpej } f_periodic_stat;
96 1.4.18.2 thorpej TAILQ_ENTRY(maple_func) f_periodicq;
97 1.4.18.2 thorpej
98 1.4.18.2 thorpej /* command request */
99 1.4.18.2 thorpej int f_command;
100 1.4.18.2 thorpej int f_datalen;
101 1.4.18.2 thorpej void *f_dataaddr;
102 1.4.18.2 thorpej enum maple_command_stat {
103 1.4.18.2 thorpej MAPLE_CMDSTAT_NONE, /* not in queue */
104 1.4.18.2 thorpej MAPLE_CMDSTAT_ASYNC, /* process immediately */
105 1.4.18.2 thorpej MAPLE_CMDSTAT_PERIODIC_DEFERED, /* periodic but process imdtly*/
106 1.4.18.2 thorpej MAPLE_CMDSTAT_ASYNC_PERIODICQ, /* async but on periodic queue*/
107 1.4.18.2 thorpej MAPLE_CMDSTAT_PERIODIC /* process on periodic timing */
108 1.4.18.2 thorpej } f_cmdstat;
109 1.4.18.2 thorpej TAILQ_ENTRY(maple_func) f_cmdq;
110 1.4.18.2 thorpej };
111 1.4.18.2 thorpej
112 1.4.18.2 thorpej struct maple_unit {
113 1.4.18.2 thorpej int port, subunit;
114 1.4.18.2 thorpej struct maple_func u_func[MAPLE_NFUNC];
115 1.4.18.2 thorpej u_int32_t getcond_func_set;
116 1.4.18.2 thorpej int u_ping_func; /* function used for ping */
117 1.4.18.2 thorpej u_int32_t u_noping; /* stop ping (bitmap of function) */
118 1.4.18.2 thorpej struct maple_devinfo devinfo;
119 1.4.18.2 thorpej
120 1.4.18.2 thorpej /* DMA status / function */
121 1.4.18.2 thorpej enum maple_dma_stat {
122 1.4.18.2 thorpej MAPLE_DMA_IDLE, /* not in queue */
123 1.4.18.2 thorpej MAPLE_DMA_RETRY, /* retrying last command (sc_retryq) */
124 1.4.18.2 thorpej MAPLE_DMA_PERIODIC, /* periodic GETCOND */
125 1.4.18.2 thorpej MAPLE_DMA_ACMD, /* asynchronous command */
126 1.4.18.2 thorpej MAPLE_DMA_PCMD, /* command on periodic timing */
127 1.4.18.2 thorpej MAPLE_DMA_PROBE, /* checking for insertion */
128 1.4.18.2 thorpej MAPLE_DMA_PING /* checking for removal */
129 1.4.18.2 thorpej } u_dma_stat;
130 1.4.18.2 thorpej int u_dma_func;
131 1.4.18.2 thorpej
132 1.4.18.2 thorpej SIMPLEQ_ENTRY(maple_unit) u_dmaq;
133 1.4.18.2 thorpej
134 1.4.18.2 thorpej /* start of each receive buffer */
135 1.4.18.2 thorpej u_int32_t *u_rxbuf;
136 1.4.18.2 thorpej u_int32_t u_rxbuf_phys;
137 1.4.18.2 thorpej
138 1.4.18.2 thorpej /* for restarting command */
139 1.4.18.2 thorpej int u_command;
140 1.4.18.2 thorpej int u_datalen;
141 1.4.18.2 thorpej void *u_dataaddr;
142 1.4.18.2 thorpej enum maple_dma_stat u_saved_dma_stat;
143 1.4.18.2 thorpej int u_retrycnt;
144 1.4.18.2 thorpej #define MAPLE_RETRY_MAX 100 /* ~2s */
145 1.4.18.2 thorpej /*
146 1.4.18.2 thorpej * The 2s retry is rather too long, but required to avoid
147 1.4.18.2 thorpej * unwanted detach/attach.
148 1.4.18.2 thorpej * If a Visual Memory (without cells) is inserted to a controller,
149 1.4.18.2 thorpej * the controller (including the base device and the other unit
150 1.4.18.2 thorpej * in the slot) stops responding for near 1 second. If two VM are
151 1.4.18.2 thorpej * inserted in succession, the period becomes near 2s.
152 1.4.18.2 thorpej */
153 1.4.18.2 thorpej
154 1.4.18.2 thorpej /* queue for probe/ping */
155 1.4.18.2 thorpej enum maple_queue_stat {
156 1.4.18.2 thorpej MAPLE_QUEUE_NONE, /* not in queue */
157 1.4.18.2 thorpej MAPLE_QUEUE_PROBE, /* checking for insertion */
158 1.4.18.2 thorpej MAPLE_QUEUE_PING /* checking for removal */
159 1.4.18.2 thorpej } u_queuestat;
160 1.4.18.2 thorpej TAILQ_ENTRY(maple_unit) u_q;
161 1.4.18.2 thorpej int u_proberetry; /* retry count (subunit != 0) */
162 1.4.18.2 thorpej #define MAPLE_PROBERETRY_MAX 5
163 1.4.18.2 thorpej };
164 1.4.18.2 thorpej
165 1.4.18.2 thorpej struct maple_softc {
166 1.4.18.2 thorpej struct device sc_dev;
167 1.4.18.2 thorpej
168 1.4.18.2 thorpej struct callout maple_callout_ch;
169 1.4.18.2 thorpej struct proc *event_thread;
170 1.4.18.2 thorpej
171 1.4.18.2 thorpej int8_t sc_port_unit_map[MAPLE_PORTS];
172 1.4.18.2 thorpej int sc_port_units[MAPLE_PORTS];
173 1.4.18.2 thorpej int sc_port_units_open[MAPLE_PORTS];
174 1.4.18.2 thorpej
175 1.4.18.2 thorpej struct maple_unit sc_unit[MAPLE_PORTS][MAPLE_SUBUNITS];
176 1.4.18.2 thorpej
177 1.4.18.2 thorpej u_int32_t *sc_txbuf; /* start of allocated transmit buffer */
178 1.4.18.2 thorpej u_int32_t *sc_txpos; /* current write position in tx buffer */
179 1.4.18.2 thorpej u_int32_t *sc_txlink; /* start of last written frame */
180 1.4.18.2 thorpej
181 1.4.18.2 thorpej u_int32_t sc_txbuf_phys; /* 29-bit physical address */
182 1.4.18.2 thorpej
183 1.4.18.2 thorpej void *sc_intrhand;
184 1.4.18.2 thorpej int sc_dmadone; /* wchan */
185 1.4.18.2 thorpej
186 1.4.18.2 thorpej int sc_event; /* periodic event is active / wchan */
187 1.4.18.2 thorpej
188 1.4.18.2 thorpej SIMPLEQ_HEAD(maple_dmaq_head, maple_unit) sc_dmaq, sc_retryq;
189 1.4.18.2 thorpej TAILQ_HEAD(maple_unitq_head, maple_unit) sc_probeq, sc_pingq;
190 1.4.18.2 thorpej TAILQ_HEAD(maple_fnq_head, maple_func) sc_periodicq, sc_periodicdeferq;
191 1.4.18.2 thorpej TAILQ_HEAD(maple_cmdq_head, maple_func) sc_acmdq, sc_pcmdq;
192 1.4.18.2 thorpej };
193