[coreboot-gerrit] New patch to review for coreboot: cpu/x86/mtrr: add helper function to detect variable MTRRs

Aaron Durbin (adurbin@chromium.org) gerrit at coreboot.org
Mon Mar 7 23:11:14 CET 2016


Aaron Durbin (adurbin at chromium.org) just uploaded a new patch set to gerrit, which you can find at https://review.coreboot.org/13935

-gerrit

commit f07430055284cd9c3d31163725f70a2edefbb56d
Author: Aaron Durbin <adurbin at chromium.org>
Date:   Mon Mar 7 16:05:36 2016 -0600

    cpu/x86/mtrr: add helper function to detect variable MTRRs
    
    The current MTRR API doesn't allow one to detect variable MTRRs
    along with handling fixed MTRRs in one function call. Therefore,
    add x86_setup_mtrrs_with_detect() to perform the same actions
    as x86_setup_mtrrs() but always do the dynamic detection.
    
    Change-Id: I443909691afa28ce11882e2beab12e836e5bcb3d
    Signed-off-by: Aaron Durbin <adurbin at chromium.org>
---
 src/cpu/x86/mtrr/mtrr.c    | 22 +++++++++++++++++++---
 src/include/cpu/x86/mtrr.h |  7 +++++++
 2 files changed, 26 insertions(+), 3 deletions(-)

diff --git a/src/cpu/x86/mtrr/mtrr.c b/src/cpu/x86/mtrr/mtrr.c
index efd0b68..84e005a 100644
--- a/src/cpu/x86/mtrr/mtrr.c
+++ b/src/cpu/x86/mtrr/mtrr.c
@@ -801,13 +801,29 @@ void x86_setup_var_mtrrs(unsigned int address_bits, unsigned int above4gb)
 	commit_var_mtrrs(sol);
 }
 
-void x86_setup_mtrrs(void)
+static void __x86_setup_mtrrs(int above4gb)
 {
 	int address_size;
+
 	x86_setup_fixed_mtrrs();
 	address_size = cpu_phys_address_size();
-	printk(BIOS_DEBUG, "CPU physical address size: %d bits\n", address_size);
-	x86_setup_var_mtrrs(address_size, 1);
+	printk(BIOS_DEBUG, "CPU physical address size: %d bits\n",
+		address_size);
+	/* Always handle addresses above 4GiB. */
+	x86_setup_var_mtrrs(address_size, above4gb);
+}
+
+void x86_setup_mtrrs(void)
+{
+	/* Handle addresses above 4GiB, but don't detect number of variable
+	 * MTRRs. */
+	__x86_setup_mtrrs(1);
+}
+
+void x86_setup_mtrrs_with_detect(void)
+{
+	/* Handle addresses above 4GiB, but detect number of variable MTRRs. */
+	__x86_setup_mtrrs(2);
 }
 
 void x86_mtrr_check(void)
diff --git a/src/include/cpu/x86/mtrr.h b/src/include/cpu/x86/mtrr.h
index 8fd4261..5a92ea3 100644
--- a/src/include/cpu/x86/mtrr.h
+++ b/src/include/cpu/x86/mtrr.h
@@ -56,9 +56,16 @@
  *    of the nature of the global MTRR enable flag. Therefore, all direct
  *    or indirect callers of enable_fixed_mtrr() should ensure that the
  *    variable MTRR MSRs do not contain bad ranges.
+ *
+ * Note that this function sets up MTRRs for addresses above 4GiB.
  */
 void x86_setup_mtrrs(void);
 /*
+ * x86_setup_mtrrs_with_detect() does the same thing as x86_setup_mtrrs(), but
+ * it always dynamically detects the number of variable MTRRs available.
+ */
+void x86_setup_mtrrs_with_detect(void);
+/*
  * x86_setup_var_mtrrs() parameters:
  * address_bits - number of physical address bits supported by cpu
  * above4gb - 2 means dynamically detect number of variable MTRRs available.



More information about the coreboot-gerrit mailing list