[arm-m] add initial vector table and initialization code
This commit is contained in:
@@ -0,0 +1,75 @@
|
||||
#include <debug.h>
|
||||
#include <compiler.h>
|
||||
#include <stdint.h>
|
||||
|
||||
/* externals */
|
||||
extern unsigned int __data_start_rom, __data_start, __data_end;
|
||||
extern unsigned int __bss_start, __bss_end;
|
||||
|
||||
void _nmi(void)
|
||||
{
|
||||
printf("nmi\n");
|
||||
halt();
|
||||
}
|
||||
|
||||
void _hardfault(void)
|
||||
{
|
||||
printf("hardfault\n");
|
||||
halt();
|
||||
}
|
||||
|
||||
void _memmanage(void)
|
||||
{
|
||||
printf("memmanage\n");
|
||||
halt();
|
||||
}
|
||||
|
||||
void _busfault(void)
|
||||
{
|
||||
printf("busfault\n");
|
||||
halt();
|
||||
}
|
||||
|
||||
void _usagefault(void)
|
||||
{
|
||||
printf("usagefault\n");
|
||||
halt();
|
||||
}
|
||||
|
||||
void _svc(void)
|
||||
{
|
||||
printf("svc\n");
|
||||
halt();
|
||||
}
|
||||
|
||||
void _pendsv(void)
|
||||
{
|
||||
printf("pendsv\n");
|
||||
halt();
|
||||
}
|
||||
|
||||
void _systick(void)
|
||||
{
|
||||
printf("systick\n");
|
||||
halt();
|
||||
}
|
||||
|
||||
void _start(void)
|
||||
{
|
||||
/* copy data from rom */
|
||||
if (&__data_start != &__data_start_rom) {
|
||||
unsigned int *src = &__data_start_rom;
|
||||
unsigned int *dest = &__data_start;
|
||||
|
||||
while (dest != &__data_end)
|
||||
*dest++ = *src++;
|
||||
}
|
||||
|
||||
/* zero out bss */
|
||||
unsigned int *bss = &__bss_start;
|
||||
while (bss != &__bss_end)
|
||||
*bss++ = 0;
|
||||
|
||||
for (;;)
|
||||
;
|
||||
}
|
||||
|
||||
41
arch/arm/arm-m/vectab.c
Normal file
41
arch/arm/arm-m/vectab.c
Normal file
@@ -0,0 +1,41 @@
|
||||
#include <compiler.h>
|
||||
#include <stdint.h>
|
||||
|
||||
static uint8_t initial_stack[1024];
|
||||
|
||||
extern void _start(void);
|
||||
extern void _nmi(void);
|
||||
extern void _hardfault(void);
|
||||
extern void _memmanage(void);
|
||||
extern void _busfault(void);
|
||||
extern void _usagefault(void);
|
||||
extern void _svc(void);
|
||||
extern void _pendsv(void);
|
||||
extern void _pendsv(void);
|
||||
extern void _systick(void);
|
||||
|
||||
const void * const __SECTION(".text.boot") vectab[] =
|
||||
{
|
||||
/* arm exceptions */
|
||||
initial_stack + sizeof(initial_stack),
|
||||
_start,
|
||||
_nmi, // nmi
|
||||
_hardfault, // hard fault
|
||||
_memmanage, // mem manage
|
||||
_busfault, // bus fault
|
||||
_usagefault, // usage fault
|
||||
0, // reserved
|
||||
0, // reserved
|
||||
0, // reserved
|
||||
0, // reserved
|
||||
_svc, // svcall
|
||||
0, // debug monitor
|
||||
0, // reserved
|
||||
_pendsv, // pendsv
|
||||
_systick, // systick
|
||||
|
||||
// XXX include irq init from platform space here
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -117,6 +117,7 @@ OBJS += \
|
||||
endif
|
||||
ifeq ($(SUBARCH),arm-m)
|
||||
OBJS += \
|
||||
$(LOCAL_DIR)/arm-m/vectab.o \
|
||||
$(LOCAL_DIR)/arm-m/start.o \
|
||||
$(LOCAL_DIR)/arm-m/thread.o
|
||||
endif
|
||||
|
||||
@@ -7,7 +7,7 @@ SECTIONS
|
||||
. = %MEMBASE%;
|
||||
|
||||
/* text/read-only data */
|
||||
.text.boot : { *(.text.boot) }
|
||||
.text.boot : { KEEP(*(.text.boot)) }
|
||||
.text : { *(.text .text.* .glue_7* .gnu.linkonce.t.*) } =0x9090
|
||||
|
||||
.interp : { *(.interp) }
|
||||
@@ -73,6 +73,7 @@ SECTIONS
|
||||
.bss : { *(.bss .bss.*) }
|
||||
|
||||
. = ALIGN(4);
|
||||
__bss_end = .;
|
||||
_end = .;
|
||||
|
||||
. = %MEMBASE% + %MEMSIZE%;
|
||||
|
||||
@@ -7,7 +7,7 @@ SECTIONS
|
||||
. = %ROMBASE%;
|
||||
|
||||
/* text/read-only data */
|
||||
.text.boot : { *(.text.boot) }
|
||||
.text.boot : { KEEP(*(.text.boot)) }
|
||||
.text : { *(.text .text.* .glue_7* .gnu.linkonce.t.*) } =0x9090
|
||||
|
||||
.interp : { *(.interp) }
|
||||
@@ -76,6 +76,7 @@ SECTIONS
|
||||
.bss : { *(.bss .bss.*) }
|
||||
|
||||
. = ALIGN(4);
|
||||
__bss_end = .;
|
||||
_end = . ;
|
||||
|
||||
. = %MEMBASE% + %MEMSIZE%;
|
||||
|
||||
Reference in New Issue
Block a user