From 8ffc1b0fd55aff5fa1014cd99db4dbb695d51a4c Mon Sep 17 00:00:00 2001 From: Christian Cunningham Date: Tue, 22 Feb 2022 23:14:49 -0700 Subject: Added locking --- src/drivers/uart.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src') diff --git a/src/drivers/uart.c b/src/drivers/uart.c index becda2d..e4ae2d1 100644 --- a/src/drivers/uart.c +++ b/src/drivers/uart.c @@ -4,18 +4,21 @@ #include #include #include +#include #define UART_BUFFER_SIZE 0x400 struct UartBuffer { char buffer[UART_BUFFER_SIZE]; unsigned long roffset; unsigned long woffset; + struct Lock l; } ubuffer; void uart_init(void) { ubuffer.roffset = 0; ubuffer.woffset = 0; + ubuffer.l.pid = 0; // Disable UART0 store32(0x0, UART0_CR); @@ -41,6 +44,7 @@ void uart_init(void) // s = zero-terminated string void* uart_print(char* s) { + lock(&ubuffer.l); char* ptr = s; while (1) { if (*ptr == 0) @@ -54,6 +58,7 @@ void* uart_print(char* s) } // Low priority flush run whenever add_thread(uart_flush, 0, PRIORITIES-1); + unlock(&ubuffer.l); return 0; } -- cgit v1.2.1