From 7d64711cf7cbdf81d5a692044161ddc69e3dc33f Mon Sep 17 00:00:00 2001 From: Josh Rahm Date: Sat, 16 Nov 2024 15:22:24 -0700 Subject: Cleanup and get the program to a basic Hello, World program. Add separate source file for initializing the uart for stdout. --- src/init.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'src/init.c') diff --git a/src/init.c b/src/init.c index 1d9474a..c402f17 100644 --- a/src/init.c +++ b/src/init.c @@ -1,6 +1,7 @@ #include #include +#include "io.h" #include "isr_vector.h" void on_reset(void); @@ -11,9 +12,11 @@ default_irq_handler(void) return; } -#define WEAK_IRQ(irq) \ - void __attribute__(( \ - weak, alias("default_irq_handler"), __section__(".isr_vector.routines"))) \ +#define WEAK_IRQ(irq) \ + void __attribute__(( \ + weak, \ + alias("default_irq_handler"), \ + __section__(".isr_vector.routines"))) \ irq(void) WEAK_IRQ(irq_on_reset); @@ -60,8 +63,8 @@ extern uint32_t BSS_STOP; static inline void set_mtvec(void* vector_table) { - uint32_t mtvec = (uint32_t) vector_table; - mtvec |= 1; // Set interrupt table mode to "VECTORED" + uint32_t mtvec = (uint32_t)vector_table; + mtvec |= 1; // Set interrupt table mode to "VECTORED" asm volatile("csrw mtvec, %0" : : "r"(mtvec)); } @@ -107,6 +110,10 @@ static __attribute((__section__(".sinit.1"))) void start(void) init_data_segments(); /* Set the mtvec to the isr_vector. */ set_mtvec(&isr_vector); + + /* Initialize stdout. */ + init_uart1_for_stdout(); + /* Jump to main */ main(); } -- cgit