diff options
author | Miod Vallat <miod@cvs.openbsd.org> | 2013-09-29 14:08:54 +0000 |
---|---|---|
committer | Miod Vallat <miod@cvs.openbsd.org> | 2013-09-29 14:08:54 +0000 |
commit | ef174a907917af1ccc7647978a1367e572f04100 (patch) | |
tree | 1cfbe0fa9133f9edbc5749ed5a53a9bd8083ac06 | |
parent | 0c3b43f564e104aaef659398e22a67cb4a9b7850 (diff) |
Test whether the WHOAMI register exists before using it. Apparently, models
100/200/300 would lack it. They are single-processor systems anyway.
-rw-r--r-- | sys/arch/aviion/aviion/m8820x.c | 45 |
1 files changed, 40 insertions, 5 deletions
diff --git a/sys/arch/aviion/aviion/m8820x.c b/sys/arch/aviion/aviion/m8820x.c index f6d6c9a1844..aa86bcddd74 100644 --- a/sys/arch/aviion/aviion/m8820x.c +++ b/sys/arch/aviion/aviion/m8820x.c @@ -1,4 +1,4 @@ -/* $OpenBSD: m8820x.c,v 1.11 2013/09/26 18:37:07 miod Exp $ */ +/* $OpenBSD: m8820x.c,v 1.12 2013/09/29 14:08:53 miod Exp $ */ /* * Copyright (c) 2004, 2006, 2010 Miodrag Vallat. * @@ -31,6 +31,7 @@ #include <machine/asm_macro.h> #include <machine/avcommon.h> +#include <machine/board.h> #include <machine/cmmu.h> #include <machine/cpu.h> #include <machine/m8820x.h> @@ -41,6 +42,8 @@ extern u_int32_t pfsr_straight[]; extern u_int32_t pfsr_double[]; extern u_int32_t pfsr_six[]; +volatile u_int32_t *whoamiptr; + /* * This routine sets up the CPU/CMMU configuration. */ @@ -56,6 +59,30 @@ m8820x_setup_board_config() u_int32_t *m8820x_pfsr; /* + * Check whether the WHOAMI register exists. + * According to documentation, that register is not available + * on 100, 200 and 300 models. + * + * Since it is unknown whether models 100 and 200 share the + * 300/310 cpuid, we'd better check whether the register can + * be read. + */ + + switch (cpuid) { + case AVIION_300_310: + /* the following for consistency and safety */ + case AVIION_300C_310C: + case AVIION_300CD_310CD: + case AVIION_300D_310D: + break; + default: + if (badaddr((vaddr_t)AV_WHOAMI, 4) == 0) + whoamiptr = (volatile u_int32_t *)AV_WHOAMI; + break; + } + + + /* * First, find if any CPU0 CMMU is a 88204. If so, we can * issue the CPUCONFIG system call to get the configuration * details. @@ -129,7 +156,12 @@ hardprobe: /* * Deduce our configuration from the WHOAMI register. */ - whoami = (*(volatile u_int32_t *)AV_WHOAMI & 0xf0) >> 4; + + if (whoamiptr == NULL) + whoami = 0x0a; /* 1 CPU, 2 CMMUs */ + else + whoami = (*whoamiptr & 0xf0) >> 4; + switch (whoami) { case 0: /* 4 CPUs, 8 CMMUs */ scc.cpucount = 4; @@ -137,11 +169,11 @@ hardprobe: case 5: /* 2 CPUs, 4 CMMUs */ scc.cpucount = 2; break; - case 0x0a: /* 1 CPU, 2 CMMU */ + case 0x0a: /* 1 CPU, 2 CMMUs */ scc.cpucount = 1; break; case 3: /* 2 CPUs, 12 CMMUs */ - case 7: /* 1 CPU, 6 CMMU */ + case 7: /* 1 CPU, 6 CMMUs */ /* * Regular logic can't cope with asymmetrical * designs. Report a 4:1 ratio with two missing @@ -279,7 +311,10 @@ m8820x_cpu_number() u_int32_t whoami; cpuid_t cpu; - whoami = *(volatile u_int32_t *)AV_WHOAMI; + if (whoamiptr == NULL) + return 0; + + whoami = *whoamiptr; switch ((whoami & 0xf0) >> 4) { case 0: case 3: |