]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
x86: mtrr: Update 'mtrr' to allow setting MTRRs on any CPU
authorSimon Glass <sjg@chromium.org>
Fri, 17 Jul 2020 14:48:29 +0000 (08:48 -0600)
committerBin Meng <bmeng.cn@gmail.com>
Mon, 20 Jul 2020 01:46:48 +0000 (09:46 +0800)
Add a -c option to mtrr to allow any CPU to be updated with this command.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Wolfgang Wallner <wolfgang.wallner@br-automation.com>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
cmd/x86/mtrr.c

index b51b1cd7e2a234d350e8a0ac6b707aa578508136..d8a7e56d5a48256a44cce370e11b8a1f0ddaf549 100644 (file)
@@ -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 <reg> <type> <start> <size>   - set a register\n"
        "\t<type> is Uncacheable, Combine, Through, Protect, Back\n"
        "disable <reg>      - disable a register\n"
-       "enable <reg>       - enable a register"
+       "enable <reg>       - enable a register\n"
+       "\n"
+       "Precede command with '-c <n>|all' to access a particular hex CPU, e.g.\n"
+       "   mtrr -c all list; mtrr -c 2e list"
 );