Subrata Banik has uploaded this change for review.

View Change

arch/x86: Add postcar_frame_add_ramcache() API

This patch adds new API for intermediate caching top_of_ram
and setting up required MTRR for next stage.

Change-Id: Iddafb573afb4799de64754a94816d7f3f2f4982f
Signed-off-by: Subrata Banik <subrata.banik@intel.com>
---
M src/arch/x86/include/arch/cpu.h
M src/arch/x86/postcar_loader.c
2 files changed, 30 insertions(+), 0 deletions(-)

git pull ssh://review.coreboot.org:29418/coreboot refs/changes/05/34805/1
diff --git a/src/arch/x86/include/arch/cpu.h b/src/arch/x86/include/arch/cpu.h
index 293ca02..7dc4049 100644
--- a/src/arch/x86/include/arch/cpu.h
+++ b/src/arch/x86/include/arch/cpu.h
@@ -329,6 +329,13 @@
void postcar_frame_add_romcache(struct postcar_frame *pcf, int type);

/*
+ * Add variable MTRR covering the Top of RAM with given MTRR type.
+ */
+void postcar_frame_add_ramcache(struct postcar_frame *pcf,
+ uintptr_t addr, size_t size, int type);
+
+
+/*
* Push used MTRR and Max MTRRs on to the stack
* and return pointer to stack top.
*/
diff --git a/src/arch/x86/postcar_loader.c b/src/arch/x86/postcar_loader.c
index 35e139f..8a1f6cb 100644
--- a/src/arch/x86/postcar_loader.c
+++ b/src/arch/x86/postcar_loader.c
@@ -120,6 +120,29 @@
postcar_frame_add_mtrr(pcf, CACHE_ROM_BASE, CACHE_ROM_SIZE, type);
}

+/*
+ * Make sure we are enabling intermediate caching to speed up next stage
+ * (postcar/romstage) loading and decompression as we are still in romstage
+ * and CAR tear down will be handled by next stage at its entry.
+ */
+static void enable_top_of_ram_cache(uintptr_t base, size_t size)
+{
+ int mtrr = get_free_var_mtrr();
+
+ if (mtrr == -1)
+ return;
+
+ set_var_mtrr(mtrr, base, size, MTRR_TYPE_WRPROT);
+}
+
+void postcar_frame_add_ramcache(struct postcar_frame *pcf,
+ uintptr_t addr, size_t size, int type)
+{
+ /* enable intermediate caching for Top of RAM */
+ enable_top_of_ram_cache(addr, size);
+ postcar_frame_add_mtrr(pcf, addr, size, type);
+}
+
void *postcar_commit_mtrrs(struct postcar_frame *pcf)
{
/*

To view, visit change 34805. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: coreboot
Gerrit-Branch: master
Gerrit-Change-Id: Iddafb573afb4799de64754a94816d7f3f2f4982f
Gerrit-Change-Number: 34805
Gerrit-PatchSet: 1
Gerrit-Owner: Subrata Banik <subrata.banik@intel.com>
Gerrit-MessageType: newchange