|
|
4f8197 |
From 1bd45ec19f7a2d4cdc293b7a5e705c6ee793953e Mon Sep 17 00:00:00 2001
|
|
|
4f8197 |
From: Ivan Khoronzhuk <ivan.khoronzhuk@linaro.org>
|
|
|
4f8197 |
Date: Thu, 15 Jan 2015 03:01:37 +0200
|
|
|
4f8197 |
Subject: [PATCH 4/4] dmidecode: add dmi sysfs support
|
|
|
4f8197 |
|
|
|
4f8197 |
For working with newly introduced dmi sysfs the dmifs library
|
|
|
4f8197 |
was used. It's needed by the systems that cannot use /dev/mem to
|
|
|
4f8197 |
access hardware addresses and as result cannot read dmi table.
|
|
|
4f8197 |
So another, more correct approach, can be used, it's to read
|
|
|
4f8197 |
information from dmi sysfs.
|
|
|
4f8197 |
|
|
|
4f8197 |
Currently we can use libdmifs library for that.
|
|
|
4f8197 |
|
|
|
4f8197 |
Reported-by: Leif Lindholm <leif.lindholm@linaro.org>
|
|
|
4f8197 |
Signed-off-by: Ivan Khoronzhuk <ivan.khoronzhuk@linaro.org>
|
|
|
4f8197 |
---
|
|
|
4f8197 |
Makefile | 2 +-
|
|
|
4f8197 |
dmidecode.c | 31 ++++++++++++++++++++++++++++++-
|
|
|
4f8197 |
version.h | 2 +-
|
|
|
4f8197 |
3 files changed, 32 insertions(+), 3 deletions(-)
|
|
|
4f8197 |
|
|
|
4f8197 |
diff --git a/Makefile b/Makefile
|
|
|
4f8197 |
index 66c24d5..e3f5c49 100644
|
|
|
4f8197 |
--- a/Makefile
|
|
|
4f8197 |
+++ b/Makefile
|
|
|
4f8197 |
@@ -58,7 +58,7 @@ all : $(PROGRAMS)
|
|
|
4f8197 |
#
|
|
|
4f8197 |
|
|
|
4f8197 |
dmidecode : dmidecode.o dmiopt.o dmioem.o util.o
|
|
|
4f8197 |
- $(CC) $(LDFLAGS) dmidecode.o dmiopt.o dmioem.o util.o -o $@
|
|
|
4f8197 |
+ $(CC) $(LDFLAGS) dmidecode.o dmiopt.o dmioem.o util.o -ldmifs -o $@
|
|
|
4f8197 |
|
|
|
4f8197 |
biosdecode : biosdecode.o util.o
|
|
|
4f8197 |
$(CC) $(LDFLAGS) biosdecode.o util.o -o $@
|
|
|
4f8197 |
diff --git a/dmidecode.c b/dmidecode.c
|
|
|
4f8197 |
index 2fedddc..7d3c133 100644
|
|
|
4f8197 |
--- a/dmidecode.c
|
|
|
4f8197 |
+++ b/dmidecode.c
|
|
|
4f8197 |
@@ -57,6 +57,7 @@
|
|
|
4f8197 |
#include <strings.h>
|
|
|
4f8197 |
#include <stdlib.h>
|
|
|
4f8197 |
#include <unistd.h>
|
|
|
4f8197 |
+#include <libdmifs.h>
|
|
|
4f8197 |
|
|
|
4f8197 |
#include "version.h"
|
|
|
4f8197 |
#include "config.h"
|
|
|
4f8197 |
@@ -4535,6 +4536,28 @@ static int smbios_decode(u8 *buf, const char *devmem)
|
|
|
4f8197 |
return 1;
|
|
|
4f8197 |
}
|
|
|
4f8197 |
|
|
|
4f8197 |
+static void dmifs_smbios_decode(void)
|
|
|
4f8197 |
+{
|
|
|
4f8197 |
+ u16 ver;
|
|
|
4f8197 |
+ u8 *smbios;
|
|
|
4f8197 |
+ struct dmi_table *dt;
|
|
|
4f8197 |
+
|
|
|
4f8197 |
+ dt = dmi_get_table();
|
|
|
4f8197 |
+ if (!dt)
|
|
|
4f8197 |
+ return;
|
|
|
4f8197 |
+
|
|
|
4f8197 |
+ smbios = dt->smbios;
|
|
|
4f8197 |
+
|
|
|
4f8197 |
+ ver = get_smbios_version(dt->smbios);
|
|
|
4f8197 |
+ dmi_table(DWORD(smbios + 0x18), dmi_get_raw_data(dt->dmi_list),
|
|
|
4f8197 |
+ WORD(smbios + 0x16), WORD(smbios + 0x1C), ver);
|
|
|
4f8197 |
+
|
|
|
4f8197 |
+ if (opt.flags & FLAG_DUMP_BIN)
|
|
|
4f8197 |
+ smbios_in_dumpfile(dt->smbios);
|
|
|
4f8197 |
+
|
|
|
4f8197 |
+ dmi_put_table(dt);
|
|
|
4f8197 |
+}
|
|
|
4f8197 |
+
|
|
|
4f8197 |
static int legacy_decode(u8 *buf, const char *devmem)
|
|
|
4f8197 |
{
|
|
|
4f8197 |
u16 len;
|
|
|
4f8197 |
@@ -4692,7 +4715,13 @@ int main(int argc, char * const argv[])
|
|
|
4f8197 |
goto done;
|
|
|
4f8197 |
}
|
|
|
4f8197 |
|
|
|
4f8197 |
- /* First try EFI (ia64, Intel-based Mac) */
|
|
|
4f8197 |
+ /* First try dmi sysfs */
|
|
|
4f8197 |
+ if (dmifs_is_exist()) {
|
|
|
4f8197 |
+ dmifs_smbios_decode();
|
|
|
4f8197 |
+ goto exit_free;
|
|
|
4f8197 |
+ }
|
|
|
4f8197 |
+
|
|
|
4f8197 |
+ /* Second try EFI (ia64, Intel-based Mac) */
|
|
|
4f8197 |
efi = address_from_efi(&fp);
|
|
|
4f8197 |
switch (efi)
|
|
|
4f8197 |
{
|
|
|
4f8197 |
diff --git a/version.h b/version.h
|
|
|
4f8197 |
index 140d334..ce7ffaf 100644
|
|
|
4f8197 |
--- a/version.h
|
|
|
4f8197 |
+++ b/version.h
|
|
|
4f8197 |
@@ -1 +1 @@
|
|
|
4f8197 |
-#define VERSION "2.12"
|
|
|
4f8197 |
+#define VERSION "2.12-dmifs"
|
|
|
4f8197 |
--
|
|
|
4f8197 |
1.9.3
|
|
|
4f8197 |
|