Subject: new sysctl: hw.cpu_isa
To: None <tech-kern@netbsd.org>
From: Simon Burge <simonb@wasabisystems.com>
List: tech-kern
Date: 11/14/2000 01:13:04
Folks,

I'd like to add a new sysctl the returns the CPU ISA.  I would suspect
that when we have SMP that the lowest ISA of any of the CPUs would be
returned by this sysctl.  My primary inspiration for this is to allow
selection of optimised libraries on ELF systems using /etc/ld.so.conf.
For example, on my test alpha I have in /etc/ld.so.conf

	libm.so.0	hw.cpu_arch	ev56:libm-ev56.so.0
	libc.so.12	hw.cpu_arch	ev56:libc-ev56.so.12

and the lib*-ev56 libraries have been compiled with -mcpu=ev56.  To
quote a meaningless benchmark, this got me about a 10% speed improvement
for the dhrystone benchmark on a 500MHz 21164a.

Note that this is not designed for fine-grained feature selection, like
the alpha amask or x86 CPUID.  If libraries wish to optimise on specific
features then machdep sysctls should be added and used.  One example is
an atomic test-and-set type routine for MIPS - MIPS3 defines the ll/sc
opcode but these aren't implemented on some of the VR4xxx processors
even though they are otherwise MIPS3 processors.

Also, there are lots of places where I've made assumptions about what is
a valid ISA for a given architecture.  These should be checked by people
familiar with those architectures.  The only ones I'm confident with are
mips, alpha, m68k, ns32k and perhaps sparc.  Here's a list of the ISA's:

	alpha	ev{4,5,56,6,67}
	arm26	arm2
	arm32	arm{2,3,4}
	i386	{3,4,5,6}86
	m68k	680{2,3,4,6}0
	mips	mips{1,2,3,4,5,32,64}
	ns32k	ns32532 +
	ppc	60{1,2,3,3e,3e+,4,4e},620,750,7400 *
	sh3	sh3 +
	sparc	sun4{,c,m,u}
	sparc64	sun4u
	vax	vax +

* For powerpc, some use 603ev while others use 603e+ and similar.  There
  really should be a single identifycpu() in arch/powerpc which I can do
  if someone tells me the canonical names.

+ For some, we either only support one cpu type or gcc at least doesn't
  provide any optimisations for different CPU ISA's.  These assumptions
  may be bogus!

So, anyone disagree with this whole idea or have any suggestions of
improvements?

Simon.
--
Simon Burge                            <simonb@wasabisystems.com>
NetBSD Sales, Support and Service:  http://www.wasabisystems.com/

Index: arch/alpha/alpha/cpu.c
===================================================================
RCS file: /cvsroot/syssrc/sys/arch/alpha/alpha/cpu.c,v
retrieving revision 1.55
diff -d -p -u -r1.55 cpu.c
--- arch/alpha/alpha/cpu.c	2000/09/04 00:31:58	1.55
+++ arch/alpha/alpha/cpu.c	2000/11/13 04:54:54
@@ -114,6 +114,7 @@ struct	cpu_info cpu_info_store;
  * extension".
  */
 u_long	cpu_implver, cpu_amask;
+u_int32_t cpu_majorrev;
 
 /* Definition of the driver for autoconfig. */
 static int	cpumatch(struct device *, struct cfdata *, void *);
@@ -150,6 +151,29 @@ struct cputable_struct {
 	{ PCS_PROC_EV67,	"21264A",	NULL		},
 };
 
+const char *cpuarchtable[] = {
+	"",		/*  0 */
+	"ev4",		/*  1: PCS_PROC_EV3 */
+	"ev4",		/*  2: PCS_PROC_EV4 */
+	"ev4",		/*  3: PCS_PROC_SIMULATION */
+	"ev4",		/*  4: PCS_PROC_LCA4 */
+	"ev5",		/*  5: PCS_PROC_EV5 */
+	"ev4",		/*  6: PCS_PROC_EV45 */
+	"ev56",		/*  7: PCS_PROC_EV56 */
+	"ev6",		/*  8: PCS_PROC_EV6 */
+	"ev56",		/*  9: PCS_PROC_PCA56 */
+	"ev56",		/* 10: PCS_PROC_PCA57 */
+	"ev67",		/* 11: PCS_PROC_EV67 */
+};
+
+const char *
+alpha_cpuarch_name(void)
+{
+	if (cpu_majorrev < sizeof cpuarchtable / sizeof cpuarchtable[0])
+		return cpuarchtable[cpu_majorrev];
+	return NULL;
+}
+
 /*
  * The following is an attempt to map out how booting secondary CPUs
  * works.
@@ -220,6 +244,7 @@ cpuattach(parent, self, aux)
 	p = LOCATE_PCS(hwrpb, ma->ma_slot);
 	major = PCS_CPU_MAJORTYPE(p);
 	minor = PCS_CPU_MINORTYPE(p);
+	cpu_majorrev = major;	/* save for alpha_cpuarch_name() */
 
 	printf(": ID %d%s, ", ma->ma_slot,
 	    ma->ma_slot == hwrpb->rpb_primary_cpu_id ? " (primary)" : "");
Index: arch/alpha/alpha/machdep.c
===================================================================
RCS file: /cvsroot/syssrc/sys/arch/alpha/alpha/machdep.c,v
retrieving revision 1.221
diff -d -p -u -r1.221 machdep.c
--- arch/alpha/alpha/machdep.c	2000/09/24 12:32:32	1.221
+++ arch/alpha/alpha/machdep.c	2000/11/13 04:57:42
@@ -153,6 +153,7 @@ u_int32_t no_optimize;
 char	machine[] = MACHINE;		/* from <machine/param.h> */
 char	machine_arch[] = MACHINE_ARCH;	/* from <machine/param.h> */
 char	cpu_model[128];
+char	cpu_isa[32];
 
 struct	user *proc0paddr;
 
@@ -361,6 +362,7 @@ nobootinfo:
 	}
 	(*c->init)();
 	strcpy(cpu_model, platform.model);
+	strcpy(cpu_isa, alpha_cpuarch_name());
 
 	/*
 	 * Initalize the real console, so that the bootstrap console is
Index: arch/alpha/include/alpha_cpu.h
===================================================================
RCS file: /cvsroot/syssrc/sys/arch/alpha/include/alpha_cpu.h,v
retrieving revision 1.41
diff -d -p -u -r1.41 alpha_cpu.h
--- arch/alpha/include/alpha_cpu.h	2000/06/08 03:10:06	1.41
+++ arch/alpha/include/alpha_cpu.h	2000/11/13 04:57:44
@@ -316,6 +316,7 @@ typedef unsigned long alpha_pt_entry_t;
  * Misc. support routines.
  */
 const char	*alpha_dsr_sysname(void);
+const char	*alpha_cpuarch_name(void);
 
 /*
  * Stubs for Alpha instructions normally inaccessible from C.
Index: arch/amiga/amiga/machdep.c
===================================================================
RCS file: /cvsroot/syssrc/sys/arch/amiga/amiga/machdep.c,v
retrieving revision 1.156
diff -d -p -u -r1.156 machdep.c
--- arch/amiga/amiga/machdep.c	2000/09/13 15:00:16	1.156
+++ arch/amiga/amiga/machdep.c	2000/11/13 05:00:07
@@ -146,11 +146,6 @@ int	safepri = PSL_LOWIPL;
 extern  int   freebufspace;
 extern	u_int lowram;
 
-/* used in init_main.c */
-char	*cpu_type = "m68k";
-/* the following is used externally (sysctl_hw) */
-char	machine[] = MACHINE;	/* from <machine/param.h> */
-
 /* Our exported CPU info; we can have only one. */
 struct cpu_info cpu_info_store;
  
@@ -387,11 +382,6 @@ setregs(p, pack, stack)
 		m68881_restore(&p->p_addr->u_pcb.pcb_fpregs);
 }
 
-/*
- * Info for CTL_HW
- */
-char cpu_model[120];
-
 #if defined(M68060)
 int m68060_pcr_init = 0x21;	/* make this patchable */
 #endif
@@ -401,7 +391,7 @@ void
 identifycpu()
 {
         /* there's alot of XXX in here... */
-	char *mach, *mmu, *fpu;
+	char *cpu, *mach, *mmu, *fpu;
 
 #ifdef M68060
 	char cpubuf[16];
@@ -431,7 +421,7 @@ identifycpu()
 		asm(".word 0x4e7a,0x0808; movl d0,%0" : "=d"(pcr) : : "d0");
 		sprintf(cpubuf, "68%s060 rev.%d",
 		    pcr & 0x10000 ? "LC/EC" : "", (pcr>>8)&0xff);
-		cpu_type = cpubuf;
+		cpu = cpubuf;
 		mmu = "/MMU";
 		if (pcr & 2) {
 			fpu = "/FPU disabled";
@@ -446,15 +436,15 @@ identifycpu()
 	} else 
 #endif
 	if (machineid & AMIGA_68040) {
-		cpu_type = "m68040";
+		cpu = "m68040";
 		mmu = "/MMU";
 		fpu = "/FPU";
 		fputype = FPU_68040; /* XXX */
 	} else if (machineid & AMIGA_68030) {
-		cpu_type = "m68030";	/* XXX */
+		cpu = "m68030";	/* XXX */
 		mmu = "/MMU";
 	} else {
-		cpu_type = "m68020";
+		cpu = "m68020";
 		mmu = " m68851 MMU";
 	}
 	if (fpu == NULL) {
@@ -469,7 +459,8 @@ identifycpu()
 			fputype = FPU_NONE;
 		}
 	}
-	sprintf(cpu_model, "%s (%s CPU%s%s)", mach, cpu_type, mmu, fpu);
+	sprintf(cpu_model, "%s (%s CPU%s%s)", mach, cpu, mmu, fpu);
+	setcpuisa();
 	printf("%s\n", cpu_model);
 }
 
Index: arch/amigappc/amigappc/machdep.c
===================================================================
RCS file: /cvsroot/syssrc/sys/arch/amigappc/amigappc/machdep.c,v
retrieving revision 1.6
diff -d -p -u -r1.6 machdep.c
--- arch/amigappc/amigappc/machdep.c	2000/09/13 15:00:16	1.6
+++ arch/amigappc/amigappc/machdep.c	2000/11/13 05:01:18
@@ -71,6 +71,7 @@ extern struct user *proc0paddr;
 
 /* from amiga/machdep.c */
 char cpu_model[80];
+char cpu_isa[32];
 char machine[] = MACHINE;
 char machine_arch[] = MACHINE_ARCH;
 
@@ -709,6 +710,7 @@ identifycpu()
 	snprintf(cpu_model, sizeof(cpu_model), 
 	    "%s %s (%s rev.%x %d MHz, busclk %d kHz)",
 	    mach, pup, cpu, pvr & 0xffff, cpuclock, busclock / 1000);
+	strcpy(cpu_isa, cpu);
 	printf("%s\n", cpu_model);
 }
 
Index: arch/arc/arc/machdep.c
===================================================================
RCS file: /cvsroot/syssrc/sys/arch/arc/arc/machdep.c,v
retrieving revision 1.45
diff -d -p -u -r1.45 machdep.c
--- arch/arc/arc/machdep.c	2000/09/24 12:32:32	1.45
+++ arch/arc/arc/machdep.c	2000/11/13 05:01:23
@@ -178,7 +178,8 @@ extern void pccnattach __P((void));
 /* the following is used externally (sysctl_hw) */
 char	machine[] = MACHINE;		/* from <machine/param.h> */
 char	machine_arch[] = MACHINE_ARCH;	/* from <machine/param.h> */
-char	cpu_model[30];
+char	cpu_model[32];
+char	cpu_isa[32];
 
 /* Our exported CPU info; we can have only one. */
 struct cpu_info cpu_info_store;
Index: arch/arm26/arm26/machdep.c
===================================================================
RCS file: /cvsroot/syssrc/sys/arch/arm26/arm26/machdep.c,v
retrieving revision 1.5
diff -d -p -u -r1.5 machdep.c
--- arch/arm26/arm26/machdep.c	2000/09/13 15:00:17	1.5
+++ arch/arm26/arm26/machdep.c	2000/11/13 05:01:54
@@ -48,6 +48,7 @@ int physmem;
 char machine[] = MACHINE;
 char machine_arch[] = MACHINE_ARCH;
 char cpu_model[] = "Archimedes";
+char cpu_isa[] = "arm2";	/* XXX */
 
 /* Our exported CPU info; we can have only one. */
 struct cpu_info cpu_info_store;
Index: arch/arm32/mainbus/cpu.c
===================================================================
RCS file: /cvsroot/syssrc/sys/arch/arm32/mainbus/cpu.c,v
retrieving revision 1.24
diff -d -p -u -r1.24 cpu.c
--- arch/arm32/mainbus/cpu.c	2000/06/29 08:53:01	1.24
+++ arch/arm32/mainbus/cpu.c	2000/11/13 05:05:47
@@ -74,6 +74,7 @@ struct cpu_softc {
 cpu_t cpus[MAX_CPUS];
 
 char cpu_model[64];
+char cpu_isa[32];
 volatile int undefined_test;	/* Used for FPA test */
 extern int cpuctrl;		/* cpu control register value */
 
@@ -347,17 +348,20 @@ identify_arm_cpu(cpu_number)
 #ifdef CPU_ARM6
         case ID_ARM610:
         	cpu->cpu_type = cpuid & CPU_ID_CPU_MASK;
+		strcpy(cpu_isa, "arm3");	/* XXX */
 		break;
 #endif
 #ifdef CPU_ARM7
 	case ID_ARM710 :
 	case ID_ARM700 :
 		cpu->cpu_type = (cpuid & CPU_ID_CPU_MASK) >> 4;
+		strcpy(cpu_isa, "arm3");	/* XXX */
 		break;
 #endif
 #ifdef CPU_ARM8
 	case ID_ARM810 :
 		cpu->cpu_type = (cpuid & CPU_ID_CPU_MASK) >> 4;
+		strcpy(cpu_isa, "arm4");	/* XXX */
 		break;
 #endif
 #ifdef CPU_SA110
@@ -366,11 +370,13 @@ identify_arm_cpu(cpu_number)
 		cpu->cpu_class = CPU_CLASS_SARM;
 		sprintf(cpu->cpu_model, "SA-110 rev %d",
 		    cpuid & CPU_ID_REVISION_MASK);
+		strcpy(cpu_isa, "arm4");	/* XXX */
 		break;
 #endif
 	default :
 		printf("Unrecognised processor ID = %08x\n", cpuid);
 		cpu->cpu_type = cpuid & CPU_ID_CPU_MASK;
+		strcpy(cpu_isa, "unknown");
 		break;
 	}
 
Index: arch/atari/atari/machdep.c
===================================================================
RCS file: /cvsroot/syssrc/sys/arch/atari/atari/machdep.c,v
retrieving revision 1.101
diff -d -p -u -r1.101 machdep.c
--- arch/atari/atari/machdep.c	2000/09/28 07:26:48	1.101
+++ arch/atari/atari/machdep.c	2000/11/13 05:05:53
@@ -114,9 +114,6 @@ extern	u_int lowram;
  */
 int	fputype = 0;
 
-/* the following is used externally (sysctl_hw) */
-char	machine[] = MACHINE;	/* from <machine/param.h> */
-
 /* Our exported CPU info; we can have only one. */
 struct cpu_info cpu_info_store;
 
@@ -349,11 +346,6 @@ setregs(p, pack, stack)
 		m68881_restore(&p->p_addr->u_pcb.pcb_fpregs);
 }
 
-/*
- * Info for CTL_HW
- */
-char cpu_model[120];
- 
 static void
 identifycpu()
 {
@@ -406,6 +398,7 @@ identifycpu()
 		mmu = " m68851 MMU";
 	}
 	sprintf(cpu_model, "%s (%s CPU%s%sFPU)", mach, cpu, mmu, fpu);
+	setcpuisa();
 	printf("%s\n", cpu_model);
 }
 
Index: arch/bebox/bebox/machdep.c
===================================================================
RCS file: /cvsroot/syssrc/sys/arch/bebox/bebox/machdep.c,v
retrieving revision 1.57
diff -d -p -u -r1.57 machdep.c
--- arch/bebox/bebox/machdep.c	2000/09/13 15:00:17	1.57
+++ arch/bebox/bebox/machdep.c	2000/11/13 05:07:28
@@ -364,6 +364,7 @@ mem_regions(mem, avail)
  */
 int cpu;
 char cpu_model[80];
+char cpu_isa[32];
 char cpu_name[] = "PowerPC";	/* cpu architecture */
 
 void
@@ -406,6 +407,7 @@ identifycpu()
 		sprintf(cpu_model, "Version %x", cpu);
 		break;
 	}
+	strcpy(cpu_isa, cpu);
 	sprintf(cpu_model + strlen(cpu_model), " (Revision %x)", pvr & 0xffff);
 	printf("CPU: %s %s\n", cpu_name, cpu_model);
 }
Index: arch/cobalt/cobalt/machdep.c
===================================================================
RCS file: /cvsroot/syssrc/sys/arch/cobalt/cobalt/machdep.c,v
retrieving revision 1.23
diff -d -p -u -r1.23 machdep.c
--- arch/cobalt/cobalt/machdep.c	2000/10/05 02:36:44	1.23
+++ arch/cobalt/cobalt/machdep.c	2000/11/13 05:07:30
@@ -79,6 +79,7 @@
 char machine[] = MACHINE;
 char machine_arch[] = MACHINE_ARCH;
 char cpu_model[] = "Cobalt Microserver";
+char cpu_isa[32];
 
 /* Our exported CPU info; we can have only one. */  
 struct cpu_info cpu_info_store;
Index: arch/hp300/hp300/machdep.c
===================================================================
RCS file: /cvsroot/syssrc/sys/arch/hp300/hp300/machdep.c,v
retrieving revision 1.143
diff -d -p -u -r1.143 machdep.c
--- arch/hp300/hp300/machdep.c	2000/09/13 15:00:18	1.143
+++ arch/hp300/hp300/machdep.c	2000/11/13 05:08:23
@@ -103,9 +103,6 @@
 #include <arch/hp300/hp300/leds.h>
 #endif
 
-/* the following is used externally (sysctl_hw) */
-char	machine[] = MACHINE;	/* from <machine/param.h> */
-
 /* Our exported CPU info; we can have only one. */  
 struct cpu_info cpu_info_store;
 
@@ -459,11 +456,6 @@ setregs(p, pack, stack)
 		m68881_restore(&p->p_addr->u_pcb.pcb_fpregs);
 }
 
-/*
- * Info for CTL_HW
- */
-char	cpu_model[120];
-
 struct hp300_model {
 	int id;
 	int mmuid;
@@ -536,6 +528,7 @@ identifycpu()
 	}
 
 	sprintf(cpu_model, "HP 9000/%s (%sMHz MC680%s CPU", t, s, mc);
+	setcpuisa();
 
 	/*
 	 * ...and the MMU type.
Index: arch/hpcmips/hpcmips/machdep.c
===================================================================
RCS file: /cvsroot/syssrc/sys/arch/hpcmips/hpcmips/machdep.c,v
retrieving revision 1.35
diff -d -p -u -r1.35 machdep.c
--- arch/hpcmips/hpcmips/machdep.c	2000/10/05 02:36:45	1.35
+++ arch/hpcmips/hpcmips/machdep.c	2000/11/13 05:08:28
@@ -125,6 +125,7 @@ extern int (*mountroot) __P((void));
 char	machine[] = MACHINE;		/* from <machine/param.h> */
 char	machine_arch[] = MACHINE_ARCH;	/* from <machine/param.h> */
 char	cpu_model[128];	
+char	cpu_isa[32];	
 
 char	cpu_name[40];			/* set cpu depend xx_init() */
 
Index: arch/i386/i386/machdep.c
===================================================================
RCS file: /cvsroot/syssrc/sys/arch/i386/i386/machdep.c,v
retrieving revision 1.412
diff -d -p -u -r1.412 machdep.c
--- arch/i386/i386/machdep.c	2000/11/10 04:00:25	1.412
+++ arch/i386/i386/machdep.c	2000/11/13 05:09:20
@@ -554,6 +554,7 @@ i386_cache_info_lookup(u_int8_t desc)
  * Info for CTL_HW
  */
 char	cpu_model[120];
+char	cpu_isa[32];
 
 /*
  * Note: these are just the ones that may not have a cpuid instruction.
@@ -570,8 +571,8 @@ struct cpu_nocpuid_nameclass i386_nocpui
 		NULL},				/* CPU_486   */
 	{ CPUVENDOR_CYRIX, "Cyrix", "486DLC",	CPUCLASS_486,
 		NULL},				/* CPU_486DLC */
-	{ CPUVENDOR_CYRIX, "Cyrix", "6x86",		CPUCLASS_486,
-		cyrix6x86_cpu_setup},	/* CPU_6x86 */
+	{ CPUVENDOR_CYRIX, "Cyrix", "6x86",	CPUCLASS_486,
+		cyrix6x86_cpu_setup},		/* CPU_6x86 */
 	{ CPUVENDOR_NEXGEN,"NexGen","586",      CPUCLASS_386,
 		NULL},				/* CPU_NX586 */
 };
@@ -930,6 +931,7 @@ identifycpu()
 
 	sprintf(cpu_model, "%s %s%s (%s-class)", vendorname, modifier, name,
 		classnames[class]);
+	strcpy(cpu_isa, classnames[class]);
 
 	cpu_class = class;
 
Index: arch/luna68k/luna68k/machdep.c
===================================================================
RCS file: /cvsroot/syssrc/sys/arch/luna68k/luna68k/machdep.c,v
retrieving revision 1.12
diff -d -p -u -r1.12 machdep.c
--- arch/luna68k/luna68k/machdep.c	2000/09/24 12:32:35	1.12
+++ arch/luna68k/luna68k/machdep.c	2000/11/13 05:09:33
@@ -88,12 +88,6 @@ __KERNEL_RCSID(0, "$NetBSD: machdep.c,v 
 #include <ddb/db_extern.h>
 #endif
 
-/*
- * Info for CTL_HW
- */
-char	machine[] = MACHINE;
-char	cpu_model[60];
-
 /* Our exported CPU info; we can have only one. */  
 struct cpu_info cpu_info_store;
 
@@ -434,6 +428,7 @@ identifycpu()
 		panic("unknown CPU type");
 	}
 	strcpy(cpu_model, cpu);
+	setcpuisa();
 	printf("%s\n", cpu_model);
 }
 
Index: arch/m68k/include/m68k.h
===================================================================
RCS file: /cvsroot/syssrc/sys/arch/m68k/include/m68k.h,v
retrieving revision 1.6
diff -d -p -u -r1.6 m68k.h
--- arch/m68k/include/m68k.h	1997/10/21 19:15:33	1.6
+++ arch/m68k/include/m68k.h	2000/11/13 05:09:34
@@ -115,6 +115,9 @@ int	mappedcopyout __P((void *fromp, void
 extern	u_int mappedcopysize;
 #endif /* MAPPEDCOPY */
 
+/* m68k_machdep.c */
+void	setcpuisa() __P((void));
+
 /* regdump.c */
 void	regdump __P((struct trapframe *, int));
 
Index: arch/m68k/m68k/m68k_machdep.c
===================================================================
RCS file: /cvsroot/syssrc/sys/arch/m68k/m68k/m68k_machdep.c,v
retrieving revision 1.4
diff -d -p -u -r1.4 m68k_machdep.c
--- arch/m68k/m68k/m68k_machdep.c	2000/06/14 16:11:24	1.4
+++ arch/m68k/m68k/m68k_machdep.c	2000/11/13 05:09:35
@@ -34,7 +34,38 @@
  */
 
 #include <sys/param.h>
+#include <machine/cpu.h>
 
 /* the following is used externally (sysctl_hw) */
+char	machine[] = MACHINE;		/* from <machine/param.h> */
 char	machine_arch[] = MACHINE_ARCH;	/* from <machine/param.h> */
+char	cpu_model[124];
+char	cpu_isa[32];
+
+void
+setcpuisa()
+{
+	char *mc;
 
+	switch (cputype) {
+	case CPU_68020:
+		mc = "20";
+		break;
+	case CPU_68030:
+		mc = "30";
+		break;
+	case CPU_68040:
+		mc = "40";
+		break;
+	case CPU_68060:
+		mc = "60";
+		break;
+	default:
+		mc = NULL;
+	}
+
+	if (mc)
+		sprintf(cpu_isa, "m680%s", mc);
+	else
+		strcpy(cpu_isa, "unknown");
+}
Index: arch/mac68k/mac68k/machdep.c
===================================================================
RCS file: /cvsroot/syssrc/sys/arch/mac68k/mac68k/machdep.c,v
retrieving revision 1.258
diff -d -p -u -r1.258 machdep.c
--- arch/mac68k/mac68k/machdep.c	2000/09/13 15:00:19	1.258
+++ arch/mac68k/mac68k/machdep.c	2000/11/13 05:12:27
@@ -141,9 +141,6 @@
 #endif
 #include <mac68k/dev/zs_cons.h>
 
-/* The following is used externally (sysctl_hw) */
-char	machine[] = MACHINE;	/* from <machine/param.h> */
-
 struct mac68k_machine_S mac68k_machine;
 
 volatile u_char *Via1Base, *Via2Base, *PSCBase = NULL;
@@ -2019,8 +2016,6 @@ struct intvid_info_t {
  * 	...?
  */
 
-char	cpu_model[120];		/* for sysctl() */
-
 int	mach_cputype __P((void));
 
 int
@@ -2037,22 +2032,23 @@ identifycpu()
 
 	switch (cputype) {
 	case CPU_68020:
-		mpu = ("(68020)");
+		mpu = "68020";
 		break;
 	case CPU_68030:
-		mpu = ("(68030)");
+		mpu = "68030";
 		break;
 	case CPU_68040:
-		mpu = ("(68040)");
+		mpu = "68040";
 		break;
 	default:
-		mpu = ("(unknown processor)");
+		mpu = "unknown processor";
 		break;
 	}
-	sprintf(cpu_model, "Apple Macintosh %s%s %s",
+	sprintf(cpu_model, "Apple Macintosh %s%s (%s)",
 	    cpu_models[mac68k_machine.cpu_model_index].model_major,
 	    cpu_models[mac68k_machine.cpu_model_index].model_minor,
 	    mpu);
+	setcpuisa();
 	printf("%s\n", cpu_model);
 	printf("cpu: delay factor %d\n", delay_factor);
 }
Index: arch/macppc/macppc/cpu.c
===================================================================
RCS file: /cvsroot/syssrc/sys/arch/macppc/macppc/cpu.c,v
retrieving revision 1.15
diff -d -p -u -r1.15 cpu.c
--- arch/macppc/macppc/cpu.c	2000/11/09 11:58:09	1.15
+++ arch/macppc/macppc/cpu.c	2000/11/13 05:12:31
@@ -254,10 +254,13 @@ identifycpu(cpu_model)
 			break;
 		cp++;
 	}
-	if (cp->name)
+	if (cp->name) {
 		strcpy(cpu_model, cp->name);
-	else
+		strcpy(cpu_isa, cpu_model);
+	} else {
 		sprintf(cpu_model, "Version %x", vers);
+		sprintf(cpu_isa, "vers%x", vers);
+	}
 	sprintf(cpu_model + strlen(cpu_model), " (Revision %x)", rev);
 }
 
Index: arch/macppc/macppc/machdep.c
===================================================================
RCS file: /cvsroot/syssrc/sys/arch/macppc/macppc/machdep.c,v
retrieving revision 1.87
diff -d -p -u -r1.87 machdep.c
--- arch/macppc/macppc/machdep.c	2000/11/06 12:35:21	1.87
+++ arch/macppc/macppc/machdep.c	2000/11/13 05:12:38
@@ -392,6 +392,7 @@ restore_ofmap(ofmap, len)
  * This should probably be in autoconf!				XXX
  */
 char cpu_model[80];
+char cpu_isa[80];
 char machine[] = MACHINE;		/* from <machine/param.h> */
 char machine_arch[] = MACHINE_ARCH;	/* from <machine/param.h> */
 
Index: arch/mips/mips/mips_machdep.c
===================================================================
RCS file: /cvsroot/syssrc/sys/arch/mips/mips/mips_machdep.c,v
retrieving revision 1.107
diff -d -p -u -r1.107 mips_machdep.c
--- arch/mips/mips/mips_machdep.c	2000/10/05 02:36:45	1.107
+++ arch/mips/mips/mips_machdep.c	2000/11/13 05:12:43
@@ -106,6 +106,8 @@ extern long *mips3_locoresw[];	/* locore
 int cpu_arch;
 int cpu_mhz;
 int mips_num_tlb_entries;
+/* the following is used externally (sysctl_hw) */
+char cpu_isa[32];
 
 #ifdef MIPS3
 u_int	mips_L2CacheSize;
@@ -476,6 +478,32 @@ mips_vector_init()
 	{
 		printf("cpu_arch 0x%x: not supported\n", cpu_arch);
 		cpu_reboot(RB_HALT, NULL);
+	}
+	switch (cpu_arch) {
+	case CPU_ARCH_MIPS1:
+		strcpy(cpu_isa, "mips1");
+		break;
+	case CPU_ARCH_MIPS2:
+		strcpy(cpu_isa, "mips2");
+		break;
+	case CPU_ARCH_MIPS3:
+		strcpy(cpu_isa, "mips3");
+		break;
+	case CPU_ARCH_MIPS4:
+		strcpy(cpu_isa, "mips4");
+		break;
+	case CPU_ARCH_MIPS5:
+		strcpy(cpu_isa, "mips5");
+		break;
+	case CPU_ARCH_MIPS32:
+		strcpy(cpu_isa, "mips32");
+		break;
+	case CPU_ARCH_MIPS64:
+		strcpy(cpu_isa, "mips64");
+		break;
+	default:
+		strcpy(cpu_isa, "unknown");
+		break;
 	}
 }
 
Index: arch/mipsco/mipsco/machdep.c
===================================================================
RCS file: /cvsroot/syssrc/sys/arch/mipsco/mipsco/machdep.c,v
retrieving revision 1.12
diff -d -p -u -r1.12 machdep.c
--- arch/mipsco/mipsco/machdep.c	2000/10/02 07:57:29	1.12
+++ arch/mipsco/mipsco/machdep.c	2000/11/13 05:13:09
@@ -103,6 +103,7 @@ __KERNEL_RCSID(0, "$NetBSD: machdep.c,v 
 char  machine[] = MACHINE;	/* from <machine/param.h> */
 char  machine_arch[] = MACHINE_ARCH;
 char  cpu_model[40];
+char  cpu_isa[32];
 unsigned ssir;
 
 /* Our exported CPU info; we can have only one. */  
Index: arch/mvme68k/mvme68k/machdep.c
===================================================================
RCS file: /cvsroot/syssrc/sys/arch/mvme68k/mvme68k/machdep.c,v
retrieving revision 1.74
diff -d -p -u -r1.74 machdep.c
--- arch/mvme68k/mvme68k/machdep.c	2000/09/15 08:50:25	1.74
+++ arch/mvme68k/mvme68k/machdep.c	2000/11/13 05:13:14
@@ -98,9 +98,6 @@
 
 #define	MAXMEM	64*1024	/* XXX - from cmap.h */
 
-/* the following is used externally (sysctl_hw) */
-char	machine[] = MACHINE;	/* from <machine/param.h> */
-
 /* Our exported CPU info; we can have only one. */  
 struct cpu_info cpu_info_store;
 
@@ -567,11 +564,6 @@ setregs(p, pack, stack)
 		m68881_restore(&p->p_addr->u_pcb.pcb_fpregs);
 }
 
-/*
- * Info for CTL_HW
- */
-char	cpu_model[124];
-
 void
 identifycpu()
 {
@@ -619,6 +611,7 @@ identifycpu()
 		printf("unknown CPU type");
 		panic("startup");
 	}
+	setcpuisa();
 
 	/* Fill in the MMU string; only need to handle one case. */
 	switch (mmutype) {
Index: arch/news68k/news68k/machdep.c
===================================================================
RCS file: /cvsroot/syssrc/sys/arch/news68k/news68k/machdep.c,v
retrieving revision 1.12
diff -d -p -u -r1.12 machdep.c
--- arch/news68k/news68k/machdep.c	2000/09/15 15:55:10	1.12
+++ arch/news68k/news68k/machdep.c	2000/11/13 05:14:21
@@ -91,9 +91,6 @@
 #include "si.h"
 /* XXX etc. etc. */
 
-/* the following is used externally (sysctl_hw) */
-char	machine[] = MACHINE;	/* from <machine/param.h> */
-
 /* Our exported CPU info; we can have only one. */  
 struct cpu_info cpu_info_store;
 
@@ -380,11 +377,6 @@ setregs(p, pack, stack)
 		m68881_restore(&p->p_addr->u_pcb.pcb_fpregs);
 }
 
-/*
- * Info for CTL_HW
- */
-char cpu_model[124];
-
 int news_machine_id;
 
 void
@@ -395,6 +387,8 @@ identifycpu()
 	printf("Machine ID #%d\n", news_machine_id);
 
 	delay_divisor = (20480 / cpuspeed + 5) / 10; /* XXX */
+
+	setcpuisa();
 }
 
 /*
Index: arch/newsmips/newsmips/machdep.c
===================================================================
RCS file: /cvsroot/syssrc/sys/arch/newsmips/newsmips/machdep.c,v
retrieving revision 1.48
diff -d -p -u -r1.48 machdep.c
--- arch/newsmips/newsmips/machdep.c	2000/10/13 17:22:52	1.48
+++ arch/newsmips/newsmips/machdep.c	2000/11/13 05:14:24
@@ -104,7 +104,8 @@ __KERNEL_RCSID(0, "$NetBSD: machdep.c,v 
 /* the following is used externally (sysctl_hw) */
 char machine[] = MACHINE;	/* from <machine/param.h> */
 char machine_arch[] = MACHINE_ARCH;
-char cpu_model[30];
+char cpu_model[32];
+char cpu_isa[32];
 
 /* Our exported CPU info; we can have only one. */  
 struct cpu_info cpu_info_store;
Index: arch/next68k/next68k/machdep.c
===================================================================
RCS file: /cvsroot/syssrc/sys/arch/next68k/next68k/machdep.c,v
retrieving revision 1.39
diff -d -p -u -r1.39 machdep.c
--- arch/next68k/next68k/machdep.c	2000/09/24 12:32:37	1.39
+++ arch/next68k/next68k/machdep.c	2000/11/13 05:14:50
@@ -103,9 +103,6 @@
 
 #define	MAXMEM	64*1024	/* XXX - from cmap.h */
 
-/* the following is used externally (sysctl_hw) */
-char	machine[] = MACHINE;	/* from <machine/param.h> */
-
 /* Our exported CPU info; we can have only one. */  
 struct cpu_info cpu_info_store;
 
@@ -445,11 +442,6 @@ setregs(p, pack, stack)
 		m68881_restore(&p->p_addr->u_pcb.pcb_fpregs);
 }
 
-/*
- * Info for CTL_HW
- */
-char	cpu_model[124];
-
 void
 identifycpu()
 {
@@ -475,6 +467,7 @@ identifycpu()
 	}
 
 	sprintf(cpu_model, "NeXT/MC680%s CPU",mc);
+	setcpuisa();
 
 	/*
 	 * ...and the MMU type.
Index: arch/ofppc/ofppc/machdep.c
===================================================================
RCS file: /cvsroot/syssrc/sys/arch/ofppc/ofppc/machdep.c,v
retrieving revision 1.59
diff -d -p -u -r1.59 machdep.c
--- arch/ofppc/ofppc/machdep.c	2000/09/24 12:32:37	1.59
+++ arch/ofppc/ofppc/machdep.c	2000/11/13 05:14:53
@@ -278,6 +278,7 @@ initppc(startkernel, endkernel, args)
  */
 int cpu;
 char cpu_model[80];
+char cpu_isa[32];
 char machine[] = MACHINE;		/* from <machine/param.h> */
 char machine_arch[] = MACHINE_ARCH;	/* from <machine/param.h> */
 
@@ -321,6 +322,7 @@ identifycpu()
 		sprintf(cpu_model, "Version %x", cpu);
 		break;
 	}
+	strcpy(cpu_isa, cpu_model);
 	sprintf(cpu_model + strlen(cpu_model), " (Revision %x)", pvr & 0xffff);
 	printf("CPU: %s\n", cpu_model);
 }
Index: arch/pc532/pc532/machdep.c
===================================================================
RCS file: /cvsroot/syssrc/sys/arch/pc532/pc532/machdep.c,v
retrieving revision 1.116
diff -d -p -u -r1.116 machdep.c
--- arch/pc532/pc532/machdep.c	2000/09/13 15:00:21	1.116
+++ arch/pc532/pc532/machdep.c	2000/11/13 05:15:13
@@ -106,6 +106,7 @@ int _mapped = 0;
 char	machine[] = MACHINE;		/* from <machine/param.h> */
 char	machine_arch[] = MACHINE_ARCH;	/* from <machine/param.h> */
 char	cpu_model[] = "ns32532";
+char	cpu_isa[] = "ns32532";
 
 /* Our exported CPU info; we can have only one. */  
 struct cpu_info cpu_info_store;
Index: arch/pmax/pmax/machdep.c
===================================================================
RCS file: /cvsroot/syssrc/sys/arch/pmax/pmax/machdep.c,v
retrieving revision 1.180
diff -d -p -u -r1.180 machdep.c
--- arch/pmax/pmax/machdep.c	2000/09/24 12:32:38	1.180
+++ arch/pmax/pmax/machdep.c	2000/11/13 05:24:50
@@ -88,6 +88,7 @@ __KERNEL_RCSID(0, "$NetBSD: machdep.c,v 
 char	machine[] = MACHINE;		/* from <machine/param.h> */
 char	machine_arch[] = MACHINE_ARCH;	/* from <machine/param.h> */
 char	cpu_model[40];
+char	cpu_isa[32];
 unsigned ssir;				/* simulated interrupt register */
 
 /* Our exported CPU info; we can have only one. */  
Index: arch/prep/prep/machdep.c
===================================================================
RCS file: /cvsroot/syssrc/sys/arch/prep/prep/machdep.c,v
retrieving revision 1.11
diff -d -p -u -r1.11 machdep.c
--- arch/prep/prep/machdep.c	2000/09/13 15:00:22	1.11
+++ arch/prep/prep/machdep.c	2000/11/13 05:26:20
@@ -123,6 +123,7 @@ char bootinfo[BOOTINFO_MAXSIZE];
 char machine[] = MACHINE;		/* machine */
 char machine_arch[] = MACHINE_ARCH;	/* machine architecture */
 char cpu_model[80];
+char cpu_isa[32];
 
 struct pcb *curpcb;
 struct pmap *curpm;
@@ -415,6 +416,7 @@ identifycpu()
 		sprintf(cpu_model, "Version %x", cpu);
 		break;
 	}
+	strcpy(cpu_isa, cpu_model);
 	sprintf(cpu_model + strlen(cpu_model), " (Revision %x)", pvr & 0xffff);
 	printf("CPU: PowerPC %s\n", cpu_model);
 }
Index: arch/sgimips/sgimips/machdep.c
===================================================================
RCS file: /cvsroot/syssrc/sys/arch/sgimips/sgimips/machdep.c,v
retrieving revision 1.6
diff -d -p -u -r1.6 machdep.c
--- arch/sgimips/sgimips/machdep.c	2000/10/05 02:36:46	1.6
+++ arch/sgimips/sgimips/machdep.c	2000/11/13 05:30:53
@@ -84,6 +84,7 @@
 char machine[] = MACHINE;
 char machine_arch[] = MACHINE_ARCH;
 char cpu_model[] = "SGI";
+char cpu_isa[32];
 
 /* Our exported CPU info; we can have only one. */  
 struct cpu_info cpu_info_store;
Index: arch/sh3/sh3/sh3_machdep.c
===================================================================
RCS file: /cvsroot/syssrc/sys/arch/sh3/sh3/sh3_machdep.c,v
retrieving revision 1.9
diff -d -p -u -r1.9 sh3_machdep.c
--- arch/sh3/sh3/sh3_machdep.c	2000/09/13 15:00:22	1.9
+++ arch/sh3/sh3/sh3_machdep.c	2000/11/13 05:30:56
@@ -96,6 +96,7 @@
 #include <uvm/uvm_extern.h>
 
 char cpu_model[120];
+char cpu_isa[32];
 
 /* Our exported CPU info; we can have only one. */  
 struct cpu_info cpu_info_store;
@@ -121,6 +122,7 @@ sh3_startup()
 	printf(version);
 
 	sprintf(cpu_model, "Hitachi SH3");
+	strcpy(cpu_isa, "sh3");		/* XXX */
 
 	format_bytes(pbuf, sizeof(pbuf), ctob(physmem));
 	printf("total memory = %s\n", pbuf);
Index: arch/sparc/sparc/cpu.c
===================================================================
RCS file: /cvsroot/syssrc/sys/arch/sparc/sparc/cpu.c,v
retrieving revision 1.109
diff -d -p -u -r1.109 cpu.c
--- arch/sparc/sparc/cpu.c	2000/11/11 12:12:46	1.109
+++ arch/sparc/sparc/cpu.c	2000/11/13 05:38:29
@@ -84,6 +84,7 @@ struct cpu_softc {
 char	machine[] = MACHINE;		/* from <machine/param.h> */
 char	machine_arch[] = MACHINE_ARCH;	/* from <machine/param.h> */
 char	cpu_model[100];
+char	cpu_isa[32];
 
 int	ncpu;
 struct	cpu_info **cpus;
@@ -333,7 +334,7 @@ static	int cpu_instance;
 #endif
 
 	cpus[cpu_instance] = cpi;
-	cpi->cpu_no = cpu_instance++;
+	cpi->ci_cpuid = cpu_instance++;
 	cpi->mid = mid;
 	cpi->node = node;
 
@@ -346,6 +347,23 @@ static	int cpu_instance;
 			cpi->cpu_name, clockfreq(cpi->hz), cpi->fpu_name);
 		printf(": %s\n", cpu_model);
 		cache_print(sc);
+		switch (cputyp) {
+		case CPU_SUN4:
+			strcpy(cpu_isa, "sun4");
+			break;
+		case CPU_SUN4C:
+			strcpy(cpu_isa, "sun4c");
+			break;
+		case CPU_SUN4M:
+			strcpy(cpu_isa, "sun4m");
+			break;
+		case CPU_SUN4U:
+			strcpy(cpu_isa, "sun4u");
+			break;
+		default:
+			strcpy(cpu_isa, "unknown");
+			break;
+		}
 		return;
 	}
 
Index: arch/sparc64/sparc64/cpu.c
===================================================================
RCS file: /cvsroot/syssrc/sys/arch/sparc64/sparc64/cpu.c,v
retrieving revision 1.10
diff -d -p -u -r1.10 cpu.c
--- arch/sparc64/sparc64/cpu.c	2000/06/29 07:37:57	1.10
+++ arch/sparc64/sparc64/cpu.c	2000/11/13 05:50:12
@@ -78,6 +78,7 @@ struct cpu_info *cpus = NULL;
 char	machine[] = MACHINE;		/* from <machine/param.h> */
 char	machine_arch[] = MACHINE_ARCH;	/* from <machine/param.h> */
 char	cpu_model[100];
+char	cpu_isa[32];
 
 /* The CPU configuration driver. */
 static void cpu_attach __P((struct device *, struct device *, void *));
@@ -279,6 +280,7 @@ cpu_attach(parent, dev, aux)
 		getpropstring(node, "name"),
 		clockfreq(clk), fpuname);
 	printf(": %s\n", cpu_model);
+	strcpy(cpu_isa, "sun4u");	/* XXX only one model to worry about? */
 
 	cacheinfo.c_physical = 1; /* Dunno... */
 	cacheinfo.c_split = 1;
Index: arch/sun3/sun3/machdep.c
===================================================================
RCS file: /cvsroot/syssrc/sys/arch/sun3/sun3/machdep.c,v
retrieving revision 1.141
diff -d -p -u -r1.141 machdep.c
--- arch/sun3/sun3/machdep.c	2000/09/13 15:00:23	1.141
+++ arch/sun3/sun3/machdep.c	2000/11/13 05:51:19
@@ -364,9 +364,7 @@ setregs(p, pack, stack)
 /*
  * Info for CTL_HW
  */
-char	machine[16] = MACHINE;		/* from <machine/param.h> */
 char	kernel_arch[16] = "sun3";	/* XXX needs a sysctl node */
-char	cpu_model[120];
 
 /*
  * Determine which Sun3 model we are running on.
@@ -383,6 +381,7 @@ identifycpu()
 	/* Other stuff? (VAC, mc6888x version, etc.) */
 	/* Note: miniroot cares about the kernel_arch part. */
 	sprintf(cpu_model, "%s %s", kernel_arch, cpu_string);
+	setcpuisa();
 
 	printf("Model: %s\n", cpu_model);
 }
Index: arch/sun3/sun3x/machdep.c
===================================================================
RCS file: /cvsroot/syssrc/sys/arch/sun3/sun3x/machdep.c,v
retrieving revision 1.61
diff -d -p -u -r1.61 machdep.c
--- arch/sun3/sun3x/machdep.c	2000/11/09 14:38:44	1.61
+++ arch/sun3/sun3x/machdep.c	2000/11/13 05:51:21
@@ -359,9 +359,7 @@ setregs(p, pack, stack)
 /*
  * Info for CTL_HW
  */
-char	machine[16] = MACHINE;		/* from <machine/param.h> */
 char	kernel_arch[16] = "sun3x";	/* XXX needs a sysctl node */
-char	cpu_model[120];
 
 /*
  * XXX - Should empirically estimate the divisor...
@@ -404,6 +402,7 @@ identifycpu()
 	/* Other stuff? (VAC, mc6888x version, etc.) */
 	/* Note: miniroot cares about the kernel_arch part. */
 	sprintf(cpu_model, "%s %s", kernel_arch, cpu_string);
+	setcpuisa();
 
 	printf("Model: %s\n", cpu_model);
 }
Index: arch/vax/vax/machdep.c
===================================================================
RCS file: /cvsroot/syssrc/sys/arch/vax/vax/machdep.c,v
retrieving revision 1.109
diff -d -p -u -r1.109 machdep.c
--- arch/vax/vax/machdep.c	2000/10/18 21:38:52	1.109
+++ arch/vax/vax/machdep.c	2000/11/13 05:52:17
@@ -101,6 +101,7 @@ extern int virtual_avail, virtual_end;
 char		machine[] = MACHINE;		/* from <machine/param.h> */
 char		machine_arch[] = MACHINE_ARCH;	/* from <machine/param.h> */
 char		cpu_model[100];
+char		cpu_isa[] = "vax";	/* XXX one size fits all?  no gcc options for code generation ... */
 caddr_t		msgbufaddr;
 int		physmem;
 int		dumpsize = 0;
Index: arch/x68k/x68k/machdep.c
===================================================================
RCS file: /cvsroot/syssrc/sys/arch/x68k/x68k/machdep.c,v
retrieving revision 1.89
diff -d -p -u -r1.89 machdep.c
--- arch/x68k/x68k/machdep.c	2000/09/13 15:00:24	1.89
+++ arch/x68k/x68k/machdep.c	2000/11/13 05:52:23
@@ -108,9 +108,6 @@ void doboot __P((void))
 int badaddr __P((caddr_t));
 int badbaddr __P((caddr_t));
 
-/* the following is used externally (sysctl_hw) */
-char	machine[] = MACHINE;	/* from <machine/param.h> */
-
 /* Our exported CPU info; we can have only one. */  
 struct cpu_info cpu_info_store;
 
@@ -390,10 +387,6 @@ setregs(p, pack, stack)
 		m68881_restore(&p->p_addr->u_pcb.pcb_fpregs);
 }
 
-/*
- * Info for CTL_HW
- */
-char	cpu_model[96];		/* max 85 chars */
 static char *fpu_descr[] = {
 #ifdef	FPU_EMULATE
 	", emulator FPU", 	/* 0 */
@@ -477,6 +470,7 @@ identifycpu()
 		fpu = ", unknown FPU";
 	sprintf(cpu_model, "X68%s (%s CPU%s%s, %s clock)",
 		mach, cpu_type, mmu, fpu, clock);
+	setcpuisa();
 	printf("%s\n", cpu_model);
 }
 
Index: sys/systm.h
===================================================================
RCS file: /cvsroot/syssrc/sys/sys/systm.h,v
retrieving revision 1.120
diff -d -p -u -r1.120 systm.h
--- sys/systm.h	2000/11/08 22:41:59	1.120
+++ sys/systm.h	2000/11/13 06:02:37
@@ -92,11 +92,13 @@ extern int doing_shutdown;	/* shutting d
 
 extern const char copyright[];	/* system copyright */
 extern char cpu_model[];	/* machine/cpu model name */
+extern char cpu_isa[];		/* machine cpu instruction set architecture */
 extern char machine[];		/* machine type */
 extern char machine_arch[];	/* machine architecture */
 extern const char osrelease[];	/* short system version */
 extern const char ostype[];	/* system type */
 extern const char version[];	/* system version */
 
 extern int autonicetime;        /* time (in seconds) before autoniceval */
 extern int autoniceval;         /* proc priority after autonicetime */