mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-03-18 21:30:38 +01:00
Overridable ISRs
This commit is contained in:
2
Makefile
2
Makefile
@@ -9,7 +9,7 @@ CFLAGS += -std=c99 -g -Wall # -Os
|
||||
CC=clang
|
||||
CFLAGS += -target thumbv7em-unknown-eabi -mcpu=cortex-m4 -mfpu=fpv4-sp-d16 -ffreestanding
|
||||
|
||||
objs := boot/crt0.o arch/stm32f429/registers/rcc.o arch/stm32f429/registers/gpio.o external/freertos/tasks.o external/freertos/list.o external/freertos/queue.o external/freertos/portable/GCC/ARM_CM4F/port.o external/freertos/portable/MemMang/heap_1.o external/newlib/libc/string/memset.o external/newlib/libc/string/memcpy.o
|
||||
objs := boot/crt0.o arch/stm32f429/isr.o arch/stm32f429/registers/rcc.o arch/stm32f429/registers/gpio.o external/freertos/tasks.o external/freertos/list.o external/freertos/queue.o external/freertos/portable/GCC/ARM_CM4F/port.o external/freertos/portable/MemMang/heap_1.o external/newlib/libc/string/memset.o external/newlib/libc/string/memcpy.o
|
||||
|
||||
default: clean boot.elf
|
||||
|
||||
|
||||
61
boot/crt0.c
61
boot/crt0.c
@@ -1,57 +1,15 @@
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
// FIXME: Use a libc, and memset, bzerto!
|
||||
|
||||
extern const void * _data_section_start_flash;
|
||||
extern const void * _data_section_start_ram;
|
||||
extern const void * _data_section_end_ram;
|
||||
extern const void * _bss_section_start_ram;
|
||||
extern const void * _bss_section_end_ram;
|
||||
extern const void * _stack_start;
|
||||
extern const void * _stack_end;
|
||||
|
||||
void _ResetServiceRoutine(void);
|
||||
void _NMIServiceRoutine(void);
|
||||
void _HardFaultServiceRoutine(void);
|
||||
void _MemManageServiceRoutine(void);
|
||||
void _BusFaultServiceRoutine(void);
|
||||
void _SVCallServiceRoutine(void);
|
||||
void _PendSVServiceRoutine(void);
|
||||
void _SystickServiceRoutine(void);
|
||||
|
||||
/* Interrupt Service Routines are void->void functions */
|
||||
typedef void(*ISR)(void);
|
||||
|
||||
/* Notice: The Cortex-M4 expects all jumps to be made at an odd address when
|
||||
* jumping to Thumb code. For example, if you want to execute Thumb code at
|
||||
* address 0x100, you'll have to jump to 0x101. Luckily, this idiosyncrasy is
|
||||
* properly handled by the C compiler that will generate proper addresses when
|
||||
* using function pointers. */
|
||||
|
||||
#define INITIALISATION_VECTOR_SIZE 0x6B
|
||||
|
||||
ISR InitialisationVector[INITIALISATION_VECTOR_SIZE]
|
||||
__attribute__((section(".isr_vector_table")))
|
||||
= {
|
||||
(ISR)&_stack_start,
|
||||
_ResetServiceRoutine,
|
||||
_NMIServiceRoutine,
|
||||
_HardFaultServiceRoutine,
|
||||
_MemManageServiceRoutine,
|
||||
_BusFaultServiceRoutine,
|
||||
0, // UsageFault
|
||||
0, // Reserved
|
||||
_SVCallServiceRoutine,
|
||||
0, // Debug Monitor
|
||||
_PendSVServiceRoutine, // PendSV
|
||||
_SystickServiceRoutine, // Systick
|
||||
0
|
||||
};
|
||||
|
||||
|
||||
int main(int argc, char * argv[]);
|
||||
|
||||
void _ResetServiceRoutine(void) {
|
||||
void _start(void) {
|
||||
// This is where execution starts after reset.
|
||||
// Many things are not initialized yet so the code here has to pay attention.
|
||||
|
||||
@@ -71,22 +29,7 @@ void _ResetServiceRoutine(void) {
|
||||
main(0, 0x0);
|
||||
}
|
||||
|
||||
void _NMIServiceRoutine(void) {
|
||||
while (1) {
|
||||
}
|
||||
}
|
||||
|
||||
void _HardFaultServiceRoutine(void) {
|
||||
while (1) {
|
||||
}
|
||||
}
|
||||
|
||||
void _MemManageServiceRoutine(void) {
|
||||
while (1) {
|
||||
}
|
||||
}
|
||||
|
||||
void _BusFaultServiceRoutine(void) {
|
||||
void _halt(void) {
|
||||
while (1) {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ MEMORY {
|
||||
}
|
||||
|
||||
SECTIONS {
|
||||
|
||||
.isr_vector_table ORIGIN(FLASH) : {
|
||||
/* When booting, the STM32F42xx fetches the content of address 0x0, and
|
||||
* extracts from it various key infos: the initial value of the PC register
|
||||
@@ -32,7 +33,24 @@ SECTIONS {
|
||||
* We're generating the ISR vector table in C, because it's very convenient:
|
||||
* using function pointers, we can easily point to the service routing for
|
||||
* each interrupt.
|
||||
* See ST/RM0090/p70 for more infos. */
|
||||
* See ST/RM0090/p70 for more infos.
|
||||
*
|
||||
* Last but not least, the ISR vector table contains pointer to functions
|
||||
* that we may want to override depending on the binary we want to produce.
|
||||
* The C implementation uses _NameServiceRoutine symbols. If those symbols
|
||||
* are defined elsewhere, we'll use that version. If they aren't defined, we
|
||||
* will provide here a default implementation (namely, calling crt0's _start
|
||||
* on reset, and an infinite loop on HardFault). */
|
||||
|
||||
_ResetServiceRoutine = DEFINED(_ResetServiceRoutine) ? _ResetServiceRoutine : _start;
|
||||
_NMIServiceRoutine = DEFINED(_NMIServiceRoutine) ? _NMIServiceRoutine : 0;
|
||||
_HardFaultServiceRoutine = DEFINED(_HardFaultServiceRoutine) ? _HardFaultServiceRoutine : _halt;
|
||||
_MemManageServiceRoutine = DEFINED(_MemManageServiceRoutine) ? _MemManageServiceRoutine : 0;
|
||||
_BusFaultServiceRoutine = DEFINED(_BusFaultServiceRoutine) ? _BusFaultServiceRoutine : 0;
|
||||
_SVCallServiceRoutine = DEFINED(_SVCallServiceRoutine) ? _SVCallServiceRoutine : 0;
|
||||
_PendSVServiceRoutine = DEFINED(_PendSVServiceRoutine) ? _PendSVServiceRoutine : 0;
|
||||
_SysTickServiceRoutine = DEFINED(_SysTickServiceRoutine) ? _SysTickServiceRoutine : 0;
|
||||
|
||||
*(.isr_vector_table)
|
||||
} >FLASH
|
||||
|
||||
|
||||
2
external/FreeRTOSConfig.h
vendored
2
external/FreeRTOSConfig.h
vendored
@@ -166,7 +166,7 @@ header file. */
|
||||
standard names. */
|
||||
#define vPortSVCHandler _SVCallServiceRoutine
|
||||
#define xPortPendSVHandler _PendSVServiceRoutine
|
||||
#define xPortSysTickHandler _SystickServiceRoutine
|
||||
#define xPortSysTickHandler _SysTickServiceRoutine
|
||||
|
||||
#endif /* FREERTOS_CONFIG_H */
|
||||
|
||||
|
||||
Reference in New Issue
Block a user