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>
33 extern void wrmsr_amd(u32 index, msr_t msr);
35 /* The maximum length of CPU names is 48 bytes, including the final NULL byte.
36 * If you change these names your BIOS will _NOT_ pass the AMD validation and
37 * your mainboard will not be posted on the AMD Recommended Motherboard Website
48 static const struct str_s String1_socket_F[] = {
49 {0x00, 0x01, 0x00, "Dual-Core AMD Opteron(tm) Processor 83"},
50 {0x00, 0x01, 0x01, "Dual-Core AMD Opteron(tm) Processor 23"},
51 {0x00, 0x03, 0x00, "Quad-Core AMD Opteron(tm) Processor 83"},
52 {0x00, 0x03, 0x01, "Quad-Core AMD Opteron(tm) Processor 23"},
53 {0x00, 0x03, 0x02, "Embedded AMD Opteron(tm) Processor 83"},
54 {0x00, 0x03, 0x03, "Embedded AMD Opteron(tm) Processor 23"},
55 {0x00, 0x03, 0x04, "Embedded AMD Opteron(tm) Processor 13"},
56 {0x00, 0x03, 0x05, "AMD Phenom(tm) FX-"},
57 {0x01, 0x01, 0x01, "Embedded AMD Opteron(tm) Processor"},
61 static const struct str_s String2_socket_F[] = {
62 {0x00, 0xFF, 0x0A, " SE"},
63 {0x00, 0xFF, 0x0B, " HE"},
64 {0x00, 0xFF, 0x0C, " EE"},
65 {0x00, 0xFF, 0x0D, " Quad-Core Processor"},
66 {0x00, 0xFF, 0x0F, ""},
67 {0x01, 0x01, 0x01, "GF HE"},
72 static const struct str_s String1_socket_AM2[] = {
73 {0x00, 0x00, 0x00, "AMD Athlon(tm) Processor LE-"},
74 {0x00, 0x00, 0x01, "AMD Sempron(tm) Processor LE-"},
75 {0x00, 0x01, 0x00, "Dual-Core AMD Opteron(tm) Processor 13"},
76 {0x00, 0x01, 0x01, "AMD Athlon(tm)"},
77 {0x00, 0x02, 0x00, "AMD Phenom(tm)"},
78 {0x00, 0x03, 0x00, "Quad-Core AMD Opteron(tm) Processor 13"},
79 {0x00, 0x03, 0x01, "AMD Phenom(tm) FX-"},
80 {0x00, 0x03, 0x02, "AMD Phenom(tm)"},
84 static const struct str_s String2_socket_AM2[] = {
85 {0x00, 0x00, 0x00, "00"},
86 {0x00, 0x00, 0x01, "10"},
87 {0x00, 0x00, 0x02, "20"},
88 {0x00, 0x00, 0x03, "30"},
89 {0x00, 0x00, 0x04, "40"},
90 {0x00, 0x00, 0x05, "50"},
91 {0x00, 0x00, 0x06, "60"},
92 {0x00, 0x00, 0x07, "70"},
93 {0x00, 0x00, 0x08, "80"},
94 {0x00, 0x00, 0x09, "90"},
95 {0x00, 0x01, 0x00, "00 Dual-Core Processor"},
96 {0x00, 0x01, 0x01, "00e Dual-Core Processor"},
97 {0x00, 0x01, 0x02, "00B Dual-Core Processor"},
98 {0x00, 0x01, 0x03, "50 Dual-Core Processor"},
99 {0x00, 0x01, 0x04, "50e Dual-Core Processor"},
100 {0x00, 0x01, 0x05, "50B Dual-Core Processor"},
101 {0x00, 0x02, 0x00, "00 Triple-Core Processor"},
102 {0x00, 0x02, 0x01, "00e Triple-Core Processor"},
103 {0x00, 0x02, 0x02, "00B Triple-Core Processor"},
104 {0x00, 0x02, 0x03, "50 Triple-Core Processor"},
105 {0x00, 0x02, 0x04, "50e Triple-Core Processor"},
106 {0x00, 0x02, 0x05, "50B Triple-Core Processor"},
107 {0x00, 0x03, 0x00, "00 Quad-Core Processor"},
108 {0x00, 0x03, 0x01, "00e Quad-Core Processor"},
109 {0x00, 0x03, 0x02, "00B Quad-Core Processor"},
110 {0x00, 0x03, 0x03, "50 Quad-Core Processor"},
111 {0x00, 0x03, 0x04, "50e Quad-Core Processor"},
112 {0x00, 0x03, 0x05, "50B Quad-Core Processor"},
113 {0x00, 0x03, 0x0A, " SE"},
114 {0x00, 0x03, 0x0B, " HE"},
115 {0x00, 0x03, 0x0C, " EE"},
116 {0x00, 0x03, 0x0D, " Quad-Core Processor"},
117 {0x00, 0xFF, 0x0F, ""},
122 char const *unknown = "AMD Processor model unknown";
123 char const *unknown2 = " type unknown";
124 char const *sample = "AMD Engineering Sample";
125 char const *thermal = "AMD Thermal Test Kit";
128 int strcpymax(char *dst, const char *src, int buflen) {
130 for (i = 0; i < buflen && src[i]; i++)
139 int init_processor_name(void)
141 /* variable names taken from fam10 revision guide for clarity */
142 u32 BrandId; /* CPUID Fn8000_0001_EBX */
143 u8 String1; /* BrandID[14:11] */
144 u8 String2; /* BrandID[3:0] */
145 u8 Model; /* BrandID[10:4] */
146 u8 Pg; /* BrandID[15] */
147 u8 PkgTyp; /* BrandID[31:28] */
148 u8 NC; /* CPUID Fn8000_0008_ECX */
149 const char *processor_name_string = unknown;
150 char program_string[48];
151 u32 *p_program_string = (u32 *)program_string;
153 int i, j = 0, str2_checkNC = 1;
154 const struct str_s *str, *str2;
157 /* Find out which CPU brand it is */
158 BrandId = cpuid_ebx(0x80000001);
159 String1 = (u8)((BrandId >> 11) & 0x0F);
160 String2 = (u8)((BrandId >> 0) & 0x0F);
161 Model = (u8)((BrandId >> 4) & 0x7F);
162 Pg = (u8)((BrandId >> 15) & 0x01);
163 PkgTyp = (u8)((BrandId >> 28) & 0x0F);
164 NC = (u8)(cpuid_ecx(0x80000008) & 0xFF);
166 /* null the string */
167 memset(program_string, 0, sizeof(program_string));
170 processor_name_string = Pg ? sample : thermal;
176 str = String1_socket_F;
177 str2 = String2_socket_F;
181 str = String1_socket_AM2;
182 str2 = String2_socket_AM2;
189 for (i = 0; str[i].value; i++) {
190 if ((str[i].Pg == Pg) &&
192 (str[i].String == String1)) {
193 processor_name_string = str[i].value;
201 j = strcpymax(program_string, processor_name_string,
202 sizeof(program_string));
204 /* Translate Model from 01-99 to ASCII and put it on the end.
205 * Numbers less than 10 should include a leading zero, e.g., 09.*/
206 if (Model < 100 && j < sizeof(program_string) - 2) {
207 program_string[j++] = (Model / 10) + '0';
208 program_string[j++] = (Model % 10) + '0';
211 processor_name_string = unknown2;
214 for(i = 0; str2[i].value; i++) {
215 if ((str2[i].Pg == Pg) &&
216 ((str2[i].NC == NC) || !str2_checkNC) &&
217 (str2[i].String == String2)) {
218 processor_name_string = str2[i].value;
225 strcpymax(&program_string[j], processor_name_string,
226 sizeof(program_string) - j);
228 printk_debug("CPU model: %s\n", program_string);
230 for (i = 0; i < 6; i++) {
231 msr.lo = p_program_string[(2 * i) + 0];
232 msr.hi = p_program_string[(2 * i) + 1];
233 wrmsr_amd(0xC0010030 + i, msr);