dmidecode-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[dmidecode] [Patch 4/4] dmidecode: add dmi sysfs support


From: Ivan Khoronzhuk
Subject: [dmidecode] [Patch 4/4] dmidecode: add dmi sysfs support
Date: Thu, 29 Jan 2015 18:50:12 +0200

In cases when access to /dev/mem is forbidden the dmi sysfs can
be used. This patch adds dmi sysfs support.

To add support of dmi sysfs the newly introduced dmifs library were
used - libdmifs. Currently it's situated at
https://git.linaro.org/people/ivan.khoronzhuk/libdmifs.git

The library is needed to simplify working with DMI sysfs.

Reported-by: Leif Lindholm <address@hidden>
Signed-off-by: Ivan Khoronzhuk <address@hidden>
---
 Makefile    |  2 +-
 dmidecode.c | 31 ++++++++++++++++++++++++++++++-
 version.h   |  2 +-
 3 files changed, 32 insertions(+), 3 deletions(-)

diff --git a/Makefile b/Makefile
index 66c24d5..e3f5c49 100644
--- a/Makefile
+++ b/Makefile
@@ -58,7 +58,7 @@ all : $(PROGRAMS)
 #
 
 dmidecode : dmidecode.o dmiopt.o dmioem.o util.o
-       $(CC) $(LDFLAGS) dmidecode.o dmiopt.o dmioem.o util.o -o $@
+       $(CC) $(LDFLAGS) dmidecode.o dmiopt.o dmioem.o util.o -ldmifs -o $@
 
 biosdecode : biosdecode.o util.o
        $(CC) $(LDFLAGS) biosdecode.o util.o -o $@
diff --git a/dmidecode.c b/dmidecode.c
index 2fedddc..7d3c133 100644
--- a/dmidecode.c
+++ b/dmidecode.c
@@ -57,6 +57,7 @@
 #include <strings.h>
 #include <stdlib.h>
 #include <unistd.h>
+#include <libdmifs.h>
 
 #include "version.h"
 #include "config.h"
@@ -4535,6 +4536,28 @@ static int smbios_decode(u8 *buf, const char *devmem)
        return 1;
 }
 
+static void dmifs_smbios_decode(void)
+{
+       u16 ver;
+       u8 *smbios;
+       struct dmi_table *dt;
+
+       dt = dmi_get_table();
+       if (!dt)
+               return;
+
+       smbios = dt->smbios;
+
+       ver = get_smbios_version(dt->smbios);
+       dmi_table(DWORD(smbios + 0x18), dmi_get_raw_data(dt->dmi_list),
+                 WORD(smbios + 0x16), WORD(smbios + 0x1C), ver);
+
+       if (opt.flags & FLAG_DUMP_BIN)
+               smbios_in_dumpfile(dt->smbios);
+
+       dmi_put_table(dt);
+}
+
 static int legacy_decode(u8 *buf, const char *devmem)
 {
        u16 len;
@@ -4692,7 +4715,13 @@ int main(int argc, char * const argv[])
                goto done;
        }
 
-       /* First try EFI (ia64, Intel-based Mac) */
+       /* First try dmi sysfs */
+       if (dmifs_is_exist()) {
+               dmifs_smbios_decode();
+               goto exit_free;
+       }
+
+       /* Second try EFI (ia64, Intel-based Mac) */
        efi = address_from_efi(&fp);
        switch (efi)
        {
diff --git a/version.h b/version.h
index 140d334..ce7ffaf 100644
--- a/version.h
+++ b/version.h
@@ -1 +1 @@
-#define VERSION "2.12"
+#define VERSION "2.12-dmifs"
-- 
1.9.1




reply via email to

[Prev in Thread] Current Thread [Next in Thread]