From patchwork Mon Jul 6 03:37:39 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 240779 List-Id: U-Boot discussion From: sjg at chromium.org (Simon Glass) Date: Sun, 5 Jul 2020 21:37:39 -0600 Subject: [PATCH v3 23/25] x86: mtrr: Update 'mtrr' to allow setting MTRRs on any CPU In-Reply-To: <20200706033741.2169374-1-sjg@chromium.org> References: <20200706033741.2169374-1-sjg@chromium.org> Message-ID: <20200706033741.2169374-20-sjg@chromium.org> Add a -c option to mtrr to allow any CPU to be updated with this command. Signed-off-by: Simon Glass Reviewed-by: Wolfgang Wallner Reviewed-by: Bin Meng --- Changes in v3: - Mention that the CPU number is in hex cmd/x86/mtrr.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/cmd/x86/mtrr.c b/cmd/x86/mtrr.c index b51b1cd7e2..d8a7e56d5a 100644 --- a/cmd/x86/mtrr.c +++ b/cmd/x86/mtrr.c @@ -104,6 +104,17 @@ static int do_mtrr(struct cmd_tbl *cmdtp, int flag, int argc, int ret; cpu_select = MP_SELECT_BSP; + if (argc >= 3 && !strcmp("-c", argv[1])) { + const char *cpustr; + + cpustr = argv[2]; + if (*cpustr == 'a') + cpu_select = MP_SELECT_ALL; + else + cpu_select = simple_strtol(cpustr, NULL, 16); + argc -= 2; + argv += 2; + } argc--; argv++; cmd = argv[0] ? *argv[0] : 0; @@ -145,11 +156,14 @@ static int do_mtrr(struct cmd_tbl *cmdtp, int flag, int argc, } U_BOOT_CMD( - mtrr, 6, 1, do_mtrr, + mtrr, 8, 1, do_mtrr, "Use x86 memory type range registers (32-bit only)", "[list] - list current registers\n" "set - set a register\n" "\t is Uncacheable, Combine, Through, Protect, Back\n" "disable - disable a register\n" - "enable - enable a register" + "enable - enable a register\n" + "\n" + "Precede command with '-c |all' to access a particular hex CPU, e.g.\n" + " mtrr -c all list; mtrr -c 2e list" );