summaryrefslogtreecommitdiffstats
path: root/cmd/x86/mtrr.c
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2020-09-22 14:54:51 -0600
committerBin Meng <bmeng.cn@gmail.com>2020-09-25 11:27:27 +0800
commit29d2d64ed55f2dfaff6d298b0f589ea0f8edef8d (patch)
treeddca703f01f651b8ac155ab17c802fcc9b00f0eb /cmd/x86/mtrr.c
parent51af144eb7a0bba3f54991059920ceccd83ddc91 (diff)
downloadu-boot-29d2d64ed55f2dfaff6d298b0f589ea0f8edef8d.tar.gz
u-boot-29d2d64ed55f2dfaff6d298b0f589ea0f8edef8d.tar.xz
u-boot-29d2d64ed55f2dfaff6d298b0f589ea0f8edef8d.zip
x86: Add support for more than 8 MTRRs
At present the mtrr command only support 8 MTRRs. Some SoCs have more than that. Update the implementation to support up to 10. Read the number of MTRRs dynamically instead. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Diffstat (limited to 'cmd/x86/mtrr.c')
-rw-r--r--cmd/x86/mtrr.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/cmd/x86/mtrr.c b/cmd/x86/mtrr.c
index 99efecb9d8..fc61a549b0 100644
--- a/cmd/x86/mtrr.c
+++ b/cmd/x86/mtrr.c
@@ -27,7 +27,7 @@ static void read_mtrrs(void *arg)
mtrr_read_all(info);
}
-static int do_mtrr_list(int cpu_select)
+static int do_mtrr_list(int reg_count, int cpu_select)
{
struct mtrr_info info;
int ret;
@@ -39,7 +39,7 @@ static int do_mtrr_list(int cpu_select)
ret = mp_run_on_cpus(cpu_select, read_mtrrs, &info);
if (ret)
return log_msg_ret("run", ret);
- for (i = 0; i < MTRR_COUNT; i++) {
+ for (i = 0; i < reg_count; i++) {
const char *type = "Invalid";
uint64_t base, mask, size;
bool valid;
@@ -98,6 +98,7 @@ static int do_mtrr_set(int cpu_select, uint reg, int argc, char *const argv[])
static int do_mtrr(struct cmd_tbl *cmdtp, int flag, int argc,
char *const argv[])
{
+ int reg_count = mtrr_get_var_count();
int cmd;
int cpu_select;
uint reg;
@@ -126,7 +127,7 @@ static int do_mtrr(struct cmd_tbl *cmdtp, int flag, int argc,
if (argc < 2)
return CMD_RET_USAGE;
reg = simple_strtoul(argv[1], NULL, 16);
- if (reg >= MTRR_COUNT) {
+ if (reg >= reg_count) {
printf("Invalid register number\n");
return CMD_RET_USAGE;
}
@@ -145,7 +146,7 @@ static int do_mtrr(struct cmd_tbl *cmdtp, int flag, int argc,
if (!first)
printf("\n");
printf("CPU %d:\n", i);
- ret = do_mtrr_list(i);
+ ret = do_mtrr_list(reg_count, i);
if (ret) {
printf("Failed to read CPU %d (err=%d)\n", i,
ret);