From 253169d468245e060e71ba1212f6988b4386d05f Mon Sep 17 00:00:00 2001 From: cgd Date: Fri, 21 May 1993 12:23:31 +0000 Subject: [PATCH] add "cpu classes" in addition to cpu names, put cpu names in table, along with mapping to classes. this is for upgraded cpu-id code coming "soon" --- sys/arch/i386/i386/machdep.c | 68 ++++++++++++++++++++------------ sys/arch/i386/include/cpu.h | 8 +++- sys/arch/i386/include/cputypes.h | 23 ++++++++--- 3 files changed, 66 insertions(+), 33 deletions(-) diff --git a/sys/arch/i386/i386/machdep.c b/sys/arch/i386/i386/machdep.c index 3317a0b80321..71498eadfedc 100644 --- a/sys/arch/i386/i386/machdep.c +++ b/sys/arch/i386/i386/machdep.c @@ -35,7 +35,7 @@ * SUCH DAMAGE. * * from: @(#)machdep.c 7.4 (Berkeley) 6/3/91 - * $Id: machdep.c,v 1.17 1993/05/20 15:36:40 cgd Exp $ + * $Id: machdep.c,v 1.18 1993/05/21 12:23:31 cgd Exp $ */ #include "param.h" @@ -248,48 +248,64 @@ again: configure(); } + +struct cpu_nameclass i386_cpus[] = { + { "Intel 80286", CPUCLASS_286 }, /* CPU_286 */ + { "i386SX", CPUCLASS_386 }, /* CPU_386SX */ + { "i386DX", CPUCLASS_386 }, /* CPU_386 */ + { "i486SX", CPUCLASS_486 }, /* CPU_486SX */ + { "i486DX", CPUCLASS_486 }, /* CPU_486 */ + { "i586", CPUCLASS_586 }, /* CPU_586 */ +}; + identifycpu() /* translated from hp300 -- cgd */ { + int class; + printf("CPU: "); - switch (cpu) { - case CPU_386SX: - printf("i386SX"); - break; - case CPU_386: - printf("i386"); - break; - case CPU_486SX: - printf("i486SX"); - break; - case CPU_486: - printf("i486"); - break; - case CPU_586: - printf("i586"); - break; - default: + if (cpu >= 0 && cpu < (sizeof i386_cpus/sizeof(struct cpu_nameclass))) { + printf("%s", i386_cpus[cpu].cpu_name); + class = i386_cpus[cpu].cpu_class; + } else { printf("unknown cpu type %d\n", cpu); panic("startup: bad cpu id"); } + printf(" ("); + switch(class) { + case CPUCLASS_286: + printf("286"); + break; + case CPUCLASS_386: + printf("386"); + break; + case CPUCLASS_486: + printf("486"); + break; + case CPUCLASS_586: + printf("586"); + break; + default: + printf("unknown"); /* will panic below... */ + } + printf("-class CPU)"); printf("\n"); /* cpu speed would be nice, but how? */ + /* * Now that we have told the user what they have, * let them know if that machine type isn't configured. */ - switch (cpu) { - case -1: /* keep compilers happy */ + switch (class) { + case CPUCLASS_286: /* a 286 should not make it this far, anyway */ #if !defined(I386_CPU) - case CPU_386SX: - case CPU_386: + case CPUCLASS_386: #endif #if !defined(I486_CPU) - case CPU_486SX: - case CPU_486: + case CPUCLASS_486: #endif #if !defined(I586_CPU) - case CPU_586: + case CPUCLASS_586: #endif - panic("CPU type not configured"); + panic("CPU class not configured"); default: break; } diff --git a/sys/arch/i386/include/cpu.h b/sys/arch/i386/include/cpu.h index 9efe753a810e..89da1cba2898 100644 --- a/sys/arch/i386/include/cpu.h +++ b/sys/arch/i386/include/cpu.h @@ -34,7 +34,7 @@ * SUCH DAMAGE. * * from: @(#)cpu.h 5.4 (Berkeley) 5/9/91 - * $Id: cpu.h,v 1.5 1993/05/21 11:06:37 cgd Exp $ + * $Id: cpu.h,v 1.6 1993/05/21 12:26:03 cgd Exp $ */ /* @@ -103,6 +103,12 @@ int want_resched; /* resched() was called */ */ #include "machine/cputypes.h" +struct cpu_nameclass { + char *cpu_name; + int cpu_class; +}; + #ifdef KERNEL extern int cpu; +extern struct cpu_nameclass i386_cpus[]; #endif diff --git a/sys/arch/i386/include/cputypes.h b/sys/arch/i386/include/cputypes.h index 8017965f7107..1c437992d468 100644 --- a/sys/arch/i386/include/cputypes.h +++ b/sys/arch/i386/include/cputypes.h @@ -24,15 +24,26 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * $Id: cputypes.h,v 1.1 1993/05/21 11:06:40 cgd Exp $ + * $Id: cputypes.h,v 1.2 1993/05/21 12:26:04 cgd Exp $ */ +/* + * Classes of Processor + */ + +#define CPUCLASS_286 0 +#define CPUCLASS_386 1 +#define CPUCLASS_486 2 +#define CPUCLASS_586 3 + /* * Kinds of Processor */ -#define CPU_386SX 0 -#define CPU_386 1 -#define CPU_486SX 2 -#define CPU_486 3 -#define CPU_586 4 +#define CPU_286 0 /* Intel 80286 */ +#define CPU_386SX 1 /* Intel 80386SX */ +#define CPU_386 2 /* Intel 80386DX */ +#define CPU_486SX 3 /* Intel 80486SX */ +#define CPU_486 4 /* Intel 80486DX */ +#define CPU_586 5 /* Intel P.....m (I hate lawyers; it's TM) */ +