[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[dmidecode] [PATCH 4/5] dmidecode: Add support for 64-bit addresses
From: |
Jean Delvare |
Subject: |
[dmidecode] [PATCH 4/5] dmidecode: Add support for 64-bit addresses |
Date: |
Tue, 21 Apr 2015 11:58:56 +0200 |
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.
---
Makefile | 6 +++++-
dmidecode.c | 13 +++++++------
util.c | 6 +++---
util.h | 4 ++--
4 files changed, 17 insertions(+), 12 deletions(-)
--- dmidecode.orig/util.h 2015-04-21 11:56:40.011403928 +0200
+++ dmidecode/util.h 2015-04-21 11:57:55.605993665 +0200
@@ -1,7 +1,7 @@
/*
* This file is part of the dmidecode project.
*
- * Copyright (C) 2003-2010 Jean Delvare <address@hidden>
+ * Copyright (C) 2003-2015 Jean Delvare <address@hidden>
*
* 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);
--- dmidecode.orig/util.c 2015-04-21 11:56:40.011403928 +0200
+++ dmidecode/util.c 2015-04-21 11:57:58.837061619 +0200
@@ -2,7 +2,7 @@
* Common "util" functions
* This file is part of the dmidecode project.
*
- * Copyright (C) 2002-2010 Jean Delvare <address@hidden>
+ * Copyright (C) 2002-2015 Jean Delvare <address@hidden>
*
* 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 ch
* 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
--- dmidecode.orig/dmidecode.c 2015-04-21 11:56:43.789483374 +0200
+++ dmidecode/dmidecode.c 2015-04-21 11:57:43.236733524 +0200
@@ -4356,7 +4356,7 @@ static void dmi_table_string(const struc
}
}
-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
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,
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,13 @@ static int smbios3_decode(u8 *buf, const
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)
{
--- dmidecode.orig/Makefile 2015-04-21 11:56:40.011403928 +0200
+++ dmidecode/Makefile 2015-04-21 11:58:04.233175109 +0200
@@ -4,7 +4,7 @@
# VPD Decode
#
# Copyright (C) 2000-2002 Alan Cox <address@hidden>
-# Copyright (C) 2002-2007 Jean Delvare <address@hidden>
+# Copyright (C) 2002-2015 Jean Delvare <address@hidden>
#
# 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
--
Jean Delvare
SUSE L3 Support