| 1 |
|
| 2 |
|
| 3 |
#include <cpu/intel/common/common.h> |
| 4 |
#include <cpu/intel/smm_reloc.h> |
| 5 |
#include <cpu/intel/turbo.h> |
| 6 |
#include <cpu/x86/mp.h> |
| 7 |
#include <cpu/x86/msr.h> |
| 8 |
#include <cpu/x86/smm.h> |
| 9 |
#include <device/device.h> |
| 10 |
#include <intelblocks/cpulib.h> |
| 11 |
#include <intelblocks/mp_init.h> |
| 12 |
#include <intelblocks/msr.h> |
| 13 |
#include <soc/msr.h> |
| 14 |
#include <soc/soc_chip.h> |
| 15 |
#include <static.h> |
| 16 |
|
| 17 |
static void configure_misc(void) |
| 18 |
{ |
| 19 |
msr_t msr; |
| 20 |
config_t *conf = config_of_soc(); |
| 21 |
|
| 22 |
msr = rdmsr(IA32_MISC_ENABLE); |
| 23 |
msr.lo |= FAST_STRINGS_ENABLE_BIT; |
| 24 |
msr.lo |= (1 << 3); |
| 25 |
wrmsr(IA32_MISC_ENABLE, msr); |
| 26 |
|
| 27 |
cpu_set_eist(conf->eist_enable); |
| 28 |
|
| 29 |
msr.lo = 0; |
| 30 |
msr.hi = 0; |
| 31 |
wrmsr(IA32_THERM_INTERRUPT, msr); |
| 32 |
|
| 33 |
msr.lo = 1 << 4; |
| 34 |
msr.hi = 0; |
| 35 |
wrmsr(IA32_PACKAGE_THERM_INTERRUPT, msr); |
| 36 |
|
| 37 |
msr = rdmsr(MSR_POWER_CTL); |
| 38 |
msr.lo |= (1 << 0); |
| 39 |
msr.lo |= (1 << 23); |
| 40 |
wrmsr(MSR_POWER_CTL, msr); |
| 41 |
} |
| 42 |
|
| 43 |
void soc_core_init(struct device *dev) |
| 44 |
{ |
| 45 |
|
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
mca_configure(); |
| 50 |
|
| 51 |
enable_lapic_tpr(); |
| 52 |
|
| 53 |
configure_misc(); |
| 54 |
|
| 55 |
configure_dca_cap(); |
| 56 |
|
| 57 |
set_energy_perf_bias(ENERGY_POLICY_NORMAL); |
| 58 |
|
| 59 |
enable_turbo(); |
| 60 |
} |
| 61 |
|
| 62 |
static void post_mp_init(void) |
| 63 |
{ |
| 64 |
cpu_set_max_ratio(); |
| 65 |
|
| 66 |
|
| 67 |
|
| 68 |
|
| 69 |
global_smi_enable(); |
| 70 |
} |
| 71 |
|
| 72 |
static const struct mp_ops mp_ops = { |
| 73 |
|
| 74 |
|
| 75 |
|
| 76 |
|
| 77 |
|
| 78 |
.get_cpu_count = get_cpu_count, |
| 79 |
#if CONFIG(HAVE_SMI_HANDLER) |
| 80 |
.get_smm_info = smm_info, |
| 81 |
#endif |
| 82 |
.get_microcode_info = get_microcode_info, |
| 83 |
.pre_mp_smm_init = smm_initialize, |
| 84 |
.per_cpu_smm_trigger = smm_relocate, |
| 85 |
.relocation_handler = smm_relocation_handler, |
| 86 |
.post_mp_init = post_mp_init, |
| 87 |
}; |
| 88 |
|
| 89 |
void mp_init_cpus(struct bus *cpu_bus) |
| 90 |
{ |
| 91 |
if (mp_init_with_smm(cpu_bus, &mp_ops)) |
| 92 |
die_with_post_code(POSTCODE_HW_INIT_FAILURE, "mp_init_with_smm failed!\n"); |
| 93 |
|
| 94 |
configure_tcc_thermal_target(); |
| 95 |
} |
| 96 |
|
| 97 |
bool cpu_soc_is_in_untrusted_mode(void) |
| 98 |
{ |
| 99 |
msr_t msr; |
| 100 |
|
| 101 |
msr = rdmsr(MSR_BIOS_DONE); |
| 102 |
return !!(msr.lo & ENABLE_IA_UNTRUSTED); |
| 103 |
} |