MOS Source Code
Loading...
Searching...
No Matches
vectors.c
Go to the documentation of this file.
1#include <stdint.h>
2
3#ifdef __cplusplus
4extern "C" {
5#endif
6
7extern void _start();
8extern void* __StackTop;
9
10static void HardFaultHandler()
11{
12 uint32_t args[3];
13 args[0] = 2;
14 args[1] = (uint32_t)"HARDFAULT";
15 args[2] = 9;
16
17 asm("mov r0, #5\n"
18 "mov r1, %0\n"
19 "bkpt 0x00ab" : : "r"(args) : "r0", "r1", "memory");
20 asm("mov r12, %0\n" "mov r0, #24\n" "bkpt 0x00ab" : : "r"(0xDEADBEEF) : "r0");
21 while(1);
22}
23
24void* const g_vector_table[16] __attribute__((section(".isr_vector"))) = {
25 (void*)&__StackTop,
26 (void*)&_start,
27 (void*)&HardFaultHandler,
28 (void*)&HardFaultHandler,
29 (void*)&HardFaultHandler,
30 (void*)&HardFaultHandler,
31 (void*)&HardFaultHandler,
32};
33
34
35void ramboot() __attribute__((noreturn, naked, section(".ramboot")));
36void ramboot()
37{
38 *(const void**)0xE000ED08 = g_vector_table; // SCB->VTOR
39 __asm__(
40 "msr msp, %0\n\t"
41 "bx %1" : : "r" (g_vector_table[0]),
42 "r" (g_vector_table[1]) : "memory");
43}
44
45#ifdef __cplusplus
46}
47#endif
char args[3][16]
Definition avr_io.c:16
unsigned int uint32_t
Definition pb_syshdr.h:24
void _start()
void section(".ramboot")))
void naked
Definition vectors.c:35
void * __StackTop
void *const g_vector_table[16] __attribute__((section(".isr_vector")))
static void HardFaultHandler()
Definition vectors.c:10
void ramboot() __attribute__((noreturn
Definition vectors.c:36