summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CHANGELOG1
-rw-r--r--dmidecode.c41
-rw-r--r--man/dmidecode.810
3 files changed, 49 insertions, 3 deletions
diff --git a/CHANGELOG b/CHANGELOG
index c6830e9..1f30bcd 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -3,6 +3,7 @@
* util.c, util.h: Add utility function read_file, which reads an
entire binary file into a buffer.
* dmidecode.c: Add passing of flags parameter to dmi_table.
+ * dmidecode.c: Add reading of SMBIOS tables from sysfs.
2015-04-20 Jean Delvare <jdelvare@suse.de>
diff --git a/dmidecode.c b/dmidecode.c
index a781377..6cd59f4 100644
--- a/dmidecode.c
+++ b/dmidecode.c
@@ -73,6 +73,9 @@ static const char *bad_index = "<BAD INDEX>";
#define FLAG_NO_FILE_OFFSET (1 << 0)
+#define SYS_ENTRY_FILE "/sys/firmware/dmi/tables/smbios_entry_point"
+#define SYS_TABLE_FILE "/sys/firmware/dmi/tables/DMI"
+
/*
* Type-independant Stuff
*/
@@ -4669,7 +4672,38 @@ int main(int argc, char * const argv[])
goto done;
}
- /* First try EFI (ia64, Intel-based Mac) */
+ /*
+ * First try reading from sysfs tables. The entry point file could
+ * contain one of several types of entry points, so read enough for
+ * the largest one, then determine what type it contains.
+ */
+ if ((buf = read_file(0x20, SYS_ENTRY_FILE)) != NULL)
+ {
+ if (!(opt.flags & FLAG_QUIET))
+ printf("Getting SMBIOS data from sysfs.\n");
+ if (memcmp(buf, "_SM3_", 5) == 0)
+ {
+ if (!(opt.flags & FLAG_QUIET))
+ printf("SMBIOS v3 64-bit entry point found, but not supported.\n");
+ }
+ else if (memcmp(buf, "_SM_", 4) == 0)
+ {
+ if (smbios_decode(buf, SYS_TABLE_FILE, FLAG_NO_FILE_OFFSET))
+ found++;
+ }
+ else if (memcmp(buf, "_DMI_", 5) == 0)
+ {
+ if (legacy_decode(buf, SYS_TABLE_FILE, FLAG_NO_FILE_OFFSET))
+ found++;
+ }
+
+ if (found)
+ goto done;
+ if (!(opt.flags & FLAG_QUIET))
+ printf("Failed to get SMBIOS data from sysfs.\n");
+ }
+
+ /* Next try EFI (ia64, Intel-based Mac) */
efi = address_from_efi(&fp);
switch (efi)
{
@@ -4680,6 +4714,9 @@ int main(int argc, char * const argv[])
goto exit_free;
}
+ if (!(opt.flags & FLAG_QUIET))
+ 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;
@@ -4691,6 +4728,8 @@ int main(int argc, char * const argv[])
goto done;
memory_scan:
+ if (!(opt.flags & FLAG_QUIET))
+ 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)
{
diff --git a/man/dmidecode.8 b/man/dmidecode.8
index 1bb4c69..8b1c79b 100644
--- a/man/dmidecode.8
+++ b/man/dmidecode.8
@@ -25,8 +25,12 @@ and developed by the \s-1DMTF\s0 (Desktop Management Task Force).
As you run it,
.B dmidecode
-will try to locate the \s-1DMI\s0 table. If it succeeds, it will then parse
-this table and display a list of records like this one:
+will try to locate the \s-1DMI\s0 table. It will first try to read the DMI table
+from sysfs, and next try reading directly from memory if sysfs access failed.
+If
+.B dmidecode
+succeeds in locating a valid DMI table, it will then parse this table
+and display a list of records like this one:
Handle 0x0002, DMI type 2, 8 bytes.
Base Board Information
@@ -241,6 +245,8 @@ The DMI table is located at offset 0x20.
.SH FILES
.I /dev/mem
+.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.