summaryrefslogtreecommitdiff
path: root/src/lib/selfboot.c
diff options
context:
space:
mode:
authorJulius Werner <jwerner@chromium.org>2019-12-09 13:03:29 -0800
committerPatrick Georgi <pgeorgi@google.com>2019-12-11 11:38:59 +0000
commit540a98001d05a7b780e415c34d14a97b14e44ac6 (patch)
treedb4cffc987097c64fb6c6be996e57bdcbf9786ac /src/lib/selfboot.c
parent86da00db899c4c58df90b4270082007c871169c7 (diff)
printf: Automatically prefix %p with 0x
According to the POSIX standard, %p is supposed to print a pointer "as if by %#x", meaning the "0x" prefix should automatically be prepended. All other implementations out there (glibc, Linux, even libpayload) do this, so we should make coreboot match. This patch changes vtxprintf() accordingly and removes any explicit instances of "0x%p" from existing format strings. How to handle zero padding is less clear: the official POSIX definition above technically says there should be no automatic zero padding, but in practice most other implementations seem to do it and I assume most programmers would prefer it. The way chosen here is to always zero-pad to 32 bits, even on a 64-bit system. The rationale for this is that even on 64-bit systems, coreboot always avoids using any memory above 4GB for itself, so in practice all pointers should fit in that range and padding everything to 64 bits would just hurt readability. Padding it this way also helps pointers that do exceed 4GB (e.g. prints from MMU config on some arm64 systems) stand out better from the others. Change-Id: I0171b52f7288abb40e3fc3c8b874aee14b9bdcd6 Signed-off-by: Julius Werner <jwerner@chromium.org> Reviewed-on: https://review.coreboot.org/c/coreboot/+/37626 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Paul Menzel <paulepanter@users.sourceforge.net> Reviewed-by: Patrick Georgi <pgeorgi@google.com> Reviewed-by: David Guckian
Diffstat (limited to 'src/lib/selfboot.c')
-rw-r--r--src/lib/selfboot.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/src/lib/selfboot.c b/src/lib/selfboot.c
index a0bb711f8a..8cf7a6ff57 100644
--- a/src/lib/selfboot.c
+++ b/src/lib/selfboot.c
@@ -56,7 +56,7 @@ static int segment_targets_type(void *dest, unsigned long memsz,
if (payload_arch_usable_ram_quirk(d, memsz))
return 1;
- printk(BIOS_ERR, "SELF segment doesn't target RAM: 0x%p, %lu bytes\n", dest, memsz);
+ printk(BIOS_ERR, "SELF segment doesn't target RAM: %p, %lu bytes\n", dest, memsz);
bootmem_dump_ranges();
return 0;
}
@@ -69,7 +69,7 @@ static int load_one_segment(uint8_t *dest,
int flags)
{
unsigned char *middle, *end;
- printk(BIOS_DEBUG, "Loading Segment: addr: 0x%p memsz: 0x%016zx filesz: 0x%016zx\n",
+ printk(BIOS_DEBUG, "Loading Segment: addr: %p memsz: 0x%016zx filesz: 0x%016zx\n",
dest, memsz, len);
/* Compute the boundaries of the segment */
@@ -150,7 +150,7 @@ static int check_payload_segments(struct cbfs_payload_segment *cbfssegs,
enum bootmem_type dest_type = *(enum bootmem_type *)args;
for (seg = cbfssegs;; ++seg) {
- printk(BIOS_DEBUG, "Checking segment from ROM address 0x%p\n", seg);
+ printk(BIOS_DEBUG, "Checking segment from ROM address %p\n", seg);
cbfs_decode_payload_segment(&segment, seg);
dest = (uint8_t *)(uintptr_t)segment.load_addr;
memsz = segment.mem_len;
@@ -171,7 +171,7 @@ static int load_payload_segments(struct cbfs_payload_segment *cbfssegs, uintptr_
int flags = 0;
for (first_segment = seg = cbfssegs;; ++seg) {
- printk(BIOS_DEBUG, "Loading segment from ROM address 0x%p\n", seg);
+ printk(BIOS_DEBUG, "Loading segment from ROM address %p\n", seg);
cbfs_decode_payload_segment(&segment, seg);
dest = (uint8_t *)(uintptr_t)segment.load_addr;
@@ -187,7 +187,7 @@ static int load_payload_segments(struct cbfs_payload_segment *cbfssegs, uintptr_
? "code" : "data", segment.compression);
src = ((uint8_t *)first_segment) + segment.offset;
printk(BIOS_DEBUG,
- " New segment dstaddr 0x%p memsize 0x%zx srcaddr 0x%p filesize 0x%zx\n",
+ " New segment dstaddr %p memsize 0x%zx srcaddr %p filesize 0x%zx\n",
dest, memsz, src, filesz);
/* Clean up the values */
@@ -198,7 +198,7 @@ static int load_payload_segments(struct cbfs_payload_segment *cbfssegs, uintptr_
break;
case PAYLOAD_SEGMENT_BSS:
- printk(BIOS_DEBUG, " BSS 0x%p (%d byte)\n", (void *)
+ printk(BIOS_DEBUG, " BSS %p (%d byte)\n", (void *)
(intptr_t)segment.load_addr, segment.mem_len);
filesz = 0;
src = ((uint8_t *)first_segment) + segment.offset;
@@ -206,7 +206,7 @@ static int load_payload_segments(struct cbfs_payload_segment *cbfssegs, uintptr_
break;
case PAYLOAD_SEGMENT_ENTRY:
- printk(BIOS_DEBUG, " Entry Point 0x%p\n", (void *)
+ printk(BIOS_DEBUG, " Entry Point %p\n", (void *)
(intptr_t)segment.load_addr);
*entry = segment.load_addr;