From 622062f9259c9a14b332b62aa5ddb5039a95934f Mon Sep 17 00:00:00 2001 From: Packit Service Date: Dec 12 2020 06:14:12 +0000 Subject: Prepare for a new update Reverting patches so we can apply the latest update and changes can be seen in the spec file and sources. --- diff --git a/Makefile b/Makefile index 7aa729d..77c9310 100644 --- a/Makefile +++ b/Makefile @@ -4,7 +4,7 @@ # VPD Decode # # Copyright (C) 2000-2002 Alan Cox -# Copyright (C) 2002-2020 Jean Delvare +# Copyright (C) 2002-2015 Jean Delvare # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -12,13 +12,8 @@ # (at your option) any later version. # -CC ?= gcc -# Base CFLAGS can be overridden by environment -CFLAGS ?= -O2 -# When debugging, disable -O2 and enable -g -#CFLAGS ?= -g - -CFLAGS += -W -Wall -Wshadow -Wstrict-prototypes -Wpointer-arith -Wcast-qual \ +CC = gcc +CFLAGS = -W -Wall -Wshadow -Wstrict-prototypes -Wpointer-arith -Wcast-qual \ -Wcast-align -Wwrite-strings -Wmissing-prototypes -Winline -Wundef # Let lseek and mmap support 64-bit wide offsets @@ -27,8 +22,12 @@ CFLAGS += -D_FILE_OFFSET_BITS=64 #CFLAGS += -DBIGENDIAN #CFLAGS += -DALIGNMENT_WORKAROUND -# Pass linker flags here (can be set from environment too) -LDFLAGS ?= +# When debugging, disable -O2 and enable -g. +CFLAGS += -O2 +#CFLAGS += -g + +# Pass linker flags here +LDFLAGS = DESTDIR = prefix = /usr/local @@ -62,8 +61,8 @@ all : $(PROGRAMS) # Programs # -dmidecode : dmidecode.o dmiopt.o dmioem.o dmioutput.o util.o - $(CC) $(LDFLAGS) dmidecode.o dmiopt.o dmioem.o dmioutput.o util.o -o $@ +dmidecode : dmidecode.o dmiopt.o dmioem.o util.o + $(CC) $(LDFLAGS) dmidecode.o dmiopt.o dmioem.o util.o -o $@ biosdecode : biosdecode.o util.o $(CC) $(LDFLAGS) biosdecode.o util.o -o $@ @@ -79,16 +78,13 @@ vpddecode : vpddecode.o vpdopt.o util.o # dmidecode.o : dmidecode.c version.h types.h util.h config.h dmidecode.h \ - dmiopt.h dmioem.h dmioutput.h + dmiopt.h dmioem.h $(CC) $(CFLAGS) -c $< -o $@ dmiopt.o : dmiopt.c config.h types.h util.h dmidecode.h dmiopt.h $(CC) $(CFLAGS) -c $< -o $@ -dmioem.o : dmioem.c types.h dmidecode.h dmioem.h dmioutput.h - $(CC) $(CFLAGS) -c $< -o $@ - -dmioutput.o : dmioutput.c types.h dmioutput.h +dmioem.o : dmioem.c types.h dmidecode.h dmioem.h $(CC) $(CFLAGS) -c $< -o $@ biosdecode.o : biosdecode.c version.h types.h util.h config.h diff --git a/config.h b/config.h index 4237355..e39091f 100644 --- a/config.h +++ b/config.h @@ -26,9 +26,4 @@ #define ALIGNMENT_WORKAROUND #endif -/* Avoid unaligned memcpy on /dev/mem */ -#ifdef __aarch64__ -#define USE_SLOW_MEMCPY -#endif - #endif diff --git a/dmidecode.c b/dmidecode.c index 981fe96..a3e9d6c 100644 --- a/dmidecode.c +++ b/dmidecode.c @@ -2,7 +2,7 @@ * DMI Decode * * Copyright (C) 2000-2002 Alan Cox - * Copyright (C) 2002-2020 Jean Delvare + * Copyright (C) 2002-2018 Jean Delvare * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -66,7 +66,6 @@ #include #include #include -#include #ifdef __FreeBSD__ #include @@ -80,7 +79,6 @@ #include "dmidecode.h" #include "dmiopt.h" #include "dmioem.h" -#include "dmioutput.h" #define out_of_spec "" static const char *bad_index = ""; @@ -110,19 +108,13 @@ int is_printable(const u8 *data, int len) return 1; } -/* Replace non-ASCII characters with dots */ -static void ascii_filter(char *bp, size_t len) -{ - size_t i; - - for (i = 0; i < len; i++) - if (bp[i] < 32 || bp[i] == 127) - bp[i] = '.'; -} - -static char *_dmi_string(const struct dmi_header *dm, u8 s, int filter) +const char *dmi_string(const struct dmi_header *dm, u8 s) { char *bp = (char *)dm->data; + size_t i, len; + + if (s == 0) + return "Not Specified"; bp += dm->length; while (s > 1 && *bp) @@ -133,25 +125,17 @@ static char *_dmi_string(const struct dmi_header *dm, u8 s, int filter) } if (!*bp) - return NULL; - - if (filter) - ascii_filter(bp, strlen(bp)); - - return bp; -} - -const char *dmi_string(const struct dmi_header *dm, u8 s) -{ - char *bp; - - if (s == 0) - return "Not Specified"; - - bp = _dmi_string(dm, s, 1); - if (bp == NULL) return bad_index; + if (!(opt.flags & FLAG_DUMP)) + { + /* ASCII filtering */ + len = strlen(bp); + for (i = 0; i < len; i++) + if (bp[i] < 32 || bp[i] == 127) + bp[i] = '.'; + } + return bp; } @@ -220,54 +204,58 @@ static int dmi_bcd_range(u8 value, u8 low, u8 high) return 1; } -static void dmi_dump(const struct dmi_header *h) +static void dmi_dump(const struct dmi_header *h, const char *prefix) { - static char raw_data[48]; int row, i; - unsigned int off; - char *s; + const char *s; - pr_list_start("Header and Data", NULL); + printf("%sHeader and Data:\n", prefix); for (row = 0; row < ((h->length - 1) >> 4) + 1; row++) { - off = 0; + printf("%s\t", prefix); for (i = 0; i < 16 && i < h->length - (row << 4); i++) - off += sprintf(raw_data + off, i ? " %02X" : "%02X", + printf("%s%02X", i ? " " : "", (h->data)[(row << 4) + i]); - pr_list_item(raw_data); + printf("\n"); } - pr_list_end(); if ((h->data)[h->length] || (h->data)[h->length + 1]) { - pr_list_start("Strings", NULL); + printf("%sStrings:\n", prefix); i = 1; - while ((s = _dmi_string(h, i++, !(opt.flags & FLAG_DUMP)))) + while ((s = dmi_string(h, i++)) != bad_index) { if (opt.flags & FLAG_DUMP) { int j, l = strlen(s) + 1; - - off = 0; for (row = 0; row < ((l - 1) >> 4) + 1; row++) { + printf("%s\t", prefix); for (j = 0; j < 16 && j < l - (row << 4); j++) - off += sprintf(raw_data + off, - j ? " %02X" : "%02X", + printf("%s%02X", j ? " " : "", (unsigned char)s[(row << 4) + j]); - pr_list_item(raw_data); + printf("\n"); } /* String isn't filtered yet so do it now */ - ascii_filter(s, l - 1); + printf("%s\t\"", prefix); + while (*s) + { + if (*s < 32 || *s == 127) + fputc('.', stdout); + else + fputc(*s, stdout); + s++; + } + printf("\"\n"); } - pr_list_item("%s", s); + else + printf("%s\t%s\n", prefix, s); } - pr_list_end(); } } /* shift is 0 if the value is in bytes, 1 if it is in kilobytes */ -static void dmi_print_memory_size(const char *attr, u64 code, int shift) +static void dmi_print_memory_size(u64 code, int shift) { unsigned long capacity; u16 split[7]; @@ -307,7 +295,7 @@ static void dmi_print_memory_size(const char *attr, u64 code, int shift) else capacity = split[i]; - pr_attr(attr, "%lu %s", capacity, unit[i + shift]); + printf(" %lu %s", capacity, unit[i + shift]); } /* @@ -316,19 +304,10 @@ static void dmi_print_memory_size(const char *attr, u64 code, int shift) static void dmi_bios_runtime_size(u32 code) { - const char *format; - if (code & 0x000003FF) - { - format = "%u bytes"; - } + printf(" %u bytes", code); else - { - format = "%u kB"; - code >>= 10; - } - - pr_attr("Runtime Size", format, code); + printf(" %u kB", code >> 10); } static void dmi_bios_rom_size(u8 code1, u16 code2) @@ -338,15 +317,12 @@ static void dmi_bios_rom_size(u8 code1, u16 code2) }; if (code1 != 0xFF) - { - u64 s = { .l = (code1 + 1) << 6 }; - dmi_print_memory_size("ROM Size", s, 1); - } + printf(" %u kB", (code1 + 1) << 6); else - pr_attr("ROM Size", "%u %s", code2 & 0x3FFF, unit[code2 >> 14]); + printf(" %u %s", code2 & 0x3FFF, unit[code2 >> 14]); } -static void dmi_bios_characteristics(u64 code) +static void dmi_bios_characteristics(u64 code, const char *prefix) { /* 7.1.1 */ static const char *characteristics[] = { @@ -387,16 +363,18 @@ static void dmi_bios_characteristics(u64 code) */ if (code.l & (1 << 3)) { - pr_list_item("%s", characteristics[0]); + printf("%s%s\n", + prefix, characteristics[0]); return; } for (i = 4; i <= 31; i++) if (code.l & (1 << i)) - pr_list_item("%s", characteristics[i - 3]); + printf("%s%s\n", + prefix, characteristics[i - 3]); } -static void dmi_bios_characteristics_x1(u8 code) +static void dmi_bios_characteristics_x1(u8 code, const char *prefix) { /* 7.1.2.1 */ static const char *characteristics[] = { @@ -413,10 +391,11 @@ static void dmi_bios_characteristics_x1(u8 code) for (i = 0; i <= 7; i++) if (code & (1 << i)) - pr_list_item("%s", characteristics[i]); + printf("%s%s\n", + prefix, characteristics[i]); } -static void dmi_bios_characteristics_x2(u8 code) +static void dmi_bios_characteristics_x2(u8 code, const char *prefix) { /* 37.1.2.2 */ static const char *characteristics[] = { @@ -430,15 +409,15 @@ static void dmi_bios_characteristics_x2(u8 code) for (i = 0; i <= 4; i++) if (code & (1 << i)) - pr_list_item("%s", characteristics[i]); + printf("%s%s\n", + prefix, characteristics[i]); } /* * 7.2 System Information (Type 1) */ -static void dmi_system_uuid(void (*print_cb)(const char *name, const char *format, ...), - const char *attr, const u8 *p, u16 ver) +static void dmi_system_uuid(const u8 *p, u16 ver) { int only0xFF = 1, only0x00 = 1; int i; @@ -451,18 +430,12 @@ static void dmi_system_uuid(void (*print_cb)(const char *name, const char *forma if (only0xFF) { - if (print_cb) - print_cb(attr, "Not Present"); - else - printf("Not Present\n"); + printf("Not Present"); return; } if (only0x00) { - if (print_cb) - print_cb(attr, "Not Settable"); - else - printf("Not Settable\n"); + printf("Not Settable"); return; } @@ -475,29 +448,13 @@ static void dmi_system_uuid(void (*print_cb)(const char *name, const char *forma * for older versions. */ if (ver >= 0x0206) - { - if (print_cb) - print_cb(attr, - "%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x", - p[3], p[2], p[1], p[0], p[5], p[4], p[7], p[6], - p[8], p[9], p[10], p[11], p[12], p[13], p[14], p[15]); - else - printf("%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x\n", - p[3], p[2], p[1], p[0], p[5], p[4], p[7], p[6], - p[8], p[9], p[10], p[11], p[12], p[13], p[14], p[15]); - } + printf("%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x", + p[3], p[2], p[1], p[0], p[5], p[4], p[7], p[6], + p[8], p[9], p[10], p[11], p[12], p[13], p[14], p[15]); else - { - if (print_cb) - print_cb(attr, - "%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x", - p[0], p[1], p[2], p[3], p[4], p[5], p[6], p[7], - p[8], p[9], p[10], p[11], p[12], p[13], p[14], p[15]); - else - printf("%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x\n", - p[0], p[1], p[2], p[3], p[4], p[5], p[6], p[7], - p[8], p[9], p[10], p[11], p[12], p[13], p[14], p[15]); - } + printf("%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x", + p[0], p[1], p[2], p[3], p[4], p[5], p[6], p[7], + p[8], p[9], p[10], p[11], p[12], p[13], p[14], p[15]); } static const char *dmi_system_wake_up_type(u8 code) @@ -524,7 +481,7 @@ static const char *dmi_system_wake_up_type(u8 code) * 7.3 Base Board Information (Type 2) */ -static void dmi_base_board_features(u8 code) +static void dmi_base_board_features(u8 code, const char *prefix) { /* 7.3.1 */ static const char *features[] = { @@ -536,17 +493,17 @@ static void dmi_base_board_features(u8 code) }; if ((code & 0x1F) == 0) - pr_list_start("Features", "%s", "None"); + printf(" None\n"); else { int i; - pr_list_start("Features", NULL); + printf("\n"); for (i = 0; i <= 4; i++) if (code & (1 << i)) - pr_list_item("%s", features[i]); + printf("%s%s\n", + prefix, features[i]); } - pr_list_end(); } static const char *dmi_base_board_type(u8 code) @@ -573,14 +530,15 @@ static const char *dmi_base_board_type(u8 code) return out_of_spec; } -static void dmi_base_board_handles(u8 count, const u8 *p) +static void dmi_base_board_handles(u8 count, const u8 *p, const char *prefix) { int i; - pr_list_start("Contained Object Handles", "%u", count); + printf("%sContained Object Handles: %u\n", + prefix, count); for (i = 0; i < count; i++) - pr_list_item("0x%04X", WORD(p + sizeof(u16) * i)); - pr_list_end(); + printf("%s\t0x%04X\n", + prefix, WORD(p + sizeof(u16) * i)); } /* @@ -682,42 +640,40 @@ static const char *dmi_chassis_security_status(u8 code) static void dmi_chassis_height(u8 code) { if (code == 0x00) - pr_attr("Height", "Unspecified"); + printf(" Unspecified"); else - pr_attr("Height", "%u U", code); + printf(" %u U", code); } static void dmi_chassis_power_cords(u8 code) { if (code == 0x00) - pr_attr("Number Of Power Cords", "Unspecified"); + printf(" Unspecified"); else - pr_attr("Number Of Power Cords", "%u", code); + printf(" %u", code); } -static void dmi_chassis_elements(u8 count, u8 len, const u8 *p) +static void dmi_chassis_elements(u8 count, u8 len, const u8 *p, const char *prefix) { int i; - pr_list_start("Contained Elements", "%u", count); + printf("%sContained Elements: %u\n", + prefix, count); for (i = 0; i < count; i++) { if (len >= 0x03) { - const char *type; - - type = (p[i * len] & 0x80) ? + printf("%s\t%s (", + prefix, p[i * len] & 0x80 ? dmi_smbios_structure_type(p[i * len] & 0x7F) : - dmi_base_board_type(p[i * len] & 0x7F); - + dmi_base_board_type(p[i * len] & 0x7F)); if (p[1 + i * len] == p[2 + i * len]) - pr_list_item("%s (%u)", type, p[1 + i * len]); + printf("%u", p[1 + i * len]); else - pr_list_item("%s (%u-%u)", type, p[1 + i * len], - p[2 + i * len]); + printf("%u-%u", p[1 + i * len], p[2 + i * len]); + printf(")\n"); } } - pr_list_end(); } /* @@ -976,10 +932,6 @@ static const char *dmi_processor_family(const struct dmi_header *h, u16 ver) { 0x140, "WinChip" }, { 0x15E, "DSP" }, { 0x1F4, "Video Processor" }, - - { 0x200, "RV32" }, - { 0x201, "RV64" }, - { 0x202, "RV128" }, }; /* * Note to developers: when adding entries to this list, check if @@ -1037,7 +989,7 @@ static const char *dmi_processor_family(const struct dmi_header *h, u16 ver) } } -static void dmi_processor_id(const struct dmi_header *h) +static void dmi_processor_id(const struct dmi_header *h, const char *prefix) { /* Intel AP-485 revision 36, table 2-4 */ static const char *flags[32] = { @@ -1087,8 +1039,8 @@ static void dmi_processor_id(const struct dmi_header *h) * This might help learn about new processors supporting the * CPUID instruction or another form of identification. */ - pr_attr("ID", "%02X %02X %02X %02X %02X %02X %02X %02X", - p[0], p[1], p[2], p[3], p[4], p[5], p[6], p[7]); + printf("%sID: %02X %02X %02X %02X %02X %02X %02X %02X\n", + prefix, p[0], p[1], p[2], p[3], p[4], p[5], p[6], p[7]); if (type == 0x05) /* 80386 */ { @@ -1096,9 +1048,8 @@ static void dmi_processor_id(const struct dmi_header *h) /* * 80386 have a different signature. */ - pr_attr("Signature", - "Type %u, Family %u, Major Stepping %u, Minor Stepping %u", - dx >> 12, (dx >> 8) & 0xF, + printf("%sSignature: Type %u, Family %u, Major Stepping %u, Minor Stepping %u\n", + prefix, dx >> 12, (dx >> 8) & 0xF, (dx >> 4) & 0xF, dx & 0xF); return; } @@ -1116,9 +1067,8 @@ static void dmi_processor_id(const struct dmi_header *h) sig = 1; else { - pr_attr("Signature", - "Type %u, Family %u, Model %u, Stepping %u", - (dx >> 12) & 0x3, (dx >> 8) & 0xF, + printf("%sSignature: Type %u, Family %u, Model %u, Stepping %u\n", + prefix, (dx >> 12) & 0x3, (dx >> 8) & 0xF, (dx >> 4) & 0xF, dx & 0xF); return; } @@ -1134,9 +1084,8 @@ static void dmi_processor_id(const struct dmi_header *h) */ if (midr == 0) return; - pr_attr("Signature", - "Implementor 0x%02x, Variant 0x%x, Architecture %u, Part 0x%03x, Revision %u", - midr >> 24, (midr >> 20) & 0xF, + printf("%sSignature: Implementor 0x%02x, Variant 0x%x, Architecture %u, Part 0x%03x, Revision %u\n", + prefix, midr >> 24, (midr >> 20) & 0xF, (midr >> 16) & 0xF, (midr >> 4) & 0xFFF, midr & 0xF); return; } @@ -1191,15 +1140,15 @@ static void dmi_processor_id(const struct dmi_header *h) switch (sig) { case 1: /* Intel */ - pr_attr("Signature", - "Type %u, Family %u, Model %u, Stepping %u", - (eax >> 12) & 0x3, + printf("%sSignature: Type %u, Family %u, Model %u, Stepping %u\n", + prefix, (eax >> 12) & 0x3, ((eax >> 20) & 0xFF) + ((eax >> 8) & 0x0F), ((eax >> 12) & 0xF0) + ((eax >> 4) & 0x0F), eax & 0xF); break; case 2: /* AMD, publication #25481 revision 2.28 */ - pr_attr("Signature", "Family %u, Model %u, Stepping %u", + printf("%sSignature: Family %u, Model %u, Stepping %u\n", + prefix, ((eax >> 8) & 0xF) + (((eax >> 8) & 0xF) == 0xF ? (eax >> 20) & 0xFF : 0), ((eax >> 4) & 0xF) | (((eax >> 8) & 0xF) == 0xF ? (eax >> 12) & 0xF0 : 0), eax & 0xF); @@ -1207,21 +1156,21 @@ static void dmi_processor_id(const struct dmi_header *h) } edx = DWORD(p + 4); + printf("%sFlags:", prefix); if ((edx & 0xBFEFFBFF) == 0) - pr_list_start("Flags", "None"); + printf(" None\n"); else { int i; - pr_list_start("Flags", NULL); + printf("\n"); for (i = 0; i <= 31; i++) if (flags[i] != NULL && edx & (1 << i)) - pr_list_item("%s", flags[i]); + printf("%s\t%s\n", prefix, flags[i]); } - pr_list_end(); } -static void dmi_processor_voltage(const char *attr, u8 code) +static void dmi_processor_voltage(u8 code) { /* 7.5.4 */ static const char *voltage[] = { @@ -1232,47 +1181,25 @@ static void dmi_processor_voltage(const char *attr, u8 code) int i; if (code & 0x80) - pr_attr(attr, "%.1f V", (float)(code & 0x7f) / 10); - else if ((code & 0x07) == 0x00) - pr_attr(attr, "Unknown"); + printf(" %.1f V", (float)(code & 0x7f) / 10); else { - char voltage_str[18]; - int off = 0; - for (i = 0; i <= 2; i++) - { if (code & (1 << i)) - { - /* Insert space if not the first value */ - off += sprintf(voltage_str + off, - off ? " %s" :"%s", - voltage[i]); - } - } - if (off) - pr_attr(attr, voltage_str); + printf(" %s", voltage[i]); + if (code == 0x00) + printf(" Unknown"); } } -static void dmi_processor_frequency(const char *attr, const u8 *p) +static void dmi_processor_frequency(const u8 *p) { u16 code = WORD(p); if (code) - { - if (attr) - pr_attr(attr, "%u MHz", code); - else - printf("%u MHz\n", code); - } + printf("%u MHz", code); else - { - if (attr) - pr_attr(attr, "Unknown"); - else - printf("Unknown\n"); - } + printf("Unknown"); } /* code is assumed to be a 3-bit value */ @@ -1363,21 +1290,20 @@ static const char *dmi_processor_upgrade(u8 code) return out_of_spec; } -static void dmi_processor_cache(const char *attr, u16 code, const char *level, - u16 ver) +static void dmi_processor_cache(u16 code, const char *level, u16 ver) { if (code == 0xFFFF) { if (ver >= 0x0203) - pr_attr(attr, "Not Provided"); + printf(" Not Provided"); else - pr_attr(attr, "No %s Cache", level); + printf(" No %s Cache", level); } else - pr_attr(attr, "0x%04X", code); + printf(" 0x%04X", code); } -static void dmi_processor_characteristics(const char *attr, u16 code) +static void dmi_processor_characteristics(u16 code, const char *prefix) { /* 7.5.9 */ static const char *characteristics[] = { @@ -1390,16 +1316,15 @@ static void dmi_processor_characteristics(const char *attr, u16 code) }; if ((code & 0x00FC) == 0) - pr_attr(attr, "None"); + printf(" None\n"); else { int i; - pr_list_start(attr, NULL); + printf("\n"); for (i = 2; i <= 7; i++) if (code & (1 << i)) - pr_list_item("%s", characteristics[i - 2]); - pr_list_end(); + printf("%s%s\n", prefix, characteristics[i - 2]); } } @@ -1426,7 +1351,7 @@ static const char *dmi_memory_controller_ed_method(u8 code) return out_of_spec; } -static void dmi_memory_controller_ec_capabilities(const char *attr, u8 code) +static void dmi_memory_controller_ec_capabilities(u8 code, const char *prefix) { /* 7.6.2 */ static const char *capabilities[] = { @@ -1439,16 +1364,15 @@ static void dmi_memory_controller_ec_capabilities(const char *attr, u8 code) }; if ((code & 0x3F) == 0) - pr_attr(attr, "None"); + printf(" None\n"); else { int i; - pr_list_start(attr, NULL); + printf("\n"); for (i = 0; i <= 5; i++) if (code & (1 << i)) - pr_list_item("%s", capabilities[i]); - pr_list_end(); + printf("%s%s\n", prefix, capabilities[i]); } } @@ -1470,7 +1394,7 @@ static const char *dmi_memory_controller_interleave(u8 code) return out_of_spec; } -static void dmi_memory_controller_speeds(const char *attr, u16 code) +static void dmi_memory_controller_speeds(u16 code, const char *prefix) { /* 7.6.4 */ const char *speeds[] = { @@ -1482,34 +1406,34 @@ static void dmi_memory_controller_speeds(const char *attr, u16 code) }; if ((code & 0x001F) == 0) - pr_attr(attr, "None"); + printf(" None\n"); else { int i; - pr_list_start(attr, NULL); + printf("\n"); for (i = 0; i <= 4; i++) if (code & (1 << i)) - pr_list_item("%s", speeds[i]); - pr_list_end(); + printf("%s%s\n", prefix, speeds[i]); } } -static void dmi_memory_controller_slots(u8 count, const u8 *p) +static void dmi_memory_controller_slots(u8 count, const u8 *p, const char *prefix) { int i; - pr_list_start("Associated Memory Slots", "%u", count); + printf("%sAssociated Memory Slots: %u\n", + prefix, count); for (i = 0; i < count; i++) - pr_list_item("0x%04X", WORD(p + sizeof(u16) * i)); - pr_list_end(); + printf("%s\t0x%04X\n", + prefix, WORD(p + sizeof(u16) * i)); } /* * 7.7 Memory Module Information (Type 6) */ -static void dmi_memory_module_types(const char *attr, u16 code, int flat) +static void dmi_memory_module_types(u16 code, const char *sep) { /* 7.7.1 */ static const char *types[] = { @@ -1527,97 +1451,74 @@ static void dmi_memory_module_types(const char *attr, u16 code, int flat) }; if ((code & 0x07FF) == 0) - pr_attr(attr, "None"); - else if (flat) - { - char type_str[68]; - int i, off = 0; - - for (i = 0; i <= 10; i++) - { - if (code & (1 << i)) - { - /* Insert space if not the first value */ - off += sprintf(type_str + off, - off ? " %s" :"%s", - types[i]); - } - } - if (off) - pr_attr(attr, type_str); - } + printf(" None"); else { int i; - pr_list_start(attr, NULL); for (i = 0; i <= 10; i++) if (code & (1 << i)) - pr_list_item("%s", types[i]); - pr_list_end(); + printf("%s%s", sep, types[i]); } } static void dmi_memory_module_connections(u8 code) { if (code == 0xFF) - pr_attr("Bank Connections", "None"); - else if ((code & 0xF0) == 0xF0) - pr_attr("Bank Connections", "%u", code & 0x0F); - else if ((code & 0x0F) == 0x0F) - pr_attr("Bank Connections", "%u", code >> 4); + printf(" None"); else - pr_attr("Bank Connections", "%u %u", code >> 4, code & 0x0F); + { + if ((code & 0xF0) != 0xF0) + printf(" %u", code >> 4); + if ((code & 0x0F) != 0x0F) + printf(" %u", code & 0x0F); + } } -static void dmi_memory_module_speed(const char *attr, u8 code) +static void dmi_memory_module_speed(u8 code) { if (code == 0) - pr_attr(attr, "Unknown"); + printf(" Unknown"); else - pr_attr(attr, "%u ns", code); + printf(" %u ns", code); } -static void dmi_memory_module_size(const char *attr, u8 code) +static void dmi_memory_module_size(u8 code) { - const char *connection; - /* 7.7.2 */ - if (code & 0x80) - connection = " (Double-bank Connection)"; - else - connection = " (Single-bank Connection)"; - switch (code & 0x7F) { case 0x7D: - pr_attr(attr, "Not Determinable%s", connection); + printf(" Not Determinable"); break; case 0x7E: - pr_attr(attr, "Disabled%s", connection); + printf(" Disabled"); break; case 0x7F: - pr_attr(attr, "Not Installed"); + printf(" Not Installed"); return; default: - pr_attr(attr, "%u MB%s", 1 << (code & 0x7F), - connection); + printf(" %u MB", 1 << (code & 0x7F)); } + + if (code & 0x80) + printf(" (Double-bank Connection)"); + else + printf(" (Single-bank Connection)"); } -static void dmi_memory_module_error(u8 code) +static void dmi_memory_module_error(u8 code, const char *prefix) { - static const char *status[] = { - "OK", /* 0x00 */ - "Uncorrectable Errors", - "Correctable Errors", - "Correctable and Uncorrectable Errors" /* 0x03 */ - }; - if (code & (1 << 2)) - pr_attr("Error Status", "See Event Log"); + printf(" See Event Log\n"); else - pr_attr("Error Status", "%s", status[code & 0x03]); + { if ((code & 0x03) == 0) + printf(" OK\n"); + if (code & (1 << 0)) + printf("%sUncorrectable Errors\n", prefix); + if (code & (1 << 1)) + printf("%sCorrectable Errors\n", prefix); + } } /* @@ -1649,33 +1550,30 @@ static const char *dmi_cache_location(u8 code) return location[code]; } -static void dmi_cache_size_2(const char *attr, u32 code) +static void dmi_cache_size(u16 code) { - u64 size; + if (code & 0x8000) + printf(" %u kB", (code & 0x7FFF) << 6); + else + printf(" %u kB", code); +} +static void dmi_cache_size_2(u32 code) +{ if (code & 0x80000000) { code &= 0x7FFFFFFFLU; - size.l = code << 6; - size.h = code >> 26; + /* Use a more convenient unit for large cache size */ + if (code >= 0x8000) + printf(" %u MB", code >> 4); + else + printf(" %u kB", code << 6); } else - { - size.l = code; - size.h = 0; - } - - /* Use a more convenient unit for large cache size */ - dmi_print_memory_size(attr, size, 1); + printf(" %u kB", code); } -static void dmi_cache_size(const char *attr, u16 code) -{ - dmi_cache_size_2(attr, - (((u32)code & 0x8000LU) << 16) | (code & 0x7FFFLU)); -} - -static void dmi_cache_types(const char *attr, u16 code, int flat) +static void dmi_cache_types(u16 code, const char *sep) { /* 7.8.2 */ static const char *types[] = { @@ -1689,34 +1587,14 @@ static void dmi_cache_types(const char *attr, u16 code, int flat) }; if ((code & 0x007F) == 0) - pr_attr(attr, "None"); - else if (flat) - { - char type_str[70]; - int i, off = 0; - - for (i = 0; i <= 6; i++) - { - if (code & (1 << i)) - { - /* Insert space if not the first value */ - off += sprintf(type_str + off, - off ? " %s" :"%s", - types[i]); - } - } - if (off) - pr_attr(attr, type_str); - } + printf(" None"); else { int i; - pr_list_start(attr, NULL); for (i = 0; i <= 6; i++) if (code & (1 << i)) - pr_list_item("%s", types[i]); - pr_list_end(); + printf("%s%s", sep, types[i]); } } @@ -1937,9 +1815,6 @@ static const char *dmi_slot_type(u8 code) "PCI Express Mini 52-pin without bottom-side keep-outs", "PCI Express Mini 76-pin" /* 0x23 */ }; - static const char *type_0x30[] = { - "CXL FLexbus 1.0" /* 0x30 */ - }; static const char *type_0xA0[] = { "PC-98/C20", /* 0xA0 */ "PC-98/C24", @@ -1963,14 +1838,7 @@ static const char *dmi_slot_type(u8 code) "PCI Express 3 x2", "PCI Express 3 x4", "PCI Express 3 x8", - "PCI Express 3 x16", - out_of_spec, /* 0xB7 */ - "PCI Express 4", - "PCI Express 4 x1", - "PCI Express 4 x2", - "PCI Express 4 x4", - "PCI Express 4 x8", - "PCI Express 4 x16" /* 0xBD */ + "PCI Express 3 x16" /* 0xB6 */ }; /* * Note to developers: when adding entries to these lists, check if @@ -1979,9 +1847,7 @@ static const char *dmi_slot_type(u8 code) if (code >= 0x01 && code <= 0x23) return type[code - 0x01]; - if (code == 0x30) - return type_0x30[code - 0x30]; - if (code >= 0xA0 && code <= 0xBD) + if (code >= 0xA0 && code <= 0xB6) return type_0xA0[code - 0xA0]; return out_of_spec; } @@ -2029,31 +1895,29 @@ static const char *dmi_slot_current_usage(u8 code) static const char *dmi_slot_length(u8 code) { - /* 7.10.4 */ + /* 7.1O.4 */ static const char *length[] = { "Other", /* 0x01 */ "Unknown", "Short", - "Long", - "2.5\" drive form factor", - "3.5\" drive form factor" /* 0x06 */ + "Long" /* 0x04 */ }; - if (code >= 0x01 && code <= 0x06) + if (code >= 0x01 && code <= 0x04) return length[code - 0x01]; return out_of_spec; } -static void dmi_slot_id(u8 code1, u8 code2, u8 type) +static void dmi_slot_id(u8 code1, u8 code2, u8 type, const char *prefix) { /* 7.10.5 */ switch (type) { case 0x04: /* MCA */ - pr_attr("ID", "%u", code1); + printf("%sID: %u\n", prefix, code1); break; case 0x05: /* EISA */ - pr_attr("ID", "%u", code1); + printf("%sID: %u\n", prefix, code1); break; case 0x06: /* PCI */ case 0x0E: /* PCI */ @@ -2085,21 +1949,15 @@ static void dmi_slot_id(u8 code1, u8 code2, u8 type) case 0xB4: /* PCI Express 3 */ case 0xB5: /* PCI Express 3 */ case 0xB6: /* PCI Express 3 */ - case 0xB8: /* PCI Express 4 */ - case 0xB9: /* PCI Express 4 */ - case 0xBA: /* PCI Express 4 */ - case 0xBB: /* PCI Express 4 */ - case 0xBC: /* PCI Express 4 */ - case 0xBD: /* PCI Express 4 */ - pr_attr("ID", "%u", code1); + printf("%sID: %u\n", prefix, code1); break; case 0x07: /* PCMCIA */ - pr_attr("ID", "Adapter %u, Socket %u", code1, code2); + printf("%sID: Adapter %u, Socket %u\n", prefix, code1, code2); break; } } -static void dmi_slot_characteristics(const char *attr, u8 code1, u8 code2) +static void dmi_slot_characteristics(u8 code1, u8 code2, const char *prefix) { /* 7.10.6 */ static const char *characteristics1[] = { @@ -2120,44 +1978,29 @@ static void dmi_slot_characteristics(const char *attr, u8 code1, u8 code2) }; if (code1 & (1 << 0)) - pr_attr(attr, "Unknown"); + printf(" Unknown\n"); else if ((code1 & 0xFE) == 0 && (code2 & 0x07) == 0) - pr_attr(attr, "None"); + printf(" None\n"); else { int i; - pr_list_start(attr, NULL); + printf("\n"); for (i = 1; i <= 7; i++) if (code1 & (1 << i)) - pr_list_item("%s", characteristics1[i - 1]); + printf("%s%s\n", prefix, characteristics1[i - 1]); for (i = 0; i <= 3; i++) if (code2 & (1 << i)) - pr_list_item("%s", characteristics2[i]); - pr_list_end(); + printf("%s%s\n", prefix, characteristics2[i]); } } -static void dmi_slot_segment_bus_func(u16 code1, u8 code2, u8 code3) +static void dmi_slot_segment_bus_func(u16 code1, u8 code2, u8 code3, const char *prefix) { /* 7.10.8 */ if (!(code1 == 0xFFFF && code2 == 0xFF && code3 == 0xFF)) - pr_attr("Bus Address", "%04x:%02x:%02x.%x", - code1, code2, code3 >> 3, code3 & 0x7); -} - -static void dmi_slot_peers(u8 n, const u8 *data) -{ - char attr[16]; - int i; - - for (i = 1; i <= n; i++, data += 5) - { - sprintf(attr, "Peer Device %hu", i); - pr_attr(attr, "%04x:%02x:%02x.%x (Width %u)", - WORD(data), data[2], data[3] >> 3, data[3] & 0x07, - data[4]); - } + printf("%sBus Address: %04x:%02x:%02x.%x\n", + prefix, code1, code2, code3 >> 3, code3 & 0x7); } /* @@ -2185,7 +2028,7 @@ static const char *dmi_on_board_devices_type(u8 code) return out_of_spec; } -static void dmi_on_board_devices(const struct dmi_header *h) +static void dmi_on_board_devices(const struct dmi_header *h, const char *prefix) { u8 *p = h->data + 4; u8 count = (h->length - 0x04) / 2; @@ -2194,15 +2037,17 @@ static void dmi_on_board_devices(const struct dmi_header *h) for (i = 0; i < count; i++) { if (count == 1) - pr_handle_name("On Board Device Information"); + printf("%sOn Board Device Information\n", + prefix); else - pr_handle_name("On Board Device %d Information", - i + 1); - pr_attr("Type", "%s", - dmi_on_board_devices_type(p[2 * i] & 0x7F)); - pr_attr("Status", "%s", - p[2 * i] & 0x80 ? "Enabled" : "Disabled"); - pr_attr("Description", "%s", dmi_string(h, p[2 * i + 1])); + printf("%sOn Board Device %d Information\n", + prefix, i + 1); + printf("%s\tType: %s\n", + prefix, dmi_on_board_devices_type(p[2 * i] & 0x7F)); + printf("%s\tStatus: %s\n", + prefix, p[2 * i] & 0x80 ? "Enabled" : "Disabled"); + printf("%s\tDescription: %s\n", + prefix, dmi_string(h, p[2 * i + 1])); } } @@ -2210,50 +2055,45 @@ static void dmi_on_board_devices(const struct dmi_header *h) * 7.12 OEM Strings (Type 11) */ -static void dmi_oem_strings(const struct dmi_header *h) +static void dmi_oem_strings(const struct dmi_header *h, const char *prefix) { - char attr[11]; u8 *p = h->data + 4; u8 count = p[0x00]; int i; for (i = 1; i <= count; i++) - { - sprintf(attr, "String %hu", i); - pr_attr(attr, "%s",dmi_string(h, i)); - } + printf("%sString %d: %s\n", + prefix, i, dmi_string(h, i)); } /* * 7.13 System Configuration Options (Type 12) */ -static void dmi_system_configuration_options(const struct dmi_header *h) +static void dmi_system_configuration_options(const struct dmi_header *h, const char *prefix) { - char attr[11]; u8 *p = h->data + 4; u8 count = p[0x00]; int i; for (i = 1; i <= count; i++) - { - sprintf(attr, "Option %hu", i); - pr_attr(attr, "%s",dmi_string(h, i)); - } + printf("%sOption %d: %s\n", + prefix, i, dmi_string(h, i)); } /* * 7.14 BIOS Language Information (Type 13) */ -static void dmi_bios_languages(const struct dmi_header *h) +static void dmi_bios_languages(const struct dmi_header *h, const char *prefix) { u8 *p = h->data + 4; u8 count = p[0x00]; int i; for (i = 1; i <= count; i++) - pr_list_item("%s", dmi_string(h, i)); + printf("%s%s\n", + prefix, dmi_string(h, i)); } static const char *dmi_bios_language_format(u8 code) @@ -2268,14 +2108,14 @@ static const char *dmi_bios_language_format(u8 code) * 7.15 Group Associations (Type 14) */ -static void dmi_group_associations_items(u8 count, const u8 *p) +static void dmi_group_associations_items(u8 count, const u8 *p, const char *prefix) { int i; for (i = 0; i < count; i++) { - pr_list_item("0x%04X (%s)", - WORD(p + 3 * i + 1), + printf("%s0x%04X (%s)\n", + prefix, WORD(p + 3 * i + 1), dmi_smbios_structure_type(p[3 * i])); } } @@ -2312,7 +2152,7 @@ static void dmi_event_log_status(u8 code) "Full" /* 1 */ }; - pr_attr("Status", "%s, %s", + printf(" %s, %s", valid[(code >> 0) & 1], full[(code >> 1) & 1]); } @@ -2324,17 +2164,16 @@ static void dmi_event_log_address(u8 method, const u8 *p) case 0x00: case 0x01: case 0x02: - pr_attr("Access Address", "Index 0x%04X, Data 0x%04X", - WORD(p), WORD(p + 2)); + printf(" Index 0x%04X, Data 0x%04X", WORD(p), WORD(p + 2)); break; case 0x03: - pr_attr("Access Address", "0x%08X", DWORD(p)); + printf(" 0x%08X", DWORD(p)); break; case 0x04: - pr_attr("Access Address", "0x%04X", WORD(p)); + printf(" 0x%04X", WORD(p)); break; default: - pr_attr("Access Address", "Unknown"); + printf(" Unknown"); } } @@ -2411,22 +2250,19 @@ static const char *dmi_event_log_descriptor_format(u8 code) return out_of_spec; } -static void dmi_event_log_descriptors(u8 count, u8 len, const u8 *p) +static void dmi_event_log_descriptors(u8 count, u8 len, const u8 *p, const char *prefix) { /* 7.16.1 */ - char attr[16]; int i; for (i = 0; i < count; i++) { if (len >= 0x02) { - sprintf(attr, "Descriptor %hu", i + 1); - pr_attr(attr, "%s", - dmi_event_log_descriptor_type(p[i * len])); - sprintf(attr, "Data Format %hu", i + 1); - pr_attr(attr, "%s", - dmi_event_log_descriptor_format(p[i * len + 1])); + printf("%sDescriptor %u: %s\n", + prefix, i + 1, dmi_event_log_descriptor_type(p[i * len])); + printf("%sData Format %u: %s\n", + prefix, i + 1, dmi_event_log_descriptor_format(p[i * len + 1])); } } } @@ -2454,13 +2290,12 @@ static const char *dmi_memory_array_location(u8 code) "PC-98/C20 Add-on Card", /* 0xA0 */ "PC-98/C24 Add-on Card", "PC-98/E Add-on Card", - "PC-98/Local Bus Add-on Card", - "CXL Flexbus 1.0" /* 0xA4 */ + "PC-98/Local Bus Add-on Card" /* 0xA3 */ }; if (code >= 0x01 && code <= 0x0A) return location[code - 0x01]; - if (code >= 0xA0 && code <= 0xA4) + if (code >= 0xA0 && code <= 0xA3) return location_0xA0[code - 0xA0]; return out_of_spec; } @@ -2504,40 +2339,40 @@ static const char *dmi_memory_array_ec_type(u8 code) static void dmi_memory_array_error_handle(u16 code) { if (code == 0xFFFE) - pr_attr("Error Information Handle", "Not Provided"); + printf(" Not Provided"); else if (code == 0xFFFF) - pr_attr("Error Information Handle", "No Error"); + printf(" No Error"); else - pr_attr("Error Information Handle", "0x%04X", code); + printf(" 0x%04X", code); } /* * 7.18 Memory Device (Type 17) */ -static void dmi_memory_device_width(const char *attr, u16 code) +static void dmi_memory_device_width(u16 code) { /* * If no memory module is present, width may be 0 */ if (code == 0xFFFF || code == 0) - pr_attr(attr, "Unknown"); + printf(" Unknown"); else - pr_attr(attr, "%u bits", code); + printf(" %u bits", code); } static void dmi_memory_device_size(u16 code) { if (code == 0) - pr_attr("Size", "No Module Installed"); + printf(" No Module Installed"); else if (code == 0xFFFF) - pr_attr("Size", "Unknown"); + printf(" Unknown"); else { - u64 s = { .l = code & 0x7FFF }; - if (!(code & 0x8000)) - s.l <<= 10; - dmi_print_memory_size("Size", s, 1); + if (code & 0x8000) + printf(" %u kB", code & 0x7FFF); + else + printf(" %u MB", code); } } @@ -2550,20 +2385,19 @@ static void dmi_memory_device_extended_size(u32 code) * as an integer without rounding */ if (code & 0x3FFUL) - pr_attr("Size", "%lu MB", (unsigned long)code); + printf(" %lu MB", (unsigned long)code); else if (code & 0xFFC00UL) - pr_attr("Size", "%lu GB", (unsigned long)code >> 10); + printf(" %lu GB", (unsigned long)code >> 10); else - pr_attr("Size", "%lu TB", (unsigned long)code >> 20); + printf(" %lu TB", (unsigned long)code >> 20); } -static void dmi_memory_voltage_value(const char *attr, u16 code) +static void dmi_memory_voltage_value(u16 code) { if (code == 0) - pr_attr(attr, "Unknown"); + printf(" Unknown"); else - pr_attr(attr, code % 100 ? "%g V" : "%.1f V", - (float)code / 1000); + printf(code % 100 ? " %g V" : " %.1f V", (float)code / 1000); } static const char *dmi_memory_device_form_factor(u8 code) @@ -2584,11 +2418,10 @@ static const char *dmi_memory_device_form_factor(u8 code) "RIMM", "SODIMM", "SRIMM", - "FB-DIMM", - "Die" /* 0x10 */ + "FB-DIMM" /* 0x0F */ }; - if (code >= 0x01 && code <= 0x10) + if (code >= 0x01 && code <= 0x0F) return form_factor[code - 0x01]; return out_of_spec; } @@ -2596,11 +2429,11 @@ static const char *dmi_memory_device_form_factor(u8 code) static void dmi_memory_device_set(u8 code) { if (code == 0) - pr_attr("Set", "None"); + printf(" None"); else if (code == 0xFF) - pr_attr("Set", "Unknown"); + printf(" Unknown"); else - pr_attr("Set", "%u", code); + printf(" %u", code); } static const char *dmi_memory_device_type(u8 code) @@ -2636,13 +2469,10 @@ static const char *dmi_memory_device_type(u8 code) "LPDDR", "LPDDR2", "LPDDR3", - "LPDDR4", - "Logical non-volatile device", - "HBM", - "HBM2" /* 0x21 */ + "LPDDR4" /* 0x1E */ }; - if (code >= 0x01 && code <= 0x21) + if (code >= 0x01 && code <= 0x1E) return type[code - 0x01]; return out_of_spec; } @@ -2667,29 +2497,25 @@ static void dmi_memory_device_type_detail(u16 code) "Unbuffered (Unregistered)", "LRDIMM" /* 15 */ }; - char list[172]; /* Update length if you touch the array above */ if ((code & 0xFFFE) == 0) - pr_attr("Type Detail", "None"); + printf(" None"); else { - int i, off = 0; + int i; - list[0] = '\0'; for (i = 1; i <= 15; i++) if (code & (1 << i)) - off += sprintf(list + off, off ? " %s" : "%s", - detail[i - 1]); - pr_attr("Type Detail", list); + printf(" %s", detail[i - 1]); } } -static void dmi_memory_device_speed(const char *attr, u16 code) +static void dmi_memory_device_speed(u16 code) { if (code == 0) - pr_attr(attr, "Unknown"); + printf(" Unknown"); else - pr_attr(attr, "%u MT/s", code); + printf(" %u MT/s", code); } static void dmi_memory_technology(u8 code) @@ -2702,12 +2528,12 @@ static void dmi_memory_technology(u8 code) "NVDIMM-N", "NVDIMM-F", "NVDIMM-P", - "Intel Optane DC persistent memory" /* 0x07 */ + "Intel persistent memory" /* 0x07 */ }; if (code >= 0x01 && code <= 0x07) - pr_attr("Memory Technology", "%s", technology[code - 0x01]); + printf(" %s", technology[code - 0x01]); else - pr_attr("Memory Technology", "%s", out_of_spec); + printf(" %s", out_of_spec); } static void dmi_memory_operating_mode_capability(u16 code) @@ -2720,54 +2546,49 @@ static void dmi_memory_operating_mode_capability(u16 code) "Byte-accessible persistent memory", "Block-accessible persistent memory" /* 5 */ }; - char list[99]; /* Update length if you touch the array above */ if ((code & 0xFFFE) == 0) - pr_attr("Memory Operating Mode Capability", "None"); + printf(" None"); else { - int i, off = 0; + int i; - list[0] = '\0'; for (i = 1; i <= 5; i++) if (code & (1 << i)) - off += sprintf(list + off, off ? " %s" : "%s", - mode[i - 1]); - pr_attr("Memory Operating Mode Capability", list); + printf(" %s", mode[i - 1]); } } -static void dmi_memory_manufacturer_id(const char *attr, u16 code) +static void dmi_memory_manufacturer_id(u16 code) { /* 7.18.8 */ /* 7.18.10 */ /* LSB is 7-bit Odd Parity number of continuation codes */ if (code == 0) - pr_attr(attr, "Unknown"); + printf(" Unknown"); else - pr_attr(attr, "Bank %d, Hex 0x%02X", - (code & 0x7F) + 1, code >> 8); + printf(" Bank %d, Hex 0x%02X", (code & 0x7F) + 1, code >> 8); } -static void dmi_memory_product_id(const char *attr, u16 code) +static void dmi_memory_product_id(u16 code) { /* 7.18.9 */ /* 7.18.11 */ if (code == 0) - pr_attr(attr, "Unknown"); + printf(" Unknown"); else - pr_attr(attr, "0x%04X", code); + printf(" 0x%04X", code); } -static void dmi_memory_size(const char *attr, u64 code) +static void dmi_memory_size(u64 code) { /* 7.18.12 */ /* 7.18.13 */ if (code.h == 0xFFFFFFFF && code.l == 0xFFFFFFFF) - pr_attr(attr, "Unknown"); + printf(" Unknown"); else if (code.h == 0x0 && code.l == 0x0) - pr_attr(attr, "None"); + printf(" None"); else - dmi_print_memory_size(attr, code, 0); + dmi_print_memory_size(code, 0); } /* @@ -2833,17 +2654,17 @@ static const char *dmi_memory_error_operation(u8 code) static void dmi_memory_error_syndrome(u32 code) { if (code == 0x00000000) - pr_attr("Vendor Syndrome", "Unknown"); + printf(" Unknown"); else - pr_attr("Vendor Syndrome", "0x%08X", code); + printf(" 0x%08X", code); } -static void dmi_32bit_memory_error_address(const char *attr, u32 code) +static void dmi_32bit_memory_error_address(u32 code) { if (code == 0x80000000) - pr_attr(attr, "Unknown"); + printf(" Unknown"); else - pr_attr(attr, "0x%08X", code); + printf(" 0x%08X", code); } /* @@ -2853,23 +2674,23 @@ static void dmi_32bit_memory_error_address(const char *attr, u32 code) static void dmi_mapped_address_size(u32 code) { if (code == 0) - pr_attr("Range Size", "Invalid"); + printf(" Invalid"); else { u64 size; size.h = 0; size.l = code; - dmi_print_memory_size("Range Size", size, 1); + dmi_print_memory_size(size, 1); } } static void dmi_mapped_address_extended_size(u64 start, u64 end) { if (start.h == end.h && start.l == end.l) - pr_attr("Range Size", "Invalid"); + printf(" Invalid"); else - dmi_print_memory_size("Range Size", u64_range(start, end), 0); + dmi_print_memory_size(u64_range(start, end), 0); } /* @@ -2879,32 +2700,36 @@ static void dmi_mapped_address_extended_size(u64 start, u64 end) static void dmi_mapped_address_row_position(u8 code) { if (code == 0) - pr_attr("Partition Row Position", "%s", out_of_spec); + printf(" %s", out_of_spec); else if (code == 0xFF) - pr_attr("Partition Row Position", "Unknown"); + printf(" Unknown"); else - pr_attr("Partition Row Position", "%u", code); + printf(" %u", code); } -static void dmi_mapped_address_interleave_position(u8 code) +static void dmi_mapped_address_interleave_position(u8 code, const char *prefix) { if (code != 0) { + printf("%sInterleave Position:", prefix); if (code == 0xFF) - pr_attr("Interleave Position", "Unknown"); + printf(" Unknown"); else - pr_attr("Interleave Position", "%u", code); + printf(" %u", code); + printf("\n"); } } -static void dmi_mapped_address_interleaved_data_depth(u8 code) +static void dmi_mapped_address_interleaved_data_depth(u8 code, const char *prefix) { if (code != 0) { + printf("%sInterleaved Data Depth:", prefix); if (code == 0xFF) - pr_attr("Interleaved Data Depth", "Unknown"); + printf(" Unknown"); else - pr_attr("Interleaved Data Depth", "%u", code); + printf(" %u", code); + printf("\n"); } } @@ -2984,25 +2809,25 @@ static const char *dmi_battery_chemistry(u8 code) static void dmi_battery_capacity(u16 code, u8 multiplier) { if (code == 0) - pr_attr("Design Capacity", "Unknown"); + printf(" Unknown"); else - pr_attr("Design Capacity", "%u mWh", code * multiplier); + printf(" %u mWh", code * multiplier); } static void dmi_battery_voltage(u16 code) { if (code == 0) - pr_attr("Design Voltage", "Unknown"); + printf(" Unknown"); else - pr_attr("Design Voltage", "%u mV", code); + printf(" %u mV", code); } static void dmi_battery_maximum_error(u8 code) { if (code == 0xFF) - pr_attr("Maximum Error", "Unknown"); + printf(" Unknown"); else - pr_attr("Maximum Error", "%u%%", code); + printf(" %u%%", code); } /* @@ -3022,20 +2847,20 @@ static const char *dmi_system_reset_boot_option(u8 code) return option[code]; } -static void dmi_system_reset_count(const char *attr, u16 code) +static void dmi_system_reset_count(u16 code) { if (code == 0xFFFF) - pr_attr(attr, "Unknown"); + printf(" Unknown"); else - pr_attr(attr, "%u", code); + printf(" %u", code); } -static void dmi_system_reset_timer(const char *attr, u16 code) +static void dmi_system_reset_timer(u16 code) { if (code == 0xFFFF) - pr_attr(attr, "Unknown"); + printf(" Unknown"); else - pr_attr(attr, "%u min", code); + printf(" %u min", code); } /* @@ -3060,32 +2885,27 @@ static const char *dmi_hardware_security_status(u8 code) static void dmi_power_controls_power_on(const u8 *p) { - char time[15]; - int off = 0; - /* 7.26.1 */ if (dmi_bcd_range(p[0], 0x01, 0x12)) - off += sprintf(time + off, "%02X", p[0]); + printf(" %02X", p[0]); else - off += sprintf(time + off, "*"); + printf(" *"); if (dmi_bcd_range(p[1], 0x01, 0x31)) - off += sprintf(time + off, "-%02X", p[1]); + printf("-%02X", p[1]); else - off += sprintf(time + off, "-*"); + printf("-*"); if (dmi_bcd_range(p[2], 0x00, 0x23)) - off += sprintf(time + off, " %02X", p[2]); + printf(" %02X", p[2]); else - off += sprintf(time + off, " *"); + printf(" *"); if (dmi_bcd_range(p[3], 0x00, 0x59)) - off += sprintf(time + off, ":%02X", p[3]); + printf(":%02X", p[3]); else - off += sprintf(time + off, ":*"); + printf(":*"); if (dmi_bcd_range(p[4], 0x00, 0x59)) - off += sprintf(time + off, ":%02X", p[4]); + printf(":%02X", p[4]); else - off += sprintf(time + off, ":*"); - - pr_attr("Next Scheduled Power-on", time); + printf(":*"); } /* @@ -3131,28 +2951,28 @@ static const char *dmi_probe_status(u8 code) return out_of_spec; } -static void dmi_voltage_probe_value(const char *attr, u16 code) +static void dmi_voltage_probe_value(u16 code) { if (code == 0x8000) - pr_attr(attr, "Unknown"); + printf(" Unknown"); else - pr_attr(attr, "%.3f V", (float)(i16)code / 1000); + printf(" %.3f V", (float)(i16)code / 1000); } static void dmi_voltage_probe_resolution(u16 code) { if (code == 0x8000) - pr_attr("Resolution", "Unknown"); + printf(" Unknown"); else - pr_attr("Resolution", "%.1f mV", (float)code / 10); + printf(" %.1f mV", (float)code / 10); } static void dmi_probe_accuracy(u16 code) { if (code == 0x8000) - pr_attr("Accuracy", "Unknown"); + printf(" Unknown"); else - pr_attr("Accuracy", "%.2f%%", (float)code / 100); + printf(" %.2f%%", (float)code / 100); } /* @@ -3188,9 +3008,9 @@ static const char *dmi_cooling_device_type(u8 code) static void dmi_cooling_device_speed(u16 code) { if (code == 0x8000) - pr_attr("Nominal Speed", "Unknown Or Non-rotating"); + printf(" Unknown Or Non-rotating"); else - pr_attr("Nominal Speed", "%u rpm", code); + printf(" %u rpm", code); } /* @@ -3223,40 +3043,40 @@ static const char *dmi_temperature_probe_location(u8 code) return out_of_spec; } -static void dmi_temperature_probe_value(const char *attr, u16 code) +static void dmi_temperature_probe_value(u16 code) { if (code == 0x8000) - pr_attr(attr, "Unknown"); + printf(" Unknown"); else - pr_attr(attr, "%.1f deg C", (float)(i16)code / 10); + printf(" %.1f deg C", (float)(i16)code / 10); } static void dmi_temperature_probe_resolution(u16 code) { if (code == 0x8000) - pr_attr("Resolution", "Unknown"); + printf(" Unknown"); else - pr_attr("Resolution", "%.3f deg C", (float)code / 1000); + printf(" %.3f deg C", (float)code / 1000); } /* * 7.30 Electrical Current Probe (Type 29) */ -static void dmi_current_probe_value(const char *attr, u16 code) +static void dmi_current_probe_value(u16 code) { if (code == 0x8000) - pr_attr(attr, "Unknown"); + printf(" Unknown"); else - pr_attr(attr, "%.3f A", (float)(i16)code / 1000); + printf(" %.3f A", (float)(i16)code / 1000); } static void dmi_current_probe_resolution(u16 code) { if (code == 0x8000) - pr_attr("Resolution", "Unknown"); + printf(" Unknown"); else - pr_attr("Resolution", "%.1f mA", (float)code / 10); + printf(" %.1f mA", (float)code / 10); } /* @@ -3290,12 +3110,12 @@ static const char *dmi_system_boot_status(u8 code) * 7.34 64-bit Memory Error Information (Type 33) */ -static void dmi_64bit_memory_error_address(const char *attr, u64 code) +static void dmi_64bit_memory_error_address(u64 code) { if (code.h == 0x80000000 && code.l == 0x00000000) - pr_attr(attr, "Unknown"); + printf(" Unknown"); else - pr_attr(attr, "0x%08X%08X", code.h, code.l); + printf(" 0x%08X%08X", code.h, code.l); } /* @@ -3312,7 +3132,7 @@ static void dmi_fixup_type_34(struct dmi_header *h, int display) { u8 *p = h->data; - /* Make sure the hidden data is ASCII only */ + /* Make sure the hidden data is ASCII only */ if (h->length == 0x10 && is_printable(p + 0x0B, 0x10 - 0x0B)) { @@ -3383,20 +3203,17 @@ static const char *dmi_memory_channel_type(u8 code) return out_of_spec; } -static void dmi_memory_channel_devices(u8 count, const u8 *p) +static void dmi_memory_channel_devices(u8 count, const u8 *p, const char *prefix) { - char attr[18]; int i; for (i = 1; i <= count; i++) { - sprintf(attr, "Device %hu Load", i); - pr_attr(attr, "%u", p[3 * i]); + printf("%sDevice %u Load: %u\n", + prefix, i, p[3 * i]); if (!(opt.flags & FLAG_QUIET)) - { - sprintf(attr, "Device %hu Handle", i); - pr_attr(attr, "0x%04X", WORD(p + 3 * i + 1)); - } + printf("%sDevice %u Handle: 0x%04X\n", + prefix, i, WORD(p + 3 * i + 1)); } } @@ -3424,13 +3241,12 @@ static void dmi_ipmi_base_address(u8 type, const u8 *p, u8 lsb) { if (type == 0x04) /* SSIF */ { - pr_attr("Base Address", "0x%02X (SMBus)", (*p) >> 1); + printf("0x%02X (SMBus)", (*p) >> 1); } else { u64 address = QWORD(p); - pr_attr("Base Address", "0x%08X%08X (%s)", - address.h, (address.l & ~1) | lsb, + printf("0x%08X%08X (%s)", address.h, (address.l & ~1) | lsb, address.l & 1 ? "I/O" : "Memory-mapped"); } } @@ -3456,9 +3272,9 @@ static const char *dmi_ipmi_register_spacing(u8 code) static void dmi_power_supply_power(u16 code) { if (code == 0x8000) - pr_attr("Max Power Capacity", "Unknown"); + printf(" Unknown"); else - pr_attr("Max Power Capacity", "%u W", (unsigned int)code); + printf(" %u W", (unsigned int)code); } static const char *dmi_power_supply_type(u8 code) @@ -3521,7 +3337,7 @@ static const char *dmi_power_supply_range_switching(u8 code) * whether it's worth the effort. */ -static void dmi_additional_info(const struct dmi_header *h) +static void dmi_additional_info(const struct dmi_header *h, const char *prefix) { u8 *p = h->data + 4; u8 count = *p++; @@ -3530,35 +3346,37 @@ static void dmi_additional_info(const struct dmi_header *h) for (i = 0; i < count; i++) { - pr_handle_name("Additional Information %d", i + 1); + printf("%sAdditional Information %d\n", prefix, i + 1); /* Check for short entries */ if (h->length < offset + 1) break; length = p[0x00]; if (length < 0x05 || h->length < offset + length) break; - pr_attr("Referenced Handle", "0x%04x", - WORD(p + 0x01)); - pr_attr("Referenced Offset", "0x%02x", - p[0x03]); - pr_attr("String", "%s", - dmi_string(h, p[0x04])); + printf("%s\tReferenced Handle: 0x%04x\n", + prefix, WORD(p + 0x01)); + printf("%s\tReferenced Offset: 0x%02x\n", + prefix, p[0x03]); + printf("%s\tString: %s\n", + prefix, dmi_string(h, p[0x04])); + printf("%s\tValue: ", prefix); switch (length - 0x05) { case 1: - pr_attr("Value", "0x%02x", p[0x05]); + printf("0x%02x", p[0x05]); break; case 2: - pr_attr("Value", "0x%04x", WORD(p + 0x05)); + printf("0x%04x", WORD(p + 0x05)); break; case 4: - pr_attr("Value", "0x%08x", DWORD(p + 0x05)); + printf("0x%08x", DWORD(p + 0x05)); break; default: - pr_attr("Value", "Unexpected size"); + printf("Unexpected size"); break; } + printf("\n"); p += length; offset += length; @@ -3603,7 +3421,7 @@ static const char *dmi_protocol_record_type(u8 type) "Reserved", "IPMI", "MCTP", - "Redfish over IP", /* 0x4 */ + "Redfish over IP", /* 0x4 */ }; if (type <= 0x4) @@ -3662,7 +3480,7 @@ static const char *dmi_address_decode(u8 *data, char *storage, u8 addrtype) /* * DSP0270: 8.5: Parse the protocol record format */ -static void dmi_parse_protocol_record(u8 *rec) +static void dmi_parse_protocol_record(const char *prefix, u8 *rec) { u8 rid; u8 rlen; @@ -3673,7 +3491,6 @@ static void dmi_parse_protocol_record(u8 *rec) u8 hlen; const char *addrstr; const char *hname; - char attr[38]; /* DSP0270: 8.5: Protocol Identifier */ rid = rec[0x0]; @@ -3682,7 +3499,7 @@ static void dmi_parse_protocol_record(u8 *rec) /* DSP0270: 8.5: Protocol Record Data */ rdata = &rec[0x2]; - pr_attr("Protocol ID", "%02x (%s)", rid, + printf("%s\tProtocol ID: %02x (%s)\n", prefix, rid, dmi_protocol_record_type(rid)); /* @@ -3712,7 +3529,9 @@ static void dmi_parse_protocol_record(u8 *rec) * endianess of the field is always little after version 2.6.0 * we can just pick a sufficiently recent version here. */ - dmi_system_uuid(pr_subattr, "Service UUID", &rdata[0], 0x311); + printf("%s\t\tService UUID: ", prefix); + dmi_system_uuid(&rdata[0], 0x311); + printf("\n"); /* * DSP0270: 8.6: Redfish Over IP Host IP Assignment Type @@ -3720,13 +3539,13 @@ static void dmi_parse_protocol_record(u8 *rec) * uses decimal, so as to make it more comparable */ assign_val = rdata[16]; - pr_subattr("Host IP Assignment Type", "%s", + printf("%s\t\tHost IP Assignment Type: %s\n", prefix, dmi_protocol_assignment_type(assign_val)); - /* DSP0270: 8.6: Redfish Over IP Host Address format */ + /* DSP0270: 8.6: Redfish Over IP Host Address format */ addrtype = rdata[17]; addrstr = dmi_address_type(addrtype); - pr_subattr("Host IP Address Format", "%s", + printf("%s\t\tHost IP Address Format: %s\n", prefix, addrstr); /* DSP0270: 8.6 IP Assignment types */ @@ -3734,26 +3553,24 @@ static void dmi_parse_protocol_record(u8 *rec) if (assign_val == 0x1 || assign_val == 0x3) { /* DSP0270: 8.6: the Host IPv[4|6] Address */ - sprintf(attr, "%s Address", addrstr); - pr_subattr(attr, "%s", + printf("%s\t\t%s Address: %s\n", prefix, addrstr, dmi_address_decode(&rdata[18], buf, addrtype)); /* DSP0270: 8.6: Prints the Host IPv[4|6] Mask */ - sprintf(attr, "%s Mask", addrstr); - pr_subattr(attr, "%s", + printf("%s\t\t%s Mask: %s\n", prefix, addrstr, dmi_address_decode(&rdata[34], buf, addrtype)); } /* DSP0270: 8.6: Get the Redfish Service IP Discovery Type */ assign_val = rdata[50]; /* Redfish Service IP Discovery type mirrors Host IP Assignment type */ - pr_subattr("Redfish Service IP Discovery Type", "%s", + printf("%s\t\tRedfish Service IP Discovery Type: %s\n", prefix, dmi_protocol_assignment_type(assign_val)); /* DSP0270: 8.6: Get the Redfish Service IP Address Format */ addrtype = rdata[51]; addrstr = dmi_address_type(addrtype); - pr_subattr("Redfish Service IP Address Format", "%s", + printf("%s\t\tRedfish Service IP Address Format: %s\n", prefix, addrstr); if (assign_val == 0x1 || assign_val == 0x3) @@ -3762,22 +3579,20 @@ static void dmi_parse_protocol_record(u8 *rec) u32 vlan; /* DSP0270: 8.6: Prints the Redfish IPv[4|6] Service Address */ - sprintf(attr, "%s Redfish Service Address", addrstr); - pr_subattr(attr, "%s", - dmi_address_decode(&rdata[52], buf, + printf("%s\t\t%s Redfish Service Address: %s\n", prefix, + addrstr, dmi_address_decode(&rdata[52], buf, addrtype)); /* DSP0270: 8.6: Prints the Redfish IPv[4|6] Service Mask */ - sprintf(attr, "%s Redfish Service Mask", addrstr); - pr_subattr(attr, "%s", - dmi_address_decode(&rdata[68], buf, + printf("%s\t\t%s Redfish Service Mask: %s\n", prefix, + addrstr, dmi_address_decode(&rdata[68], buf, addrtype)); /* DSP0270: 8.6: Redfish vlan and port info */ port = WORD(&rdata[84]); vlan = DWORD(&rdata[86]); - pr_subattr("Redfish Service Port", "%hu", port); - pr_subattr("Redfish Service Vlan", "%u", vlan); + printf("%s\t\tRedfish Service Port: %hu\n", prefix, port); + printf("%s\t\tRedfish Service Vlan: %u\n", prefix, vlan); } /* DSP0270: 8.6: Redfish host length and name */ @@ -3794,7 +3609,7 @@ static void dmi_parse_protocol_record(u8 *rec) hname = out_of_spec; hlen = strlen(out_of_spec); } - pr_subattr("Redfish Service Hostname", "%.*s", hlen, hname); + printf("%s\t\tRedfish Service Hostname: %*s\n", prefix, hlen, hname); } /* @@ -3814,7 +3629,8 @@ static const char *dmi_parse_device_type(u8 type) return out_of_spec; } -static void dmi_parse_controller_structure(const struct dmi_header *h) +static void dmi_parse_controller_structure(const struct dmi_header *h, + const char *prefix) { int i; u8 *data = h->data; @@ -3844,7 +3660,7 @@ static void dmi_parse_controller_structure(const struct dmi_header *h) return; type = data[0x4]; - pr_attr("Host Interface Type", "%s", + printf("%sHost Interface Type: %s\n", prefix, dmi_management_controller_host_type(type)); /* @@ -3859,17 +3675,17 @@ static void dmi_parse_controller_structure(const struct dmi_header *h) /* DSP0270: 8.3 Table 2: Device Type */ type = data[0x6]; - pr_attr("Device Type", "%s", + printf("%sDevice Type: %s\n", prefix, dmi_parse_device_type(type)); if (type == 0x2 && len >= 5) { /* USB Device Type - need at least 6 bytes */ u8 *usbdata = &data[0x7]; /* USB Device Descriptor: idVendor */ - pr_attr("idVendor", "0x%04x", + printf("%s\tidVendor: 0x%04x\n", prefix, WORD(&usbdata[0x0])); /* USB Device Descriptor: idProduct */ - pr_attr("idProduct", "0x%04x", + printf("%s\tidProduct: 0x%04x\n", prefix, WORD(&usbdata[0x2])); /* * USB Serial number is here, but its useless, don't @@ -3881,16 +3697,16 @@ static void dmi_parse_controller_structure(const struct dmi_header *h) /* PCI Device Type - Need at least 8 bytes */ u8 *pcidata = &data[0x7]; /* PCI Device Descriptor: VendorID */ - pr_attr("VendorID", "0x%04x", + printf("%s\tVendorID: 0x%04x\n", prefix, WORD(&pcidata[0x0])); /* PCI Device Descriptor: DeviceID */ - pr_attr("DeviceID", "0x%04x", + printf("%s\tDeviceID: 0x%04x\n", prefix, WORD(&pcidata[0x2])); /* PCI Device Descriptor: PCI SubvendorID */ - pr_attr("SubVendorID", "0x%04x", + printf("%s\tSubVendorID: 0x%04x\n", prefix, WORD(&pcidata[0x4])); /* PCI Device Descriptor: PCI SubdeviceID */ - pr_attr("SubDeviceID", "0x%04x", + printf("%s\tSubDeviceID: 0x%04x\n", prefix, WORD(&pcidata[0x6])); } else if (type == 0x4 && len >= 5) @@ -3898,8 +3714,8 @@ static void dmi_parse_controller_structure(const struct dmi_header *h) /* OEM Device Type - Need at least 4 bytes */ u8 *oemdata = &data[0x7]; /* OEM Device Descriptor: IANA */ - pr_attr("Vendor ID", "0x%02x:0x%02x:0x%02x:0x%02x", - oemdata[0x0], oemdata[0x1], + printf("%s\tVendor ID: 0x%02x:0x%02x:0x%02x:0x%02x\n", + prefix, oemdata[0x0], oemdata[0x1], oemdata[0x2], oemdata[0x3]); } /* Don't mess with unknown types for now */ @@ -3918,9 +3734,8 @@ static void dmi_parse_controller_structure(const struct dmi_header *h) total_read++; if (total_read > h->length) { - fprintf(stderr, - "Total read length %d exceeds total structure length %d (handle 0x%04hx)\n", - total_read, h->length, h->handle); + printf("%s\tWARN: Total read length %d exceeds total structure length %d\n", + prefix, total_read, h->length); return; } @@ -3940,13 +3755,12 @@ static void dmi_parse_controller_structure(const struct dmi_header *h) total_read += rec[1] + 2; if (total_read > h->length) { - fprintf(stderr, - "Total read length %d exceeds total structure length %d (handle 0x%04hx, record %d)\n", - total_read, h->length, h->handle, i + 1); + printf("%s\tWARN: Total read length %d exceeds total structure length %d\n", + prefix, total_read, h->length); return; } - dmi_parse_protocol_record(rec); + dmi_parse_protocol_record(prefix, rec); /* * DSP0270: 8.6 @@ -3982,10 +3796,10 @@ static void dmi_tpm_vendor_id(const u8 *p) /* Terminate the string */ vendor_id[i] = '\0'; - pr_attr("Vendor ID", "%s", vendor_id); + printf(" %s", vendor_id); } -static void dmi_tpm_characteristics(u64 code) +static void dmi_tpm_characteristics(u64 code, const char *prefix) { /* 7.1.1 */ static const char *characteristics[] = { @@ -4001,13 +3815,15 @@ static void dmi_tpm_characteristics(u64 code) */ if (code.l & (1 << 2)) { - pr_list_item("%s", characteristics[0]); + printf("%s%s\n", + prefix, characteristics[0]); return; } for (i = 3; i <= 5; i++) if (code.l & (1 << i)) - pr_list_item("%s", characteristics[i - 2]); + printf("%s%s\n", + prefix, characteristics[i - 2]); } /* @@ -4024,13 +3840,13 @@ static void dmi_decode(const struct dmi_header *h, u16 ver) switch (h->type) { case 0: /* 7.1 BIOS Information */ - pr_handle_name("BIOS Information"); + printf("BIOS Information\n"); if (h->length < 0x12) break; - pr_attr("Vendor", "%s", + printf("\tVendor: %s\n", dmi_string(h, data[0x04])); - pr_attr("Version", "%s", + printf("\tVersion: %s\n", dmi_string(h, data[0x05])); - pr_attr("Release Date", "%s", + printf("\tRelease Date: %s\n", dmi_string(h, data[0x08])); /* * On IA-64, the BIOS base address will read 0 because @@ -4039,376 +3855,419 @@ static void dmi_decode(const struct dmi_header *h, u16 ver) */ if (WORD(data + 0x06) != 0) { - pr_attr("Address", "0x%04X0", + printf("\tAddress: 0x%04X0\n", WORD(data + 0x06)); + printf("\tRuntime Size:"); dmi_bios_runtime_size((0x10000 - WORD(data + 0x06)) << 4); + printf("\n"); } + printf("\tROM Size:"); dmi_bios_rom_size(data[0x09], h->length < 0x1A ? 16 : WORD(data + 0x18)); - pr_list_start("Characteristics", NULL); - dmi_bios_characteristics(QWORD(data + 0x0A)); - pr_list_end(); + printf("\n"); + printf("\tCharacteristics:\n"); + dmi_bios_characteristics(QWORD(data + 0x0A), "\t\t"); if (h->length < 0x13) break; - dmi_bios_characteristics_x1(data[0x12]); + dmi_bios_characteristics_x1(data[0x12], "\t\t"); if (h->length < 0x14) break; - dmi_bios_characteristics_x2(data[0x13]); + dmi_bios_characteristics_x2(data[0x13], "\t\t"); if (h->length < 0x18) break; if (data[0x14] != 0xFF && data[0x15] != 0xFF) - pr_attr("BIOS Revision", "%u.%u", + printf("\tBIOS Revision: %u.%u\n", data[0x14], data[0x15]); if (data[0x16] != 0xFF && data[0x17] != 0xFF) - pr_attr("Firmware Revision", "%u.%u", + printf("\tFirmware Revision: %u.%u\n", data[0x16], data[0x17]); break; case 1: /* 7.2 System Information */ - pr_handle_name("System Information"); + printf("System Information\n"); if (h->length < 0x08) break; - pr_attr("Manufacturer", "%s", + printf("\tManufacturer: %s\n", dmi_string(h, data[0x04])); - pr_attr("Product Name", "%s", + printf("\tProduct Name: %s\n", dmi_string(h, data[0x05])); - pr_attr("Version", "%s", + printf("\tVersion: %s\n", dmi_string(h, data[0x06])); - pr_attr("Serial Number", "%s", + printf("\tSerial Number: %s\n", dmi_string(h, data[0x07])); if (h->length < 0x19) break; - dmi_system_uuid(pr_attr, "UUID", data + 0x08, ver); - pr_attr("Wake-up Type", "%s", + printf("\tUUID: "); + dmi_system_uuid(data + 0x08, ver); + printf("\n"); + printf("\tWake-up Type: %s\n", dmi_system_wake_up_type(data[0x18])); if (h->length < 0x1B) break; - pr_attr("SKU Number", "%s", + printf("\tSKU Number: %s\n", dmi_string(h, data[0x19])); - pr_attr("Family", "%s", + printf("\tFamily: %s\n", dmi_string(h, data[0x1A])); break; case 2: /* 7.3 Base Board Information */ - pr_handle_name("Base Board Information"); + printf("Base Board Information\n"); if (h->length < 0x08) break; - pr_attr("Manufacturer", "%s", + printf("\tManufacturer: %s\n", dmi_string(h, data[0x04])); - pr_attr("Product Name", "%s", + printf("\tProduct Name: %s\n", dmi_string(h, data[0x05])); - pr_attr("Version", "%s", + printf("\tVersion: %s\n", dmi_string(h, data[0x06])); - pr_attr("Serial Number", "%s", + printf("\tSerial Number: %s\n", dmi_string(h, data[0x07])); if (h->length < 0x09) break; - pr_attr("Asset Tag", "%s", + printf("\tAsset Tag: %s\n", dmi_string(h, data[0x08])); if (h->length < 0x0A) break; - dmi_base_board_features(data[0x09]); + printf("\tFeatures:"); + dmi_base_board_features(data[0x09], "\t\t"); if (h->length < 0x0E) break; - pr_attr("Location In Chassis", "%s", + printf("\tLocation In Chassis: %s\n", dmi_string(h, data[0x0A])); if (!(opt.flags & FLAG_QUIET)) - pr_attr("Chassis Handle", "0x%04X", + printf("\tChassis Handle: 0x%04X\n", WORD(data + 0x0B)); - pr_attr("Type", "%s", + printf("\tType: %s\n", dmi_base_board_type(data[0x0D])); if (h->length < 0x0F) break; if (h->length < 0x0F + data[0x0E] * sizeof(u16)) break; if (!(opt.flags & FLAG_QUIET)) - dmi_base_board_handles(data[0x0E], data + 0x0F); + dmi_base_board_handles(data[0x0E], data + 0x0F, "\t"); break; case 3: /* 7.4 Chassis Information */ - pr_handle_name("Chassis Information"); + printf("Chassis Information\n"); if (h->length < 0x09) break; - pr_attr("Manufacturer", "%s", + printf("\tManufacturer: %s\n", dmi_string(h, data[0x04])); - pr_attr("Type", "%s", + printf("\tType: %s\n", dmi_chassis_type(data[0x05])); - pr_attr("Lock", "%s", + printf("\tLock: %s\n", dmi_chassis_lock(data[0x05] >> 7)); - pr_attr("Version", "%s", + printf("\tVersion: %s\n", dmi_string(h, data[0x06])); - pr_attr("Serial Number", "%s", + printf("\tSerial Number: %s\n", dmi_string(h, data[0x07])); - pr_attr("Asset Tag", "%s", + printf("\tAsset Tag: %s\n", dmi_string(h, data[0x08])); if (h->length < 0x0D) break; - pr_attr("Boot-up State", "%s", + printf("\tBoot-up State: %s\n", dmi_chassis_state(data[0x09])); - pr_attr("Power Supply State", "%s", + printf("\tPower Supply State: %s\n", dmi_chassis_state(data[0x0A])); - pr_attr("Thermal State", "%s", + printf("\tThermal State: %s\n", dmi_chassis_state(data[0x0B])); - pr_attr("Security Status", "%s", + printf("\tSecurity Status: %s\n", dmi_chassis_security_status(data[0x0C])); if (h->length < 0x11) break; - pr_attr("OEM Information", "0x%08X", + printf("\tOEM Information: 0x%08X\n", DWORD(data + 0x0D)); if (h->length < 0x13) break; + printf("\tHeight:"); dmi_chassis_height(data[0x11]); + printf("\n"); + printf("\tNumber Of Power Cords:"); dmi_chassis_power_cords(data[0x12]); + printf("\n"); if (h->length < 0x15) break; if (h->length < 0x15 + data[0x13] * data[0x14]) break; - dmi_chassis_elements(data[0x13], data[0x14], data + 0x15); + dmi_chassis_elements(data[0x13], data[0x14], data + 0x15, "\t"); if (h->length < 0x16 + data[0x13] * data[0x14]) break; - pr_attr("SKU Number", "%s", + printf("\tSKU Number: %s\n", dmi_string(h, data[0x15 + data[0x13] * data[0x14]])); break; case 4: /* 7.5 Processor Information */ - pr_handle_name("Processor Information"); + printf("Processor Information\n"); if (h->length < 0x1A) break; - pr_attr("Socket Designation", "%s", + printf("\tSocket Designation: %s\n", dmi_string(h, data[0x04])); - pr_attr("Type", "%s", + printf("\tType: %s\n", dmi_processor_type(data[0x05])); - pr_attr("Family", "%s", + printf("\tFamily: %s\n", dmi_processor_family(h, ver)); - pr_attr("Manufacturer", "%s", + printf("\tManufacturer: %s\n", dmi_string(h, data[0x07])); - dmi_processor_id(h); - pr_attr("Version", "%s", + dmi_processor_id(h, "\t"); + printf("\tVersion: %s\n", dmi_string(h, data[0x10])); - dmi_processor_voltage("Voltage", data[0x11]); - dmi_processor_frequency("External Clock", data + 0x12); - dmi_processor_frequency("Max Speed", data + 0x14); - dmi_processor_frequency("Current Speed", data + 0x16); + printf("\tVoltage:"); + dmi_processor_voltage(data[0x11]); + printf("\n"); + printf("\tExternal Clock: "); + dmi_processor_frequency(data + 0x12); + printf("\n"); + printf("\tMax Speed: "); + dmi_processor_frequency(data + 0x14); + printf("\n"); + printf("\tCurrent Speed: "); + dmi_processor_frequency(data + 0x16); + printf("\n"); if (data[0x18] & (1 << 6)) - pr_attr("Status", "Populated, %s", + printf("\tStatus: Populated, %s\n", dmi_processor_status(data[0x18] & 0x07)); else - pr_attr("Status", "Unpopulated"); - pr_attr("Upgrade", "%s", + printf("\tStatus: Unpopulated\n"); + printf("\tUpgrade: %s\n", dmi_processor_upgrade(data[0x19])); if (h->length < 0x20) break; if (!(opt.flags & FLAG_QUIET)) { - dmi_processor_cache("L1 Cache Handle", - WORD(data + 0x1A), "L1", ver); - dmi_processor_cache("L2 Cache Handle", - WORD(data + 0x1C), "L2", ver); - dmi_processor_cache("L3 Cache Handle", - WORD(data + 0x1E), "L3", ver); + printf("\tL1 Cache Handle:"); + dmi_processor_cache(WORD(data + 0x1A), "L1", ver); + printf("\n"); + printf("\tL2 Cache Handle:"); + dmi_processor_cache(WORD(data + 0x1C), "L2", ver); + printf("\n"); + printf("\tL3 Cache Handle:"); + dmi_processor_cache(WORD(data + 0x1E), "L3", ver); + printf("\n"); } if (h->length < 0x23) break; - pr_attr("Serial Number", "%s", + printf("\tSerial Number: %s\n", dmi_string(h, data[0x20])); - pr_attr("Asset Tag", "%s", + printf("\tAsset Tag: %s\n", dmi_string(h, data[0x21])); - pr_attr("Part Number", "%s", + printf("\tPart Number: %s\n", dmi_string(h, data[0x22])); if (h->length < 0x28) break; if (data[0x23] != 0) - pr_attr("Core Count", "%u", + printf("\tCore Count: %u\n", h->length >= 0x2C && data[0x23] == 0xFF ? WORD(data + 0x2A) : data[0x23]); if (data[0x24] != 0) - pr_attr("Core Enabled", "%u", + printf("\tCore Enabled: %u\n", h->length >= 0x2E && data[0x24] == 0xFF ? WORD(data + 0x2C) : data[0x24]); if (data[0x25] != 0) - pr_attr("Thread Count", "%u", + printf("\tThread Count: %u\n", h->length >= 0x30 && data[0x25] == 0xFF ? WORD(data + 0x2E) : data[0x25]); - dmi_processor_characteristics("Characteristics", - WORD(data + 0x26)); + printf("\tCharacteristics:"); + dmi_processor_characteristics(WORD(data + 0x26), "\t\t"); break; case 5: /* 7.6 Memory Controller Information */ - pr_handle_name("Memory Controller Information"); + printf("Memory Controller Information\n"); if (h->length < 0x0F) break; - pr_attr("Error Detecting Method", "%s", + printf("\tError Detecting Method: %s\n", dmi_memory_controller_ed_method(data[0x04])); - dmi_memory_controller_ec_capabilities("Error Correcting Capabilities", - data[0x05]); - pr_attr("Supported Interleave", "%s", + printf("\tError Correcting Capabilities:"); + dmi_memory_controller_ec_capabilities(data[0x05], "\t\t"); + printf("\tSupported Interleave: %s\n", dmi_memory_controller_interleave(data[0x06])); - pr_attr("Current Interleave", "%s", + printf("\tCurrent Interleave: %s\n", dmi_memory_controller_interleave(data[0x07])); - pr_attr("Maximum Memory Module Size", "%u MB", + printf("\tMaximum Memory Module Size: %u MB\n", 1 << data[0x08]); - pr_attr("Maximum Total Memory Size", "%u MB", + printf("\tMaximum Total Memory Size: %u MB\n", data[0x0E] * (1 << data[0x08])); - dmi_memory_controller_speeds("Supported Speeds", - WORD(data + 0x09)); - dmi_memory_module_types("Supported Memory Types", - WORD(data + 0x0B), 0); - dmi_processor_voltage("Memory Module Voltage", data[0x0D]); + printf("\tSupported Speeds:"); + dmi_memory_controller_speeds(WORD(data + 0x09), "\t\t"); + printf("\tSupported Memory Types:"); + dmi_memory_module_types(WORD(data + 0x0B), "\n\t\t"); + printf("\n"); + printf("\tMemory Module Voltage:"); + dmi_processor_voltage(data[0x0D]); + printf("\n"); if (h->length < 0x0F + data[0x0E] * sizeof(u16)) break; - dmi_memory_controller_slots(data[0x0E], data + 0x0F); + dmi_memory_controller_slots(data[0x0E], data + 0x0F, "\t"); if (h->length < 0x10 + data[0x0E] * sizeof(u16)) break; - dmi_memory_controller_ec_capabilities("Enabled Error Correcting Capabilities", - data[0x0F + data[0x0E] * sizeof(u16)]); + printf("\tEnabled Error Correcting Capabilities:"); + dmi_memory_controller_ec_capabilities(data[0x0F + data[0x0E] * sizeof(u16)], "\t\t"); break; case 6: /* 7.7 Memory Module Information */ - pr_handle_name("Memory Module Information"); + printf("Memory Module Information\n"); if (h->length < 0x0C) break; - pr_attr("Socket Designation", "%s", + printf("\tSocket Designation: %s\n", dmi_string(h, data[0x04])); + printf("\tBank Connections:"); dmi_memory_module_connections(data[0x05]); - dmi_memory_module_speed("Current Speed", data[0x06]); - dmi_memory_module_types("Type", WORD(data + 0x07), 1); - dmi_memory_module_size("Installed Size", data[0x09]); - dmi_memory_module_size("Enabled Size", data[0x0A]); - dmi_memory_module_error(data[0x0B]); + printf("\n"); + printf("\tCurrent Speed:"); + dmi_memory_module_speed(data[0x06]); + printf("\n"); + printf("\tType:"); + dmi_memory_module_types(WORD(data + 0x07), " "); + printf("\n"); + printf("\tInstalled Size:"); + dmi_memory_module_size(data[0x09]); + printf("\n"); + printf("\tEnabled Size:"); + dmi_memory_module_size(data[0x0A]); + printf("\n"); + printf("\tError Status:"); + dmi_memory_module_error(data[0x0B], "\t\t"); break; case 7: /* 7.8 Cache Information */ - pr_handle_name("Cache Information"); + printf("Cache Information\n"); if (h->length < 0x0F) break; - pr_attr("Socket Designation", "%s", + printf("\tSocket Designation: %s\n", dmi_string(h, data[0x04])); - pr_attr("Configuration", "%s, %s, Level %u", + printf("\tConfiguration: %s, %s, Level %u\n", WORD(data + 0x05) & 0x0080 ? "Enabled" : "Disabled", WORD(data + 0x05) & 0x0008 ? "Socketed" : "Not Socketed", (WORD(data + 0x05) & 0x0007) + 1); - pr_attr("Operational Mode", "%s", + printf("\tOperational Mode: %s\n", dmi_cache_mode((WORD(data + 0x05) >> 8) & 0x0003)); - pr_attr("Location", "%s", + printf("\tLocation: %s\n", dmi_cache_location((WORD(data + 0x05) >> 5) & 0x0003)); + printf("\tInstalled Size:"); if (h->length >= 0x1B) - dmi_cache_size_2("Installed Size", DWORD(data + 0x17)); + dmi_cache_size_2(DWORD(data + 0x17)); else - dmi_cache_size("Installed Size", WORD(data + 0x09)); + dmi_cache_size(WORD(data + 0x09)); + printf("\n"); + printf("\tMaximum Size:"); if (h->length >= 0x17) - dmi_cache_size_2("Maximum Size", DWORD(data + 0x13)); + dmi_cache_size_2(DWORD(data + 0x13)); else - dmi_cache_size("Maximum Size", WORD(data + 0x07)); - dmi_cache_types("Supported SRAM Types", WORD(data + 0x0B), 0); - dmi_cache_types("Installed SRAM Type", WORD(data + 0x0D), 1); + dmi_cache_size(WORD(data + 0x07)); + printf("\n"); + printf("\tSupported SRAM Types:"); + dmi_cache_types(WORD(data + 0x0B), "\n\t\t"); + printf("\n"); + printf("\tInstalled SRAM Type:"); + dmi_cache_types(WORD(data + 0x0D), " "); + printf("\n"); if (h->length < 0x13) break; - dmi_memory_module_speed("Speed", data[0x0F]); - pr_attr("Error Correction Type", "%s", + printf("\tSpeed:"); + dmi_memory_module_speed(data[0x0F]); + printf("\n"); + printf("\tError Correction Type: %s\n", dmi_cache_ec_type(data[0x10])); - pr_attr("System Type", "%s", + printf("\tSystem Type: %s\n", dmi_cache_type(data[0x11])); - pr_attr("Associativity", "%s", + printf("\tAssociativity: %s\n", dmi_cache_associativity(data[0x12])); break; case 8: /* 7.9 Port Connector Information */ - pr_handle_name("Port Connector Information"); + printf("Port Connector Information\n"); if (h->length < 0x09) break; - pr_attr("Internal Reference Designator", "%s", + printf("\tInternal Reference Designator: %s\n", dmi_string(h, data[0x04])); - pr_attr("Internal Connector Type", "%s", + printf("\tInternal Connector Type: %s\n", dmi_port_connector_type(data[0x05])); - pr_attr("External Reference Designator", "%s", + printf("\tExternal Reference Designator: %s\n", dmi_string(h, data[0x06])); - pr_attr("External Connector Type", "%s", + printf("\tExternal Connector Type: %s\n", dmi_port_connector_type(data[0x07])); - pr_attr("Port Type", "%s", + printf("\tPort Type: %s\n", dmi_port_type(data[0x08])); break; case 9: /* 7.10 System Slots */ - pr_handle_name("System Slot Information"); + printf("System Slot Information\n"); if (h->length < 0x0C) break; - pr_attr("Designation", "%s", + printf("\tDesignation: %s\n", dmi_string(h, data[0x04])); - pr_attr("Type", "%s%s", + printf("\tType: %s%s\n", dmi_slot_bus_width(data[0x06]), dmi_slot_type(data[0x05])); - pr_attr("Current Usage", "%s", + printf("\tCurrent Usage: %s\n", dmi_slot_current_usage(data[0x07])); - pr_attr("Length", "%s", + printf("\tLength: %s\n", dmi_slot_length(data[0x08])); - dmi_slot_id(data[0x09], data[0x0A], data[0x05]); + dmi_slot_id(data[0x09], data[0x0A], data[0x05], "\t"); + printf("\tCharacteristics:"); if (h->length < 0x0D) - dmi_slot_characteristics("Characteristics", data[0x0B], 0x00); + dmi_slot_characteristics(data[0x0B], 0x00, "\t\t"); else - dmi_slot_characteristics("Characteristics", data[0x0B], data[0x0C]); + dmi_slot_characteristics(data[0x0B], data[0x0C], "\t\t"); if (h->length < 0x11) break; - dmi_slot_segment_bus_func(WORD(data + 0x0D), data[0x0F], data[0x10]); - if (h->length < 0x13) break; - pr_attr("Data Bus Width", "%u", data[0x11]); - pr_attr("Peer Devices", "%u", data[0x12]); - if (h->length - 0x13 >= data[0x12] * 5) - dmi_slot_peers(data[0x12], data + 0x13); + dmi_slot_segment_bus_func(WORD(data + 0x0D), data[0x0F], data[0x10], "\t"); break; case 10: /* 7.11 On Board Devices Information */ - dmi_on_board_devices(h); + dmi_on_board_devices(h, ""); break; case 11: /* 7.12 OEM Strings */ - pr_handle_name("OEM Strings"); + printf("OEM Strings\n"); if (h->length < 0x05) break; - dmi_oem_strings(h); + dmi_oem_strings(h, "\t"); break; case 12: /* 7.13 System Configuration Options */ - pr_handle_name("System Configuration Options"); + printf("System Configuration Options\n"); if (h->length < 0x05) break; - dmi_system_configuration_options(h); + dmi_system_configuration_options(h, "\t"); break; case 13: /* 7.14 BIOS Language Information */ - pr_handle_name("BIOS Language Information"); + printf("BIOS Language Information\n"); if (h->length < 0x16) break; if (ver >= 0x0201) { - pr_attr("Language Description Format", "%s", + printf("\tLanguage Description Format: %s\n", dmi_bios_language_format(data[0x05])); } - pr_list_start("Installable Languages", "%u", data[0x04]); - dmi_bios_languages(h); - pr_list_end(); - pr_attr("Currently Installed Language", "%s", + printf("\tInstallable Languages: %u\n", data[0x04]); + dmi_bios_languages(h, "\t\t"); + printf("\tCurrently Installed Language: %s\n", dmi_string(h, data[0x15])); break; case 14: /* 7.15 Group Associations */ - pr_handle_name("Group Associations"); + printf("Group Associations\n"); if (h->length < 0x05) break; - pr_attr("Name", "%s", + printf("\tName: %s\n", dmi_string(h, data[0x04])); - pr_list_start("Items", "%u", + printf("\tItems: %u\n", (h->length - 0x05) / 3); - dmi_group_associations_items((h->length - 0x05) / 3, data + 0x05); - pr_list_end(); + dmi_group_associations_items((h->length - 0x05) / 3, data + 0x05, "\t\t"); break; case 15: /* 7.16 System Event Log */ - pr_handle_name("System Event Log"); + printf("System Event Log\n"); if (h->length < 0x14) break; - pr_attr("Area Length", "%u bytes", + printf("\tArea Length: %u bytes\n", WORD(data + 0x04)); - pr_attr("Header Start Offset", "0x%04X", + printf("\tHeader Start Offset: 0x%04X\n", WORD(data + 0x06)); if (WORD(data + 0x08) - WORD(data + 0x06)) - pr_attr("Header Length", "%u byte%s", + printf("\tHeader Length: %u byte%s\n", WORD(data + 0x08) - WORD(data + 0x06), WORD(data + 0x08) - WORD(data + 0x06) > 1 ? "s" : ""); - pr_attr("Data Start Offset", "0x%04X", + printf("\tData Start Offset: 0x%04X\n", WORD(data + 0x08)); - pr_attr("Access Method", "%s", + printf("\tAccess Method: %s\n", dmi_event_log_method(data[0x0A])); + printf("\tAccess Address:"); dmi_event_log_address(data[0x0A], data + 0x10); + printf("\n"); + printf("\tStatus:"); dmi_event_log_status(data[0x0B]); - pr_attr("Change Token", "0x%08X", + printf("\n"); + printf("\tChange Token: 0x%08X\n", DWORD(data + 0x0C)); if (h->length < 0x17) break; - pr_attr("Header Format", "%s", + printf("\tHeader Format: %s\n", dmi_event_log_header_type(data[0x14])); - pr_attr("Supported Log Type Descriptors", "%u", + printf("\tSupported Log Type Descriptors: %u\n", data[0x15]); if (h->length < 0x17 + data[0x15] * data[0x16]) break; - dmi_event_log_descriptors(data[0x15], data[0x16], data + 0x17); + dmi_event_log_descriptors(data[0x15], data[0x16], data + 0x17, "\t"); break; case 16: /* 7.17 Physical Memory Array */ - pr_handle_name("Physical Memory Array"); + printf("Physical Memory Array\n"); if (h->length < 0x0F) break; - pr_attr("Location", "%s", + printf("\tLocation: %s\n", dmi_memory_array_location(data[0x04])); - pr_attr("Use", "%s", + printf("\tUse: %s\n", dmi_memory_array_use(data[0x05])); - pr_attr("Error Correction Type", "%s", + printf("\tError Correction Type: %s\n", dmi_memory_array_ec_type(data[0x06])); + printf("\tMaximum Capacity:"); if (DWORD(data + 0x07) == 0x80000000) { if (h->length < 0x17) - pr_attr("Maximum Capacity", "Unknown"); + printf(" Unknown"); else - dmi_print_memory_size("Maximum Capacity", - QWORD(data + 0x0F), 0); + dmi_print_memory_size(QWORD(data + 0x0F), 0); } else { @@ -4416,109 +4275,154 @@ static void dmi_decode(const struct dmi_header *h, u16 ver) capacity.h = 0; capacity.l = DWORD(data + 0x07); - dmi_print_memory_size("Maximum Capacity", - capacity, 1); + dmi_print_memory_size(capacity, 1); } + printf("\n"); if (!(opt.flags & FLAG_QUIET)) + { + printf("\tError Information Handle:"); dmi_memory_array_error_handle(WORD(data + 0x0B)); - pr_attr("Number Of Devices", "%u", + printf("\n"); + } + printf("\tNumber Of Devices: %u\n", WORD(data + 0x0D)); break; case 17: /* 7.18 Memory Device */ - pr_handle_name("Memory Device"); + printf("Memory Device\n"); if (h->length < 0x15) break; if (!(opt.flags & FLAG_QUIET)) { - pr_attr("Array Handle", "0x%04X", + printf("\tArray Handle: 0x%04X\n", WORD(data + 0x04)); + printf("\tError Information Handle:"); dmi_memory_array_error_handle(WORD(data + 0x06)); + printf("\n"); } - dmi_memory_device_width("Total Width", WORD(data + 0x08)); - dmi_memory_device_width("Data Width", WORD(data + 0x0A)); + printf("\tTotal Width:"); + dmi_memory_device_width(WORD(data + 0x08)); + printf("\n"); + printf("\tData Width:"); + dmi_memory_device_width(WORD(data + 0x0A)); + printf("\n"); + printf("\tSize:"); if (h->length >= 0x20 && WORD(data + 0x0C) == 0x7FFF) dmi_memory_device_extended_size(DWORD(data + 0x1C)); else dmi_memory_device_size(WORD(data + 0x0C)); - pr_attr("Form Factor", "%s", + printf("\n"); + printf("\tForm Factor: %s\n", dmi_memory_device_form_factor(data[0x0E])); + printf("\tSet:"); dmi_memory_device_set(data[0x0F]); - pr_attr("Locator", "%s", + printf("\n"); + printf("\tLocator: %s\n", dmi_string(h, data[0x10])); - pr_attr("Bank Locator", "%s", + printf("\tBank Locator: %s\n", dmi_string(h, data[0x11])); - pr_attr("Type", "%s", + printf("\tType: %s\n", dmi_memory_device_type(data[0x12])); + printf("\tType Detail:"); dmi_memory_device_type_detail(WORD(data + 0x13)); + printf("\n"); if (h->length < 0x17) break; - dmi_memory_device_speed("Speed", WORD(data + 0x15)); + printf("\tSpeed:"); + dmi_memory_device_speed(WORD(data + 0x15)); + printf("\n"); if (h->length < 0x1B) break; - pr_attr("Manufacturer", "%s", + printf("\tManufacturer: %s\n", dmi_string(h, data[0x17])); - pr_attr("Serial Number", "%s", + printf("\tSerial Number: %s\n", dmi_string(h, data[0x18])); - pr_attr("Asset Tag", "%s", + printf("\tAsset Tag: %s\n", dmi_string(h, data[0x19])); - pr_attr("Part Number", "%s", + printf("\tPart Number: %s\n", dmi_string(h, data[0x1A])); if (h->length < 0x1C) break; + printf("\tRank: "); if ((data[0x1B] & 0x0F) == 0) - pr_attr("Rank", "Unknown"); + printf("Unknown"); else - pr_attr("Rank", "%u", data[0x1B] & 0x0F); + printf("%u", data[0x1B] & 0x0F); + printf("\n"); if (h->length < 0x22) break; - dmi_memory_device_speed("Configured Memory Speed", - WORD(data + 0x20)); + printf("\tConfigured Memory Speed:"); + dmi_memory_device_speed(WORD(data + 0x20)); + printf("\n"); if (h->length < 0x28) break; - dmi_memory_voltage_value("Minimum Voltage", - WORD(data + 0x22)); - dmi_memory_voltage_value("Maximum Voltage", - WORD(data + 0x24)); - dmi_memory_voltage_value("Configured Voltage", - WORD(data + 0x26)); + printf("\tMinimum Voltage:"); + dmi_memory_voltage_value(WORD(data + 0x22)); + printf("\n"); + printf("\tMaximum Voltage:"); + dmi_memory_voltage_value(WORD(data + 0x24)); + printf("\n"); + printf("\tConfigured Voltage:"); + dmi_memory_voltage_value(WORD(data + 0x26)); + printf("\n"); if (h->length < 0x34) break; + printf("\tMemory Technology:"); dmi_memory_technology(data[0x28]); + printf("\n"); + printf("\tMemory Operating Mode Capability:"); dmi_memory_operating_mode_capability(WORD(data + 0x29)); - pr_attr("Firmware Version", "%s", + printf("\n"); + printf("\tFirmware Version: %s\n", dmi_string(h, data[0x2B])); - dmi_memory_manufacturer_id("Module Manufacturer ID", - WORD(data + 0x2C)); - dmi_memory_product_id("Module Product ID", - WORD(data + 0x2E)); - dmi_memory_manufacturer_id("Memory Subsystem Controller Manufacturer ID", - WORD(data + 0x30)); - dmi_memory_product_id("Memory Subsystem Controller Product ID", - WORD(data + 0x32)); + printf("\tModule Manufacturer ID:"); + dmi_memory_manufacturer_id(WORD(data + 0x2C)); + printf("\n"); + printf("\tModule Product ID:"); + dmi_memory_product_id(WORD(data + 0x2E)); + printf("\n"); + printf("\tMemory Subsystem Controller Manufacturer ID:"); + dmi_memory_manufacturer_id(WORD(data + 0x30)); + printf("\n"); + printf("\tMemory Subsystem Controller Product ID:"); + dmi_memory_product_id(WORD(data + 0x32)); + printf("\n"); if (h->length < 0x3C) break; - dmi_memory_size("Non-Volatile Size", QWORD(data + 0x34)); + printf("\tNon-Volatile Size:"); + dmi_memory_size(QWORD(data + 0x34)); + printf("\n"); if (h->length < 0x44) break; - dmi_memory_size("Volatile Size", QWORD(data + 0x3C)); + printf("\tVolatile Size:"); + dmi_memory_size(QWORD(data + 0x3C)); + printf("\n"); if (h->length < 0x4C) break; - dmi_memory_size("Cache Size", QWORD(data + 0x44)); + printf("\tCache Size:"); + dmi_memory_size(QWORD(data + 0x44)); + printf("\n"); if (h->length < 0x54) break; - dmi_memory_size("Logical Size", QWORD(data + 0x4C)); + printf("\tLogical Size:"); + dmi_memory_size(QWORD(data + 0x4C)); + printf("\n"); break; case 18: /* 7.19 32-bit Memory Error Information */ - pr_handle_name("32-bit Memory Error Information"); + printf("32-bit Memory Error Information\n"); if (h->length < 0x17) break; - pr_attr("Type", "%s", + printf("\tType: %s\n", dmi_memory_error_type(data[0x04])); - pr_attr("Granularity", "%s", + printf("\tGranularity: %s\n", dmi_memory_error_granularity(data[0x05])); - pr_attr("Operation", "%s", + printf("\tOperation: %s\n", dmi_memory_error_operation(data[0x06])); + printf("\tVendor Syndrome:"); dmi_memory_error_syndrome(DWORD(data + 0x07)); - dmi_32bit_memory_error_address("Memory Array Address", - DWORD(data + 0x0B)); - dmi_32bit_memory_error_address("Device Address", - DWORD(data + 0x0F)); - dmi_32bit_memory_error_address("Resolution", - DWORD(data + 0x13)); + printf("\n"); + printf("\tMemory Array Address:"); + dmi_32bit_memory_error_address(DWORD(data + 0x0B)); + printf("\n"); + printf("\tDevice Address:"); + dmi_32bit_memory_error_address(DWORD(data + 0x0F)); + printf("\n"); + printf("\tResolution:"); + dmi_32bit_memory_error_address(DWORD(data + 0x13)); + printf("\n"); break; case 19: /* 7.20 Memory Array Mapped Address */ - pr_handle_name("Memory Array Mapped Address"); + printf("Memory Array Mapped Address\n"); if (h->length < 0x0F) break; if (h->length >= 0x1F && DWORD(data + 0x04) == 0xFFFFFFFF) { @@ -4527,31 +4431,34 @@ static void dmi_decode(const struct dmi_header *h, u16 ver) start = QWORD(data + 0x0F); end = QWORD(data + 0x17); - pr_attr("Starting Address", "0x%08X%08Xk", + printf("\tStarting Address: 0x%08X%08Xk\n", start.h, start.l); - pr_attr("Ending Address", "0x%08X%08Xk", + printf("\tEnding Address: 0x%08X%08Xk\n", end.h, end.l); + printf("\tRange Size:"); dmi_mapped_address_extended_size(start, end); } else { - pr_attr("Starting Address", "0x%08X%03X", + printf("\tStarting Address: 0x%08X%03X\n", DWORD(data + 0x04) >> 2, (DWORD(data + 0x04) & 0x3) << 10); - pr_attr("Ending Address", "0x%08X%03X", + printf("\tEnding Address: 0x%08X%03X\n", DWORD(data + 0x08) >> 2, ((DWORD(data + 0x08) & 0x3) << 10) + 0x3FF); + printf("\tRange Size:"); dmi_mapped_address_size(DWORD(data + 0x08) - DWORD(data + 0x04) + 1); } + printf("\n"); if (!(opt.flags & FLAG_QUIET)) - pr_attr("Physical Array Handle", "0x%04X", + printf("\tPhysical Array Handle: 0x%04X\n", WORD(data + 0x0C)); - pr_attr("Partition Width", "%u", + printf("\tPartition Width: %u\n", data[0x0E]); break; case 20: /* 7.21 Memory Device Mapped Address */ - pr_handle_name("Memory Device Mapped Address"); + printf("Memory Device Mapped Address\n"); if (h->length < 0x13) break; if (h->length >= 0x23 && DWORD(data + 0x04) == 0xFFFFFFFF) { @@ -4560,326 +4467,382 @@ static void dmi_decode(const struct dmi_header *h, u16 ver) start = QWORD(data + 0x13); end = QWORD(data + 0x1B); - pr_attr("Starting Address", "0x%08X%08Xk", + printf("\tStarting Address: 0x%08X%08Xk\n", start.h, start.l); - pr_attr("Ending Address", "0x%08X%08Xk", + printf("\tEnding Address: 0x%08X%08Xk\n", end.h, end.l); + printf("\tRange Size:"); dmi_mapped_address_extended_size(start, end); } else { - pr_attr("Starting Address", "0x%08X%03X", + printf("\tStarting Address: 0x%08X%03X\n", DWORD(data + 0x04) >> 2, (DWORD(data + 0x04) & 0x3) << 10); - pr_attr("Ending Address", "0x%08X%03X", + printf("\tEnding Address: 0x%08X%03X\n", DWORD(data + 0x08) >> 2, ((DWORD(data + 0x08) & 0x3) << 10) + 0x3FF); + printf("\tRange Size:"); dmi_mapped_address_size(DWORD(data + 0x08) - DWORD(data + 0x04) + 1); } + printf("\n"); if (!(opt.flags & FLAG_QUIET)) { - pr_attr("Physical Device Handle", "0x%04X", + printf("\tPhysical Device Handle: 0x%04X\n", WORD(data + 0x0C)); - pr_attr("Memory Array Mapped Address Handle", "0x%04X", + printf("\tMemory Array Mapped Address Handle: 0x%04X\n", WORD(data + 0x0E)); } + printf("\tPartition Row Position:"); dmi_mapped_address_row_position(data[0x10]); - dmi_mapped_address_interleave_position(data[0x11]); - dmi_mapped_address_interleaved_data_depth(data[0x12]); + printf("\n"); + dmi_mapped_address_interleave_position(data[0x11], "\t"); + dmi_mapped_address_interleaved_data_depth(data[0x12], "\t"); break; case 21: /* 7.22 Built-in Pointing Device */ - pr_handle_name("Built-in Pointing Device"); + printf("Built-in Pointing Device\n"); if (h->length < 0x07) break; - pr_attr("Type", "%s", + printf("\tType: %s\n", dmi_pointing_device_type(data[0x04])); - pr_attr("Interface", "%s", + printf("\tInterface: %s\n", dmi_pointing_device_interface(data[0x05])); - pr_attr("Buttons", "%u", + printf("\tButtons: %u\n", data[0x06]); break; case 22: /* 7.23 Portable Battery */ - pr_handle_name("Portable Battery"); + printf("Portable Battery\n"); if (h->length < 0x10) break; - pr_attr("Location", "%s", + printf("\tLocation: %s\n", dmi_string(h, data[0x04])); - pr_attr("Manufacturer", "%s", + printf("\tManufacturer: %s\n", dmi_string(h, data[0x05])); if (data[0x06] || h->length < 0x1A) - pr_attr("Manufacture Date", "%s", + printf("\tManufacture Date: %s\n", dmi_string(h, data[0x06])); if (data[0x07] || h->length < 0x1A) - pr_attr("Serial Number", "%s", + printf("\tSerial Number: %s\n", dmi_string(h, data[0x07])); - pr_attr("Name", "%s", + printf("\tName: %s\n", dmi_string(h, data[0x08])); if (data[0x09] != 0x02 || h->length < 0x1A) - pr_attr("Chemistry", "%s", + printf("\tChemistry: %s\n", dmi_battery_chemistry(data[0x09])); + printf("\tDesign Capacity:"); if (h->length < 0x16) dmi_battery_capacity(WORD(data + 0x0A), 1); else dmi_battery_capacity(WORD(data + 0x0A), data[0x15]); + printf("\n"); + printf("\tDesign Voltage:"); dmi_battery_voltage(WORD(data + 0x0C)); - pr_attr("SBDS Version", "%s", + printf("\n"); + printf("\tSBDS Version: %s\n", dmi_string(h, data[0x0E])); + printf("\tMaximum Error:"); dmi_battery_maximum_error(data[0x0F]); + printf("\n"); if (h->length < 0x1A) break; if (data[0x07] == 0) - pr_attr("SBDS Serial Number", "%04X", + printf("\tSBDS Serial Number: %04X\n", WORD(data + 0x10)); if (data[0x06] == 0) - pr_attr("SBDS Manufacture Date", "%u-%02u-%02u", + printf("\tSBDS Manufacture Date: %u-%02u-%02u\n", 1980 + (WORD(data + 0x12) >> 9), (WORD(data + 0x12) >> 5) & 0x0F, WORD(data + 0x12) & 0x1F); if (data[0x09] == 0x02) - pr_attr("SBDS Chemistry", "%s", + printf("\tSBDS Chemistry: %s\n", dmi_string(h, data[0x14])); - pr_attr("OEM-specific Information", "0x%08X", + printf("\tOEM-specific Information: 0x%08X\n", DWORD(data + 0x16)); break; case 23: /* 7.24 System Reset */ - pr_handle_name("System Reset"); + printf("System Reset\n"); if (h->length < 0x0D) break; - pr_attr("Status", "%s", + printf("\tStatus: %s\n", data[0x04] & (1 << 0) ? "Enabled" : "Disabled"); - pr_attr("Watchdog Timer", "%s", + printf("\tWatchdog Timer: %s\n", data[0x04] & (1 << 5) ? "Present" : "Not Present"); if (!(data[0x04] & (1 << 5))) break; - pr_attr("Boot Option", "%s", + printf("\tBoot Option: %s\n", dmi_system_reset_boot_option((data[0x04] >> 1) & 0x3)); - pr_attr("Boot Option On Limit", "%s", + printf("\tBoot Option On Limit: %s\n", dmi_system_reset_boot_option((data[0x04] >> 3) & 0x3)); - dmi_system_reset_count("Reset Count", WORD(data + 0x05)); - dmi_system_reset_count("Reset Limit", WORD(data + 0x07)); - dmi_system_reset_timer("Timer Interval", WORD(data + 0x09)); - dmi_system_reset_timer("Timeout", WORD(data + 0x0B)); + printf("\tReset Count:"); + dmi_system_reset_count(WORD(data + 0x05)); + printf("\n"); + printf("\tReset Limit:"); + dmi_system_reset_count(WORD(data + 0x07)); + printf("\n"); + printf("\tTimer Interval:"); + dmi_system_reset_timer(WORD(data + 0x09)); + printf("\n"); + printf("\tTimeout:"); + dmi_system_reset_timer(WORD(data + 0x0B)); + printf("\n"); break; case 24: /* 7.25 Hardware Security */ - pr_handle_name("Hardware Security"); + printf("Hardware Security\n"); if (h->length < 0x05) break; - pr_attr("Power-On Password Status", "%s", + printf("\tPower-On Password Status: %s\n", dmi_hardware_security_status(data[0x04] >> 6)); - pr_attr("Keyboard Password Status", "%s", + printf("\tKeyboard Password Status: %s\n", dmi_hardware_security_status((data[0x04] >> 4) & 0x3)); - pr_attr("Administrator Password Status", "%s", + printf("\tAdministrator Password Status: %s\n", dmi_hardware_security_status((data[0x04] >> 2) & 0x3)); - pr_attr("Front Panel Reset Status", "%s", + printf("\tFront Panel Reset Status: %s\n", dmi_hardware_security_status(data[0x04] & 0x3)); break; case 25: /* 7.26 System Power Controls */ - pr_handle_name("System Power Controls"); + printf("\tSystem Power Controls\n"); if (h->length < 0x09) break; + printf("\tNext Scheduled Power-on:"); dmi_power_controls_power_on(data + 0x04); + printf("\n"); break; case 26: /* 7.27 Voltage Probe */ - pr_handle_name("Voltage Probe"); + printf("Voltage Probe\n"); if (h->length < 0x14) break; - pr_attr("Description", "%s", + printf("\tDescription: %s\n", dmi_string(h, data[0x04])); - pr_attr("Location", "%s", + printf("\tLocation: %s\n", dmi_voltage_probe_location(data[0x05] & 0x1f)); - pr_attr("Status", "%s", + printf("\tStatus: %s\n", dmi_probe_status(data[0x05] >> 5)); - dmi_voltage_probe_value("Maximum Value", WORD(data + 0x06)); - dmi_voltage_probe_value("Minimum Value", WORD(data + 0x08)); + printf("\tMaximum Value:"); + dmi_voltage_probe_value(WORD(data + 0x06)); + printf("\n"); + printf("\tMinimum Value:"); + dmi_voltage_probe_value(WORD(data + 0x08)); + printf("\n"); + printf("\tResolution:"); dmi_voltage_probe_resolution(WORD(data + 0x0A)); - dmi_voltage_probe_value("Tolerance", WORD(data + 0x0C)); + printf("\n"); + printf("\tTolerance:"); + dmi_voltage_probe_value(WORD(data + 0x0C)); + printf("\n"); + printf("\tAccuracy:"); dmi_probe_accuracy(WORD(data + 0x0E)); - pr_attr("OEM-specific Information", "0x%08X", + printf("\n"); + printf("\tOEM-specific Information: 0x%08X\n", DWORD(data + 0x10)); if (h->length < 0x16) break; - dmi_voltage_probe_value("Nominal Value", WORD(data + 0x14)); + printf("\tNominal Value:"); + dmi_voltage_probe_value(WORD(data + 0x14)); + printf("\n"); break; case 27: /* 7.28 Cooling Device */ - pr_handle_name("Cooling Device"); + printf("Cooling Device\n"); if (h->length < 0x0C) break; if (!(opt.flags & FLAG_QUIET) && WORD(data + 0x04) != 0xFFFF) - pr_attr("Temperature Probe Handle", "0x%04X", + printf("\tTemperature Probe Handle: 0x%04X\n", WORD(data + 0x04)); - pr_attr("Type", "%s", + printf("\tType: %s\n", dmi_cooling_device_type(data[0x06] & 0x1f)); - pr_attr("Status", "%s", + printf("\tStatus: %s\n", dmi_probe_status(data[0x06] >> 5)); if (data[0x07] != 0x00) - pr_attr("Cooling Unit Group", "%u", + printf("\tCooling Unit Group: %u\n", data[0x07]); - pr_attr("OEM-specific Information", "0x%08X", + printf("\tOEM-specific Information: 0x%08X\n", DWORD(data + 0x08)); if (h->length < 0x0E) break; + printf("\tNominal Speed:"); dmi_cooling_device_speed(WORD(data + 0x0C)); + printf("\n"); if (h->length < 0x0F) break; - pr_attr("Description", "%s", dmi_string(h, data[0x0E])); + printf("\tDescription: %s\n", dmi_string(h, data[0x0E])); break; case 28: /* 7.29 Temperature Probe */ - pr_handle_name("Temperature Probe"); + printf("Temperature Probe\n"); if (h->length < 0x14) break; - pr_attr("Description", "%s", + printf("\tDescription: %s\n", dmi_string(h, data[0x04])); - pr_attr("Location", "%s", + printf("\tLocation: %s\n", dmi_temperature_probe_location(data[0x05] & 0x1F)); - pr_attr("Status", "%s", + printf("\tStatus: %s\n", dmi_probe_status(data[0x05] >> 5)); - dmi_temperature_probe_value("Maximum Value", - WORD(data + 0x06)); - dmi_temperature_probe_value("Minimum Value", - WORD(data + 0x08)); + printf("\tMaximum Value:"); + dmi_temperature_probe_value(WORD(data + 0x06)); + printf("\n"); + printf("\tMinimum Value:"); + dmi_temperature_probe_value(WORD(data + 0x08)); + printf("\n"); + printf("\tResolution:"); dmi_temperature_probe_resolution(WORD(data + 0x0A)); - dmi_temperature_probe_value("Tolerance", - WORD(data + 0x0C)); + printf("\n"); + printf("\tTolerance:"); + dmi_temperature_probe_value(WORD(data + 0x0C)); + printf("\n"); + printf("\tAccuracy:"); dmi_probe_accuracy(WORD(data + 0x0E)); - pr_attr("OEM-specific Information", "0x%08X", + printf("\n"); + printf("\tOEM-specific Information: 0x%08X\n", DWORD(data + 0x10)); if (h->length < 0x16) break; - dmi_temperature_probe_value("Nominal Value", - WORD(data + 0x14)); + printf("\tNominal Value:"); + dmi_temperature_probe_value(WORD(data + 0x14)); + printf("\n"); break; case 29: /* 7.30 Electrical Current Probe */ - pr_handle_name("Electrical Current Probe"); + printf("Electrical Current Probe\n"); if (h->length < 0x14) break; - pr_attr("Description", "%s", + printf("\tDescription: %s\n", dmi_string(h, data[0x04])); - pr_attr("Location", "%s", + printf("\tLocation: %s\n", dmi_voltage_probe_location(data[5] & 0x1F)); - pr_attr("Status", "%s", + printf("\tStatus: %s\n", dmi_probe_status(data[0x05] >> 5)); - dmi_current_probe_value("Maximum Value", - WORD(data + 0x06)); - dmi_current_probe_value("Minimum Value", - WORD(data + 0x08)); + printf("\tMaximum Value:"); + dmi_current_probe_value(WORD(data + 0x06)); + printf("\n"); + printf("\tMinimum Value:"); + dmi_current_probe_value(WORD(data + 0x08)); + printf("\n"); + printf("\tResolution:"); dmi_current_probe_resolution(WORD(data + 0x0A)); - dmi_current_probe_value("Tolerance", - WORD(data + 0x0C)); + printf("\n"); + printf("\tTolerance:"); + dmi_current_probe_value(WORD(data + 0x0C)); + printf("\n"); + printf("\tAccuracy:"); dmi_probe_accuracy(WORD(data + 0x0E)); - pr_attr("OEM-specific Information", "0x%08X", + printf("\n"); + printf("\tOEM-specific Information: 0x%08X\n", DWORD(data + 0x10)); if (h->length < 0x16) break; - dmi_current_probe_value("Nominal Value", - WORD(data + 0x14)); + printf("\tNominal Value:"); + dmi_current_probe_value(WORD(data + 0x14)); + printf("\n"); break; case 30: /* 7.31 Out-of-band Remote Access */ - pr_handle_name("Out-of-band Remote Access"); + printf("Out-of-band Remote Access\n"); if (h->length < 0x06) break; - pr_attr("Manufacturer Name", "%s", + printf("\tManufacturer Name: %s\n", dmi_string(h, data[0x04])); - pr_attr("Inbound Connection", "%s", + printf("\tInbound Connection: %s\n", data[0x05] & (1 << 0) ? "Enabled" : "Disabled"); - pr_attr("Outbound Connection", "%s", + printf("\tOutbound Connection: %s\n", data[0x05] & (1 << 1) ? "Enabled" : "Disabled"); break; case 31: /* 7.32 Boot Integrity Services Entry Point */ - pr_handle_name("Boot Integrity Services Entry Point"); + printf("Boot Integrity Services Entry Point\n"); if (h->length < 0x1C) break; - pr_attr("Checksum", "%s", + printf("\tChecksum: %s\n", checksum(data, h->length) ? "OK" : "Invalid"); - pr_attr("16-bit Entry Point Address", "%04X:%04X", + printf("\t16-bit Entry Point Address: %04X:%04X\n", DWORD(data + 0x08) >> 16, DWORD(data + 0x08) & 0xFFFF); - pr_attr("32-bit Entry Point Address", "0x%08X", + printf("\t32-bit Entry Point Address: 0x%08X\n", DWORD(data + 0x0C)); break; case 32: /* 7.33 System Boot Information */ - pr_handle_name("System Boot Information"); + printf("System Boot Information\n"); if (h->length < 0x0B) break; - pr_attr("Status", "%s", + printf("\tStatus: %s\n", dmi_system_boot_status(data[0x0A])); break; case 33: /* 7.34 64-bit Memory Error Information */ - pr_handle_name("64-bit Memory Error Information"); if (h->length < 0x1F) break; - pr_attr("Type", "%s", + printf("64-bit Memory Error Information\n"); + printf("\tType: %s\n", dmi_memory_error_type(data[0x04])); - pr_attr("Granularity", "%s", + printf("\tGranularity: %s\n", dmi_memory_error_granularity(data[0x05])); - pr_attr("Operation", "%s", + printf("\tOperation: %s\n", dmi_memory_error_operation(data[0x06])); + printf("\tVendor Syndrome:"); dmi_memory_error_syndrome(DWORD(data + 0x07)); - dmi_64bit_memory_error_address("Memory Array Address", - QWORD(data + 0x0B)); - dmi_64bit_memory_error_address("Device Address", - QWORD(data + 0x13)); - dmi_32bit_memory_error_address("Resolution", - DWORD(data + 0x1B)); + printf("\n"); + printf("\tMemory Array Address:"); + dmi_64bit_memory_error_address(QWORD(data + 0x0B)); + printf("\n"); + printf("\tDevice Address:"); + dmi_64bit_memory_error_address(QWORD(data + 0x13)); + printf("\n"); + printf("\tResolution:"); + dmi_32bit_memory_error_address(DWORD(data + 0x1B)); + printf("\n"); break; case 34: /* 7.35 Management Device */ - pr_handle_name("Management Device"); + printf("Management Device\n"); if (h->length < 0x0B) break; - pr_attr("Description", "%s", + printf("\tDescription: %s\n", dmi_string(h, data[0x04])); - pr_attr("Type", "%s", + printf("\tType: %s\n", dmi_management_device_type(data[0x05])); - pr_attr("Address", "0x%08X", + printf("\tAddress: 0x%08X\n", DWORD(data + 0x06)); - pr_attr("Address Type", "%s", + printf("\tAddress Type: %s\n", dmi_management_device_address_type(data[0x0A])); break; case 35: /* 7.36 Management Device Component */ - pr_handle_name("Management Device Component"); + printf("Management Device Component\n"); if (h->length < 0x0B) break; - pr_attr("Description", "%s", + printf("\tDescription: %s\n", dmi_string(h, data[0x04])); if (!(opt.flags & FLAG_QUIET)) { - pr_attr("Management Device Handle", "0x%04X", + printf("\tManagement Device Handle: 0x%04X\n", WORD(data + 0x05)); - pr_attr("Component Handle", "0x%04X", + printf("\tComponent Handle: 0x%04X\n", WORD(data + 0x07)); if (WORD(data + 0x09) != 0xFFFF) - pr_attr("Threshold Handle", "0x%04X", - WORD(data + 0x09)); + printf("\tThreshold Handle: 0x%04X\n", + WORD(data + 0x09)); } break; case 36: /* 7.37 Management Device Threshold Data */ - pr_handle_name("Management Device Threshold Data"); + printf("Management Device Threshold Data\n"); if (h->length < 0x10) break; if (WORD(data + 0x04) != 0x8000) - pr_attr("Lower Non-critical Threshold", "%d", + printf("\tLower Non-critical Threshold: %d\n", (i16)WORD(data + 0x04)); if (WORD(data + 0x06) != 0x8000) - pr_attr("Upper Non-critical Threshold", "%d", + printf("\tUpper Non-critical Threshold: %d\n", (i16)WORD(data + 0x06)); if (WORD(data + 0x08) != 0x8000) - pr_attr("Lower Critical Threshold", "%d", + printf("\tLower Critical Threshold: %d\n", (i16)WORD(data + 0x08)); if (WORD(data + 0x0A) != 0x8000) - pr_attr("Upper Critical Threshold", "%d", + printf("\tUpper Critical Threshold: %d\n", (i16)WORD(data + 0x0A)); if (WORD(data + 0x0C) != 0x8000) - pr_attr("Lower Non-recoverable Threshold", "%d", + printf("\tLower Non-recoverable Threshold: %d\n", (i16)WORD(data + 0x0C)); if (WORD(data + 0x0E) != 0x8000) - pr_attr("Upper Non-recoverable Threshold", "%d", + printf("\tUpper Non-recoverable Threshold: %d\n", (i16)WORD(data + 0x0E)); break; case 37: /* 7.38 Memory Channel */ - pr_handle_name("Memory Channel"); + printf("Memory Channel\n"); if (h->length < 0x07) break; - pr_attr("Type", "%s", + printf("\tType: %s\n", dmi_memory_channel_type(data[0x04])); - pr_attr("Maximal Load", "%u", + printf("\tMaximal Load: %u\n", data[0x05]); - pr_attr("Devices", "%u", + printf("\tDevices: %u\n", data[0x06]); if (h->length < 0x07 + 3 * data[0x06]) break; - dmi_memory_channel_devices(data[0x06], data + 0x07); + dmi_memory_channel_devices(data[0x06], data + 0x07, "\t"); break; case 38: /* 7.39 IPMI Device Information */ @@ -4887,86 +4850,92 @@ static void dmi_decode(const struct dmi_header *h, u16 ver) * We use the word "Version" instead of "Revision", conforming to * the IPMI specification. */ - pr_handle_name("IPMI Device Information"); + printf("IPMI Device Information\n"); if (h->length < 0x10) break; - pr_attr("Interface Type", "%s", + printf("\tInterface Type: %s\n", dmi_ipmi_interface_type(data[0x04])); - pr_attr("Specification Version", "%u.%u", + printf("\tSpecification Version: %u.%u\n", data[0x05] >> 4, data[0x05] & 0x0F); - pr_attr("I2C Slave Address", "0x%02x", + printf("\tI2C Slave Address: 0x%02x\n", data[0x06] >> 1); if (data[0x07] != 0xFF) - pr_attr("NV Storage Device Address", "%u", + printf("\tNV Storage Device Address: %u\n", data[0x07]); else - pr_attr("NV Storage Device", "Not Present"); + printf("\tNV Storage Device: Not Present\n"); + printf("\tBase Address: "); dmi_ipmi_base_address(data[0x04], data + 0x08, h->length < 0x11 ? 0 : (data[0x10] >> 4) & 1); + printf("\n"); if (h->length < 0x12) break; if (data[0x04] != 0x04) { - pr_attr("Register Spacing", "%s", + printf("\tRegister Spacing: %s\n", dmi_ipmi_register_spacing(data[0x10] >> 6)); if (data[0x10] & (1 << 3)) { - pr_attr("Interrupt Polarity", "%s", + printf("\tInterrupt Polarity: %s\n", data[0x10] & (1 << 1) ? "Active High" : "Active Low"); - pr_attr("Interrupt Trigger Mode", "%s", + printf("\tInterrupt Trigger Mode: %s\n", data[0x10] & (1 << 0) ? "Level" : "Edge"); } } if (data[0x11] != 0x00) { - pr_attr("Interrupt Number", "%u", + printf("\tInterrupt Number: %u\n", data[0x11]); } break; case 39: /* 7.40 System Power Supply */ - pr_handle_name("System Power Supply"); + printf("System Power Supply\n"); if (h->length < 0x10) break; if (data[0x04] != 0x00) - pr_attr("Power Unit Group", "%u", + printf("\tPower Unit Group: %u\n", data[0x04]); - pr_attr("Location", "%s", + printf("\tLocation: %s\n", dmi_string(h, data[0x05])); - pr_attr("Name", "%s", + printf("\tName: %s\n", dmi_string(h, data[0x06])); - pr_attr("Manufacturer", "%s", + printf("\tManufacturer: %s\n", dmi_string(h, data[0x07])); - pr_attr("Serial Number", "%s", + printf("\tSerial Number: %s\n", dmi_string(h, data[0x08])); - pr_attr("Asset Tag", "%s", + printf("\tAsset Tag: %s\n", dmi_string(h, data[0x09])); - pr_attr("Model Part Number", "%s", + printf("\tModel Part Number: %s\n", dmi_string(h, data[0x0A])); - pr_attr("Revision", "%s", + printf("\tRevision: %s\n", dmi_string(h, data[0x0B])); + printf("\tMax Power Capacity:"); dmi_power_supply_power(WORD(data + 0x0C)); + printf("\n"); + printf("\tStatus:"); if (WORD(data + 0x0E) & (1 << 1)) - pr_attr("Status", "Present, %s", + printf(" Present, %s", dmi_power_supply_status((WORD(data + 0x0E) >> 7) & 0x07)); else - pr_attr("Status", "Not Present"); - pr_attr("Type", "%s", + printf(" Not Present"); + printf("\n"); + printf("\tType: %s\n", dmi_power_supply_type((WORD(data + 0x0E) >> 10) & 0x0F)); - pr_attr("Input Voltage Range Switching", "%s", + printf("\tInput Voltage Range Switching: %s\n", dmi_power_supply_range_switching((WORD(data + 0x0E) >> 3) & 0x0F)); - pr_attr("Plugged", "%s", + printf("\tPlugged: %s\n", WORD(data + 0x0E) & (1 << 2) ? "No" : "Yes"); - pr_attr("Hot Replaceable", "%s", + printf("\tHot Replaceable: %s\n", WORD(data + 0x0E) & (1 << 0) ? "Yes" : "No"); if (h->length < 0x16) break; if (!(opt.flags & FLAG_QUIET)) { if (WORD(data + 0x10) != 0xFFFF) - pr_attr("Input Voltage Probe Handle", "0x%04X", + printf("\tInput Voltage Probe Handle: 0x%04X\n", WORD(data + 0x10)); if (WORD(data + 0x12) != 0xFFFF) - pr_attr("Cooling Device Handle", "0x%04X", + printf("\tCooling Device Handle: 0x%04X\n", WORD(data + 0x12)); if (WORD(data + 0x14) != 0xFFFF) - pr_attr("Input Current Probe Handle", "0x%04X", + printf("\tInput Current Probe Handle: 0x%04X\n", WORD(data + 0x14)); } break; @@ -4975,27 +4944,27 @@ static void dmi_decode(const struct dmi_header *h, u16 ver) if (h->length < 0x0B) break; if (opt.flags & FLAG_QUIET) return; - dmi_additional_info(h); + dmi_additional_info(h, ""); break; case 41: /* 7.42 Onboard Device Extended Information */ - pr_handle_name("Onboard Device"); + printf("Onboard Device\n"); if (h->length < 0x0B) break; - pr_attr("Reference Designation", "%s", dmi_string(h, data[0x04])); - pr_attr("Type", "%s", + printf("\tReference Designation: %s\n", dmi_string(h, data[0x04])); + printf("\tType: %s\n", dmi_on_board_devices_type(data[0x05] & 0x7F)); - pr_attr("Status", "%s", + printf("\tStatus: %s\n", data[0x05] & 0x80 ? "Enabled" : "Disabled"); - pr_attr("Type Instance", "%u", data[0x06]); - dmi_slot_segment_bus_func(WORD(data + 0x07), data[0x09], data[0x0A]); + printf("\tType Instance: %u\n", data[0x06]); + dmi_slot_segment_bus_func(WORD(data + 0x07), data[0x09], data[0x0A], "\t"); break; case 42: /* 7.43 Management Controller Host Interface */ - pr_handle_name("Management Controller Host Interface"); + printf("Management Controller Host Interface\n"); if (ver < 0x0302) { if (h->length < 0x05) break; - pr_attr("Interface Type", "%s", + printf("\tInterface Type: %s\n", dmi_management_controller_host_type(data[0x04])); /* * There you have a type-dependent, variable-length @@ -5006,20 +4975,22 @@ static void dmi_decode(const struct dmi_header *h, u16 ver) if (h->length < 0x09) break; if (data[0x04] == 0xF0) /* OEM */ { - pr_attr("Vendor ID", "0x%02X%02X%02X%02X", + printf("\tVendor ID: 0x%02X%02X%02X%02X\n", data[0x05], data[0x06], data[0x07], data[0x08]); } } else - dmi_parse_controller_structure(h); + dmi_parse_controller_structure(h, "\t"); break; case 43: /* 7.44 TPM Device */ - pr_handle_name("TPM Device"); + printf("TPM Device\n"); if (h->length < 0x1B) break; + printf("\tVendor ID:"); dmi_tpm_vendor_id(data + 0x04); - pr_attr("Specification Version", "%d.%d", data[0x08], data[0x09]); + printf("\n"); + printf("\tSpecification Version: %d.%d", data[0x08], data[0x09]); switch (data[0x08]) { case 0x01: @@ -5028,11 +4999,11 @@ static void dmi_decode(const struct dmi_header *h, u16 ver) * redundant with the above, and uncoded * in a silly way. */ - pr_attr("Firmware Revision", "%u.%u", + printf("\tFirmware Revision: %u.%u\n", data[0x0C], data[0x0D]); break; case 0x02: - pr_attr("Firmware Revision", "%u.%u", + printf("\tFirmware Revision: %u.%u\n", DWORD(data + 0x0A) >> 16, DWORD(data + 0x0A) & 0xFFFF); /* @@ -5042,21 +5013,20 @@ static void dmi_decode(const struct dmi_header *h, u16 ver) */ break; } - pr_attr("Description", "%s", dmi_string(h, data[0x12])); - pr_list_start("Characteristics", NULL); - dmi_tpm_characteristics(QWORD(data + 0x13)); - pr_list_end(); + printf("\tDescription: %s", dmi_string(h, data[0x12])); + printf("\tCharacteristics:\n"); + dmi_tpm_characteristics(QWORD(data + 0x13), "\t\t"); if (h->length < 0x1F) break; - pr_attr("OEM-specific Information", "0x%08X", + printf("\tOEM-specific Information: 0x%08X\n", DWORD(data + 0x1B)); break; case 126: /* 7.44 Inactive */ - pr_handle_name("Inactive"); + printf("Inactive\n"); break; case 127: /* 7.45 End Of Table */ - pr_handle_name("End Of Table"); + printf("End Of Table\n"); break; default: @@ -5064,11 +5034,11 @@ static void dmi_decode(const struct dmi_header *h, u16 ver) break; if (opt.flags & FLAG_QUIET) return; - pr_handle_name("%s Type", + printf("%s Type\n", h->type >= 128 ? "OEM-specific" : "Unknown"); - dmi_dump(h); + dmi_dump(h, "\t"); } - pr_sep(); + printf("\n"); } static void to_dmi_header(struct dmi_header *h, u8 *data) @@ -5105,16 +5075,9 @@ static void dmi_table_string(const struct dmi_header *h, const u8 *data, u16 ver key = (opt.string->type << 8) | offset; switch (key) { - case 0x015: /* -s bios-revision */ - if (data[key - 1] != 0xFF && data[key] != 0xFF) - printf("%u.%u\n", data[key - 1], data[key]); - break; - case 0x017: /* -s firmware-revision */ - if (data[key - 1] != 0xFF && data[key] != 0xFF) - printf("%u.%u\n", data[key - 1], data[key]); - break; case 0x108: - dmi_system_uuid(NULL, NULL, data + offset, ver); + dmi_system_uuid(data + offset, ver); + printf("\n"); break; case 0x305: printf("%s\n", dmi_chassis_type(data[offset])); @@ -5123,7 +5086,8 @@ static void dmi_table_string(const struct dmi_header *h, const u8 *data, u16 ver printf("%s\n", dmi_processor_family(h, ver)); break; case 0x416: - dmi_processor_frequency(NULL, data + offset); + dmi_processor_frequency(data + offset); + printf("\n"); break; default: printf("%s\n", dmi_string(h, data[offset])); @@ -5133,7 +5097,7 @@ static void dmi_table_string(const struct dmi_header *h, const u8 *data, u16 ver static void dmi_table_dump(const u8 *buf, u32 len) { if (!(opt.flags & FLAG_QUIET)) - pr_comment("Writing %d bytes to %s.", len, opt.dumpfile); + printf("# Writing %d bytes to %s.\n", len, opt.dumpfile); write_dump(32, len, buf, opt.dumpfile, 0); } @@ -5182,7 +5146,8 @@ static void dmi_table_decode(u8 *buf, u32 len, u16 num, u16 ver, u32 flags) if (display && (!(opt.flags & FLAG_QUIET) || (opt.flags & FLAG_DUMP))) - pr_handle(&h); + printf("Handle 0x%04X, DMI type %d, %d bytes\n", + h.handle, h.type, h.length); /* Look for the next handle */ next = data + h.length; @@ -5195,8 +5160,7 @@ static void dmi_table_decode(u8 *buf, u32 len, u16 num, u16 ver, u32 flags) if ((unsigned long)(next - buf) > len) { if (display && !(opt.flags & FLAG_QUIET)) - pr_struct_err(""); - pr_sep(); + printf("\t\n\n"); data = next; break; } @@ -5213,8 +5177,8 @@ static void dmi_table_decode(u8 *buf, u32 len, u16 num, u16 ver, u32 flags) { if (opt.flags & FLAG_DUMP) { - dmi_dump(&h); - pr_sep(); + dmi_dump(&h, "\t"); + printf("\n"); } else dmi_decode(&h, ver); @@ -5254,11 +5218,11 @@ static void dmi_table(off_t base, u32 len, u16 num, u32 ver, const char *devmem, if (ver > SUPPORTED_SMBIOS_VER && !(opt.flags & FLAG_QUIET)) { - pr_comment("SMBIOS implementations newer than version %u.%u.%u are not", - SUPPORTED_SMBIOS_VER >> 16, - (SUPPORTED_SMBIOS_VER >> 8) & 0xFF, - SUPPORTED_SMBIOS_VER & 0xFF); - pr_comment("fully supported by this version of dmidecode."); + printf("# SMBIOS implementations newer than version %u.%u.%u are not\n" + "# fully supported by this version of dmidecode.\n", + SUPPORTED_SMBIOS_VER >> 16, + (SUPPORTED_SMBIOS_VER >> 8) & 0xFF, + SUPPORTED_SMBIOS_VER & 0xFF); } if (!(opt.flags & FLAG_QUIET)) @@ -5266,13 +5230,13 @@ static void dmi_table(off_t base, u32 len, u16 num, u32 ver, const char *devmem, if (opt.type == NULL) { if (num) - pr_info("%u structures occupying %u bytes.", - num, len); + printf("%u structures occupying %u bytes.\n", + num, len); if (!(opt.flags & FLAG_FROM_DUMP)) - pr_info("Table at 0x%08llX.", - (unsigned long long)base); + printf("Table at 0x%08llX.\n", + (unsigned long long)base); } - pr_sep(); + printf("\n"); } if ((flags & FLAG_NO_FILE_OFFSET) || (opt.flags & FLAG_FROM_DUMP)) @@ -5367,8 +5331,8 @@ static int smbios3_decode(u8 *buf, const char *devmem, u32 flags) ver = (buf[0x07] << 16) + (buf[0x08] << 8) + buf[0x09]; if (!(opt.flags & FLAG_QUIET)) - pr_info("SMBIOS %u.%u.%u present.", - buf[0x07], buf[0x08], buf[0x09]); + printf("SMBIOS %u.%u.%u present.\n", + buf[0x07], buf[0x08], buf[0x09]); offset = QWORD(buf + 0x10); if (!(flags & FLAG_NO_FILE_OFFSET) && offset.h && sizeof(off_t) < 8) @@ -5388,8 +5352,8 @@ static int smbios3_decode(u8 *buf, const char *devmem, u32 flags) overwrite_smbios3_address(crafted); if (!(opt.flags & FLAG_QUIET)) - pr_comment("Writing %d bytes to %s.", crafted[0x06], - opt.dumpfile); + printf("# Writing %d bytes to %s.\n", crafted[0x06], + opt.dumpfile); write_dump(0, crafted[0x06], crafted, opt.dumpfile, 1); } @@ -5435,7 +5399,7 @@ static int smbios_decode(u8 *buf, const char *devmem, u32 flags) break; } if (!(opt.flags & FLAG_QUIET)) - pr_info("SMBIOS %u.%u present.", + printf("SMBIOS %u.%u present.\n", ver >> 8, ver & 0xFF); dmi_table(DWORD(buf + 0x18), WORD(buf + 0x16), WORD(buf + 0x1C), @@ -5449,8 +5413,8 @@ static int smbios_decode(u8 *buf, const char *devmem, u32 flags) overwrite_dmi_address(crafted + 0x10); if (!(opt.flags & FLAG_QUIET)) - pr_comment("Writing %d bytes to %s.", crafted[0x05], - opt.dumpfile); + printf("# Writing %d bytes to %s.\n", crafted[0x05], + opt.dumpfile); write_dump(0, crafted[0x05], crafted, opt.dumpfile, 1); } @@ -5463,7 +5427,7 @@ static int legacy_decode(u8 *buf, const char *devmem, u32 flags) return 0; if (!(opt.flags & FLAG_QUIET)) - pr_info("Legacy DMI %u.%u present.", + printf("Legacy DMI %u.%u present.\n", buf[0x0E] >> 4, buf[0x0E] & 0x0F); dmi_table(DWORD(buf + 0x08), WORD(buf + 0x06), WORD(buf + 0x0C), @@ -5478,8 +5442,8 @@ static int legacy_decode(u8 *buf, const char *devmem, u32 flags) overwrite_dmi_address(crafted); if (!(opt.flags & FLAG_QUIET)) - pr_comment("Writing %d bytes to %s.", 0x0F, - opt.dumpfile); + printf("# Writing %d bytes to %s.\n", 0x0F, + opt.dumpfile); write_dump(0, 0x0F, crafted, opt.dumpfile, 1); } @@ -5557,8 +5521,8 @@ static int address_from_efi(off_t *address) #endif if (ret == 0 && !(opt.flags & FLAG_QUIET)) - pr_comment("%s entry point at 0x%08llx", - eptype, (unsigned long long)*address); + printf("# %s entry point at 0x%08llx\n", + eptype, (unsigned long long)*address); return ret; } @@ -5570,7 +5534,7 @@ int main(int argc, char * const argv[]) off_t fp; size_t size; int efi; - u8 *buf = NULL; + u8 *buf; /* * We don't want stdout and stderr to be mixed up if both are @@ -5609,14 +5573,14 @@ int main(int argc, char * const argv[]) } if (!(opt.flags & FLAG_QUIET)) - pr_comment("dmidecode %s", VERSION); + printf("# dmidecode %s\n", VERSION); /* Read from dump if so instructed */ if (opt.flags & FLAG_FROM_DUMP) { if (!(opt.flags & FLAG_QUIET)) - pr_info("Reading SMBIOS/DMI data from file %s.", - opt.dumpfile); + printf("Reading SMBIOS/DMI data from file %s.\n", + opt.dumpfile); if ((buf = mem_chunk(0, 0x20, opt.dumpfile)) == NULL) { ret = 1; @@ -5651,7 +5615,7 @@ int main(int argc, char * const argv[]) && (buf = read_file(0, &size, SYS_ENTRY_FILE)) != NULL) { if (!(opt.flags & FLAG_QUIET)) - pr_info("Getting SMBIOS data from sysfs."); + printf("Getting SMBIOS data from sysfs.\n"); if (size >= 24 && memcmp(buf, "_SM3_", 5) == 0) { if (smbios3_decode(buf, SYS_TABLE_FILE, FLAG_NO_FILE_OFFSET)) @@ -5671,10 +5635,10 @@ int main(int argc, char * const argv[]) if (found) goto done; if (!(opt.flags & FLAG_QUIET)) - pr_info("Failed to get SMBIOS data from sysfs."); + printf("Failed to get SMBIOS data from sysfs.\n"); } - /* Next try EFI (ia64, Intel-based Mac, arm64) */ + /* Next try EFI (ia64, Intel-based Mac) */ efi = address_from_efi(&fp); switch (efi) { @@ -5686,8 +5650,8 @@ int main(int argc, char * const argv[]) } if (!(opt.flags & FLAG_QUIET)) - pr_info("Found SMBIOS entry point in EFI, reading table from %s.", - opt.devmem); + printf("Found SMBIOS entry point in EFI, reading table from %s.\n", + opt.devmem); if ((buf = mem_chunk(fp, 0x20, opt.devmem)) == NULL) { ret = 1; @@ -5707,9 +5671,8 @@ int main(int argc, char * const argv[]) goto done; memory_scan: -#if defined __i386__ || defined __x86_64__ if (!(opt.flags & FLAG_QUIET)) - pr_info("Scanning %s for entry point.", opt.devmem); + printf("Scanning %s for entry point.\n", opt.devmem); /* Fallback to memory scan (x86, x86_64) */ if ((buf = mem_chunk(0xF0000, 0x10000, opt.devmem)) == NULL) { @@ -5750,11 +5713,10 @@ memory_scan: } } } -#endif done: if (!found && !(opt.flags & FLAG_QUIET)) - pr_comment("No SMBIOS nor DMI entry point found, sorry."); + printf("# No SMBIOS nor DMI entry point found, sorry.\n"); free(buf); exit_free: diff --git a/dmidecode.h b/dmidecode.h index 1dc59a7..20e7e96 100644 --- a/dmidecode.h +++ b/dmidecode.h @@ -1,7 +1,7 @@ /* * This file is part of the dmidecode project. * - * Copyright (C) 2005-2020 Jean Delvare + * Copyright (C) 2005-2008 Jean Delvare * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -18,9 +18,6 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef DMIDECODE_H -#define DMIDECODE_H - #include "types.h" struct dmi_header @@ -33,5 +30,3 @@ struct dmi_header int is_printable(const u8 *data, int len); const char *dmi_string(const struct dmi_header *dm, u8 s); - -#endif diff --git a/dmioem.c b/dmioem.c index 60b6674..1a9bd82 100644 --- a/dmioem.c +++ b/dmioem.c @@ -2,7 +2,7 @@ * Decoding of OEM-specific entries * This file is part of the dmidecode project. * - * Copyright (C) 2007-2020 Jean Delvare + * Copyright (C) 2007-2008 Jean Delvare * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -25,7 +25,6 @@ #include "types.h" #include "dmidecode.h" #include "dmioem.h" -#include "dmioutput.h" /* * Globals for vendor-specific decodes @@ -93,19 +92,19 @@ static int dmi_decode_acer(const struct dmi_header *h) * brands, including Fujitsu-Siemens, Medion, Lenovo, * and eMachines. */ - pr_handle_name("Acer Hotkey Function"); + printf("Acer Hotkey Function\n"); if (h->length < 0x0F) break; cap = WORD(data + 0x04); - pr_attr("Function bitmap for Communication Button", "0x%04hx", cap); - pr_subattr("WiFi", "%s", cap & 0x0001 ? "Yes" : "No"); - pr_subattr("3G", "%s", cap & 0x0040 ? "Yes" : "No"); - pr_subattr("WiMAX", "%s", cap & 0x0080 ? "Yes" : "No"); - pr_subattr("Bluetooth", "%s", cap & 0x0800 ? "Yes" : "No"); - pr_attr("Function bitmap for Application Button", "0x%04hx", WORD(data + 0x06)); - pr_attr("Function bitmap for Media Button", "0x%04hx", WORD(data + 0x08)); - pr_attr("Function bitmap for Display Button", "0x%04hx", WORD(data + 0x0A)); - pr_attr("Function bitmap for Others Button", "0x%04hx", WORD(data + 0x0C)); - pr_attr("Communication Function Key Number", "%d", data[0x0E]); + printf("\tFunction bitmap for Communication Button: 0x%04hx\n", cap); + printf("\t\tWiFi: %s\n", cap & 0x0001 ? "Yes" : "No"); + printf("\t\t3G: %s\n", cap & 0x0040 ? "Yes" : "No"); + printf("\t\tWiMAX: %s\n", cap & 0x0080 ? "Yes" : "No"); + printf("\t\tBluetooth: %s\n", cap & 0x0800 ? "Yes" : "No"); + printf("\tFunction bitmap for Application Button: 0x%04hx\n", WORD(data + 0x06)); + printf("\tFunction bitmap for Media Button: 0x%04hx\n", WORD(data + 0x08)); + printf("\tFunction bitmap for Display Button: 0x%04hx\n", WORD(data + 0x0A)); + printf("\tFunction bitmap for Others Button: 0x%04hx\n", WORD(data + 0x0C)); + printf("\tCommunication Function Key Number: %d\n", data[0x0E]); break; default: @@ -128,21 +127,19 @@ static void dmi_print_hp_net_iface_rec(u8 id, u8 bus, u8 dev, const u8 *mac) * 640K ought to be enough for anybody(said no one, ever). * */ static u8 nic_ctr; - char attr[8]; if (id == 0xFF) id = ++nic_ctr; - sprintf(attr, "NIC %hu", id); if (dev == 0x00 && bus == 0x00) - pr_attr(attr, "Disabled"); + printf("\tNIC %d: Disabled\n", id); else if (dev == 0xFF && bus == 0xFF) - pr_attr(attr, "Not Installed"); + printf("\tNIC %d: Not Installed\n", id); else { - pr_attr(attr, "PCI device %02x:%02x.%x, " - "MAC address %02X:%02X:%02X:%02X:%02X:%02X", - bus, dev >> 3, dev & 7, + printf("\tNIC %d: PCI device %02x:%02x.%x, " + "MAC address %02X:%02X:%02X:%02X:%02X:%02X\n", + id, bus, dev >> 3, dev & 7, mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]); } } @@ -160,15 +157,15 @@ static int dmi_decode_hp(const struct dmi_header *h) /* * Vendor Specific: HPE ProLiant System/Rack Locator */ - pr_handle_name("%s ProLiant System/Rack Locator", company); + printf("%s ProLiant System/Rack Locator\n", company); if (h->length < 0x0B) break; - pr_attr("Rack Name", "%s", dmi_string(h, data[0x04])); - pr_attr("Enclosure Name", "%s", dmi_string(h, data[0x05])); - pr_attr("Enclosure Model", "%s", dmi_string(h, data[0x06])); - pr_attr("Enclosure Serial", "%s", dmi_string(h, data[0x0A])); - pr_attr("Enclosure Bays", "%d", data[0x08]); - pr_attr("Server Bay", "%s", dmi_string(h, data[0x07])); - pr_attr("Bays Filled", "%d", data[0x09]); + printf("\tRack Name: %s\n", dmi_string(h, data[0x04])); + printf("\tEnclosure Name: %s\n", dmi_string(h, data[0x05])); + printf("\tEnclosure Model: %s\n", dmi_string(h, data[0x06])); + printf("\tEnclosure Serial: %s\n", dmi_string(h, data[0x0A])); + printf("\tEnclosure Bays: %d\n", data[0x08]); + printf("\tServer Bay: %s\n", dmi_string(h, data[0x07])); + printf("\tBays Filled: %d\n", data[0x09]); break; case 209: @@ -192,9 +189,10 @@ static int dmi_decode_hp(const struct dmi_header *h) * * Type 221: is deprecated in the latest docs */ - pr_handle_name("%s %s", company, h->type == 221 ? - "BIOS iSCSI NIC PCI and MAC Information" : - "BIOS PXE NIC PCI and MAC Information"); + printf("%s %s\n", company, + h->type == 221 ? + "BIOS iSCSI NIC PCI and MAC Information" : + "BIOS PXE NIC PCI and MAC Information"); nic = 1; ptr = 4; while (h->length >= ptr + 8) @@ -226,8 +224,7 @@ static int dmi_decode_hp(const struct dmi_header *h) * 0x08 | MAC | 32B | MAC addr padded w/ 0s * 0x28 | Port No| BYTE | Each NIC maps to a Port */ - pr_handle_name("%s BIOS PXE NIC PCI and MAC Information", - company); + printf("%s BIOS PXE NIC PCI and MAC Information\n", company); if (h->length < 0x0E) break; /* If the record isn't long enough, we don't have an ID * use 0xFF to use the internal counter. @@ -243,24 +240,22 @@ static int dmi_decode_hp(const struct dmi_header *h) * * Source: hpwdt kernel driver */ - pr_handle_name("%s 64-bit CRU Information", company); + printf("%s 64-bit CRU Information\n", company); if (h->length < 0x18) break; + printf("\tSignature: 0x%08x", DWORD(data + 0x04)); if (is_printable(data + 0x04, 4)) - pr_attr("Signature", "0x%08x (%c%c%c%c)", - DWORD(data + 0x04), - data[0x04], data[0x05], + printf(" (%c%c%c%c)", data[0x04], data[0x05], data[0x06], data[0x07]); - else - pr_attr("Signature", "0x%08x", DWORD(data + 0x04)); + printf("\n"); if (DWORD(data + 0x04) == 0x55524324) { u64 paddr = QWORD(data + 0x08); paddr.l += DWORD(data + 0x14); if (paddr.l < DWORD(data + 0x14)) paddr.h++; - pr_attr("Physical Address", "0x%08x%08x", + printf("\tPhysical Address: 0x%08x%08x\n", paddr.h, paddr.l); - pr_attr("Length", "0x%08x", DWORD(data + 0x10)); + printf("\tLength: 0x%08x\n", DWORD(data + 0x10)); } break; @@ -270,16 +265,16 @@ static int dmi_decode_hp(const struct dmi_header *h) * * Source: hpwdt kernel driver */ - pr_handle_name("%s ProLiant Information", company); + printf("%s ProLiant Information\n", company); if (h->length < 0x08) break; - pr_attr("Power Features", "0x%08x", DWORD(data + 0x04)); + printf("\tPower Features: 0x%08x\n", DWORD(data + 0x04)); if (h->length < 0x0C) break; - pr_attr("Omega Features", "0x%08x", DWORD(data + 0x08)); + printf("\tOmega Features: 0x%08x\n", DWORD(data + 0x08)); if (h->length < 0x14) break; feat = DWORD(data + 0x10); - pr_attr("Misc. Features", "0x%08x", feat); - pr_subattr("iCRU", "%s", feat & 0x0001 ? "Yes" : "No"); - pr_subattr("UEFI", "%s", feat & 0x1400 ? "Yes" : "No"); + printf("\tMisc. Features: 0x%08x\n", feat); + printf("\t\tiCRU: %s\n", feat & 0x0001 ? "Yes" : "No"); + printf("\t\tUEFI: %s\n", feat & 0x1400 ? "Yes" : "No"); break; default: @@ -323,9 +318,9 @@ static int dmi_decode_ibm_lenovo(const struct dmi_header *h) || strcmp(dmi_string(h, 1), "TVT-Enablement") != 0) return 0; - pr_handle_name("ThinkVantage Technologies"); - pr_attr("Version", "%u", data[0x04]); - pr_attr("Diagnostics", "%s", + printf("ThinkVantage Technologies\n"); + printf("\tVersion: %u\n", data[0x04]); + printf("\tDiagnostics: %s\n", data[0x14] & 0x80 ? "Available" : "No"); break; @@ -362,8 +357,8 @@ static int dmi_decode_ibm_lenovo(const struct dmi_header *h) if (data[0x06] != 0x07 || data[0x07] != 0x03 || data[0x08] != 0x01) return 0; - pr_handle_name("ThinkPad Device Presence Detection"); - pr_attr("Fingerprint Reader", "%s", + printf("ThinkPad Device Presence Detection\n"); + printf("\tFingerprint Reader: %s\n", data[0x09] & 0x01 ? "Present" : "No"); break; @@ -395,9 +390,9 @@ static int dmi_decode_ibm_lenovo(const struct dmi_header *h) if (data[0x0A] != 0x0B || data[0x0B] != 0x07 || data[0x0C] != 0x01) return 0; - pr_handle_name("ThinkPad Embedded Controller Program"); - pr_attr("Version ID", "%s", dmi_string(h, 1)); - pr_attr("Release Date", "%s", dmi_string(h, 2)); + printf("ThinkPad Embedded Controller Program\n"); + printf("\tVersion ID: %s\n", dmi_string(h, 1)); + printf("\tRelease Date: %s\n", dmi_string(h, 2)); break; default: diff --git a/dmiopt.c b/dmiopt.c index 1c3b760..2f285f3 100644 --- a/dmiopt.c +++ b/dmiopt.c @@ -151,8 +151,6 @@ static const struct string_keyword opt_string_keyword[] = { { "bios-vendor", 0, 0x04 }, { "bios-version", 0, 0x05 }, { "bios-release-date", 0, 0x08 }, - { "bios-revision", 0, 0x15 }, /* 0x14 and 0x15 */ - { "firmware-revision", 0, 0x17 }, /* 0x16 and 0x17 */ { "system-manufacturer", 1, 0x04 }, { "system-product-name", 1, 0x05 }, { "system-version", 1, 0x06 }, diff --git a/dmioutput.c b/dmioutput.c deleted file mode 100644 index 42f8d32..0000000 --- a/dmioutput.c +++ /dev/null @@ -1,137 +0,0 @@ -/* - * Generic output functions - * This file is part of the dmidecode project. - * - * Copyright (C) 2020 Jean Delvare - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include -#include -#include "dmioutput.h" - -void pr_comment(const char *format, ...) -{ - va_list args; - - printf("# "); - va_start(args, format); - vprintf(format, args); - va_end(args); - printf("\n"); -} - -void pr_info(const char *format, ...) -{ - va_list args; - - va_start(args, format); - vprintf(format, args); - va_end(args); - printf("\n"); -} - -void pr_handle(const struct dmi_header *h) -{ - printf("Handle 0x%04X, DMI type %d, %d bytes\n", - h->handle, h->type, h->length); -} - -void pr_handle_name(const char *format, ...) -{ - va_list args; - - va_start(args, format); - vprintf(format, args); - va_end(args); - printf("\n"); -} - -void pr_attr(const char *name, const char *format, ...) -{ - va_list args; - - printf("\t%s: ", name); - - va_start(args, format); - vprintf(format, args); - va_end(args); - printf("\n"); -} - -void pr_subattr(const char *name, const char *format, ...) -{ - va_list args; - - printf("\t\t%s: ", name); - - va_start(args, format); - vprintf(format, args); - va_end(args); - printf("\n"); -} - -void pr_list_start(const char *name, const char *format, ...) -{ - va_list args; - - printf("\t%s:", name); - - /* format is optional, skip value if not provided */ - if (format) - { - printf(" "); - va_start(args, format); - vprintf(format, args); - va_end(args); - } - printf("\n"); - -} - -void pr_list_item(const char *format, ...) -{ - va_list args; - - printf("\t\t"); - - va_start(args, format); - vprintf(format, args); - va_end(args); - printf("\n"); -} - -void pr_list_end(void) -{ - /* a no-op for text output */ -} - -void pr_sep(void) -{ - printf("\n"); -} - -void pr_struct_err(const char *format, ...) -{ - va_list args; - - printf("\t"); - - va_start(args, format); - vprintf(format, args); - va_end(args); - printf("\n"); -} diff --git a/dmioutput.h b/dmioutput.h deleted file mode 100644 index a492ec0..0000000 --- a/dmioutput.h +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Generic output functions - * This file is part of the dmidecode project. - * - * Copyright (C) 2020 Jean Delvare - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include "dmidecode.h" - -void pr_comment(const char *format, ...); -void pr_info(const char *format, ...); -void pr_handle(const struct dmi_header *h); -void pr_handle_name(const char *format, ...); -void pr_attr(const char *name, const char *format, ...); -void pr_subattr(const char *name, const char *format, ...); -void pr_list_start(const char *name, const char *format, ...); -void pr_list_item(const char *format, ...); -void pr_list_end(void); -void pr_sep(void); -void pr_struct_err(const char *format, ...); diff --git a/man/biosdecode.8 b/man/biosdecode.8 index cf7d4db..a96eb68 100644 --- a/man/biosdecode.8 +++ b/man/biosdecode.8 @@ -1,12 +1,10 @@ .TH BIOSDECODE 8 "February 2007" "dmidecode" -.\" .SH NAME biosdecode \- \s-1BIOS\s0 information decoder -.\" .SH SYNOPSIS .B biosdecode .RB [ OPTIONS ] -.\" + .SH DESCRIPTION .B biosdecode parses the \s-1BIOS\s0 memory and prints information about all structures (or @@ -56,7 +54,7 @@ started its life as a part of .B dmidecode but as more entry point types were added, it was moved to a different program. -.\" + .SH OPTIONS .TP .BR "-d" ", " "--dev-mem FILE" @@ -70,20 +68,17 @@ Display usage information and exit .TP .BR "-V" ", " "--version" Display the version and exit -.\" + .SH FILES .I /dev/mem -.\" .SH BUGS Most of the time, .B biosdecode prints too much information (you don't really care about addresses) or not enough (because it doesn't follow pointers and has no lookup tables). -.\" .SH AUTHORS Alan Cox, Jean Delvare -.\" .SH "SEE ALSO" .BR dmidecode (8), .BR mem (4), diff --git a/man/dmidecode.8 b/man/dmidecode.8 index 4602088..df861e1 100644 --- a/man/dmidecode.8 +++ b/man/dmidecode.8 @@ -1,12 +1,10 @@ -.TH DMIDECODE 8 "January 2019" "dmidecode" -.\" +.TH DMIDECODE 8 "March 2012" "dmidecode" .SH NAME dmidecode \- \s-1DMI\s0 table decoder -.\" .SH SYNOPSIS .B dmidecode .RB [ OPTIONS ] -.\" + .SH DESCRIPTION .B dmidecode is a tool for dumping a computer's \s-1DMI\s0 (some say \s-1SMBIOS\s0) table @@ -60,7 +58,7 @@ displayed value. Decoded values. The information presented of course depends on the type of record. Here, we learn about the board's manufacturer, model, version and serial number. -.\" + .SH OPTIONS .TP .BR "-d" ", " "--dev-mem FILE" @@ -74,7 +72,6 @@ displayed. Meta-data and handle references are hidden. Only display the value of the \s-1DMI\s0 string identified by \fBKEYWORD\fR. \fBKEYWORD\fR must be a keyword from the following list: \fBbios-vendor\fR, \fBbios-version\fR, \fBbios-release-date\fR, -\fBbios-revision\fR, \fBfirmware-revision\fR, \fBsystem-manufacturer\fR, \fBsystem-product-name\fR, \fBsystem-version\fR, \fBsystem-serial-number\fR, \fBsystem-uuid\fR, \fBsystem-family\fR, @@ -161,9 +158,10 @@ is run on a system with BIOS that boasts new SMBIOS specification, which is not supported by the tool yet, it will print out relevant message in addition to requested data on the very top of the output. Thus informs the output data is not reliable. -.\" + .SH "DMI TYPES" The \s-1SMBIOS\s0 specification defines the following \s-1DMI\s0 types: + .TS r l __ @@ -248,7 +246,7 @@ dmidecode --type 0,13 dmidecode --type bios .IP \(bu dmidecode --type BIOS -.\" + .SH BINARY DUMP FILE FORMAT The binary dump files generated by --dump-bin and read using --from-dump are formatted as follows: @@ -257,37 +255,16 @@ The SMBIOS or DMI entry point is located at offset 0x00. It is crafted to hard-code the table address at offset 0x20. .IP \(bu "\w'\(bu'u+1n" The DMI table is located at offset 0x20. -.\" -.SH UUID FORMAT -There is some ambiguity about how to interpret the UUID fields prior to SMBIOS -specification version 2.6. There was no mention of byte swapping, and RFC 4122 -says that no byte swapping should be applied by default. However, SMBIOS -specification version 2.6 (and later) explicitly states that the first 3 fields -of the UUID should be read as little-endian numbers (byte-swapped). -Furthermore, it implies that the same was already true for older versions of -the specification, even though it was not mentioned. In practice, many hardware -vendors were not byte-swapping the UUID. So, in order to preserve -compatibility, it was decided to interpret the UUID fields according to RFC -4122 (no byte swapping) when the SMBIOS version is older than 2.6, and to -interpret the first 3 fields as little-endian (byte-swapped) when the SMBIOS -version is 2.6 or later. The Linux kernel follows the same logic. -.\" + .SH FILES .I /dev/mem -.br -.I /sys/firmware/dmi/tables/smbios_entry_point -(Linux only) -.br -.I /sys/firmware/dmi/tables/DMI -(Linux only) -.\" +.I /sys/firmware/dmi/tables/smbios_entry_point (Linux only) +.I /sys/firmware/dmi/tables/DMI (Linux only) .SH BUGS More often than not, information contained in the \s-1DMI\s0 tables is inaccurate, incomplete or simply wrong. -.\" .SH AUTHORS Alan Cox, Jean Delvare -.\" .SH "SEE ALSO" .BR biosdecode (8), .BR mem (4), diff --git a/man/ownership.8 b/man/ownership.8 index 71ed788..f24ef94 100644 --- a/man/ownership.8 +++ b/man/ownership.8 @@ -1,12 +1,10 @@ .TH OWNERSHIP 8 "February 2005" "dmidecode" -.\" .SH NAME ownership \- Compaq ownership tag retriever -.\" .SH SYNOPSIS .B ownership .RB [ OPTIONS ] -.\" + .SH DESCRIPTION .B ownership retrieves and prints the "ownership tag" that can be set on Compaq @@ -16,7 +14,7 @@ package, .B ownership doesn't print any version information, nor labels, but only the raw ownership tag. This should help its integration in scripts. -.\" + .SH OPTIONS .TP .BR "-d" ", " "--dev-mem FILE" @@ -27,13 +25,11 @@ Display usage information and exit .TP .BR "-V" ", " "--version" Display the version and exit -.\" + .SH FILES .I /dev/mem -.\" .SH AUTHOR Jean Delvare -.\" .SH "SEE ALSO" .BR biosdecode (8), .BR dmidecode (8), diff --git a/man/vpddecode.8 b/man/vpddecode.8 index 1cc2b76..c9e4acf 100644 --- a/man/vpddecode.8 +++ b/man/vpddecode.8 @@ -1,12 +1,10 @@ .TH VPDDECODE 8 "February 2007" "dmidecode" -.\" .SH NAME vpddecode \- \s-1VPD\s0 structure decoder -.\" .SH SYNOPSIS .B vpddecode .RB [ OPTIONS ] -.\" + .SH DESCRIPTION .B vpddecode prints the "vital product data" information that can be found in almost @@ -19,17 +17,19 @@ Box Serial Number Motherboard Serial Number .IP \(bu Machine Type/Model + .PP Some systems have these additional items: .IP \(bu "\w'\(bu'u+1n" BIOS Release Date .IP \(bu Default Flash Image File Name + .PP Note that these additional items are not documented by IBM, so this is guess work, and as such should not be blindly trusted. Feedback about the accuracy of these labels is welcome. -.\" + .SH OPTIONS .TP .BR "-d" ", " "--dev-mem FILE" @@ -62,13 +62,11 @@ Display usage information and exit .TP .BR "-V" ", " "--version" Display the version and exit -.\" + .SH FILES .I /dev/mem -.\" .SH AUTHOR Jean Delvare -.\" .SH "SEE ALSO" .BR biosdecode (8), .BR dmidecode (8), diff --git a/util.c b/util.c index 04aaadd..eeffdae 100644 --- a/util.c +++ b/util.c @@ -155,18 +155,6 @@ out: return p; } -static void safe_memcpy(void *dest, const void *src, size_t n) -{ -#ifdef USE_SLOW_MEMCPY - size_t i; - - for (i = 0; i < n; i++) - *((u8 *)dest + i) = *((const u8 *)src + i); -#else - memcpy(dest, src, n); -#endif -} - /* * Copy a physical memory chunk into a memory buffer. * This function allocates memory. @@ -226,7 +214,7 @@ void *mem_chunk(off_t base, size_t len, const char *devmem) if (mmp == MAP_FAILED) goto try_read; - safe_memcpy(p, (u8 *)mmp + mmoffset, len); + memcpy(p, (u8 *)mmp + mmoffset, len); if (munmap(mmp, mmoffset + len) == -1) {