14#pragma clang diagnostic ignored "-Wempty-translation-unit"
19#if defined(__ARM_EABI__)
23#if defined(OS_USE_OS_APP_CONFIG_H)
24#include <cmsis-plus/os-app-config.h>
27#include <cmsis-plus/rtos/port/os-c-decls.h>
29#include <cmsis_device.h>
38#pragma GCC diagnostic push
39#pragma GCC diagnostic ignored "-Wredundant-decls"
41extern void __attribute__((noreturn,weak))
44#pragma GCC diagnostic pop
82void __attribute__ ((section(
".after_vectors"),noreturn, weak))
86 __asm__(
" MSR msp, %0 " : :
"r"(&
__stack) :);
94#if defined(__ARM_ARCH_7M__) || defined(__ARM_ARCH_7EM__)
95 *((uint32_t*)0xE000ED08)
102 *((uint32_t*)0xE000ED88) |= (uint32_t)(0xF << 20);
106 *((uint32_t*)0xE000EF34) |= (uint32_t)(0x3 << 29);
112 *p++ = OS_INTEGER_RTOS_STACK_FILL_MAGIC;
118void __attribute__ ((section(
".after_vectors"),weak))
122#if defined(__ARM_ARCH_7M__) || defined(__ARM_ARCH_7EM__)
123 if ((CoreDebug->DHCSR & CoreDebug_DHCSR_C_DEBUGEN_Msk) != 0)
142#if defined(__ARM_ARCH_7M__) || defined(__ARM_ARCH_7EM__)
157 uint32_t mmfar, uint32_t bfar, uint32_t lr)
174 if (cfsr & (1UL << 7))
178 if (cfsr & (1UL << 15))
188#if defined(__ARM_ARCH_6M__)
212#if defined(__ARM_ARCH_7M__) || defined(__ARM_ARCH_7EM__)
214#if defined(OS_USE_SEMIHOSTING_SYSCALLS) \
215 || defined(OS_USE_TRACE_SEMIHOSTING_STDOUT) \
216 || defined(OS_USE_TRACE_SEMIHOSTING_DEBUG)
230 uint16_t* pw = (uint16_t*) frame->
pc;
233 uint32_t r0 = frame->
r0;
234#if defined(OS_DEBUG_SEMIHOSTING_FAULTS) \
235 || defined(OS_USE_SEMIHOSTING_SYSCALLS) \
236 || defined(OS_USE_TRACE_SEMIHOSTING_STDOUT)
237 uint32_t r1 = frame->
r1;
239#if defined(OS_USE_SEMIHOSTING_SYSCALLS) || 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) || defined(OS_USE_TRACE_SEMIHOSTING_STDOUT)
315#define HANDLER_STDIN (1)
316#define HANDLER_STDOUT (2)
317#define HANDLER_STDERR (3)
321 if (strcmp ((
char*) blk[0],
":tt") == 0)
325 frame->
r0 = HANDLER_STDIN;
328 else if (blk[1] == 4)
330 frame->
r0 = HANDLER_STDOUT;
333 else if (blk[1] == 8)
335 frame->
r0 = HANDLER_STDERR;
340 frame->
r0 = (uint32_t) -1;
345 if ((blk[0] == HANDLER_STDOUT) || (blk[0] == HANDLER_STDERR))
347#if defined(OS_DEBUG_SEMIHOSTING_FAULTS)
348 frame->
r0 = (uint32_t) blk[2]
364#if defined(OS_USE_SEMIHOSTING_SYSCALLS) \
365 || defined(OS_USE_TRACE_SEMIHOSTING_STDOUT) \
366 || defined(OS_USE_TRACE_SEMIHOSTING_DEBUG)
369#if defined(OS_DEBUG_SEMIHOSTING_FAULTS)
371 char ch = *((
char*) r1);
379#if defined(OS_DEBUG_SEMIHOSTING_FAULTS)
381 char* p = ((
char*) r1);
411void __attribute__ ((section(
".after_vectors"),weak,naked))
420 " ldr r2,=HardFault_Handler_C \n"
429void __attribute__ ((section(
".after_vectors"),weak,used))
431 uint32_t lr __attribute__((unused)))
434 uint32_t mmfar = SCB->MMFAR;
435 uint32_t bfar = SCB->BFAR;
436 uint32_t cfsr = SCB->CFSR;
439#if defined(OS_USE_SEMIHOSTING_SYSCALLS) \
440 || defined(OS_USE_TRACE_SEMIHOSTING_STDOUT) \
441 || defined(OS_USE_TRACE_SEMIHOSTING_DEBUG)
448 if (((SCB->DFSR & SCB_DFSR_BKPT_Msk) != 0)
449 && ((SCB->HFSR & SCB_HFSR_DEBUGEVT_Msk) != 0))
451 if (is_semihosting (frame, 0xBE00 + (
AngelSWI & 0xFF)))
454 SCB->HFSR = SCB_HFSR_DEBUGEVT_Msk;
465 dump_exception_stack (frame, cfsr, mmfar, bfar, lr);
469#if defined(__ARM_ARCH_7M__) || defined(__ARM_ARCH_7EM__)
470 if ((CoreDebug->DHCSR & CoreDebug_DHCSR_C_DEBUGEN_Msk) != 0)
487#if defined(__ARM_ARCH_6M__)
496void __attribute__ ((section(
".after_vectors"),weak,naked))
510 " ldr r2,=HardFault_Handler_C \n"
519void __attribute__ ((section(
".after_vectors"),weak,used))
521 uint32_t lr __attribute__((unused)))
528 dump_exception_stack (frame, lr);
532#if defined(__ARM_ARCH_7M__) || defined(__ARM_ARCH_7EM__)
533 if ((CoreDebug->DHCSR & CoreDebug_DHCSR_C_DEBUGEN_Msk) != 0)
550#if defined(__ARM_ARCH_7M__) || defined(__ARM_ARCH_7EM__)
552void __attribute__ ((section(
".after_vectors"),weak))
553MemManage_Handler (
void)
556#if defined(__ARM_ARCH_7M__) || defined(__ARM_ARCH_7EM__)
557 if ((CoreDebug->DHCSR & CoreDebug_DHCSR_C_DEBUGEN_Msk) != 0)
572void __attribute__ ((section(
".after_vectors"),weak,naked))
573BusFault_Handler (
void)
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)
629 " ldr r2,=UsageFault_Handler_C \n"
638void __attribute__ ((section(
".after_vectors"),weak,used))
640 uint32_t lr __attribute__((unused)))
643 uint32_t mmfar = SCB->MMFAR;
644 uint32_t bfar = SCB->BFAR;
645 uint32_t cfsr = SCB->CFSR;
648#if defined(OS_DEBUG_SEMIHOSTING_FAULTS)
650 if ((cfsr & (1UL << 16)) != 0)
653 if (is_semihosting (frame, AngelSWITestFaultOpCode))
663 dump_exception_stack (frame, cfsr, mmfar, bfar, lr);
667#if defined(__ARM_ARCH_7M__) || defined(__ARM_ARCH_7EM__)
668 if ((CoreDebug->DHCSR & CoreDebug_DHCSR_C_DEBUGEN_Msk) != 0)
685void __attribute__ ((section(
".after_vectors"),weak))
689#if defined(__ARM_ARCH_7M__) || defined(__ARM_ARCH_7EM__)
690 if ((CoreDebug->DHCSR & CoreDebug_DHCSR_C_DEBUGEN_Msk) != 0)
705#if defined(__ARM_ARCH_7M__) || defined(__ARM_ARCH_7EM__)
707void __attribute__ ((section(
".after_vectors"),weak))
708DebugMon_Handler (
void)
711 if ((CoreDebug->DHCSR & CoreDebug_DHCSR_C_DEBUGEN_Msk) != 0)
725void __attribute__ ((section(
".after_vectors"),weak))
729#if defined(__ARM_ARCH_7M__) || defined(__ARM_ARCH_7EM__)
730 if ((CoreDebug->DHCSR & CoreDebug_DHCSR_C_DEBUGEN_Msk) != 0)
745void __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)