aboutsummaryrefslogtreecommitdiff
path: root/util/intelmetool/mmap.c
diff options
context:
space:
mode:
authorPaul Menzel <paulepanter@users.sourceforge.net>2016-12-27 15:24:02 +0100
committerMartin Roth <martinroth@google.com>2016-12-28 17:25:56 +0100
commit1e7911e8aa830fcdf86cbb72671d79ea4c2c0e2a (patch)
treeb4f8e5fece79282226eaf3bfec0c8929c7bc7809 /util/intelmetool/mmap.c
parent010ecf800956f389bc34e09b968fe8934d4aa2ae (diff)
util/intelmetool: Fix warning building with 32-bit
On a 32-bit system, pointers are 32-bit wide, and not 64-bit, resulting in the warning below. ``` mmap.c: In function ‘map_physical_exact’: mmap.c:26:20: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast] virt_addr = mmap((void*)mapto, len, PROT_WRITE | PROT_READ, ^ ``` Fix this by using compatible types. Change-Id: I4ede26127efcbd5668b978e6880a0535607e373d Signed-off-by: Paul Menzel <paulepanter@users.sourceforge.net> Reviewed-on: https://review.coreboot.org/17970 Tested-by: build bot (Jenkins) Reviewed-by: Nico Huber <nico.h@gmx.de> Reviewed-by: Martin Roth <martinroth@google.com>
Diffstat (limited to 'util/intelmetool/mmap.c')
-rw-r--r--util/intelmetool/mmap.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/util/intelmetool/mmap.c b/util/intelmetool/mmap.c
index da36eaac08..041aac9c81 100644
--- a/util/intelmetool/mmap.c
+++ b/util/intelmetool/mmap.c
@@ -19,33 +19,33 @@
#ifndef __DARWIN__
int fd_mem;
-void *map_physical_exact(uint64_t phys_addr, uint64_t mapto, size_t len) {
+void *map_physical_exact(off_t phys_addr, void *mapto, size_t len) {
void *virt_addr;
int err;
- virt_addr = mmap((void*)mapto, len, PROT_WRITE | PROT_READ,
- MAP_SHARED | MAP_FIXED, fd_mem, (off_t) phys_addr);
+ virt_addr = mmap(mapto, len, PROT_WRITE | PROT_READ,
+ MAP_SHARED | MAP_FIXED, fd_mem, phys_addr);
if (virt_addr == MAP_FAILED) {
err = errno;
- printf("Error mapping physical memory 0x%016" PRIx64 "[0x%zx] ERRNO=%d\n",
- phys_addr, len, err);
+ printf("Error mapping physical memory 0x%016jd [0x%zx] ERRNO=%d\n",
+ (intmax_t)phys_addr, len, err);
return NULL;
}
return virt_addr;
}
-void *map_physical(uint64_t phys_addr, size_t len) {
+void *map_physical(off_t phys_addr, size_t len) {
void *virt_addr;
int err;
- virt_addr = mmap(NULL, len, PROT_WRITE | PROT_READ, MAP_SHARED, fd_mem, (off_t) phys_addr);
+ virt_addr = mmap(NULL, len, PROT_WRITE | PROT_READ, MAP_SHARED, fd_mem, phys_addr);
if (virt_addr == MAP_FAILED) {
err = errno;
- printf("Error mapping physical memory 0x%016" PRIx64 "[0x%zx] ERRNO=%d\n",
- phys_addr, len, err);
+ printf("Error mapping physical memory 0x%016jd [0x%zx] ERRNO=%d\n",
+ (intmax_t)phys_addr, len, err);
return NULL;
}