diff options
Diffstat (limited to 'pbl')
-rw-r--r-- | pbl/Kconfig | 11 | ||||
-rw-r--r-- | pbl/console.c | 34 | ||||
-rw-r--r-- | pbl/decomp.c | 26 |
3 files changed, 50 insertions, 21 deletions
diff --git a/pbl/Kconfig b/pbl/Kconfig index ba809af2d5..d1877a988d 100644 --- a/pbl/Kconfig +++ b/pbl/Kconfig @@ -46,9 +46,16 @@ config PBL_RELOCATABLE This option only influences the PBL image. See RELOCATABLE to also make the real image relocatable. +config PBL_FULLY_PIC + bool "fully position-independent pbl image" + depends on PBL_RELOCATABLE && ARM && CPU_64 + help + Compared to CONFIG_PBL_RELOCATABLE, this image has no relocations in + the code sections. + config PBL_VERIFY_PIGGY depends on ARM - bool + bool "Verify barebox proper hash before decompression" if COMPILE_TEST config BOARD_GENERIC_DT bool @@ -63,7 +70,7 @@ if IMAGE_COMPRESSION choice prompt "Compression" - default IMAGE_COMPRESSION_LZO + default IMAGE_COMPRESSION_LZ4 config IMAGE_COMPRESSION_LZ4 bool "lz4" diff --git a/pbl/console.c b/pbl/console.c index fc8e8cdf13..d81bf580d5 100644 --- a/pbl/console.c +++ b/pbl/console.c @@ -2,13 +2,14 @@ #include <common.h> #include <debug_ll.h> +#include <asm/sections.h> #include <linux/err.h> /* * Put these in the data section so that they survive the clearing of the * BSS segment. */ -static __attribute__ ((section(".data"))) void (*__putc)(void *ctx, int c); +static __attribute__ ((section(".data"))) ulong putc_offset; static __attribute__ ((section(".data"))) void *putc_ctx; /** @@ -21,13 +22,19 @@ static __attribute__ ((section(".data"))) void *putc_ctx; */ void pbl_set_putc(void (*putcf)(void *ctx, int c), void *ctx) { - __putc = putcf; + putc_offset = (ulong)putcf - (ulong)_text; putc_ctx = ctx; } +static void __putc(void *ctx, int c) +{ + void (*putc)(void *, int) = (void *)_text + putc_offset; + putc(ctx, c); +} + void console_putc(unsigned int ch, char c) { - if (__putc) + if (putc_offset) __putc(putc_ctx, c); else putc_ll(c); @@ -39,9 +46,9 @@ int console_puts(unsigned int ch, const char *str) while (*str) { if (*str == '\n') - console_putc(CONSOLE_STDOUT, '\r'); + console_putc(ch, '\r'); - console_putc(CONSOLE_STDOUT, *str); + console_putc(ch, *str); str++; n++; } @@ -74,7 +81,22 @@ int pr_print(int level, const char *fmt, ...) i = vsnprintf(printbuffer, sizeof(printbuffer), fmt, args); va_end(args); - console_puts(CONSOLE_STDOUT, printbuffer); + console_puts(CONSOLE_STDERR, printbuffer); + + return i; +} + +int dev_printf(int level, const struct device *dev, const char *fmt, ...) +{ + va_list args; + uint i; + char printbuffer[CFG_PBSIZE]; + + va_start(args, fmt); + i = vsnprintf(printbuffer, sizeof(printbuffer), fmt, args); + va_end(args); + + console_puts(CONSOLE_STDERR, printbuffer); return i; } diff --git a/pbl/decomp.c b/pbl/decomp.c index 553895bac5..ebdf81ddfb 100644 --- a/pbl/decomp.c +++ b/pbl/decomp.c @@ -70,20 +70,20 @@ int pbl_barebox_verify(const void *compressed_start, unsigned int len, sha256_update(&d, compressed_start, len); sha256_final(&d, computed_hash); if (IS_ENABLED(CONFIG_DEBUG_LL)) { - putc_ll('C'); - putc_ll('H'); - putc_ll('\n'); - for (i = 0; i < SHA256_DIGEST_SIZE; i++) { - puthex_ll(computed_hash[i]); - putc_ll('\n'); - } - putc_ll('I'); - putc_ll('H'); + puts_ll("CH "); + + for (i = 0; i < SHA256_DIGEST_SIZE; i++) + puthexc_ll(computed_hash[i]); + + puts_ll("\nIH "); + + for (i = 0; i < SHA256_DIGEST_SIZE; i++) + puthexc_ll(char_hash[i]); + putc_ll('\n'); - for (i = 0; i < SHA256_DIGEST_SIZE; i++) { - puthex_ll(char_hash[i]); - putc_ll('\n'); - } + + pr_debug("Hexdump of first 64 bytes of %u\n", len); + print_hex_dump_bytes("", DUMP_PREFIX_ADDRESS, compressed_start, 64); } return memcmp(hash, computed_hash, SHA256_DIGEST_SIZE); |