summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkhali <khali>2015-04-27 08:36:16 +0000
committerkhali <khali>2015-04-27 08:36:16 +0000
commita6e5b96b3ec62a0d27f3daa706e3554bebf39aff (patch)
treeaab2e0e6114fd61c3f3e4a2223e60219086ecc90
parent12864a3f3af38ee0ec71b9796bd10ee98b5d32dd (diff)
downloaddmidecode-a6e5b96b3ec62a0d27f3daa706e3554bebf39aff.tar.gz
dmidecode: Add support for 64-bit addresses
We can easily support 64-bit addresses by compiling dmidecode with -D_FILE_OFFSET_BITS=64. This looks reasonably portable. Also add support for 32-bit long tables, as SMBIOS 3.0.0 allows it, even though I don't expect to see such a long DMI table any time soon.
-rw-r--r--CHANGELOG5
-rw-r--r--Makefile6
-rw-r--r--dmidecode.c12
-rw-r--r--util.c6
-rw-r--r--util.h4
5 files changed, 20 insertions, 13 deletions
diff --git a/CHANGELOG b/CHANGELOG
index b992f74..35bfd10 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -2,8 +2,9 @@
Update to support SMBIOS specification version 3.0.0.
- * dmidecode.c: Add preliminary support for the new _SM3_ 64-bit
- entry point defined in the SMBIOS specification version 3.0.0.
+ * dmidecode.c: Add support for the new _SM3_ 64-bit entry point
+ defined in the SMBIOS specification version 3.0.0, including
+ support of 64-bit addresses and 32-bit table lengths.
* dmidecode.c: Add 3 new chassis types (DMI type 3).
* dmidecode.c: Add 4 new processor families (DMI type 4).
* dmidecode.c: Add 4 new Intel socket types (DMI type 4).
diff --git a/Makefile b/Makefile
index 66c24d5..1f54a1f 100644
--- a/Makefile
+++ b/Makefile
@@ -4,7 +4,7 @@
# VPD Decode
#
# Copyright (C) 2000-2002 Alan Cox <alan@redhat.com>
-# Copyright (C) 2002-2007 Jean Delvare <jdelvare@suse.de>
+# Copyright (C) 2002-2015 Jean Delvare <jdelvare@suse.de>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -15,6 +15,10 @@
CC = gcc
CFLAGS = -W -Wall -Wshadow -Wstrict-prototypes -Wpointer-arith -Wcast-qual \
-Wcast-align -Wwrite-strings -Wmissing-prototypes -Winline -Wundef
+
+# Let lseek and mmap support 64-bit wide offsets
+CFLAGS += -D_FILE_OFFSET_BITS=64
+
#CFLAGS += -DBIGENDIAN
#CFLAGS += -DALIGNMENT_WORKAROUND
diff --git a/dmidecode.c b/dmidecode.c
index 731026a..693e417 100644
--- a/dmidecode.c
+++ b/dmidecode.c
@@ -4356,7 +4356,7 @@ static void dmi_table_string(const struct dmi_header *h, const u8 *data, u16 ver
}
}
-static void dmi_table_dump(u32 base, u16 len, const char *devmem)
+static void dmi_table_dump(off_t base, u32 len, const char *devmem)
{
u8 *buf;
@@ -4372,7 +4372,7 @@ static void dmi_table_dump(u32 base, u16 len, const char *devmem)
free(buf);
}
-static void dmi_table(u32 base, u16 len, u16 num, u16 ver, const char *devmem,
+static void dmi_table(off_t base, u32 len, u16 num, u16 ver, const char *devmem,
u32 flags)
{
u8 *buf;
@@ -4400,7 +4400,8 @@ static void dmi_table(u32 base, u16 len, u16 num, u16 ver, const char *devmem,
printf("%u structures occupying %u bytes.\n",
num, len);
if (!(opt.flags & FLAG_FROM_DUMP))
- printf("Table at 0x%08X.\n", base);
+ printf("Table at 0x%08llX.\n",
+ (unsigned long long)base);
}
printf("\n");
}
@@ -4555,13 +4556,14 @@ static int smbios3_decode(u8 *buf, const char *devmem, u32 flags)
buf[0x07], buf[0x08], buf[0x09]);
offset = QWORD(buf + 0x10);
- if (!(flags & FLAG_NO_FILE_OFFSET) && offset.h)
+ if (!(flags & FLAG_NO_FILE_OFFSET) && offset.h && sizeof(off_t) < 8)
{
fprintf(stderr, "64-bit addresses not supported, sorry.\n");
return 0;
}
- dmi_table(offset.l, WORD(buf + 0x0C), 0, ver, devmem, flags);
+ dmi_table(((off_t)offset.h << 32) | offset.l,
+ WORD(buf + 0x0C), 0, ver, devmem, flags);
if (opt.flags & FLAG_DUMP_BIN)
{
diff --git a/util.c b/util.c
index c8ce365..026855a 100644
--- a/util.c
+++ b/util.c
@@ -2,7 +2,7 @@
* Common "util" functions
* This file is part of the dmidecode project.
*
- * Copyright (C) 2002-2010 Jean Delvare <jdelvare@suse.de>
+ * Copyright (C) 2002-2015 Jean Delvare <jdelvare@suse.de>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -147,12 +147,12 @@ void *read_file(size_t max_len, const char *filename)
* Copy a physical memory chunk into a memory buffer.
* This function allocates memory.
*/
-void *mem_chunk(size_t base, size_t len, const char *devmem)
+void *mem_chunk(off_t base, size_t len, const char *devmem)
{
void *p;
int fd;
#ifdef USE_MMAP
- size_t mmoffset;
+ off_t mmoffset;
void *mmp;
#endif
diff --git a/util.h b/util.h
index 2f0af51..9d409cd 100644
--- a/util.h
+++ b/util.h
@@ -1,7 +1,7 @@
/*
* This file is part of the dmidecode project.
*
- * Copyright (C) 2003-2010 Jean Delvare <jdelvare@suse.de>
+ * Copyright (C) 2003-2015 Jean Delvare <jdelvare@suse.de>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -26,6 +26,6 @@
int checksum(const u8 *buf, size_t len);
void *read_file(size_t len, const char *filename);
-void *mem_chunk(size_t base, size_t len, const char *devmem);
+void *mem_chunk(off_t base, size_t len, const char *devmem);
int write_dump(size_t base, size_t len, const void *data, const char *dumpfile, int add);
u64 u64_range(u64 start, u64 end);