diff options
Diffstat (limited to 'src/soc/intel/apollolake/romstage.c')
-rw-r--r-- | src/soc/intel/apollolake/romstage.c | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/src/soc/intel/apollolake/romstage.c b/src/soc/intel/apollolake/romstage.c index 6a2007e937..bccfc16ba6 100644 --- a/src/soc/intel/apollolake/romstage.c +++ b/src/soc/intel/apollolake/romstage.c @@ -27,6 +27,7 @@ #include <compiler.h> #include <console/console.h> #include <cpu/x86/mtrr.h> +#include <cpu/x86/pae.h> #include <device/pci_def.h> #include <device/resource.h> #include <intelblocks/lpc_lib.h> @@ -41,6 +42,7 @@ #include <reset.h> #include <soc/cpu.h> #include <soc/iomap.h> +#include <soc/meminit.h> #include <soc/systemagent.h> #include <soc/pci_devs.h> #include <soc/pm.h> @@ -246,6 +248,13 @@ asmlinkage void car_stage_entry(void) tseg_base = (uintptr_t)smm_base; postcar_frame_add_mtrr(&pcf, tseg_base, smm_size, MTRR_TYPE_WRBACK); + /* Ensure TSEG has mappings. */ + if (IS_ENABLED(CONFIG_PAGING_IN_CACHE_AS_RAM)) { + if (paging_identity_map_addr(tseg_base, smm_size, PAT_WB)) + printk(BIOS_ERR, "Unable to map TSEG: %lx--%lx\n", + tseg_base, tseg_base + smm_size); + } + run_postcar_phase(&pcf); } @@ -330,6 +339,40 @@ static void parse_devicetree_setting(FSPM_UPD *m_upd) #endif } +static void prepare_fspm_pages(void) +{ + const size_t mib128 = 128 * MiB; + uintptr_t base; + /* All in units of MiB */ + size_t mem_sz; + size_t iohole_sz; + size_t low_mem_sz; + + mem_sz = memory_in_system_in_mib(); + + if (!mem_sz) { + printk(BIOS_ERR, "No memory in system! FSP will hang...\n"); + return; + } + + iohole_sz = iohole_in_mib(); + + /* Mark pages as WB where FSP will write. One region will be in cbmem, + but it's not clear what else FSP is writing to. Try to make the best + calculation. */ + low_mem_sz = 4 * (GiB / MiB) - iohole_sz; + + if (low_mem_sz > mem_sz) + low_mem_sz = mem_sz; + + /* Assume all accesses are within 128MiB of the crude low memory + calculation above. */ + base = low_mem_sz * MiB - mib128; + if (paging_identity_map_addr(base, mib128, PAT_WB)) + printk(BIOS_ERR, "Unable to map %lx--%lx\n", base, + base + mib128); +} + void platform_fsp_memory_init_params_cb(FSPM_UPD *mupd, uint32_t version) { struct region_device rdev; @@ -382,6 +425,9 @@ void platform_fsp_memory_init_params_cb(FSPM_UPD *mupd, uint32_t version) } car_set_var(fsp_version, version); + + if (IS_ENABLED(CONFIG_PAGING_IN_CACHE_AS_RAM)) + prepare_fspm_pages(); } __weak |