summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorMark Kettenis <kettenis@cvs.openbsd.org>2007-03-15 21:24:24 +0000
committerMark Kettenis <kettenis@cvs.openbsd.org>2007-03-15 21:24:24 +0000
commit7fcab7d30fb6eeadb6e819d7899ce24eb1e76ef0 (patch)
tree26e7ecfa0ea1fb38017afb8bf34020b164191863 /sys
parent177c3f7790be67ce20d3f9d6d69bd32a1dd2aa52 (diff)
UltraSPARC-IV cpus appear a bit different in OpenFirmware than older cpus.
Make sure we fetch the right properties such that we don't crash later in the pci bus walking code when we divide by a zero cache line size.
Diffstat (limited to 'sys')
-rw-r--r--sys/arch/sparc64/sparc64/cpu.c31
1 files changed, 24 insertions, 7 deletions
diff --git a/sys/arch/sparc64/sparc64/cpu.c b/sys/arch/sparc64/sparc64/cpu.c
index 8b69deaba04..e7bc20cd82a 100644
--- a/sys/arch/sparc64/sparc64/cpu.c
+++ b/sys/arch/sparc64/sparc64/cpu.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cpu.c,v 1.18 2007/01/07 18:13:41 kettenis Exp $ */
+/* $OpenBSD: cpu.c,v 1.19 2007/03/15 21:24:23 kettenis Exp $ */
/* $NetBSD: cpu.c,v 1.13 2001/05/26 21:27:15 chs Exp $ */
/*
@@ -127,6 +127,7 @@ cpu_attach(parent, dev, aux)
int node;
long clk;
int impl, vers, fver;
+ char *cpuname;
char *fpuname;
struct mainbus_attach_args *ma = aux;
struct fpstate64 *fpstate;
@@ -174,14 +175,20 @@ cpu_attach(parent, dev, aux)
cpu_clockrate[0] = clk; /* Tell OS what frequency we run on */
cpu_clockrate[1] = clk/1000000;
}
+ cpuname = getpropstring(node, "name");
+ if (strcmp(cpuname, "cpu") == 0)
+ cpuname = getpropstring(node, "compatible");
snprintf(cpu_model, sizeof cpu_model,
- "%s (rev %d.%d) @ %s MHz, %s FPU", getpropstring(node, "name"),
+ "%s (rev %d.%d) @ %s MHz, %s FPU", cpuname,
vers >> 4, vers & 0xf, clockfreq(clk), fpuname);
printf(": %s\n", cpu_model);
cacheinfo.c_physical = 1; /* Dunno... */
cacheinfo.c_split = 1;
- cacheinfo.ic_linesize = l = getpropint(node, "icache-line-size", 0);
+ l = getpropint(node, "icache-line-size", 0);
+ if (l == 0)
+ l = getpropint(node, "l1-icache-line-size", 0);
+ cacheinfo.ic_linesize = l;
for (i = 0; (1 << i) < l && l; i++)
/* void */;
if ((1 << i) != l && l)
@@ -189,12 +196,16 @@ cpu_attach(parent, dev, aux)
cacheinfo.ic_l2linesize = i;
cacheinfo.ic_totalsize = getpropint(node, "icache-size", 0);
if (cacheinfo.ic_totalsize == 0)
+ cacheinfo.ic_totalsize = getpropint(node, "l1-icache-size", 0);
+ if (cacheinfo.ic_totalsize == 0)
cacheinfo.ic_totalsize = l *
getpropint(node, "icache-nlines", 64) *
getpropint(node, "icache-associativity", 1);
- cacheinfo.dc_linesize = l =
- getpropint(node, "dcache-line-size",0);
+ l = getpropint(node, "dcache-line-size", 0);
+ if (l == 0)
+ l = getpropint(node, "l1-dcache-line-size", 0);
+ cacheinfo.dc_linesize = l;
for (i = 0; (1 << i) < l && l; i++)
/* void */;
if ((1 << i) != l && l)
@@ -202,12 +213,16 @@ cpu_attach(parent, dev, aux)
cacheinfo.dc_l2linesize = i;
cacheinfo.dc_totalsize = getpropint(node, "dcache-size", 0);
if (cacheinfo.dc_totalsize == 0)
+ cacheinfo.dc_totalsize = getpropint(node, "l1-dcache-size", 0);
+ if (cacheinfo.dc_totalsize == 0)
cacheinfo.dc_totalsize = l *
getpropint(node, "dcache-nlines", 128) *
getpropint(node, "dcache-associativity", 1);
- cacheinfo.ec_linesize = l =
- getpropint(node, "ecache-line-size", 0);
+ l = getpropint(node, "ecache-line-size", 0);
+ if (l == 0)
+ l = getpropint(node, "l2-cache-line-size", 0);
+ cacheinfo.ec_linesize = l;
for (i = 0; (1 << i) < l && l; i++)
/* void */;
if ((1 << i) != l && l)
@@ -215,6 +230,8 @@ cpu_attach(parent, dev, aux)
cacheinfo.ec_l2linesize = i;
cacheinfo.ec_totalsize = getpropint(node, "ecache-size", 0);
if (cacheinfo.ec_totalsize == 0)
+ cacheinfo.ec_totalsize = getpropint(node, "l2-cache-size", 0);
+ if (cacheinfo.ec_totalsize == 0)
cacheinfo.ec_totalsize = l *
getpropint(node, "ecache-nlines", 32768) *
getpropint(node, "ecache-associativity", 1);