Martin Roth | 9df9e939 | 2016-01-12 15:55:28 -0700 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of the coreboot project. |
| 3 | * |
| 4 | * This program is free software; you can redistribute it and/or modify |
| 5 | * it under the terms of the GNU General Public License as published by |
| 6 | * the Free Software Foundation; version 2 of the License. |
| 7 | * |
| 8 | * This program is distributed in the hope that it will be useful, |
| 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 11 | * GNU General Public License for more details. |
| 12 | */ |
| 13 | |
Aaron Durbin | b21e362 | 2016-12-07 00:32:19 -0600 | [diff] [blame^] | 14 | #include <bootstate.h> |
Aaron Durbin | f6ada1c | 2016-02-10 10:52:47 -0600 | [diff] [blame] | 15 | #include <boot/coreboot_tables.h> |
Eric Biederman | 8ca8d76 | 2003-04-22 19:02:15 +0000 | [diff] [blame] | 16 | #include <console/console.h> |
| 17 | #include <cpu/cpu.h> |
Eric Biederman | 8ca8d76 | 2003-04-22 19:02:15 +0000 | [diff] [blame] | 18 | #include <arch/io.h> |
| 19 | #include <string.h> |
Aaron Durbin | b21e362 | 2016-12-07 00:32:19 -0600 | [diff] [blame^] | 20 | #include <cpu/x86/mp.h> |
Eric Biederman | b78c197 | 2004-10-14 20:54:17 +0000 | [diff] [blame] | 21 | #include <cpu/x86/mtrr.h> |
| 22 | #include <cpu/x86/msr.h> |
| 23 | #include <cpu/x86/lapic.h> |
Aaron Durbin | e0969ae | 2016-02-10 10:56:06 -0600 | [diff] [blame] | 24 | #include <cpu/x86/tsc.h> |
Eric Biederman | b78c197 | 2004-10-14 20:54:17 +0000 | [diff] [blame] | 25 | #include <arch/cpu.h> |
| 26 | #include <device/path.h> |
| 27 | #include <device/device.h> |
| 28 | #include <smp/spinlock.h> |
Eric Biederman | 8ca8d76 | 2003-04-22 19:02:15 +0000 | [diff] [blame] | 29 | |
Stefan Reinauer | 9693885 | 2015-06-18 01:23:48 -0700 | [diff] [blame] | 30 | #ifndef __x86_64__ |
Eric Biederman | b78c197 | 2004-10-14 20:54:17 +0000 | [diff] [blame] | 31 | /* Standard macro to see if a specific flag is changeable */ |
| 32 | static inline int flag_is_changeable_p(uint32_t flag) |
Eric Biederman | 8ca8d76 | 2003-04-22 19:02:15 +0000 | [diff] [blame] | 33 | { |
Eric Biederman | b78c197 | 2004-10-14 20:54:17 +0000 | [diff] [blame] | 34 | uint32_t f1, f2; |
Eric Biederman | 8ca8d76 | 2003-04-22 19:02:15 +0000 | [diff] [blame] | 35 | |
Eric Biederman | b78c197 | 2004-10-14 20:54:17 +0000 | [diff] [blame] | 36 | asm( |
| 37 | "pushfl\n\t" |
| 38 | "pushfl\n\t" |
| 39 | "popl %0\n\t" |
| 40 | "movl %0,%1\n\t" |
| 41 | "xorl %2,%0\n\t" |
| 42 | "pushl %0\n\t" |
| 43 | "popfl\n\t" |
| 44 | "pushfl\n\t" |
| 45 | "popl %0\n\t" |
| 46 | "popfl\n\t" |
| 47 | : "=&r" (f1), "=&r" (f2) |
| 48 | : "ir" (flag)); |
| 49 | return ((f1^f2) & flag) != 0; |
Eric Biederman | 8ca8d76 | 2003-04-22 19:02:15 +0000 | [diff] [blame] | 50 | } |
| 51 | |
Eric Biederman | b78c197 | 2004-10-14 20:54:17 +0000 | [diff] [blame] | 52 | /* |
| 53 | * Cyrix CPUs without cpuid or with cpuid not yet enabled can be detected |
| 54 | * by the fact that they preserve the flags across the division of 5/2. |
| 55 | * PII and PPro exhibit this behavior too, but they have cpuid available. |
| 56 | */ |
Stefan Reinauer | 14e2277 | 2010-04-27 06:56:47 +0000 | [diff] [blame] | 57 | |
Eric Biederman | b78c197 | 2004-10-14 20:54:17 +0000 | [diff] [blame] | 58 | /* |
| 59 | * Perform the Cyrix 5/2 test. A Cyrix won't change |
| 60 | * the flags, while other 486 chips will. |
| 61 | */ |
| 62 | static inline int test_cyrix_52div(void) |
| 63 | { |
| 64 | unsigned int test; |
| 65 | |
| 66 | __asm__ __volatile__( |
| 67 | "sahf\n\t" /* clear flags (%eax = 0x0005) */ |
| 68 | "div %b2\n\t" /* divide 5 by 2 */ |
| 69 | "lahf" /* store flags into %ah */ |
| 70 | : "=a" (test) |
| 71 | : "0" (5), "q" (2) |
| 72 | : "cc"); |
| 73 | |
| 74 | /* AH is 0x02 on Cyrix after the divide.. */ |
| 75 | return (unsigned char) (test >> 8) == 0x02; |
| 76 | } |
| 77 | |
| 78 | /* |
| 79 | * Detect a NexGen CPU running without BIOS hypercode new enough |
| 80 | * to have CPUID. (Thanks to Herbert Oppmann) |
| 81 | */ |
Stefan Reinauer | 14e2277 | 2010-04-27 06:56:47 +0000 | [diff] [blame] | 82 | |
Eric Biederman | b78c197 | 2004-10-14 20:54:17 +0000 | [diff] [blame] | 83 | static int deep_magic_nexgen_probe(void) |
| 84 | { |
| 85 | int ret; |
Stefan Reinauer | 14e2277 | 2010-04-27 06:56:47 +0000 | [diff] [blame] | 86 | |
Eric Biederman | b78c197 | 2004-10-14 20:54:17 +0000 | [diff] [blame] | 87 | __asm__ __volatile__ ( |
| 88 | " movw $0x5555, %%ax\n" |
| 89 | " xorw %%dx,%%dx\n" |
| 90 | " movw $2, %%cx\n" |
| 91 | " divw %%cx\n" |
| 92 | " movl $0, %%eax\n" |
| 93 | " jnz 1f\n" |
| 94 | " movl $1, %%eax\n" |
Stefan Reinauer | 14e2277 | 2010-04-27 06:56:47 +0000 | [diff] [blame] | 95 | "1:\n" |
Eric Biederman | b78c197 | 2004-10-14 20:54:17 +0000 | [diff] [blame] | 96 | : "=a" (ret) : : "cx", "dx" ); |
| 97 | return ret; |
| 98 | } |
Stefan Reinauer | 9693885 | 2015-06-18 01:23:48 -0700 | [diff] [blame] | 99 | #endif |
Eric Biederman | b78c197 | 2004-10-14 20:54:17 +0000 | [diff] [blame] | 100 | |
Elyes HAOUAS | 777ea89 | 2016-07-29 07:40:41 +0200 | [diff] [blame] | 101 | /* List of CPU vendor strings along with their normalized |
Eric Biederman | b78c197 | 2004-10-14 20:54:17 +0000 | [diff] [blame] | 102 | * id values. |
| 103 | */ |
| 104 | static struct { |
| 105 | int vendor; |
| 106 | const char *name; |
| 107 | } x86_vendors[] = { |
| 108 | { X86_VENDOR_INTEL, "GenuineIntel", }, |
| 109 | { X86_VENDOR_CYRIX, "CyrixInstead", }, |
Stefan Reinauer | 14e2277 | 2010-04-27 06:56:47 +0000 | [diff] [blame] | 110 | { X86_VENDOR_AMD, "AuthenticAMD", }, |
Eric Biederman | b78c197 | 2004-10-14 20:54:17 +0000 | [diff] [blame] | 111 | { X86_VENDOR_UMC, "UMC UMC UMC ", }, |
| 112 | { X86_VENDOR_NEXGEN, "NexGenDriven", }, |
| 113 | { X86_VENDOR_CENTAUR, "CentaurHauls", }, |
Martin Roth | e369010 | 2016-01-06 15:21:02 -0700 | [diff] [blame] | 114 | { X86_VENDOR_RISE, "RiseRiseRise", }, |
| 115 | { X86_VENDOR_TRANSMETA, "GenuineTMx86", }, |
Eric Biederman | b78c197 | 2004-10-14 20:54:17 +0000 | [diff] [blame] | 116 | { X86_VENDOR_TRANSMETA, "TransmetaCPU", }, |
| 117 | { X86_VENDOR_NSC, "Geode by NSC", }, |
| 118 | { X86_VENDOR_SIS, "SiS SiS SiS ", }, |
| 119 | }; |
| 120 | |
| 121 | static const char *x86_vendor_name[] = { |
| 122 | [X86_VENDOR_INTEL] = "Intel", |
| 123 | [X86_VENDOR_CYRIX] = "Cyrix", |
| 124 | [X86_VENDOR_AMD] = "AMD", |
| 125 | [X86_VENDOR_UMC] = "UMC", |
| 126 | [X86_VENDOR_NEXGEN] = "NexGen", |
| 127 | [X86_VENDOR_CENTAUR] = "Centaur", |
| 128 | [X86_VENDOR_RISE] = "Rise", |
| 129 | [X86_VENDOR_TRANSMETA] = "Transmeta", |
| 130 | [X86_VENDOR_NSC] = "NSC", |
| 131 | [X86_VENDOR_SIS] = "SiS", |
| 132 | }; |
| 133 | |
| 134 | static const char *cpu_vendor_name(int vendor) |
| 135 | { |
| 136 | const char *name; |
Elyes HAOUAS | 777ea89 | 2016-07-29 07:40:41 +0200 | [diff] [blame] | 137 | name = "<invalid CPU vendor>"; |
Carl-Daniel Hailfinger | 2ee6779 | 2008-10-01 12:52:52 +0000 | [diff] [blame] | 138 | if ((vendor < (ARRAY_SIZE(x86_vendor_name))) && |
Stefan Reinauer | 14e2277 | 2010-04-27 06:56:47 +0000 | [diff] [blame] | 139 | (x86_vendor_name[vendor] != 0)) |
Eric Biederman | b78c197 | 2004-10-14 20:54:17 +0000 | [diff] [blame] | 140 | { |
| 141 | name = x86_vendor_name[vendor]; |
| 142 | } |
| 143 | return name; |
| 144 | } |
| 145 | |
| 146 | static void identify_cpu(struct device *cpu) |
| 147 | { |
| 148 | char vendor_name[16]; |
Eric Biederman | b78c197 | 2004-10-14 20:54:17 +0000 | [diff] [blame] | 149 | int i; |
| 150 | |
| 151 | vendor_name[0] = '\0'; /* Unset */ |
Eric Biederman | b78c197 | 2004-10-14 20:54:17 +0000 | [diff] [blame] | 152 | |
Stefan Reinauer | 9693885 | 2015-06-18 01:23:48 -0700 | [diff] [blame] | 153 | #ifndef __x86_64__ |
Eric Biederman | b78c197 | 2004-10-14 20:54:17 +0000 | [diff] [blame] | 154 | /* Find the id and vendor_name */ |
Rudolf Marek | 06253cd | 2012-02-25 23:51:12 +0100 | [diff] [blame] | 155 | if (!cpu_have_cpuid()) { |
Eric Biederman | b78c197 | 2004-10-14 20:54:17 +0000 | [diff] [blame] | 156 | /* Its a 486 if we can modify the AC flag */ |
| 157 | if (flag_is_changeable_p(X86_EFLAGS_AC)) { |
| 158 | cpu->device = 0x00000400; /* 486 */ |
| 159 | } else { |
| 160 | cpu->device = 0x00000300; /* 386 */ |
| 161 | } |
| 162 | if ((cpu->device == 0x00000400) && test_cyrix_52div()) { |
| 163 | memcpy(vendor_name, "CyrixInstead", 13); |
| 164 | /* If we ever care we can enable cpuid here */ |
| 165 | } |
| 166 | /* Detect NexGen with old hypercode */ |
| 167 | else if (deep_magic_nexgen_probe()) { |
| 168 | memcpy(vendor_name, "NexGenDriven", 13); |
| 169 | } |
| 170 | } |
Stefan Reinauer | 9693885 | 2015-06-18 01:23:48 -0700 | [diff] [blame] | 171 | #endif |
Rudolf Marek | 06253cd | 2012-02-25 23:51:12 +0100 | [diff] [blame] | 172 | if (cpu_have_cpuid()) { |
Stefan Reinauer | 4b556a1 | 2009-05-26 12:33:06 +0000 | [diff] [blame] | 173 | int cpuid_level; |
Eric Biederman | b78c197 | 2004-10-14 20:54:17 +0000 | [diff] [blame] | 174 | struct cpuid_result result; |
| 175 | result = cpuid(0x00000000); |
| 176 | cpuid_level = result.eax; |
| 177 | vendor_name[ 0] = (result.ebx >> 0) & 0xff; |
| 178 | vendor_name[ 1] = (result.ebx >> 8) & 0xff; |
| 179 | vendor_name[ 2] = (result.ebx >> 16) & 0xff; |
| 180 | vendor_name[ 3] = (result.ebx >> 24) & 0xff; |
| 181 | vendor_name[ 4] = (result.edx >> 0) & 0xff; |
| 182 | vendor_name[ 5] = (result.edx >> 8) & 0xff; |
| 183 | vendor_name[ 6] = (result.edx >> 16) & 0xff; |
| 184 | vendor_name[ 7] = (result.edx >> 24) & 0xff; |
| 185 | vendor_name[ 8] = (result.ecx >> 0) & 0xff; |
| 186 | vendor_name[ 9] = (result.ecx >> 8) & 0xff; |
| 187 | vendor_name[10] = (result.ecx >> 16) & 0xff; |
| 188 | vendor_name[11] = (result.ecx >> 24) & 0xff; |
| 189 | vendor_name[12] = '\0'; |
Stefan Reinauer | 14e2277 | 2010-04-27 06:56:47 +0000 | [diff] [blame] | 190 | |
Eric Biederman | b78c197 | 2004-10-14 20:54:17 +0000 | [diff] [blame] | 191 | /* Intel-defined flags: level 0x00000001 */ |
| 192 | if (cpuid_level >= 0x00000001) { |
| 193 | cpu->device = cpuid_eax(0x00000001); |
| 194 | } |
| 195 | else { |
| 196 | /* Have CPUID level 0 only unheard of */ |
| 197 | cpu->device = 0x00000400; |
| 198 | } |
| 199 | } |
| 200 | cpu->vendor = X86_VENDOR_UNKNOWN; |
Elyes HAOUAS | dbf3067 | 2016-08-21 17:37:15 +0200 | [diff] [blame] | 201 | for (i = 0; i < ARRAY_SIZE(x86_vendors); i++) { |
Eric Biederman | b78c197 | 2004-10-14 20:54:17 +0000 | [diff] [blame] | 202 | if (memcmp(vendor_name, x86_vendors[i].name, 12) == 0) { |
| 203 | cpu->vendor = x86_vendors[i].vendor; |
| 204 | break; |
| 205 | } |
| 206 | } |
| 207 | } |
| 208 | |
Stefan Reinauer | 6293d30 | 2012-04-03 16:07:56 -0700 | [diff] [blame] | 209 | struct cpu_driver *find_cpu_driver(struct device *cpu) |
Eric Biederman | b78c197 | 2004-10-14 20:54:17 +0000 | [diff] [blame] | 210 | { |
| 211 | struct cpu_driver *driver; |
Aaron Durbin | 0375815 | 2015-09-03 17:23:08 -0500 | [diff] [blame] | 212 | for (driver = _cpu_drivers; driver < _ecpu_drivers; driver++) { |
Eric Biederman | b78c197 | 2004-10-14 20:54:17 +0000 | [diff] [blame] | 213 | struct cpu_device_id *id; |
Stefan Reinauer | 6293d30 | 2012-04-03 16:07:56 -0700 | [diff] [blame] | 214 | for (id = driver->id_table; |
| 215 | id->vendor != X86_VENDOR_INVALID; id++) { |
Eric Biederman | b78c197 | 2004-10-14 20:54:17 +0000 | [diff] [blame] | 216 | if ((cpu->vendor == id->vendor) && |
Stefan Reinauer | 14e2277 | 2010-04-27 06:56:47 +0000 | [diff] [blame] | 217 | (cpu->device == id->device)) |
Eric Biederman | b78c197 | 2004-10-14 20:54:17 +0000 | [diff] [blame] | 218 | { |
Stefan Reinauer | 6293d30 | 2012-04-03 16:07:56 -0700 | [diff] [blame] | 219 | return driver; |
Eric Biederman | b78c197 | 2004-10-14 20:54:17 +0000 | [diff] [blame] | 220 | } |
Gerd Hoffmann | cbf3073 | 2013-05-31 09:23:26 +0200 | [diff] [blame] | 221 | if (X86_VENDOR_ANY == id->vendor) |
| 222 | return driver; |
Eric Biederman | b78c197 | 2004-10-14 20:54:17 +0000 | [diff] [blame] | 223 | } |
| 224 | } |
Stefan Reinauer | 6293d30 | 2012-04-03 16:07:56 -0700 | [diff] [blame] | 225 | return NULL; |
| 226 | } |
| 227 | |
| 228 | static void set_cpu_ops(struct device *cpu) |
| 229 | { |
| 230 | struct cpu_driver *driver = find_cpu_driver(cpu); |
| 231 | cpu->ops = driver ? driver->ops : NULL; |
Eric Biederman | b78c197 | 2004-10-14 20:54:17 +0000 | [diff] [blame] | 232 | } |
| 233 | |
Ronald G. Minnich | 8b93059 | 2012-06-05 14:41:27 -0700 | [diff] [blame] | 234 | void cpu_initialize(unsigned int index) |
Eric Biederman | 8ca8d76 | 2003-04-22 19:02:15 +0000 | [diff] [blame] | 235 | { |
| 236 | /* Because we busy wait at the printk spinlock. |
| 237 | * It is important to keep the number of printed messages |
| 238 | * from secondary cpus to a minimum, when debugging is |
| 239 | * disabled. |
| 240 | */ |
Eric Biederman | b78c197 | 2004-10-14 20:54:17 +0000 | [diff] [blame] | 241 | struct device *cpu; |
Sven Schnelle | 51676b1 | 2012-07-29 19:18:03 +0200 | [diff] [blame] | 242 | struct cpu_info *info; |
Yinghai Lu | d4b278c | 2006-10-04 20:46:15 +0000 | [diff] [blame] | 243 | struct cpuinfo_x86 c; |
Stefan Reinauer | 14e2277 | 2010-04-27 06:56:47 +0000 | [diff] [blame] | 244 | |
Sven Schnelle | 51676b1 | 2012-07-29 19:18:03 +0200 | [diff] [blame] | 245 | info = cpu_info(); |
Eric Biederman | 83b991a | 2003-10-11 06:20:25 +0000 | [diff] [blame] | 246 | |
Ronald G. Minnich | 8b93059 | 2012-06-05 14:41:27 -0700 | [diff] [blame] | 247 | printk(BIOS_INFO, "Initializing CPU #%d\n", index); |
Kyösti Mälkki | bc8c996 | 2012-07-10 10:19:40 +0300 | [diff] [blame] | 248 | |
Sven Schnelle | 51676b1 | 2012-07-29 19:18:03 +0200 | [diff] [blame] | 249 | cpu = info->cpu; |
| 250 | if (!cpu) { |
Elyes HAOUAS | 777ea89 | 2016-07-29 07:40:41 +0200 | [diff] [blame] | 251 | die("CPU: missing CPU device structure"); |
Sven Schnelle | 51676b1 | 2012-07-29 19:18:03 +0200 | [diff] [blame] | 252 | } |
Li-Ta Lo | 8cb91dc | 2004-03-26 18:34:48 +0000 | [diff] [blame] | 253 | |
Damien Zammit | 149c4c5 | 2015-11-28 21:27:05 +1100 | [diff] [blame] | 254 | if (cpu->initialized) |
| 255 | return; |
| 256 | |
Duncan Laurie | 8adf7a2 | 2013-06-10 10:34:20 -0700 | [diff] [blame] | 257 | post_log_path(cpu); |
| 258 | |
Elyes HAOUAS | 777ea89 | 2016-07-29 07:40:41 +0200 | [diff] [blame] | 259 | /* Find what type of CPU we are dealing with */ |
Yinghai Lu | 30b4abe | 2007-04-06 19:57:42 +0000 | [diff] [blame] | 260 | identify_cpu(cpu); |
Stefan Reinauer | c02b4fc | 2010-03-22 11:42:32 +0000 | [diff] [blame] | 261 | printk(BIOS_DEBUG, "CPU: vendor %s device %x\n", |
Yinghai Lu | 30b4abe | 2007-04-06 19:57:42 +0000 | [diff] [blame] | 262 | cpu_vendor_name(cpu->vendor), cpu->device); |
Li-Ta Lo | fd3f2d7 | 2004-05-12 16:34:46 +0000 | [diff] [blame] | 263 | |
Yinghai Lu | 30b4abe | 2007-04-06 19:57:42 +0000 | [diff] [blame] | 264 | get_fms(&c, cpu->device); |
Yinghai Lu | d4b278c | 2006-10-04 20:46:15 +0000 | [diff] [blame] | 265 | |
Stefan Reinauer | 5f5436f | 2010-04-25 20:42:02 +0000 | [diff] [blame] | 266 | printk(BIOS_DEBUG, "CPU: family %02x, model %02x, stepping %02x\n", |
| 267 | c.x86, c.x86_model, c.x86_mask); |
Stefan Reinauer | 14e2277 | 2010-04-27 06:56:47 +0000 | [diff] [blame] | 268 | |
Yinghai Lu | 30b4abe | 2007-04-06 19:57:42 +0000 | [diff] [blame] | 269 | /* Lookup the cpu's operations */ |
| 270 | set_cpu_ops(cpu); |
Yinghai Lu | d4b278c | 2006-10-04 20:46:15 +0000 | [diff] [blame] | 271 | |
Elyes HAOUAS | dbf3067 | 2016-08-21 17:37:15 +0200 | [diff] [blame] | 272 | if (!cpu->ops) { |
Yinghai Lu | 30b4abe | 2007-04-06 19:57:42 +0000 | [diff] [blame] | 273 | /* mask out the stepping and try again */ |
| 274 | cpu->device -= c.x86_mask; |
Steven J. Magnani | eccc357 | 2005-09-14 13:53:45 +0000 | [diff] [blame] | 275 | set_cpu_ops(cpu); |
Yinghai Lu | 30b4abe | 2007-04-06 19:57:42 +0000 | [diff] [blame] | 276 | cpu->device += c.x86_mask; |
Elyes HAOUAS | dbf3067 | 2016-08-21 17:37:15 +0200 | [diff] [blame] | 277 | if (!cpu->ops) die("Unknown cpu"); |
Elyes HAOUAS | 777ea89 | 2016-07-29 07:40:41 +0200 | [diff] [blame] | 278 | printk(BIOS_DEBUG, "Using generic CPU ops (good)\n"); |
Ronald G. Minnich | 43225bc | 2005-11-22 00:07:02 +0000 | [diff] [blame] | 279 | } |
Stefan Reinauer | 14e2277 | 2010-04-27 06:56:47 +0000 | [diff] [blame] | 280 | |
Sven Schnelle | 51676b1 | 2012-07-29 19:18:03 +0200 | [diff] [blame] | 281 | |
Elyes HAOUAS | 777ea89 | 2016-07-29 07:40:41 +0200 | [diff] [blame] | 282 | /* Initialize the CPU */ |
Yinghai Lu | 30b4abe | 2007-04-06 19:57:42 +0000 | [diff] [blame] | 283 | if (cpu->ops && cpu->ops->init) { |
| 284 | cpu->enabled = 1; |
| 285 | cpu->initialized = 1; |
| 286 | cpu->ops->init(cpu); |
| 287 | } |
Duncan Laurie | 8adf7a2 | 2013-06-10 10:34:20 -0700 | [diff] [blame] | 288 | post_log_clear(); |
Yinghai Lu | 30b4abe | 2007-04-06 19:57:42 +0000 | [diff] [blame] | 289 | |
Ronald G. Minnich | 8b93059 | 2012-06-05 14:41:27 -0700 | [diff] [blame] | 290 | printk(BIOS_INFO, "CPU #%d initialized\n", index); |
Yinghai Lu | 30b4abe | 2007-04-06 19:57:42 +0000 | [diff] [blame] | 291 | |
Eric Biederman | b78c197 | 2004-10-14 20:54:17 +0000 | [diff] [blame] | 292 | return; |
Eric Biederman | 8ca8d76 | 2003-04-22 19:02:15 +0000 | [diff] [blame] | 293 | } |
Aaron Durbin | f6ada1c | 2016-02-10 10:52:47 -0600 | [diff] [blame] | 294 | |
| 295 | void lb_arch_add_records(struct lb_header *header) |
| 296 | { |
Aaron Durbin | e0969ae | 2016-02-10 10:56:06 -0600 | [diff] [blame] | 297 | uint32_t freq_khz; |
| 298 | struct lb_tsc_info *tsc_info; |
| 299 | |
| 300 | /* Don't advertise a TSC rate unless it's constant. */ |
| 301 | if (!IS_ENABLED(CONFIG_TSC_CONSTANT_RATE)) |
| 302 | return; |
| 303 | |
| 304 | freq_khz = tsc_freq_mhz() * 1000; |
| 305 | |
| 306 | /* No use exposing a TSC frequency that is zero. */ |
| 307 | if (freq_khz == 0) |
| 308 | return; |
| 309 | |
| 310 | tsc_info = (void *)lb_new_record(header); |
| 311 | tsc_info->tag = LB_TAG_TSC_INFO; |
| 312 | tsc_info->size = sizeof(*tsc_info); |
| 313 | tsc_info->freq_khz = freq_khz; |
Aaron Durbin | f6ada1c | 2016-02-10 10:52:47 -0600 | [diff] [blame] | 314 | } |
Aaron Durbin | b21e362 | 2016-12-07 00:32:19 -0600 | [diff] [blame^] | 315 | |
| 316 | void arch_bootstate_coreboot_exit(void) |
| 317 | { |
| 318 | /* APs are already parked by existing infrastructure. */ |
| 319 | if (!IS_ENABLED(CONFIG_PARALLEL_MP_AP_WORK)) |
| 320 | return; |
| 321 | |
| 322 | /* APs are waiting for work. Last thing to do is park them. */ |
| 323 | if (mp_park_aps()) |
| 324 | printk(BIOS_ERR, "Parking APs failed.\n"); |
| 325 | } |