From ea16c1ada34eb27ee570e5b246bd2804ef4c9087 Mon Sep 17 00:00:00 2001 From: matt Date: Tue, 6 Jun 2000 20:17:34 +0000 Subject: [PATCH] Enable __HAVE_DEVICE_REGISTER and add a ofw_device_register to shark_machdep.c This works for booting diskless. It should work for booting off ide but that is untested for the moment. --- sys/arch/arm32/arm32/autoconf.c | 11 +++- sys/arch/arm32/include/types.h | 3 +- sys/arch/arm32/ofw/ofw.c | 5 +- sys/arch/arm32/shark/shark_machdep.c | 98 +++++++++++++++++++++++++++- 4 files changed, 113 insertions(+), 4 deletions(-) diff --git a/sys/arch/arm32/arm32/autoconf.c b/sys/arch/arm32/arm32/autoconf.c index c6ea6ebbf7a7..518a6195289d 100644 --- a/sys/arch/arm32/arm32/autoconf.c +++ b/sys/arch/arm32/arm32/autoconf.c @@ -1,4 +1,4 @@ -/* $NetBSD: autoconf.c,v 1.35 2000/06/03 16:48:59 matt Exp $ */ +/* $NetBSD: autoconf.c,v 1.36 2000/06/06 20:17:34 matt Exp $ */ /* * Copyright (c) 1994-1998 Mark Brinicombe. @@ -60,6 +60,7 @@ #ifdef SHARK #include extern void ofrootfound __P((void)); +extern void ofw_device_register __P((struct device *, void *aux)); extern void startrtclock __P((void)); #endif @@ -217,4 +218,12 @@ cpu_configure() (void)spl0(); } +void +device_register(struct device *dev, void *aux) +{ +#if defined(OFWGENCFG) || defined(SHARK) + /* Temporary for SHARK! */ + ofw_device_register(dev, aux); +#endif +} /* End of autoconf.c */ diff --git a/sys/arch/arm32/include/types.h b/sys/arch/arm32/include/types.h index ed9a5fb18837..c768e570e997 100644 --- a/sys/arch/arm32/include/types.h +++ b/sys/arch/arm32/include/types.h @@ -1,4 +1,4 @@ -/* $NetBSD: types.h,v 1.10 2000/02/13 05:20:45 mark Exp $ */ +/* $NetBSD: types.h,v 1.11 2000/06/06 20:17:35 matt Exp $ */ /* * Copyright (c) 1990 The Regents of the University of California. @@ -76,5 +76,6 @@ typedef unsigned long long u_int64_t; typedef int32_t register_t; #define __HAVE_NWSCONS +#define __HAVE_DEVICE_REGISTER #endif /* _ARM32_TYPES_H_ */ diff --git a/sys/arch/arm32/ofw/ofw.c b/sys/arch/arm32/ofw/ofw.c index 94723dd0745d..a743e692f058 100644 --- a/sys/arch/arm32/ofw/ofw.c +++ b/sys/arch/arm32/ofw/ofw.c @@ -1,4 +1,4 @@ -/* $NetBSD: ofw.c,v 1.23 1999/09/17 19:59:39 thorpej Exp $ */ +/* $NetBSD: ofw.c,v 1.24 2000/06/06 20:17:36 matt Exp $ */ /* * Copyright 1997 @@ -542,6 +542,9 @@ ofw_getbootinfo(bp_pp, ba_pp) *bp_pp = bootpathv; *ba_pp = bootargsv; +#ifdef DIAGNOSTIC + printf("bootpath=<%s>, bootargs=<%s>\n", bootpathv, bootargsv); +#endif } vm_offset_t diff --git a/sys/arch/arm32/shark/shark_machdep.c b/sys/arch/arm32/shark/shark_machdep.c index 53fd4e46bce6..d0ccb2475934 100644 --- a/sys/arch/arm32/shark/shark_machdep.c +++ b/sys/arch/arm32/shark/shark_machdep.c @@ -1,4 +1,4 @@ -/* $NetBSD: shark_machdep.c,v 1.15 2000/03/24 17:05:32 ws Exp $ */ +/* $NetBSD: shark_machdep.c,v 1.16 2000/06/06 20:17:36 matt Exp $ */ /* * Copyright 1997 @@ -70,8 +70,23 @@ #include #include #include +#include +#include #include +#include "wd.h" +#include "cd.h" +#include "sd.h" + +#if NWD > 0 || NSD > 0 || NCD > 0 +#include +#endif +#if NSD > 0 || NCD > 0 +#include +#include +#include +#endif + /* * Imported variables */ @@ -369,3 +384,84 @@ ofrootfound(void) if (!config_rootfound("ofbus", &aa)) panic("ofw root ofbus not configured"); } + +void +ofw_device_register(struct device *dev, void *aux) +{ + static struct device *parent; +#if NSD > 0 || NCD > 0 + static struct device *scsipidev; +#endif + static char *boot_component; + struct ofbus_attach_args *oba; + const char *cd_name = dev->dv_cfdata->cf_driver->cd_name; + char name[64]; + int i; + + if (boot_component == NULL) + boot_component = boot_file; + + if (booted_device != NULL + || boot_component == NULL + || boot_component[0] == '\0') + return; + + if (!strcmp(cd_name, "ofbus") || !strcmp(cd_name, "ofisa")) { + oba = aux; + } else if (parent == NULL) { + return; + } else if (parent == dev->dv_parent + && !strcmp(parent->dv_cfdata->cf_driver->cd_name, "ofisa")) { + struct ofisa_attach_args *aa = aux; + oba = &aa->oba; +#if NWD > 0 || NSD > 0 || NCD > 0 + } else if (parent == dev->dv_parent + && !strcmp(parent->dv_cfdata->cf_driver->cd_name, "wdc")) { +#if NSD > 0 || NCD > 0 + if (!strcmp(cd_name, "atapibus")) { + scsipidev = dev; + return; + } +#endif +#if NWD > 0 + if (!strcmp(cd_name, "wd")) { + struct ata_atapi_attach *aa = aux; + char *cp = strchr(boot_component, '@'); + if (cp != NULL + && aa->aa_drv_data->drive == strtoul(cp+1, NULL, 16) + && aa->aa_channel == 0) { + booted_device = dev; + return; + } + } + return; +#endif /* NWD > 0 */ +#if NSD > 0 || NCD > 0 + } else if (scsipidev == dev->dv_parent + && (!strcmp(cd_name, "sd") || !strcmp(cd_name, "cd"))) { + struct scsipibus_attach_args *sa = aux; + char *cp = strchr(boot_component, '@'); + if (cp != NULL + && sa->sa_sc_link->type == BUS_ATAPI + && sa->sa_sc_link->scsipi_atapi.channel == 0 + && sa->sa_sc_link->scsipi_atapi.drive == strtoul(cp+1, NULL, 16)) { + booted_device = dev; + } + return; +#endif /* NSD > 0 || NCD > 0 */ +#endif /* NWD > 0 || NSD > 0 || NCD > 0 */ + } else { + return; + } + (void) of_packagename(oba->oba_phandle, name, sizeof name); + i = strlen(name); + if (!strncmp(name, &boot_component[1], i) + && (boot_component[i+1] == '/' || boot_component[i+1] == '\0')) { + boot_component += i + 1; + if (boot_component[0] == '/') { + parent = dev; + } else { + booted_device = dev; + } + } +}