Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/ia64/ia64 Move identifycpu() into cpu.c. Our cpu* ...



details:   https://anonhg.NetBSD.org/src/rev/1fecca11af7e
branches:  trunk
changeset: 755915:1fecca11af7e
user:      kiyohara <kiyohara%NetBSD.org@localhost>
date:      Mon Jun 28 12:08:13 2010 +0000

description:
Move identifycpu() into cpu.c.  Our cpu* says:
  cpu0 at mainbus0: ProcessorID 0, Id 0, Eid 0
  cpu0: McKinley (1000.00-MHz Itanium 2)
  cpu0: Origin "GenuineIntel",  Revision 7
  cpu0: Features 0x1

diffstat:

 sys/arch/ia64/ia64/cpu.c     |  90 +++++++++++++++++++++++++++++++++++++++++--
 sys/arch/ia64/ia64/machdep.c |  84 +----------------------------------------
 2 files changed, 87 insertions(+), 87 deletions(-)

diffs (237 lines):

diff -r 829044daff09 -r 1fecca11af7e sys/arch/ia64/ia64/cpu.c
--- a/sys/arch/ia64/ia64/cpu.c  Mon Jun 28 11:18:44 2010 +0000
+++ b/sys/arch/ia64/ia64/cpu.c  Mon Jun 28 12:08:13 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: cpu.c,v 1.8 2010/05/17 11:46:19 kiyohara Exp $ */
+/*     $NetBSD: cpu.c,v 1.9 2010/06/28 12:08:13 kiyohara Exp $ */
 
 /*
  * Copyright (c) 2006 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.8 2010/05/17 11:46:19 kiyohara Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.9 2010/06/28 12:08:13 kiyohara Exp $");
 
 #include <sys/param.h>
 #include <sys/proc.h>
@@ -41,17 +41,23 @@
 #include <dev/acpi/acpica.h>
 #include <dev/acpi/acpivar.h>
 
+#define MHz    1000000L
+#define GHz    (1000L * MHz)
 
 struct cpu_info cpu_info_primary __aligned(CACHE_LINE_SIZE);
 
-static int cpu_match(device_t, cfdata_t, void *);
-static void cpu_attach(device_t, device_t, void *);
-
 struct cpu_softc {
        device_t sc_dev;                /* device tree glue */
        struct cpu_info *sc_info;       /* pointer to CPU info */
 };
 
+char cpu_model[64];
+
+static int cpu_match(device_t, cfdata_t, void *);
+static void cpu_attach(device_t, device_t, void *);
+
+static void identifycpu(struct cpu_softc *);
+
 CFATTACH_DECL_NEW(cpu, sizeof(struct cpu_softc),
     cpu_match, cpu_attach, NULL, NULL);
 
@@ -98,5 +104,79 @@
        ci->ci_intrdepth = -1;                  /* need ? */
        ci->ci_dev = self;
 
+       identifycpu(sc);
+
        return;
 }
+
+
+static void
+identifycpu(struct cpu_softc *sc)
+{
+       uint64_t vendor[3];
+       const char *family_name, *model_name;
+       uint64_t features, tmp;
+       int number, revision, model, family, archrev;
+       extern uint64_t processor_frequency;
+
+       /*
+        * Assumes little-endian.
+        */
+       vendor[0] = ia64_get_cpuid(0);
+       vendor[1] = ia64_get_cpuid(1);
+       vendor[2] = '\0';
+
+       tmp = ia64_get_cpuid(3);
+       number = (tmp >> 0) & 0xff;
+       revision = (tmp >> 8) & 0xff;
+       model = (tmp >> 16) & 0xff;
+       family = (tmp >> 24) & 0xff;
+       archrev = (tmp >> 32) & 0xff;
+
+       family_name = model_name = "unknown";
+       switch (family) {
+       case 0x07:
+               family_name = "Itanium";
+               model_name = "Merced";
+               break;
+       case 0x1f:
+               family_name = "Itanium 2";
+               switch (model) {
+               case 0x00:
+                       model_name = "McKinley";
+                       break;
+               case 0x01:
+                       /*
+                        * Deerfield is a low-voltage variant based on the
+                        * Madison core. We need circumstantial evidence
+                        * (i.e. the clock frequency) to identify those.
+                        * Allow for roughly 1% error margin.
+                        */
+                       tmp = processor_frequency >> 7;
+                       if ((processor_frequency - tmp) < 1*GHz &&
+                           (processor_frequency + tmp) >= 1*GHz)
+                               model_name = "Deerfield";
+                       else
+                               model_name = "Madison";
+                       break;
+               case 0x02:
+                       model_name = "Madison II";
+                       break;
+               }
+               break;
+       }
+       snprintf(cpu_model, sizeof(cpu_model), "%s", model_name);
+
+       features = ia64_get_cpuid(4);
+
+       aprint_normal_dev(sc->sc_dev, "%s (", model_name);
+       if (processor_frequency) {
+               aprint_normal("%ld.%02ld-MHz ",
+                   (processor_frequency + 4999) / MHz,
+                   ((processor_frequency + 4999) / (MHz/100)) % 100);
+       }
+       aprint_normal("%s)\n", family_name);
+       aprint_normal_dev(sc->sc_dev, "Origin \"%s\",  Revision %d\n",
+           (char *)vendor, revision);
+       aprint_normal_dev(sc->sc_dev, "Features 0x%x\n", (uint32_t)features);
+}
diff -r 829044daff09 -r 1fecca11af7e sys/arch/ia64/ia64/machdep.c
--- a/sys/arch/ia64/ia64/machdep.c      Mon Jun 28 11:18:44 2010 +0000
+++ b/sys/arch/ia64/ia64/machdep.c      Mon Jun 28 12:08:13 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: machdep.c,v 1.23 2010/02/08 19:02:29 joerg Exp $       */
+/*     $NetBSD: machdep.c,v 1.24 2010/06/28 12:08:13 kiyohara Exp $    */
 
 /*-
  * Copyright (c) 2003,2004 Marcel Moolenaar
@@ -133,10 +133,7 @@
 struct vm_map *phys_map = NULL;
 
 void *msgbufaddr;
-int    physmem;
-
-char   cpu_model[64];
-char   cpu_family[64];
+int physmem;
 
 vaddr_t kernstart, kernend;
 
@@ -159,78 +156,6 @@
 
 struct fpswa_iface *fpswa_iface;
 
-#define Mhz     1000000L
-#define Ghz     (1000L*Mhz)
-
-static void
-identifycpu(void)
-{
-       uint64_t vendor[3];
-       const char *family_name, *model_name;
-       uint64_t features, tmp;
-       int number, revision, model, family, archrev;
-
-       /*
-        * Assumes little-endian.
-        */
-       vendor[0] = ia64_get_cpuid(0);
-       vendor[1] = ia64_get_cpuid(1);
-       vendor[2] = '\0';
-
-       tmp = ia64_get_cpuid(3);
-       number = (tmp >> 0) & 0xff;
-       revision = (tmp >> 8) & 0xff;
-       model = (tmp >> 16) & 0xff;
-       family = (tmp >> 24) & 0xff;
-       archrev = (tmp >> 32) & 0xff;
-
-       family_name = model_name = "unknown";
-       switch (family) {
-       case 0x07:
-               family_name = "Itanium";
-               model_name = "Merced";
-               break;
-       case 0x1f:
-               family_name = "Itanium 2";
-               switch (model) {
-               case 0x00:
-                       model_name = "McKinley";
-                       break;
-               case 0x01:
-                       /*
-                        * Deerfield is a low-voltage variant based on the
-                        * Madison core. We need circumstantial evidence
-                        * (i.e. the clock frequency) to identify those.
-                        * Allow for roughly 1% error margin.
-                        */
-                       tmp = processor_frequency >> 7;
-                       if ((processor_frequency - tmp) < 1*Ghz &&
-                           (processor_frequency + tmp) >= 1*Ghz)
-                               model_name = "Deerfield";
-                       else
-                               model_name = "Madison";
-                       break;
-               case 0x02:
-                       model_name = "Madison II";
-                       break;
-               }
-               break;
-       }
-       snprintf(cpu_family, sizeof(cpu_family), "%s", family_name);
-       snprintf(cpu_model, sizeof(cpu_model), "%s", model_name);
-
-       features = ia64_get_cpuid(4);
-
-       printf("CPU: %s (", model_name);
-       if (processor_frequency) {
-               printf("%ld.%02ld-MHz ", (processor_frequency + 4999) / Mhz,
-                   ((processor_frequency + 4999) / (Mhz/100)) % 100);
-       }
-       printf("%s)\n", family_name);
-       printf("  Origin = \"%s\"  Revision = %d\n", (char *) vendor, revision);
-       printf("  Features = 0x%x\n", (uint32_t) features);
-
-}
 
 /*
  * Machine-dependent startup code
@@ -240,11 +165,6 @@
 {
        vaddr_t minaddr, maxaddr;
 
-       /*
-        * Good {morning,afternoon,evening,night}.
-        */
-       identifycpu();
-
        /* XXX: startrtclock(); */
 #ifdef PERFMON
        perfmon_init();



Home | Main Index | Thread Index | Old Index