Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 15 Sep 2016 17:05:54 +0000 (UTC)
From:      John Baldwin <jhb@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r305836 - in head/sys: amd64/amd64 amd64/include compat/linprocfs i386/include x86/include x86/x86
Message-ID:  <201609151705.u8FH5sKY073637@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: jhb
Date: Thu Sep 15 17:05:54 2016
New Revision: 305836
URL: https://svnweb.freebsd.org/changeset/base/305836

Log:
  Remove 'cpu' and 'cpu_class' on amd64.
  
  The 'cpu' and 'cpu_class' variables were always set to the same value
  on amd64 and are legacy holdovers from i386.  Remove them entirely on
  amd64.
  
  Reviewed by:	imp, kib (older version)
  Differential Revision:	https://reviews.freebsd.org/D7888

Modified:
  head/sys/amd64/amd64/machdep.c
  head/sys/amd64/include/cputypes.h
  head/sys/compat/linprocfs/linprocfs.c
  head/sys/i386/include/cputypes.h
  head/sys/i386/include/md_var.h
  head/sys/x86/include/cputypes.h
  head/sys/x86/include/x86_var.h
  head/sys/x86/x86/identcpu.c

Modified: head/sys/amd64/amd64/machdep.c
==============================================================================
--- head/sys/amd64/amd64/machdep.c	Thu Sep 15 15:32:40 2016	(r305835)
+++ head/sys/amd64/amd64/machdep.c	Thu Sep 15 17:05:54 2016	(r305836)
@@ -269,7 +269,6 @@ cpu_startup(dummy)
 	 */
 	startrtclock();
 	printcpuinfo();
-	panicifcpuunsupported();
 
 	/*
 	 * Display physical memory if SMBIOS reports reasonable amount.

Modified: head/sys/amd64/include/cputypes.h
==============================================================================
--- head/sys/amd64/include/cputypes.h	Thu Sep 15 15:32:40 2016	(r305835)
+++ head/sys/amd64/include/cputypes.h	Thu Sep 15 17:05:54 2016	(r305836)
@@ -1,48 +1,6 @@
 /*-
- * Copyright (c) 1993 Christopher G. Demetriou
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- *    derived from this software without specific prior written permission
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * $FreeBSD$
+ * This file is in the public domain.
  */
-
-#ifndef _MACHINE_CPUTYPES_H_
-#define	_MACHINE_CPUTYPES_H_
+/* $FreeBSD$ */
 
 #include <x86/cputypes.h>
-
-/*
- * Classes of processor.
- */
-#define	CPUCLASS_X86		0	/* X86 */
-#define	CPUCLASS_K8		1	/* K8 AMD64 class */
-
-/*
- * Kinds of processor.
- */
-#define	CPU_X86			0	/* Intel */
-#define	CPU_CLAWHAMMER		1	/* AMD Clawhammer */
-#define	CPU_SLEDGEHAMMER	2	/* AMD Sledgehammer */
-
-#endif /* !_MACHINE_CPUTYPES_H_ */

Modified: head/sys/compat/linprocfs/linprocfs.c
==============================================================================
--- head/sys/compat/linprocfs/linprocfs.c	Thu Sep 15 15:32:40 2016	(r305835)
+++ head/sys/compat/linprocfs/linprocfs.c	Thu Sep 15 17:05:54 2016	(r305836)
@@ -218,7 +218,7 @@ linprocfs_docpuinfo(PFS_FILL_ARGS)
 	char model[128];
 	uint64_t freq;
 	size_t size;
-	int class, fqmhz, fqkhz;
+	int fqmhz, fqkhz;
 	int i;
 
 	/*
@@ -235,33 +235,6 @@ linprocfs_docpuinfo(PFS_FILL_ARGS)
 		"3dnowext", "3dnow"
 	};
 
-	switch (cpu_class) {
-#ifdef __i386__
-	case CPUCLASS_286:
-		class = 2;
-		break;
-	case CPUCLASS_386:
-		class = 3;
-		break;
-	case CPUCLASS_486:
-		class = 4;
-		break;
-	case CPUCLASS_586:
-		class = 5;
-		break;
-	case CPUCLASS_686:
-		class = 6;
-		break;
-	default:
-		class = 0;
-		break;
-#else /* __amd64__ */
-	default:
-		class = 15;
-		break;
-#endif
-	}
-
 	hw_model[0] = CTL_HW;
 	hw_model[1] = HW_MODEL;
 	model[0] = '\0';
@@ -286,7 +259,7 @@ linprocfs_docpuinfo(PFS_FILL_ARGS)
 #ifdef __i386__
 	switch (cpu_vendor_id) {
 	case CPU_VENDOR_AMD:
-		if (class < 6)
+		if (cpu_class < CPUCLASS_686)
 			flags[16] = "fcmov";
 		break;
 	case CPU_VENDOR_CYRIX:

Modified: head/sys/i386/include/cputypes.h
==============================================================================
--- head/sys/i386/include/cputypes.h	Thu Sep 15 15:32:40 2016	(r305835)
+++ head/sys/i386/include/cputypes.h	Thu Sep 15 17:05:54 2016	(r305836)
@@ -63,4 +63,9 @@
 #define	CPU_P4			16	/* Intel Pentium 4 */
 #define	CPU_GEODE1100		17	/* NS Geode SC1100 */
 
+#ifndef LOCORE
+extern int	cpu;
+extern int	cpu_class;
+#endif
+
 #endif /* !_MACHINE_CPUTYPES_H_ */

Modified: head/sys/i386/include/md_var.h
==============================================================================
--- head/sys/i386/include/md_var.h	Thu Sep 15 15:32:40 2016	(r305835)
+++ head/sys/i386/include/md_var.h	Thu Sep 15 17:05:54 2016	(r305836)
@@ -65,6 +65,7 @@ void	i686_pagezero(void *addr);
 void	sse2_pagezero(void *addr);
 void	init_AMD_Elan_sc520(void);
 vm_paddr_t kvtop(void *addr);
+void	panicifcpuunsupported(void);
 void	ppro_reenable_apic(void);
 void	setidt(int idx, alias_for_inthand_t *func, int typ, int dpl, int selec);
 union savefpu *get_pcb_user_save_td(struct thread *td);

Modified: head/sys/x86/include/cputypes.h
==============================================================================
--- head/sys/x86/include/cputypes.h	Thu Sep 15 15:32:40 2016	(r305835)
+++ head/sys/x86/include/cputypes.h	Thu Sep 15 17:05:54 2016	(r305836)
@@ -46,9 +46,4 @@
 #define	CPU_VENDOR_RISE		0xdead2bad	/* Rise */
 #define	CPU_VENDOR_CENTAUR	CPU_VENDOR_IDT
 
-#ifndef LOCORE
-extern int	cpu;
-extern int	cpu_class;
-#endif
-
 #endif /* !_X86_CPUTYPES_H_ */

Modified: head/sys/x86/include/x86_var.h
==============================================================================
--- head/sys/x86/include/x86_var.h	Thu Sep 15 15:32:40 2016	(r305835)
+++ head/sys/x86/include/x86_var.h	Thu Sep 15 17:05:54 2016	(r305836)
@@ -107,7 +107,6 @@ bool	fix_cpuid(void);
 void	fillw(int /*u_short*/ pat, void *base, size_t cnt);
 int	is_physical_memory(vm_paddr_t addr);
 int	isa_nmi(int cd);
-void	panicifcpuunsupported(void);
 void	pagecopy(void *from, void *to);
 void	printcpuinfo(void);
 int	user_dbreg_trap(void);

Modified: head/sys/x86/x86/identcpu.c
==============================================================================
--- head/sys/x86/x86/identcpu.c	Thu Sep 15 15:32:40 2016	(r305835)
+++ head/sys/x86/x86/identcpu.c	Thu Sep 15 17:05:54 2016	(r305836)
@@ -87,8 +87,10 @@ static void print_svm_info(void);
 static void print_via_padlock_info(void);
 static void print_vmx_info(void);
 
+#ifdef __i386__
 int	cpu;			/* Are we 386, 386sx, 486, etc? */
 int	cpu_class;
+#endif
 u_int	cpu_feature;		/* Feature flags */
 u_int	cpu_feature2;		/* Feature flags */
 u_int	amd_feature;		/* AMD feature flags */
@@ -184,13 +186,11 @@ static const char *cpu_brandtable[MAX_BR
 	NULL,
 	"Intel Pentium 4"
 };
-#endif
 
 static struct {
 	char	*cpu_name;
 	int	cpu_class;
 } cpus[] = {
-#ifdef __i386__
 	{ "Intel 80286",	CPUCLASS_286 },		/* CPU_286   */
 	{ "i386SX",		CPUCLASS_386 },		/* CPU_386SX */
 	{ "i386DX",		CPUCLASS_386 },		/* CPU_386   */
@@ -208,11 +208,8 @@ static struct {
 	{ "Pentium II",		CPUCLASS_686 },		/* CPU_PII */
 	{ "Pentium III",	CPUCLASS_686 },		/* CPU_PIII */
 	{ "Pentium 4",		CPUCLASS_686 },		/* CPU_P4 */
-#else
-	{ "Clawhammer",		CPUCLASS_K8 },		/* CPU_CLAWHAMMER */
-	{ "Sledgehammer",	CPUCLASS_K8 },		/* CPU_SLEDGEHAMMER */
-#endif
 };
+#endif
 
 static struct {
 	char	*vendor;
@@ -242,9 +239,13 @@ printcpuinfo(void)
 	u_int regs[4], i;
 	char *brand;
 
-	cpu_class = cpus[cpu].cpu_class;
 	printf("CPU: ");
+#ifdef __i386__
+	cpu_class = cpus[cpu].cpu_class;
 	strncpy(cpu_model, cpus[cpu].cpu_name, sizeof (cpu_model));
+#else
+	strncpy(cpu_model, "Hammer", sizeof (cpu_model));
+#endif
 
 	/* Check for extended CPUID information and a processor name. */
 	if (cpu_exthigh >= 0x80000004) {
@@ -697,8 +698,8 @@ printcpuinfo(void)
 		    (intmax_t)(tsc_freq + 4999) / 1000000,
 		    (u_int)((tsc_freq + 4999) / 10000) % 100);
 	}
-	switch(cpu_class) {
 #ifdef __i386__
+	switch(cpu_class) {
 	case CPUCLASS_286:
 		printf("286");
 		break;
@@ -720,14 +721,12 @@ printcpuinfo(void)
 		printf("686");
 		break;
 #endif
-#else
-	case CPUCLASS_K8:
-		printf("K8");
-		break;
-#endif
 	default:
 		printf("Unknown");	/* will panic below... */
 	}
+#else
+	printf("K8");
+#endif
 	printf("-class CPU)\n");
 	if (*cpu_vendor)
 		printf("  Origin=\"%s\"", cpu_vendor);
@@ -1051,28 +1050,22 @@ printcpuinfo(void)
 	print_hypervisor_info();
 }
 
+#ifdef __i386__
 void
 panicifcpuunsupported(void)
 {
 
-#ifdef __i386__
 #if !defined(lint)
 #if !defined(I486_CPU) && !defined(I586_CPU) && !defined(I686_CPU)
 #error This kernel is not configured for one of the supported CPUs
 #endif
 #else /* lint */
 #endif /* lint */
-#else /* __amd64__ */
-#ifndef HAMMER
-#error "You need to specify a cpu type"
-#endif
-#endif
 	/*
 	 * Now that we have told the user what they have,
 	 * let them know if that machine type isn't configured.
 	 */
 	switch (cpu_class) {
-#ifdef __i386__
 	case CPUCLASS_286:	/* a 286 should not make it this far, anyway */
 	case CPUCLASS_386:
 #if !defined(I486_CPU)
@@ -1084,19 +1077,12 @@ panicifcpuunsupported(void)
 #if !defined(I686_CPU)
 	case CPUCLASS_686:
 #endif
-#else /* __amd64__ */
-	case CPUCLASS_X86:
-#ifndef HAMMER
-	case CPUCLASS_K8:
-#endif
-#endif
 		panic("CPU class not configured");
 	default:
 		break;
 	}
 }
 
-#ifdef __i386__
 static	volatile u_int trap_by_rdmsr;
 
 /*
@@ -1580,9 +1566,6 @@ identify_cpu(void)
 			return;
 		}
 	}
-#else
-	/* XXX */
-	cpu = CPU_CLAWHAMMER;
 #endif
 }
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201609151705.u8FH5sKY073637>