Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.sbin/cpuctl/arch No functional change:



details:   https://anonhg.NetBSD.org/src/rev/e5b69f2da497
branches:  trunk
changeset: 790790:e5b69f2da497
user:      msaitoh <msaitoh%NetBSD.org@localhost>
date:      Mon Oct 21 06:28:15 2013 +0000

description:
No functional change:
- Add prototypes.
- Make some function static.
- Sort functions.

diffstat:

 usr.sbin/cpuctl/arch/i386.c |  1052 +++++++++++++++++++++---------------------
 1 files changed, 532 insertions(+), 520 deletions(-)

diffs (truncated from 1129 to 300 lines):

diff -r 280a70ed69b4 -r e5b69f2da497 usr.sbin/cpuctl/arch/i386.c
--- a/usr.sbin/cpuctl/arch/i386.c       Mon Oct 21 06:11:49 2013 +0000
+++ b/usr.sbin/cpuctl/arch/i386.c       Mon Oct 21 06:28:15 2013 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: i386.c,v 1.43 2013/10/04 17:12:48 msaitoh Exp $        */
+/*     $NetBSD: i386.c,v 1.44 2013/10/21 06:28:15 msaitoh Exp $        */
 
 /*-
  * Copyright (c) 1999, 2000, 2001, 2006, 2007, 2008 The NetBSD Foundation, Inc.
@@ -57,7 +57,7 @@
 
 #include <sys/cdefs.h>
 #ifndef lint
-__RCSID("$NetBSD: i386.c,v 1.43 2013/10/04 17:12:48 msaitoh Exp $");
+__RCSID("$NetBSD: i386.c,v 1.44 2013/10/21 06:28:15 msaitoh Exp $");
 #endif /* not lint */
 
 #include <sys/types.h>
@@ -198,26 +198,38 @@
 static char amd_brand_name[48];
 static int use_pae, largepagesize;
 
-static void via_cpu_probe(struct cpu_info *);
-static void amd_family6_probe(struct cpu_info *);
-static void intel_family_new_probe(struct cpu_info *);
+/* Setup functions */
+static void    disable_tsc(struct cpu_info *);
+static void    amd_family5_setup(struct cpu_info *); /* alike cpu_probe_k5 */
+static void    cyrix6x86_cpu_setup(struct cpu_info *);
+static void    winchip_cpu_setup(struct cpu_info *);
+/* Brand/Model name functions */
 static const char *intel_family6_name(struct cpu_info *);
 static const char *amd_amd64_name(struct cpu_info *);
-static void amd_family5_setup(struct cpu_info *);
-static void transmeta_cpu_info(struct cpu_info *);
+/* Probe functions */
+static void    amd_family6_probe(struct cpu_info *);
+static void    powernow_probe(struct cpu_info *);
+static void    intel_family_new_probe(struct cpu_info *);
+static void    via_cpu_probe(struct cpu_info *);
+/* (Cache) Info functions */
+static void    amd_cpu_cacheinfo(struct cpu_info *); /* alike */
+static void    via_cpu_cacheinfo(struct cpu_info *);
+static void    tmx86_get_longrun_status(u_int *, u_int *, u_int *);
+static void    transmeta_cpu_info(struct cpu_info *);
+/* Common functions */
+static void    cpu_probe_base_features(struct cpu_info *, const char *);
+       /* alike cpu_probe() */
+static void    cpu_probe_features(struct cpu_info *);
+static void    print_bits(const char *, const char *, const char *, uint32_t);
+/* XXX identifycpu alike cpu_identify */
+static void    identifycpu_cpuids(struct cpu_info *);
 static const char *print_cache_config(struct cpu_info *, int, const char *,
     const char *);
 static const char *print_tlb_config(struct cpu_info *, int, const char *,
     const char *);
-static void    amd_cpu_cacheinfo(struct cpu_info *);
-static void    via_cpu_cacheinfo(struct cpu_info *);
-static void    x86_print_cacheinfo(struct cpu_info *);
-static const struct x86_cache_info *cache_info_lookup(
+static const struct x86_cache_info *cache_info_lookup( /* XXX same */
     const struct x86_cache_info *, uint8_t);
-static void cyrix6x86_cpu_setup(struct cpu_info *);
-static void winchip_cpu_setup(struct cpu_info *);
-static void amd_family5_setup(struct cpu_info *);
-static void powernow_probe(struct cpu_info *);
+static void    x86_print_cacheinfo(struct cpu_info *);
 
 /*
  * Note: these are just the ones that may not have a cpuid instruction.
@@ -660,6 +672,29 @@
 }
 
 static void
+amd_family5_setup(struct cpu_info *ci)
+{
+
+       switch (ci->ci_model) {
+       case 0:         /* AMD-K5 Model 0 */
+               /*
+                * According to the AMD Processor Recognition App Note,
+                * the AMD-K5 Model 0 uses the wrong bit to indicate
+                * support for global PTEs, instead using bit 9 (APIC)
+                * rather than bit 13 (i.e. "0x200" vs. 0x2000".  Oops!).
+                */
+               if (ci->ci_feat_val[0] & CPUID_APIC)
+                       ci->ci_feat_val[0] =
+                           (ci->ci_feat_val[0] & ~CPUID_APIC) | CPUID_PGE;
+               /*
+                * XXX But pmap_pg_g is already initialized -- need to kick
+                * XXX the pmap somehow.  How does the MP branch do this?
+                */
+               break;
+       }
+}
+
+static void
 cyrix6x86_cpu_setup(struct cpu_info *ci)
 {
 
@@ -671,7 +706,7 @@
                disable_tsc(ci);
 }
 
-void
+static void
 winchip_cpu_setup(struct cpu_info *ci)
 {
        switch (ci->ci_model) {
@@ -681,98 +716,6 @@
 }
 
 
-static void
-identifycpu_cpuids(struct cpu_info *ci)
-{
-       const char *cpuname = ci->ci_dev;
-       u_int lp_max = 1;       /* logical processors per package */
-       u_int smt_max;          /* smt per core */
-       u_int core_max = 1;     /* core per package */
-       u_int smt_bits, core_bits;
-       uint32_t descs[4];
-       uint32_t highest_basic_info;
-
-       aprint_verbose("%s: Initial APIC ID %u\n", cpuname, ci->ci_initapicid);
-       ci->ci_packageid = ci->ci_initapicid;
-       ci->ci_coreid = 0;
-       ci->ci_smtid = 0;
-       if (cpu_vendor != CPUVENDOR_INTEL) {
-               return;
-       }
-
-       /*
-        * 253668.pdf 7.10.2
-        */
-
-       if ((ci->ci_feat_val[0] & CPUID_HTT) != 0) {
-               x86_cpuid(1, descs);
-               lp_max = (descs[1] >> 16) & 0xff;
-       }
-       x86_cpuid(0, descs);
-       highest_basic_info = descs[0];
-       if (highest_basic_info >= 4) {
-               x86_cpuid2(4, 0, descs);
-               core_max = (descs[0] >> 26) + 1;
-       }
-       assert(lp_max >= core_max);
-       smt_max = lp_max / core_max;
-       smt_bits = ilog2(smt_max - 1) + 1;
-       core_bits = ilog2(core_max - 1) + 1;
-       if (smt_bits + core_bits) {
-               ci->ci_packageid = ci->ci_initapicid >> (smt_bits + core_bits);
-       }
-       aprint_verbose("%s: Cluster/Package ID %u\n", cpuname,
-           ci->ci_packageid);
-       if (core_bits) {
-               u_int core_mask = __BITS(smt_bits, smt_bits + core_bits - 1);
-
-               ci->ci_coreid =
-                   __SHIFTOUT(ci->ci_initapicid, core_mask);
-               aprint_verbose("%s: Core ID %u\n", cpuname, ci->ci_coreid);
-       }
-       if (smt_bits) {
-               u_int smt_mask = __BITS((int)0, (int)(smt_bits - 1));
-
-               ci->ci_smtid = __SHIFTOUT(ci->ci_initapicid, smt_mask);
-               aprint_verbose("%s: SMT ID %u\n", cpuname, ci->ci_smtid);
-       }
-}
-
-static void
-via_cpu_probe(struct cpu_info *ci)
-{
-       u_int stepping = CPUID2STEPPING(ci->ci_signature);
-       u_int descs[4];
-       u_int lfunc;
-
-       /*
-        * Determine the largest extended function value.
-        */
-       x86_cpuid(0x80000000, descs);
-       lfunc = descs[0];
-
-       /*
-        * Determine the extended feature flags.
-        */
-       if (lfunc >= 0x80000001) {
-               x86_cpuid(0x80000001, descs);
-               ci->ci_feat_val[2] |= descs[3];
-       }
-
-       if (ci->ci_model < 0x9 || (ci->ci_model == 0x9 && stepping < 3))
-               return;
-
-       /* Nehemiah or Esther */
-       x86_cpuid(0xc0000000, descs);
-       lfunc = descs[0];
-       if (lfunc < 0xc0000001) /* no ACE, no RNG */
-               return;
-
-       x86_cpuid(0xc0000001, descs);
-       lfunc = descs[3];
-       ci->ci_feat_val[4] = lfunc;
-}
-
 static const char *
 intel_family6_name(struct cpu_info *ci)
 {
@@ -934,6 +877,430 @@
 }
 
 static void
+intel_family_new_probe(struct cpu_info *ci)
+{
+       uint32_t descs[4];
+
+       x86_cpuid(0x80000000, descs);
+
+       /*
+        * Determine extended feature flags.
+        */
+       if (descs[0] >= 0x80000001) {
+               x86_cpuid(0x80000001, descs);
+               ci->ci_feat_val[2] |= descs[3];
+               ci->ci_feat_val[3] |= descs[2];
+       }
+}
+
+static void
+via_cpu_probe(struct cpu_info *ci)
+{
+       u_int stepping = CPUID2STEPPING(ci->ci_signature);
+       u_int descs[4];
+       u_int lfunc;
+
+       /*
+        * Determine the largest extended function value.
+        */
+       x86_cpuid(0x80000000, descs);
+       lfunc = descs[0];
+
+       /*
+        * Determine the extended feature flags.
+        */
+       if (lfunc >= 0x80000001) {
+               x86_cpuid(0x80000001, descs);
+               ci->ci_feat_val[2] |= descs[3];
+       }
+
+       if (ci->ci_model < 0x9 || (ci->ci_model == 0x9 && stepping < 3))
+               return;
+
+       /* Nehemiah or Esther */
+       x86_cpuid(0xc0000000, descs);
+       lfunc = descs[0];
+       if (lfunc < 0xc0000001) /* no ACE, no RNG */
+               return;
+
+       x86_cpuid(0xc0000001, descs);
+       lfunc = descs[3];
+       ci->ci_feat_val[4] = lfunc;
+}
+
+static void
+amd_family6_probe(struct cpu_info *ci)
+{
+       uint32_t descs[4];
+       char *p;
+       size_t i;
+
+       x86_cpuid(0x80000000, descs);
+
+       /*
+        * Determine the extended feature flags.
+        */
+       if (descs[0] >= 0x80000001) {
+               x86_cpuid(0x80000001, descs);
+               ci->ci_feat_val[2] |= descs[3]; /* %edx */
+               ci->ci_feat_val[3] = descs[2]; /* %ecx */
+       }
+
+       if (*cpu_brand_string == '\0')
+               return;
+       
+       for (i = 1; i < __arraycount(amd_brand); i++)
+               if ((p = strstr(cpu_brand_string, amd_brand[i])) != NULL) {
+                       ci->ci_brand_id = i;
+                       strlcpy(amd_brand_name, p, sizeof(amd_brand_name));
+                       break;
+               }
+}
+
+static const struct x86_cache_info amd_cpuid_l2cache_assoc_info[] = 
+    AMD_L2CACHE_INFO;
+
+static const struct x86_cache_info amd_cpuid_l3cache_assoc_info[] = 
+    AMD_L3CACHE_INFO;
+
+static void
+amd_cpu_cacheinfo(struct cpu_info *ci)



Home | Main Index | Thread Index | Old Index