identcpu.c revision 112398
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 * $FreeBSD: head/sys/sparc64/sparc64/identcpu.c 112398 2003-03-19 05:51:21Z jake $
10 */
11#include <sys/param.h>
12#include <sys/systm.h>
13#include <sys/kernel.h>
14#include <sys/sysctl.h>
15
16#include <machine/cpufunc.h>
17#include <machine/md_var.h>
18#include <machine/ver.h>
19
20char machine[] = "sparc64";
21SYSCTL_STRING(_hw, HW_MACHINE, machine, CTLFLAG_RD,
22    machine, 0, "Machine class");
23
24static char cpu_model[128];
25SYSCTL_STRING(_hw, HW_MODEL, model, CTLFLAG_RD,
26    cpu_model, 0, "Machine model");
27
28int cpu_impl;
29
30void
31cpu_identify(u_long vers, u_int freq, u_int id)
32{
33	const char *manus;
34	const char *impls;
35
36	switch (VER_MANUF(vers)) {
37	case 0x04:
38		manus = "HAL";
39		break;
40	case 0x13:
41	case 0x17:
42	case 0x22:
43	case 0x3e:
44		manus = "Sun Microsystems";
45		break;
46	default:
47		manus = NULL;
48		break;
49	}
50	switch (VER_IMPL(vers)) {
51	case CPU_IMPL_SPARC64:
52		impls = "SPARC64";
53		break;
54	case CPU_IMPL_ULTRASPARCI:
55		impls = "UltraSparc-I";
56		break;
57	case CPU_IMPL_ULTRASPARCII:
58		impls = "UltraSparc-II";
59		break;
60	case CPU_IMPL_ULTRASPARCIIi:
61		impls = "UltraSparc-IIi";
62		break;
63	case CPU_IMPL_ULTRASPARCIIe:
64		/* V9 Manual says `UltraSparc-e'.  I assume this is wrong. */
65		impls = "UltraSparc-IIe";
66		break;
67	case CPU_IMPL_ULTRASPARCIII:
68		impls = "UltraSparc-III";
69		break;
70	case CPU_IMPL_ULTRASPARCIIIp:
71		impls = "UltraSparc-III+";
72		break;
73	default:
74		impls = NULL;
75		break;
76	}
77	if (manus == NULL || impls == NULL) {
78		printf(
79		    "CPU: unknown; please e-mail the following value together\n"
80		    "     with the exact name of your processor to "
81		    "<freebsd-sparc@FreeBSD.org>.\n"
82		    "     version register: <0x%lx>\n", vers);
83		return;
84	}
85
86	snprintf(cpu_model, sizeof(cpu_model), "%s %s", manus, impls);
87	printf("cpu%d: %s %s Processor (%d.%02d MHz CPU)\n", id, manus, impls,
88	    (freq + 4999) / 1000000, ((freq + 4999) / 10000) % 100);
89	if (bootverbose) {
90		printf("  mask=0x%lx maxtl=%ld maxwin=%ld\n", VER_MASK(vers),
91		    VER_MAXTL(vers), VER_MAXWIN(vers));
92	}
93}
94