13#pragma clang diagnostic ignored "-Wempty-translation-unit"
18#if defined(__ARM_EABI__)
22#if defined(OS_USE_OS_APP_CONFIG_H)
23#include <cmsis-plus/os-app-config.h>
26#include <cmsis-plus/rtos/port/os-c-decls.h>
28#include <cmsis_device.h>
37#pragma GCC diagnostic push
38#pragma GCC diagnostic ignored "-Wredundant-decls"
40extern void __attribute__ ((noreturn, weak))
43#pragma GCC diagnostic pop
80void __attribute__ ((section (
".after_vectors"), noreturn, weak))
84 __asm__ (
" MSR msp, %0 " : :
"r"(&
__stack) :);
92#if defined(__ARM_ARCH_7M__) || defined(__ARM_ARCH_7EM__)
93 *((uint32_t*)0xE000ED08)
100 *((uint32_t*)0xE000ED88) |= (uint32_t)(0xF << 20);
104 *((uint32_t*)0xE000EF34) |= (uint32_t)(0x3 << 29);
110 *p++ = OS_INTEGER_RTOS_STACK_FILL_MAGIC;
116void __attribute__ ((section (
".after_vectors"), weak))
120#if defined(__ARM_ARCH_7M__) || defined(__ARM_ARCH_7EM__)
121 if ((CoreDebug->DHCSR & CoreDebug_DHCSR_C_DEBUGEN_Msk) != 0)
140#if defined(__ARM_ARCH_7M__) || defined(__ARM_ARCH_7EM__)
155 uint32_t mmfar, uint32_t bfar, uint32_t lr)
172 if (cfsr & (1UL << 7))
176 if (cfsr & (1UL << 15))
186#if defined(__ARM_ARCH_6M__)
210#if defined(__ARM_ARCH_7M__) || defined(__ARM_ARCH_7EM__)
212#if defined(OS_USE_SEMIHOSTING_SYSCALLS) \
213 || defined(OS_USE_TRACE_SEMIHOSTING_STDOUT) \
214 || defined(OS_USE_TRACE_SEMIHOSTING_DEBUG)
229 uint16_t* pw = (uint16_t*)frame->
pc;
232 uint32_t r0 = frame->
r0;
233#if defined(OS_DEBUG_SEMIHOSTING_FAULTS) \
234 || defined(OS_USE_SEMIHOSTING_SYSCALLS) \
235 || defined(OS_USE_TRACE_SEMIHOSTING_STDOUT)
236 uint32_t r1 = frame->
r1;
238#if defined(OS_USE_SEMIHOSTING_SYSCALLS) \
239 || defined(OS_USE_TRACE_SEMIHOSTING_STDOUT)
240 uint32_t* blk = (uint32_t*)r1;
243#if defined(OS_DEBUG_SEMIHOSTING_FAULTS)
250#if defined(OS_USE_SEMIHOSTING_SYSCALLS)
264 frame->
r0 = (uint32_t)-1;
313#if defined(OS_USE_SEMIHOSTING_SYSCALLS) \
314 || defined(OS_USE_TRACE_SEMIHOSTING_STDOUT)
316#define HANDLER_STDIN (1)
317#define HANDLER_STDOUT (2)
318#define HANDLER_STDERR (3)
322 if (strcmp ((
char*)blk[0],
":tt") == 0)
326 frame->
r0 = HANDLER_STDIN;
329 else if (blk[1] == 4)
331 frame->
r0 = HANDLER_STDOUT;
334 else if (blk[1] == 8)
336 frame->
r0 = HANDLER_STDERR;
341 frame->
r0 = (uint32_t)-1;
347 if ((blk[0] == HANDLER_STDOUT) || (blk[0] == HANDLER_STDERR))
349#if defined(OS_DEBUG_SEMIHOSTING_FAULTS)
351 = (uint32_t)blk[2] -
trace_write ((
char*)blk[1], blk[2]);
367#if defined(OS_USE_SEMIHOSTING_SYSCALLS) \
368 || defined(OS_USE_TRACE_SEMIHOSTING_STDOUT) \
369 || defined(OS_USE_TRACE_SEMIHOSTING_DEBUG)
372#if defined(OS_DEBUG_SEMIHOSTING_FAULTS)
374 char ch = *((
char*)r1);
382#if defined(OS_DEBUG_SEMIHOSTING_FAULTS)
384 char* p = ((
char*)r1);
414void __attribute__ ((section (
".after_vectors"), weak, naked))
417 __asm__
volatile (
" tst lr,#4 \n"
422 " ldr r2,=HardFault_Handler_C \n"
431void __attribute__ ((section (
".after_vectors"), weak, used))
433 uint32_t lr __attribute__ ((unused)))
436 uint32_t mmfar = SCB->MMFAR;
437 uint32_t bfar = SCB->BFAR;
438 uint32_t cfsr = SCB->CFSR;
441#if defined(OS_USE_SEMIHOSTING_SYSCALLS) \
442 || defined(OS_USE_TRACE_SEMIHOSTING_STDOUT) \
443 || defined(OS_USE_TRACE_SEMIHOSTING_DEBUG)
450 if (((SCB->DFSR & SCB_DFSR_BKPT_Msk) != 0)
451 && ((SCB->HFSR & SCB_HFSR_DEBUGEVT_Msk) != 0))
453 if (is_semihosting (frame, 0xBE00 + (
AngelSWI & 0xFF)))
456 SCB->HFSR = SCB_HFSR_DEBUGEVT_Msk;
467 dump_exception_stack (frame, cfsr, mmfar, bfar, lr);
471#if defined(__ARM_ARCH_7M__) || defined(__ARM_ARCH_7EM__)
472 if ((CoreDebug->DHCSR & CoreDebug_DHCSR_C_DEBUGEN_Msk) != 0)
489#if defined(__ARM_ARCH_6M__)
498void __attribute__ ((section (
".after_vectors"), weak, naked))
501 __asm__
volatile (
" movs r0,#4 \n"
511 " ldr r2,=HardFault_Handler_C \n"
520void __attribute__ ((section (
".after_vectors"), weak, used))
522 uint32_t lr __attribute__ ((unused)))
529 dump_exception_stack (frame, lr);
533#if defined(__ARM_ARCH_7M__) || defined(__ARM_ARCH_7EM__)
534 if ((CoreDebug->DHCSR & CoreDebug_DHCSR_C_DEBUGEN_Msk) != 0)
551#if defined(__ARM_ARCH_7M__) || defined(__ARM_ARCH_7EM__)
553void __attribute__ ((section (
".after_vectors"), weak))
554MemManage_Handler (
void)
557#if defined(__ARM_ARCH_7M__) || defined(__ARM_ARCH_7EM__)
558 if ((CoreDebug->DHCSR & CoreDebug_DHCSR_C_DEBUGEN_Msk) != 0)
573void __attribute__ ((section (
".after_vectors"), weak, naked))
574BusFault_Handler (
void)
576 __asm__
volatile (
" tst lr,#4 \n"
581 " ldr r2,=BusFault_Handler_C \n"
590void __attribute__ ((section (
".after_vectors"), weak, used))
592 uint32_t lr __attribute__ ((unused)))
595 uint32_t mmfar = SCB->MMFAR;
596 uint32_t bfar = SCB->BFAR;
597 uint32_t cfsr = SCB->CFSR;
600 dump_exception_stack (frame, cfsr, mmfar, bfar, lr);
604#if defined(__ARM_ARCH_7M__) || defined(__ARM_ARCH_7EM__)
605 if ((CoreDebug->DHCSR & CoreDebug_DHCSR_C_DEBUGEN_Msk) != 0)
620void __attribute__ ((section (
".after_vectors"), weak, naked))
621UsageFault_Handler (
void)
623 __asm__
volatile (
" tst lr,#4 \n"
628 " ldr r2,=UsageFault_Handler_C \n"
637void __attribute__ ((section (
".after_vectors"), weak, used))
639 uint32_t lr __attribute__ ((unused)))
642 uint32_t mmfar = SCB->MMFAR;
643 uint32_t bfar = SCB->BFAR;
644 uint32_t cfsr = SCB->CFSR;
647#if defined(OS_DEBUG_SEMIHOSTING_FAULTS)
649 if ((cfsr & (1UL << 16)) != 0)
652 if (is_semihosting (frame, AngelSWITestFaultOpCode))
662 dump_exception_stack (frame, cfsr, mmfar, bfar, lr);
666#if defined(__ARM_ARCH_7M__) || defined(__ARM_ARCH_7EM__)
667 if ((CoreDebug->DHCSR & CoreDebug_DHCSR_C_DEBUGEN_Msk) != 0)
684void __attribute__ ((section (
".after_vectors"), weak))
688#if defined(__ARM_ARCH_7M__) || defined(__ARM_ARCH_7EM__)
689 if ((CoreDebug->DHCSR & CoreDebug_DHCSR_C_DEBUGEN_Msk) != 0)
704#if defined(__ARM_ARCH_7M__) || defined(__ARM_ARCH_7EM__)
706void __attribute__ ((section (
".after_vectors"), weak))
707DebugMon_Handler (
void)
710 if ((CoreDebug->DHCSR & CoreDebug_DHCSR_C_DEBUGEN_Msk) != 0)
724void __attribute__ ((section (
".after_vectors"), weak))
728#if defined(__ARM_ARCH_7M__) || defined(__ARM_ARCH_7EM__)
729 if ((CoreDebug->DHCSR & CoreDebug_DHCSR_C_DEBUGEN_Msk) != 0)
744void __attribute__ ((section (
".after_vectors"), weak))
void PendSV_Handler(void)
void SysTick_Handler(void)
handler_ptr_t _interrupt_vectors[]
void(* handler_ptr_t)(void)
void HardFault_Handler(void)
void HardFault_Handler_C(exception_stack_frame_t *frame, uint32_t lr)
void _start(void)
The standard C application entry point.
@ SEMIHOSTING_SYS_TICKFREQ
@ SEMIHOSTING_ReportException
@ SEMIHOSTING_SYS_ISERROR
@ SEMIHOSTING_SYS_GET_CMDLINE
@ SEMIHOSTING_SYS_HEAPINFO
@ SEMIHOSTING_SYS_ELAPSED
int trace_printf(const char *format,...)
ssize_t trace_write(const void *buf, size_t nbyte)