diff options
author | Josh Rahm <joshuarahm@gmail.com> | 2024-11-16 15:22:24 -0700 |
---|---|---|
committer | Josh Rahm <joshuarahm@gmail.com> | 2024-11-16 15:22:24 -0700 |
commit | 7d64711cf7cbdf81d5a692044161ddc69e3dc33f (patch) | |
tree | fce2a6e12d8d648dda5cf4f4b55d5d5dc0cf72a0 /src/init.c | |
parent | 4c0d75cccc41335bcc39677d39d6761b77024dc6 (diff) | |
download | ch573-7d64711cf7cbdf81d5a692044161ddc69e3dc33f.tar.gz ch573-7d64711cf7cbdf81d5a692044161ddc69e3dc33f.tar.bz2 ch573-7d64711cf7cbdf81d5a692044161ddc69e3dc33f.zip |
Cleanup and get the program to a basic Hello, World program.
Add separate source file for initializing the uart for stdout.
Diffstat (limited to 'src/init.c')
-rw-r--r-- | src/init.c | 17 |
1 files changed, 12 insertions, 5 deletions
@@ -1,6 +1,7 @@ #include <stddef.h> #include <stdint.h> +#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(); } |