4 * This code sets the Processor Name String for AMD64 CPUs.
6 * Written by Stefan Reinauer <stepan@coresystems.de> using
7 * the Revision Guide for AMD Athlon™ 64 and AMD Opteron™ Processors
8 * Document ID 25759 Rev 3.59, April 2006 (Public Version)
10 * (C) 2006 by coresystems GmbH <info@coresystems.de>
12 * This file is subject to the terms and conditions of the GNU General
13 * Public License. See the file COPYING in the main directory of this
14 * archive for more details.
18 #include <console/console.h>
21 #include <cpu/x86/msr.h>
23 /* The maximum length of CPU names is 48 bytes, including the final NULL byte.
24 * If you change these names your BIOS will _NOT_ pass the AMD validation and
25 * your mainboard will not be posted on the AMD Recommended Motherboard Website
28 static char *processor_names[]={
29 /* 0x00 */ "AMD Engineering Sample",
30 /* 0x01-0x03 */ NULL, NULL, NULL,
31 /* 0x04 */ "AMD Athlon(tm) 64 Processor XX00+",
32 /* 0x05 */ "AMD Athlon(tm) 64 X2 Dual Core Processor XX00+",
33 /* 0x06-0x07 */ NULL, NULL,
34 /* 0x08 */ "Mobile AMD Athlon(tm) 64 Processor XX00+",
35 /* 0x09 */ "Mobile AMD Athlon(tm) 64 Processor XX00+",
36 /* 0x0A */ "AMD Turion(tm) 64 Mobile Technology ML-XX",
37 /* 0x0B */ "AMD Turion(tm) 64 Mobile Technology MT-XX",
38 /* 0x0C */ "AMD Opteron(tm) Processor 1YY",
39 /* 0x0D */ "AMD Opteron(tm) Processor 1YY",
40 /* 0x0E */ "AMD Opteron(tm) Processor 1YY HE",
41 /* 0x0F */ "AMD Opteron(tm) Processor 1YY EE",
42 /* 0x10 */ "AMD Opteron(tm) Processor 2YY",
43 /* 0x11 */ "AMD Opteron(tm) Processor 2YY",
44 /* 0x12 */ "AMD Opteron(tm) Processor 2YY HE",
45 /* 0x13 */ "AMD Opteron(tm) Processor 2YY EE",
46 /* 0x14 */ "AMD Opteron(tm) Processor 8YY",
47 /* 0x15 */ "AMD Opteron(tm) Processor 8YY",
48 /* 0x16 */ "AMD Opteron(tm) Processor 8YY HE",
49 /* 0x17 */ "AMD Opteron(tm) Processor 8YY EE",
50 /* 0x18 */ "AMD Athlon(tm) 64 Processor VV00+",
51 /* 0x19-0x1C */ NULL, NULL, NULL, NULL,
52 /* 0x1D */ "Mobile AMD Athlon(tm) XP-M Processor XX00+",
53 /* 0x1E */ "Mobile AMD Athlon(tm) XP-M Processor XX00+",
55 /* 0x20 */ "AMD Athlon(tm) XP Processor XX00+",
56 /* 0x21 */ "Mobile AMD Sempron(tm) Processor TT00+",
57 /* 0x22 */ "AMD Sempron(tm) Processor TT00+",
58 /* 0x23 */ "Mobile AMD Sempron(tm) Processor TT00+",
59 /* 0x24 */ "AMD Athlon(tm) 64 FX-ZZ Processor",
61 /* 0x26 */ "AMD Sempron(tm) Processor TT00+",
62 /* 0x27-0x28 */ NULL, NULL,
63 /* 0x29 */ "Dual Core AMD Opteron(tm) Processor 1RR SE",
64 /* 0x2A */ "Dual Core AMD Opteron(tm) Processor 2RR SE",
65 /* 0x2B */ "Dual Core AMD Opteron(tm) Processor 8RR SE",
66 /* 0x2C */ "Dual Core AMD Opteron(tm) Processor 1RR",
67 /* 0x2D */ "Dual Core AMD Opteron(tm) Processor 1RR",
68 /* 0x2E */ "Dual Core AMD Opteron(tm) Processor 1RR HE",
69 /* 0x2F */ "Dual Core AMD Opteron(tm) Processor 1RR EE",
70 /* 0x30 */ "Dual Core AMD Opteron(tm) Processor 2RR",
71 /* 0x31 */ "Dual Core AMD Opteron(tm) Processor 2RR",
72 /* 0x32 */ "Dual Core AMD Opteron(tm) Processor 2RR HE",
73 /* 0x33 */ "Dual Core AMD Opteron(tm) Processor 2RR EE",
74 /* 0x34 */ "Dual Core AMD Opteron(tm) Processor 8RR",
75 /* 0x35 */ "Dual Core AMD Opteron(tm) Processor 8RR",
76 /* 0x36 */ "Dual Core AMD Opteron(tm) Processor 8RR HE",
77 /* 0x37 */ "Dual Core AMD Opteron(tm) Processor 8RR EE",
78 /* 0x38 */ "Dual Core AMD Opteron(tm) Processor 1RR",
79 /* 0x39 */ "Dual Core AMD Opteron(tm) Processor 2RR",
80 /* 0x3A */ "Dual Core AMD Opteron(tm) Processor 8RR"
81 #define MAX_CPU_NUMBER 0x3A
84 /* wrmsr_amd() is from yhlu's changes to model_fxx_init.c */
86 static inline void wrmsr_amd(unsigned index, msr_t msr)
88 __asm__ __volatile__ (
91 : "c" (index), "a" (msr.lo), "d" (msr.hi), "D" (0x9c5a203a)
95 static inline unsigned int cpuid_ebx(unsigned int op)
97 unsigned int eax, ebx;
100 : "=a" (eax), "=b" (ebx)
106 static inline void strcpy(char *dst, char *src)
108 while (*src) *dst++ = *src++;
112 int init_processor_name(void)
122 char *processor_name_string=NULL;
123 char program_string[48];
124 unsigned int *program_values = (unsigned int *)program_string;
126 /* Find out which CPU brand it is */
127 EightBitBrandId = cpuid_ebx(0x00000001) & 0xff;
128 BrandId = cpuid_ebx(0x80000001) & 0xffff;
130 if(!EightBitBrandId && !BrandId) {
133 } else if(!EightBitBrandId) {
134 BrandTableIndex = (BrandId >> 6) & 0x3f; // BrandId[11:6]
135 NN = BrandId & 0x3f; // // BrandId[6:0]
137 BrandTableIndex = EightBitBrandId >> (5-2) & 0xfc; // { 0b, 8BitBrandId[7:5], 00b }
138 NN = EightBitBrandId & 0x1f; // 8BitBrandId[4:0]
141 /* Look up the CPU brand in above table */
142 if (BrandTableIndex <= MAX_CPU_NUMBER)
143 processor_name_string = processor_names[BrandTableIndex];
145 if (!processor_name_string)
146 processor_name_string = "AMD Processor model unknown";
148 memset(program_string, 0, 48);
149 strcpy(program_string, processor_name_string);
151 /* Now create a model number - See Table 4. Model Number Calculation
152 * in the Revision Guide. NOTE: #6, EE was changed to VV because
153 * otherwise it clashes with the brand names.
156 for (i=0; i<47; i++) { // 48 -1
157 if(program_string[i] == program_string[i+1]) {
158 switch (program_string[i]) {
159 case 'X': ModelNumber = 22+ NN; break;
160 case 'Y': ModelNumber = 38 + (2*NN); break;
162 case 'T': ModelNumber = 24 + NN; break;
163 case 'R': ModelNumber = 45 + (5*NN); break;
164 case 'V': ModelNumber = 9 + NN; break;
167 if(ModelNumber && ModelNumber < 100) {
168 // No idea what to do with RR=100. According
169 // to the revision guide this is possible.
171 // --> "AMD Opteron(tm) Processor 8100"?
172 program_string[i]=(ModelNumber/10)+'0';
173 program_string[i+1]=(ModelNumber%10)+'0';
179 printk_debug("CPU model %s\n", program_string);
181 for (i=0; i<6; i++) {
182 progmsr.lo = program_values[(2*i)+0];
183 progmsr.hi = program_values[(2*i)+1];
184 wrmsr_amd(0xc0010030+i, progmsr);