{cpu/x86, drivers/amd}: Use `get_var_mtrr_count()` to get MTRR count
This patch replaces the implementation that is used to get the number of variable MTRRs with `get_var_mtrr_count()` function. BUG=b:225766934 TEST=Able to build and boot google/redrix board to ChromeOS. Signed-off-by: Subrata Banik <subratabanik@google.com> Change-Id: I4751add9c45374e60b7a425df87d06f52e6fcb8c Reviewed-on: https://review.coreboot.org/c/coreboot/+/63219 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Felix Held <felix-coreboot@felixheld.de> Reviewed-by: Arthur Heymans <arthur@aheymans.xyz> Reviewed-by: Eric Lai <eric_lai@quanta.corp-partner.google.com> Reviewed-by: Tim Wawrzynczak <twawrzynczak@chromium.org>
This commit is contained in:
parent
3ad00d0c89
commit
7578ea43ce
|
@ -247,11 +247,9 @@ static int save_bsp_msrs(char *start, int size)
|
||||||
int num_var_mtrrs;
|
int num_var_mtrrs;
|
||||||
struct saved_msr *msr_entry;
|
struct saved_msr *msr_entry;
|
||||||
int i;
|
int i;
|
||||||
msr_t msr;
|
|
||||||
|
|
||||||
/* Determine number of MTRRs need to be saved. */
|
/* Determine number of MTRRs need to be saved. */
|
||||||
msr = rdmsr(MTRR_CAP_MSR);
|
num_var_mtrrs = get_var_mtrr_count();
|
||||||
num_var_mtrrs = msr.lo & 0xff;
|
|
||||||
|
|
||||||
/* 2 * num_var_mtrrs for base and mask. +1 for IA32_MTRR_DEF_TYPE. */
|
/* 2 * num_var_mtrrs for base and mask. +1 for IA32_MTRR_DEF_TYPE. */
|
||||||
msr_count = 2 * num_var_mtrrs + NUM_FIXED_MTRRS + 1;
|
msr_count = 2 * num_var_mtrrs + NUM_FIXED_MTRRS + 1;
|
||||||
|
|
|
@ -41,11 +41,7 @@ static int total_mtrrs;
|
||||||
|
|
||||||
static void detect_var_mtrrs(void)
|
static void detect_var_mtrrs(void)
|
||||||
{
|
{
|
||||||
msr_t msr;
|
total_mtrrs = get_var_mtrr_count();
|
||||||
|
|
||||||
msr = rdmsr(MTRR_CAP_MSR);
|
|
||||||
|
|
||||||
total_mtrrs = msr.lo & 0xff;
|
|
||||||
|
|
||||||
if (total_mtrrs > NUM_MTRR_STATIC_STORAGE) {
|
if (total_mtrrs > NUM_MTRR_STATIC_STORAGE) {
|
||||||
printk(BIOS_WARNING,
|
printk(BIOS_WARNING,
|
||||||
|
|
|
@ -14,8 +14,7 @@
|
||||||
the MTRR, no matter the caching type, are filled and not overlapping. */
|
the MTRR, no matter the caching type, are filled and not overlapping. */
|
||||||
static uint32_t max_cache_used(void)
|
static uint32_t max_cache_used(void)
|
||||||
{
|
{
|
||||||
msr_t msr = rdmsr(MTRR_CAP_MSR);
|
int i, total_mtrrs = get_var_mtrr_count();
|
||||||
int i, total_mtrrs = msr.lo & MTRR_CAP_VCNT;
|
|
||||||
uint32_t total_cache = 0;
|
uint32_t total_cache = 0;
|
||||||
|
|
||||||
for (i = 0; i < total_mtrrs; i++) {
|
for (i = 0; i < total_mtrrs; i++) {
|
||||||
|
|
|
@ -14,8 +14,7 @@ static void set_range_uc(u32 base, u32 size)
|
||||||
{
|
{
|
||||||
int i, max_var_mtrrs;
|
int i, max_var_mtrrs;
|
||||||
msr_t msr;
|
msr_t msr;
|
||||||
msr = rdmsr(MTRR_CAP_MSR);
|
max_var_mtrrs = get_var_mtrr_count();
|
||||||
max_var_mtrrs = msr.lo & MTRR_CAP_VCNT;
|
|
||||||
|
|
||||||
for (i = 0; i < max_var_mtrrs; i++) {
|
for (i = 0; i < max_var_mtrrs; i++) {
|
||||||
msr = rdmsr(MTRR_PHYS_MASK(i));
|
msr = rdmsr(MTRR_PHYS_MASK(i));
|
||||||
|
|
Loading…
Reference in New Issue