2 * This file is part of the coreboot project.
4 * Copyright (C) 2007 Advanced Micro Devices, Inc.
5 * Copyright (C) 2008 Peter Stuge
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; version 2 of the License.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA, 02110-1301 USA
22 * This code sets the Processor Name String for AMD64 CPUs.
24 * Revision Guide for AMD Family 10h Processors
25 * Publication # 41322 Revision: 3.17 Issue Date: February 2008
28 #include <console/console.h>
30 #include <cpu/x86/msr.h>
32 #include <cpu/amd/model_10xxx_rev.h>
34 extern void wrmsr_amd(u32 index, msr_t msr);
36 /* The maximum length of CPU names is 48 bytes, including the final NULL byte.
37 * If you change these names your BIOS will _NOT_ pass the AMD validation and
38 * your mainboard will not be posted on the AMD Recommended Motherboard Website
49 static const struct str_s String1_socket_F[] = {
50 {0x00, 0x01, 0x00, "Dual-Core AMD Opteron(tm) Processor 83"},
51 {0x00, 0x01, 0x01, "Dual-Core AMD Opteron(tm) Processor 23"},
52 {0x00, 0x03, 0x00, "Quad-Core AMD Opteron(tm) Processor 83"},
53 {0x00, 0x03, 0x01, "Quad-Core AMD Opteron(tm) Processor 23"},
54 {0x00, 0x03, 0x02, "Embedded AMD Opteron(tm) Processor 83"},
55 {0x00, 0x03, 0x03, "Embedded AMD Opteron(tm) Processor 23"},
56 {0x00, 0x03, 0x04, "Embedded AMD Opteron(tm) Processor 13"},
57 {0x00, 0x03, 0x05, "AMD Phenom(tm) FX-"},
58 {0x01, 0x01, 0x01, "Embedded AMD Opteron(tm) Processor"},
62 static const struct str_s String2_socket_F[] = {
63 {0x00, 0xFF, 0x0A, " SE"},
64 {0x00, 0xFF, 0x0B, " HE"},
65 {0x00, 0xFF, 0x0C, " EE"},
66 {0x00, 0xFF, 0x0D, " Quad-Core Processor"},
67 {0x00, 0xFF, 0x0F, ""},
68 {0x01, 0x01, 0x01, "GF HE"},
73 static const struct str_s String1_socket_AM2[] = {
74 {0x00, 0x00, 0x00, "AMD Athlon(tm) Processor LE-"},
75 {0x00, 0x00, 0x01, "AMD Sempron(tm) Processor LE-"},
76 {0x00, 0x01, 0x00, "Dual-Core AMD Opteron(tm) Processor 13"},
77 {0x00, 0x01, 0x01, "AMD Athlon(tm)"},
78 {0x00, 0x02, 0x00, "AMD Phenom(tm)"},
79 {0x00, 0x03, 0x00, "Quad-Core AMD Opteron(tm) Processor 13"},
80 {0x00, 0x03, 0x01, "AMD Phenom(tm) FX-"},
81 {0x00, 0x03, 0x02, "AMD Phenom(tm)"},
85 static const struct str_s String2_socket_AM2[] = {
86 {0x00, 0x00, 0x00, "00"},
87 {0x00, 0x00, 0x01, "10"},
88 {0x00, 0x00, 0x02, "20"},
89 {0x00, 0x00, 0x03, "30"},
90 {0x00, 0x00, 0x04, "40"},
91 {0x00, 0x00, 0x05, "50"},
92 {0x00, 0x00, 0x06, "60"},
93 {0x00, 0x00, 0x07, "70"},
94 {0x00, 0x00, 0x08, "80"},
95 {0x00, 0x00, 0x09, "90"},
96 {0x00, 0x01, 0x00, "00 Dual-Core Processor"},
97 {0x00, 0x01, 0x01, "00e Dual-Core Processor"},
98 {0x00, 0x01, 0x02, "00B Dual-Core Processor"},
99 {0x00, 0x01, 0x03, "50 Dual-Core Processor"},
100 {0x00, 0x01, 0x04, "50e Dual-Core Processor"},
101 {0x00, 0x01, 0x05, "50B Dual-Core Processor"},
102 {0x00, 0x02, 0x00, "00 Triple-Core Processor"},
103 {0x00, 0x02, 0x01, "00e Triple-Core Processor"},
104 {0x00, 0x02, 0x02, "00B Triple-Core Processor"},
105 {0x00, 0x02, 0x03, "50 Triple-Core Processor"},
106 {0x00, 0x02, 0x04, "50e Triple-Core Processor"},
107 {0x00, 0x02, 0x05, "50B Triple-Core Processor"},
108 {0x00, 0x03, 0x00, "00 Quad-Core Processor"},
109 {0x00, 0x03, 0x01, "00e Quad-Core Processor"},
110 {0x00, 0x03, 0x02, "00B Quad-Core Processor"},
111 {0x00, 0x03, 0x03, "50 Quad-Core Processor"},
112 {0x00, 0x03, 0x04, "50e Quad-Core Processor"},
113 {0x00, 0x03, 0x05, "50B Quad-Core Processor"},
114 {0x00, 0x03, 0x0A, " SE"},
115 {0x00, 0x03, 0x0B, " HE"},
116 {0x00, 0x03, 0x0C, " EE"},
117 {0x00, 0x03, 0x0D, " Quad-Core Processor"},
118 {0x00, 0xFF, 0x0F, ""},
123 const char const *unknown = "AMD Processor model unknown";
124 const char const *unknown2 = " type unknown";
125 const char const *sample = "AMD Engineering Sample";
126 const char const *thermal = "AMD Thermal Test Kit";
129 static int strcpymax(char *dst, const char *src, int buflen)
132 for (i = 0; i < buflen && src[i]; i++)
141 int init_processor_name(void)
143 /* variable names taken from fam10 revision guide for clarity */
144 u32 BrandId; /* CPUID Fn8000_0001_EBX */
145 u8 String1; /* BrandID[14:11] */
146 u8 String2; /* BrandID[3:0] */
147 u8 Model; /* BrandID[10:4] */
148 u8 Pg; /* BrandID[15] */
149 u8 PkgTyp; /* BrandID[31:28] */
150 u8 NC; /* CPUID Fn8000_0008_ECX */
151 const char *processor_name_string = unknown;
152 char program_string[48];
153 u32 *p_program_string = (u32 *)program_string;
155 int i, j = 0, str2_checkNC = 1;
156 const struct str_s *str, *str2;
159 /* Find out which CPU brand it is */
160 BrandId = cpuid_ebx(0x80000001);
161 String1 = (u8)((BrandId >> 11) & 0x0F);
162 String2 = (u8)((BrandId >> 0) & 0x0F);
163 Model = (u8)((BrandId >> 4) & 0x7F);
164 Pg = (u8)((BrandId >> 15) & 0x01);
165 PkgTyp = (u8)((BrandId >> 28) & 0x0F);
166 NC = (u8)(cpuid_ecx(0x80000008) & 0xFF);
168 /* null the string */
169 memset(program_string, 0, sizeof(program_string));
172 processor_name_string = Pg ? sample : thermal;
178 str = String1_socket_F;
179 str2 = String2_socket_F;
183 str = String1_socket_AM2;
184 str2 = String2_socket_AM2;
191 for (i = 0; str[i].value; i++) {
192 if ((str[i].Pg == Pg) &&
194 (str[i].String == String1)) {
195 processor_name_string = str[i].value;
203 j = strcpymax(program_string, processor_name_string,
204 sizeof(program_string));
206 /* Translate Model from 01-99 to ASCII and put it on the end.
207 * Numbers less than 10 should include a leading zero, e.g., 09.*/
208 if (Model < 100 && j < sizeof(program_string) - 2) {
209 program_string[j++] = (Model / 10) + '0';
210 program_string[j++] = (Model % 10) + '0';
213 processor_name_string = unknown2;
216 for(i = 0; str2[i].value; i++) {
217 if ((str2[i].Pg == Pg) &&
218 ((str2[i].NC == NC) || !str2_checkNC) &&
219 (str2[i].String == String2)) {
220 processor_name_string = str2[i].value;
227 strcpymax(&program_string[j], processor_name_string,
228 sizeof(program_string) - j);
230 printk(BIOS_DEBUG, "CPU model: %s\n", program_string);
232 for (i = 0; i < 6; i++) {
233 msr.lo = p_program_string[(2 * i) + 0];
234 msr.hi = p_program_string[(2 * i) + 1];
235 wrmsr_amd(0xC0010030 + i, msr);