From d0f5524676ba0a2556b6b2db51c433d9deb60b04 Mon Sep 17 00:00:00 2001 From: Alexander von Gluck IV Date: Wed, 16 May 2012 06:25:13 -0500 Subject: [PATCH] rpi: Wait for keypress on panic * Cleanup serial shutdown process --- .../boot/platform/raspberrypi_arm/serial.cpp | 22 ++++++++++++++----- .../boot/platform/raspberrypi_arm/start.c | 3 +++ 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/src/system/boot/platform/raspberrypi_arm/serial.cpp b/src/system/boot/platform/raspberrypi_arm/serial.cpp index 926f0b4092..a85c69d840 100644 --- a/src/system/boot/platform/raspberrypi_arm/serial.cpp +++ b/src/system/boot/platform/raspberrypi_arm/serial.cpp @@ -20,7 +20,7 @@ UartPL011 gLoaderUART(uart_base_debug()); -static int32 sSerialEnabled = 0; +static bool sSerialEnabled = false; static void @@ -30,10 +30,17 @@ serial_putc(char c) } +extern "C" int +serial_getc(bool wait) +{ + return gLoaderUART.GetChar(wait); +} + + extern "C" void serial_puts(const char* string, size_t size) { - if (sSerialEnabled <= 0) + if (!sSerialEnabled) return; while (size-- > 0) { @@ -53,23 +60,26 @@ serial_puts(const char* string, size_t size) extern "C" void serial_disable(void) { - sSerialEnabled--; + if (sSerialEnabled) + serial_cleanup(); + + gLoaderUART.Disable(); } extern "C" void serial_enable(void) { - sSerialEnabled++; + gLoaderUART.Enable(); + sSerialEnabled = true; } extern "C" void serial_cleanup(void) { - // Transmit the last of our fifo + sSerialEnabled = false; gLoaderUART.FlushTx(); - gLoaderUART.Disable(); } diff --git a/src/system/boot/platform/raspberrypi_arm/start.c b/src/system/boot/platform/raspberrypi_arm/start.c index 366bb64354..470ac06a3e 100644 --- a/src/system/boot/platform/raspberrypi_arm/start.c +++ b/src/system/boot/platform/raspberrypi_arm/start.c @@ -93,6 +93,9 @@ void platform_exit(void) { serial_cleanup(); + // Wait for keypress on serial + serial_getc(true); + serial_disable(); }