Am 10.07.2013 21:17 schrieb Stefan Tauner:
unsigned long is not the right type for manipulating pointer values. Since C99 there are suitable unsigned and signed types available, namely uintptr_t and intptr_t respectively.
Use them in physmap.c and its callers where applicable.
This patch also changes the display width of all address values in physmap.c to 16/8 hex characters depending on the actual size.
Signed-off-by: Stefan Tauner stefan.tauner@student.tuwien.ac.at
Why don't you use PRIxPTR_WIDTH everywhere including dummyflasher.c? Put another way, is there a reason to use PRIxPTR_WIDTH at all? Do we care that C99 doesn't guarantee a 0x prefix for printed addresses with PRIxPTR? Will that cause confusion?
I think PRIxPTR is a good idea, but I'm not so sure about the side effects.
There's also the problem of programmer_map_flash_region. It should not take an uintptr_t. The address parameter is a horrible mess: A physical address from the CPU point of view for the internal programmer, a top-of-4-GB aligned fake address for some other programmers, and a bottom-aligned address for the rest of our programmers. If we want to do this the right way, we need to have a wrapper for physmap in the "internal" programmer case instead of setting map_flash_region = physmap. And then I need to update my patch which abstracts the flash bus address vs programmer address conflict into something that won't cause madness.
dummyflasher.c | 4 ++-- flash.h | 3 +-- flashrom.c | 3 +-- physmap.c | 36 +++++++++++++++++++----------------- programmer.c | 2 +- programmer.h | 10 +++++----- 6 files changed, 29 insertions(+), 29 deletions(-)
diff --git a/dummyflasher.c b/dummyflasher.c index e2ec036..8e861ee 100644 --- a/dummyflasher.c +++ b/dummyflasher.c @@ -412,9 +412,9 @@ dummy_init_out: return 0; }
-void *dummy_map(const char *descr, unsigned long phys_addr, size_t len) +void *dummy_map(const char *descr, uintptr_t phys_addr, size_t len) {
- msg_pspew("%s: Mapping %s, 0x%lx bytes at 0x%08lx\n",
- msg_pspew("%s: Mapping %s, 0x%lx bytes at 0x%08" PRIxPTR "\n", __func__, descr, (unsigned long)len, phys_addr); return (void *)phys_addr;
} diff --git a/flash.h b/flash.h index 9e787c0..a752d6b 100644 --- a/flash.h +++ b/flash.h @@ -45,8 +45,7 @@ typedef uintptr_t chipaddr;
int register_shutdown(int (*function) (void *data), void *data); -void *programmer_map_flash_region(const char *descr, unsigned long phys_addr,
size_t len);
+void *programmer_map_flash_region(const char *descr, uintptr_t phys_addr, size_t len); void programmer_unmap_flash_region(void *virt_addr, size_t len); void programmer_delay(int usecs);
diff --git a/flashrom.c b/flashrom.c index c298748..43b7b11 100644 --- a/flashrom.c +++ b/flashrom.c @@ -417,8 +417,7 @@ int programmer_shutdown(void) return ret; }
-void *programmer_map_flash_region(const char *descr, unsigned long phys_addr,
size_t len)
+void *programmer_map_flash_region(const char *descr, uintptr_t phys_addr, size_t len) { return programmer_table[programmer].map_flash_region(descr, phys_addr, len); diff --git a/physmap.c b/physmap.c index 644ee35..8be4f06 100644 --- a/physmap.c +++ b/physmap.c @@ -20,6 +20,7 @@
- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
+#include <inttypes.h> #include <unistd.h> #include <stdio.h> #include <stdlib.h> @@ -34,6 +35,8 @@ #include <fcntl.h> #endif
+#define PRIxPTR_WIDTH ((int)(sizeof(uintptr_t)*2))
#ifdef __DJGPP__ #include <dpmi.h> #include <sys/nearptr.h> @@ -42,7 +45,7 @@
static void *realmem_map;
-static void *map_first_meg(unsigned long phys_addr, size_t len) +static void *map_first_meg(uintptr_t phys_addr, size_t len) { if (realmem_map) return realmem_map + phys_addr; @@ -61,7 +64,7 @@ static void *map_first_meg(unsigned long phys_addr, size_t len) return realmem_map + phys_addr; }
-static void *sys_physmap(unsigned long phys_addr, size_t len) +static void *sys_physmap(uintptr_t phys_addr, size_t len) { int ret; __dpmi_meminfo mi; @@ -109,7 +112,7 @@ void physunmap(void *virt_addr, size_t len)
#define MEM_DEV ""
-void *sys_physmap(unsigned long phys_addr, size_t len) +void *sys_physmap(uintptr_t phys_addr, size_t len) { return (void *)phys_to_virt(phys_addr); } @@ -124,7 +127,7 @@ void physunmap(void *virt_addr, size_t len)
#define MEM_DEV "DirectHW"
-static void *sys_physmap(unsigned long phys_addr, size_t len) +static void *sys_physmap(uintptr_t phys_addr, size_t len) { /* The short form of ?: is a GNU extension. * FIXME: map_physical returns NULL both for errors and for success @@ -156,7 +159,7 @@ static int fd_mem = -1; static int fd_mem_cached = -1;
/* For MMIO access. Must be uncached, doesn't make sense to restrict to ro. */ -static void *sys_physmap_rw_uncached(unsigned long phys_addr, size_t len) +static void *sys_physmap_rw_uncached(uintptr_t phys_addr, size_t len) { void *virt_addr;
@@ -176,7 +179,7 @@ static void *sys_physmap_rw_uncached(unsigned long phys_addr, size_t len) /* For reading DMI/coreboot/whatever tables. We should never write, and we
- do not care about caching.
*/ -static void *sys_physmap_ro_cached(unsigned long phys_addr, size_t len) +static void *sys_physmap_ro_cached(uintptr_t phys_addr, size_t len) { void *virt_addr;
@@ -209,25 +212,24 @@ void physunmap(void *virt_addr, size_t len) #define PHYSMAP_RW 0 #define PHYSMAP_RO 1
-static void *physmap_common(const char *descr, unsigned long phys_addr, +static void *physmap_common(const char *descr, uintptr_t phys_addr, size_t len, int mayfail, int readonly) { void *virt_addr;
if (len == 0) {
msg_pspew("Not mapping %s, zero size at 0x%08lx.\n",
descr, phys_addr);
msg_pspew("Not mapping %s, zero size at 0x%0*" PRIxPTR ".\n", descr, PRIxPTR_WIDTH, phys_addr);
return ERROR_PTR; }
if ((getpagesize() - 1) & len) {
msg_perr("Mapping %s at 0x%08lx, unaligned size 0x%lx.\n",
descr, phys_addr, (unsigned long)len);
msg_perr("Mapping %s at 0x%0*" PRIxPTR ", unaligned size 0x%lx.\n",
descr, PRIxPTR_WIDTH, phys_addr, (unsigned long)len);
}
if ((getpagesize() - 1) & phys_addr) {
msg_perr("Mapping %s, 0x%lx bytes at unaligned 0x%08lx.\n",
descr, (unsigned long)len, phys_addr);
msg_perr("Mapping %s, 0x%lx bytes at unaligned 0x%0*" PRIxPTR ".\n",
descr, (unsigned long)len, PRIxPTR_WIDTH, phys_addr);
}
if (readonly)
@@ -238,8 +240,8 @@ static void *physmap_common(const char *descr, unsigned long phys_addr, if (ERROR_PTR == virt_addr) { if (NULL == descr) descr = "memory";
msg_perr("Error accessing %s, 0x%lx bytes at 0x%08lx\n", descr,
(unsigned long)len, phys_addr);
msg_perr("Error accessing %s, 0x%0zx bytes at 0x%0*" PRIxPTR "\n",
msg_perr(MEM_DEV " mmap failed: %s\n", strerror(errno));descr, len, PRIxPTR_WIDTH, phys_addr);
#ifdef __linux__ if (EINVAL == errno) { @@ -261,13 +263,13 @@ static void *physmap_common(const char *descr, unsigned long phys_addr, return virt_addr; }
-void *physmap(const char *descr, unsigned long phys_addr, size_t len) +void *physmap(const char *descr, uintptr_t phys_addr, size_t len) { return physmap_common(descr, phys_addr, len, PHYSMAP_NOFAIL, PHYSMAP_RW); }
-void *physmap_try_ro(const char *descr, unsigned long phys_addr, size_t len) +void *physmap_try_ro(const char *descr, uintptr_t phys_addr, size_t len) { return physmap_common(descr, phys_addr, len, PHYSMAP_MAYFAIL, PHYSMAP_RO); diff --git a/programmer.c b/programmer.c index 3b4def0..bf7dca1 100644 --- a/programmer.c +++ b/programmer.c @@ -28,7 +28,7 @@ int noop_shutdown(void) }
/* Fallback map() for programmers which don't need special handling */ -void *fallback_map(const char *descr, unsigned long phys_addr, size_t len) +void *fallback_map(const char *descr, uintptr_t phys_addr, size_t len) { /* FIXME: Should return phys_addr. */ return NULL; diff --git a/programmer.h b/programmer.h index 7de8f2c..4ed7c90 100644 --- a/programmer.h +++ b/programmer.h @@ -117,7 +117,7 @@ struct programmer_entry {
int (*init) (void);
- void *(*map_flash_region) (const char *descr, unsigned long phys_addr, size_t len);
void *(*map_flash_region) (const char *descr, uintptr_t phys_addr, size_t len); void (*unmap_flash_region) (void *virt_addr, size_t len);
void (*delay) (int usecs);
@@ -275,8 +275,8 @@ int processor_flash_enable(void); #endif
/* physmap.c */ -void *physmap(const char *descr, unsigned long phys_addr, size_t len); -void *physmap_try_ro(const char *descr, unsigned long phys_addr, size_t len); +void *physmap(const char *descr, uintptr_t phys_addr, size_t len); +void *physmap_try_ro(const char *descr, uintptr_t phys_addr, size_t len); void physunmap(void *virt_addr, size_t len); #if CONFIG_INTERNAL == 1 int setup_cpu_msr(int cpu); @@ -359,7 +359,7 @@ void rmmio_vall(void *addr); /* dummyflasher.c */ #if CONFIG_DUMMY == 1 int dummy_init(void); -void *dummy_map(const char *descr, unsigned long phys_addr, size_t len); +void *dummy_map(const char *descr, uintptr_t phys_addr, size_t len); void dummy_unmap(void *virt_addr, size_t len); #endif
@@ -609,7 +609,7 @@ int register_opaque_programmer(const struct opaque_programmer *pgm);
/* programmer.c */ int noop_shutdown(void); -void *fallback_map(const char *descr, unsigned long phys_addr, size_t len); +void *fallback_map(const char *descr, uintptr_t phys_addr, size_t len); void fallback_unmap(void *virt_addr, size_t len); void noop_chip_writeb(const struct flashctx *flash, uint8_t val, chipaddr addr); void fallback_chip_writew(const struct flashctx *flash, uint16_t val, chipaddr addr);
Overall, while I'd like to have this patch in, it conceptually breaks as much stuff as it fixes. I don't see this getting fixed within the release timeframe, so I'd like to postpone.
Regards, Carl-Daniel
On Mon, 15 Jul 2013 10:20:29 +0200 Carl-Daniel Hailfinger c-d.hailfinger.devel.2006@gmx.net wrote:
Am 10.07.2013 21:17 schrieb Stefan Tauner:
unsigned long is not the right type for manipulating pointer values. Since C99 there are suitable unsigned and signed types available, namely uintptr_t and intptr_t respectively.
Use them in physmap.c and its callers where applicable.
This patch also changes the display width of all address values in physmap.c to 16/8 hex characters depending on the actual size.
Signed-off-by: Stefan Tauner stefan.tauner@student.tuwien.ac.at
Why don't you use PRIxPTR_WIDTH everywhere including dummyflasher.c?
That's a bug AFAICS, thanks.
Put another way, is there a reason to use PRIxPTR_WIDTH at all? Do we care that C99 doesn't guarantee a 0x prefix for printed addresses with PRIxPTR? Will that cause confusion?
The main point of it is to get nicely aligned/readable addresses that are padded to the right(tm) size, and yes I guess the guaranteed 0x prefix too (I can't remember TBH :).
I think PRIxPTR is a good idea, but I'm not so sure about the side effects.
There's also the problem of programmer_map_flash_region. It should not take an uintptr_t. The address parameter is a horrible mess: A physical address from the CPU point of view for the internal programmer, a top-of-4-GB aligned fake address for some other programmers, and a bottom-aligned address for the rest of our programmers. If we want to do this the right way, we need to have a wrapper for physmap in the "internal" programmer case instead of setting map_flash_region = physmap. And then I need to update my patch which abstracts the flash bus address vs programmer address conflict into something that won't cause madness.
Hm, I need to look into this again. Using a union for the type and a wrapper does not sound so bad to me (without looking at the code :) This could at least be made platform-independent without jumping through hoops.
Overall, while I'd like to have this patch in, it conceptually breaks as much stuff as it fixes. I don't see this getting fixed within the release timeframe, so I'd like to postpone.
Fine with me, but this means no win64 support in this stable.
Am 15.07.2013 22:49 schrieb Stefan Tauner:
On Mon, 15 Jul 2013 10:20:29 +0200 Carl-Daniel Hailfinger c-d.hailfinger.devel.2006@gmx.net wrote:
Am 10.07.2013 21:17 schrieb Stefan Tauner:
unsigned long is not the right type for manipulating pointer values. Since C99 there are suitable unsigned and signed types available, namely uintptr_t and intptr_t respectively.
Use them in physmap.c and its callers where applicable.
This patch also changes the display width of all address values in physmap.c to 16/8 hex characters depending on the actual size.
Signed-off-by: Stefan Tauner stefan.tauner@student.tuwien.ac.at
Why don't you use PRIxPTR_WIDTH everywhere including dummyflasher.c?
That's a bug AFAICS, thanks.
Put another way, is there a reason to use PRIxPTR_WIDTH at all?
IIRC the C99 standard says that PRIxPTR guarantees a canonical formatting. I'm guessing the canonical formatting means (for most platforms) that the printed pointers have constant width, i.e. the PRIxPTR_WIDTH specifier is superfluous. I would avoid that specifier unless shown a real-world case where PRIxPTR formatted pointers have variable length inside the same flashrom executable.
Do we care that C99 doesn't guarantee a 0x prefix for printed addresses with PRIxPTR? Will that cause confusion?
The main point of it is to get nicely aligned/readable addresses that are padded to the right(tm) size, and yes I guess the guaranteed 0x prefix too (I can't remember TBH :).
AFAIK the 0x prefix is not guaranteed, and it may even be missing on Windows. Someone would have to test (preferably not in Wine).
I think PRIxPTR is a good idea, but I'm not so sure about the side effects.
There's also the problem of programmer_map_flash_region. It should not take an uintptr_t. The address parameter is a horrible mess: A physical address from the CPU point of view for the internal programmer, a top-of-4-GB aligned fake address for some other programmers, and a bottom-aligned address for the rest of our programmers. If we want to do this the right way, we need to have a wrapper for physmap in the "internal" programmer case instead of setting map_flash_region = physmap. And then I need to update my patch which abstracts the flash bus address vs programmer address conflict into something that won't cause madness.
Hm, I need to look into this again. Using a union for the type and a wrapper does not sound so bad to me (without looking at the code :)
Not what I meant. Turns out that my proposal is unworkable anyway.
This could at least be made platform-independent without jumping through hoops.
Overall, while I'd like to have this patch in, it conceptually breaks as much stuff as it fixes. I don't see this getting fixed within the release timeframe, so I'd like to postpone.
Fine with me, but this means no win64 support in this stable.
Once the PRIxPTR_WIDTH stuff is consistent (preferably removed everywhere), this is: Acked-by: Carl-Daniel Hailfinger c-d.hailfinger.devel.2006@gmx.net
Sorry for my earlier Nack.
Regards, Carl-Daniel
Am 17.07.2013 00:04 schrieb Carl-Daniel Hailfinger:
Am 15.07.2013 22:49 schrieb Stefan Tauner:
On Mon, 15 Jul 2013 10:20:29 +0200 Carl-Daniel Hailfinger c-d.hailfinger.devel.2006@gmx.net wrote:
Am 10.07.2013 21:17 schrieb Stefan Tauner:
unsigned long is not the right type for manipulating pointer values. Since C99 there are suitable unsigned and signed types available, namely uintptr_t and intptr_t respectively.
Use them in physmap.c and its callers where applicable.
This patch also changes the display width of all address values in physmap.c to 16/8 hex characters depending on the actual size.
Signed-off-by: Stefan Tauner stefan.tauner@student.tuwien.ac.at
Why don't you use PRIxPTR_WIDTH everywhere including dummyflasher.c?
That's a bug AFAICS, thanks.
Put another way, is there a reason to use PRIxPTR_WIDTH at all?
IIRC the C99 standard says that PRIxPTR guarantees a canonical formatting. I'm guessing the canonical formatting means (for most platforms) that the printed pointers have constant width, i.e. the PRIxPTR_WIDTH specifier is superfluous. I would avoid that specifier unless shown a real-world case where PRIxPTR formatted pointers have variable length inside the same flashrom executable.
You have shown a real-world case: Linux. Thanks for checking this. In that light, PRIxPTR_WIDTH is essential.
Do we care that C99 doesn't guarantee a 0x prefix for printed addresses with PRIxPTR? Will that cause confusion?
The main point of it is to get nicely aligned/readable addresses that are padded to the right(tm) size, and yes I guess the guaranteed 0x prefix too (I can't remember TBH :).
AFAIK the 0x prefix is not guaranteed, and it may even be missing on Windows. Someone would have to test (preferably not in Wine).
In your test case, 0x was missing. Do we want to manually add a "0x" prefix or do we want to use the "#" modifier? If PRIxPTR is "p" or some variant of it, this might cause a problem because the "#" modifier is not listed as valid modifier for "p" in C99.
Once the PRIxPTR_WIDTH stuff is consistent (preferably removed everywhere), this is:
s/removed/included/
Acked-by: Carl-Daniel Hailfinger c-d.hailfinger.devel.2006@gmx.net
Regards, Carl-Daniel
unsigned long is not the right type for manipulating pointer values. Since C99 there are suitable unsigned and signed types available, namely uintptr_t and intptr_t respectively.
Use them in functions assigned to programmers' map_flash_region fields and their callers where applicable.
This patch also changes the display width of all associated address values in physmap.c to 16/8 hex characters depending on the actual size by introducing a macro PRIxPTR_WIDTH and exploiting printf's * field width specifier.
Signed-off-by: Stefan Tauner stefan.tauner@student.tuwien.ac.at Acked-by: Carl-Daniel Hailfinger c-d.hailfinger.devel.2006@gmx.net ---
Can you please verify that this is what you want? I put the _WIDTH macro in flash.h now for obvious reasons.
dummyflasher.c | 6 +++--- flash.h | 4 ++-- flashrom.c | 3 +-- physmap.c | 33 ++++++++++++++++----------------- programmer.c | 2 +- programmer.h | 10 +++++----- 6 files changed, 28 insertions(+), 30 deletions(-)
diff --git a/dummyflasher.c b/dummyflasher.c index e2ec036..cc15b00 100644 --- a/dummyflasher.c +++ b/dummyflasher.c @@ -412,10 +412,10 @@ dummy_init_out: return 0; }
-void *dummy_map(const char *descr, unsigned long phys_addr, size_t len) +void *dummy_map(const char *descr, uintptr_t phys_addr, size_t len) { - msg_pspew("%s: Mapping %s, 0x%lx bytes at 0x%08lx\n", - __func__, descr, (unsigned long)len, phys_addr); + msg_pspew("%s: Mapping %s, 0x%lx bytes at 0x%*" PRIxPTR "\n", + __func__, descr, (unsigned long)len, PRIxPTR_WIDTH, phys_addr); return (void *)phys_addr; }
diff --git a/flash.h b/flash.h index 9e787c0..cba7bd8 100644 --- a/flash.h +++ b/flash.h @@ -43,10 +43,10 @@
/* TODO: check using code for correct usage of types */ typedef uintptr_t chipaddr; +#define PRIxPTR_WIDTH ((int)(sizeof(uintptr_t)*2))
int register_shutdown(int (*function) (void *data), void *data); -void *programmer_map_flash_region(const char *descr, unsigned long phys_addr, - size_t len); +void *programmer_map_flash_region(const char *descr, uintptr_t phys_addr, size_t len); void programmer_unmap_flash_region(void *virt_addr, size_t len); void programmer_delay(int usecs);
diff --git a/flashrom.c b/flashrom.c index b9c0395..b05faf3 100644 --- a/flashrom.c +++ b/flashrom.c @@ -417,8 +417,7 @@ int programmer_shutdown(void) return ret; }
-void *programmer_map_flash_region(const char *descr, unsigned long phys_addr, - size_t len) +void *programmer_map_flash_region(const char *descr, uintptr_t phys_addr, size_t len) { return programmer_table[programmer].map_flash_region(descr, phys_addr, len); diff --git a/physmap.c b/physmap.c index 6e3d646..5e22883 100644 --- a/physmap.c +++ b/physmap.c @@ -42,7 +42,7 @@
static void *realmem_map;
-static void *map_first_meg(unsigned long phys_addr, size_t len) +static void *map_first_meg(uintptr_t phys_addr, size_t len) { if (realmem_map) return realmem_map + phys_addr; @@ -61,7 +61,7 @@ static void *map_first_meg(unsigned long phys_addr, size_t len) return realmem_map + phys_addr; }
-static void *sys_physmap(unsigned long phys_addr, size_t len) +static void *sys_physmap(uintptr_t phys_addr, size_t len) { int ret; __dpmi_meminfo mi; @@ -109,7 +109,7 @@ void physunmap(void *virt_addr, size_t len)
#define MEM_DEV ""
-void *sys_physmap(unsigned long phys_addr, size_t len) +void *sys_physmap(uintptr_t phys_addr, size_t len) { return (void *)phys_to_virt(phys_addr); } @@ -124,7 +124,7 @@ void physunmap(void *virt_addr, size_t len)
#define MEM_DEV "DirectHW"
-static void *sys_physmap(unsigned long phys_addr, size_t len) +static void *sys_physmap(uintptr_t phys_addr, size_t len) { /* The short form of ?: is a GNU extension. * FIXME: map_physical returns NULL both for errors and for success @@ -156,7 +156,7 @@ static int fd_mem = -1; static int fd_mem_cached = -1;
/* For MMIO access. Must be uncached, doesn't make sense to restrict to ro. */ -static void *sys_physmap_rw_uncached(unsigned long phys_addr, size_t len) +static void *sys_physmap_rw_uncached(uintptr_t phys_addr, size_t len) { void *virt_addr;
@@ -176,7 +176,7 @@ static void *sys_physmap_rw_uncached(unsigned long phys_addr, size_t len) /* For reading DMI/coreboot/whatever tables. We should never write, and we * do not care about caching. */ -static void *sys_physmap_ro_cached(unsigned long phys_addr, size_t len) +static void *sys_physmap_ro_cached(uintptr_t phys_addr, size_t len) { void *virt_addr;
@@ -209,25 +209,24 @@ void physunmap(void *virt_addr, size_t len) #define PHYSMAP_RW 0 #define PHYSMAP_RO 1
-static void *physmap_common(const char *descr, unsigned long phys_addr, +static void *physmap_common(const char *descr, uintptr_t phys_addr, size_t len, int mayfail, int readonly) { void *virt_addr;
if (len == 0) { - msg_pspew("Not mapping %s, zero size at 0x%08lx.\n", - descr, phys_addr); + msg_pspew("Not mapping %s, zero size at 0x%0*" PRIxPTR ".\n", descr, PRIxPTR_WIDTH, phys_addr); return ERROR_PTR; }
if ((getpagesize() - 1) & len) { - msg_perr("Mapping %s at 0x%08lx, unaligned size 0x%lx.\n", - descr, phys_addr, (unsigned long)len); + msg_perr("Mapping %s at 0x%0*" PRIxPTR ", unaligned size 0x%lx.\n", + descr, PRIxPTR_WIDTH, phys_addr, (unsigned long)len); }
if ((getpagesize() - 1) & phys_addr) { - msg_perr("Mapping %s, 0x%lx bytes at unaligned 0x%08lx.\n", - descr, (unsigned long)len, phys_addr); + msg_perr("Mapping %s, 0x%lx bytes at unaligned 0x%0*" PRIxPTR ".\n", + descr, (unsigned long)len, PRIxPTR_WIDTH, phys_addr); }
if (readonly) @@ -238,8 +237,8 @@ static void *physmap_common(const char *descr, unsigned long phys_addr, if (ERROR_PTR == virt_addr) { if (NULL == descr) descr = "memory"; - msg_perr("Error accessing %s, 0x%lx bytes at 0x%08lx\n", descr, - (unsigned long)len, phys_addr); + msg_perr("Error accessing %s, 0x%lx bytes at 0x%0*" PRIxPTR "\n", + descr, (unsigned long)len, PRIxPTR_WIDTH, phys_addr); msg_perr(MEM_DEV " mmap failed: %s\n", strerror(errno)); #ifdef __linux__ if (EINVAL == errno) { @@ -261,13 +260,13 @@ static void *physmap_common(const char *descr, unsigned long phys_addr, return virt_addr; }
-void *physmap(const char *descr, unsigned long phys_addr, size_t len) +void *physmap(const char *descr, uintptr_t phys_addr, size_t len) { return physmap_common(descr, phys_addr, len, PHYSMAP_NOFAIL, PHYSMAP_RW); }
-void *physmap_try_ro(const char *descr, unsigned long phys_addr, size_t len) +void *physmap_try_ro(const char *descr, uintptr_t phys_addr, size_t len) { return physmap_common(descr, phys_addr, len, PHYSMAP_MAYFAIL, PHYSMAP_RO); diff --git a/programmer.c b/programmer.c index 3b4def0..bf7dca1 100644 --- a/programmer.c +++ b/programmer.c @@ -28,7 +28,7 @@ int noop_shutdown(void) }
/* Fallback map() for programmers which don't need special handling */ -void *fallback_map(const char *descr, unsigned long phys_addr, size_t len) +void *fallback_map(const char *descr, uintptr_t phys_addr, size_t len) { /* FIXME: Should return phys_addr. */ return NULL; diff --git a/programmer.h b/programmer.h index 2ea7b48..db914cb 100644 --- a/programmer.h +++ b/programmer.h @@ -117,7 +117,7 @@ struct programmer_entry {
int (*init) (void);
- void *(*map_flash_region) (const char *descr, unsigned long phys_addr, size_t len); + void *(*map_flash_region) (const char *descr, uintptr_t phys_addr, size_t len); void (*unmap_flash_region) (void *virt_addr, size_t len);
void (*delay) (int usecs); @@ -275,8 +275,8 @@ int processor_flash_enable(void); #endif
/* physmap.c */ -void *physmap(const char *descr, unsigned long phys_addr, size_t len); -void *physmap_try_ro(const char *descr, unsigned long phys_addr, size_t len); +void *physmap(const char *descr, uintptr_t phys_addr, size_t len); +void *physmap_try_ro(const char *descr, uintptr_t phys_addr, size_t len); void physunmap(void *virt_addr, size_t len); #if CONFIG_INTERNAL == 1 int setup_cpu_msr(int cpu); @@ -359,7 +359,7 @@ void rmmio_vall(void *addr); /* dummyflasher.c */ #if CONFIG_DUMMY == 1 int dummy_init(void); -void *dummy_map(const char *descr, unsigned long phys_addr, size_t len); +void *dummy_map(const char *descr, uintptr_t phys_addr, size_t len); void dummy_unmap(void *virt_addr, size_t len); #endif
@@ -606,7 +606,7 @@ int register_opaque_programmer(const struct opaque_programmer *pgm);
/* programmer.c */ int noop_shutdown(void); -void *fallback_map(const char *descr, unsigned long phys_addr, size_t len); +void *fallback_map(const char *descr, uintptr_t phys_addr, size_t len); void fallback_unmap(void *virt_addr, size_t len); void noop_chip_writeb(const struct flashctx *flash, uint8_t val, chipaddr addr); void fallback_chip_writew(const struct flashctx *flash, uint16_t val, chipaddr addr);