aboutsummaryrefslogtreecommitdiff
path: root/src/init.c
diff options
context:
space:
mode:
authorJosh Rahm <joshuarahm@gmail.com>2024-11-15 02:48:27 -0700
committerJosh Rahm <joshuarahm@gmail.com>2024-11-15 02:48:27 -0700
commitede9bee7f22fd5d0e1bacb7689f1cac23992b70b (patch)
tree904d8d80063aa415b9e407f6ec73aa874483ebcd /src/init.c
parent63054d2fdf9a0ae3e9dcdd0d20eb8714671a010b (diff)
downloadch573-ede9bee7f22fd5d0e1bacb7689f1cac23992b70b.tar.gz
ch573-ede9bee7f22fd5d0e1bacb7689f1cac23992b70b.tar.bz2
ch573-ede9bee7f22fd5d0e1bacb7689f1cac23992b70b.zip
UART is working.
Diffstat (limited to 'src/init.c')
-rw-r--r--src/init.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/src/init.c b/src/init.c
index 30e2c6d..5753a13 100644
--- a/src/init.c
+++ b/src/init.c
@@ -5,7 +5,7 @@
void on_reset(void);
-void __attribute__((weak, interrupt, __section__(".isr_vector")))
+void __attribute__((weak, interrupt, __section__(".isr_vector.routines")))
default_irq_handler(void)
{
return;
@@ -13,7 +13,7 @@ default_irq_handler(void)
#define WEAK_IRQ(irq) \
void __attribute__(( \
- weak, alias("default_irq_handler"), __section__(".isr_vector"))) \
+ weak, alias("default_irq_handler"), __section__(".isr_vector.routines"))) \
irq(void)
WEAK_IRQ(irq_on_reset);
@@ -60,7 +60,9 @@ extern uint32_t BSS_STOP;
static inline void set_mtvec(void* vector_table)
{
- asm volatile("csrw mtvec, %0" : : "r"(vector_table));
+ uint32_t mtvec = (uint32_t) vector_table;
+ mtvec |= 1; // Set interrupt table mode to "VECTORED"
+ asm volatile("csrw mtvec, %0" : : "r"(mtvec));
}
/*
@@ -99,7 +101,7 @@ extern void main(void);
/* Start function. Responsible for initializing the system and jumping to the
* main function. */
-static void start(void)
+static __attribute((__section__(".sinit.1"))) void start(void)
{
/* Initialize the data segments. */
init_data_segments();
@@ -113,7 +115,7 @@ static void start(void)
* The reset callback.This has to be a naked function because the stack pointer
* may not be initialized!!.
*/
-__attribute((naked, __section__(".isr_routines.on_reset"))) void on_reset(void)
+__attribute((naked, __section__(".sinit"))) void _begin(void)
{
// Set up the stack pointer to point to the end of SRAM.
asm volatile(