|
|
3ea658 |
From db2e8e195c15ed0e56e6652c1b59fdd487d4fbb9 Mon Sep 17 00:00:00 2001
|
|
|
3ea658 |
From: Ivan Khoronzhuk <ivan.khoronzhuk@linaro.org>
|
|
|
3ea658 |
Date: Thu, 15 Jan 2015 01:14:43 +0200
|
|
|
3ea658 |
Subject: [PATCH 1/4] dmidecode: use common function to get SMBIOS version
|
|
|
3ea658 |
|
|
|
3ea658 |
Move SMBIOS version code in separate function as it's more readable
|
|
|
3ea658 |
and can be used by others when it's required.
|
|
|
3ea658 |
In paticular, it can be used when dmi sysfs support is added.
|
|
|
3ea658 |
|
|
|
3ea658 |
Signed-off-by: Ivan Khoronzhuk <ivan.khoronzhuk@linaro.org>
|
|
|
3ea658 |
---
|
|
|
3ea658 |
dmidecode.c | 59 +++++++++++++++++++++++++++++++++++++----------------------
|
|
|
3ea658 |
1 file changed, 37 insertions(+), 22 deletions(-)
|
|
|
3ea658 |
|
|
|
3ea658 |
diff --git a/dmidecode.c b/dmidecode.c
|
|
|
3ea658 |
index a5304a7..c4b4fd1 100644
|
|
|
3ea658 |
--- a/dmidecode.c
|
|
|
3ea658 |
+++ b/dmidecode.c
|
|
|
3ea658 |
@@ -4266,6 +4266,42 @@ static void dmi_decode(const struct dmi_header *h, u16 ver)
|
|
|
3ea658 |
printf("\n");
|
|
|
3ea658 |
}
|
|
|
3ea658 |
|
|
|
3ea658 |
+/**
|
|
|
3ea658 |
+ * get_smbios_version - get SMBIOS version
|
|
|
3ea658 |
+ * @smbios: pointer on SMBIOS entry point table
|
|
|
3ea658 |
+ *
|
|
|
3ea658 |
+ * Returns SMBIOS version
|
|
|
3ea658 |
+ */
|
|
|
3ea658 |
+static u16 get_smbios_version(unsigned char *smbios)
|
|
|
3ea658 |
+{
|
|
|
3ea658 |
+ u16 ver;
|
|
|
3ea658 |
+
|
|
|
3ea658 |
+ ver = (smbios[0x06] << 8) + smbios[0x07];
|
|
|
3ea658 |
+
|
|
|
3ea658 |
+ /* Some BIOS report weird SMBIOS version, fix that up */
|
|
|
3ea658 |
+ switch (ver) {
|
|
|
3ea658 |
+ case 0x021F:
|
|
|
3ea658 |
+ case 0x0221:
|
|
|
3ea658 |
+ if (!(opt.flags & FLAG_QUIET))
|
|
|
3ea658 |
+ printf("SMBIOS version fixup (2.%d -> 2.%d).\n",
|
|
|
3ea658 |
+ ver & 0xFF, 3);
|
|
|
3ea658 |
+ ver = 0x0203;
|
|
|
3ea658 |
+ break;
|
|
|
3ea658 |
+ case 0x0233:
|
|
|
3ea658 |
+ if (!(opt.flags & FLAG_QUIET))
|
|
|
3ea658 |
+ printf("SMBIOS version fixup (2.%d -> 2.%d).\n",
|
|
|
3ea658 |
+ 51, 6);
|
|
|
3ea658 |
+ ver = 0x0206;
|
|
|
3ea658 |
+ break;
|
|
|
3ea658 |
+ }
|
|
|
3ea658 |
+
|
|
|
3ea658 |
+ if (!(opt.flags & FLAG_QUIET))
|
|
|
3ea658 |
+ printf("SMBIOS %u.%u present.\n",
|
|
|
3ea658 |
+ ver >> 8, ver & 0xFF);
|
|
|
3ea658 |
+
|
|
|
3ea658 |
+ return ver;
|
|
|
3ea658 |
+}
|
|
|
3ea658 |
+
|
|
|
3ea658 |
static void to_dmi_header(struct dmi_header *h, u8 *data)
|
|
|
3ea658 |
{
|
|
|
3ea658 |
h->type = data[0];
|
|
|
3ea658 |
@@ -4442,7 +4478,6 @@ static void dmi_table(u32 base, u16 len, u16 num, u16 ver, const char *devmem)
|
|
|
3ea658 |
free(buf);
|
|
|
3ea658 |
}
|
|
|
3ea658 |
|
|
|
3ea658 |
-
|
|
|
3ea658 |
/*
|
|
|
3ea658 |
* Build a crafted entry point with table address hard-coded to 32,
|
|
|
3ea658 |
* as this is where we will put it in the output file. We adjust the
|
|
|
3ea658 |
@@ -4466,27 +4501,7 @@ static int smbios_decode(u8 *buf, const char *devmem)
|
|
|
3ea658 |
|| !checksum(buf + 0x10, 0x0F))
|
|
|
3ea658 |
return 0;
|
|
|
3ea658 |
|
|
|
3ea658 |
- ver = (buf[0x06] << 8) + buf[0x07];
|
|
|
3ea658 |
- /* Some BIOS report weird SMBIOS version, fix that up */
|
|
|
3ea658 |
- switch (ver)
|
|
|
3ea658 |
- {
|
|
|
3ea658 |
- case 0x021F:
|
|
|
3ea658 |
- case 0x0221:
|
|
|
3ea658 |
- if (!(opt.flags & FLAG_QUIET))
|
|
|
3ea658 |
- printf("SMBIOS version fixup (2.%d -> 2.%d).\n",
|
|
|
3ea658 |
- ver & 0xFF, 3);
|
|
|
3ea658 |
- ver = 0x0203;
|
|
|
3ea658 |
- break;
|
|
|
3ea658 |
- case 0x0233:
|
|
|
3ea658 |
- if (!(opt.flags & FLAG_QUIET))
|
|
|
3ea658 |
- printf("SMBIOS version fixup (2.%d -> 2.%d).\n",
|
|
|
3ea658 |
- 51, 6);
|
|
|
3ea658 |
- ver = 0x0206;
|
|
|
3ea658 |
- break;
|
|
|
3ea658 |
- }
|
|
|
3ea658 |
- if (!(opt.flags & FLAG_QUIET))
|
|
|
3ea658 |
- printf("SMBIOS %u.%u present.\n",
|
|
|
3ea658 |
- ver >> 8, ver & 0xFF);
|
|
|
3ea658 |
+ ver = get_smbios_version(buf);
|
|
|
3ea658 |
|
|
|
3ea658 |
dmi_table(DWORD(buf + 0x18), WORD(buf + 0x16), WORD(buf + 0x1C),
|
|
|
3ea658 |
ver, devmem);
|
|
|
3ea658 |
--
|
|
|
3ea658 |
1.9.3
|