coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
model_16_init.c
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 
3 #include <commonlib/helpers.h>
4 #include <console/console.h>
5 #include <cpu/amd/microcode.h>
6 #include <cpu/x86/msr.h>
7 #include <cpu/amd/msr.h>
8 #include <cpu/x86/mtrr.h>
9 #include <cpu/amd/mtrr.h>
10 #include <device/device.h>
11 #include <device/pci.h>
12 #include <cpu/x86/pae.h>
13 #include <cpu/cpu.h>
14 #include <cpu/x86/cache.h>
15 #include <smp/node.h>
16 
17 static void model_16_init(struct device *dev)
18 {
19  printk(BIOS_DEBUG, "Model 16 Init.\n");
20 
21  msr_t msr;
22  u32 siblings;
23 
24  /* zero the machine check error status registers */
26 
27  if (CONFIG(LOGICAL_CPUS)) {
28  siblings = cpuid_ecx(0x80000008) & 0xff;
29 
30  if (siblings > 0) {
32  msr.lo |= 1 << 28;
34 
36  msr.hi |= 1 << (33 - 32);
38  }
39  printk(BIOS_DEBUG, "siblings = %02d, ", siblings);
40  }
41 
42  /* DisableCf8ExtCfg */
43  msr = rdmsr(NB_CFG_MSR);
44  msr.hi &= ~(1 << (46 - 32));
45  wrmsr(NB_CFG_MSR, msr);
46 
47  /* Write protect SMM space with SMMLOCK. */
48  msr = rdmsr(HWCR_MSR);
49  msr.lo |= (1 << 0);
50  wrmsr(HWCR_MSR, msr);
51 
53 
54  display_mtrrs();
55 }
56 
57 static struct device_operations cpu_dev_ops = {
59 };
60 
61 static const struct cpu_device_id cpu_table[] = {
62  { X86_VENDOR_AMD, 0x730F00 },
63  { X86_VENDOR_AMD, 0x730F01 },
64  { 0, 0 },
65 };
66 
67 static const struct cpu_driver model_16 __cpu_driver = {
68  .ops = &cpu_dev_ops,
69  .id_table = cpu_table,
70 };
static __always_inline void wrmsr_amd(unsigned int index, msr_t msr)
Definition: mtrr.h:60
static __always_inline msr_t rdmsr_amd(unsigned int index)
Definition: mtrr.h:49
static unsigned int cpuid_ecx(unsigned int op)
Definition: cpu.h:106
#define X86_VENDOR_AMD
Definition: cpu.h:140
#define printk(level,...)
Definition: stdlib.h:16
void amd_update_microcode_from_cbfs(void)
asmlinkage void display_mtrrs(void)
Definition: debug.c:186
@ CONFIG
Definition: dsi_common.h:201
#define CPU_ID_FEATURES_MSR
Definition: msr.h:65
#define NB_CFG_MSR
Definition: msr.h:19
#define CPU_ID_EXT_FEATURES_MSR
Definition: msr.h:66
#define HWCR_MSR
Definition: msr.h:17
static __always_inline msr_t rdmsr(unsigned int index)
Definition: msr.h:146
static void mca_clear_status(void)
Definition: msr.h:176
static __always_inline void wrmsr(unsigned int index, msr_t msr)
Definition: msr.h:157
#define BIOS_DEBUG
BIOS_DEBUG - Verbose output.
Definition: loglevel.h:128
static void model_16_init(struct device *dev)
Definition: model_16_init.c:17
static const struct cpu_driver model_16 __cpu_driver
Definition: model_16_init.c:67
static const struct cpu_device_id cpu_table[]
Definition: model_16_init.c:61
static struct device_operations cpu_dev_ops
Definition: model_16_init.c:57
uint32_t u32
Definition: stdint.h:51
Definition: cpu.h:13
struct device_operations * ops
Definition: cpu.h:14
void(* init)(struct device *dev)
Definition: device.h:42
Definition: device.h:107
unsigned int hi
Definition: msr.h:112
unsigned int lo
Definition: msr.h:111