Skip to contentSkip to conversation

x86: Updates to some commands

PATCH Superseded Simon Glass 2 participants 11 messages Sep 20, 2020 – Sep 22, 2020 x86

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

cover x86: Updates to some commands

This series adds a few more features to some x86-specific commands.

Simon Glass (5):
x86: hob: Add way to show a single hob entry
x86: hob: Try to show a name instead of a GUID
x86: Allow showing details about a HOB entry
x86: Add support for more than 8 MTRRs
x86: video: Show information about each video device

 arch/x86/cpu/mtrr.c                |  12 ++--
 arch/x86/include/asm/fsp/fsp_hob.h |  25 ++++++++
 arch/x86/include/asm/mtrr.h        |  15 ++++-
 cmd/bdinfo.c                       |  26 +++++++-
 cmd/x86/hob.c                      | 100 +++++++++++++++++++++++++++--
 cmd/x86/mtrr.c                     |   9 +--
 6 files changed, 167 insertions(+), 20 deletions(-)
Signature · 1 line
2.28.0.681.g6f77f65b4e-goog
#1 lore raw

PATCH 1/5 x86: hob: Add way to show a single hob entry

The 'hob' command currently lists all HOB entries. Add way to list a single entry, by index.

---

 cmd/x86/hob.c | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)
cmd/x86/hob.c +11 -5
index 6b1f7bda5b8..e3f512beee8 100644
@@ -34,7 +34,12 @@ static int do_hob(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
 	int i = 0;
 	efi_guid_t *guid;
 	char uuid[UUID_STR_LEN + 1];
+	int seq = -1;	/* Show all by default */
 
+	argc--;
+	argv++;
+	if (argc)
+		seq = simple_strtol(*argv, NULL, 16);
 	hdr = gd->arch.hob_list;
 
 	printf("HOB list address: 0x%08x\n\n", (unsigned int)hdr);
@@ -43,7 +48,9 @@ static int do_hob(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
 	printf("%36s\n", "GUID");
 	printf("---|----------|-----------|------|-");
 	printf("------------------------------------\n");
-	while (!end_of_hob(hdr)) {
+	for (i = 0; !end_of_hob(hdr); i++, hdr = get_next_hob(hdr)) {
+		if (seq != -1 && seq != i)
+			continue;
 		printf("%02x | %08x | ", i, (unsigned int)hdr);
 		type = hdr->type;
 		if (type == HOB_TYPE_UNUSED)
@@ -65,14 +72,13 @@ static int do_hob(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
 			printf("%36s", "Not Available");
 		}
 		printf("\n");
-		hdr = get_next_hob(hdr);
-		i++;
 	}
 
 	return 0;
 }
 
-U_BOOT_CMD(hob, 1, 1, do_hob,
-	   "Print Hand-Off Block (HOB) information",
+U_BOOT_CMD(hob, 2, 1, do_hob,
+	   "[seq]  Print Hand-Off Block (HOB) information"
+	   "   seq - Record # to show (all by default)",
 	   ""
 );
Signature · 1 line
2.28.0.681.g6f77f65b4e-goog
#2 lore raw

PATCH 1/5 x86: hob: Add way to show a single hob entry

Quoted 10 lines · Simon Glass

The 'hob' command currently lists all HOB entries. Add way to list a single entry, by index.

---

 cmd/x86/hob.c | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)
#3 lore raw

PATCH 2/5 x86: hob: Try to show a name instead of a GUID

In reply to Simon Glass

GUIDs are one of the seven evils of the computer world. They obfuscate the meaning and require people to look up long hex strings to decode it.

Luckily only a miniscule fraction of the 10^38 possible GUIDs are in use.

Add a way to decode the GUIDs known to U-Boot. Add a few more to the list for good measure.

---

 arch/x86/include/asm/fsp/fsp_hob.h | 25 +++++++++++++++++
 cmd/x86/hob.c                      | 43 ++++++++++++++++++++++++++++--
 2 files changed, 66 insertions(+), 2 deletions(-)
arch/x86/include/asm/fsp/fsp_hob.h +25 -0
index d248520e972..ea3983e04ff 100644
@@ -99,4 +99,29 @@ struct __packed hob_graphics_info {
 	EFI_GUID(0x39f62cce, 0x6825, 0x4669, \
 		0xbb, 0x56, 0x54, 0x1a, 0xba, 0x75, 0x3a, 0x07)
 
+/* The following GUIDs are observed with FSP 2.1 / Apollo Lake */
+#define FSP_HOB_RESOURCE_OWNER_SMM_PEI_SMRAM_GUID \
+	EFI_GUID(0x6dadf1d1, 0xd4cc, 0x4910, \
+		0xbb, 0x6e, 0x82, 0xb1, 0xfd, 0x80, 0xff, 0x3d)
+
+#define FSP_HOB_RESOURCE_OWNER_PCD_DATABASE_GUID1 \
+	EFI_GUID(0xea296d92, 0x0b69, 0x423c, \
+		0x8c, 0x28, 0x33, 0xb4, 0xe0, 0xa9, 0x12, 0x68)
+
+#define FSP_HOB_RESOURCE_OWNER_PCD_DATABASE_GUID2 \
+	EFI_GUID(0x9b3ada4f, 0xae56, 0x4c24, \
+		0x8d, 0xea, 0xf0, 0x3b, 0x75, 0x58, 0xae, 0x50)
+
+#define FSP_HOB_RESOURCE_OWNER_PEIM_DXE_GUID \
+	EFI_GUID(0x86d70125, 0xbaa3, 0x4296, \
+		0xa6, 0x2f, 0x60, 0x2b, 0xeb, 0xbb, 0x90, 0x81)
+
+#define FSP_HOB_RESOURCE_OWNER_ALLOC_STACK_GUID \
+	EFI_GUID(0x4ed4bf27, 0x4092, 0x42e9, \
+		0x80, 0x7d, 0x52, 0x7b, 0x1d, 0x00, 0xc9, 0xbd)
+
+#define FSP_HOB_RESOURCE_OWNER_SMBIOS_MEMORY_GUID \
+	EFI_GUID(0x01a1108c, 0x9dee, 0x4984, \
+		0x88, 0xc3, 0xee, 0xe8, 0xc4, 0x9e, 0xfb, 0x89)
+
 #endif
cmd/x86/hob.c +41 -2

62 lines not on this page · raw message

Signature · 1 line
2.28.0.681.g6f77f65b4e-goog
#4 lore raw

PATCH 2/5 x86: hob: Try to show a name instead of a GUID

Hi Simon,

Quoted 3 lines · Simon Glass

GUIDs are one of the seven evils of the computer world. They obfuscate the meaning and require people to look up long hex strings to decode it.

Agreed :)

Quoted 65 lines

Luckily only a miniscule fraction of the 10^38 possible GUIDs are in use.

Add a way to decode the GUIDs known to U-Boot. Add a few more to the list for good measure.

---

 arch/x86/include/asm/fsp/fsp_hob.h | 25 +++++++++++++++++
 cmd/x86/hob.c                      | 43 ++++++++++++++++++++++++++++--
 2 files changed, 66 insertions(+), 2 deletions(-)
arch/x86/include/asm/fsp/fsp_hob.h +25 -0
index d248520e972..ea3983e04ff 100644
@@ -99,4 +99,29 @@ struct __packed hob_graphics_info {
        EFI_GUID(0x39f62cce, 0x6825, 0x4669, \
                0xbb, 0x56, 0x54, 0x1a, 0xba, 0x75, 0x3a, 0x07)
 
+/* The following GUIDs are observed with FSP 2.1 / Apollo Lake */
+#define FSP_HOB_RESOURCE_OWNER_SMM_PEI_SMRAM_GUID \
+       EFI_GUID(0x6dadf1d1, 0xd4cc, 0x4910, \
+               0xbb, 0x6e, 0x82, 0xb1, 0xfd, 0x80, 0xff, 0x3d)
+
+#define FSP_HOB_RESOURCE_OWNER_PCD_DATABASE_GUID1 \
+       EFI_GUID(0xea296d92, 0x0b69, 0x423c, \
+               0x8c, 0x28, 0x33, 0xb4, 0xe0, 0xa9, 0x12, 0x68)
+
+#define FSP_HOB_RESOURCE_OWNER_PCD_DATABASE_GUID2 \
+       EFI_GUID(0x9b3ada4f, 0xae56, 0x4c24, \
+               0x8d, 0xea, 0xf0, 0x3b, 0x75, 0x58, 0xae, 0x50)
+
+#define FSP_HOB_RESOURCE_OWNER_PEIM_DXE_GUID \
+       EFI_GUID(0x86d70125, 0xbaa3, 0x4296, \
+               0xa6, 0x2f, 0x60, 0x2b, 0xeb, 0xbb, 0x90, 0x81)
+
+#define FSP_HOB_RESOURCE_OWNER_ALLOC_STACK_GUID \
+       EFI_GUID(0x4ed4bf27, 0x4092, 0x42e9, \
+               0x80, 0x7d, 0x52, 0x7b, 0x1d, 0x00, 0xc9, 0xbd)
+
+#define FSP_HOB_RESOURCE_OWNER_SMBIOS_MEMORY_GUID \
+       EFI_GUID(0x01a1108c, 0x9dee, 0x4984, \
+               0x88, 0xc3, 0xee, 0xe8, 0xc4, 0x9e, 0xfb, 0x89)
+
 #endif
cmd/x86/hob.c +3 -0
index e3f512beee8..bbe38bbf20e 100644
@@ -8,6 +8,7 @@
 #include <efi.h>
 #include <uuid.h>
 #include <asm/hob.h>
+#include <asm/fsp/fsp_hob.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -26,6 +27,37 @@ static char *hob_type[] = {
        "Capsule",
 };
 
+static struct guid_name {
+       efi_guid_t guid;

cmd/x86/hob.c static char *hob_type[] = { · line 41

Quoted 10 lines
cmd/x86/hob.c +10 -0
+       const char *name;
+} guid_name[] = {
+       { FSP_HOB_RESOURCE_OWNER_TSEG_GUID, "TSEG" },
+       { FSP_HOB_RESOURCE_OWNER_FSP_GUID, "FSP" },
+       { FSP_HOB_RESOURCE_OWNER_SMM_PEI_SMRAM_GUID, "SMM PEI SMRAM" },
+       { FSP_NON_VOLATILE_STORAGE_HOB_GUID, "NVS" },
+       { FSP_VARIABLE_NV_DATA_HOB_GUID, "Variable NVS" },
+       { FSP_GRAPHICS_INFO_HOB_GUID, "Graphics info" },
+       { FSP_HOB_RESOURCE_OWNER_PCD_DATABASE_GUID1, "PCD database ea" },
+       { FSP_HOB_RESOURCE_OWNER_PCD_DATABASE_GUID2, "PCD database 93" },

93 should be 9b

Quoted 32 lines
cmd/x86/hob.c +22 -2
+       { FSP_HOB_RESOURCE_OWNER_PEIM_DXE_GUID, "PEIM Init DXE" },
+       { FSP_HOB_RESOURCE_OWNER_ALLOC_STACK_GUID, "Alloc stack" },
+       { FSP_HOB_RESOURCE_OWNER_SMBIOS_MEMORY_GUID, "SMBIOS memory" },
+       { {}, "zero-guid" },
+       {}
+};
+
+static const char *guid_to_name(const efi_guid_t *guid)
+{
+       struct guid_name *entry;
+
+       for (entry = guid_name; entry->name; entry++) {
+               if (!guidcmp(guid, &entry->guid))
+                       return entry->name;
+       }
+
+       return NULL;
+}
+
 static int do_hob(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
 {
        const struct hob_header *hdr;
@@ -65,9 +97,16 @@ static int do_hob(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
 
                if (type == HOB_TYPE_MEM_ALLOC || type == HOB_TYPE_RES_DESC ||
                    type == HOB_TYPE_GUID_EXT) {
+                       const char *name;
+
                        guid = (efi_guid_t *)(hdr + 1);
-                       uuid_bin_to_str(guid->b, uuid, UUID_STR_FORMAT_GUID);
-                       printf("%s", uuid);
+                       name = guid_to_name(guid);

cmd/x86/hob.c static int do_hob(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])

Quoted 10 lines
cmd/x86/hob.c +6 -1
+                       if (!name) {
+                               uuid_bin_to_str(guid->b, uuid,
+                                               UUID_STR_FORMAT_GUID);
+                               name = uuid;
+                       }
+                       printf("%36s", name);
                } else {
                        printf("%36s", "Not Available");
                }
--

Regards,
Bin

#5 lore raw

PATCH 3/5 x86: Allow showing details about a HOB entry

In reply to Simon Glass

Some HOBs include information that can be decoded. Add a -v option to the hob command, to allow this to be displayed. Add the ability to decode a resource descriptor.

---

 cmd/x86/hob.c | 49 +++++++++++++++++++++++++++++++++++++++++++++----
 1 file changed, 45 insertions(+), 4 deletions(-)
cmd/x86/hob.c +45 -4
index bbe38bbf20e..2933bc08c76 100644
@@ -27,6 +27,16 @@ static char *hob_type[] = {
 	"Capsule",
 };
 
+static char *res_type[] = {
+	"system",
+	"Memory-mapped I/O",
+	"I/O",
+	"Firmware device",
+	"Memory-mapped I/O port",
+	"Reserved",
+	"I/O reserved",
+};
+
 static struct guid_name {
 	efi_guid_t guid;
 	const char *name;
@@ -58,6 +68,26 @@ static const char *guid_to_name(const efi_guid_t *guid)
 	return NULL;
 }
 
+static void show_hob_details(const struct hob_header *hdr)
+{
+	const void *ptr = hdr;
+
+	switch (hdr->type) {
+	case HOB_TYPE_RES_DESC: {
+		const struct hob_res_desc *res = ptr;
+		const char *typename;
+
+		typename = res->type > 0 && res->type <= RES_MAX_MEM_TYPE ?
+			res_type[res->type] : "unknown";
+
+		printf("     base = %08llx, len = %08llx, end = %08llx, type = %d (%s)\n\n",
+		       res->phys_start, res->len, res->phys_start + res->len,
+		       res->type, typename);
+		break;
+	}
+	}
+}
+
 static int do_hob(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
 {
 	const struct hob_header *hdr;
@@ -66,12 +96,20 @@ static int do_hob(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
 	int i = 0;
 	efi_guid_t *guid;
 	char uuid[UUID_STR_LEN + 1];
+	bool verbose = false;
 	int seq = -1;	/* Show all by default */
 
 	argc--;
 	argv++;
-	if (argc)
-		seq = simple_strtol(*argv, NULL, 16);
+	if (argc) {
+		if (!strcmp("-v", *argv)) {
+			verbose = true;
+			argc--;
+			argv++;
+		}
+		if (argc)
+			seq = simple_strtol(*argv, NULL, 16);
+	}
 	hdr = gd->arch.hob_list;
 
 	printf("HOB list address: 0x%08x\n\n", (unsigned int)hdr);
@@ -111,13 +149,16 @@ static int do_hob(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
 			printf("%36s", "Not Available");
 		}
 		printf("\n");
+		if (verbose)
+			show_hob_details(hdr);
 	}
 
 	return 0;
 }
 
-U_BOOT_CMD(hob, 2, 1, do_hob,
-	   "[seq]  Print Hand-Off Block (HOB) information"
+U_BOOT_CMD(hob, 3, 1, do_hob,
+	   "[-v] [seq]  Print Hand-Off Block (HOB) information"
+	   "   -v  - Show detailed HOB information where available"
 	   "   seq - Record # to show (all by default)",
 	   ""
 );
Signature · 1 line
2.28.0.681.g6f77f65b4e-goog
#6 lore raw

PATCH 3/5 x86: Allow showing details about a HOB entry

Quoted 16 lines · Simon Glass

Some HOBs include information that can be decoded. Add a -v option to the hob command, to allow this to be displayed. Add the ability to decode a resource descriptor.

---

 cmd/x86/hob.c | 49 +++++++++++++++++++++++++++++++++++++++++++++----
 1 file changed, 45 insertions(+), 4 deletions(-)
cmd/x86/hob.c +0 -0
index bbe38bbf20e..2933bc08c76 100644

cmd/x86/hob.c static char *hob_type[] = { · line 31

Quoted 5 lines
cmd/x86/hob.c +2 -0
@@ -27,6 +27,16 @@ static char *hob_type[] = {
        "Capsule",
 };
 
+static char *res_type[] = {
+       "system",

nits: System

Quoted 70 lines
cmd/x86/hob.c +40 -2
+       "Memory-mapped I/O",
+       "I/O",
+       "Firmware device",
+       "Memory-mapped I/O port",
+       "Reserved",
+       "I/O reserved",
+};
+
 static struct guid_name {
        efi_guid_t guid;
        const char *name;
@@ -58,6 +68,26 @@ static const char *guid_to_name(const efi_guid_t *guid)
        return NULL;
 }
 
+static void show_hob_details(const struct hob_header *hdr)
+{
+       const void *ptr = hdr;
+
+       switch (hdr->type) {
+       case HOB_TYPE_RES_DESC: {
+               const struct hob_res_desc *res = ptr;
+               const char *typename;
+
+               typename = res->type > 0 && res->type <= RES_MAX_MEM_TYPE ?
+                       res_type[res->type] : "unknown";
+
+               printf("     base = %08llx, len = %08llx, end = %08llx, type = %d (%s)\n\n",
+                      res->phys_start, res->len, res->phys_start + res->len,
+                      res->type, typename);
+               break;
+       }
+       }
+}
+
 static int do_hob(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
 {
        const struct hob_header *hdr;
@@ -66,12 +96,20 @@ static int do_hob(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
        int i = 0;
        efi_guid_t *guid;
        char uuid[UUID_STR_LEN + 1];
+       bool verbose = false;
        int seq = -1;   /* Show all by default */
 
        argc--;
        argv++;
-       if (argc)
-               seq = simple_strtol(*argv, NULL, 16);
+       if (argc) {
+               if (!strcmp("-v", *argv)) {
+                       verbose = true;
+                       argc--;
+                       argv++;
+               }
+               if (argc)
+                       seq = simple_strtol(*argv, NULL, 16);
+       }
        hdr = gd->arch.hob_list;
 
        printf("HOB list address: 0x%08x\n\n", (unsigned int)hdr);
@@ -111,13 +149,16 @@ static int do_hob(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
                        printf("%36s", "Not Available");
                }
                printf("\n");
+               if (verbose)
+                       show_hob_details(hdr);
        }
 
        return 0;

cmd/x86/hob.c static int do_hob(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) · line 164

Quoted 10 lines
cmd/x86/hob.c +3 -2
 }
 
-U_BOOT_CMD(hob, 2, 1, do_hob,
-          "[seq]  Print Hand-Off Block (HOB) information"
+U_BOOT_CMD(hob, 3, 1, do_hob,
+          "[-v] [seq]  Print Hand-Off Block (HOB) information"
+          "   -v  - Show detailed HOB information where available"
           "   seq - Record # to show (all by default)",
           ""
 );
#7 lore raw

PATCH 4/5 x86: Add support for more than 8 MTRRs

In reply to Simon Glass

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.

---

 arch/x86/cpu/mtrr.c         | 12 +++++++-----
 arch/x86/include/asm/mtrr.h | 15 ++++++++++++---
 cmd/x86/mtrr.c              |  9 +++++----
 3 files changed, 24 insertions(+), 12 deletions(-)
arch/x86/cpu/mtrr.c +7 -5
index 2468d88a80a..aed4c411367 100644
@@ -66,9 +66,10 @@ static void set_var_mtrr(uint reg, uint type, uint64_t start, uint64_t size)
 
 void mtrr_read_all(struct mtrr_info *info)
 {
+	int reg_count = mtrr_get_var_count();
 	int i;
 
-	for (i = 0; i < MTRR_COUNT; i++) {
+	for (i = 0; i < reg_count; i++) {
 		info->mtrr[i].base = native_read_msr(MTRR_PHYS_BASE_MSR(i));
 		info->mtrr[i].mask = native_read_msr(MTRR_PHYS_MASK_MSR(i));
 	}
@@ -76,10 +77,11 @@ void mtrr_read_all(struct mtrr_info *info)
 
 void mtrr_write_all(struct mtrr_info *info)
 {
+	int reg_count = mtrr_get_var_count();
 	struct mtrr_state state;
 	int i;
 
-	for (i = 0; i < MTRR_COUNT; i++) {
+	for (i = 0; i < reg_count; i++) {
 		mtrr_open(&state, true);
 		wrmsrl(MTRR_PHYS_BASE_MSR(i), info->mtrr[i].base);
 		wrmsrl(MTRR_PHYS_MASK_MSR(i), info->mtrr[i].mask);
@@ -144,7 +146,7 @@ int mtrr_commit(bool do_caches)
 
 	/* Clear the ones that are unused */
 	debug("clear\n");
-	for (; i < MTRR_COUNT; i++)
+	for (; i < MTRR_MAX_COUNT; i++)
 		wrmsrl(MTRR_PHYS_MASK_MSR(i), 0);
 	debug("close\n");
 	mtrr_close(&state, do_caches);
@@ -184,7 +186,7 @@ int mtrr_add_request(int type, uint64_t start, uint64_t size)
 	return 0;
 }
 
-static int get_var_mtrr_count(void)
+int mtrr_get_var_count(void)
 {
 	return msr_read(MSR_MTRR_CAP_MSR).lo & MSR_MTRR_CAP_VCNT;
 }
@@ -195,7 +197,7 @@ static int get_free_var_mtrr(void)
 	int vcnt;
 	int i;
 
-	vcnt = get_var_mtrr_count();
+	vcnt = mtrr_get_var_count();
 
 	/* Identify the first var mtrr which is not valid */
 	for (i = 0; i < vcnt; i++) {
arch/x86/include/asm/mtrr.h +12 -3
index 48db1dd82f7..3a98aacdef5 100644
@@ -36,8 +36,8 @@
 
 #define MTRR_BASE_TYPE_MASK	0x7
 
-/* Number of MTRRs supported */
-#define MTRR_COUNT		8
+/* Maximum number of MTRRs supported - see also mtrr_get_var_count() */
+#define MTRR_MAX_COUNT		10
 
 #define NUM_FIXED_MTRRS		11
 #define RANGES_PER_FIXED_MTRR	8
@@ -87,7 +87,7 @@ struct mtrr {
  * @mtrr: Information about each mtrr
  */
 struct mtrr_info {
-	struct mtrr mtrr[MTRR_COUNT];
+	struct mtrr mtrr[MTRR_MAX_COUNT];
 };
 
 /**
@@ -180,6 +180,15 @@ int mtrr_set_valid(int cpu_select, int reg, bool valid);
  */
 int mtrr_set(int cpu_select, int reg, u64 base, u64 mask);
 
+/**
+ * mtrr_get_var_count() - Get the number of variable MTRRs
+ *
+ * Some CPUs have more than 8 MTRRs. This function returns the actual number
+ *
+ * @return number of variable MTRRs
+ */
+int mtrr_get_var_count(void);
+
 #endif
 
 #if ((CONFIG_XIP_ROM_SIZE & (CONFIG_XIP_ROM_SIZE - 1)) != 0)
cmd/x86/mtrr.c +5 -4
index 99efecb9d8e..fc61a549b02 100644
@@ -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);
Signature · 1 line
2.28.0.681.g6f77f65b4e-goog
#8 lore raw

PATCH 4/5 x86: Add support for more than 8 MTRRs

Quoted 5 lines · Simon Glass

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.

Quoted 8 lines

---

 arch/x86/cpu/mtrr.c         | 12 +++++++-----
 arch/x86/include/asm/mtrr.h | 15 ++++++++++++---
 cmd/x86/mtrr.c              |  9 +++++----
 3 files changed, 24 insertions(+), 12 deletions(-)
#9 lore raw

PATCH 5/5 x86: video: Show information about each video device

In reply to Simon Glass

At present the 'bdinfo' command shows the framebuffer address, but not the address of the copy framebuffer, if present. Add support for this.

---

 cmd/bdinfo.c | 26 +++++++++++++++++++++++++-
 1 file changed, 25 insertions(+), 1 deletion(-)
cmd/bdinfo.c +25 -1
index 9593b345a3d..2d88eb18ba7 100644
@@ -8,9 +8,11 @@
 
 #include <common.h>
 #include <command.h>
+#include <dm.h>
 #include <env.h>
 #include <lmb.h>
 #include <net.h>
+#include <video.h>
 #include <vsprintf.h>
 #include <asm/cache.h>
 
@@ -66,6 +68,26 @@ __weak void arch_print_bdinfo(void)
 {
 }
 
+static void show_video_info(void)
+{
+	const struct udevice *dev;
+	struct uclass *uc;
+
+	uclass_id_foreach_dev(UCLASS_VIDEO, dev, uc) {
+		printf("%-12s= %s %sactive\n", "Video", dev->name,
+		       device_active(dev) ? "" : "in");
+		if (device_active(dev)) {
+			struct video_priv *upriv = dev_get_uclass_priv(dev);
+
+			print_phys_addr("FB base", (ulong)upriv->fb);
+			if (upriv->copy_fb)
+				print_phys_addr("FB copy", (ulong)upriv->copy_fb);
+			printf("%-12s= %dx%dx%d\n", "FB size", upriv->xsize,
+			       upriv->ysize, 1 << upriv->bpix);
+		}
+	}
+}
+
 int do_bdinfo(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
 {
 	struct bd_info *bd = gd->bd;
@@ -96,7 +118,9 @@ int do_bdinfo(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
 	bdinfo_print_num("fdt_blob", (ulong)gd->fdt_blob);
 	bdinfo_print_num("new_fdt", (ulong)gd->new_fdt);
 	bdinfo_print_num("fdt_size", (ulong)gd->fdt_size);
-#if defined(CONFIG_LCD) || defined(CONFIG_VIDEO) || defined(CONFIG_DM_VIDEO)
+	if (IS_ENABLED(CONFIG_DM_VIDEO))
+		show_video_info();
+#if defined(CONFIG_LCD) || defined(CONFIG_VIDEO)
 	bdinfo_print_num("FB base  ", gd->fb_base);
 #endif
 #if CONFIG_IS_ENABLED(MULTI_DTB_FIT)
Signature · 1 line
2.28.0.681.g6f77f65b4e-goog
#10 lore raw

PATCH 5/5 x86: video: Show information about each video device

Quoted 10 lines · Simon Glass

At present the 'bdinfo' command shows the framebuffer address, but not the address of the copy framebuffer, if present. Add support for this.

---

 cmd/bdinfo.c | 26 +++++++++++++++++++++++++-
 1 file changed, 25 insertions(+), 1 deletion(-)