diff options
author | Gordon Willem Klok <gwk@cvs.openbsd.org> | 2007-02-12 22:22:40 +0000 |
---|---|---|
committer | Gordon Willem Klok <gwk@cvs.openbsd.org> | 2007-02-12 22:22:40 +0000 |
commit | a03f82c0981705ca1ff579de1839fc64070f8e52 (patch) | |
tree | 7948f8b53497db08dd736786ad5b35947a21b335 /sys/arch | |
parent | 1bfce5563f02d29f71ade675875250ced7e40f37 (diff) |
Cope with the different format of the name property of the root device in
the openfirmware tree as found in old world macs. Also utilize the
compatible property to print nice model information in the dmesg
and the sysctl hw.vendor/product fields.
mainbus0 (root): model Power Macintosh 9500
hw.vendor=Apple Computer, Inc.
hw.product=Power Macintosh 9500
Note this is from a 9600, this information will reflect the architecture in
this case both the 9500 and 9600 are from tsunami architecture and differ
only in the processor daughtercard.
Tested by myself and martin@ on old world machines, and by martin@ on
a new world.
ok martin@, drahn@
Diffstat (limited to 'sys/arch')
-rw-r--r-- | sys/arch/macppc/macppc/mainbus.c | 40 |
1 files changed, 31 insertions, 9 deletions
diff --git a/sys/arch/macppc/macppc/mainbus.c b/sys/arch/macppc/macppc/mainbus.c index 4591691228b..c93b187dbae 100644 --- a/sys/arch/macppc/macppc/mainbus.c +++ b/sys/arch/macppc/macppc/mainbus.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mainbus.c,v 1.15 2006/07/11 06:33:48 gwk Exp $ */ +/* $OpenBSD: mainbus.c,v 1.16 2007/02/12 22:22:39 gwk Exp $ */ /* * Copyright (c) 1994, 1995 Carnegie-Mellon University. @@ -54,7 +54,7 @@ struct cfdriver mainbus_cd = { }; /* hw.product sysctl see sys/kern/kern_sysctl.c */ -extern char *hw_prod; +extern char *hw_prod, *hw_ver, *hw_vendor; void mb_intr_establish(struct confargs *, int (*)(void *), void *); void mb_intr_disestablish(struct confargs *); @@ -77,20 +77,42 @@ mbattach(struct device *parent, struct device *self, void *aux) { struct mainbus_softc *sc = (struct mainbus_softc *)self; struct confargs nca; - char name[64]; - int node, len; + char name[64], *t = NULL; + int node, len, slen; node = OF_peer(0); len = OF_getprop(node, "model", name, sizeof(name)); if (len > 1) { name[len] = '\0'; - printf(": model %s", name); - len = strlen(name)+1; - if ((hw_prod = malloc(len, M_DEVBUF, M_NOWAIT)) != NULL) - strlcpy(hw_prod, name, len); + slen = strlen(name)+1; + if ((t = malloc(slen, M_DEVBUF, M_NOWAIT)) != NULL) + strlcpy(t, name, slen); + } - printf("\n"); + len = OF_getprop(node, "compatible", name, sizeof(name)); + if (len > 1) { + name[len] = '\0'; + if ((strncmp(t, name, strlen(t))) == 0) { + /* New World Macintosh */ + hw_vendor = "Apple Computer, Inc."; + hw_prod = t; + } else { + /* Old World Macintosh */ + if ((strncmp(name, "AAPL", 4)) == 0) { + hw_vendor = "Apple Computer, Inc."; + slen = strlen(t) + strlen(name) - 3; + if ((hw_prod = malloc(slen, M_DEVBUF, + M_NOWAIT)) != NULL) { + snprintf(hw_prod, slen, "%s %s", t, + name + 5); + free(t, M_DEVBUF); + } + } + + } + } + printf(": model %s\n", hw_prod); sc->sc_bus.bh_dv = (struct device *)sc; sc->sc_bus.bh_type = BUS_MAIN; |