cpu/x86/mtrr: Allow for multiple TEMP MTRR ranges
Temporary MTRR setup usually covers the memory mapped flash. On recent Intel hardware the mapping is not coherent. It uses an external window for parts of the BIOS region that exceed 16M. This now allows up to 10 temporary memory ranges. TESTED: Qemu with multiple MTRR temporary MTRR ranges sets up a valid and optimized temporary MTRR solution. Change-Id: I23442bd2ab7602e4c5cbd37d187a31413cf27ecc Signed-off-by: Arthur Heymans <arthur@aheymans.xyz> Reviewed-on: https://review.coreboot.org/c/coreboot/+/63555 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Lean Sheng Tan <sheng.tan@9elements.com> Reviewed-by: Tim Wawrzynczak <twawrzynczak@chromium.org> Reviewed-by: Subrata Banik <subratabanik@google.com>
This commit is contained in:
parent
d99a311a8a
commit
4ed2260136
|
@ -9,6 +9,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
|
#include <stdint.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <bootstate.h>
|
#include <bootstate.h>
|
||||||
#include <commonlib/helpers.h>
|
#include <commonlib/helpers.h>
|
||||||
|
@ -873,6 +874,28 @@ void mtrr_use_temp_range(uintptr_t begin, size_t size, int type)
|
||||||
struct memranges addr_space;
|
struct memranges addr_space;
|
||||||
const int above4gb = 1; /* Cover above 4GiB by default. */
|
const int above4gb = 1; /* Cover above 4GiB by default. */
|
||||||
int address_bits;
|
int address_bits;
|
||||||
|
static struct temp_range {
|
||||||
|
uintptr_t begin;
|
||||||
|
size_t size;
|
||||||
|
int type;
|
||||||
|
} temp_ranges[10];
|
||||||
|
|
||||||
|
if (size == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
int i;
|
||||||
|
for (i = 0; i < ARRAY_SIZE(temp_ranges); i++) {
|
||||||
|
if (temp_ranges[i].size == 0) {
|
||||||
|
temp_ranges[i].begin = begin;
|
||||||
|
temp_ranges[i].size = size;
|
||||||
|
temp_ranges[i].type = type;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (i == ARRAY_SIZE(temp_ranges)) {
|
||||||
|
printk(BIOS_ERR, "Out of temporary ranges for MTRR use\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
/* Make a copy of the original address space and tweak it with the
|
/* Make a copy of the original address space and tweak it with the
|
||||||
* provided range. */
|
* provided range. */
|
||||||
|
@ -891,7 +914,11 @@ void mtrr_use_temp_range(uintptr_t begin, size_t size, int type)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Place new range into the address space. */
|
/* Place new range into the address space. */
|
||||||
memranges_insert(&addr_space, begin, size, type);
|
for (i = 0; i < ARRAY_SIZE(temp_ranges); i++) {
|
||||||
|
if (temp_ranges[i].size != 0)
|
||||||
|
memranges_insert(&addr_space, temp_ranges[i].begin,
|
||||||
|
temp_ranges[i].size, temp_ranges[i].type);
|
||||||
|
}
|
||||||
|
|
||||||
print_physical_address_space(&addr_space, "TEMPORARY");
|
print_physical_address_space(&addr_space, "TEMPORARY");
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue