Skip to content

Commit

Permalink
Make sure UART is always on debug-console
Browse files Browse the repository at this point in the history
  • Loading branch information
Siguza committed Oct 12, 2024
1 parent 5d4695b commit fe98206
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/drivers/uart/uart.c
Original file line number Diff line number Diff line change
Expand Up @@ -89,12 +89,22 @@ static inline void put_serial_modifier(const char* str) {
while (*str) serial_putc(*str++);
}

static dt_node_t* serial_dt_node(void)
{
static dt_node_t *uart = NULL;
if(!uart)
{
uart = dt_node_parent(dt_get("debug-console"));
}
return uart;
}

uint32_t orig_rUCON0, orig_rULCON0, orig_rUFCON0, orig_rUMCON0;
uint64_t gUartBase;
extern uint32_t gLogoBitmap[32];
void serial_early_init() {
disable_interrupts();
gUartBase = dt_get_u32_prop("uart0", "reg");
gUartBase = dt_node_u32(serial_dt_node(), "reg", 0);
gUartBase += gIOBase;
orig_rUCON0 = rUCON0;
orig_rULCON0 = rULCON0;
Expand Down Expand Up @@ -146,7 +156,7 @@ void serial_init() {
struct task* irq_task = task_create_extended("uart", uart_main, TASK_IRQ_HANDLER|TASK_PREEMPT, 0);

disable_interrupts();
uart_irq = dt_get_u32_prop("uart0", "interrupts");
uart_irq = dt_node_u32(serial_dt_node(), "interrupts", 0);
serial_disable_rx();
task_bind_to_irq(irq_task, uart_irq);
rUCON0 = 0x5885;
Expand Down

0 comments on commit fe98206

Please sign in to comment.