2 * This file is part of the coreboot project.
4 * Copyright (C) 2007 Advanced Micro Devices, Inc.
5 * Copyright (C) 2008 Peter Stuge
6 * Copyright (C) 2010 Marc Jones <marcj303@gmail.com>
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; version 2 of the License.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA, 02110-1301 USA
23 * This code sets the Processor Name String for AMD64 CPUs.
25 * Revision Guide for AMD Family 10h Processors
26 * Publication # 41322 Revision: 3.17 Issue Date: February 2008
29 #include <console/console.h>
31 #include <cpu/x86/msr.h>
33 #include <cpu/amd/model_10xxx_rev.h>
35 extern void wrmsr_amd(u32 index, msr_t msr);
37 /* The maximum length of CPU names is 48 bytes, including the final NULL byte.
38 * If you change these names your BIOS will _NOT_ pass the AMD validation and
39 * your mainboard will not be posted on the AMD Recommended Motherboard Website
50 static const struct str_s String1_socket_F[] = {
51 {0x00, 0x01, 0x00, "Dual-Core AMD Opteron(tm) Processor 83"},
52 {0x00, 0x01, 0x01, "Dual-Core AMD Opteron(tm) Processor 23"},
53 {0x00, 0x03, 0x00, "Quad-Core AMD Opteron(tm) Processor 83"},
54 {0x00, 0x03, 0x01, "Quad-Core AMD Opteron(tm) Processor 23"},
55 {0x00, 0x03, 0x02, "Embedded AMD Opteron(tm) Processor 83"},
56 {0x00, 0x03, 0x03, "Embedded AMD Opteron(tm) Processor 23"},
57 {0x00, 0x03, 0x04, "Embedded AMD Opteron(tm) Processor 13"},
58 {0x00, 0x03, 0x05, "AMD Phenom(tm) FX-"},
59 {0x01, 0x01, 0x01, "Embedded AMD Opteron(tm) Processor"},
63 static const struct str_s String2_socket_F[] = {
64 {0x00, 0xFF, 0x0A, " SE"},
65 {0x00, 0xFF, 0x0B, " HE"},
66 {0x00, 0xFF, 0x0C, " EE"},
67 {0x00, 0xFF, 0x0D, " Quad-Core Processor"},
68 {0x00, 0xFF, 0x0F, ""},
69 {0x01, 0x01, 0x01, "GF HE"},
74 static const struct str_s String1_socket_AM2[] = {
75 {0x00, 0x00, 0x00, "AMD Athlon(tm) Processor LE-"},
76 {0x00, 0x00, 0x01, "AMD Sempron(tm) Processor LE-"},
77 {0x00, 0x00, 0x02, "AMD Sempron(tm) 1"},
78 {0x00, 0x00, 0x03, "AMD Athlon(tm) II 1"},
79 {0x00, 0x01, 0x00, "Dual-Core AMD Opteron(tm) Processor 13"},
80 {0x00, 0x01, 0x01, "AMD Athlon(tm)"},
81 {0x00, 0x01, 0x03, "AMD Athlon(tm) II X2 2"},
82 {0x00, 0x01, 0x04, "AMD Athlon(tm) II X2 B"},
83 {0x00, 0x01, 0x05, "AMD Athlon(tm) II X2"},
84 {0x00, 0x01, 0x07, "AMD Phenom(tm) II X2 5"},
85 {0x00, 0x01, 0x0A, "AMD Phenom(tm) II X2"},
86 {0x00, 0x01, 0x0B, "AMD Phenom(tm) II X2 B"},
87 {0x00, 0x02, 0x00, "AMD Phenom(tm)"},
88 {0x00, 0x02, 0x03, "AMD Phenom(tm) II X3 B"},
89 {0x00, 0x02, 0x04, "AMD Phenom(tm) II X3"},
90 {0x00, 0x02, 0x07, "AMD Athlon(tm) II X3 4"},
91 {0x00, 0x02, 0x08, "AMD Phenom(tm) II X3 7"},
92 {0x00, 0x02, 0x0A, "AMD Athlon(tm) II X3"},
93 {0x00, 0x03, 0x00, "Quad-Core AMD Opteron(tm) Processor 13"},
94 {0x00, 0x03, 0x01, "AMD Phenom(tm) FX-"},
95 {0x00, 0x03, 0x02, "AMD Phenom(tm)"},
96 {0x00, 0x03, 0x03, "AMD Phenom(tm) II X4 9"},
97 {0x00, 0x03, 0x04, "AMD Phenom(tm) II X4 8"},
98 {0x00, 0x03, 0x07, "AMD Phenom(tm) II X4 B"},
99 {0x00, 0x03, 0x08, "AMD Phenom(tm) II X4"},
100 {0x00, 0x03, 0x0A, "AMD Athlon(tm) II X4 6"},
101 {0x00, 0x03, 0x0F, "AMD Athlon(tm) II X4"},
105 static const struct str_s String2_socket_AM2[] = {
106 {0x00, 0x00, 0x00, "00"},
107 {0x00, 0x00, 0x01, "10"},
108 {0x00, 0x00, 0x02, "20"},
109 {0x00, 0x00, 0x03, "30"},
110 {0x00, 0x00, 0x04, "40"},
111 {0x00, 0x00, 0x05, "50"},
112 {0x00, 0x00, 0x06, "60"},
113 {0x00, 0x00, 0x07, "70"},
114 {0x00, 0x00, 0x08, "80"},
115 {0x00, 0x00, 0x09, "90"},
116 {0x00, 0x00, 0x09, " Processor"},
117 {0x00, 0x00, 0x09, "u Processor"},
118 {0x00, 0x01, 0x00, "00 Dual-Core Processor"},
119 {0x00, 0x01, 0x01, "00e Dual-Core Processor"},
120 {0x00, 0x01, 0x02, "00B Dual-Core Processor"},
121 {0x00, 0x01, 0x03, "50 Dual-Core Processor"},
122 {0x00, 0x01, 0x04, "50e Dual-Core Processor"},
123 {0x00, 0x01, 0x05, "50B Dual-Core Processor"},
124 {0x00, 0x01, 0x06, " Processor"},
125 {0x00, 0x01, 0x07, "e Processor"},
126 {0x00, 0x01, 0x09, "0 Processor"},
127 {0x00, 0x01, 0x0A, "0e Processor"},
128 {0x00, 0x01, 0x0B, "u Processor"},
129 {0x00, 0x02, 0x00, "00 Triple-Core Processor"},
130 {0x00, 0x02, 0x01, "00e Triple-Core Processor"},
131 {0x00, 0x02, 0x02, "00B Triple-Core Processor"},
132 {0x00, 0x02, 0x03, "50 Triple-Core Processor"},
133 {0x00, 0x02, 0x04, "50e Triple-Core Processor"},
134 {0x00, 0x02, 0x05, "50B Triple-Core Processor"},
135 {0x00, 0x02, 0x06, " Processor"},
136 {0x00, 0x02, 0x07, "e Processor"},
137 {0x00, 0x02, 0x09, "0e Processor"},
138 {0x00, 0x02, 0x0A, "0 Processor"},
139 {0x00, 0x03, 0x00, "00 Quad-Core Processor"},
140 {0x00, 0x03, 0x01, "00e Quad-Core Processor"},
141 {0x00, 0x03, 0x02, "00B Quad-Core Processor"},
142 {0x00, 0x03, 0x03, "50 Quad-Core Processor"},
143 {0x00, 0x03, 0x04, "50e Quad-Core Processor"},
144 {0x00, 0x03, 0x05, "50B Quad-Core Processor"},
145 {0x00, 0x03, 0x06, " Processor"},
146 {0x00, 0x03, 0x07, "e Processor"},
147 {0x00, 0x03, 0x09, "0e Processor"},
148 {0x00, 0x03, 0x0A, " SE"},
149 {0x00, 0x03, 0x0B, " HE"},
150 {0x00, 0x03, 0x0C, " EE"},
151 {0x00, 0x03, 0x0D, " Quad-Core Processor"},
152 {0x00, 0x03, 0x0E, "0 Processor"},
153 {0x00, 0xFF, 0x0F, ""},
157 static const struct str_s String1_socket_C32[] = {
158 {0x00, 0x03, 0x00, "AMD Opteron(tm) Processor 41"},
159 {0x00, 0x05, 0x00, "AMD Opteron(tm) Processor 41"},
160 {0x01, 0x03, 0x01, "Embedded AMD Opteron(tm) Processor "},
161 {0x01, 0x05, 0x01, "Embedded AMD Opteron(tm) Processor "},
165 static const struct str_s String2_socket_C32[] = {
166 {0x00, 0x03, 0x00, " HE"},
167 {0x00, 0x03, 0x01, " EE"},
168 {0x00, 0x05, 0x00, " HE"},
169 {0x00, 0x05, 0x01, " EE"},
170 {0x01, 0x03, 0x01, "QS HE"},
171 {0x01, 0x03, 0x02, "LE HE"},
172 {0x01, 0x05, 0x01, "KX HE"},
173 {0x01, 0x05, 0x02, "GL EE"},
177 const char const *unknown = "AMD Processor model unknown";
178 const char const *unknown2 = " type unknown";
179 const char const *sample = "AMD Engineering Sample";
180 const char const *thermal = "AMD Thermal Test Kit";
183 static int strcpymax(char *dst, const char *src, int buflen)
186 for (i = 0; i < buflen && src[i]; i++)
195 int init_processor_name(void)
197 /* variable names taken from fam10 revision guide for clarity */
198 u32 BrandId; /* CPUID Fn8000_0001_EBX */
199 u8 String1; /* BrandID[14:11] */
200 u8 String2; /* BrandID[3:0] */
201 u8 Model; /* BrandID[10:4] */
202 u8 Pg; /* BrandID[15] */
203 u8 PkgTyp; /* BrandID[31:28] */
204 u8 NC; /* CPUID Fn8000_0008_ECX */
205 const char *processor_name_string = unknown;
206 char program_string[48];
207 u32 *p_program_string = (u32 *)program_string;
209 int i, j = 0, str2_checkNC = 1;
210 const struct str_s *str, *str2;
213 /* Find out which CPU brand it is */
214 BrandId = cpuid_ebx(0x80000001);
215 String1 = (u8)((BrandId >> 11) & 0x0F);
216 String2 = (u8)((BrandId >> 0) & 0x0F);
217 Model = (u8)((BrandId >> 4) & 0x7F);
218 Pg = (u8)((BrandId >> 15) & 0x01);
219 PkgTyp = (u8)((BrandId >> 28) & 0x0F);
220 NC = (u8)(cpuid_ecx(0x80000008) & 0xFF);
222 /* null the string */
223 memset(program_string, 0, sizeof(program_string));
226 processor_name_string = Pg ? thermal : sample;
232 str = String1_socket_F;
233 str2 = String2_socket_F;
237 str = String1_socket_AM2;
238 str2 = String2_socket_AM2;
241 str = String1_socket_C32;
242 str2 = String2_socket_C32;
249 for (i = 0; str[i].value; i++) {
250 if ((str[i].Pg == Pg) &&
252 (str[i].String == String1)) {
253 processor_name_string = str[i].value;
261 j = strcpymax(program_string, processor_name_string,
262 sizeof(program_string));
264 /* Translate Model from 01-99 to ASCII and put it on the end.
265 * Numbers less than 10 should include a leading zero, e.g., 09.*/
266 if (Model < 100 && j < sizeof(program_string) - 2) {
267 program_string[j++] = (Model / 10) + '0';
268 program_string[j++] = (Model % 10) + '0';
271 processor_name_string = unknown2;
274 for(i = 0; str2[i].value; i++) {
275 if ((str2[i].Pg == Pg) &&
276 ((str2[i].NC == NC) || !str2_checkNC) &&
277 (str2[i].String == String2)) {
278 processor_name_string = str2[i].value;
285 strcpymax(&program_string[j], processor_name_string,
286 sizeof(program_string) - j);
288 printk(BIOS_DEBUG, "CPU model: %s\n", program_string);
290 for (i = 0; i < 6; i++) {
291 msr.lo = p_program_string[(2 * i) + 0];
292 msr.hi = p_program_string[(2 * i) + 1];
293 wrmsr_amd(0xC0010030 + i, msr);