The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/sparc64/sparc64/identcpu.c

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    1 /*-
    2  * Initial implementation:
    3  * Copyright (c) 2001 Robert Drehmel
    4  * All rights reserved.
    5  *
    6  * As long as the above copyright statement and this notice remain
    7  * unchanged, you can do what ever you want with this file.
    8  */
    9 
   10 #include <sys/cdefs.h>
   11 __FBSDID("$FreeBSD$");
   12 
   13 #include <sys/param.h>
   14 #include <sys/systm.h>
   15 #include <sys/kernel.h>
   16 #include <sys/sysctl.h>
   17 
   18 #include <machine/md_var.h>
   19 #include <machine/ver.h>
   20 
   21 char machine[] = MACHINE;
   22 SYSCTL_STRING(_hw, HW_MACHINE, machine, CTLFLAG_RD,
   23     machine, 0, "Machine class");
   24 
   25 static char cpu_model[128];
   26 SYSCTL_STRING(_hw, HW_MODEL, model, CTLFLAG_RD,
   27     cpu_model, 0, "Machine model");
   28 
   29 SYSCTL_NODE(_hw, OID_AUTO, freq, CTLFLAG_RD, 0, "");
   30 
   31 static u_int cpu_count;
   32 static u_int cpu_freq;
   33 SYSCTL_UINT(_hw_freq, OID_AUTO, cpu, CTLFLAG_RD, &cpu_freq, 0,
   34     "CPU clock frequency");
   35 
   36 void
   37 cpu_identify(u_long vers, u_int freq, u_int id)
   38 {
   39         const char *manus;
   40         const char *impls;
   41 
   42         switch (VER_MANUF(vers)) {
   43         case 0x04:
   44                 manus = "HAL/Fujitsu";
   45                 break;
   46         case 0x13:
   47         case 0x17:
   48         case 0x22:
   49         case 0x3e:
   50                 manus = "Sun Microsystems";
   51                 break;
   52         default:
   53                 manus = NULL;
   54                 break;
   55         }
   56         switch (VER_IMPL(vers)) {
   57         case CPU_IMPL_SPARC64:
   58                 impls = "SPARC64";
   59                 break;
   60         case CPU_IMPL_SPARC64II:
   61                 impls = "SPARC64-II";
   62                 break;
   63         case CPU_IMPL_SPARC64III:
   64                 impls = "SPARC64-III";
   65                 break;
   66         case CPU_IMPL_SPARC64IV:
   67                 impls = "SPARC64-IV";
   68                 break;
   69         case CPU_IMPL_SPARC64V:
   70                 impls = "SPARC64-V";
   71                 break;
   72         case CPU_IMPL_SPARC64VI:
   73                 impls = "SPARC64-VI";
   74                 break;
   75         case CPU_IMPL_SPARC64VII:
   76                 impls = "SPARC64-VII";
   77                 break;
   78         case CPU_IMPL_SPARC64VIIIfx:
   79                 impls = "SPARC64-VIIIfx";
   80                 break;
   81         case CPU_IMPL_ULTRASPARCI:
   82                 impls = "UltraSparc-I";
   83                 break;
   84         case CPU_IMPL_ULTRASPARCII:
   85                 impls = "UltraSparc-II";
   86                 break;
   87         case CPU_IMPL_ULTRASPARCIIi:
   88                 impls = "UltraSparc-IIi";
   89                 break;
   90         case CPU_IMPL_ULTRASPARCIIe:
   91                 impls = "UltraSparc-IIe";
   92                 break;
   93         case CPU_IMPL_ULTRASPARCIII:
   94                 impls = "UltraSparc-III";
   95                 break;
   96         case CPU_IMPL_ULTRASPARCIIIp:
   97                 impls = "UltraSparc-III+";
   98                 break;
   99         case CPU_IMPL_ULTRASPARCIIIi:
  100                 impls = "UltraSparc-IIIi";
  101                 break;
  102         case CPU_IMPL_ULTRASPARCIV:
  103                 impls = "UltraSparc-IV";
  104                 break;
  105         case CPU_IMPL_ULTRASPARCIVp:
  106                 impls = "UltraSparc-IV+";
  107                 break;
  108         case CPU_IMPL_ULTRASPARCIIIip:
  109                 impls = "UltraSparc-IIIi+";
  110                 break;
  111         default:
  112                 impls = NULL;
  113                 break;
  114         }
  115         if (manus == NULL || impls == NULL) {
  116                 printf(
  117                     "CPU: unknown; please e-mail the following value together\n"
  118                     "     with the exact name of your processor to "
  119                     "<freebsd-sparc64@FreeBSD.org>.\n"
  120                     "     version register: <0x%lx>\n", vers);
  121                 return;
  122         }
  123 
  124         snprintf(cpu_model, sizeof(cpu_model), "%s %s", manus, impls);
  125         printf("cpu%d: %s %s Processor (%d.%02d MHz CPU)\n", id, manus, impls,
  126             (freq + 4999) / 1000000, ((freq + 4999) / 10000) % 100);
  127         if (bootverbose) {
  128                 printf("  mask=0x%lx maxtl=%ld maxwin=%ld\n", VER_MASK(vers),
  129                     VER_MAXTL(vers), VER_MAXWIN(vers));
  130         }
  131 
  132         /*
  133          * Calculate the average CPU frequency.
  134          */
  135         freq = (freq + 500000ul) / 1000000ul;
  136         cpu_freq = (cpu_freq * cpu_count + freq) / (cpu_count + 1);
  137         cpu_count++;
  138 }

Cache object: 0c1d40a4cd7295e491a56f2bdf70bee8


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.