|
|
3ea658 |
From d4a148740afb211dc519945a8fc8b5eaa0adf280 Mon Sep 17 00:00:00 2001
|
|
|
3ea658 |
From: Ivan Khoronzhuk <ivan.khoronzhuk@linaro.org>
|
|
|
3ea658 |
Date: Thu, 15 Jan 2015 02:28:22 +0200
|
|
|
3ea658 |
Subject: [PATCH 2/4] dmidecode: use common function to put SMBIOS in dumpfile
|
|
|
3ea658 |
|
|
|
3ea658 |
It's needed in order to generalize code before adding dmi sysfs
|
|
|
3ea658 |
support. It' more convenient to hold common code in separate function.
|
|
|
3ea658 |
|
|
|
3ea658 |
Signed-off-by: Ivan Khoronzhuk <ivan.khoronzhuk@linaro.org>
|
|
|
3ea658 |
---
|
|
|
3ea658 |
dmidecode.c | 30 +++++++++++++++++++-----------
|
|
|
3ea658 |
1 file changed, 19 insertions(+), 11 deletions(-)
|
|
|
3ea658 |
|
|
|
3ea658 |
diff --git a/dmidecode.c b/dmidecode.c
|
|
|
3ea658 |
index c4b4fd1..4e4a82f 100644
|
|
|
3ea658 |
--- a/dmidecode.c
|
|
|
3ea658 |
+++ b/dmidecode.c
|
|
|
3ea658 |
@@ -4492,6 +4492,24 @@ static void overwrite_dmi_address(u8 *buf)
|
|
|
3ea658 |
buf[0x0B] = 0;
|
|
|
3ea658 |
}
|
|
|
3ea658 |
|
|
|
3ea658 |
+/**
|
|
|
3ea658 |
+ * smbios_in_dumpfile - put SMBIOS entry table in dump file
|
|
|
3ea658 |
+ * @smbios: pointer on SMBIOS entry table
|
|
|
3ea658 |
+ */
|
|
|
3ea658 |
+static void smbios_in_dumpfile(unsigned char *smbios)
|
|
|
3ea658 |
+{
|
|
|
3ea658 |
+ u8 crafted[32];
|
|
|
3ea658 |
+
|
|
|
3ea658 |
+ memcpy(crafted, smbios, 32);
|
|
|
3ea658 |
+ overwrite_dmi_address(crafted + 0x10);
|
|
|
3ea658 |
+
|
|
|
3ea658 |
+ if (!(opt.flags & FLAG_QUIET))
|
|
|
3ea658 |
+ printf("# Writing %d bytes to %s.\n", crafted[0x05],
|
|
|
3ea658 |
+ opt.dumpfile);
|
|
|
3ea658 |
+
|
|
|
3ea658 |
+ write_dump(0, crafted[0x05], crafted, opt.dumpfile, 1);
|
|
|
3ea658 |
+}
|
|
|
3ea658 |
+
|
|
|
3ea658 |
static int smbios_decode(u8 *buf, const char *devmem)
|
|
|
3ea658 |
{
|
|
|
3ea658 |
u16 ver;
|
|
|
3ea658 |
@@ -4507,17 +4525,7 @@ static int smbios_decode(u8 *buf, const char *devmem)
|
|
|
3ea658 |
ver, devmem);
|
|
|
3ea658 |
|
|
|
3ea658 |
if (opt.flags & FLAG_DUMP_BIN)
|
|
|
3ea658 |
- {
|
|
|
3ea658 |
- u8 crafted[32];
|
|
|
3ea658 |
-
|
|
|
3ea658 |
- memcpy(crafted, buf, 32);
|
|
|
3ea658 |
- overwrite_dmi_address(crafted + 0x10);
|
|
|
3ea658 |
-
|
|
|
3ea658 |
- if (!(opt.flags & FLAG_QUIET))
|
|
|
3ea658 |
- printf("# Writing %d bytes to %s.\n", crafted[0x05],
|
|
|
3ea658 |
- opt.dumpfile);
|
|
|
3ea658 |
- write_dump(0, crafted[0x05], crafted, opt.dumpfile, 1);
|
|
|
3ea658 |
- }
|
|
|
3ea658 |
+ smbios_in_dumpfile(buf);
|
|
|
3ea658 |
|
|
|
3ea658 |
return 1;
|
|
|
3ea658 |
}
|
|
|
3ea658 |
--
|
|
|
3ea658 |
1.9.3
|