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 char const *unknown = "AMD Processor model unknown";
124 char const *unknown2 = " type unknown";
125 char const *sample = "AMD Engineering Sample";
126 char const *thermal = "AMD Thermal Test Kit";
129 int strcpymax(char *dst, const char *src, int buflen) {
131 for (i = 0; i < buflen && src[i]; i++)
140 int init_processor_name(void)
142 /* variable names taken from fam10 revision guide for clarity */
143 u32 BrandId; /* CPUID Fn8000_0001_EBX */
144 u8 String1; /* BrandID[14:11] */
145 u8 String2; /* BrandID[3:0] */
146 u8 Model; /* BrandID[10:4] */
147 u8 Pg; /* BrandID[15] */
148 u8 PkgTyp; /* BrandID[31:28] */
149 u8 NC; /* CPUID Fn8000_0008_ECX */
150 const char *processor_name_string = unknown;
151 char program_string[48];
152 u32 *p_program_string = (u32 *)program_string;
154 int i, j = 0, str2_checkNC = 1;
155 const struct str_s *str, *str2;
158 /* Find out which CPU brand it is */
159 BrandId = cpuid_ebx(0x80000001);
160 String1 = (u8)((BrandId >> 11) & 0x0F);
161 String2 = (u8)((BrandId >> 0) & 0x0F);
162 Model = (u8)((BrandId >> 4) & 0x7F);
163 Pg = (u8)((BrandId >> 15) & 0x01);
164 PkgTyp = (u8)((BrandId >> 28) & 0x0F);
165 NC = (u8)(cpuid_ecx(0x80000008) & 0xFF);
167 /* null the string */
168 memset(program_string, 0, sizeof(program_string));
171 processor_name_string = Pg ? sample : thermal;
177 str = String1_socket_F;
178 str2 = String2_socket_F;
182 str = String1_socket_AM2;
183 str2 = String2_socket_AM2;
190 for (i = 0; str[i].value; i++) {
191 if ((str[i].Pg == Pg) &&
193 (str[i].String == String1)) {
194 processor_name_string = str[i].value;
202 j = strcpymax(program_string, processor_name_string,
203 sizeof(program_string));
205 /* Translate Model from 01-99 to ASCII and put it on the end.
206 * Numbers less than 10 should include a leading zero, e.g., 09.*/
207 if (Model < 100 && j < sizeof(program_string) - 2) {
208 program_string[j++] = (Model / 10) + '0';
209 program_string[j++] = (Model % 10) + '0';
212 processor_name_string = unknown2;
215 for(i = 0; str2[i].value; i++) {
216 if ((str2[i].Pg == Pg) &&
217 ((str2[i].NC == NC) || !str2_checkNC) &&
218 (str2[i].String == String2)) {
219 processor_name_string = str2[i].value;
226 strcpymax(&program_string[j], processor_name_string,
227 sizeof(program_string) - j);
229 printk_debug("CPU model: %s\n", program_string);
231 for (i = 0; i < 6; i++) {
232 msr.lo = p_program_string[(2 * i) + 0];
233 msr.hi = p_program_string[(2 * i) + 1];
234 wrmsr_amd(0xC0010030 + i, msr);