Mon Jan 30 04:25:15 2012 UTC ()
avoid writing 1 byte beyond the end of the string promlib.c has given us.
instead of forcing a nul byte afterwards, KASSERT() that the final byte
already is a nul.  if there are broken proms... well, we can fix them.

this, plus one more change, allows my SS20 to boot multiuser.


(mrg)
diff -r1.33 -r1.34 src/sys/arch/sparc/dev/ebus.c
diff -r1.75 -r1.76 src/sys/arch/sparc/dev/sbus.c
diff -r1.59 -r1.60 src/sys/arch/sparc64/dev/ebus.c
diff -r1.92 -r1.93 src/sys/arch/sparc64/dev/sbus.c

cvs diff -r1.33 -r1.34 src/sys/arch/sparc/dev/ebus.c (expand / switch to unified diff)

--- src/sys/arch/sparc/dev/ebus.c 2011/07/18 00:31:13 1.33
+++ src/sys/arch/sparc/dev/ebus.c 2012/01/30 04:25:14 1.34
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: ebus.c,v 1.33 2011/07/18 00:31:13 mrg Exp $ */ 1/* $NetBSD: ebus.c,v 1.34 2012/01/30 04:25:14 mrg Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 1999, 2000 Matthew R. Green 4 * Copyright (c) 1999, 2000 Matthew R. Green
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.
@@ -22,27 +22,27 @@ @@ -22,27 +22,27 @@
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
23 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 23 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
24 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 24 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 * SUCH DAMAGE. 26 * SUCH DAMAGE.
27 */ 27 */
28 28
29/* 29/*
30 * EBus support for PCI based SPARC systems (ms-IIep, Ultra). 30 * EBus support for PCI based SPARC systems (ms-IIep, Ultra).
31 * EBus is documented in PCIO manual (Sun Part#: 802-7837-01). 31 * EBus is documented in PCIO manual (Sun Part#: 802-7837-01).
32 */ 32 */
33 33
34#include <sys/cdefs.h> 34#include <sys/cdefs.h>
35__KERNEL_RCSID(0, "$NetBSD: ebus.c,v 1.33 2011/07/18 00:31:13 mrg Exp $"); 35__KERNEL_RCSID(0, "$NetBSD: ebus.c,v 1.34 2012/01/30 04:25:14 mrg Exp $");
36 36
37#if defined(DEBUG) && !defined(EBUS_DEBUG) 37#if defined(DEBUG) && !defined(EBUS_DEBUG)
38#define EBUS_DEBUG 38#define EBUS_DEBUG
39#endif 39#endif
40 40
41#ifdef EBUS_DEBUG 41#ifdef EBUS_DEBUG
42#define EDB_PROM 0x01 42#define EDB_PROM 0x01
43#define EDB_CHILD 0x02 43#define EDB_CHILD 0x02
44#define EDB_INTRMAP 0x04 44#define EDB_INTRMAP 0x04
45#define EDB_BUSMAP 0x08 45#define EDB_BUSMAP 0x08
46#define EDB_BUSDMA 0x10 46#define EDB_BUSDMA 0x10
47#define EDB_INTR 0x20 47#define EDB_INTR 0x20
48int ebus_debug = 0; 48int ebus_debug = 0;
@@ -322,27 +322,27 @@ ebus_attach(device_t parent, device_t se @@ -322,27 +322,27 @@ ebus_attach(device_t parent, device_t se
322 322
323static int 323static int
324ebus_setup_attach_args(struct ebus_softc *sc, 324ebus_setup_attach_args(struct ebus_softc *sc,
325 bus_space_tag_t bustag, bus_dma_tag_t dmatag, int node, 325 bus_space_tag_t bustag, bus_dma_tag_t dmatag, int node,
326 struct ebus_attach_args *ea) 326 struct ebus_attach_args *ea)
327{ 327{
328 int n, err; 328 int n, err;
329 329
330 memset(ea, 0, sizeof(struct ebus_attach_args)); 330 memset(ea, 0, sizeof(struct ebus_attach_args));
331 331
332 err = prom_getprop(node, "name", 1, &n, &ea->ea_name); 332 err = prom_getprop(node, "name", 1, &n, &ea->ea_name);
333 if (err != 0) 333 if (err != 0)
334 return (err); 334 return (err);
335 ea->ea_name[n] = '\0'; 335 KASSERT(ea->ea_name[n-1] == '\0');
336 336
337 ea->ea_node = node; 337 ea->ea_node = node;
338 ea->ea_bustag = bustag; 338 ea->ea_bustag = bustag;
339 ea->ea_dmatag = dmatag; 339 ea->ea_dmatag = dmatag;
340 340
341 err = prom_getprop(node, "reg", sizeof(struct ebus_regs), 341 err = prom_getprop(node, "reg", sizeof(struct ebus_regs),
342 &ea->ea_nreg, &ea->ea_reg); 342 &ea->ea_nreg, &ea->ea_reg);
343 if (err != 0) 343 if (err != 0)
344 return (err); 344 return (err);
345 345
346 /* 346 /*
347 * On Ultra the bar is the _offset_ of the BAR in PCI config 347 * On Ultra the bar is the _offset_ of the BAR in PCI config
348 * space but in (some?) ms-IIep systems (e.g. Krups) it's the 348 * space but in (some?) ms-IIep systems (e.g. Krups) it's the

cvs diff -r1.75 -r1.76 src/sys/arch/sparc/dev/sbus.c (expand / switch to unified diff)

--- src/sys/arch/sparc/dev/sbus.c 2011/07/01 18:50:41 1.75
+++ src/sys/arch/sparc/dev/sbus.c 2012/01/30 04:25:14 1.76
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: sbus.c,v 1.75 2011/07/01 18:50:41 dyoung Exp $ */ 1/* $NetBSD: sbus.c,v 1.76 2012/01/30 04:25:14 mrg Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 1998 The NetBSD Foundation, Inc. 4 * Copyright (c) 1998 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 Paul Kranenburg. 8 * by Paul Kranenburg.
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.
@@ -64,27 +64,27 @@ @@ -64,27 +64,27 @@
64 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 64 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
65 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 65 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
66 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 66 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
67 * SUCH DAMAGE. 67 * SUCH DAMAGE.
68 * 68 *
69 * @(#)sbus.c 8.1 (Berkeley) 6/11/93 69 * @(#)sbus.c 8.1 (Berkeley) 6/11/93
70 */ 70 */
71 71
72/* 72/*
73 * Sbus stuff. 73 * Sbus stuff.
74 */ 74 */
75 75
76#include <sys/cdefs.h> 76#include <sys/cdefs.h>
77__KERNEL_RCSID(0, "$NetBSD: sbus.c,v 1.75 2011/07/01 18:50:41 dyoung Exp $"); 77__KERNEL_RCSID(0, "$NetBSD: sbus.c,v 1.76 2012/01/30 04:25:14 mrg Exp $");
78 78
79#include <sys/param.h> 79#include <sys/param.h>
80#include <sys/malloc.h> 80#include <sys/malloc.h>
81#include <sys/kernel.h> 81#include <sys/kernel.h>
82#include <sys/systm.h> 82#include <sys/systm.h>
83#include <sys/device.h> 83#include <sys/device.h>
84 84
85#include <uvm/uvm_extern.h> 85#include <uvm/uvm_extern.h>
86 86
87#include <machine/autoconf.h> 87#include <machine/autoconf.h>
88#include <sys/bus.h> 88#include <sys/bus.h>
89#include <sparc/dev/sbusreg.h> 89#include <sparc/dev/sbusreg.h>
90#include <dev/sbus/sbusvar.h> 90#include <dev/sbus/sbusvar.h>
@@ -434,27 +434,27 @@ sbus_attach_common(struct sbus_softc *sc @@ -434,27 +434,27 @@ sbus_attach_common(struct sbus_softc *sc
434} 434}
435 435
436int 436int
437sbus_setup_attach_args(struct sbus_softc *sc, 437sbus_setup_attach_args(struct sbus_softc *sc,
438 bus_space_tag_t bustag, bus_dma_tag_t dmatag, int node, 438 bus_space_tag_t bustag, bus_dma_tag_t dmatag, int node,
439 struct sbus_attach_args *sa) 439 struct sbus_attach_args *sa)
440{ 440{
441 int n, error; 441 int n, error;
442 442
443 memset(sa, 0, sizeof(struct sbus_attach_args)); 443 memset(sa, 0, sizeof(struct sbus_attach_args));
444 error = prom_getprop(node, "name", 1, &n, &sa->sa_name); 444 error = prom_getprop(node, "name", 1, &n, &sa->sa_name);
445 if (error != 0) 445 if (error != 0)
446 return (error); 446 return (error);
447 sa->sa_name[n] = '\0'; 447 KASSERT(sa->sa_name[n-1] == '\0');
448 448
449 sa->sa_bustag = bustag; 449 sa->sa_bustag = bustag;
450 sa->sa_dmatag = dmatag; 450 sa->sa_dmatag = dmatag;
451 sa->sa_node = node; 451 sa->sa_node = node;
452 sa->sa_frequency = sc->sc_clockfreq; 452 sa->sa_frequency = sc->sc_clockfreq;
453 453
454 error = prom_getprop(node, "reg", sizeof(struct openprom_addr), 454 error = prom_getprop(node, "reg", sizeof(struct openprom_addr),
455 &sa->sa_nreg, &sa->sa_reg); 455 &sa->sa_nreg, &sa->sa_reg);
456 if (error != 0) { 456 if (error != 0) {
457 char buf[32]; 457 char buf[32];
458 if (error != ENOENT || 458 if (error != ENOENT ||
459 !node_has_property(node, "device_type") || 459 !node_has_property(node, "device_type") ||
460 strcmp(prom_getpropstringA(node, "device_type", buf, sizeof buf), 460 strcmp(prom_getpropstringA(node, "device_type", buf, sizeof buf),

cvs diff -r1.59 -r1.60 src/sys/arch/sparc64/dev/ebus.c (expand / switch to unified diff)

--- src/sys/arch/sparc64/dev/ebus.c 2011/07/20 12:06:00 1.59
+++ src/sys/arch/sparc64/dev/ebus.c 2012/01/30 04:25:15 1.60
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: ebus.c,v 1.59 2011/07/20 12:06:00 macallan Exp $ */ 1/* $NetBSD: ebus.c,v 1.60 2012/01/30 04:25:15 mrg Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 1999, 2000, 2001 Matthew R. Green 4 * Copyright (c) 1999, 2000, 2001 Matthew R. Green
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.
@@ -17,27 +17,27 @@ @@ -17,27 +17,27 @@
17 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 17 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 18 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 19 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
20 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 20 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
21 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
23 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 23 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
24 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 24 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 * SUCH DAMAGE. 26 * SUCH DAMAGE.
27 */ 27 */
28 28
29#include <sys/cdefs.h> 29#include <sys/cdefs.h>
30__KERNEL_RCSID(0, "$NetBSD: ebus.c,v 1.59 2011/07/20 12:06:00 macallan Exp $"); 30__KERNEL_RCSID(0, "$NetBSD: ebus.c,v 1.60 2012/01/30 04:25:15 mrg Exp $");
31 31
32#include "opt_ddb.h" 32#include "opt_ddb.h"
33 33
34/* 34/*
35 * UltraSPARC 5 and beyond ebus support. 35 * UltraSPARC 5 and beyond ebus support.
36 * 36 *
37 * note that this driver is not complete: 37 * note that this driver is not complete:
38 * - interrupt establish is written and appears to work 38 * - interrupt establish is written and appears to work
39 * - bus map code is written and appears to work 39 * - bus map code is written and appears to work
40 * - ebus2 DMA code is completely unwritten, we just punt to 40 * - ebus2 DMA code is completely unwritten, we just punt to
41 * the iommu. 41 * the iommu.
42 */ 42 */
43 43
@@ -216,27 +216,27 @@ ebus_attach(device_t parent, device_t se @@ -216,27 +216,27 @@ ebus_attach(device_t parent, device_t se
216int ebus_setup_attach_args(struct ebus_softc *, int, 216int ebus_setup_attach_args(struct ebus_softc *, int,
217 struct ebus_attach_args *); 217 struct ebus_attach_args *);
218int 218int
219ebus_setup_attach_args(struct ebus_softc *sc, int node, 219ebus_setup_attach_args(struct ebus_softc *sc, int node,
220 struct ebus_attach_args *ea) 220 struct ebus_attach_args *ea)
221{ 221{
222 int n, rv; 222 int n, rv;
223 223
224 memset(ea, 0, sizeof(struct ebus_attach_args)); 224 memset(ea, 0, sizeof(struct ebus_attach_args));
225 n = 0; 225 n = 0;
226 rv = prom_getprop(node, "name", 1, &n, &ea->ea_name); 226 rv = prom_getprop(node, "name", 1, &n, &ea->ea_name);
227 if (rv != 0) 227 if (rv != 0)
228 return (rv); 228 return (rv);
229 ea->ea_name[n] = '\0'; 229 KASSERT(ea->ea_name[n-1] == '\0');
230 230
231 ea->ea_node = node; 231 ea->ea_node = node;
232 ea->ea_bustag = sc->sc_childbustag; 232 ea->ea_bustag = sc->sc_childbustag;
233 ea->ea_dmatag = sc->sc_dmatag; 233 ea->ea_dmatag = sc->sc_dmatag;
234 234
235 rv = prom_getprop(node, "reg", sizeof(struct ebus_regs), &ea->ea_nreg, 235 rv = prom_getprop(node, "reg", sizeof(struct ebus_regs), &ea->ea_nreg,
236 &ea->ea_reg); 236 &ea->ea_reg);
237 if (rv) 237 if (rv)
238 return (rv); 238 return (rv);
239 239
240 rv = prom_getprop(node, "address", sizeof(uint32_t), &ea->ea_nvaddr, 240 rv = prom_getprop(node, "address", sizeof(uint32_t), &ea->ea_nvaddr,
241 &ea->ea_vaddr); 241 &ea->ea_vaddr);
242 if (rv != ENOENT) { 242 if (rv != ENOENT) {

cvs diff -r1.92 -r1.93 src/sys/arch/sparc64/dev/sbus.c (expand / switch to unified diff)

--- src/sys/arch/sparc64/dev/sbus.c 2011/09/04 12:17:14 1.92
+++ src/sys/arch/sparc64/dev/sbus.c 2012/01/30 04:25:15 1.93
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: sbus.c,v 1.92 2011/09/04 12:17:14 nakayama Exp $ */ 1/* $NetBSD: sbus.c,v 1.93 2012/01/30 04:25:15 mrg Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 1999-2002 Eduardo Horvath 4 * Copyright (c) 1999-2002 Eduardo Horvath
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.
@@ -24,27 +24,27 @@ @@ -24,27 +24,27 @@
24 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 24 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
25 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 25 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
26 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28 * SUCH DAMAGE. 28 * SUCH DAMAGE.
29 */ 29 */
30 30
31 31
32/* 32/*
33 * Sbus stuff. 33 * Sbus stuff.
34 */ 34 */
35 35
36#include <sys/cdefs.h> 36#include <sys/cdefs.h>
37__KERNEL_RCSID(0, "$NetBSD: sbus.c,v 1.92 2011/09/04 12:17:14 nakayama Exp $"); 37__KERNEL_RCSID(0, "$NetBSD: sbus.c,v 1.93 2012/01/30 04:25:15 mrg Exp $");
38 38
39#include "opt_ddb.h" 39#include "opt_ddb.h"
40 40
41#include <sys/param.h> 41#include <sys/param.h>
42#include <sys/extent.h> 42#include <sys/extent.h>
43#include <sys/malloc.h> 43#include <sys/malloc.h>
44#include <sys/systm.h> 44#include <sys/systm.h>
45#include <sys/device.h> 45#include <sys/device.h>
46#include <sys/reboot.h> 46#include <sys/reboot.h>
47 47
48#include <sys/bus.h> 48#include <sys/bus.h>
49#include <machine/openfirm.h> 49#include <machine/openfirm.h>
50 50
@@ -305,27 +305,27 @@ int @@ -305,27 +305,27 @@ int
305sbus_setup_attach_args(struct sbus_softc *sc, bus_space_tag_t bustag, 305sbus_setup_attach_args(struct sbus_softc *sc, bus_space_tag_t bustag,
306 bus_dma_tag_t dmatag, int node, struct sbus_attach_args *sa) 306 bus_dma_tag_t dmatag, int node, struct sbus_attach_args *sa)
307{ 307{
308 /*struct openprom_addr sbusreg;*/ 308 /*struct openprom_addr sbusreg;*/
309 /*int base;*/ 309 /*int base;*/
310 int error; 310 int error;
311 int n; 311 int n;
312 312
313 memset(sa, 0, sizeof(struct sbus_attach_args)); 313 memset(sa, 0, sizeof(struct sbus_attach_args));
314 n = 0; 314 n = 0;
315 error = prom_getprop(node, "name", 1, &n, &sa->sa_name); 315 error = prom_getprop(node, "name", 1, &n, &sa->sa_name);
316 if (error != 0) 316 if (error != 0)
317 return (error); 317 return (error);
318 sa->sa_name[n] = '\0'; 318 KASSERT(sa->sa_name[n-1] == '\0');
319 319
320 sa->sa_bustag = bustag; 320 sa->sa_bustag = bustag;
321 sa->sa_dmatag = dmatag; 321 sa->sa_dmatag = dmatag;
322 sa->sa_node = node; 322 sa->sa_node = node;
323 sa->sa_frequency = sc->sc_clockfreq; 323 sa->sa_frequency = sc->sc_clockfreq;
324 324
325 error = prom_getprop(node, "reg", sizeof(struct openprom_addr), 325 error = prom_getprop(node, "reg", sizeof(struct openprom_addr),
326 &sa->sa_nreg, &sa->sa_reg); 326 &sa->sa_nreg, &sa->sa_reg);
327 if (error != 0) { 327 if (error != 0) {
328 char buf[32]; 328 char buf[32];
329 if (error != ENOENT || 329 if (error != ENOENT ||
330 !node_has_property(node, "device_type") || 330 !node_has_property(node, "device_type") ||
331 strcmp(prom_getpropstringA(node, "device_type", buf, sizeof buf), 331 strcmp(prom_getpropstringA(node, "device_type", buf, sizeof buf),