arch/x86: Add postcar_frame_common_mtrrs()
As most platforms will share the subset of enabling both low RAM WB and high ROM WP MTRRs, provide them with a single function. Add possibility for the platform to skip these if required. Change-Id: Id1f8b7682035e654231f6133a42909a36e3e15a1 Signed-off-by: Kyösti Mälkki <kyosti.malkki@gmail.com> Reviewed-on: https://review.coreboot.org/c/coreboot/+/34809 Reviewed-by: Aaron Durbin <adurbin@chromium.org> Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
This commit is contained in:
parent
5bc641afeb
commit
544878b563
|
@ -302,6 +302,7 @@ struct postcar_frame {
|
||||||
uint32_t upper_mask;
|
uint32_t upper_mask;
|
||||||
int max_var_mtrrs;
|
int max_var_mtrrs;
|
||||||
int num_var_mtrrs;
|
int num_var_mtrrs;
|
||||||
|
int skip_common_mtrr;
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -322,6 +323,11 @@ void postcar_frame_add_mtrr(struct postcar_frame *pcf,
|
||||||
*/
|
*/
|
||||||
void postcar_frame_add_romcache(struct postcar_frame *pcf, int type);
|
void postcar_frame_add_romcache(struct postcar_frame *pcf, int type);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Add a common MTRR setup most platforms will have as a subset.
|
||||||
|
*/
|
||||||
|
void postcar_frame_common_mtrrs(struct postcar_frame *pcf);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Push used MTRR and Max MTRRs on to the stack
|
* Push used MTRR and Max MTRRs on to the stack
|
||||||
* and return pointer to stack top.
|
* and return pointer to stack top.
|
||||||
|
|
|
@ -120,6 +120,18 @@ void postcar_frame_add_romcache(struct postcar_frame *pcf, int type)
|
||||||
postcar_frame_add_mtrr(pcf, CACHE_ROM_BASE, CACHE_ROM_SIZE, type);
|
postcar_frame_add_mtrr(pcf, CACHE_ROM_BASE, CACHE_ROM_SIZE, type);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void postcar_frame_common_mtrrs(struct postcar_frame *pcf)
|
||||||
|
{
|
||||||
|
if (pcf->skip_common_mtrr)
|
||||||
|
return;
|
||||||
|
|
||||||
|
/* Cache RAM as WB from 0 -> CACHE_TMP_RAMTOP. */
|
||||||
|
postcar_frame_add_mtrr(pcf, 0, CACHE_TMP_RAMTOP, MTRR_TYPE_WRBACK);
|
||||||
|
|
||||||
|
/* Cache the ROM as WP just below 4GiB. */
|
||||||
|
postcar_frame_add_romcache(pcf, MTRR_TYPE_WRPROT);
|
||||||
|
}
|
||||||
|
|
||||||
void *postcar_commit_mtrrs(struct postcar_frame *pcf)
|
void *postcar_commit_mtrrs(struct postcar_frame *pcf)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -33,6 +33,8 @@ static void prepare_and_run_postcar(struct postcar_frame *pcf)
|
||||||
|
|
||||||
fill_postcar_frame(pcf);
|
fill_postcar_frame(pcf);
|
||||||
|
|
||||||
|
postcar_frame_common_mtrrs(pcf);
|
||||||
|
|
||||||
run_postcar_phase(pcf);
|
run_postcar_phase(pcf);
|
||||||
/* We do not return here. */
|
/* We do not return here. */
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,13 +28,6 @@ void fill_postcar_frame(struct postcar_frame *pcf)
|
||||||
{
|
{
|
||||||
uintptr_t top_of_ram;
|
uintptr_t top_of_ram;
|
||||||
|
|
||||||
/* Cache the ROM as WP just below 4GiB. */
|
|
||||||
postcar_frame_add_mtrr(pcf, CACHE_ROM_BASE, CACHE_ROM_SIZE,
|
|
||||||
MTRR_TYPE_WRPROT);
|
|
||||||
|
|
||||||
/* Cache RAM as WB from 0 -> CACHE_TMP_RAMTOP. */
|
|
||||||
postcar_frame_add_mtrr(pcf, 0, CACHE_TMP_RAMTOP, MTRR_TYPE_WRBACK);
|
|
||||||
|
|
||||||
/* Cache at least 8 MiB below the top of ram, and at most 8 MiB
|
/* Cache at least 8 MiB below the top of ram, and at most 8 MiB
|
||||||
* above top of the ram. This satisfies MTRR alignment requirement
|
* above top of the ram. This satisfies MTRR alignment requirement
|
||||||
* with different TSEG size configurations. */
|
* with different TSEG size configurations. */
|
||||||
|
|
|
@ -54,6 +54,8 @@ void fill_postcar_frame(struct postcar_frame *pcf)
|
||||||
* operations when source is left as UC.
|
* operations when source is left as UC.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
pcf->skip_common_mtrr = 1;
|
||||||
|
|
||||||
/* Cache RAM as WB from 0 -> CACHE_TMP_RAMTOP. */
|
/* Cache RAM as WB from 0 -> CACHE_TMP_RAMTOP. */
|
||||||
postcar_frame_add_mtrr(pcf, 0, CACHE_TMP_RAMTOP, MTRR_TYPE_WRBACK);
|
postcar_frame_add_mtrr(pcf, 0, CACHE_TMP_RAMTOP, MTRR_TYPE_WRBACK);
|
||||||
|
|
||||||
|
|
|
@ -138,13 +138,6 @@ void fill_postcar_frame(struct postcar_frame *pcf)
|
||||||
{
|
{
|
||||||
uintptr_t top_of_ram;
|
uintptr_t top_of_ram;
|
||||||
|
|
||||||
|
|
||||||
/* Cache the ROM as WP just below 4GiB. */
|
|
||||||
postcar_frame_add_romcache(pcf, MTRR_TYPE_WRPROT);
|
|
||||||
|
|
||||||
/* Cache RAM as WB from 0 -> CACHE_TMP_RAMTOP. */
|
|
||||||
postcar_frame_add_mtrr(pcf, 0, CACHE_TMP_RAMTOP, MTRR_TYPE_WRBACK);
|
|
||||||
|
|
||||||
/* Cache 8 MiB region below the top of ram and 2 MiB above top of
|
/* Cache 8 MiB region below the top of ram and 2 MiB above top of
|
||||||
* ram to cover both cbmem as the TSEG region.
|
* ram to cover both cbmem as the TSEG region.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -57,12 +57,6 @@ void fill_postcar_frame(struct postcar_frame *pcf)
|
||||||
{
|
{
|
||||||
uintptr_t top_of_ram;
|
uintptr_t top_of_ram;
|
||||||
|
|
||||||
/* Cache the ROM as WP just below 4GiB. */
|
|
||||||
postcar_frame_add_romcache(pcf, MTRR_TYPE_WRPROT);
|
|
||||||
|
|
||||||
/* Cache RAM as WB from 0 -> CACHE_TMP_RAMTOP. */
|
|
||||||
postcar_frame_add_mtrr(pcf, 0, CACHE_TMP_RAMTOP, MTRR_TYPE_WRBACK);
|
|
||||||
|
|
||||||
/* Cache at least 8 MiB below the top of ram, and at most 8 MiB
|
/* Cache at least 8 MiB below the top of ram, and at most 8 MiB
|
||||||
* above top of the ram. This satisfies MTRR alignment requirement
|
* above top of the ram. This satisfies MTRR alignment requirement
|
||||||
* with different TSEG size configurations.
|
* with different TSEG size configurations.
|
||||||
|
|
|
@ -72,13 +72,6 @@ void fill_postcar_frame(struct postcar_frame *pcf)
|
||||||
{
|
{
|
||||||
uintptr_t top_of_ram;
|
uintptr_t top_of_ram;
|
||||||
|
|
||||||
|
|
||||||
/* Cache the ROM as WP just below 4GiB. */
|
|
||||||
postcar_frame_add_romcache(pcf, MTRR_TYPE_WRPROT);
|
|
||||||
|
|
||||||
/* Cache RAM as WB from 0 -> CACHE_TMP_RAMTOP. */
|
|
||||||
postcar_frame_add_mtrr(pcf, 0, CACHE_TMP_RAMTOP, MTRR_TYPE_WRBACK);
|
|
||||||
|
|
||||||
/* Cache CBMEM region as WB. */
|
/* Cache CBMEM region as WB. */
|
||||||
top_of_ram = (uintptr_t)cbmem_top();
|
top_of_ram = (uintptr_t)cbmem_top();
|
||||||
postcar_frame_add_mtrr(pcf, top_of_ram - 8*MiB, 8*MiB,
|
postcar_frame_add_mtrr(pcf, top_of_ram - 8*MiB, 8*MiB,
|
||||||
|
|
|
@ -104,13 +104,6 @@ void fill_postcar_frame(struct postcar_frame *pcf)
|
||||||
{
|
{
|
||||||
uintptr_t top_of_ram;
|
uintptr_t top_of_ram;
|
||||||
|
|
||||||
|
|
||||||
/* Cache the ROM as WP just below 4GiB. */
|
|
||||||
postcar_frame_add_romcache(pcf, MTRR_TYPE_WRPROT);
|
|
||||||
|
|
||||||
/* Cache RAM as WB from 0 -> CACHE_TMP_RAMTOP. */
|
|
||||||
postcar_frame_add_mtrr(pcf, 0, CACHE_TMP_RAMTOP, MTRR_TYPE_WRBACK);
|
|
||||||
|
|
||||||
/* Cache 8 MiB region below the top of ram and 2 MiB above top of
|
/* Cache 8 MiB region below the top of ram and 2 MiB above top of
|
||||||
* ram to cover both cbmem as the TSEG region.
|
* ram to cover both cbmem as the TSEG region.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -62,13 +62,6 @@ void fill_postcar_frame(struct postcar_frame *pcf)
|
||||||
{
|
{
|
||||||
uintptr_t top_of_ram;
|
uintptr_t top_of_ram;
|
||||||
|
|
||||||
|
|
||||||
/* Cache the ROM as WP just below 4GiB. */
|
|
||||||
postcar_frame_add_romcache(pcf, MTRR_TYPE_WRPROT);
|
|
||||||
|
|
||||||
/* Cache RAM as WB from 0 -> CACHE_TMP_RAMTOP. */
|
|
||||||
postcar_frame_add_mtrr(pcf, 0, CACHE_TMP_RAMTOP, MTRR_TYPE_WRBACK);
|
|
||||||
|
|
||||||
/* Cache at least 8 MiB below the top of ram, and at most 8 MiB
|
/* Cache at least 8 MiB below the top of ram, and at most 8 MiB
|
||||||
* above top of the ram. This satisfies MTRR alignment requirement
|
* above top of the ram. This satisfies MTRR alignment requirement
|
||||||
* with different TSEG size configurations.
|
* with different TSEG size configurations.
|
||||||
|
|
|
@ -154,13 +154,6 @@ void fill_postcar_frame(struct postcar_frame *pcf)
|
||||||
{
|
{
|
||||||
uintptr_t top_of_ram;
|
uintptr_t top_of_ram;
|
||||||
|
|
||||||
|
|
||||||
/* Cache the ROM as WP just below 4GiB. */
|
|
||||||
postcar_frame_add_romcache(pcf, MTRR_TYPE_WRPROT);
|
|
||||||
|
|
||||||
/* Cache RAM as WB from 0 -> CACHE_TMP_RAMTOP. */
|
|
||||||
postcar_frame_add_mtrr(pcf, 0, CACHE_TMP_RAMTOP, MTRR_TYPE_WRBACK);
|
|
||||||
|
|
||||||
/* Cache 8 MiB region below the top of ram and 2 MiB above top of
|
/* Cache 8 MiB region below the top of ram and 2 MiB above top of
|
||||||
* ram to cover both cbmem as the TSEG region.
|
* ram to cover both cbmem as the TSEG region.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -61,13 +61,6 @@ void fill_postcar_frame(struct postcar_frame *pcf)
|
||||||
{
|
{
|
||||||
uintptr_t top_of_ram;
|
uintptr_t top_of_ram;
|
||||||
|
|
||||||
|
|
||||||
/* Cache the ROM as WP just below 4GiB. */
|
|
||||||
postcar_frame_add_romcache(pcf, MTRR_TYPE_WRPROT);
|
|
||||||
|
|
||||||
/* Cache RAM as WB from 0 -> CACHE_TMP_RAMTOP. */
|
|
||||||
postcar_frame_add_mtrr(pcf, 0, CACHE_TMP_RAMTOP, MTRR_TYPE_WRBACK);
|
|
||||||
|
|
||||||
top_of_ram = (uintptr_t)cbmem_top();
|
top_of_ram = (uintptr_t)cbmem_top();
|
||||||
/* Cache 8MiB below the top of ram. On sandybridge systems the top of
|
/* Cache 8MiB below the top of ram. On sandybridge systems the top of
|
||||||
* ram under 4GiB is the start of the TSEG region. It is required to
|
* ram under 4GiB is the start of the TSEG region. It is required to
|
||||||
|
|
|
@ -149,13 +149,6 @@ void fill_postcar_frame(struct postcar_frame *pcf)
|
||||||
{
|
{
|
||||||
uintptr_t top_of_ram;
|
uintptr_t top_of_ram;
|
||||||
|
|
||||||
|
|
||||||
/* Cache the ROM as WP just below 4GiB. */
|
|
||||||
postcar_frame_add_romcache(pcf, MTRR_TYPE_WRPROT);
|
|
||||||
|
|
||||||
/* Cache RAM as WB from 0 -> CACHE_TMP_RAMTOP. */
|
|
||||||
postcar_frame_add_mtrr(pcf, 0, CACHE_TMP_RAMTOP, MTRR_TYPE_WRBACK);
|
|
||||||
|
|
||||||
/* Cache 8 MiB region below the top of ram and 2 MiB above top of
|
/* Cache 8 MiB region below the top of ram and 2 MiB above top of
|
||||||
* ram to cover both cbmem as the TSEG region.
|
* ram to cover both cbmem as the TSEG region.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -62,6 +62,8 @@ static void prepare_and_run_postcar(struct postcar_frame *pcf)
|
||||||
|
|
||||||
fill_postcar_frame(pcf);
|
fill_postcar_frame(pcf);
|
||||||
|
|
||||||
|
postcar_frame_common_mtrrs(pcf);
|
||||||
|
|
||||||
run_postcar_phase(pcf);
|
run_postcar_phase(pcf);
|
||||||
/* We do not return here. */
|
/* We do not return here. */
|
||||||
}
|
}
|
||||||
|
@ -256,12 +258,6 @@ static void fill_postcar_frame(struct postcar_frame *pcf)
|
||||||
{
|
{
|
||||||
uintptr_t top_of_ram;
|
uintptr_t top_of_ram;
|
||||||
|
|
||||||
/* Cache the ROM as WP just below 4GiB. */
|
|
||||||
postcar_frame_add_romcache(pcf, MTRR_TYPE_WRPROT);
|
|
||||||
|
|
||||||
/* Cache RAM as WB from 0 -> CACHE_TMP_RAMTOP. */
|
|
||||||
postcar_frame_add_mtrr(pcf, 0, CACHE_TMP_RAMTOP, MTRR_TYPE_WRBACK);
|
|
||||||
|
|
||||||
/* Cache at least 8 MiB below the top of ram, and at most 8 MiB
|
/* Cache at least 8 MiB below the top of ram, and at most 8 MiB
|
||||||
* above top of the ram. This satisfies MTRR alignment requirement
|
* above top of the ram. This satisfies MTRR alignment requirement
|
||||||
* with different TSEG size configurations.
|
* with different TSEG size configurations.
|
||||||
|
|
|
@ -39,12 +39,6 @@ void fill_postcar_frame(struct postcar_frame *pcf)
|
||||||
{
|
{
|
||||||
uintptr_t top_of_ram;
|
uintptr_t top_of_ram;
|
||||||
|
|
||||||
/* Cache the ROM as WP just below 4GiB. */
|
|
||||||
postcar_frame_add_romcache(pcf, MTRR_TYPE_WRPROT);
|
|
||||||
|
|
||||||
/* Cache RAM as WB from 0 -> CACHE_TMP_RAMTOP. */
|
|
||||||
postcar_frame_add_mtrr(pcf, 0, CACHE_TMP_RAMTOP, MTRR_TYPE_WRBACK);
|
|
||||||
|
|
||||||
/* Cache at least 8 MiB below the top of ram, and at most 8 MiB
|
/* Cache at least 8 MiB below the top of ram, and at most 8 MiB
|
||||||
* above top of the ram. This satisfies MTRR alignment requirement
|
* above top of the ram. This satisfies MTRR alignment requirement
|
||||||
* with different TSEG size configurations.
|
* with different TSEG size configurations.
|
||||||
|
|
Loading…
Reference in New Issue