From 29d2d64ed55f2dfaff6d298b0f589ea0f8edef8d Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Tue, 22 Sep 2020 14:54:51 -0600 Subject: 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 Reviewed-by: Bin Meng --- cmd/x86/mtrr.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'cmd/x86') diff --git a/cmd/x86/mtrr.c b/cmd/x86/mtrr.c index 99efecb..fc61a54 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); -- cgit v1.1