From owner-svn-src-all@FreeBSD.ORG Thu Sep 10 17:27:36 2009 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id EC8FD106568F; Thu, 10 Sep 2009 17:27:36 +0000 (UTC) (envelope-from jkim@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id D9F778FC1F; Thu, 10 Sep 2009 17:27:36 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n8AHRaJJ026110; Thu, 10 Sep 2009 17:27:36 GMT (envelope-from jkim@svn.freebsd.org) Received: (from jkim@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n8AHRa8L026099; Thu, 10 Sep 2009 17:27:36 GMT (envelope-from jkim@svn.freebsd.org) Message-Id: <200909101727.n8AHRa8L026099@svn.freebsd.org> From: Jung-uk Kim Date: Thu, 10 Sep 2009 17:27:36 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r197070 - in head/sys: amd64/amd64 amd64/include i386/cpufreq i386/i386 i386/include i386/xen X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 10 Sep 2009 17:27:37 -0000 Author: jkim Date: Thu Sep 10 17:27:36 2009 New Revision: 197070 URL: http://svn.freebsd.org/changeset/base/197070 Log: Consolidate CPUID to CPU family/model macros for amd64 and i386 to reduce unnecessary #ifdef's for shared code between them. Modified: head/sys/amd64/amd64/identcpu.c head/sys/amd64/amd64/initcpu.c head/sys/amd64/amd64/msi.c head/sys/amd64/include/specialreg.h head/sys/i386/cpufreq/hwpstate.c head/sys/i386/i386/identcpu.c head/sys/i386/i386/msi.c head/sys/i386/i386/pmap.c head/sys/i386/include/specialreg.h head/sys/i386/xen/pmap.c Modified: head/sys/amd64/amd64/identcpu.c ============================================================================== --- head/sys/amd64/amd64/identcpu.c Thu Sep 10 16:03:11 2009 (r197069) +++ head/sys/amd64/amd64/identcpu.c Thu Sep 10 17:27:36 2009 (r197070) @@ -371,21 +371,21 @@ printcpuinfo(void) switch (cpu_vendor_id) { case CPU_VENDOR_AMD: if ((amd_pminfo & AMDPM_TSC_INVARIANT) || - AMD64_CPU_FAMILY(cpu_id) >= 0x10 || + CPUID_TO_FAMILY(cpu_id) >= 0x10 || cpu_id == 0x60fb2) tsc_is_invariant = 1; break; case CPU_VENDOR_INTEL: if ((amd_pminfo & AMDPM_TSC_INVARIANT) || - (AMD64_CPU_FAMILY(cpu_id) == 0x6 && - AMD64_CPU_MODEL(cpu_id) >= 0xe) || - (AMD64_CPU_FAMILY(cpu_id) == 0xf && - AMD64_CPU_MODEL(cpu_id) >= 0x3)) + (CPUID_TO_FAMILY(cpu_id) == 0x6 && + CPUID_TO_MODEL(cpu_id) >= 0xe) || + (CPUID_TO_FAMILY(cpu_id) == 0xf && + CPUID_TO_MODEL(cpu_id) >= 0x3)) tsc_is_invariant = 1; break; case CPU_VENDOR_CENTAUR: - if (AMD64_CPU_FAMILY(cpu_id) == 0x6 && - AMD64_CPU_MODEL(cpu_id) >= 0xf && + if (CPUID_TO_FAMILY(cpu_id) == 0x6 && + CPUID_TO_MODEL(cpu_id) >= 0xf && (rdmsr(0x1203) & 0x100000000ULL) == 0) tsc_is_invariant = 1; break; Modified: head/sys/amd64/amd64/initcpu.c ============================================================================== --- head/sys/amd64/amd64/initcpu.c Thu Sep 10 16:03:11 2009 (r197069) +++ head/sys/amd64/amd64/initcpu.c Thu Sep 10 17:27:36 2009 (r197070) @@ -154,8 +154,8 @@ initializecpu(void) pg_nx = PG_NX; } if (cpu_vendor_id == CPU_VENDOR_CENTAUR && - AMD64_CPU_FAMILY(cpu_id) == 0x6 && - AMD64_CPU_MODEL(cpu_id) >= 0xf) + CPUID_TO_FAMILY(cpu_id) == 0x6 && + CPUID_TO_MODEL(cpu_id) >= 0xf) init_via(); /* Modified: head/sys/amd64/amd64/msi.c ============================================================================== --- head/sys/amd64/amd64/msi.c Thu Sep 10 16:03:11 2009 (r197069) +++ head/sys/amd64/amd64/msi.c Thu Sep 10 17:27:36 2009 (r197070) @@ -275,8 +275,8 @@ msi_init(void) case CPU_VENDOR_AMD: break; case CPU_VENDOR_CENTAUR: - if (AMD64_CPU_FAMILY(cpu_id) == 0x6 && - AMD64_CPU_MODEL(cpu_id) >= 0xf) + if (CPUID_TO_FAMILY(cpu_id) == 0x6 && + CPUID_TO_MODEL(cpu_id) >= 0xf) break; /* FALLTHROUGH */ default: Modified: head/sys/amd64/include/specialreg.h ============================================================================== --- head/sys/amd64/include/specialreg.h Thu Sep 10 16:03:11 2009 (r197069) +++ head/sys/amd64/include/specialreg.h Thu Sep 10 17:27:36 2009 (r197070) @@ -168,10 +168,10 @@ #define CPUID_FAMILY 0x00000f00 #define CPUID_EXT_MODEL 0x000f0000 #define CPUID_EXT_FAMILY 0x0ff00000 -#define AMD64_CPU_MODEL(id) \ +#define CPUID_TO_MODEL(id) \ ((((id) & CPUID_MODEL) >> 4) | \ (((id) & CPUID_EXT_MODEL) >> 12)) -#define AMD64_CPU_FAMILY(id) \ +#define CPUID_TO_FAMILY(id) \ ((((id) & CPUID_FAMILY) >> 8) + \ (((id) & CPUID_EXT_FAMILY) >> 20)) Modified: head/sys/i386/cpufreq/hwpstate.c ============================================================================== --- head/sys/i386/cpufreq/hwpstate.c Thu Sep 10 16:03:11 2009 (r197069) +++ head/sys/i386/cpufreq/hwpstate.c Thu Sep 10 17:27:36 2009 (r197070) @@ -83,12 +83,6 @@ __FBSDID("$FreeBSD$"); #define AMD_10H_11H_CUR_DID(msr) (((msr) >> 6) & 0x07) #define AMD_10H_11H_CUR_FID(msr) ((msr) & 0x3F) -#if defined(__amd64__) -#define CPU_FAMILY(id) AMD64_CPU_FAMILY(id) -#elif defined(__i386__) -#define CPU_FAMILY(id) I386_CPU_FAMILY(id) -#endif - #define HWPSTATE_DEBUG(dev, msg...) \ do{ \ if(hwpstate_verbose) \ @@ -302,7 +296,7 @@ hwpstate_identify(driver_t *driver, devi if (device_find_child(parent, "hwpstate", -1) != NULL) return; - if (cpu_vendor_id != CPU_VENDOR_AMD || CPU_FAMILY(cpu_id) < 0x10) + if (cpu_vendor_id != CPU_VENDOR_AMD || CPUID_TO_FAMILY(cpu_id) < 0x10) return; /* @@ -405,7 +399,7 @@ hwpstate_get_info_from_msr(device_t dev) uint64_t msr; int family, i, fid, did; - family = CPU_FAMILY(cpu_id); + family = CPUID_TO_FAMILY(cpu_id); sc = device_get_softc(dev); /* Get pstate count */ msr = rdmsr(MSR_AMD_10H_11H_LIMIT); Modified: head/sys/i386/i386/identcpu.c ============================================================================== --- head/sys/i386/i386/identcpu.c Thu Sep 10 16:03:11 2009 (r197069) +++ head/sys/i386/i386/identcpu.c Thu Sep 10 17:27:36 2009 (r197070) @@ -858,21 +858,21 @@ printcpuinfo(void) switch (cpu_vendor_id) { case CPU_VENDOR_AMD: if ((amd_pminfo & AMDPM_TSC_INVARIANT) || - I386_CPU_FAMILY(cpu_id) >= 0x10 || + CPUID_TO_FAMILY(cpu_id) >= 0x10 || cpu_id == 0x60fb2) tsc_is_invariant = 1; break; case CPU_VENDOR_INTEL: if ((amd_pminfo & AMDPM_TSC_INVARIANT) || - (I386_CPU_FAMILY(cpu_id) == 0x6 && - I386_CPU_MODEL(cpu_id) >= 0xe) || - (I386_CPU_FAMILY(cpu_id) == 0xf && - I386_CPU_MODEL(cpu_id) >= 0x3)) + (CPUID_TO_FAMILY(cpu_id) == 0x6 && + CPUID_TO_MODEL(cpu_id) >= 0xe) || + (CPUID_TO_FAMILY(cpu_id) == 0xf && + CPUID_TO_MODEL(cpu_id) >= 0x3)) tsc_is_invariant = 1; break; case CPU_VENDOR_CENTAUR: - if (I386_CPU_FAMILY(cpu_id) == 0x6 && - I386_CPU_MODEL(cpu_id) >= 0xf && + if (CPUID_TO_FAMILY(cpu_id) == 0x6 && + CPUID_TO_MODEL(cpu_id) >= 0xf && (rdmsr(0x1203) & 0x100000000ULL) == 0) tsc_is_invariant = 1; break; @@ -1106,8 +1106,8 @@ finishidentcpu(void) * XXX This is only done on the BSP package. */ if (cpu_vendor_id == CPU_VENDOR_INTEL && cpu_high > 0 && cpu_high < 4 && - ((I386_CPU_FAMILY(cpu_id) == 0xf && I386_CPU_MODEL(cpu_id) >= 0x3) || - (I386_CPU_FAMILY(cpu_id) == 0x6 && I386_CPU_MODEL(cpu_id) >= 0xe))) { + ((CPUID_TO_FAMILY(cpu_id) == 0xf && CPUID_TO_MODEL(cpu_id) >= 0x3) || + (CPUID_TO_FAMILY(cpu_id) == 0x6 && CPUID_TO_MODEL(cpu_id) >= 0xe))) { uint64_t msr; msr = rdmsr(MSR_IA32_MISC_ENABLE); if ((msr & 0x400000ULL) != 0) { Modified: head/sys/i386/i386/msi.c ============================================================================== --- head/sys/i386/i386/msi.c Thu Sep 10 16:03:11 2009 (r197069) +++ head/sys/i386/i386/msi.c Thu Sep 10 17:27:36 2009 (r197070) @@ -275,8 +275,8 @@ msi_init(void) case CPU_VENDOR_AMD: break; case CPU_VENDOR_CENTAUR: - if (I386_CPU_FAMILY(cpu_id) == 0x6 && - I386_CPU_MODEL(cpu_id) >= 0xf) + if (CPUID_TO_FAMILY(cpu_id) == 0x6 && + CPUID_TO_MODEL(cpu_id) >= 0xf) break; /* FALLTHROUGH */ default: Modified: head/sys/i386/i386/pmap.c ============================================================================== --- head/sys/i386/i386/pmap.c Thu Sep 10 16:03:11 2009 (r197069) +++ head/sys/i386/i386/pmap.c Thu Sep 10 17:27:36 2009 (r197070) @@ -501,8 +501,8 @@ pmap_init_pat(void) */ if (!pat_tested) { if (cpu_vendor_id != CPU_VENDOR_INTEL || - (I386_CPU_FAMILY(cpu_id) == 6 && - I386_CPU_MODEL(cpu_id) >= 0xe)) { + (CPUID_TO_FAMILY(cpu_id) == 6 && + CPUID_TO_MODEL(cpu_id) >= 0xe)) { pat_works = 1; sysenv = getenv("smbios.system.product"); if (sysenv != NULL) { Modified: head/sys/i386/include/specialreg.h ============================================================================== --- head/sys/i386/include/specialreg.h Thu Sep 10 16:03:11 2009 (r197069) +++ head/sys/i386/include/specialreg.h Thu Sep 10 17:27:36 2009 (r197070) @@ -165,11 +165,11 @@ #define CPUID_FAMILY 0x00000f00 #define CPUID_EXT_MODEL 0x000f0000 #define CPUID_EXT_FAMILY 0x0ff00000 -#define I386_CPU_MODEL(id) \ +#define CPUID_TO_MODEL(id) \ ((((id) & CPUID_MODEL) >> 4) | \ ((((id) & CPUID_FAMILY) >= 0x600) ? \ (((id) & CPUID_EXT_MODEL) >> 12) : 0)) -#define I386_CPU_FAMILY(id) \ +#define CPUID_TO_FAMILY(id) \ ((((id) & CPUID_FAMILY) >> 8) + \ ((((id) & CPUID_FAMILY) == 0xf00) ? \ (((id) & CPUID_EXT_FAMILY) >> 20) : 0)) Modified: head/sys/i386/xen/pmap.c ============================================================================== --- head/sys/i386/xen/pmap.c Thu Sep 10 16:03:11 2009 (r197069) +++ head/sys/i386/xen/pmap.c Thu Sep 10 17:27:36 2009 (r197070) @@ -517,7 +517,7 @@ pmap_init_pat(void) return; if (cpu_vendor_id != CPU_VENDOR_INTEL || - (I386_CPU_FAMILY(cpu_id) == 6 && I386_CPU_MODEL(cpu_id) >= 0xe)) { + (CPUID_TO_FAMILY(cpu_id) == 6 && CPUID_TO_MODEL(cpu_id) >= 0xe)) { /* * Leave the indices 0-3 at the default of WB, WT, UC, and UC-. * Program 4 and 5 as WP and WC.