diff options
author | Christian Cunningham <cc@localhost> | 2022-02-22 23:14:49 -0700 |
---|---|---|
committer | Christian Cunningham <cc@localhost> | 2022-02-22 23:14:49 -0700 |
commit | 8ffc1b0fd55aff5fa1014cd99db4dbb695d51a4c (patch) | |
tree | 48b52a55e93da80937057a7fed0bc9cf446b9f49 /src/drivers/uart.c | |
parent | c59fed186238d07557817a752f951471201ba9e0 (diff) |
Added locking
Diffstat (limited to 'src/drivers/uart.c')
-rw-r--r-- | src/drivers/uart.c | 5 |
1 files changed, 5 insertions, 0 deletions
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 <sys/core.h> #include <sys/schedule.h> #include <symbols.h> +#include <util/lock.h> #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; } |