sbus.c revision 1.24 1 /* $NetBSD: sbus.c,v 1.24 1998/04/18 19:00:18 pk Exp $ */
2
3 /*-
4 * Copyright (c) 1998 The NetBSD Foundation, Inc.
5 * All rights reserved.
6 *
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Paul Kranenburg.
9 *
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
12 * are met:
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 * 3. All advertising materials mentioning features or use of this software
19 * must display the following acknowledgement:
20 * This product includes software developed by the NetBSD
21 * Foundation, Inc. and its contributors.
22 * 4. Neither the name of The NetBSD Foundation nor the names of its
23 * contributors may be used to endorse or promote products derived
24 * from this software without specific prior written permission.
25 *
26 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
27 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
28 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
30 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
32 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
33 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
34 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
35 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36 * POSSIBILITY OF SUCH DAMAGE.
37 */
38
39 /*
40 * Copyright (c) 1992, 1993
41 * The Regents of the University of California. All rights reserved.
42 *
43 * This software was developed by the Computer Systems Engineering group
44 * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
45 * contributed to Berkeley.
46 *
47 * All advertising materials mentioning features or use of this software
48 * must display the following acknowledgement:
49 * This product includes software developed by the University of
50 * California, Lawrence Berkeley Laboratory.
51 *
52 * Redistribution and use in source and binary forms, with or without
53 * modification, are permitted provided that the following conditions
54 * are met:
55 * 1. Redistributions of source code must retain the above copyright
56 * notice, this list of conditions and the following disclaimer.
57 * 2. Redistributions in binary form must reproduce the above copyright
58 * notice, this list of conditions and the following disclaimer in the
59 * documentation and/or other materials provided with the distribution.
60 * 3. All advertising materials mentioning features or use of this software
61 * must display the following acknowledgement:
62 * This product includes software developed by the University of
63 * California, Berkeley and its contributors.
64 * 4. Neither the name of the University nor the names of its contributors
65 * may be used to endorse or promote products derived from this software
66 * without specific prior written permission.
67 *
68 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
69 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
70 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
71 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
72 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
73 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
74 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
75 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
76 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
77 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
78 * SUCH DAMAGE.
79 *
80 * @(#)sbus.c 8.1 (Berkeley) 6/11/93
81 */
82
83 /*
84 * Sbus stuff.
85 */
86
87 #include <sys/param.h>
88 #include <sys/malloc.h>
89 #include <sys/systm.h>
90 #include <sys/device.h>
91 #include <vm/vm.h>
92
93 #include <machine/bus.h>
94 #include <sparc/dev/sbusreg.h>
95 #include <sparc/dev/sbusvar.h>
96 #include <sparc/dev/xboxvar.h>
97
98 #include <sparc/sparc/iommuvar.h>
99 #include <machine/autoconf.h>
100
101
102 void sbusreset __P((int));
103
104 static bus_space_tag_t sbus_alloc_bustag __P((struct sbus_softc *));
105 static int sbus_get_intr __P((struct sbus_softc *, int, int *));
106 static int sbus_bus_mmap __P((bus_space_tag_t, bus_type_t, bus_addr_t,
107 int, bus_space_handle_t *));
108 static int _sbus_bus_map __P((
109 bus_space_tag_t,
110 bus_type_t, /*slot*/
111 bus_addr_t, /*offset*/
112 bus_size_t, /*size*/
113 int, /*flags*/
114 vm_offset_t, /*preferred virtual address */
115 bus_space_handle_t *));
116 static void *sbus_intr_establish __P((
117 bus_space_tag_t,
118 int, /*level*/
119 int, /*flags*/
120 int (*) __P((void *)), /*handler*/
121 void *)); /*handler arg*/
122
123
124 /* autoconfiguration driver */
125 int sbus_match_mainbus __P((struct device *, struct cfdata *, void *));
126 int sbus_match_iommu __P((struct device *, struct cfdata *, void *));
127 int sbus_match_xbox __P((struct device *, struct cfdata *, void *));
128 void sbus_attach_mainbus __P((struct device *, struct device *, void *));
129 void sbus_attach_iommu __P((struct device *, struct device *, void *));
130 void sbus_attach_xbox __P((struct device *, struct device *, void *));
131
132 struct cfattach sbus_mainbus_ca = {
133 sizeof(struct sbus_softc), sbus_match_mainbus, sbus_attach_mainbus
134 };
135 struct cfattach sbus_iommu_ca = {
136 sizeof(struct sbus_softc), sbus_match_iommu, sbus_attach_iommu
137 };
138 struct cfattach sbus_xbox_ca = {
139 sizeof(struct sbus_softc), sbus_match_xbox, sbus_attach_xbox
140 };
141
142 extern struct cfdriver sbus_cd;
143
144 /* If the PROM does not provide the `ranges' property, we make up our own */
145 struct rom_range sbus_translations[] = {
146 /* Assume a maximum of 4 Sbus slots, all mapped to on-board io space */
147 { 0, 0, PMAP_OBIO, SBUS_ADDR(0,0), 1 << 25 },
148 { 1, 0, PMAP_OBIO, SBUS_ADDR(1,0), 1 << 25 },
149 { 2, 0, PMAP_OBIO, SBUS_ADDR(2,0), 1 << 25 },
150 { 3, 0, PMAP_OBIO, SBUS_ADDR(3,0), 1 << 25 }
151 };
152
153 /*
154 * Child devices receive the Sbus interrupt level in their attach
155 * arguments. We translate these to CPU IPLs using the following
156 * tables. Note: obio bus interrupt levels are identical to the
157 * processor IPL.
158 *
159 * The second set of tables is used when the Sbus interrupt level
160 * cannot be had from the PROM as an `interrupt' property. We then
161 * fall back on the `intr' property which contains the CPU IPL.
162 */
163
164 /* Translate Sbus interrupt level to processor IPL */
165 static int intr_sbus2ipl_4c[] = {
166 0, 1, 2, 3, 5, 7, 8, 9
167 };
168 static int intr_sbus2ipl_4m[] = {
169 0, 2, 3, 5, 7, 9, 11, 13
170 };
171
172 /*
173 * This value is or'ed into the attach args' interrupt level cookie
174 * if the interrupt level comes from an `intr' property, i.e. it is
175 * not an Sbus interrupt level.
176 */
177 #define SBUS_INTR_COMPAT 0x80000000
178
179
180 /*
181 * Print the location of some sbus-attached device (called just
182 * before attaching that device). If `sbus' is not NULL, the
183 * device was found but not configured; print the sbus as well.
184 * Return UNCONF (config_find ignores this if the device was configured).
185 */
186 int
187 sbus_print(args, busname)
188 void *args;
189 const char *busname;
190 {
191 struct sbus_attach_args *sa = args;
192
193 if (busname)
194 printf("%s at %s", sa->sa_name, busname);
195 printf(" slot %d offset 0x%x", sa->sa_slot, sa->sa_offset);
196 if (sa->sa_pri) {
197 int level = sa->sa_pri;
198 struct sbus_softc *sc =
199 (struct sbus_softc *) sa->sa_bustag->cookie;
200
201 printf(" level %d", level & ~SBUS_INTR_COMPAT);
202 if ((level & SBUS_INTR_COMPAT) == 0) {
203 int ipl = sc->sc_intr2ipl[level];
204 if (ipl != level)
205 printf(" (ipl %d)", ipl);
206 }
207 }
208 return (UNCONF);
209 }
210
211 int
212 sbus_match_mainbus(parent, cf, aux)
213 struct device *parent;
214 struct cfdata *cf;
215 void *aux;
216 {
217 struct mainbus_attach_args *ma = aux;
218
219 if (CPU_ISSUN4)
220 return (0);
221
222 return (strcmp(cf->cf_driver->cd_name, ma->ma_name) == 0);
223 }
224
225 int
226 sbus_match_iommu(parent, cf, aux)
227 struct device *parent;
228 struct cfdata *cf;
229 void *aux;
230 {
231 struct iommu_attach_args *ia = aux;
232
233 if (CPU_ISSUN4)
234 return (0);
235
236 return (strcmp(cf->cf_driver->cd_name, ia->iom_name) == 0);
237 }
238
239 int
240 sbus_match_xbox(parent, cf, aux)
241 struct device *parent;
242 struct cfdata *cf;
243 void *aux;
244 {
245 struct xbox_attach_args *xa = aux;
246
247 if (CPU_ISSUN4)
248 return (0);
249
250 return (strcmp(cf->cf_driver->cd_name, xa->xa_name) == 0);
251 }
252
253 /*
254 * Attach an Sbus.
255 */
256 void
257 sbus_attach_mainbus(parent, self, aux)
258 struct device *parent;
259 struct device *self;
260 void *aux;
261 {
262 struct sbus_softc *sc = (struct sbus_softc *)self;
263 struct mainbus_attach_args *ma = aux;
264 int node = ma->ma_node;
265
266 /*
267 * XXX there is only one Sbus, for now -- do not know how to
268 * address children on others
269 */
270 if (sc->sc_dev.dv_unit > 0) {
271 printf(" unsupported\n");
272 return;
273 }
274
275 sc->sc_bustag = ma->ma_bustag;
276 sc->sc_dmatag = ma->ma_dmatag;
277
278 /* Setup interrupt translation tables */
279 sc->sc_intr2ipl = CPU_ISSUN4C
280 ? intr_sbus2ipl_4c
281 : intr_sbus2ipl_4m;
282
283 /*
284 * Record clock frequency for synchronous SCSI.
285 * IS THIS THE CORRECT DEFAULT??
286 */
287 sc->sc_clockfreq = getpropint(node, "clock-frequency", 25*1000*1000);
288 printf(": clock = %s MHz\n", clockfreq(sc->sc_clockfreq));
289
290 sbus_attach(sc, "sbus", node, ma->ma_bp, NULL);
291 }
292
293 void
294 sbus_attach_iommu(parent, self, aux)
295 struct device *parent;
296 struct device *self;
297 void *aux;
298 {
299 struct sbus_softc *sc = (struct sbus_softc *)self;
300 struct iommu_attach_args *ia = aux;
301 int node = ia->iom_node;
302
303 sc->sc_bustag = ia->iom_bustag;
304 sc->sc_dmatag = ia->iom_dmatag;
305
306 /* Setup interrupt translation tables */
307 sc->sc_intr2ipl = CPU_ISSUN4C ? intr_sbus2ipl_4c : intr_sbus2ipl_4m;
308
309 /*
310 * Record clock frequency for synchronous SCSI.
311 * IS THIS THE CORRECT DEFAULT??
312 */
313 sc->sc_clockfreq = getpropint(node, "clock-frequency", 25*1000*1000);
314 printf(": clock = %s MHz\n", clockfreq(sc->sc_clockfreq));
315
316 sbus_attach(sc, "sbus", node, ia->iom_bp, NULL);
317 }
318
319 void
320 sbus_attach_xbox(parent, self, aux)
321 struct device *parent;
322 struct device *self;
323 void *aux;
324 {
325 struct sbus_softc *sc = (struct sbus_softc *)self;
326 struct xbox_attach_args *xa = aux;
327 int node = xa->xa_node;
328
329 sc->sc_bustag = xa->xa_bustag;
330 sc->sc_dmatag = xa->xa_dmatag;
331
332 /* Setup interrupt translation tables */
333 sc->sc_intr2ipl = CPU_ISSUN4C ? intr_sbus2ipl_4c : intr_sbus2ipl_4m;
334
335 /*
336 * Record clock frequency for synchronous SCSI.
337 * IS THIS THE CORRECT DEFAULT??
338 */
339 sc->sc_clockfreq = getpropint(node, "clock-frequency", 25*1000*1000);
340 printf(": clock = %s MHz\n", clockfreq(sc->sc_clockfreq));
341
342 sbus_attach(sc, "sbus", node, xa->xa_bp, NULL);
343 }
344
345 void
346 sbus_attach(sc, busname, busnode, bp, specials)
347 struct sbus_softc *sc;
348 char *busname;
349 int busnode;
350 struct bootpath *bp;
351 const char * const *specials;
352 {
353 int node0, node, error;
354 const char *sp;
355 const char *const *ssp;
356 bus_space_tag_t sbt;
357 struct sbus_attach_args sa;
358
359 sbt = sbus_alloc_bustag(sc);
360
361 /*
362 * Get the SBus burst transfer size if burst transfers are supported
363 */
364 sc->sc_burst = getpropint(busnode, "burst-sizes", 0);
365
366 /* Propagate bootpath */
367 if (bp != NULL && strcmp(bp->name, busname) == 0)
368 bp++;
369 else
370 bp = NULL;
371
372 /*
373 * Collect address translations from the OBP.
374 */
375 error = getpropA(busnode, "ranges", sizeof(struct rom_range),
376 &sc->sc_nrange, (void **)&sc->sc_range);
377 switch (error) {
378 case 0:
379 break;
380 case ENOENT:
381 /* Fall back to our own `range' construction */
382 sc->sc_range = sbus_translations;
383 sc->sc_nrange =
384 sizeof(sbus_translations)/sizeof(sbus_translations[0]);
385 break;
386 default:
387 panic("%s: error getting ranges property", sc->sc_dev.dv_xname);
388 }
389
390 /*
391 * Loop through ROM children, fixing any relative addresses
392 * and then configuring each device.
393 * `specials' is an array of device names that are treated
394 * specially:
395 */
396 node0 = firstchild(busnode);
397 for (ssp = specials ; ssp != NULL && *(sp = *ssp) != 0; ssp++) {
398 if ((node = findnode(node0, sp)) == 0) {
399 panic("could not find %s amongst %s devices",
400 sp, busname);
401 }
402
403 if (sbus_setup_attach_args(sc, sbt, sc->sc_dmatag,
404 node, bp, &sa) != 0) {
405 panic("sbus_attach: %s: incomplete", sp);
406 }
407 (void) config_found(&sc->sc_dev, (void *)&sa, sbus_print);
408 }
409
410 for (node = node0; node; node = nextsibling(node)) {
411 char *name = getpropstring(node, "name");
412 for (ssp = specials, sp = NULL;
413 ssp != NULL && (sp = *ssp) != NULL;
414 ssp++)
415 if (strcmp(name, sp) == 0)
416 break;
417
418 if (sp != NULL)
419 /* Already configured as an "early" device */
420 continue;
421
422 if (sbus_setup_attach_args(sc, sbt, sc->sc_dmatag,
423 node, bp, &sa) != 0) {
424 printf("sbus_attach: %s: incomplete\n", name);
425 continue;
426 }
427 (void) config_found(&sc->sc_dev, (void *)&sa, sbus_print);
428 }
429 }
430
431 int
432 sbus_setup_attach_args(sc, bustag, dmatag, node, bp, sa)
433 struct sbus_softc *sc;
434 bus_space_tag_t bustag;
435 bus_dma_tag_t dmatag;
436 int node;
437 struct bootpath *bp;
438 struct sbus_attach_args *sa;
439 {
440 struct rom_reg romreg;
441 int base;
442 int error;
443
444 bzero(sa, sizeof(struct sbus_attach_args));
445 sa->sa_name = getpropstring(node, "name");
446 sa->sa_bustag = bustag;
447 sa->sa_dmatag = dmatag;
448 sa->sa_node = node;
449 sa->sa_bp = bp;
450
451 if ((error = getprop_reg1(node, &romreg)) != 0)
452 return (error);
453
454 /* We pass only the first "reg" property */
455 base = (int)romreg.rr_paddr;
456 if (SBUS_ABS(base)) {
457 sa->sa_slot = SBUS_ABS_TO_SLOT(base);
458 sa->sa_offset = SBUS_ABS_TO_OFFSET(base);
459 } else {
460 sa->sa_slot = romreg.rr_iospace;
461 sa->sa_offset = base;
462 }
463 sa->sa_size = romreg.rr_len;
464
465 if ((error = sbus_get_intr(sc, node, &sa->sa_pri)) != 0)
466 return (error);
467
468 if ((error = getprop_address1(node, &sa->sa_promvaddr)) != 0)
469 return (error);
470
471 return (0);
472 }
473
474 int
475 _sbus_bus_map(t, btype, offset, size, flags, vaddr, hp)
476 bus_space_tag_t t;
477 bus_type_t btype;
478 bus_addr_t offset;
479 bus_size_t size;
480 int flags;
481 vm_offset_t vaddr;
482 bus_space_handle_t *hp;
483 {
484 struct sbus_softc *sc = t->cookie;
485 int slot = btype;
486 int i;
487
488 for (i = 0; i < sc->sc_nrange; i++) {
489 bus_addr_t paddr;
490 bus_type_t iospace;
491
492 if (sc->sc_range[i].cspace != slot)
493 continue;
494
495 /* We've found the connection to the parent bus */
496 paddr = sc->sc_range[i].poffset + offset;
497 iospace = sc->sc_range[i].pspace;
498 return (bus_space_map2(sc->sc_bustag, iospace, paddr,
499 size, flags, vaddr, hp));
500 }
501
502 return (EINVAL);
503 }
504
505 int
506 sbus_bus_mmap(t, btype, paddr, flags, hp)
507 bus_space_tag_t t;
508 bus_type_t btype;
509 bus_addr_t paddr;
510 int flags;
511 bus_space_handle_t *hp;
512 {
513 int slot = (int)btype;
514 int offset = (int)paddr;
515 struct sbus_softc *sc = t->cookie;
516 int i;
517
518 for (i = 0; i < sc->sc_nrange; i++) {
519 bus_addr_t paddr;
520 bus_addr_t iospace;
521
522 if (sc->sc_range[i].cspace != slot)
523 continue;
524
525 paddr = sc->sc_range[i].poffset + offset;
526 iospace = (bus_addr_t)sc->sc_range[i].pspace;
527 return (bus_space_mmap(sc->sc_bustag, iospace, paddr,
528 flags, hp));
529 }
530
531 return (-1);
532 }
533
534
535 /*
536 * Each attached device calls sbus_establish after it initializes
537 * its sbusdev portion.
538 */
539 void
540 sbus_establish(sd, dev)
541 register struct sbusdev *sd;
542 register struct device *dev;
543 {
544 register struct sbus_softc *sc;
545 register struct device *curdev;
546
547 /*
548 * We have to look for the sbus by name, since it is not necessarily
549 * our immediate parent (i.e. sun4m /iommu/sbus/espdma/esp)
550 * We don't just use the device structure of the above-attached
551 * sbus, since we might (in the future) support multiple sbus's.
552 */
553 for (curdev = dev->dv_parent; ; curdev = curdev->dv_parent) {
554 if (!curdev || !curdev->dv_xname)
555 panic("sbus_establish: can't find sbus parent for %s",
556 sd->sd_dev->dv_xname
557 ? sd->sd_dev->dv_xname
558 : "<unknown>" );
559
560 if (strncmp(curdev->dv_xname, "sbus", 4) == 0)
561 break;
562 }
563 sc = (struct sbus_softc *) curdev;
564
565 sd->sd_dev = dev;
566 sd->sd_bchain = sc->sc_sbdev;
567 sc->sc_sbdev = sd;
568 }
569
570 /*
571 * Reset the given sbus. (???)
572 */
573 void
574 sbusreset(sbus)
575 int sbus;
576 {
577 register struct sbusdev *sd;
578 struct sbus_softc *sc = sbus_cd.cd_devs[sbus];
579 struct device *dev;
580
581 printf("reset %s:", sc->sc_dev.dv_xname);
582 for (sd = sc->sc_sbdev; sd != NULL; sd = sd->sd_bchain) {
583 if (sd->sd_reset) {
584 dev = sd->sd_dev;
585 (*sd->sd_reset)(dev);
586 printf(" %s", dev->dv_xname);
587 }
588 }
589 }
590
591
592 /*
593 * Get interrupt attributes for an Sbus device.
594 */
595 int
596 sbus_get_intr(sc, node, ip)
597 struct sbus_softc *sc;
598 int node;
599 int *ip;
600 {
601 struct rom_intr *rip;
602 int *ipl;
603 int n;
604
605 /*
606 * The `interrupts' property contains the Sbus interrupt level.
607 */
608 ipl = NULL;
609 if (getpropA(node, "interrupts", sizeof(int), &n, (void **)&ipl) == 0) {
610 *ip = ipl[0];
611 free(ipl, M_DEVBUF);
612 return (0);
613 }
614
615 /*
616 * Fall back on `intr' property.
617 */
618 rip = NULL;
619 switch (getpropA(node, "intr", sizeof(*rip), &n, (void **)&rip)) {
620 case 0:
621 *ip = (rip[0].int_pri & 0xf) | SBUS_INTR_COMPAT;
622 free(rip, M_DEVBUF);
623 return (0);
624 case ENOENT:
625 *ip = 0;
626 return (0);
627 }
628
629 return (-1);
630 }
631
632
633 /*
634 * Install an interrupt handler for an Sbus device.
635 */
636 void *
637 sbus_intr_establish(t, level, flags, handler, arg)
638 bus_space_tag_t t;
639 int level;
640 int flags;
641 int (*handler) __P((void *));
642 void *arg;
643 {
644 struct sbus_softc *sc = t->cookie;
645 struct intrhand *ih;
646 int ipl;
647
648 ih = (struct intrhand *)
649 malloc(sizeof(struct intrhand), M_DEVBUF, M_NOWAIT);
650 if (ih == NULL)
651 return (NULL);
652
653 if ((flags & BUS_INTR_ESTABLISH_SOFTINTR) != 0)
654 ipl = level;
655 else if ((level & SBUS_INTR_COMPAT) != 0)
656 ipl = level & ~SBUS_INTR_COMPAT;
657 else
658 ipl = sc->sc_intr2ipl[level];
659
660 ih->ih_fun = handler;
661 ih->ih_arg = arg;
662 if ((flags & BUS_INTR_ESTABLISH_FASTTRAP) != 0)
663 intr_fasttrap(ipl, (void (*)__P((void)))handler);
664 else
665 intr_establish(ipl, ih);
666 return (ih);
667 }
668
669 static bus_space_tag_t
670 sbus_alloc_bustag(sc)
671 struct sbus_softc *sc;
672 {
673 bus_space_tag_t sbt;
674
675 sbt = (bus_space_tag_t)
676 malloc(sizeof(struct sparc_bus_space_tag), M_DEVBUF, M_NOWAIT);
677 if (sbt == NULL)
678 return (NULL);
679
680 bzero(sbt, sizeof *sbt);
681 sbt->cookie = sc;
682 sbt->parent = sc->sc_bustag;
683 sbt->sparc_bus_map = _sbus_bus_map;
684 sbt->sparc_bus_mmap = sbus_bus_mmap;
685 sbt->sparc_intr_establish = sbus_intr_establish;
686 return (sbt);
687 }
688