summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJean Delvare <jdelvare@suse.de>2022-12-16 10:36:59 +0100
committerJean Delvare <jdelvare@suse.de>2022-12-16 10:36:59 +0100
commitc1a2520433a31294fe9a0ccb52136d048f2d76e6 (patch)
treee7f349e9bab7b2068ac91a2648deae4fdfab35f6
parent67dc0b27d50e3986d5e7cd35ec25cc5901a2e9e9 (diff)
downloaddmidecode-git-c1a2520433a31294fe9a0ccb52136d048f2d76e6.tar.gz
dmidecode: Add a --no-quirks option
This new option is aimed at firmware developers to help them validate their work. When this option is used, quirks and fixups are disabled in dmidecode, which will dumbly decode everything found in the table even if it is known to be incorrect. Signed-off-by: Jean Delvare <jdelvare@suse.de>
-rw-r--r--dmidecode.c50
-rw-r--r--dmiopt.c5
-rw-r--r--dmiopt.h1
-rw-r--r--man/dmidecode.85
4 files changed, 39 insertions, 22 deletions
diff --git a/dmidecode.c b/dmidecode.c
index 4ce56e5..5aea33e 100644
--- a/dmidecode.c
+++ b/dmidecode.c
@@ -2722,7 +2722,7 @@ static void dmi_memory_device_width(const char *attr, u16 code)
/*
* If no memory module is present, width may be 0
*/
- if (code == 0xFFFF || code == 0)
+ if (code == 0xFFFF || (code == 0 && !(opt.flags & FLAG_NO_QUIRKS)))
pr_attr(attr, "Unknown");
else
pr_attr(attr, "%u bits", code);
@@ -4720,7 +4720,7 @@ static void dmi_decode(const struct dmi_header *h, u16 ver)
dmi_memory_device_type_detail(WORD(data + 0x13));
if (h->length < 0x17) break;
/* If no module is present, the remaining fields are irrelevant */
- if (WORD(data + 0x0C) == 0)
+ if (WORD(data + 0x0C) == 0 && !(opt.flags & FLAG_NO_QUIRKS))
break;
dmi_memory_device_speed("Speed", WORD(data + 0x15),
h->length >= 0x5C ?
@@ -5544,7 +5544,7 @@ static void dmi_table_decode(u8 *buf, u32 len, u16 num, u16 ver, u32 flags)
}
/* Fixup a common mistake */
- if (h.type == 34)
+ if (h.type == 34 && !(opt.flags & FLAG_NO_QUIRKS))
dmi_fixup_type_34(&h, display);
if (display)
@@ -5735,6 +5735,29 @@ static int smbios3_decode(u8 *buf, const char *devmem, u32 flags)
return 1;
}
+static void dmi_fixup_version(u16 *ver)
+{
+ /* Some BIOS report weird SMBIOS version, fix that up */
+ switch (*ver)
+ {
+ case 0x021F:
+ case 0x0221:
+ if (!(opt.flags & FLAG_QUIET))
+ fprintf(stderr,
+ "SMBIOS version fixup (2.%d -> 2.%d).\n",
+ *ver & 0xFF, 3);
+ *ver = 0x0203;
+ break;
+ case 0x0233:
+ if (!(opt.flags & FLAG_QUIET))
+ fprintf(stderr,
+ "SMBIOS version fixup (2.%d -> 2.%d).\n",
+ 51, 6);
+ *ver = 0x0206;
+ break;
+ }
+}
+
static int smbios_decode(u8 *buf, const char *devmem, u32 flags)
{
u16 ver;
@@ -5759,25 +5782,8 @@ static int smbios_decode(u8 *buf, const char *devmem, u32 flags)
return 0;
ver = (buf[0x06] << 8) + buf[0x07];
- /* Some BIOS report weird SMBIOS version, fix that up */
- switch (ver)
- {
- case 0x021F:
- case 0x0221:
- if (!(opt.flags & FLAG_QUIET))
- fprintf(stderr,
- "SMBIOS version fixup (2.%d -> 2.%d).\n",
- ver & 0xFF, 3);
- ver = 0x0203;
- break;
- case 0x0233:
- if (!(opt.flags & FLAG_QUIET))
- fprintf(stderr,
- "SMBIOS version fixup (2.%d -> 2.%d).\n",
- 51, 6);
- ver = 0x0206;
- break;
- }
+ if (!(opt.flags & FLAG_NO_QUIRKS))
+ dmi_fixup_version(&ver);
if (!(opt.flags & FLAG_QUIET))
pr_info("SMBIOS %u.%u present.",
ver >> 8, ver & 0xFF);
diff --git a/dmiopt.c b/dmiopt.c
index d08288f..fa84f22 100644
--- a/dmiopt.c
+++ b/dmiopt.c
@@ -270,6 +270,7 @@ int parse_command_line(int argc, char * const argv[])
{ "dev-mem", required_argument, NULL, 'd' },
{ "help", no_argument, NULL, 'h' },
{ "quiet", no_argument, NULL, 'q' },
+ { "no-quirks", no_argument, NULL, 'Q' },
{ "string", required_argument, NULL, 's' },
{ "type", required_argument, NULL, 't' },
{ "dump", no_argument, NULL, 'u' },
@@ -302,6 +303,9 @@ int parse_command_line(int argc, char * const argv[])
case 'q':
opt.flags |= FLAG_QUIET;
break;
+ case 'Q':
+ opt.flags |= FLAG_NO_QUIRKS;
+ break;
case 's':
if (parse_opt_string(optarg) < 0)
return -1;
@@ -371,6 +375,7 @@ void print_help(void)
" -d, --dev-mem FILE Read memory from device FILE (default: " DEFAULT_MEM_DEV ")\n"
" -h, --help Display this help text and exit\n"
" -q, --quiet Less verbose output\n"
+ " --no-quirks Decode everything without quirks\n"
" -s, --string KEYWORD Only display the value of the given DMI string\n"
" -t, --type TYPE Only display the entries of given type\n"
" -H, --handle HANDLE Only display the entry of given handle\n"
diff --git a/dmiopt.h b/dmiopt.h
index 2374637..62ffcbb 100644
--- a/dmiopt.h
+++ b/dmiopt.h
@@ -46,6 +46,7 @@ extern struct opt opt;
#define FLAG_DUMP_BIN (1 << 4)
#define FLAG_FROM_DUMP (1 << 5)
#define FLAG_NO_SYSFS (1 << 6)
+#define FLAG_NO_QUIRKS (1 << 7)
int parse_command_line(int argc, char * const argv[]);
void print_help(void);
diff --git a/man/dmidecode.8 b/man/dmidecode.8
index ed066b3..62aa304 100644
--- a/man/dmidecode.8
+++ b/man/dmidecode.8
@@ -70,6 +70,11 @@ Read memory from device \fIFILE\fP (default: \fI/dev/mem\fP)
Be less verbose. Unknown, inactive and \s-1OEM\s0-specific entries are not
displayed. Meta-data and handle references are hidden.
.TP
+.BR " " " " "--no-quirks"
+Decode everything exactly as it is in the table, without trying to fix up
+common mistakes or hide irrelevant fields.
+This mode is primarily aimed at firmware developers.
+.TP
.BR "-s" ", " "--string \fIKEYWORD\fP"
Only display the value of the \s-1DMI\s0 string identified by \fIKEYWORD\fP.
It must be a keyword from the following list: