kopia lustrzana https://github.com/majbthrd/pico-debug
114 wiersze
2.2 KiB
ArmAsm
114 wiersze
2.2 KiB
ArmAsm
/*****************************************************************************
|
|
* THIS FILE IS PROVIDED AS IS WITH NO WARRANTY OF ANY KIND, INCLUDING THE *
|
|
* WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. *
|
|
*****************************************************************************/
|
|
|
|
//#define STARTUP_FROM_RESET
|
|
|
|
.macro ISR_HANDLER name=
|
|
.section .vectors, "ax"
|
|
.word \name
|
|
.section .init, "ax"
|
|
.thumb_func
|
|
.weak \name
|
|
\name:
|
|
1: b 1b /* endless loop */
|
|
.endm
|
|
|
|
.macro ISR_RESERVED
|
|
.section .vectors, "ax"
|
|
.word 0
|
|
.endm
|
|
|
|
.syntax unified
|
|
.global reset_handler
|
|
|
|
.section .boot, "ax"
|
|
.thumb_func
|
|
|
|
reset_handler:
|
|
|
|
#ifndef __NO_SYSTEM_INIT
|
|
ldr r0, =__SRAM_segment_end__
|
|
mov sp, r0
|
|
bl SystemInit
|
|
#endif
|
|
|
|
#ifdef VECTORS_IN_RAM
|
|
ldr r0, =__vectors_load_start__
|
|
ldr r1, =__vectors_load_end__
|
|
ldr r2, =_vectors_ram
|
|
l0:
|
|
cmp r0, r1
|
|
beq l1
|
|
ldr r3, [r0]
|
|
str r3, [r2]
|
|
adds r0, r0, #4
|
|
adds r2, r2, #4
|
|
b l0
|
|
l1:
|
|
#endif
|
|
|
|
/* origin of user app */
|
|
#ifdef VECTORS_IN_RAM
|
|
ldr r1, =_vectors_ram
|
|
#else
|
|
ldr r1, =_vectors
|
|
#endif
|
|
ldr r0, =0xE000ED08 /* VTOR register */
|
|
str r1, [r0] /* point VTOR to user app */
|
|
ldr r0, [r1] /* load stack pointer from user app */
|
|
msr msp, r0
|
|
msr psp, r0
|
|
|
|
b _start
|
|
|
|
#ifndef __NO_SYSTEM_INIT
|
|
.thumb_func
|
|
.weak SystemInit
|
|
SystemInit:
|
|
bx lr
|
|
#endif
|
|
|
|
#ifndef STARTUP_FROM_RESET
|
|
.thumb_func
|
|
reset_wait:
|
|
1: b 1b /* endless loop */
|
|
#endif /* STARTUP_FROM_RESET */
|
|
|
|
.section .vectors, "ax"
|
|
.code 16
|
|
.global _vectors
|
|
.align 8
|
|
|
|
_vectors:
|
|
.word __stack_end__
|
|
#ifdef STARTUP_FROM_RESET
|
|
.word reset_handler
|
|
#else
|
|
.word reset_wait
|
|
#endif /* STARTUP_FROM_RESET */
|
|
ISR_HANDLER NMI_Handler
|
|
ISR_HANDLER HardFault_Handler
|
|
ISR_HANDLER MemManage_Handler
|
|
ISR_HANDLER BusFault_Handler
|
|
ISR_HANDLER UsageFault_Handler
|
|
ISR_RESERVED
|
|
ISR_RESERVED
|
|
ISR_RESERVED
|
|
ISR_RESERVED
|
|
ISR_HANDLER SVC_Handler
|
|
ISR_HANDLER DebugMon_Handler
|
|
ISR_RESERVED
|
|
ISR_HANDLER PendSV_Handler
|
|
ISR_HANDLER SysTick_Handler
|
|
#include "RP2040.vec"
|
|
.section .vectors, "ax"
|
|
_vectors_end:
|
|
|
|
#ifdef VECTORS_IN_RAM
|
|
.section .vectors_ram, "ax"
|
|
_vectors_ram:
|
|
.space _vectors_end-_vectors, 0
|
|
#endif
|