1998-05-02 20:45:27 +04:00
|
|
|
/* $NetBSD: nubus.c,v 1.44 1998/05/02 16:45:30 scottr Exp $ */
|
1994-10-26 11:45:48 +03:00
|
|
|
|
1995-04-30 00:23:36 +04:00
|
|
|
/*
|
1996-12-17 09:47:37 +03:00
|
|
|
* Copyright (c) 1995, 1996 Allen Briggs. All rights reserved.
|
1993-09-29 09:08:37 +03:00
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
* 3. All advertising materials mentioning features or use of this software
|
|
|
|
* must display the following acknowledgement:
|
1995-04-30 00:23:36 +04:00
|
|
|
* This product includes software developed by Allen Briggs.
|
|
|
|
* 4. The name of the author may not be used to endorse or promote products
|
|
|
|
* derived from this software without specific prior written permission.
|
1993-09-29 09:08:37 +03:00
|
|
|
*
|
1995-04-30 00:23:36 +04:00
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
1993-09-29 09:08:37 +03:00
|
|
|
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|
|
|
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
1995-04-30 00:23:36 +04:00
|
|
|
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
1993-09-29 09:08:37 +03:00
|
|
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
|
|
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
|
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
|
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
1995-04-30 00:23:36 +04:00
|
|
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|
|
|
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
1993-09-29 09:08:37 +03:00
|
|
|
*/
|
|
|
|
|
1994-01-30 04:11:36 +03:00
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/systm.h>
|
|
|
|
#include <sys/device.h>
|
1996-12-17 09:47:37 +03:00
|
|
|
#include <sys/buf.h>
|
|
|
|
#include <sys/conf.h>
|
|
|
|
#include <sys/dmap.h>
|
|
|
|
|
|
|
|
#include <vm/vm.h>
|
|
|
|
#include <vm/vm_kern.h>
|
|
|
|
#include <vm/vm_map.h>
|
1993-09-29 09:08:37 +03:00
|
|
|
|
1996-05-05 10:15:56 +04:00
|
|
|
#include <machine/autoconf.h>
|
1997-02-22 03:00:34 +03:00
|
|
|
#include <machine/bus.h>
|
1996-12-17 09:47:37 +03:00
|
|
|
#include <machine/vmparam.h>
|
|
|
|
#include <machine/param.h>
|
1995-04-21 06:47:35 +04:00
|
|
|
#include <machine/cpu.h>
|
1996-12-17 09:47:37 +03:00
|
|
|
#include <machine/pte.h>
|
1997-03-15 21:33:44 +03:00
|
|
|
#include <machine/viareg.h>
|
1993-09-29 09:08:37 +03:00
|
|
|
|
1995-06-21 06:59:08 +04:00
|
|
|
#include <vm/vm.h>
|
|
|
|
|
1998-05-02 20:45:27 +04:00
|
|
|
#include <mac68k/nubus/nubus.h>
|
1993-09-29 09:08:37 +03:00
|
|
|
|
1996-05-08 19:14:53 +04:00
|
|
|
#ifdef DEBUG
|
1995-06-21 06:59:08 +04:00
|
|
|
#define NDB_PROBE 0x1
|
|
|
|
#define NDB_FOLLOW 0x2
|
|
|
|
#define NDB_ARITH 0x4
|
1997-05-11 23:11:27 +04:00
|
|
|
static int nubus_debug = 0 /* | NDB_PROBE */;
|
1995-06-21 06:59:08 +04:00
|
|
|
#endif
|
|
|
|
|
1996-12-16 19:17:02 +03:00
|
|
|
static int nubus_print __P((void *, const char *));
|
|
|
|
static int nubus_match __P((struct device *, struct cfdata *, void *));
|
|
|
|
static void nubus_attach __P((struct device *, struct device *, void *));
|
1997-05-11 23:11:27 +04:00
|
|
|
static int nubus_video_resource __P((int));
|
1993-09-29 09:08:37 +03:00
|
|
|
|
1997-05-11 23:11:27 +04:00
|
|
|
static int nubus_probe_slot __P((bus_space_tag_t, bus_space_handle_t,
|
|
|
|
int, nubus_slot *));
|
|
|
|
static u_int32_t nubus_calc_CRC __P((bus_space_tag_t, bus_space_handle_t,
|
|
|
|
nubus_slot *));
|
|
|
|
|
|
|
|
static u_long nubus_adjust_ptr __P((u_int8_t, u_long, long));
|
|
|
|
static u_int8_t nubus_read_1 __P((bus_space_tag_t, bus_space_handle_t,
|
|
|
|
u_int8_t, u_long));
|
1996-04-01 05:35:48 +04:00
|
|
|
#ifdef notyet
|
1997-05-11 23:11:27 +04:00
|
|
|
static u_int16_t nubus_read_2 __P((bus_space_tag_t, bus_space_handle_t,
|
|
|
|
u_int8_t, u_long));
|
1996-04-01 05:35:48 +04:00
|
|
|
#endif
|
1997-05-11 23:11:27 +04:00
|
|
|
static u_int32_t nubus_read_4 __P((bus_space_tag_t, bus_space_handle_t,
|
|
|
|
u_int8_t, u_long));
|
1996-12-17 09:47:37 +03:00
|
|
|
|
1996-03-17 04:26:49 +03:00
|
|
|
struct cfattach nubus_ca = {
|
1996-12-16 19:17:02 +03:00
|
|
|
sizeof(struct nubus_softc), nubus_match, nubus_attach
|
1996-03-17 04:26:49 +03:00
|
|
|
};
|
|
|
|
|
1996-05-05 10:15:56 +04:00
|
|
|
static int
|
1996-12-16 19:17:02 +03:00
|
|
|
nubus_match(parent, cf, aux)
|
1996-05-05 10:15:56 +04:00
|
|
|
struct device *parent;
|
1996-12-16 19:17:02 +03:00
|
|
|
struct cfdata *cf;
|
|
|
|
void *aux;
|
1996-05-05 10:15:56 +04:00
|
|
|
{
|
1996-12-17 09:47:37 +03:00
|
|
|
static int nubus_matched = 0;
|
1996-05-05 10:15:56 +04:00
|
|
|
|
1996-12-17 09:47:37 +03:00
|
|
|
/* Allow only one instance. */
|
|
|
|
if (nubus_matched)
|
|
|
|
return (0);
|
|
|
|
|
|
|
|
nubus_matched = 1;
|
|
|
|
return (1);
|
1996-05-05 10:15:56 +04:00
|
|
|
}
|
|
|
|
|
1995-04-30 00:23:36 +04:00
|
|
|
static void
|
1996-12-16 19:17:02 +03:00
|
|
|
nubus_attach(parent, self, aux)
|
|
|
|
struct device *parent, *self;
|
|
|
|
void *aux;
|
1995-04-30 00:23:36 +04:00
|
|
|
{
|
1996-12-16 19:17:02 +03:00
|
|
|
struct nubus_attach_args na_args;
|
1997-05-11 23:11:27 +04:00
|
|
|
bus_space_tag_t bst;
|
|
|
|
bus_space_handle_t bsh;
|
1996-12-16 19:17:02 +03:00
|
|
|
nubus_slot fmtblock;
|
|
|
|
nubus_dir dir;
|
|
|
|
nubus_dirent dirent;
|
|
|
|
nubus_type slottype;
|
1997-04-10 07:28:54 +04:00
|
|
|
u_long entry;
|
1996-12-16 19:17:02 +03:00
|
|
|
int i, rsrcid;
|
1997-05-11 23:11:27 +04:00
|
|
|
u_int8_t lanes;
|
1993-09-29 09:08:37 +03:00
|
|
|
|
1996-10-13 07:21:13 +04:00
|
|
|
printf("\n");
|
1995-04-21 06:47:35 +04:00
|
|
|
|
1996-05-05 10:15:56 +04:00
|
|
|
for (i = NUBUS_MIN_SLOT; i <= NUBUS_MAX_SLOT; i++) {
|
1997-05-11 23:11:27 +04:00
|
|
|
na_args.slot = i;
|
|
|
|
na_args.na_tag = bst = MAC68K_BUS_SPACE_MEM;
|
|
|
|
|
|
|
|
if (bus_space_map(bst,
|
|
|
|
NUBUS_SLOT2PA(na_args.slot), NBMEMSIZE, 0, &bsh)) {
|
|
|
|
#ifdef DIAGNOSTIC
|
1997-07-15 03:05:35 +04:00
|
|
|
printf("%s: failed to map slot %x, address %p\n",
|
1997-05-11 23:11:27 +04:00
|
|
|
self->dv_xname, i, (void *)NUBUS_SLOT2PA(i));
|
|
|
|
#endif
|
1996-12-16 19:17:02 +03:00
|
|
|
continue;
|
1997-05-11 23:11:27 +04:00
|
|
|
}
|
1996-12-16 19:17:02 +03:00
|
|
|
|
1997-05-11 23:11:27 +04:00
|
|
|
if (nubus_probe_slot(bst, bsh, i, &fmtblock) <= 0) {
|
|
|
|
notfound:
|
|
|
|
bus_space_unmap(bst, bsh, NBMEMSIZE);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
1997-04-10 07:28:54 +04:00
|
|
|
rsrcid = 0x80;
|
1997-05-11 23:11:27 +04:00
|
|
|
lanes = fmtblock.bytelanes;
|
1996-12-16 19:17:02 +03:00
|
|
|
|
|
|
|
nubus_get_main_dir(&fmtblock, &dir);
|
|
|
|
|
1997-04-10 07:28:54 +04:00
|
|
|
/*
|
|
|
|
* Get the resource for the first function on the card.
|
|
|
|
* This is assumed to be at resource ID 0x80. If we can
|
|
|
|
* not find this entry (as we can not on some video cards),
|
|
|
|
* check to see if we can get a different ID from the list
|
|
|
|
* of video resources given to us by the booter. If that
|
|
|
|
* doesn't work either, take the first resource following
|
|
|
|
* the board resource.
|
|
|
|
*/
|
1997-05-11 23:11:27 +04:00
|
|
|
if (nubus_find_rsrc(bst, bsh,
|
|
|
|
&fmtblock, &dir, rsrcid, &dirent) <= 0) {
|
1997-04-10 07:28:54 +04:00
|
|
|
if ((rsrcid = nubus_video_resource(i)) == -1) {
|
|
|
|
/*
|
|
|
|
* Since nubus_find_rsrc failed, the directory
|
|
|
|
* is back at its base.
|
|
|
|
*/
|
|
|
|
entry = dir.curr_ent;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* All nubus cards should have a board
|
|
|
|
* resource, but be sure that's what it
|
|
|
|
* is before we skip it.
|
|
|
|
*/
|
1997-05-11 23:11:27 +04:00
|
|
|
rsrcid = nubus_read_1(bst, bsh,
|
|
|
|
lanes, entry);
|
1997-04-10 07:28:54 +04:00
|
|
|
if (rsrcid == 0x1)
|
1997-05-11 23:11:27 +04:00
|
|
|
entry = nubus_adjust_ptr(lanes,
|
|
|
|
dir.curr_ent, 4);
|
1997-04-10 07:28:54 +04:00
|
|
|
|
1997-05-11 23:11:27 +04:00
|
|
|
rsrcid = nubus_read_1(bst, bsh, lanes, entry);
|
1997-04-10 07:28:54 +04:00
|
|
|
#ifdef DEBUG
|
|
|
|
if (nubus_debug & NDB_FOLLOW)
|
|
|
|
printf("\tUsing rsrc 0x%x.\n", rsrcid);
|
|
|
|
#endif
|
1997-05-11 23:11:27 +04:00
|
|
|
if (rsrcid == 0xff) /* end of chain */
|
|
|
|
goto notfound;
|
1997-04-10 07:28:54 +04:00
|
|
|
}
|
|
|
|
/*
|
|
|
|
* Try to find the resource passed by the booter
|
|
|
|
* or the one we just tracked down.
|
|
|
|
*/
|
1997-05-11 23:11:27 +04:00
|
|
|
if (nubus_find_rsrc(bst, bsh,
|
|
|
|
&fmtblock, &dir, rsrcid, &dirent) <= 0)
|
|
|
|
goto notfound;
|
1997-04-10 07:28:54 +04:00
|
|
|
}
|
1996-12-16 19:17:02 +03:00
|
|
|
|
|
|
|
nubus_get_dir_from_rsrc(&fmtblock, &dirent, &dir);
|
|
|
|
|
1997-05-11 23:11:27 +04:00
|
|
|
if (nubus_find_rsrc(bst, bsh,
|
|
|
|
&fmtblock, &dir, NUBUS_RSRC_TYPE, &dirent) <= 0)
|
|
|
|
goto notfound;
|
1996-12-16 19:17:02 +03:00
|
|
|
|
1997-05-11 23:11:27 +04:00
|
|
|
if (nubus_get_ind_data(bst, bsh, &fmtblock, &dirent,
|
|
|
|
(caddr_t)&slottype, sizeof(nubus_type)) <= 0)
|
|
|
|
goto notfound;
|
1996-12-16 19:17:02 +03:00
|
|
|
|
1997-04-10 07:28:54 +04:00
|
|
|
/*
|
|
|
|
* If this is a display card, try to pull out the correct
|
|
|
|
* display mode as passed by the booter.
|
|
|
|
*/
|
|
|
|
if (slottype.category == NUBUS_CATEGORY_DISPLAY) {
|
1997-05-11 23:11:27 +04:00
|
|
|
int r;
|
1997-04-10 07:28:54 +04:00
|
|
|
|
|
|
|
if ((r = nubus_video_resource(i)) != -1) {
|
|
|
|
|
|
|
|
nubus_get_main_dir(&fmtblock, &dir);
|
|
|
|
|
1997-05-11 23:11:27 +04:00
|
|
|
if (nubus_find_rsrc(bst, bsh,
|
|
|
|
&fmtblock, &dir, r, &dirent) <= 0)
|
|
|
|
goto notfound;
|
1997-04-10 07:28:54 +04:00
|
|
|
|
|
|
|
nubus_get_dir_from_rsrc(&fmtblock,
|
1997-05-11 23:11:27 +04:00
|
|
|
&dirent, &dir);
|
1997-04-10 07:28:54 +04:00
|
|
|
|
1997-05-11 23:11:27 +04:00
|
|
|
if (nubus_find_rsrc(bst, bsh, &fmtblock, &dir,
|
|
|
|
NUBUS_RSRC_TYPE, &dirent) <= 0)
|
|
|
|
goto notfound;
|
1997-04-10 07:28:54 +04:00
|
|
|
|
1997-05-11 23:11:27 +04:00
|
|
|
if (nubus_get_ind_data(bst, bsh,
|
|
|
|
&fmtblock, &dirent, (caddr_t)&slottype,
|
|
|
|
sizeof(nubus_type)) <= 0)
|
|
|
|
goto notfound;
|
1997-04-23 17:37:43 +04:00
|
|
|
|
|
|
|
rsrcid = r;
|
1997-04-10 07:28:54 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1996-12-16 19:17:02 +03:00
|
|
|
na_args.slot = i;
|
|
|
|
na_args.rsrcid = rsrcid;
|
|
|
|
na_args.category = slottype.category;
|
|
|
|
na_args.type = slottype.type;
|
|
|
|
na_args.drsw = slottype.drsw;
|
|
|
|
na_args.drhw = slottype.drhw;
|
|
|
|
na_args.fmt = &fmtblock;
|
|
|
|
|
1997-05-11 23:11:27 +04:00
|
|
|
bus_space_unmap(bst, bsh, NBMEMSIZE);
|
|
|
|
|
1996-12-16 19:17:02 +03:00
|
|
|
config_found(self, &na_args, nubus_print);
|
1995-08-04 06:55:06 +04:00
|
|
|
}
|
1997-03-15 21:33:44 +03:00
|
|
|
|
|
|
|
enable_nubus_intr();
|
1993-09-29 09:08:37 +03:00
|
|
|
}
|
|
|
|
|
1995-04-21 06:47:35 +04:00
|
|
|
static int
|
1997-07-15 11:43:12 +04:00
|
|
|
nubus_print(aux, pnp)
|
1996-12-16 19:17:02 +03:00
|
|
|
void *aux;
|
1997-07-15 11:43:12 +04:00
|
|
|
const char *pnp;
|
1993-09-29 09:08:37 +03:00
|
|
|
{
|
1997-05-11 23:11:27 +04:00
|
|
|
struct nubus_attach_args *na = (struct nubus_attach_args *)aux;
|
|
|
|
bus_space_tag_t bst = na->na_tag;
|
|
|
|
bus_space_handle_t bsh;
|
1995-04-30 00:23:36 +04:00
|
|
|
|
1997-07-15 11:43:12 +04:00
|
|
|
if (pnp) {
|
|
|
|
printf("%s slot %x", pnp, na->slot);
|
1997-05-11 23:11:27 +04:00
|
|
|
if (bus_space_map(bst,
|
1997-07-15 11:43:12 +04:00
|
|
|
NUBUS_SLOT2PA(na->slot), NBMEMSIZE, 0, &bsh) == 0) {
|
|
|
|
printf(": %s", nubus_get_card_name(bst, bsh, na->fmt));
|
1997-05-11 23:11:27 +04:00
|
|
|
printf(" (Vendor: %s,", nubus_get_vendor(bst, bsh,
|
|
|
|
na->fmt, NUBUS_RSRC_VEND_ID));
|
1997-07-15 11:43:12 +04:00
|
|
|
printf(" Part: %s)", nubus_get_vendor(bst, bsh,
|
1997-05-11 23:11:27 +04:00
|
|
|
na->fmt, NUBUS_RSRC_VEND_PART));
|
|
|
|
bus_space_unmap(bst, bsh, NBMEMSIZE);
|
|
|
|
}
|
1997-07-15 11:43:12 +04:00
|
|
|
#ifdef DIAGNOSTIC
|
|
|
|
else
|
|
|
|
printf(":");
|
|
|
|
printf(" Type: %04x %04x %04x %04x",
|
|
|
|
na->category, na->type, na->drsw, na->drhw);
|
|
|
|
#endif
|
|
|
|
} else {
|
|
|
|
printf(" slot %x", na->slot);
|
1995-04-30 00:23:36 +04:00
|
|
|
}
|
|
|
|
return (UNCONF);
|
1993-09-29 09:08:37 +03:00
|
|
|
}
|
|
|
|
|
1997-05-11 23:11:27 +04:00
|
|
|
static int
|
1996-12-16 19:17:02 +03:00
|
|
|
nubus_video_resource(slot)
|
|
|
|
int slot;
|
|
|
|
{
|
|
|
|
extern u_int16_t mac68k_vrsrc_vec[];
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0 ; i < 6 ; i++)
|
|
|
|
if ((mac68k_vrsrc_vec[i] & 0xff) == slot)
|
|
|
|
return ((mac68k_vrsrc_vec[i] >> 8) & 0xff);
|
|
|
|
return (-1);
|
|
|
|
}
|
|
|
|
|
1995-04-30 00:23:36 +04:00
|
|
|
/*
|
|
|
|
* Probe a given nubus slot. If a card is there and we can get the
|
|
|
|
* format block from it's clutching decl. ROMs, fill the format block
|
|
|
|
* and return non-zero. If we can't find a card there with a valid
|
|
|
|
* decl. ROM, return 0.
|
|
|
|
*
|
|
|
|
* First, we check to see if we can access the memory at the tail
|
|
|
|
* end of the slot. If so, then we check for a bytelanes byte. We
|
|
|
|
* could probably just return a failure status if we bus error on
|
|
|
|
* the first try, but there really is little reason not to go ahead
|
|
|
|
* and check the other three locations in case there's a wierd card
|
|
|
|
* out there.
|
|
|
|
*
|
|
|
|
* Checking for a card involves locating the "bytelanes" byte which
|
|
|
|
* tells us how to interpret the declaration ROM's data. The format
|
|
|
|
* block is at the top of the card's standard memory space and the
|
|
|
|
* bytelanes byte is at the end of that block.
|
|
|
|
*
|
|
|
|
* After some inspection of the bytelanes byte, it appears that it
|
|
|
|
* takes the form 0xXY where Y is a bitmask of the bytelanes in use
|
|
|
|
* and X is a bitmask of the lanes to ignore. Hence, (X ^ Y) == 0
|
|
|
|
* and (less obviously), Y will have the upper N bits clear if it is
|
|
|
|
* found N bytes from the last possible location. Both that and
|
|
|
|
* the exclusive-or check are made.
|
|
|
|
*
|
|
|
|
* If a valid
|
|
|
|
*/
|
1997-05-11 23:11:27 +04:00
|
|
|
static u_int8_t nbits[] = {0,1,1,2,1,2,2,3,1,2,2,3,2,3,3,4};
|
1995-04-21 06:47:35 +04:00
|
|
|
static int
|
1997-05-11 23:11:27 +04:00
|
|
|
nubus_probe_slot(bst, bsh, slot, fmt)
|
|
|
|
bus_space_tag_t bst;
|
|
|
|
bus_space_handle_t bsh;
|
|
|
|
int slot;
|
|
|
|
nubus_slot *fmt;
|
1993-09-29 09:08:37 +03:00
|
|
|
{
|
1997-05-11 23:11:27 +04:00
|
|
|
u_long ofs, hdr;
|
|
|
|
int i, j, found, hdr_size;
|
|
|
|
u_int8_t lanes;
|
1995-04-21 06:47:35 +04:00
|
|
|
|
1995-06-21 06:59:08 +04:00
|
|
|
#ifdef DEBUG
|
1997-05-11 23:11:27 +04:00
|
|
|
if (nubus_debug & NDB_PROBE)
|
|
|
|
printf("probing slot %x\n", slot);
|
1995-06-21 06:59:08 +04:00
|
|
|
#endif
|
|
|
|
|
1997-05-11 23:11:27 +04:00
|
|
|
/*
|
|
|
|
* The idea behind this glorious work of art is to probe for only
|
1997-05-13 17:22:56 +04:00
|
|
|
* valid bytelanes values at appropriate locations (see DC&D p. 159
|
1997-05-11 23:11:27 +04:00
|
|
|
* for a list). Note the pattern: the first 8 values are at offset
|
|
|
|
* 0xffffff in the slot's space; the next 4 values at 0xfffffe; the
|
|
|
|
* next 2 values at 0xfffffd; and the last one at 0xfffffc.
|
|
|
|
*
|
|
|
|
* The nested loops implement an efficient search of this space,
|
|
|
|
* probing first for a valid address, then checking for each of the
|
|
|
|
* valid bytelanes values at that address.
|
|
|
|
*/
|
|
|
|
ofs = NBMEMSIZE;
|
|
|
|
lanes = 0xf;
|
|
|
|
|
|
|
|
for (j = 8, found = 0; j > 0 && !found; j >>= 1) {
|
|
|
|
ofs--;
|
|
|
|
for (i = j; i > 0; i--, lanes--) {
|
1998-01-13 22:15:32 +03:00
|
|
|
if (!mac68k_bus_space_probe(bst, bsh, ofs, 1)) {
|
1997-05-11 23:11:27 +04:00
|
|
|
lanes -= i;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (bus_space_read_1(bst, bsh, ofs) ==
|
|
|
|
(((~lanes & 0xf) << 4) | lanes)) {
|
|
|
|
found = 1;
|
|
|
|
break;
|
|
|
|
}
|
1995-04-30 00:23:36 +04:00
|
|
|
}
|
|
|
|
}
|
1997-05-11 23:11:27 +04:00
|
|
|
|
|
|
|
if (!found) {
|
1995-04-30 00:23:36 +04:00
|
|
|
#ifdef DEBUG
|
1997-05-11 23:11:27 +04:00
|
|
|
if (nubus_debug & NDB_PROBE)
|
|
|
|
printf("bytelanes not found for slot %x\n", slot);
|
1995-04-30 00:23:36 +04:00
|
|
|
#endif
|
|
|
|
return 0;
|
1997-05-11 23:11:27 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
fmt->bytelanes = lanes;
|
|
|
|
fmt->step = nbits[(lanes & 0x0f)];
|
|
|
|
fmt->slot = slot; /* XXX redundant; get rid of this someday */
|
1993-09-29 09:08:37 +03:00
|
|
|
|
1995-04-30 00:23:36 +04:00
|
|
|
#ifdef DEBUG
|
1995-06-21 06:59:08 +04:00
|
|
|
if (nubus_debug & NDB_PROBE)
|
1996-10-13 07:21:13 +04:00
|
|
|
printf("bytelanes of 0x%x found for slot 0x%x.\n",
|
1997-05-11 23:11:27 +04:00
|
|
|
fmt->bytelanes, slot);
|
1995-04-30 00:23:36 +04:00
|
|
|
#endif
|
1995-04-21 06:47:35 +04:00
|
|
|
|
1995-04-30 00:23:36 +04:00
|
|
|
/*
|
|
|
|
* Go ahead and attempt to load format header.
|
|
|
|
* First, we need to find the first byte beyond memory that
|
|
|
|
* would be valid. This is necessary for NUBUS_ROM_offset()
|
|
|
|
* to work.
|
|
|
|
*/
|
1997-05-11 23:11:27 +04:00
|
|
|
hdr = NBMEMSIZE;
|
|
|
|
hdr_size = 20;
|
1996-05-05 10:15:56 +04:00
|
|
|
|
1997-05-11 23:11:27 +04:00
|
|
|
i = 0x10 | (lanes & 0x0f);
|
1995-04-30 00:23:36 +04:00
|
|
|
while ((i & 1) == 0) {
|
|
|
|
hdr++;
|
|
|
|
i >>= 1;
|
|
|
|
}
|
|
|
|
fmt->top = hdr;
|
1997-05-11 23:11:27 +04:00
|
|
|
hdr = nubus_adjust_ptr(lanes, hdr, -hdr_size);
|
1995-04-30 00:23:36 +04:00
|
|
|
#ifdef DEBUG
|
1995-06-21 06:59:08 +04:00
|
|
|
if (nubus_debug & NDB_PROBE)
|
1996-10-21 09:42:23 +04:00
|
|
|
printf("fmt->top is 0x%lx, that minus 0x%x puts us at 0x%lx.\n",
|
1997-05-11 23:11:27 +04:00
|
|
|
fmt->top, hdr_size, hdr);
|
|
|
|
if (nubus_debug & NDB_ARITH)
|
|
|
|
for (i = 1 ; i < 8 ; i++)
|
|
|
|
printf("0x%lx - 0x%x = 0x%lx, + 0x%x = 0x%lx.\n",
|
|
|
|
hdr, i, nubus_adjust_ptr(lanes, hdr, -i),
|
|
|
|
i, nubus_adjust_ptr(lanes, hdr, i));
|
1995-04-30 00:23:36 +04:00
|
|
|
#endif
|
|
|
|
|
1997-05-11 23:11:27 +04:00
|
|
|
fmt->directory_offset =
|
|
|
|
0xff000000 | nubus_read_4(bst, bsh, lanes, hdr);
|
|
|
|
hdr = nubus_adjust_ptr(lanes, hdr, 4);
|
|
|
|
fmt->length = nubus_read_4(bst, bsh, lanes, hdr);
|
|
|
|
hdr = nubus_adjust_ptr(lanes, hdr, 4);
|
|
|
|
fmt->crc = nubus_read_4(bst, bsh, lanes, hdr);
|
|
|
|
hdr = nubus_adjust_ptr(lanes, hdr, 4);
|
|
|
|
fmt->revision_level = nubus_read_1(bst, bsh, lanes, hdr);
|
|
|
|
hdr = nubus_adjust_ptr(lanes, hdr, 1);
|
|
|
|
fmt->format = nubus_read_1(bst, bsh, lanes, hdr);
|
|
|
|
hdr = nubus_adjust_ptr(lanes, hdr, 1);
|
|
|
|
fmt->test_pattern = nubus_read_4(bst, bsh, lanes, hdr);
|
1995-04-30 00:23:36 +04:00
|
|
|
|
1996-05-08 19:14:53 +04:00
|
|
|
#ifdef DEBUG
|
1995-06-21 06:59:08 +04:00
|
|
|
if (nubus_debug & NDB_PROBE) {
|
1996-10-13 07:21:13 +04:00
|
|
|
printf("Directory offset 0x%x\t", fmt->directory_offset);
|
|
|
|
printf("Length 0x%x\t", fmt->length);
|
|
|
|
printf("CRC 0x%x\n", fmt->crc);
|
|
|
|
printf("Revision level 0x%x\t", fmt->revision_level);
|
|
|
|
printf("Format 0x%x\t", fmt->format);
|
|
|
|
printf("Test Pattern 0x%x\n", fmt->test_pattern);
|
1995-06-21 06:59:08 +04:00
|
|
|
}
|
1995-04-30 00:23:36 +04:00
|
|
|
#endif
|
|
|
|
|
1995-06-21 06:59:08 +04:00
|
|
|
if ((fmt->directory_offset & 0x00ff0000) == 0) {
|
1996-10-13 07:21:13 +04:00
|
|
|
printf("Invalid looking directory offset (0x%x)!\n",
|
1997-05-11 23:11:27 +04:00
|
|
|
fmt->directory_offset);
|
1995-06-21 06:59:08 +04:00
|
|
|
return 0;
|
|
|
|
}
|
1995-04-30 00:23:36 +04:00
|
|
|
if (fmt->test_pattern != NUBUS_ROM_TEST_PATTERN) {
|
1996-10-13 07:21:13 +04:00
|
|
|
printf("Nubus--test pattern invalid:\n");
|
1997-05-11 23:11:27 +04:00
|
|
|
printf(" slot 0x%x, bytelanes 0x%x?\n", fmt->slot, lanes);
|
1996-10-13 07:21:13 +04:00
|
|
|
printf(" read test 0x%x, compare with 0x%x.\n",
|
1997-05-11 23:11:27 +04:00
|
|
|
fmt->test_pattern, NUBUS_ROM_TEST_PATTERN);
|
1995-04-30 00:23:36 +04:00
|
|
|
return 0;
|
1993-09-29 09:08:37 +03:00
|
|
|
}
|
|
|
|
|
1995-04-30 00:23:36 +04:00
|
|
|
/* Perform CRC */
|
1997-05-11 23:11:27 +04:00
|
|
|
if (fmt->crc != nubus_calc_CRC(bst, bsh, fmt)) {
|
|
|
|
printf("Nubus--crc check failed, slot 0x%x.\n", fmt->slot);
|
1995-04-30 00:23:36 +04:00
|
|
|
return 0;
|
1993-09-29 09:08:37 +03:00
|
|
|
}
|
1995-04-21 06:47:35 +04:00
|
|
|
|
1995-04-30 00:23:36 +04:00
|
|
|
return 1;
|
1993-09-29 09:08:37 +03:00
|
|
|
}
|
|
|
|
|
1997-05-11 23:11:27 +04:00
|
|
|
static u_int32_t
|
|
|
|
nubus_calc_CRC(bst, bsh, fmt)
|
|
|
|
bus_space_tag_t bst;
|
|
|
|
bus_space_handle_t bsh;
|
|
|
|
nubus_slot *fmt;
|
|
|
|
{
|
|
|
|
#if 0
|
|
|
|
u_long base, ptr, crc_loc;
|
|
|
|
u_int32_t sum;
|
|
|
|
u_int8_t lanes = fmt->bytelanes;
|
|
|
|
|
|
|
|
base = fmt->top;
|
|
|
|
crc_loc = NUBUS_ROM_offset(fmt, base, -12);
|
|
|
|
ptr = NUBUS_ROM_offset(fmt, base, -fmt->length);
|
|
|
|
|
|
|
|
sum = 0;
|
|
|
|
while (ptr < base)
|
|
|
|
roll #1, sum
|
|
|
|
if (ptr == crc_loc) {
|
|
|
|
roll #3, sum
|
|
|
|
ptr = nubus_adjust_ptr(lanes, ptr, 3);
|
|
|
|
} else {
|
|
|
|
sum += nubus_read_1(bst, bsh, lanes, ptr);
|
|
|
|
}
|
|
|
|
ptr = nubus_adjust_ptr(lanes, ptr, 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
return sum;
|
|
|
|
#endif
|
|
|
|
return fmt->crc;
|
|
|
|
}
|
|
|
|
|
1995-04-30 00:23:36 +04:00
|
|
|
/*
|
|
|
|
* Compute byte offset on card, taking into account bytelanes.
|
|
|
|
* Base must be on a valid bytelane for this function to work.
|
|
|
|
* Return the new address.
|
|
|
|
*
|
|
|
|
* XXX -- There has GOT to be a better way to do this.
|
|
|
|
*/
|
|
|
|
static u_long
|
1997-05-11 23:11:27 +04:00
|
|
|
nubus_adjust_ptr(lanes, base, amt)
|
|
|
|
u_int8_t lanes;
|
|
|
|
u_long base;
|
|
|
|
long amt;
|
1993-09-29 09:08:37 +03:00
|
|
|
{
|
1997-05-11 23:11:27 +04:00
|
|
|
u_int8_t b, t;
|
1995-04-30 00:23:36 +04:00
|
|
|
|
|
|
|
if (!amt)
|
|
|
|
return base;
|
|
|
|
|
|
|
|
if (amt < 0) {
|
|
|
|
amt = -amt;
|
1997-05-11 23:11:27 +04:00
|
|
|
b = lanes;
|
1995-04-30 00:23:36 +04:00
|
|
|
t = (b << 4);
|
|
|
|
b <<= (3 - (base & 0x3));
|
|
|
|
while (amt) {
|
|
|
|
b <<= 1;
|
|
|
|
if (b == t)
|
1997-05-11 23:11:27 +04:00
|
|
|
b = lanes;
|
1995-04-30 00:23:36 +04:00
|
|
|
if (b & 0x08)
|
|
|
|
amt--;
|
|
|
|
base--;
|
|
|
|
}
|
|
|
|
return base;
|
1993-09-29 09:08:37 +03:00
|
|
|
}
|
1995-04-21 06:47:35 +04:00
|
|
|
|
1997-05-11 23:11:27 +04:00
|
|
|
t = (lanes & 0xf) | 0x10;
|
1995-04-30 00:23:36 +04:00
|
|
|
b = t >> (base & 0x3);
|
|
|
|
while (amt) {
|
|
|
|
b >>= 1;
|
|
|
|
if (b == 1)
|
|
|
|
b = t;
|
|
|
|
if (b & 1)
|
|
|
|
amt--;
|
|
|
|
base++;
|
|
|
|
}
|
1993-09-29 09:08:37 +03:00
|
|
|
|
1995-04-30 00:23:36 +04:00
|
|
|
return base;
|
1993-09-29 09:08:37 +03:00
|
|
|
}
|
|
|
|
|
1997-05-11 23:11:27 +04:00
|
|
|
static u_int8_t
|
|
|
|
nubus_read_1(bst, bsh, lanes, ofs)
|
|
|
|
bus_space_tag_t bst;
|
|
|
|
bus_space_handle_t bsh;
|
|
|
|
u_int8_t lanes;
|
|
|
|
u_long ofs;
|
1993-09-29 09:08:37 +03:00
|
|
|
{
|
1997-05-11 23:11:27 +04:00
|
|
|
return bus_space_read_1(bst, bsh, ofs);
|
1993-09-29 09:08:37 +03:00
|
|
|
}
|
|
|
|
|
1996-04-01 05:35:48 +04:00
|
|
|
#ifdef notyet
|
|
|
|
/* Nothing uses this, yet */
|
1997-05-11 23:11:27 +04:00
|
|
|
static u_int16_t
|
|
|
|
nubus_read_2(bst, bsh, lanes, ofs)
|
|
|
|
bus_space_tag_t bst;
|
|
|
|
bus_space_handle_t bsh;
|
|
|
|
u_int8_t lanes;
|
|
|
|
u_long ofs;
|
1993-09-29 09:08:37 +03:00
|
|
|
{
|
1997-05-11 23:11:27 +04:00
|
|
|
u_int16_t s;
|
1995-04-21 06:47:35 +04:00
|
|
|
|
1997-05-11 23:11:27 +04:00
|
|
|
s = (nubus_read_1(bst, bsh, lanes, ofs) << 8);
|
|
|
|
ofs = nubus_adjust_ptr(lanes, ofs, 1);
|
|
|
|
s |= nubus_read_1(bst, bsh, lanes, ofs);
|
1995-04-30 00:23:36 +04:00
|
|
|
return s;
|
|
|
|
}
|
1996-04-01 05:35:48 +04:00
|
|
|
#endif
|
1995-04-21 06:47:35 +04:00
|
|
|
|
1997-05-11 23:11:27 +04:00
|
|
|
static u_int32_t
|
|
|
|
nubus_read_4(bst, bsh, lanes, ofs)
|
|
|
|
bus_space_tag_t bst;
|
|
|
|
bus_space_handle_t bsh;
|
|
|
|
u_int8_t lanes;
|
|
|
|
u_long ofs;
|
1995-04-30 00:23:36 +04:00
|
|
|
{
|
1997-05-11 23:11:27 +04:00
|
|
|
u_int32_t l;
|
|
|
|
int i;
|
1995-04-21 06:47:35 +04:00
|
|
|
|
1995-04-30 00:23:36 +04:00
|
|
|
l = 0;
|
1997-05-11 23:11:27 +04:00
|
|
|
for (i = 0; i < 4; i++) {
|
|
|
|
l = (l << 8) | nubus_read_1(bst, bsh, lanes, ofs);
|
|
|
|
ofs = nubus_adjust_ptr(lanes, ofs, 1);
|
1993-09-29 09:08:37 +03:00
|
|
|
}
|
1995-04-30 00:23:36 +04:00
|
|
|
return l;
|
1993-09-29 09:08:37 +03:00
|
|
|
}
|
|
|
|
|
1995-04-30 00:23:36 +04:00
|
|
|
void
|
1997-05-11 23:11:27 +04:00
|
|
|
nubus_get_main_dir(fmt, dir_return)
|
|
|
|
nubus_slot *fmt;
|
|
|
|
nubus_dir *dir_return;
|
|
|
|
{
|
|
|
|
#ifdef DEBUG
|
|
|
|
if (nubus_debug & NDB_FOLLOW)
|
|
|
|
printf("nubus_get_main_dir(%p, %p)\n",
|
|
|
|
fmt, dir_return);
|
|
|
|
#endif
|
|
|
|
dir_return->dirbase = nubus_adjust_ptr(fmt->bytelanes, fmt->top,
|
|
|
|
fmt->directory_offset - 20);
|
|
|
|
dir_return->curr_ent = dir_return->dirbase;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nubus_get_dir_from_rsrc(fmt, dirent, dir_return)
|
|
|
|
nubus_slot *fmt;
|
|
|
|
nubus_dirent *dirent;
|
|
|
|
nubus_dir *dir_return;
|
1993-09-29 09:08:37 +03:00
|
|
|
{
|
1997-05-11 23:11:27 +04:00
|
|
|
u_long loc;
|
|
|
|
|
1996-05-08 19:14:53 +04:00
|
|
|
#ifdef DEBUG
|
1995-06-21 06:59:08 +04:00
|
|
|
if (nubus_debug & NDB_FOLLOW)
|
1997-05-11 23:11:27 +04:00
|
|
|
printf("nubus_get_dir_from_rsrc(%p, %p, %p).\n",
|
|
|
|
fmt, dirent, dir_return);
|
1995-06-21 06:59:08 +04:00
|
|
|
#endif
|
1997-05-11 23:11:27 +04:00
|
|
|
if ((loc = dirent->offset) & 0x800000) {
|
|
|
|
loc |= 0xff000000;
|
|
|
|
}
|
|
|
|
dir_return->dirbase =
|
|
|
|
nubus_adjust_ptr(fmt->bytelanes, dirent->myloc, loc);
|
1995-04-30 00:23:36 +04:00
|
|
|
dir_return->curr_ent = dir_return->dirbase;
|
1993-09-29 09:08:37 +03:00
|
|
|
}
|
|
|
|
|
1995-04-30 00:23:36 +04:00
|
|
|
int
|
1997-05-11 23:11:27 +04:00
|
|
|
nubus_find_rsrc(bst, bsh, fmt, dir, rsrcid, dirent_return)
|
|
|
|
bus_space_tag_t bst;
|
|
|
|
bus_space_handle_t bsh;
|
|
|
|
nubus_slot *fmt;
|
|
|
|
nubus_dir *dir;
|
|
|
|
u_int8_t rsrcid;
|
|
|
|
nubus_dirent *dirent_return;
|
1993-09-29 09:08:37 +03:00
|
|
|
{
|
1997-05-11 23:11:27 +04:00
|
|
|
u_long entry;
|
|
|
|
u_int8_t byte, lanes = fmt->bytelanes;
|
1995-04-30 00:23:36 +04:00
|
|
|
|
1996-05-08 19:14:53 +04:00
|
|
|
#ifdef DEBUG
|
1995-06-21 06:59:08 +04:00
|
|
|
if (nubus_debug & NDB_FOLLOW)
|
1997-05-11 23:11:27 +04:00
|
|
|
printf("nubus_find_rsrc(%p, %p, 0x%x, %p)\n",
|
|
|
|
fmt, dir, rsrcid, dirent_return);
|
1995-04-30 00:23:36 +04:00
|
|
|
#endif
|
1997-05-11 23:11:27 +04:00
|
|
|
if (fmt->test_pattern != NUBUS_ROM_TEST_PATTERN)
|
1995-06-21 06:59:08 +04:00
|
|
|
return -1;
|
|
|
|
|
|
|
|
entry = dir->curr_ent;
|
1995-04-30 00:23:36 +04:00
|
|
|
do {
|
1997-05-11 23:11:27 +04:00
|
|
|
byte = nubus_read_1(bst, bsh, lanes, entry);
|
1996-05-08 19:14:53 +04:00
|
|
|
#ifdef DEBUG
|
1995-06-21 06:59:08 +04:00
|
|
|
if (nubus_debug & NDB_FOLLOW)
|
1996-10-13 07:21:13 +04:00
|
|
|
printf("\tFound rsrc 0x%x.\n", byte);
|
1995-04-30 00:23:36 +04:00
|
|
|
#endif
|
|
|
|
if (byte == rsrcid) {
|
|
|
|
dirent_return->myloc = entry;
|
|
|
|
dirent_return->rsrc_id = rsrcid;
|
1997-05-11 23:11:27 +04:00
|
|
|
entry = nubus_read_4(bst, bsh, lanes, entry);
|
1995-04-30 00:23:36 +04:00
|
|
|
dirent_return->offset = (entry & 0x00ffffff);
|
|
|
|
return 1;
|
1993-09-29 09:08:37 +03:00
|
|
|
}
|
1995-04-30 00:23:36 +04:00
|
|
|
if (byte == 0xff) {
|
|
|
|
entry = dir->dirbase;
|
|
|
|
} else {
|
1997-05-11 23:11:27 +04:00
|
|
|
entry = nubus_adjust_ptr(lanes, entry, 4);
|
1995-04-30 00:23:36 +04:00
|
|
|
}
|
1997-05-11 23:11:27 +04:00
|
|
|
} while (entry != (u_long)dir->curr_ent);
|
1993-09-29 09:08:37 +03:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
1995-04-30 00:23:36 +04:00
|
|
|
int
|
1997-05-11 23:11:27 +04:00
|
|
|
nubus_get_ind_data(bst, bsh, fmt, dirent, data_return, nbytes)
|
|
|
|
bus_space_tag_t bst;
|
|
|
|
bus_space_handle_t bsh;
|
|
|
|
nubus_slot *fmt;
|
1995-04-30 00:23:36 +04:00
|
|
|
nubus_dirent *dirent;
|
|
|
|
caddr_t data_return;
|
|
|
|
int nbytes;
|
|
|
|
{
|
1997-05-11 23:11:27 +04:00
|
|
|
u_long loc;
|
|
|
|
u_int8_t lanes = fmt->bytelanes;
|
1993-09-29 09:08:37 +03:00
|
|
|
|
1996-05-08 19:14:53 +04:00
|
|
|
#ifdef DEBUG
|
1995-06-21 06:59:08 +04:00
|
|
|
if (nubus_debug & NDB_FOLLOW)
|
1997-05-11 23:11:27 +04:00
|
|
|
printf("nubus_get_ind_data(%p, %p, %p, %d).\n",
|
|
|
|
fmt, dirent, data_return, nbytes);
|
1995-06-21 06:59:08 +04:00
|
|
|
#endif
|
1995-04-30 00:23:36 +04:00
|
|
|
if ((loc = dirent->offset) & 0x800000) {
|
|
|
|
loc |= 0xff000000;
|
|
|
|
}
|
1997-05-11 23:11:27 +04:00
|
|
|
loc = nubus_adjust_ptr(lanes, dirent->myloc, loc);
|
1993-09-29 09:08:37 +03:00
|
|
|
|
1995-04-30 00:23:36 +04:00
|
|
|
while (nbytes--) {
|
1997-05-11 23:11:27 +04:00
|
|
|
*data_return++ = nubus_read_1(bst, bsh, lanes, loc);
|
|
|
|
loc = nubus_adjust_ptr(lanes, loc, 1);
|
1995-04-30 00:23:36 +04:00
|
|
|
}
|
|
|
|
return 1;
|
1993-09-29 09:08:37 +03:00
|
|
|
}
|
1993-11-29 03:32:22 +03:00
|
|
|
|
1995-04-30 00:23:36 +04:00
|
|
|
int
|
1997-05-11 23:11:27 +04:00
|
|
|
nubus_get_c_string(bst, bsh, fmt, dirent, data_return, max_bytes)
|
|
|
|
bus_space_tag_t bst;
|
|
|
|
bus_space_handle_t bsh;
|
|
|
|
nubus_slot *fmt;
|
1995-04-30 00:23:36 +04:00
|
|
|
nubus_dirent *dirent;
|
|
|
|
caddr_t data_return;
|
|
|
|
int max_bytes;
|
1993-12-21 06:18:00 +03:00
|
|
|
{
|
1997-05-11 23:11:27 +04:00
|
|
|
u_long loc;
|
|
|
|
u_int8_t lanes = fmt->bytelanes;
|
1995-04-30 00:23:36 +04:00
|
|
|
|
1996-05-08 19:14:53 +04:00
|
|
|
#ifdef DEBUG
|
1995-06-21 06:59:08 +04:00
|
|
|
if (nubus_debug & NDB_FOLLOW)
|
1997-05-11 23:11:27 +04:00
|
|
|
printf("nubus_get_c_string(%p, %p, %p, %d).\n",
|
|
|
|
fmt, dirent, data_return, max_bytes);
|
1995-06-21 06:59:08 +04:00
|
|
|
#endif
|
1997-05-11 23:11:27 +04:00
|
|
|
if ((loc = dirent->offset) & 0x800000)
|
1995-04-30 00:23:36 +04:00
|
|
|
loc |= 0xff000000;
|
1997-05-11 23:11:27 +04:00
|
|
|
|
|
|
|
loc = nubus_adjust_ptr(lanes, dirent->myloc, loc);
|
1993-12-21 06:18:00 +03:00
|
|
|
|
1995-04-30 00:23:36 +04:00
|
|
|
*data_return = '\0';
|
|
|
|
while (max_bytes--) {
|
1997-05-11 23:11:27 +04:00
|
|
|
if ((*data_return++ =
|
|
|
|
nubus_read_1(bst, bsh, lanes, loc)) == 0)
|
1995-04-30 00:23:36 +04:00
|
|
|
return 1;
|
1997-05-11 23:11:27 +04:00
|
|
|
loc = nubus_adjust_ptr(lanes, loc, 1);
|
1995-04-30 00:23:36 +04:00
|
|
|
}
|
|
|
|
return 0;
|
1993-12-21 06:18:00 +03:00
|
|
|
}
|
|
|
|
|
1995-04-30 00:23:36 +04:00
|
|
|
static char *huh = "???";
|
1995-04-21 06:47:35 +04:00
|
|
|
|
1995-04-30 00:23:36 +04:00
|
|
|
char *
|
1997-05-11 23:11:27 +04:00
|
|
|
nubus_get_vendor(bst, bsh, fmt, rsrc)
|
|
|
|
bus_space_tag_t bst;
|
|
|
|
bus_space_handle_t bsh;
|
|
|
|
nubus_slot *fmt;
|
|
|
|
int rsrc;
|
1995-04-30 00:23:36 +04:00
|
|
|
{
|
1997-05-11 23:11:27 +04:00
|
|
|
static char str_ret[64];
|
|
|
|
nubus_dir dir;
|
|
|
|
nubus_dirent ent;
|
1995-04-21 06:47:35 +04:00
|
|
|
|
1996-05-08 19:14:53 +04:00
|
|
|
#ifdef DEBUG
|
1995-06-21 06:59:08 +04:00
|
|
|
if (nubus_debug & NDB_FOLLOW)
|
1997-05-11 23:11:27 +04:00
|
|
|
printf("nubus_get_vendor(%p, 0x%x).\n", fmt, rsrc);
|
1995-06-21 06:59:08 +04:00
|
|
|
#endif
|
1997-05-11 23:11:27 +04:00
|
|
|
nubus_get_main_dir(fmt, &dir);
|
|
|
|
if (nubus_find_rsrc(bst, bsh, fmt, &dir, 1, &ent) <= 0)
|
1995-04-30 00:23:36 +04:00
|
|
|
return huh;
|
1997-05-11 23:11:27 +04:00
|
|
|
nubus_get_dir_from_rsrc(fmt, &ent, &dir);
|
1995-04-21 06:47:35 +04:00
|
|
|
|
1997-05-11 23:11:27 +04:00
|
|
|
if (nubus_find_rsrc(bst, bsh, fmt, &dir, NUBUS_RSRC_VENDORINFO, &ent)
|
|
|
|
<= 0)
|
1995-04-30 00:23:36 +04:00
|
|
|
return huh;
|
1997-05-11 23:11:27 +04:00
|
|
|
nubus_get_dir_from_rsrc(fmt, &ent, &dir);
|
1995-04-21 06:47:35 +04:00
|
|
|
|
1997-05-11 23:11:27 +04:00
|
|
|
if (nubus_find_rsrc(bst, bsh, fmt, &dir, rsrc, &ent) <= 0)
|
1995-04-30 00:23:36 +04:00
|
|
|
return huh;
|
1995-04-21 06:47:35 +04:00
|
|
|
|
1997-05-11 23:11:27 +04:00
|
|
|
nubus_get_c_string(bst, bsh, fmt, &ent, str_ret, 64);
|
1995-04-21 06:47:35 +04:00
|
|
|
|
1995-04-30 00:23:36 +04:00
|
|
|
return str_ret;
|
1993-11-29 03:32:22 +03:00
|
|
|
}
|
|
|
|
|
1995-04-30 00:23:36 +04:00
|
|
|
char *
|
1997-05-11 23:11:27 +04:00
|
|
|
nubus_get_card_name(bst, bsh, fmt)
|
|
|
|
bus_space_tag_t bst;
|
|
|
|
bus_space_handle_t bsh;
|
|
|
|
nubus_slot *fmt;
|
1993-11-29 03:32:22 +03:00
|
|
|
{
|
1997-05-11 23:11:27 +04:00
|
|
|
static char name_ret[64];
|
|
|
|
nubus_dir dir;
|
|
|
|
nubus_dirent ent;
|
1993-11-29 03:32:22 +03:00
|
|
|
|
1996-05-08 19:14:53 +04:00
|
|
|
#ifdef DEBUG
|
1995-06-21 06:59:08 +04:00
|
|
|
if (nubus_debug & NDB_FOLLOW)
|
1997-05-11 23:11:27 +04:00
|
|
|
printf("nubus_get_card_name(%p).\n", fmt);
|
1995-06-21 06:59:08 +04:00
|
|
|
#endif
|
1997-05-11 23:11:27 +04:00
|
|
|
nubus_get_main_dir(fmt, &dir);
|
1993-11-29 03:32:22 +03:00
|
|
|
|
1997-05-11 23:11:27 +04:00
|
|
|
if (nubus_find_rsrc(bst, bsh, fmt, &dir, 1, &ent) <= 0)
|
1995-04-30 00:23:36 +04:00
|
|
|
return huh;
|
1993-11-29 03:32:22 +03:00
|
|
|
|
1997-05-11 23:11:27 +04:00
|
|
|
nubus_get_dir_from_rsrc(fmt, &ent, &dir);
|
1993-11-29 03:32:22 +03:00
|
|
|
|
1997-05-11 23:11:27 +04:00
|
|
|
if (nubus_find_rsrc(bst, bsh, fmt, &dir, NUBUS_RSRC_NAME, &ent) <= 0)
|
1995-04-30 00:23:36 +04:00
|
|
|
return huh;
|
1993-11-29 03:32:22 +03:00
|
|
|
|
1997-05-11 23:11:27 +04:00
|
|
|
nubus_get_c_string(bst, bsh, fmt, &ent, name_ret, 64);
|
1993-11-29 03:32:22 +03:00
|
|
|
|
1995-04-30 00:23:36 +04:00
|
|
|
return name_ret;
|
1993-11-29 03:32:22 +03:00
|
|
|
}
|