| 1 |
|
| 2 |
|
| 3 |
#include <console/console.h> |
| 4 |
#include <cpu/intel/microcode.h> |
| 5 |
#include <cpu/intel/smm_reloc.h> |
| 6 |
#include <cpu/intel/common/common.h> |
| 7 |
#include <cpu/x86/legacy_save_state.h> |
| 8 |
#include <cpu/x86/mtrr.h> |
| 9 |
#include <cpu/x86/mp.h> |
| 10 |
#include <device/device.h> |
| 11 |
#include <device/pci_ops.h> |
| 12 |
#include <types.h> |
| 13 |
|
| 14 |
|
| 15 |
static void pre_mp_init(void) |
| 16 |
{ |
| 17 |
const void *patch = intel_microcode_find(); |
| 18 |
intel_microcode_load_unlocked(patch); |
| 19 |
|
| 20 |
|
| 21 |
x86_setup_mtrrs_with_detect(); |
| 22 |
x86_mtrr_check(); |
| 23 |
} |
| 24 |
|
| 25 |
static int get_cpu_count(void) |
| 26 |
{ |
| 27 |
return CONFIG_MAX_CPUS; |
| 28 |
} |
| 29 |
|
| 30 |
static void get_microcode_info(const void **microcode, int *parallel) |
| 31 |
{ |
| 32 |
*microcode = intel_microcode_find(); |
| 33 |
*parallel = !intel_ht_supported(); |
| 34 |
} |
| 35 |
|
| 36 |
static void pre_mp_smm_init(void) |
| 37 |
{ |
| 38 |
|
| 39 |
smm_southbridge_clear_state(); |
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
|
| 45 |
smm_initiate_relocation(); |
| 46 |
} |
| 47 |
|
| 48 |
static void get_smm_info(uintptr_t *perm_smbase, size_t *perm_smsize, |
| 49 |
size_t *smm_save_state_size) |
| 50 |
{ |
| 51 |
printk(BIOS_DEBUG, "Setting up SMI for CPU\n"); |
| 52 |
|
| 53 |
smm_open(); |
| 54 |
|
| 55 |
smm_subregion(SMM_SUBREGION_HANDLER, perm_smbase, perm_smsize); |
| 56 |
|
| 57 |
*smm_save_state_size = sizeof(legacy_smm_state_save_area_t); |
| 58 |
printk(BIOS_DEBUG, "Save state size: 0x%zx bytes\n", *smm_save_state_size); |
| 59 |
} |
| 60 |
|
| 61 |
|
| 62 |
|
| 63 |
|
| 64 |
|
| 65 |
|
| 66 |
static void relocation_handler(int cpu, uintptr_t curr_smbase, uintptr_t staggered_smbase) |
| 67 |
{ |
| 68 |
legacy_smm_state_save_area_t *save_state; |
| 69 |
u32 smbase = staggered_smbase; |
| 70 |
|
| 71 |
save_state = (void *)(curr_smbase + SMM_DEFAULT_SIZE - sizeof(*save_state)); |
| 72 |
save_state->smbase = smbase; |
| 73 |
|
| 74 |
printk(BIOS_DEBUG, "In relocation handler: cpu %d\n", cpu); |
| 75 |
printk(BIOS_DEBUG, "SMM revision: 0x%08x\n", save_state->smm_revision); |
| 76 |
printk(BIOS_DEBUG, "New SMBASE=0x%08x\n", smbase); |
| 77 |
} |
| 78 |
|
| 79 |
static void post_mp_init(void) |
| 80 |
{ |
| 81 |
smm_close(); |
| 82 |
|
| 83 |
|
| 84 |
global_smi_enable(); |
| 85 |
|
| 86 |
|
| 87 |
smm_lock(); |
| 88 |
} |
| 89 |
|
| 90 |
static const struct mp_ops mp_ops = { |
| 91 |
.pre_mp_init = pre_mp_init, |
| 92 |
.get_cpu_count = get_cpu_count, |
| 93 |
.get_smm_info = get_smm_info, |
| 94 |
.get_microcode_info = get_microcode_info, |
| 95 |
.pre_mp_smm_init = pre_mp_smm_init, |
| 96 |
|
| 97 |
.relocation_handler = relocation_handler, |
| 98 |
.post_mp_init = post_mp_init, |
| 99 |
}; |
| 100 |
|
| 101 |
void mp_init_cpus(struct bus *cpu_bus) |
| 102 |
{ |
| 103 |
|
| 104 |
mp_init_with_smm(cpu_bus, &mp_ops); |
| 105 |
} |