Fri Feb 11 17:30:48 2022 UTC ()
playstation2: Fix some pre-device_t/softc-split device private sizes.

Nothing appears to use device_private here, so let's not allocate
anything or ask for sizeof(struct device).


(riastradh)
diff -r1.19 -r1.20 src/sys/arch/playstation2/dev/sbus.c
diff -r1.15 -r1.16 src/sys/arch/playstation2/dev/spd.c
diff -r1.18 -r1.19 src/sys/arch/playstation2/playstation2/mainbus.c

cvs diff -r1.19 -r1.20 src/sys/arch/playstation2/dev/sbus.c (switch to unified diff)

--- src/sys/arch/playstation2/dev/sbus.c 2021/08/07 16:19:02 1.19
+++ src/sys/arch/playstation2/dev/sbus.c 2022/02/11 17:30:48 1.20
@@ -1,309 +1,309 @@ @@ -1,309 +1,309 @@
1/* $NetBSD: sbus.c,v 1.19 2021/08/07 16:19:02 thorpej Exp $ */ 1/* $NetBSD: sbus.c,v 1.20 2022/02/11 17:30:48 riastradh Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 2001 The NetBSD Foundation, Inc. 4 * Copyright (c) 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 UCHIYAMA Yasushi. 8 * by UCHIYAMA Yasushi.
9 * 9 *
10 * Redistribution and use in source and binary forms, with or without 10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions 11 * modification, are permitted provided that the following conditions
12 * are met: 12 * are met:
13 * 1. Redistributions of source code must retain the above copyright 13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer. 14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright 15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the 16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution. 17 * documentation and/or other materials provided with the distribution.
18 * 18 *
19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE. 29 * POSSIBILITY OF SUCH DAMAGE.
30 */ 30 */
31 31
32/* 32/*
33 * PlayStation 2 internal PCMCIA/USB interface unit. 33 * PlayStation 2 internal PCMCIA/USB interface unit.
34 */ 34 */
35 35
36#include <sys/cdefs.h> 36#include <sys/cdefs.h>
37__KERNEL_RCSID(0, "$NetBSD: sbus.c,v 1.19 2021/08/07 16:19:02 thorpej Exp $"); 37__KERNEL_RCSID(0, "$NetBSD: sbus.c,v 1.20 2022/02/11 17:30:48 riastradh Exp $");
38 38
39#include <sys/param.h> 39#include <sys/param.h>
40#include <sys/device.h> 40#include <sys/device.h>
41#include <sys/systm.h> 41#include <sys/systm.h>
42 42
43#include <machine/bootinfo.h> 43#include <machine/bootinfo.h>
44#include <machine/autoconf.h> 44#include <machine/autoconf.h>
45 45
46#include <playstation2/playstation2/interrupt.h> 46#include <playstation2/playstation2/interrupt.h>
47 47
48#include <playstation2/ee/eevar.h> 48#include <playstation2/ee/eevar.h>
49#include <playstation2/ee/intcvar.h> 49#include <playstation2/ee/intcvar.h>
50#include <playstation2/dev/sbusvar.h> 50#include <playstation2/dev/sbusvar.h>
51#include <playstation2/dev/sbusreg.h> 51#include <playstation2/dev/sbusreg.h>
52 52
53#ifdef DEBUG 53#ifdef DEBUG
54#define STATIC 54#define STATIC
55#else 55#else
56#define STATIC static 56#define STATIC static
57#endif 57#endif
58 58
59STATIC void sbus_type2_pcmcia_intr_clear(void); 59STATIC void sbus_type2_pcmcia_intr_clear(void);
60STATIC void sbus_type2_pcmcia_intr_enable(void); 60STATIC void sbus_type2_pcmcia_intr_enable(void);
61STATIC void sbus_type2_pcmcia_intr_disable(void); 61STATIC void sbus_type2_pcmcia_intr_disable(void);
62STATIC void sbus_type2_pcmcia_intr_reinstall(void); 62STATIC void sbus_type2_pcmcia_intr_reinstall(void);
63STATIC void sbus_type3_pcmcia_intr_clear(void); 63STATIC void sbus_type3_pcmcia_intr_clear(void);
64STATIC void sbus_type3_pcmcia_intr_enable(void); 64STATIC void sbus_type3_pcmcia_intr_enable(void);
65STATIC void sbus_type3_pcmcia_intr_disable(void); 65STATIC void sbus_type3_pcmcia_intr_disable(void);
66STATIC void sbus_type3_pcmcia_intr_reinstall(void); 66STATIC void sbus_type3_pcmcia_intr_reinstall(void);
67STATIC int sbus_spurious_intr(void *); 67STATIC int sbus_spurious_intr(void *);
68 68
69STATIC void (*sbus_pcmcia_intr_clear)(void); 69STATIC void (*sbus_pcmcia_intr_clear)(void);
70STATIC void (*sbus_pcmcia_intr_enable)(void); 70STATIC void (*sbus_pcmcia_intr_enable)(void);
71STATIC void (*sbus_pcmcia_intr_disable)(void); 71STATIC void (*sbus_pcmcia_intr_disable)(void);
72STATIC void (*sbus_pcmcia_intr_reinstall)(void); 72STATIC void (*sbus_pcmcia_intr_reinstall)(void);
73 73
74STATIC int (*sbus_pcmcia_intr)(void *) = sbus_spurious_intr; 74STATIC int (*sbus_pcmcia_intr)(void *) = sbus_spurious_intr;
75STATIC void *sbus_pcmcia_context; 75STATIC void *sbus_pcmcia_context;
76STATIC int (*sbus_usb_intr)(void *) = sbus_spurious_intr; 76STATIC int (*sbus_usb_intr)(void *) = sbus_spurious_intr;
77STATIC void *sbus_usb_context; 77STATIC void *sbus_usb_context;
78 78
79STATIC void sbus_init(int); 79STATIC void sbus_init(int);
80STATIC int sbus_intr(void *); 80STATIC int sbus_intr(void *);
81 81
82STATIC int sbus_match(device_t, cfdata_t, void *); 82STATIC int sbus_match(device_t, cfdata_t, void *);
83STATIC void sbus_attach(device_t, device_t, void *); 83STATIC void sbus_attach(device_t, device_t, void *);
84STATIC int sbus_search(device_t, cfdata_t, 84STATIC int sbus_search(device_t, cfdata_t,
85 const int *, void *); 85 const int *, void *);
86STATIC int sbus_print(void *, const char *); 86STATIC int sbus_print(void *, const char *);
87 87
88CFATTACH_DECL_NEW(sbus, sizeof (struct device), 88CFATTACH_DECL_NEW(sbus, 0,
89 sbus_match, sbus_attach, NULL, NULL); 89 sbus_match, sbus_attach, NULL, NULL);
90 90
91extern struct cfdriver sbus_cd; 91extern struct cfdriver sbus_cd;
92STATIC int __sbus_attached; 92STATIC int __sbus_attached;
93 93
94int 94int
95sbus_match(device_t parent, cfdata_t cf, void *aux) 95sbus_match(device_t parent, cfdata_t cf, void *aux)
96{ 96{
97 struct mainbus_attach_args *ma = aux; 97 struct mainbus_attach_args *ma = aux;
98 98
99 if (strcmp(ma->ma_name, sbus_cd.cd_name) != 0) 99 if (strcmp(ma->ma_name, sbus_cd.cd_name) != 0)
100 return (0); 100 return (0);
101 101
102 return (!__sbus_attached); 102 return (!__sbus_attached);
103} 103}
104 104
105void 105void
106sbus_attach(device_t parent, device_t self, void *aux) 106sbus_attach(device_t parent, device_t self, void *aux)
107{ 107{
108 int type = BOOTINFO_REF(BOOTINFO_PCMCIA_TYPE);  108 int type = BOOTINFO_REF(BOOTINFO_PCMCIA_TYPE);
109 109
110 printf(": controller type %d\n", type); 110 printf(": controller type %d\n", type);
111 111
112 /* Initialize SBUS controller */ 112 /* Initialize SBUS controller */
113 sbus_init(type); 113 sbus_init(type);
114 114
115 config_search(self, NULL, 115 config_search(self, NULL,
116 CFARGS(.search = sbus_search)); 116 CFARGS(.search = sbus_search));
117} 117}
118 118
119int 119int
120sbus_search(device_t parent, cfdata_t cf, 120sbus_search(device_t parent, cfdata_t cf,
121 const int *ldesc, void *aux) 121 const int *ldesc, void *aux)
122{ 122{
123 struct sbus_attach_args sa; 123 struct sbus_attach_args sa;
124 124
125 if (config_probe(parent, cf, &sa)) 125 if (config_probe(parent, cf, &sa))
126 config_attach(parent, cf, &sa, sbus_print, CFARGS_NONE); 126 config_attach(parent, cf, &sa, sbus_print, CFARGS_NONE);
127  127
128 return (0); 128 return (0);
129} 129}
130 130
131int 131int
132sbus_print(void *aux, const char *pnp) 132sbus_print(void *aux, const char *pnp)
133{ 133{
134 134
135 return (pnp ? QUIET : UNCONF); 135 return (pnp ? QUIET : UNCONF);
136} 136}
137 137
138void 138void
139sbus_init(int type) 139sbus_init(int type)
140{ 140{
141 /* install model dependent hook */ 141 /* install model dependent hook */
142#define SET_PCMCIA_INTR_OPS(x) \ 142#define SET_PCMCIA_INTR_OPS(x) \
143 sbus_pcmcia_intr_clear = sbus_type##x##_pcmcia_intr_clear; \ 143 sbus_pcmcia_intr_clear = sbus_type##x##_pcmcia_intr_clear; \
144 sbus_pcmcia_intr_enable = sbus_type##x##_pcmcia_intr_enable; \ 144 sbus_pcmcia_intr_enable = sbus_type##x##_pcmcia_intr_enable; \
145 sbus_pcmcia_intr_disable = sbus_type##x##_pcmcia_intr_disable; \ 145 sbus_pcmcia_intr_disable = sbus_type##x##_pcmcia_intr_disable; \
146 sbus_pcmcia_intr_reinstall = sbus_type##x##_pcmcia_intr_reinstall 146 sbus_pcmcia_intr_reinstall = sbus_type##x##_pcmcia_intr_reinstall
147 147
148 switch (type) { 148 switch (type) {
149 default: 149 default:
150 panic("unknown pcmcia controller type = %d", type); 150 panic("unknown pcmcia controller type = %d", type);
151 break; 151 break;
152 case 0: 152 case 0:
153 /* FALLTHROUGH */ 153 /* FALLTHROUGH */
154 case 1: 154 case 1:
155 /* FALLTHROUGH */ 155 /* FALLTHROUGH */
156 case 2: 156 case 2:
157 SET_PCMCIA_INTR_OPS(2); 157 SET_PCMCIA_INTR_OPS(2);
158 break; 158 break;
159 case 3: 159 case 3:
160 SET_PCMCIA_INTR_OPS(3); 160 SET_PCMCIA_INTR_OPS(3);
161 break; 161 break;
162 } 162 }
163#undef SET_PCMCIA_INTR_OPS 163#undef SET_PCMCIA_INTR_OPS
164 /* disable interrupt */ 164 /* disable interrupt */
165 (*sbus_pcmcia_intr_disable)(); 165 (*sbus_pcmcia_intr_disable)();
166 166
167 /* clear interrupt */ 167 /* clear interrupt */
168 (*sbus_pcmcia_intr_clear)(); 168 (*sbus_pcmcia_intr_clear)();
169 _reg_write_4(SBUS_SMFLG_REG, SMFLG_PCMCIA_INT); 169 _reg_write_4(SBUS_SMFLG_REG, SMFLG_PCMCIA_INT);
170 _reg_write_4(SBUS_SMFLG_REG, SMFLG_USB_INT);  170 _reg_write_4(SBUS_SMFLG_REG, SMFLG_USB_INT);
171 171
172 /* connect to INTC */ 172 /* connect to INTC */
173 intc_intr_establish(I_CH1_SBUS, IPL_BIO, sbus_intr, 0); 173 intc_intr_establish(I_CH1_SBUS, IPL_BIO, sbus_intr, 0);
174} 174}
175 175
176void * 176void *
177sbus_intr_establish(enum sbus_irq irq, int (*ih_func)(void *), void *ih_arg) 177sbus_intr_establish(enum sbus_irq irq, int (*ih_func)(void *), void *ih_arg)
178{ 178{
179 switch (irq) { 179 switch (irq) {
180 default: 180 default:
181 panic("unknown IRQ"); 181 panic("unknown IRQ");
182 break; 182 break;
183 case SBUS_IRQ_PCMCIA: 183 case SBUS_IRQ_PCMCIA:
184 sbus_pcmcia_intr = ih_func; 184 sbus_pcmcia_intr = ih_func;
185 sbus_pcmcia_context = ih_arg; 185 sbus_pcmcia_context = ih_arg;
186 (*sbus_pcmcia_intr_enable)(); 186 (*sbus_pcmcia_intr_enable)();
187 break; 187 break;
188 case SBUS_IRQ_USB: 188 case SBUS_IRQ_USB:
189 sbus_usb_intr = ih_func; 189 sbus_usb_intr = ih_func;
190 sbus_usb_context = ih_arg; 190 sbus_usb_context = ih_arg;
191 break; 191 break;
192 } 192 }
193 193
194 return (void *)irq; 194 return (void *)irq;
195} 195}
196 196
197void 197void
198sbus_intr_disestablish(void *handle) 198sbus_intr_disestablish(void *handle)
199{ 199{
200 int irq = (int)handle; 200 int irq = (int)handle;
201 201
202 switch (irq) { 202 switch (irq) {
203 default: 203 default:
204 panic("unknown IRQ"); 204 panic("unknown IRQ");
205 break; 205 break;
206 case SBUS_IRQ_PCMCIA: 206 case SBUS_IRQ_PCMCIA:
207 sbus_pcmcia_intr = sbus_spurious_intr; 207 sbus_pcmcia_intr = sbus_spurious_intr;
208 (*sbus_pcmcia_intr_disable)(); 208 (*sbus_pcmcia_intr_disable)();
209 break; 209 break;
210 case SBUS_IRQ_USB: 210 case SBUS_IRQ_USB:
211 sbus_usb_intr = sbus_spurious_intr; 211 sbus_usb_intr = sbus_spurious_intr;
212 break; 212 break;
213 } 213 }
214} 214}
215 215
216int 216int
217sbus_intr(void *arg) 217sbus_intr(void *arg)
218{ 218{
219 u_int32_t stat; 219 u_int32_t stat;
220 220
221 _playstation2_evcnt.sbus.ev_count++; 221 _playstation2_evcnt.sbus.ev_count++;
222 stat = _reg_read_4(SBUS_SMFLG_REG); 222 stat = _reg_read_4(SBUS_SMFLG_REG);
223 223
224 if (stat & SMFLG_PCMCIA_INT) { 224 if (stat & SMFLG_PCMCIA_INT) {
225 (*sbus_pcmcia_intr_clear)(); 225 (*sbus_pcmcia_intr_clear)();
226 _reg_write_4(SBUS_SMFLG_REG, SMFLG_PCMCIA_INT); 226 _reg_write_4(SBUS_SMFLG_REG, SMFLG_PCMCIA_INT);
227 (*sbus_pcmcia_intr)(sbus_pcmcia_context); 227 (*sbus_pcmcia_intr)(sbus_pcmcia_context);
228 } 228 }
229 229
230 if (stat & SMFLG_USB_INT) { 230 if (stat & SMFLG_USB_INT) {
231 _reg_write_4(SBUS_SMFLG_REG, SMFLG_USB_INT); 231 _reg_write_4(SBUS_SMFLG_REG, SMFLG_USB_INT);
232 (*sbus_usb_intr)(sbus_usb_context); 232 (*sbus_usb_intr)(sbus_usb_context);
233 } 233 }
234  234
235 (*sbus_pcmcia_intr_reinstall)(); 235 (*sbus_pcmcia_intr_reinstall)();
236 236
237 return (1); 237 return (1);
238} 238}
239 239
240int 240int
241sbus_spurious_intr(void *arg) 241sbus_spurious_intr(void *arg)
242{ 242{
243 243
244 printf("spurious interrupt.\n"); 244 printf("spurious interrupt.\n");
245 245
246 return (1); 246 return (1);
247} 247}
248 248
249/* SCPH-18000 */ 249/* SCPH-18000 */
250void 250void
251sbus_type2_pcmcia_intr_clear(void) 251sbus_type2_pcmcia_intr_clear(void)
252{ 252{
253 253
254 if (_reg_read_2(SBUS_PCMCIA_CSC1_REG16) & 0x080) 254 if (_reg_read_2(SBUS_PCMCIA_CSC1_REG16) & 0x080)
255 _reg_write_2(SBUS_PCMCIA_CSC1_REG16, 0xffff); 255 _reg_write_2(SBUS_PCMCIA_CSC1_REG16, 0xffff);
256} 256}
257 257
258void 258void
259sbus_type2_pcmcia_intr_enable(void) 259sbus_type2_pcmcia_intr_enable(void)
260{ 260{
261 261
262 _reg_write_2(SBUS_PCMCIA_TIMR_REG16, 0); 262 _reg_write_2(SBUS_PCMCIA_TIMR_REG16, 0);
263} 263}
264 264
265void 265void
266sbus_type2_pcmcia_intr_disable(void) 266sbus_type2_pcmcia_intr_disable(void)
267{ 267{
268 268
269 _reg_write_2(SBUS_PCMCIA_TIMR_REG16, 1); 269 _reg_write_2(SBUS_PCMCIA_TIMR_REG16, 1);
270} 270}
271 271
272void 272void
273sbus_type2_pcmcia_intr_reinstall(void) 273sbus_type2_pcmcia_intr_reinstall(void)
274{ 274{
275 u_int16_t r = _reg_read_2(SBUS_PCMCIA_TIMR_REG16); 275 u_int16_t r = _reg_read_2(SBUS_PCMCIA_TIMR_REG16);
276 276
277 _reg_write_2(SBUS_PCMCIA_TIMR_REG16, 1); 277 _reg_write_2(SBUS_PCMCIA_TIMR_REG16, 1);
278 _reg_write_2(SBUS_PCMCIA_TIMR_REG16, r); 278 _reg_write_2(SBUS_PCMCIA_TIMR_REG16, r);
279} 279}
280 280
281/* SCPH-30000/35000 */ 281/* SCPH-30000/35000 */
282void 282void
283sbus_type3_pcmcia_intr_clear(void) 283sbus_type3_pcmcia_intr_clear(void)
284{ 284{
285 /* nothing */ 285 /* nothing */
286} 286}
287 287
288void 288void
289sbus_type3_pcmcia_intr_enable(void) 289sbus_type3_pcmcia_intr_enable(void)
290{ 290{
291 291
292 _reg_write_2(SBUS_PCMCIA3_TIMR_REG16, 0); 292 _reg_write_2(SBUS_PCMCIA3_TIMR_REG16, 0);
293} 293}
294 294
295void 295void
296sbus_type3_pcmcia_intr_disable(void) 296sbus_type3_pcmcia_intr_disable(void)
297{ 297{
298 298
299 _reg_write_2(SBUS_PCMCIA3_TIMR_REG16, 1); 299 _reg_write_2(SBUS_PCMCIA3_TIMR_REG16, 1);
300} 300}
301 301
302void 302void
303sbus_type3_pcmcia_intr_reinstall(void) 303sbus_type3_pcmcia_intr_reinstall(void)
304{ 304{
305 u_int16_t r = _reg_read_2(SBUS_PCMCIA3_TIMR_REG16); 305 u_int16_t r = _reg_read_2(SBUS_PCMCIA3_TIMR_REG16);
306 306
307 _reg_write_2(SBUS_PCMCIA3_TIMR_REG16, 1); 307 _reg_write_2(SBUS_PCMCIA3_TIMR_REG16, 1);
308 _reg_write_2(SBUS_PCMCIA3_TIMR_REG16, r); 308 _reg_write_2(SBUS_PCMCIA3_TIMR_REG16, r);
309} 309}

cvs diff -r1.15 -r1.16 src/sys/arch/playstation2/dev/spd.c (switch to unified diff)

--- src/sys/arch/playstation2/dev/spd.c 2021/08/07 16:19:02 1.15
+++ src/sys/arch/playstation2/dev/spd.c 2022/02/11 17:30:48 1.16
@@ -1,276 +1,276 @@ @@ -1,276 +1,276 @@
1/* $NetBSD: spd.c,v 1.15 2021/08/07 16:19:02 thorpej Exp $ */ 1/* $NetBSD: spd.c,v 1.16 2022/02/11 17:30:48 riastradh Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 2001 The NetBSD Foundation, Inc. 4 * Copyright (c) 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 UCHIYAMA Yasushi. 8 * by UCHIYAMA Yasushi.
9 * 9 *
10 * Redistribution and use in source and binary forms, with or without 10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions 11 * modification, are permitted provided that the following conditions
12 * are met: 12 * are met:
13 * 1. Redistributions of source code must retain the above copyright 13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer. 14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright 15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the 16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution. 17 * documentation and/or other materials provided with the distribution.
18 * 18 *
19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE. 29 * POSSIBILITY OF SUCH DAMAGE.
30 */ 30 */
31 31
32#include <sys/cdefs.h> 32#include <sys/cdefs.h>
33__KERNEL_RCSID(0, "$NetBSD: spd.c,v 1.15 2021/08/07 16:19:02 thorpej Exp $"); 33__KERNEL_RCSID(0, "$NetBSD: spd.c,v 1.16 2022/02/11 17:30:48 riastradh Exp $");
34 34
35#include <sys/param.h> 35#include <sys/param.h>
36#include <sys/device.h> 36#include <sys/device.h>
37#include <sys/systm.h> 37#include <sys/systm.h>
38 38
39#include <machine/bootinfo.h> 39#include <machine/bootinfo.h>
40 40
41#include <playstation2/ee/eevar.h> 41#include <playstation2/ee/eevar.h>
42#include <playstation2/dev/sbusvar.h> 42#include <playstation2/dev/sbusvar.h>
43#include <playstation2/dev/spdvar.h> 43#include <playstation2/dev/spdvar.h>
44#include <playstation2/dev/spdreg.h> 44#include <playstation2/dev/spdreg.h>
45 45
46#ifdef DEBUG 46#ifdef DEBUG
47#define STATIC 47#define STATIC
48#else 48#else
49#define STATIC static 49#define STATIC static
50#endif 50#endif
51 51
52STATIC int spd_match(device_t, cfdata_t, void *); 52STATIC int spd_match(device_t, cfdata_t, void *);
53STATIC void spd_attach(device_t, device_t, void *); 53STATIC void spd_attach(device_t, device_t, void *);
54STATIC int spd_print(void *, const char *); 54STATIC int spd_print(void *, const char *);
55STATIC int spd_intr(void *); 55STATIC int spd_intr(void *);
56STATIC void __spd_eeprom_out(u_int8_t *, int); 56STATIC void __spd_eeprom_out(u_int8_t *, int);
57STATIC int __spd_eeprom_in(u_int8_t *); 57STATIC int __spd_eeprom_in(u_int8_t *);
58 58
59/* SPD device can't attach twice. because PS2 PC-Card slot is only one. */ 59/* SPD device can't attach twice. because PS2 PC-Card slot is only one. */
60STATIC struct { 60STATIC struct {
61 int (*func)(void *); 61 int (*func)(void *);
62 void *arg; 62 void *arg;
63 const char *name; 63 const char *name;
64} __spd_table[2]; 64} __spd_table[2];
65 65
66CFATTACH_DECL_NEW(spd, sizeof(struct device), 66CFATTACH_DECL_NEW(spd, 0,
67 spd_match, spd_attach, NULL, NULL); 67 spd_match, spd_attach, NULL, NULL);
68 68
69#ifdef DEBUG 69#ifdef DEBUG
70#define LEGAL_SLOT(slot) ((slot) >= 0 && (slot) < 2) 70#define LEGAL_SLOT(slot) ((slot) >= 0 && (slot) < 2)
71#endif 71#endif
72 72
73int 73int
74spd_match(device_t parent, cfdata_t cf, void *aux) 74spd_match(device_t parent, cfdata_t cf, void *aux)
75{ 75{
76  76
77 return ((BOOTINFO_REF(BOOTINFO_DEVCONF) == 77 return ((BOOTINFO_REF(BOOTINFO_DEVCONF) ==
78 BOOTINFO_DEVCONF_SPD_PRESENT)); 78 BOOTINFO_DEVCONF_SPD_PRESENT));
79} 79}
80 80
81void 81void
82spd_attach(device_t parent, device_t self, void *aux) 82spd_attach(device_t parent, device_t self, void *aux)
83{ 83{
84 struct spd_attach_args spa; 84 struct spd_attach_args spa;
85 85
86 printf(": PlayStation 2 HDD Unit\n"); 86 printf(": PlayStation 2 HDD Unit\n");
87 87
88 switch (BOOTINFO_REF(BOOTINFO_PCMCIA_TYPE)) { 88 switch (BOOTINFO_REF(BOOTINFO_PCMCIA_TYPE)) {
89 default: 89 default:
90 __spd_table[0].name = "<unknown product>"; 90 __spd_table[0].name = "<unknown product>";
91 break; 91 break;
92 case 0: 92 case 0:
93 /* FALLTHROUGH */ 93 /* FALLTHROUGH */
94 case 1: 94 case 1:
95 /* FALLTHROUGH */ 95 /* FALLTHROUGH */
96 case 2: 96 case 2:
97 __spd_table[SPD_HDD].name = "SCPH-20400"; 97 __spd_table[SPD_HDD].name = "SCPH-20400";
98 __spd_table[SPD_NIC].name = "SCPH-10190"; 98 __spd_table[SPD_NIC].name = "SCPH-10190";
99 break; 99 break;
100 case 3: 100 case 3:
101 __spd_table[SPD_HDD].name = "SCPH-10260"; 101 __spd_table[SPD_HDD].name = "SCPH-10260";
102 __spd_table[SPD_NIC].name = "SCPH-10260"; 102 __spd_table[SPD_NIC].name = "SCPH-10260";
103 break; 103 break;
104 } 104 }
105 105
106 /* disable all */ 106 /* disable all */
107 _reg_write_2(SPD_INTR_ENABLE_REG16, 0); 107 _reg_write_2(SPD_INTR_ENABLE_REG16, 0);
108 _reg_write_2(SPD_INTR_CLEAR_REG16, _reg_read_2(SPD_INTR_STATUS_REG16)); 108 _reg_write_2(SPD_INTR_CLEAR_REG16, _reg_read_2(SPD_INTR_STATUS_REG16));
109 109
110 spa.spa_slot = SPD_HDD; 110 spa.spa_slot = SPD_HDD;
111 spa.spa_product_name = __spd_table[SPD_HDD].name; 111 spa.spa_product_name = __spd_table[SPD_HDD].name;
112 config_found(self, &spa, spd_print, CFARGS_NONE); 112 config_found(self, &spa, spd_print, CFARGS_NONE);
113 113
114 spa.spa_slot = SPD_NIC; 114 spa.spa_slot = SPD_NIC;
115 spa.spa_product_name = __spd_table[SPD_NIC].name; 115 spa.spa_product_name = __spd_table[SPD_NIC].name;
116 config_found(self, &spa, spd_print, CFARGS_NONE); 116 config_found(self, &spa, spd_print, CFARGS_NONE);
117 117
118 sbus_intr_establish(SBUS_IRQ_PCMCIA, spd_intr, 0); 118 sbus_intr_establish(SBUS_IRQ_PCMCIA, spd_intr, 0);
119} 119}
120 120
121int 121int
122spd_print(void *aux, const char *pnp) 122spd_print(void *aux, const char *pnp)
123{ 123{
124 struct spd_attach_args *spa = aux; 124 struct spd_attach_args *spa = aux;
125 125
126 if (pnp) 126 if (pnp)
127 aprint_normal("%s at %s", __spd_table[spa->spa_slot].name, pnp); 127 aprint_normal("%s at %s", __spd_table[spa->spa_slot].name, pnp);
128 128
129 return (UNCONF); 129 return (UNCONF);
130} 130}
131 131
132int 132int
133spd_intr(void *arg) 133spd_intr(void *arg)
134{ 134{
135 u_int16_t r; 135 u_int16_t r;
136  136
137 r = _reg_read_2(SPD_INTR_STATUS_REG16); 137 r = _reg_read_2(SPD_INTR_STATUS_REG16);
138 138
139 /* HDD (SCPH-20400) */ 139 /* HDD (SCPH-20400) */
140 if ((r & SPD_INTR_HDD) != 0) 140 if ((r & SPD_INTR_HDD) != 0)
141 if (__spd_table[SPD_HDD].func != NULL) 141 if (__spd_table[SPD_HDD].func != NULL)
142 (*__spd_table[SPD_HDD].func)(__spd_table[SPD_HDD].arg); 142 (*__spd_table[SPD_HDD].func)(__spd_table[SPD_HDD].arg);
143 143
144 /* Network (SCPH-10190) */ 144 /* Network (SCPH-10190) */
145 if ((r & (SPD_INTR_EMAC3 | SPD_INTR_RXEND | SPD_INTR_TXEND | 145 if ((r & (SPD_INTR_EMAC3 | SPD_INTR_RXEND | SPD_INTR_TXEND |
146 SPD_INTR_RXDNV | SPD_INTR_TXDNV)) != 0) 146 SPD_INTR_RXDNV | SPD_INTR_TXDNV)) != 0)
147 if (__spd_table[SPD_NIC].func) 147 if (__spd_table[SPD_NIC].func)
148 (*__spd_table[SPD_NIC].func)(__spd_table[SPD_NIC].arg); 148 (*__spd_table[SPD_NIC].func)(__spd_table[SPD_NIC].arg);
149 149
150 /* reinstall */ 150 /* reinstall */
151 r = _reg_read_2(SPD_INTR_ENABLE_REG16); 151 r = _reg_read_2(SPD_INTR_ENABLE_REG16);
152 _reg_write_2(SPD_INTR_ENABLE_REG16, 0); 152 _reg_write_2(SPD_INTR_ENABLE_REG16, 0);
153 _reg_write_2(SPD_INTR_ENABLE_REG16, r); 153 _reg_write_2(SPD_INTR_ENABLE_REG16, r);
154 154
155 return (1); 155 return (1);
156} 156}
157 157
158void * 158void *
159spd_intr_establish(enum spd_slot slot, int (*func)(void *), void *arg) 159spd_intr_establish(enum spd_slot slot, int (*func)(void *), void *arg)
160{ 160{
161 161
162 KDASSERT(LEGAL_SLOT(slot)); 162 KDASSERT(LEGAL_SLOT(slot));
163 KDASSERT(__spd_table[slot].func == 0); 163 KDASSERT(__spd_table[slot].func == 0);
164 164
165 __spd_table[slot].func = func; 165 __spd_table[slot].func = func;
166 __spd_table[slot].arg = arg; 166 __spd_table[slot].arg = arg;
167 167
168 return ((void *)slot); 168 return ((void *)slot);
169} 169}
170 170
171void 171void
172spd_intr_disestablish(void *handle) 172spd_intr_disestablish(void *handle)
173{ 173{
174 int slot = (int)handle; 174 int slot = (int)handle;
175 175
176 KDASSERT(LEGAL_SLOT(slot)); 176 KDASSERT(LEGAL_SLOT(slot));
177 177
178 __spd_table[slot].func = 0; 178 __spd_table[slot].func = 0;
179} 179}
180 180
181/* 181/*
182 * EEPROM access 182 * EEPROM access
183 */ 183 */
184void 184void
185spd_eeprom_read(int addr, u_int16_t *data, int n) 185spd_eeprom_read(int addr, u_int16_t *data, int n)
186{ 186{
187 int i, j, s; 187 int i, j, s;
188 u_int8_t r; 188 u_int8_t r;
189 189
190 s = _intr_suspend(); 190 s = _intr_suspend();
191 191
192 /* set direction */ 192 /* set direction */
193 _reg_write_1(SPD_IO_DIR_REG8, SPD_IO_CLK | SPD_IO_CS | SPD_IO_IN); 193 _reg_write_1(SPD_IO_DIR_REG8, SPD_IO_CLK | SPD_IO_CS | SPD_IO_IN);
194 194
195 /* chip select high */ 195 /* chip select high */
196 r = 0; 196 r = 0;
197 _reg_write_1(SPD_IO_DATA_REG8, r); 197 _reg_write_1(SPD_IO_DATA_REG8, r);
198 delay(1); 198 delay(1);
199 r |= SPD_IO_CS; 199 r |= SPD_IO_CS;
200 r &= ~(SPD_IO_IN | SPD_IO_CLK); 200 r &= ~(SPD_IO_IN | SPD_IO_CLK);
201 _reg_write_1(SPD_IO_DATA_REG8, r);  201 _reg_write_1(SPD_IO_DATA_REG8, r);
202 delay(1); 202 delay(1);
203 203
204 /* put start bit */ 204 /* put start bit */
205 __spd_eeprom_out(&r, 1); 205 __spd_eeprom_out(&r, 1);
206 206
207 /* put op code (read) */ 207 /* put op code (read) */
208 __spd_eeprom_out(&r, 1); 208 __spd_eeprom_out(&r, 1);
209 __spd_eeprom_out(&r, 0); 209 __spd_eeprom_out(&r, 0);
210 210
211 /* set address */ 211 /* set address */
212 for (i = 0; i < 6; i++, addr <<= 1) 212 for (i = 0; i < 6; i++, addr <<= 1)
213 __spd_eeprom_out(&r, addr & 0x20); 213 __spd_eeprom_out(&r, addr & 0x20);
214  214
215 /* get data */ 215 /* get data */
216 for (i = 0; i < n; i++, data++) 216 for (i = 0; i < n; i++, data++)
217 for (*data = 0, j = 15; j >= 0; j--) 217 for (*data = 0, j = 15; j >= 0; j--)
218 *data |= (__spd_eeprom_in(&r) << j); 218 *data |= (__spd_eeprom_in(&r) << j);
219 219
220 /* chip select low */ 220 /* chip select low */
221 r &= ~(SPD_IO_CS | SPD_IO_IN | SPD_IO_CLK); 221 r &= ~(SPD_IO_CS | SPD_IO_IN | SPD_IO_CLK);
222 _reg_write_1(SPD_IO_DATA_REG8, r); 222 _reg_write_1(SPD_IO_DATA_REG8, r);
223 delay(2); 223 delay(2);
224 224
225 _intr_resume(s); 225 _intr_resume(s);
226} 226}
227 227
228void 228void
229__spd_eeprom_out(u_int8_t *rp, int onoff) 229__spd_eeprom_out(u_int8_t *rp, int onoff)
230{ 230{
231 u_int8_t r = *rp; 231 u_int8_t r = *rp;
232 232
233 if (onoff) 233 if (onoff)
234 r |= SPD_IO_IN; 234 r |= SPD_IO_IN;
235 else 235 else
236 r &= ~SPD_IO_IN; 236 r &= ~SPD_IO_IN;
237 237
238 r &= ~SPD_IO_CLK; 238 r &= ~SPD_IO_CLK;
239 _reg_write_1(SPD_IO_DATA_REG8, r); 239 _reg_write_1(SPD_IO_DATA_REG8, r);
240 delay(1); 240 delay(1);
241  241
242 r |= SPD_IO_CLK; 242 r |= SPD_IO_CLK;
243 _reg_write_1(SPD_IO_DATA_REG8, r); 243 _reg_write_1(SPD_IO_DATA_REG8, r);
244 delay(1); 244 delay(1);
245 245
246 r &= ~SPD_IO_CLK; 246 r &= ~SPD_IO_CLK;
247 _reg_write_1(SPD_IO_DATA_REG8, r); 247 _reg_write_1(SPD_IO_DATA_REG8, r);
248 delay(1); 248 delay(1);
249 249
250 *rp = r; 250 *rp = r;
251} 251}
252 252
253int 253int
254__spd_eeprom_in(u_int8_t *rp) 254__spd_eeprom_in(u_int8_t *rp)
255{ 255{
256 int ret; 256 int ret;
257 u_int8_t r = *rp; 257 u_int8_t r = *rp;
258 258
259 r &= ~(SPD_IO_IN | SPD_IO_CLK); 259 r &= ~(SPD_IO_IN | SPD_IO_CLK);
260 _reg_write_1(SPD_IO_DATA_REG8, r); 260 _reg_write_1(SPD_IO_DATA_REG8, r);
261 delay(1); 261 delay(1);
262 262
263 r |= SPD_IO_CLK; 263 r |= SPD_IO_CLK;
264 _reg_write_1(SPD_IO_DATA_REG8, r); 264 _reg_write_1(SPD_IO_DATA_REG8, r);
265 delay(1); 265 delay(1);
266 ret = (_reg_read_1(SPD_IO_DATA_REG8) >> 4) & 0x1; 266 ret = (_reg_read_1(SPD_IO_DATA_REG8) >> 4) & 0x1;
267 267
268 r &= ~SPD_IO_CLK; 268 r &= ~SPD_IO_CLK;
269 _reg_write_1(SPD_IO_DATA_REG8, r); 269 _reg_write_1(SPD_IO_DATA_REG8, r);
270 delay(1); 270 delay(1);
271 271
272 *rp = r; 272 *rp = r;
273 273
274 return (ret); 274 return (ret);
275} 275}
276 276

cvs diff -r1.18 -r1.19 src/sys/arch/playstation2/playstation2/mainbus.c (switch to unified diff)

--- src/sys/arch/playstation2/playstation2/mainbus.c 2021/08/07 16:19:02 1.18
+++ src/sys/arch/playstation2/playstation2/mainbus.c 2022/02/11 17:30:48 1.19
@@ -1,86 +1,86 @@ @@ -1,86 +1,86 @@
1/* $NetBSD: mainbus.c,v 1.18 2021/08/07 16:19:02 thorpej Exp $ */ 1/* $NetBSD: mainbus.c,v 1.19 2022/02/11 17:30:48 riastradh Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 2001 The NetBSD Foundation, Inc. 4 * Copyright (c) 2001 The NetBSD Foundation, Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer. 11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright 12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the 13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution. 14 * documentation and/or other materials provided with the distribution.
15 * 15 *
16 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 16 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
17 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 17 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
18 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 18 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
19 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 19 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
20 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 20 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26 * POSSIBILITY OF SUCH DAMAGE. 26 * POSSIBILITY OF SUCH DAMAGE.
27 */ 27 */
28 28
29#include <sys/cdefs.h> 29#include <sys/cdefs.h>
30__KERNEL_RCSID(0, "$NetBSD: mainbus.c,v 1.18 2021/08/07 16:19:02 thorpej Exp $"); 30__KERNEL_RCSID(0, "$NetBSD: mainbus.c,v 1.19 2022/02/11 17:30:48 riastradh Exp $");
31 31
32#include <sys/param.h> 32#include <sys/param.h>
33#include <sys/device.h> 33#include <sys/device.h>
34#include <sys/systm.h> 34#include <sys/systm.h>
35 35
36#include <machine/autoconf.h> 36#include <machine/autoconf.h>
37 37
38static int mainbus_match(device_t, cfdata_t, void *); 38static int mainbus_match(device_t, cfdata_t, void *);
39static void mainbus_attach(device_t, device_t, void *); 39static void mainbus_attach(device_t, device_t, void *);
40static int mainbus_search(device_t, cfdata_t, 40static int mainbus_search(device_t, cfdata_t,
41 const int *, void *); 41 const int *, void *);
42static int mainbus_print(void *, const char *); 42static int mainbus_print(void *, const char *);
43 43
44CFATTACH_DECL_NEW(mainbus, sizeof(struct device), 44CFATTACH_DECL_NEW(mainbus, 0,
45 mainbus_match, mainbus_attach, NULL, NULL); 45 mainbus_match, mainbus_attach, NULL, NULL);
46 46
47static int 47static int
48mainbus_match(device_t parent, cfdata_t cf, void *aux) 48mainbus_match(device_t parent, cfdata_t cf, void *aux)
49{ 49{
50 50
51 return (1); 51 return (1);
52} 52}
53 53
54static void 54static void
55mainbus_attach(device_t parent, device_t self, void *aux) 55mainbus_attach(device_t parent, device_t self, void *aux)
56{ 56{
57 57
58 printf("\n"); 58 printf("\n");
59 59
60 /* attach CPU first */ 60 /* attach CPU first */
61 config_found(self, &(struct mainbus_attach_args){.ma_name = "cpu"}, 61 config_found(self, &(struct mainbus_attach_args){.ma_name = "cpu"},
62 mainbus_print, CFARGS_NONE); 62 mainbus_print, CFARGS_NONE);
63 63
64 config_search(self, NULL, 64 config_search(self, NULL,
65 CFARGS(.search = mainbus_search)); 65 CFARGS(.search = mainbus_search));
66} 66}
67 67
68static int 68static int
69mainbus_search(device_t parent, cfdata_t cf, 69mainbus_search(device_t parent, cfdata_t cf,
70 const int *ldesc, void *aux) 70 const int *ldesc, void *aux)
71{ 71{
72 struct mainbus_attach_args ma; 72 struct mainbus_attach_args ma;
73 73
74 ma.ma_name = cf->cf_name; 74 ma.ma_name = cf->cf_name;
75 if (config_probe(parent, cf, &ma)) 75 if (config_probe(parent, cf, &ma))
76 config_attach(parent, cf, &ma, mainbus_print, CFARGS_NONE); 76 config_attach(parent, cf, &ma, mainbus_print, CFARGS_NONE);
77  77
78 return (0); 78 return (0);
79} 79}
80 80
81static int 81static int
82mainbus_print(void *aux, const char *pnp) 82mainbus_print(void *aux, const char *pnp)
83{ 83{
84 84
85 return (pnp ? QUIET : UNCONF); 85 return (pnp ? QUIET : UNCONF);
86} 86}