Kyösti Mälkki (kyosti.malkki@gmail.com) just uploaded a new patch set to gerrit, which you can find at https://review.coreboot.org/17700
-gerrit
commit 15a71c351d159c2f24b1b8146e97719edf7d373a Author: Kyösti Mälkki kyosti.malkki@gmail.com Date: Fri Dec 2 19:47:07 2016 +0200
postcar_loader: Support LATE_CBMEM_INIT boards
Create postcar_frame object without placing stack in CBMEM. This way same cache_as_ram.inc code can be used unmodified.
Change-Id: Ic5ed404ce268ee881e9893dd434534231aa2bc88 Signed-off-by: Kyösti Mälkki kyosti.malkki@gmail.com --- src/arch/x86/include/arch/cpu.h | 5 +++++ src/arch/x86/postcar_loader.c | 31 +++++++++++++++++++++---------- 2 files changed, 26 insertions(+), 10 deletions(-)
diff --git a/src/arch/x86/include/arch/cpu.h b/src/arch/x86/include/arch/cpu.h index faa2375..d33bb92 100644 --- a/src/arch/x86/include/arch/cpu.h +++ b/src/arch/x86/include/arch/cpu.h @@ -268,6 +268,11 @@ struct postcar_frame { int postcar_frame_init(struct postcar_frame *pcf, size_t stack_size);
/* + * Initialize postcar_frame object with a fixed stacktop in low memory. + */ +void postcar_frame_init_lowmem(struct postcar_frame *pcf); + +/* * Add variable MTRR covering the provided range with MTRR type. */ void postcar_frame_add_mtrr(struct postcar_frame *pcf, diff --git a/src/arch/x86/postcar_loader.c b/src/arch/x86/postcar_loader.c index 948e445..11d05b4 100644 --- a/src/arch/x86/postcar_loader.c +++ b/src/arch/x86/postcar_loader.c @@ -32,13 +32,20 @@ static inline void stack_push(struct postcar_frame *pcf, uint32_t val) *ptr = val; }
-int postcar_frame_init(struct postcar_frame *pcf, size_t stack_size) +static void postcar_frame_prepare(struct postcar_frame *pcf) { - void *stack; msr_t msr; - msr = rdmsr(MTRR_CAP_MSR);
+ pcf->upper_mask = (1 << (cpu_phys_address_size() - 32)) - 1; + pcf->max_var_mttrs = msr.lo & MTRR_CAP_VCNT; + pcf->num_var_mttrs = 0; +} + +int postcar_frame_init(struct postcar_frame *pcf, size_t stack_size) +{ + void *stack; + stack = cbmem_add(CBMEM_ID_ROMSTAGE_RAM_STACK, stack_size); if (stack == NULL) { printk(BIOS_ERR, "Couldn't add %zd byte stack in cbmem.\n", @@ -46,18 +53,22 @@ int postcar_frame_init(struct postcar_frame *pcf, size_t stack_size) return -1; }
+ postcar_frame_prepare(pcf); pcf->stack = (uintptr_t)stack; pcf->stack += stack_size; - - pcf->upper_mask = (1 << (cpu_phys_address_size() - 32)) - 1; - - pcf->max_var_mttrs = msr.lo & MTRR_CAP_VCNT; - - pcf->num_var_mttrs = 0; - return 0; }
+/* + * For use with LATE_CBMEM_INIT boards only, with a fixed stacktop in + * low memory. + */ +void postcar_frame_init_lowmem(struct postcar_frame *pcf) +{ + postcar_frame_prepare(pcf); + pcf->stack = CONFIG_RAMTOP; +} + void postcar_frame_add_mtrr(struct postcar_frame *pcf, uintptr_t addr, size_t size, int type) {