mirror of
https://github.com/Fishwaldo/u-boot.git
synced 2025-03-17 12:41:32 +00:00
x86: mtrr: Restructure so command execution is in one place
At present do_mtrr() does the 'list' subcommand at the top and the rest below. Update it to do them all in the same place so we can (in a later patch) add parsing of the CPU number for all subcommands. 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>
This commit is contained in:
parent
e68b12805b
commit
b2a76b3fe7
1 changed files with 37 additions and 20 deletions
|
@ -98,31 +98,48 @@ 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,
|
static int do_mtrr(struct cmd_tbl *cmdtp, int flag, int argc,
|
||||||
char *const argv[])
|
char *const argv[])
|
||||||
{
|
{
|
||||||
const char *cmd;
|
int cmd;
|
||||||
int cpu_select;
|
int cpu_select;
|
||||||
uint reg;
|
uint reg;
|
||||||
|
int ret;
|
||||||
|
|
||||||
cpu_select = MP_SELECT_BSP;
|
cpu_select = MP_SELECT_BSP;
|
||||||
cmd = argv[1];
|
argc--;
|
||||||
if (argc < 2 || *cmd == 'l')
|
argv++;
|
||||||
return do_mtrr_list(cpu_select);
|
cmd = argv[0] ? *argv[0] : 0;
|
||||||
argc -= 2;
|
if (argc < 1 || !cmd) {
|
||||||
argv += 2;
|
cmd = 'l';
|
||||||
if (argc <= 0)
|
reg = 0;
|
||||||
return CMD_RET_USAGE;
|
} else {
|
||||||
reg = simple_strtoul(argv[0], NULL, 16);
|
if (argc < 2)
|
||||||
if (reg >= MTRR_COUNT) {
|
return CMD_RET_USAGE;
|
||||||
printf("Invalid register number\n");
|
reg = simple_strtoul(argv[1], NULL, 16);
|
||||||
return CMD_RET_USAGE;
|
if (reg >= MTRR_COUNT) {
|
||||||
|
printf("Invalid register number\n");
|
||||||
|
return CMD_RET_USAGE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (cmd == 'l') {
|
||||||
|
return do_mtrr_list(cpu_select);
|
||||||
|
} else {
|
||||||
|
switch (cmd) {
|
||||||
|
case 'e':
|
||||||
|
ret = mtrr_set_valid(cpu_select, reg, true);
|
||||||
|
break;
|
||||||
|
case 'd':
|
||||||
|
ret = mtrr_set_valid(cpu_select, reg, false);
|
||||||
|
break;
|
||||||
|
case 's':
|
||||||
|
ret = do_mtrr_set(cpu_select, reg, argc - 2, argv + 2);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return CMD_RET_USAGE;
|
||||||
|
}
|
||||||
|
if (ret) {
|
||||||
|
printf("Operation failed (err=%d)\n", ret);
|
||||||
|
return CMD_RET_FAILURE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (*cmd == 'e')
|
|
||||||
return mtrr_set_valid(cpu_select, reg, true);
|
|
||||||
else if (*cmd == 'd')
|
|
||||||
return mtrr_set_valid(cpu_select, reg, false);
|
|
||||||
else if (*cmd == 's')
|
|
||||||
return do_mtrr_set(cpu_select, reg, argc - 1, argv + 1);
|
|
||||||
else
|
|
||||||
return CMD_RET_USAGE;
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue