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 <jdelv...@suse.de> --- I'm resurrecting this patch which fell into oblivion (my fault) after a first submission/review round. Changes since v1: * Rename the new option from --dumb to --no-quirks (suggested by Erwan Velu) dmidecode.c | 50 ++++++++++++++++++++++++++++---------------------- dmiopt.c | 5 +++++ dmiopt.h | 1 + man/dmidecode.8 | 5 +++++ 4 files changed, 39 insertions(+), 22 deletions(-) --- dmidecode.orig/dmidecode.c +++ dmidecode/dmidecode.c @@ -2722,7 +2722,7 @@ static void dmi_memory_device_width(cons /* * 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_ 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, u3 } /* 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 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 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); --- dmidecode.orig/dmiopt.c +++ dmidecode/dmiopt.c @@ -270,6 +270,7 @@ int parse_command_line(int argc, char * { "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 * 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" --- dmidecode.orig/dmiopt.h +++ dmidecode/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); --- dmidecode.orig/man/dmidecode.8 +++ dmidecode/man/dmidecode.8 @@ -70,6 +70,11 @@ Read memory from device \fIFILE\fP (defa 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: -- Jean Delvare SUSE L3 Support _______________________________________________ https://lists.nongnu.org/mailman/listinfo/dmidecode-devel