Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch/ofppc Various things that make OFW-driver kernels w...
details: https://anonhg.NetBSD.org/src/rev/5d9f083857e1
branches: trunk
changeset: 516378:5d9f083857e1
user: thorpej <thorpej%NetBSD.org@localhost>
date: Mon Oct 22 14:46:08 2001 +0000
description:
Various things that make OFW-driver kernels work on my Firepower LX MP
again:
- Special-case the attachment of CPUs, and logically attach them to
"mainbus", attaching them before any other devices. Otherwise,
CPUs would be found very late in the game on my Firepower.
- Sanity check the timebase-frequency property, printing a warning if
it's not the same on each CPU.
- Pass the correct CPU ID to cpu_attach_subr().
- Fetch the platform name from the OFW root node. We can key off this
later when we implement support for native drivers in the ofppc port.
- Use a table of "special" toplevel OFW nodes ... we skip these nodes
during the device configuration phase. This generally includes the
"options", "packages", etc. nodes. Inspired by sparc & sparc64 ports.
diffstat:
sys/arch/ofppc/conf/GENERIC | 8 +-
sys/arch/ofppc/conf/files.ofppc | 4 +-
sys/arch/ofppc/ofppc/cpu.c | 39 +++++++++++---
sys/arch/ofppc/ofppc/mainbus.c | 106 ++++++++++++++++++++++++++++++++++-----
4 files changed, 128 insertions(+), 29 deletions(-)
diffs (267 lines):
diff -r 19d415fbfc8b -r 5d9f083857e1 sys/arch/ofppc/conf/GENERIC
--- a/sys/arch/ofppc/conf/GENERIC Mon Oct 22 14:36:55 2001 +0000
+++ b/sys/arch/ofppc/conf/GENERIC Mon Oct 22 14:46:08 2001 +0000
@@ -1,11 +1,11 @@
-# $NetBSD: GENERIC,v 1.43 2001/09/12 21:05:37 manu Exp $
+# $NetBSD: GENERIC,v 1.44 2001/10/22 14:46:08 thorpej Exp $
#
# GENERIC -- everything that's currently supported
#
include "arch/ofppc/conf/std.ofppc"
-#ident "GENERIC-$Revision: 1.43 $"
+#ident "GENERIC-$Revision: 1.44 $"
maxusers 32
@@ -113,8 +113,8 @@
ofbus* at mainbus?
ofbus* at ofbus?
-# CPU
-cpu* at ofbus?
+# CPUs
+cpu* at mainbus?
# Generic OpenFirmware disk support
ofdisk* at ofbus?
diff -r 19d415fbfc8b -r 5d9f083857e1 sys/arch/ofppc/conf/files.ofppc
--- a/sys/arch/ofppc/conf/files.ofppc Mon Oct 22 14:36:55 2001 +0000
+++ b/sys/arch/ofppc/conf/files.ofppc Mon Oct 22 14:46:08 2001 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: files.ofppc,v 1.14 2001/08/26 02:47:40 matt Exp $
+# $NetBSD: files.ofppc,v 1.15 2001/10/22 14:46:08 thorpej Exp $
#
# First try for ofppc-specific configuration info
#
@@ -59,7 +59,7 @@
file arch/ofppc/ofppc/mainbus.c mainbus
device cpu
-attach cpu at ofbus
+attach cpu at mainbus
file arch/ofppc/ofppc/cpu.c cpu
# RAIDframe
diff -r 19d415fbfc8b -r 5d9f083857e1 sys/arch/ofppc/ofppc/cpu.c
--- a/sys/arch/ofppc/ofppc/cpu.c Mon Oct 22 14:36:55 2001 +0000
+++ b/sys/arch/ofppc/ofppc/cpu.c Mon Oct 22 14:46:08 2001 +0000
@@ -1,11 +1,11 @@
-/* $NetBSD: cpu.c,v 1.2 2001/10/20 08:22:58 billc Exp $ */
+/* $NetBSD: cpu.c,v 1.3 2001/10/22 14:46:09 thorpej Exp $ */
/*-
* Copyright (c) 2000, 2001 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
- * by NONAKA Kimihiro.
+ * by NONAKA Kimihiro; by Jason R. Thorpe.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -56,10 +56,16 @@
struct ofbus_attach_args *oba = aux;
char name[32];
- if (OF_getprop(oba->oba_phandle, "device_type", name, sizeof name) <= 3)
+ if (strcmp(oba->oba_busname, "cpu") != 0)
return (0);
- if (!strcmp(name, "cpu"))
+
+ if (OF_getprop(oba->oba_phandle, "device_type", name,
+ sizeof(name)) <= 3)
+ return (0);
+
+ if (strcmp(name, "cpu") == 0)
return (1);
+
return (0);
}
@@ -69,12 +75,29 @@
struct cpu_softc *sc = (struct cpu_softc *) self;
struct ofbus_attach_args *oba = aux;
unsigned char data[4];
+ int tbase, cpunum;
sc->sc_ofnode = oba->oba_phandle;
- cpu_attach_common(self, 0);
+
+ if (OF_getprop(sc->sc_ofnode, "reg",
+ data, sizeof(data)) < sizeof(data)) {
+ printf(": unable to get CPU ID\n");
+ return;
+ }
+ cpunum = of_decode_int(data);
+
+ cpu_attach_common(self, cpunum);
- if (OF_getprop(oba->oba_phandle, "timebase-frequency",
- data, sizeof data) >= sizeof(int)) {
- cpu_timebase = of_decode_int(data);
+ if (OF_getprop(oba->oba_phandle, "timebase-frequency",
+ data, sizeof(data)) < sizeof(data))
+ printf("%s: unable to get timebase-frequence property\n",
+ sc->sc_dev.dv_xname);
+ else {
+ tbase = of_decode_int(data);
+ if (cpu_timebase == 0)
+ cpu_timebase = tbase;
+ else if (tbase != cpu_timebase)
+ printf("%s: WARNING: timebase %d != %d\n",
+ sc->sc_dev.dv_xname, tbase, cpu_timebase);
}
}
diff -r 19d415fbfc8b -r 5d9f083857e1 sys/arch/ofppc/ofppc/mainbus.c
--- a/sys/arch/ofppc/ofppc/mainbus.c Mon Oct 22 14:36:55 2001 +0000
+++ b/sys/arch/ofppc/ofppc/mainbus.c Mon Oct 22 14:46:08 2001 +0000
@@ -1,11 +1,11 @@
-/* $NetBSD: mainbus.c,v 1.3 2001/08/26 02:47:41 matt Exp $ */
+/* $NetBSD: mainbus.c,v 1.4 2001/10/22 14:46:09 thorpej Exp $ */
/*-
- * Copyright (c) 1998 The NetBSD Foundation, Inc.
+ * Copyright (c) 1998, 2001 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
- * by Charles M. Hannum.
+ * by Charles M. Hannum; by Jason R. Thorpe.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -42,24 +42,26 @@
#include <dev/ofw/openfirm.h>
-int mainbus_match __P((struct device *, struct cfdata *, void *));
-void mainbus_attach __P((struct device *, struct device *, void *));
+int mainbus_match(struct device *, struct cfdata *, void *);
+void mainbus_attach(struct device *, struct device *, void *);
struct cfattach mainbus_ca = {
sizeof(struct device), mainbus_match, mainbus_attach
};
+int mainbus_print(void *, const char *);
+
extern struct cfdriver mainbus_cd;
+char platform_type[64];
+
/*
* Probe for the mainbus; always succeeds.
*/
int
-mainbus_match(parent, cf, aux)
- struct device *parent;
- struct cfdata *cf;
- void *aux;
+mainbus_match(struct device *parent, struct cfdata *cf, void *aux)
{
+
return (1);
}
@@ -67,19 +69,93 @@
* Attach the mainbus.
*/
void
-mainbus_attach(parent, self, aux)
- struct device *parent, *self;
- void *aux;
+mainbus_attach(struct device *parent, struct device *self, void *aux)
{
struct ofbus_attach_args oba;
+ char buf[32];
+ const char * const *ssp, *sp = NULL;
int node;
- printf("\n");
+ static const char * const openfirmware_special[] = {
+ /*
+ * These are _root_ devices to ignore. Others must be
+ * handled elsewhere, if at all.
+ */
+ "virtual-memory",
+ "mmu",
+ "aliases",
+ "memory",
+ "openprom",
+ "options",
+ "packages",
+ "chosen",
+
+ /*
+ * This one is extra-special .. we make a special case
+ * and attach CPUs early.
+ */
+ "cpus",
+
+ NULL
+ };
node = OF_peer(0);
- if (node) {
+ if (node == 0) {
+ printf("\n");
+ panic("mainbus_attach: no OpenFirmware root node\n");
+ }
+
+ /*
+ * Display the type of system we are running on. Eventually,
+ * this can be used to look up methods to handle native hardware
+ * devices.
+ */
+ OF_getprop(node, "name", platform_type, sizeof(platform_type));
+ printf(": %s\n", platform_type);
+
+ /*
+ * Before we do anything else, attach CPUs. We do this early,
+ * because we might need to make CPU dependent decisions during
+ * the autoconfiguration process. Also, it's a little weird to
+ * see CPUs after other devices in the boot messages.
+ */
+ node = OF_finddevice("/cpus");
+ if (node != -1) {
+ for (node = OF_child(node); node != 0; node = OF_peer(node)) {
+ oba.oba_busname = "cpu";
+ oba.oba_phandle = node;
+ (void) config_found(self, &oba, mainbus_print);
+ }
+ }
+
+ /*
+ * Now attach the rest of the devices on the system.
+ */
+ for (node = OF_child(OF_peer(0)); node != 0; node = OF_peer(node)) {
+ OF_getprop(node, "name", buf, sizeof(buf));
+ for (ssp = openfirmware_special; (sp = *ssp) != NULL; ssp++) {
+ if (strcmp(buf, sp) == 0)
+ break;
+ }
+ if (sp != NULL)
+ continue;
+
oba.oba_busname = "ofw";
oba.oba_phandle = node;
- config_found(self, &oba, NULL);
+ (void) config_found(self, &oba, mainbus_print);
}
}
+
+int
+mainbus_print(void *aux, const char *pnp)
+{
+ struct ofbus_attach_args *oba = aux;
+ char name[64];
+
+ if (pnp) {
+ OF_getprop(oba->oba_phandle, "name", name, sizeof(name));
+ printf("%s at %s", name, pnp);
+ }
+
+ return (UNCONF);
+}
Home |
Main Index |
Thread Index |
Old Index