diff options
-rw-r--r-- | core/console.c | 6 | ||||
-rw-r--r-- | core/platform.c | 4 | ||||
-rw-r--r-- | hw/lpc-uart.c | 14 | ||||
-rw-r--r-- | include/console.h | 3 |
4 files changed, 26 insertions, 1 deletions
diff --git a/core/console.c b/core/console.c index df3ce3b..f993237 100644 --- a/core/console.c +++ b/core/console.c @@ -290,6 +290,12 @@ ssize_t read(int fd __unused, void *buf, size_t req_count) return count; } +void flush_console_driver(void) +{ + if (con_driver->flush != NULL) + con_driver->flush(); +} + void set_console(struct con_ops *driver) { con_driver = driver; diff --git a/core/platform.c b/core/platform.c index 12c4ec2..865d5b2 100644 --- a/core/platform.c +++ b/core/platform.c @@ -37,6 +37,8 @@ static int64_t opal_cec_power_down(uint64_t request) { printf("OPAL: Shutdown request type 0x%llx...\n", request); + flush_console_driver(); + if (platform.cec_power_down) return platform.cec_power_down(request); @@ -48,6 +50,8 @@ static int64_t opal_cec_reboot(void) { printf("OPAL: Reboot request...\n"); + flush_console_driver(); + #ifdef ENABLE_FAST_RESET /* Try a fast reset first */ fast_reset(); diff --git a/hw/lpc-uart.c b/hw/lpc-uart.c index 5c5d942..e856563 100644 --- a/hw/lpc-uart.c +++ b/hw/lpc-uart.c @@ -156,8 +156,11 @@ static size_t uart_con_write(const char *buf, size_t len) return written; } +static void uart_con_flush_all(void); + static struct con_ops uart_con_driver = { - .write = uart_con_write + .write = uart_con_write, + .flush = uart_con_flush_all }; /* @@ -376,6 +379,15 @@ static void uart_irq(uint32_t chip_id __unused, uint32_t irq_mask __unused) } /* + * Flush the entire buffer all at once + */ +static void uart_con_flush_all(void) +{ + while(out_buf_prod != out_buf_cons) + uart_flush_out(); +} + +/* * Common setup/inits */ diff --git a/include/console.h b/include/console.h index e426adb..45f914b 100644 --- a/include/console.h +++ b/include/console.h @@ -51,6 +51,7 @@ struct con_ops { size_t (*write)(const char *buf, size_t len); size_t (*read)(char *buf, size_t len); bool (*poll_read)(void); + void (*flush)(void); }; extern struct lock con_lock; @@ -61,6 +62,8 @@ extern bool flush_console(void); extern bool __flush_console(bool flush_to_drivers); extern void set_console(struct con_ops *driver); +extern void flush_console_driver(void); + extern int mambo_read(void); extern void mambo_write(const char *buf, size_t count); extern void enable_mambo_console(void); |