Squash commits for public release
This commit is contained in:
24
boot/riscv64/prekernel/drivers/uart.c
Normal file
24
boot/riscv64/prekernel/drivers/uart.c
Normal file
@@ -0,0 +1,24 @@
|
||||
#include "uart.h"
|
||||
|
||||
volatile uint32_t* output = NULL;
|
||||
|
||||
#define UART 0x10000000
|
||||
#define UART_THR (char*)(UART + 0x00) // THR:transmitter holding register
|
||||
#define UART_LSR (char*)(UART + 0x05) // LSR:line status register
|
||||
#define UART_LSR_EMPTY_MASK 0x40 // LSR Bit 6: Transmitter empty; both the THR and LSR are empty
|
||||
|
||||
void uart_init()
|
||||
{
|
||||
output = (uint32_t*)UART;
|
||||
}
|
||||
|
||||
int uart_write(uint8_t data)
|
||||
{
|
||||
if (!output) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
while ((*UART_LSR & UART_LSR_EMPTY_MASK) == 0) { }
|
||||
*output = data;
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user