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
This commit is contained in:
committed by
Patrick Georgi
parent
86da00db89
commit
540a98001d
@@ -118,6 +118,6 @@ void bootblock_soc_init(void)
|
||||
void platform_prog_run(struct prog *prog)
|
||||
{
|
||||
/* Display the program entry point */
|
||||
printk(BIOS_SPEW, "Calling %s, 0x%p(0x%p)\n", prog->name,
|
||||
printk(BIOS_SPEW, "Calling %s, %p(%p)\n", prog->name,
|
||||
prog->entry, prog->arg);
|
||||
}
|
||||
|
@@ -209,7 +209,7 @@ int platform_i2c_transfer(unsigned int bus, struct i2c_msg *segment,
|
||||
if (index == 0)
|
||||
printk(BIOS_ERR, "I2C Start\n");
|
||||
printk(BIOS_ERR,
|
||||
"I2C segment[%d]: %s 0x%02x %s 0x%p, 0x%08x bytes\n",
|
||||
"I2C segment[%d]: %s 0x%02x %s %p, 0x%08x bytes\n",
|
||||
index,
|
||||
(segment[index].flags & I2C_M_RD) ? "Read from" : "Write to",
|
||||
segment[index].slave,
|
||||
|
@@ -26,7 +26,7 @@ void soc_display_fspm_upd_params(const FSPM_UPD *fspm_old_upd,
|
||||
new = &fspm_new_upd->FspmConfig;
|
||||
|
||||
/* Display the parameters for MemoryInit */
|
||||
printk(BIOS_SPEW, "UPD values for MemoryInit at: 0x%p\n", new);
|
||||
printk(BIOS_SPEW, "UPD values for MemoryInit at: %p\n", new);
|
||||
fsp_display_upd_value("AddrMode", sizeof(old->AddrMode),
|
||||
old->AddrMode, new->AddrMode);
|
||||
fsp_display_upd_value("ChanMask", sizeof(old->ChanMask),
|
||||
|
@@ -111,13 +111,13 @@ void platform_fsp_memory_init_params_cb(FSPM_UPD *fspm_upd, uint32_t version)
|
||||
"+-------------------+ 0x%08x (CONFIG_FSP_ESRAM_LOC)\n",
|
||||
CONFIG_FSP_ESRAM_LOC);
|
||||
printk(BIOS_SPEW, "| FSP stack |\n");
|
||||
printk(BIOS_SPEW, "+-------------------+ 0x%p\n",
|
||||
printk(BIOS_SPEW, "+-------------------+ %p\n",
|
||||
aupd->StackBase);
|
||||
printk(BIOS_SPEW, "| |\n");
|
||||
printk(BIOS_SPEW, "+-------------------+ 0x%p\n",
|
||||
printk(BIOS_SPEW, "+-------------------+ %p\n",
|
||||
_car_unallocated_start);
|
||||
printk(BIOS_SPEW, "| coreboot data |\n");
|
||||
printk(BIOS_SPEW, "+-------------------+ 0x%p\n",
|
||||
printk(BIOS_SPEW, "+-------------------+ %p\n",
|
||||
_ecar_stack);
|
||||
printk(BIOS_SPEW, "| coreboot stack |\n");
|
||||
printk(BIOS_SPEW,
|
||||
|
Reference in New Issue
Block a user