diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/cpu/irq.c | 3 | ||||
-rw-r--r-- | src/drivers/uart.c | 38 | ||||
-rw-r--r-- | src/sys/core.c | 1 |
3 files changed, 42 insertions, 0 deletions
diff --git a/src/cpu/irq.c b/src/cpu/irq.c index 2197067..15603b9 100644 --- a/src/cpu/irq.c +++ b/src/cpu/irq.c @@ -84,6 +84,9 @@ unsigned long c_fiq_handler(void) if (counter % 0x6000 == 0) { counter = 0; } + if (counter % 0x8 == 0) { + add_thread(uart_flush, 0, 5); + } if (counter % 0x30 == 0) { return 1; } diff --git a/src/drivers/uart.c b/src/drivers/uart.c index f6fe79b..c5514ce 100644 --- a/src/drivers/uart.c +++ b/src/drivers/uart.c @@ -1,5 +1,43 @@ #include <drivers/uart.h> +#define UART_BUFFER_SIZE 0x100 +struct UartBuffer { + char buffer[UART_BUFFER_SIZE]; + unsigned long roffset; + unsigned long woffset; +} ubuffer; + +void uart_init(void) +{ + ubuffer.roffset = 0; + ubuffer.woffset = 0; +} + +// s = zero-terminated string +void* uart_print(char* s) +{ + char* ptr = s; + while (1) { + if (*ptr == 0) + break; + ubuffer.buffer[ubuffer.woffset] = *ptr; + if ((ubuffer.woffset+1)%UART_BUFFER_SIZE == ubuffer.roffset) + return ptr; + ubuffer.woffset++; + ubuffer.woffset %= UART_BUFFER_SIZE; + ptr += 1; + } + return 0; +} + +void uart_flush(void) +{ + while (ubuffer.roffset != ubuffer.woffset) { + uart_char(ubuffer.buffer[ubuffer.roffset++]); + ubuffer.roffset %= UART_BUFFER_SIZE; + } +} + void uart_10(unsigned long val) { unsigned long t = val; diff --git a/src/sys/core.c b/src/sys/core.c index b29412f..d761336 100644 --- a/src/sys/core.c +++ b/src/sys/core.c @@ -28,6 +28,7 @@ void sysinit(void) stimeh = *(unsigned long*)SYS_TIMER_CHI; stimel = *(unsigned long*)SYS_TIMER_CLO; *(unsigned long*) SYS_TIMER_C0 = 60000000 + stimeh; // 60 second trigger + uart_init(); ///... // Route GPU interrupts to Core 0 |