soc/amd/common/cpu/noncar/early_cache: use get_top_of_mem_below_4gb
Use get_top_of_mem_below_4gb instead of open-coding the functionality. Signed-off-by: Felix Held <felix-coreboot@felixheld.de> Change-Id: Icc9e5ad8954c6203fc4762aa976bba7e8ea16159 Reviewed-on: https://review.coreboot.org/c/coreboot/+/74615 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Jason Glenesk <jason.glenesk@gmail.com>
This commit is contained in:
@@ -20,7 +20,6 @@
|
|||||||
*/
|
*/
|
||||||
void early_cache_setup(void)
|
void early_cache_setup(void)
|
||||||
{
|
{
|
||||||
msr_t top_mem;
|
|
||||||
msr_t sys_cfg;
|
msr_t sys_cfg;
|
||||||
msr_t mtrr_def_type;
|
msr_t mtrr_def_type;
|
||||||
msr_t fixed_mtrr_ram;
|
msr_t fixed_mtrr_ram;
|
||||||
@@ -34,7 +33,6 @@ void early_cache_setup(void)
|
|||||||
|
|
||||||
var_mtrr_context_init(&mtrr_ctx.ctx);
|
var_mtrr_context_init(&mtrr_ctx.ctx);
|
||||||
mtrr_ctx.ctx.max_var_mtrrs = MIN(MAX_VAR_MTRR_USE, mtrr_ctx.ctx.max_var_mtrrs);
|
mtrr_ctx.ctx.max_var_mtrrs = MIN(MAX_VAR_MTRR_USE, mtrr_ctx.ctx.max_var_mtrrs);
|
||||||
top_mem = rdmsr(TOP_MEM);
|
|
||||||
/* Enable RdDram and WrDram attributes in fixed MTRRs. */
|
/* Enable RdDram and WrDram attributes in fixed MTRRs. */
|
||||||
sys_cfg = rdmsr(SYSCFG_MSR);
|
sys_cfg = rdmsr(SYSCFG_MSR);
|
||||||
sys_cfg.lo |= SYSCFG_MSR_MtrrFixDramModEn;
|
sys_cfg.lo |= SYSCFG_MSR_MtrrFixDramModEn;
|
||||||
@@ -61,7 +59,8 @@ void early_cache_setup(void)
|
|||||||
|
|
||||||
wrmsr(SYSCFG_MSR, sys_cfg);
|
wrmsr(SYSCFG_MSR, sys_cfg);
|
||||||
|
|
||||||
var_mtrr_set(&mtrr_ctx.ctx, 0, ALIGN_DOWN(top_mem.lo, 8 * MiB), MTRR_TYPE_WRBACK);
|
var_mtrr_set(&mtrr_ctx.ctx, 0, ALIGN_DOWN(get_top_of_mem_below_4gb(), 8 * MiB),
|
||||||
|
MTRR_TYPE_WRBACK);
|
||||||
/* Always mark the 16 MByte right below the 4 GB boundary as WRPROT */
|
/* Always mark the 16 MByte right below the 4 GB boundary as WRPROT */
|
||||||
var_mtrr_set(&mtrr_ctx.ctx, FLASH_BELOW_4GB_MAPPING_REGION_BASE,
|
var_mtrr_set(&mtrr_ctx.ctx, FLASH_BELOW_4GB_MAPPING_REGION_BASE,
|
||||||
FLASH_BELOW_4GB_MAPPING_REGION_SIZE, MTRR_TYPE_WRPROT);
|
FLASH_BELOW_4GB_MAPPING_REGION_SIZE, MTRR_TYPE_WRPROT);
|
||||||
|
Reference in New Issue
Block a user