1 /* $NetBSD: nubus.c,v 1.62 2007/03/07 13:54:49 tsutsui Exp $ */
4 * Copyright (c) 1995, 1996 Allen Briggs. All rights reserved.
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * 3. All advertising materials mentioning features or use of this software
15 * must display the following acknowledgement:
16 * This product includes software developed by Allen Briggs.
17 * 4. The name of the author may not be used to endorse or promote products
18 * derived from this software without specific prior written permission.
20 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
21 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
22 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
23 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
24 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
25 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
29 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 #include <sys/cdefs.h>
33 __KERNEL_RCSID(0, "$NetBSD: nubus.c,v 1.62 2007/03/07 13:54:49 tsutsui Exp $");
35 #include <sys/param.h>
36 #include <sys/systm.h>
37 #include <sys/malloc.h>
38 #include <sys/device.h>
42 #include <uvm/uvm_extern.h>
44 #include <machine/autoconf.h>
45 #include <machine/vmparam.h>
46 #include <machine/param.h>
47 #include <machine/cpu.h>
48 #include <machine/pte.h>
49 #include <machine/viareg.h>
51 #include <mac68k/nubus/nubus.h>
55 #define NDB_FOLLOW 0x2
57 static int nubus_debug
= 0 /* | NDB_PROBE | NDB_FOLLOW | NDB_ARITH */ ;
60 static int nubus_print(void *, const char *);
61 static int nubus_match(struct device
*, struct cfdata
*, void *);
62 static void nubus_attach(struct device
*, struct device
*, void *);
63 static int nubus_video_resource(int);
65 static int nubus_probe_slot(bus_space_tag_t
, bus_space_handle_t
, int,
67 static u_int32_t
nubus_calc_CRC(bus_space_tag_t
, bus_space_handle_t
,
70 static u_long
nubus_adjust_ptr(u_int8_t
, u_long
, long);
71 static u_int8_t
nubus_read_1(bus_space_tag_t
, bus_space_handle_t
, u_int8_t
,
74 static u_int16_t
nubus_read_2(bus_space_tag_t
, bus_space_handle_t
, u_int8_t
,
77 static u_int32_t
nubus_read_4(bus_space_tag_t
, bus_space_handle_t
, u_int8_t
,
80 CFATTACH_DECL(nubus
, sizeof(struct nubus_softc
),
81 nubus_match
, nubus_attach
, NULL
, NULL
);
84 nubus_match(struct device
*parent
, struct cfdata
*cf
, void *aux
)
86 static int nubus_matched
= 0;
88 /* Allow only one instance. */
97 nubus_attach(struct device
*parent
, struct device
*self
, void *aux
)
99 struct nubus_attach_args na_args
;
100 struct mainbus_attach_args
*mba
;
102 bus_space_handle_t bsh
;
112 KASSERT(NULL
!= mba
->mba_dmat
);
116 for (i
= NUBUS_MIN_SLOT
; i
<= NUBUS_MAX_SLOT
; i
++) {
118 na_args
.na_tag
= bst
= mba
->mba_bst
;
119 na_args
.na_dmat
= mba
->mba_dmat
;
121 if (bus_space_map(bst
,
122 NUBUS_SLOT2PA(na_args
.slot
), NBMEMSIZE
, 0, &bsh
)) {
124 if (nubus_debug
& NDB_PROBE
)
125 printf("%s: failed to map slot %x, "
126 "address %p (in use?)\n",
128 (void *)NUBUS_SLOT2PA(i
));
133 if (nubus_probe_slot(bst
, bsh
, i
, &fmtblock
) <= 0) {
135 bus_space_unmap(bst
, bsh
, NBMEMSIZE
);
140 lanes
= fmtblock
.bytelanes
;
142 nubus_get_main_dir(&fmtblock
, &dir
);
145 * Get the resource for the first function on the card.
146 * This is assumed to be at resource ID 0x80. If we can
147 * not find this entry (as we can not on some video cards),
148 * check to see if we can get a different ID from the list
149 * of video resources given to us by the booter. If that
150 * doesn't work either, take the first resource following
151 * the board resource.
152 * If we only find a board resource, report that.
153 * There are cards that do not have anything else; their
154 * driver then has to match on the board resource and
157 if (nubus_find_rsrc(bst
, bsh
,
158 &fmtblock
, &dir
, rsrcid
, &dirent
) <= 0) {
159 if ((rsrcid
= nubus_video_resource(i
)) == -1) {
160 int has_board_rsrc
= 0;
163 * Since nubus_find_rsrc failed, the directory
164 * is back at its base.
166 entry
= dir
.curr_ent
;
169 * All nubus cards should have a board
170 * resource, but be sure that's what it
171 * is before we skip it, and note the fact.
173 rsrcid
= nubus_read_1(bst
, bsh
,
177 entry
= nubus_adjust_ptr(lanes
,
180 rsrcid
= nubus_read_1(bst
, bsh
, lanes
, entry
);
182 if (rsrcid
== 0xff) {
189 if (nubus_debug
& NDB_FOLLOW
)
190 printf("\tUsing rsrc 0x%x.\n", rsrcid
);
194 * Try to find the resource passed by the booter
195 * or the one we just tracked down.
197 if (nubus_find_rsrc(bst
, bsh
,
198 &fmtblock
, &dir
, rsrcid
, &dirent
) <= 0)
202 nubus_get_dir_from_rsrc(&fmtblock
, &dirent
, &dir
);
204 if (nubus_find_rsrc(bst
, bsh
,
205 &fmtblock
, &dir
, NUBUS_RSRC_TYPE
, &dirent
) <= 0)
208 if (nubus_get_ind_data(bst
, bsh
, &fmtblock
, &dirent
,
209 (void *)&slottype
, sizeof(nubus_type
)) <= 0)
213 * If this is a display card, try to pull out the correct
214 * display mode as passed by the booter.
216 if (slottype
.category
== NUBUS_CATEGORY_DISPLAY
) {
219 if ((r
= nubus_video_resource(i
)) != -1) {
221 nubus_get_main_dir(&fmtblock
, &dir
);
223 if (nubus_find_rsrc(bst
, bsh
,
224 &fmtblock
, &dir
, r
, &dirent
) <= 0)
227 nubus_get_dir_from_rsrc(&fmtblock
,
230 if (nubus_find_rsrc(bst
, bsh
, &fmtblock
, &dir
,
231 NUBUS_RSRC_TYPE
, &dirent
) <= 0)
234 if (nubus_get_ind_data(bst
, bsh
,
235 &fmtblock
, &dirent
, (void *)&slottype
,
236 sizeof(nubus_type
)) <= 0)
244 na_args
.rsrcid
= rsrcid
;
245 na_args
.category
= slottype
.category
;
246 na_args
.type
= slottype
.type
;
247 na_args
.drsw
= slottype
.drsw
;
248 na_args
.drhw
= slottype
.drhw
;
249 na_args
.fmt
= &fmtblock
;
251 bus_space_unmap(bst
, bsh
, NBMEMSIZE
);
253 config_found(self
, &na_args
, nubus_print
);
260 nubus_print(void *aux
, const char *pnp
)
262 struct nubus_attach_args
*na
= (struct nubus_attach_args
*)aux
;
263 bus_space_tag_t bst
= na
->na_tag
;
264 bus_space_handle_t bsh
;
267 aprint_normal("%s slot %x", pnp
, na
->slot
);
268 if (bus_space_map(bst
,
269 NUBUS_SLOT2PA(na
->slot
), NBMEMSIZE
, 0, &bsh
) == 0) {
270 aprint_normal(": %s",
271 nubus_get_card_name(bst
, bsh
, na
->fmt
));
272 aprint_normal(" (Vendor: %s,",
273 nubus_get_vendor(bst
, bsh
,
274 na
->fmt
, NUBUS_RSRC_VEND_ID
));
275 aprint_normal(" Part: %s)", nubus_get_vendor(bst
, bsh
,
276 na
->fmt
, NUBUS_RSRC_VEND_PART
));
277 bus_space_unmap(bst
, bsh
, NBMEMSIZE
);
282 aprint_normal(" Type: %04x %04x %04x %04x",
283 na
->category
, na
->type
, na
->drsw
, na
->drhw
);
286 aprint_normal(" slot %x", na
->slot
);
292 nubus_video_resource(int slot
)
294 extern u_int16_t mac68k_vrsrc_vec
[];
297 for (i
= 0 ; i
< 6 ; i
++)
298 if ((mac68k_vrsrc_vec
[i
] & 0xff) == slot
)
299 return ((mac68k_vrsrc_vec
[i
] >> 8) & 0xff);
304 * Probe a given nubus slot. If a card is there and we can get the
305 * format block from it's clutching decl. ROMs, fill the format block
306 * and return non-zero. If we can't find a card there with a valid
307 * decl. ROM, return 0.
309 * First, we check to see if we can access the memory at the tail
310 * end of the slot. If so, then we check for a bytelanes byte. We
311 * could probably just return a failure status if we bus error on
312 * the first try, but there really is little reason not to go ahead
313 * and check the other three locations in case there's a weird card
316 * Checking for a card involves locating the "bytelanes" byte which
317 * tells us how to interpret the declaration ROM's data. The format
318 * block is at the top of the card's standard memory space and the
319 * bytelanes byte is at the end of that block.
321 * After some inspection of the bytelanes byte, it appears that it
322 * takes the form 0xXY where Y is a bitmask of the bytelanes in use
323 * and X is a bitmask of the lanes to ignore. Hence, (X ^ Y) == 0
324 * and (less obviously), Y will have the upper N bits clear if it is
325 * found N bytes from the last possible location. Both that and
326 * the exclusive-or check are made.
330 static u_int8_t nbits
[] = {0,1,1,2,1,2,2,3,1,2,2,3,2,3,3,4};
332 nubus_probe_slot(bus_space_tag_t bst
, bus_space_handle_t bsh
, int slot
,
336 int i
, j
, found
, hdr_size
;
340 if (nubus_debug
& NDB_PROBE
)
341 printf("probing slot %x\n", slot
);
345 * The idea behind this glorious work of art is to probe for only
346 * valid bytelanes values at appropriate locations (see DC&D p. 159
347 * for a list). Note the pattern: the first 8 values are at offset
348 * 0xffffff in the slot's space; the next 4 values at 0xfffffe; the
349 * next 2 values at 0xfffffd; and the last one at 0xfffffc.
351 * The nested loops implement an efficient search of this space,
352 * probing first for a valid address, then checking for each of the
353 * valid bytelanes values at that address.
358 for (j
= 8, found
= 0; j
> 0 && !found
; j
>>= 1) {
360 for (i
= j
; i
> 0; i
--, lanes
--) {
361 if (!mac68k_bus_space_probe(bst
, bsh
, ofs
, 1)) {
365 if (bus_space_read_1(bst
, bsh
, ofs
) ==
366 (((~lanes
& 0xf) << 4) | lanes
)) {
375 if (nubus_debug
& NDB_PROBE
)
376 printf("bytelanes not found for slot %x\n", slot
);
381 fmt
->bytelanes
= lanes
;
382 fmt
->step
= nbits
[(lanes
& 0x0f)];
383 fmt
->slot
= slot
; /* XXX redundant; get rid of this someday */
386 if (nubus_debug
& NDB_PROBE
)
387 printf("bytelanes of 0x%x found for slot 0x%x.\n",
388 fmt
->bytelanes
, slot
);
392 * Go ahead and attempt to load format header.
393 * First, we need to find the first byte beyond memory that
394 * would be valid. This is necessary for NUBUS_ROM_offset()
400 i
= 0x10 | (lanes
& 0x0f);
401 while ((i
& 1) == 0) {
406 hdr
= nubus_adjust_ptr(lanes
, hdr
, -hdr_size
);
408 if (nubus_debug
& NDB_PROBE
)
409 printf("fmt->top is 0x%lx, that minus 0x%x puts us at 0x%lx.\n",
410 fmt
->top
, hdr_size
, hdr
);
411 if (nubus_debug
& NDB_ARITH
)
412 for (i
= 1 ; i
< 8 ; i
++)
413 printf("0x%lx - 0x%x = 0x%lx, + 0x%x = 0x%lx.\n",
414 hdr
, i
, nubus_adjust_ptr(lanes
, hdr
, -i
),
415 i
, nubus_adjust_ptr(lanes
, hdr
, i
));
418 fmt
->directory_offset
=
419 0xff000000 | nubus_read_4(bst
, bsh
, lanes
, hdr
);
420 hdr
= nubus_adjust_ptr(lanes
, hdr
, 4);
421 fmt
->length
= nubus_read_4(bst
, bsh
, lanes
, hdr
);
422 hdr
= nubus_adjust_ptr(lanes
, hdr
, 4);
423 fmt
->crc
= nubus_read_4(bst
, bsh
, lanes
, hdr
);
424 hdr
= nubus_adjust_ptr(lanes
, hdr
, 4);
425 fmt
->revision_level
= nubus_read_1(bst
, bsh
, lanes
, hdr
);
426 hdr
= nubus_adjust_ptr(lanes
, hdr
, 1);
427 fmt
->format
= nubus_read_1(bst
, bsh
, lanes
, hdr
);
428 hdr
= nubus_adjust_ptr(lanes
, hdr
, 1);
429 fmt
->test_pattern
= nubus_read_4(bst
, bsh
, lanes
, hdr
);
432 if (nubus_debug
& NDB_PROBE
) {
433 printf("Directory offset 0x%x\t", fmt
->directory_offset
);
434 printf("Length 0x%x\t", fmt
->length
);
435 printf("CRC 0x%x\n", fmt
->crc
);
436 printf("Revision level 0x%x\t", fmt
->revision_level
);
437 printf("Format 0x%x\t", fmt
->format
);
438 printf("Test Pattern 0x%x\n", fmt
->test_pattern
);
442 if ((fmt
->directory_offset
& 0x00ff0000) == 0) {
443 printf("Invalid looking directory offset (0x%x)!\n",
444 fmt
->directory_offset
);
447 if (fmt
->test_pattern
!= NUBUS_ROM_TEST_PATTERN
) {
448 printf("Nubus--test pattern invalid:\n");
449 printf(" slot 0x%x, bytelanes 0x%x?\n", fmt
->slot
, lanes
);
450 printf(" read test 0x%x, compare with 0x%x.\n",
451 fmt
->test_pattern
, NUBUS_ROM_TEST_PATTERN
);
456 if (fmt
->crc
!= nubus_calc_CRC(bst
, bsh
, fmt
)) {
457 printf("Nubus--crc check failed, slot 0x%x.\n", fmt
->slot
);
465 nubus_calc_CRC(bus_space_tag_t bst
, bus_space_handle_t bsh
, nubus_slot
*fmt
)
468 u_long base
, ptr
, crc_loc
;
470 u_int8_t lanes
= fmt
->bytelanes
;
473 crc_loc
= NUBUS_ROM_offset(fmt
, base
, -12);
474 ptr
= NUBUS_ROM_offset(fmt
, base
, -fmt
->length
);
479 if (ptr
== crc_loc
) {
481 ptr
= nubus_adjust_ptr(lanes
, ptr
, 3);
483 sum
+= nubus_read_1(bst
, bsh
, lanes
, ptr
);
485 ptr
= nubus_adjust_ptr(lanes
, ptr
, 1);
494 * Compute byte offset on card, taking into account bytelanes.
495 * Base must be on a valid bytelane for this function to work.
496 * Return the new address.
498 * XXX -- There has GOT to be a better way to do this.
501 nubus_adjust_ptr(u_int8_t lanes
, u_long base
, long amt
)
512 b
<<= (3 - (base
& 0x3));
524 t
= (lanes
& 0xf) | 0x10;
525 b
= t
>> (base
& 0x3);
539 nubus_read_1(bus_space_tag_t bst
, bus_space_handle_t bsh
, u_int8_t lanes
,
542 return bus_space_read_1(bst
, bsh
, ofs
);
546 /* Nothing uses this, yet */
548 nubus_read_2(bus_space_tag_t bst
, bus_space_handle_t bsh
, u_int8_t lanes
,
553 s
= (nubus_read_1(bst
, bsh
, lanes
, ofs
) << 8);
554 ofs
= nubus_adjust_ptr(lanes
, ofs
, 1);
555 s
|= nubus_read_1(bst
, bsh
, lanes
, ofs
);
561 nubus_read_4(bus_space_tag_t bst
, bus_space_handle_t bsh
, u_int8_t lanes
,
568 for (i
= 0; i
< 4; i
++) {
569 l
= (l
<< 8) | nubus_read_1(bst
, bsh
, lanes
, ofs
);
570 ofs
= nubus_adjust_ptr(lanes
, ofs
, 1);
576 nubus_get_main_dir(nubus_slot
*fmt
, nubus_dir
*dir_return
)
579 if (nubus_debug
& NDB_FOLLOW
)
580 printf("nubus_get_main_dir(%p, %p)\n",
583 dir_return
->dirbase
= nubus_adjust_ptr(fmt
->bytelanes
, fmt
->top
,
584 fmt
->directory_offset
- 20);
585 dir_return
->curr_ent
= dir_return
->dirbase
;
589 nubus_get_dir_from_rsrc(nubus_slot
*fmt
, nubus_dirent
*dirent
,
590 nubus_dir
*dir_return
)
595 if (nubus_debug
& NDB_FOLLOW
)
596 printf("nubus_get_dir_from_rsrc(%p, %p, %p).\n",
597 fmt
, dirent
, dir_return
);
599 if ((loc
= dirent
->offset
) & 0x800000) {
602 dir_return
->dirbase
=
603 nubus_adjust_ptr(fmt
->bytelanes
, dirent
->myloc
, loc
);
604 dir_return
->curr_ent
= dir_return
->dirbase
;
608 nubus_find_rsrc(bus_space_tag_t bst
, bus_space_handle_t bsh
, nubus_slot
*fmt
,
609 nubus_dir
*dir
, u_int8_t rsrcid
, nubus_dirent
*dirent_return
)
612 u_int8_t byte
, lanes
= fmt
->bytelanes
;
615 if (nubus_debug
& NDB_FOLLOW
)
616 printf("nubus_find_rsrc(%p, %p, 0x%x, %p)\n",
617 fmt
, dir
, rsrcid
, dirent_return
);
619 if (fmt
->test_pattern
!= NUBUS_ROM_TEST_PATTERN
)
622 entry
= dir
->curr_ent
;
624 byte
= nubus_read_1(bst
, bsh
, lanes
, entry
);
626 if (nubus_debug
& NDB_FOLLOW
)
627 printf("\tFound rsrc 0x%x.\n", byte
);
629 if (byte
== rsrcid
) {
630 dirent_return
->myloc
= entry
;
631 dirent_return
->rsrc_id
= rsrcid
;
632 entry
= nubus_read_4(bst
, bsh
, lanes
, entry
);
633 dirent_return
->offset
= (entry
& 0x00ffffff);
637 entry
= dir
->dirbase
;
639 entry
= nubus_adjust_ptr(lanes
, entry
, 4);
641 } while (entry
!= (u_long
)dir
->curr_ent
);
646 nubus_get_ind_data(bus_space_tag_t bst
, bus_space_handle_t bsh
, nubus_slot
*fmt
,
647 nubus_dirent
*dirent
, char *data_return
, int nbytes
)
650 u_int8_t lanes
= fmt
->bytelanes
;
653 if (nubus_debug
& NDB_FOLLOW
)
654 printf("nubus_get_ind_data(%p, %p, %p, %d).\n",
655 fmt
, dirent
, data_return
, nbytes
);
657 if ((loc
= dirent
->offset
) & 0x800000) {
660 loc
= nubus_adjust_ptr(lanes
, dirent
->myloc
, loc
);
663 *data_return
++ = nubus_read_1(bst
, bsh
, lanes
, loc
);
664 loc
= nubus_adjust_ptr(lanes
, loc
, 1);
670 nubus_get_c_string(bus_space_tag_t bst
, bus_space_handle_t bsh
, nubus_slot
*fmt
,
671 nubus_dirent
*dirent
, char *data_return
, int max_bytes
)
674 u_int8_t lanes
= fmt
->bytelanes
;
677 if (nubus_debug
& NDB_FOLLOW
)
678 printf("nubus_get_c_string(%p, %p, %p, %d).\n",
679 fmt
, dirent
, data_return
, max_bytes
);
681 if ((loc
= dirent
->offset
) & 0x800000)
684 loc
= nubus_adjust_ptr(lanes
, dirent
->myloc
, loc
);
687 while (max_bytes
--) {
688 if ((*data_return
++ =
689 nubus_read_1(bst
, bsh
, lanes
, loc
)) == 0)
691 loc
= nubus_adjust_ptr(lanes
, loc
, 1);
693 *(data_return
-1) = '\0';
698 * Get list of address ranges for an sMemory resource
702 nubus_get_smem_addr_rangelist(bus_space_tag_t bst
, bus_space_handle_t bsh
,
703 nubus_slot
*fmt
, nubus_dirent
*dirent
, void *data_return
)
706 u_int8_t lanes
= fmt
->bytelanes
;
711 if (nubus_debug
& NDB_FOLLOW
)
712 printf("nubus_get_smem_addr_rangelist(%p, %p, %p).\n",
713 fmt
, dirent
, data_return
);
715 if ((loc
= dirent
->offset
) & 0x800000) {
718 loc
= nubus_adjust_ptr(lanes
, dirent
->myloc
, loc
);
720 /* Obtain the block length from the head of the list */
721 blocklen
= nubus_read_4(bst
, bsh
, lanes
, loc
);
724 * malloc a block of (blocklen) bytes
725 * caller must recycle block after use
727 blocklist
= malloc(blocklen
,M_TEMP
,M_WAITOK
);
729 /* read ((blocklen - 4) / 8) (length,offset) pairs into block */
730 nubus_get_ind_data(bst
, bsh
, fmt
, dirent
, blocklist
, blocklen
);
732 if (nubus_debug
& NDB_FOLLOW
) {
734 nubus_smem_rangelist
*rlist
;
736 rlist
= (nubus_smem_rangelist
*)blocklist
;
737 printf("\tblock@%p, len 0x0%X\n", rlist
, rlist
->length
);
739 for (ii
=0; ii
< ((blocklen
- 4) / 8); ii
++) {
740 printf("\tRange %d: base addr 0x%X [0x%X]\n", ii
,
741 rlist
->range
[ii
].offset
, rlist
->range
[ii
].length
);
745 *(void **)data_return
= blocklist
;
750 static const char *huh
= "???";
753 nubus_get_vendor(bus_space_tag_t bst
, bus_space_handle_t bsh
, nubus_slot
*fmt
,
756 static char str_ret
[64];
761 if (nubus_debug
& NDB_FOLLOW
)
762 printf("nubus_get_vendor(%p, 0x%x).\n", fmt
, rsrc
);
764 nubus_get_main_dir(fmt
, &dir
);
765 if (nubus_find_rsrc(bst
, bsh
, fmt
, &dir
, 1, &ent
) <= 0)
767 nubus_get_dir_from_rsrc(fmt
, &ent
, &dir
);
769 if (nubus_find_rsrc(bst
, bsh
, fmt
, &dir
, NUBUS_RSRC_VENDORINFO
, &ent
)
772 nubus_get_dir_from_rsrc(fmt
, &ent
, &dir
);
774 if (nubus_find_rsrc(bst
, bsh
, fmt
, &dir
, rsrc
, &ent
) <= 0)
777 nubus_get_c_string(bst
, bsh
, fmt
, &ent
, str_ret
, 64);
783 nubus_get_card_name(bus_space_tag_t bst
, bus_space_handle_t bsh
,
786 static char name_ret
[64];
791 if (nubus_debug
& NDB_FOLLOW
)
792 printf("nubus_get_card_name(%p).\n", fmt
);
794 nubus_get_main_dir(fmt
, &dir
);
796 if (nubus_find_rsrc(bst
, bsh
, fmt
, &dir
, 1, &ent
) <= 0)
799 nubus_get_dir_from_rsrc(fmt
, &ent
, &dir
);
801 if (nubus_find_rsrc(bst
, bsh
, fmt
, &dir
, NUBUS_RSRC_NAME
, &ent
) <= 0)
804 nubus_get_c_string(bst
, bsh
, fmt
, &ent
, name_ret
, 64);
811 nubus_scan_slot(bus_space_tag_t bst
, int slotno
)
814 char twirl
[] = "-\\|/";
815 bus_space_handle_t sc_bsh
;
817 if (bus_space_map(bst
, NUBUS_SLOT2PA(slotno
), NBMEMSIZE
, 0, &sc_bsh
)) {
818 printf("nubus_scan_slot: failed to map slot %x\n", slotno
);
822 printf("Scanning slot %c for accessible regions:\n",
823 slotno
== 9 ? '9' : slotno
- 10 + 'A');
824 for (i
=0 ; i
<NBMEMSIZE
; i
++) {
825 if (mac68k_bus_space_probe(bst
, sc_bsh
, i
, 1)) {
827 printf("\t0x%x-", i
);
837 printf("%c\b", twirl
[(i
/100)%4]);