aboutsummaryrefslogtreecommitdiff
path: root/src/init.c
diff options
context:
space:
mode:
authorJosh Rahm <joshuarahm@gmail.com>2024-11-16 15:22:24 -0700
committerJosh Rahm <joshuarahm@gmail.com>2024-11-16 15:22:24 -0700
commit7d64711cf7cbdf81d5a692044161ddc69e3dc33f (patch)
treefce2a6e12d8d648dda5cf4f4b55d5d5dc0cf72a0 /src/init.c
parent4c0d75cccc41335bcc39677d39d6761b77024dc6 (diff)
downloadch573-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.c17
1 files changed, 12 insertions, 5 deletions
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 <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();
}