Maximilian Brune has uploaded this change for review.

View Change

arch/arm64/armv8: Add exception output without printk

In case printk does not work the current exception handler will print a
simple "!" to notify the developer that coreboot is actually there but
something went wrong.

The "!" can be quite confusing when it actually happens that printk does
not work. Since "!" doesn't really say much (if you don't know the
exception arm64 code) the developer (like me) can easily assume that
something went wrong while configuring clocks or baud rate of UART,
since the output seemingly does not seem to make sense.

This adds a little bit more output to assure the developer that what was
printed was actually intended to be printed. Therefore it prints "FAIL"
which assures the developer that this was intended output. It also adds
a comment above so that developer can more easily grep for this message.

Signed-off-by: Maximilian Brune <maximilian.brune@9elements.com>
Change-Id: I2f858730469fff3cae120fd7c32fec53b3d309ca
---
M src/arch/arm64/armv8/exception.c
M src/arch/arm64/include/armv8/arch/exception.h
2 files changed, 30 insertions(+), 1 deletion(-)

git pull ssh://review.coreboot.org:29418/coreboot refs/changes/84/80184/1
diff --git a/src/arch/arm64/armv8/exception.c b/src/arch/arm64/armv8/exception.c
index 15d7e38..220a1d7 100644
--- a/src/arch/arm64/armv8/exception.c
+++ b/src/arch/arm64/armv8/exception.c
@@ -101,10 +101,22 @@

static void print_exception_info(struct exc_state *state, uint64_t idx)
{
- /* Poor man's sign of life in case printk() is shot. */
+ // Sign of life in case printk() is shot. Prints !FAIL!idx!esr_register! to UART
__uart_tx_byte('\r');
__uart_tx_byte('\n');
__uart_tx_byte('!');
+ __uart_tx_byte('F');
+ __uart_tx_byte('A');
+ __uart_tx_byte('I');
+ __uart_tx_byte('L');
+ __uart_tx_byte('!');
+ if (idx < 10)
+ __uart_tx_byte('0' + (char)idx);
+ else if (idx < 16)
+ __uart_tx_byte('A' - 10 + (char)idx);
+ __uart_tx_byte('!');
+ UART_DIRECT_PRINT(raw_read_esr(), 32)
+ __uart_tx_byte('!');

printk(BIOS_DEBUG, "\nexception %s\n",
idx < NUM_EXC_VIDS ? exception_names[idx] : "_unknown");
diff --git a/src/arch/arm64/include/armv8/arch/exception.h b/src/arch/arm64/include/armv8/arch/exception.h
index 2c5b7f9..9eac768 100644
--- a/src/arch/arm64/include/armv8/arch/exception.h
+++ b/src/arch/arm64/include/armv8/arch/exception.h
@@ -6,6 +6,23 @@
#include <arch/transition.h>
#include <types.h>

+/*
+ * Directly prints to the UART interface.
+ * data: number to be printed
+ * bits: size of data in bits
+ * Example usage:
+ * void *stack_pointer = (void *)0x0123456789ABCDEF
+ * UART_DIRECT_PRINT((unsigned long)stack_pointer)
+ */
+#define UART_DIRECT_PRINT(data, bits) \
+ for (int i = bits - 4; i >= 0; i -= 4) { \
+ int nibble = (data >> i) & 15; \
+ if (nibble < 10) \
+ __uart_tx_byte('0' + nibble); \
+ else \
+ __uart_tx_byte('A' - 10 + nibble); \
+ }
+
/* Initialize the exception handling on the current CPU. */
void exception_init(void);


To view, visit change 80184. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: coreboot
Gerrit-Branch: main
Gerrit-Change-Id: I2f858730469fff3cae120fd7c32fec53b3d309ca
Gerrit-Change-Number: 80184
Gerrit-PatchSet: 1
Gerrit-Owner: Maximilian Brune <maximilian.brune@9elements.com>
Gerrit-MessageType: newchange