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>
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user