29#pragma clang diagnostic ignored "-Wempty-translation-unit"
34#if defined(__ARM_EABI__)
38#include <cmsis-plus/os-app-config.h>
39#include <cmsis-plus/rtos/port/os-c-decls.h>
41#include <cmsis_device.h>
50extern void __attribute__((noreturn,weak))
84void __attribute__ ((section(
".after_vectors"),noreturn,weak))
90 *p++ = OS_INTEGER_RTOS_STACK_FILL_MAGIC;
96void __attribute__ ((section(
".after_vectors"),weak))
100#if defined(__ARM_ARCH_7M__) || defined(__ARM_ARCH_7EM__)
101 if ((CoreDebug->DHCSR & CoreDebug_DHCSR_C_DEBUGEN_Msk) != 0)
120#if defined(__ARM_ARCH_7M__) || defined(__ARM_ARCH_7EM__)
135 uint32_t mmfar, uint32_t bfar, uint32_t lr)
152 if (cfsr & (1UL << 7))
156 if (cfsr & (1UL << 15))
166#if defined(__ARM_ARCH_6M__)
190#if defined(__ARM_ARCH_7M__) || defined(__ARM_ARCH_7EM__)
192#if defined(OS_USE_SEMIHOSTING_SYSCALLS) \
193 || defined(OS_USE_TRACE_SEMIHOSTING_STDOUT) \
194 || defined(OS_USE_TRACE_SEMIHOSTING_DEBUG)
208 uint16_t* pw = (uint16_t*) frame->
pc;
211 uint32_t r0 = frame->
r0;
212#if defined(OS_DEBUG_SEMIHOSTING_FAULTS) \
213 || defined(OS_USE_SEMIHOSTING_SYSCALLS) \
214 || defined(OS_USE_TRACE_SEMIHOSTING_STDOUT)
215 uint32_t r1 = frame->
r1;
217#if defined(OS_USE_SEMIHOSTING_SYSCALLS) || defined(OS_USE_TRACE_SEMIHOSTING_STDOUT)
218 uint32_t* blk = (uint32_t*) r1;
221#if defined(OS_DEBUG_SEMIHOSTING_FAULTS)
228#if defined(OS_USE_SEMIHOSTING_SYSCALLS)
242 frame->
r0 = (uint32_t) -1;
291#if defined(OS_USE_SEMIHOSTING_SYSCALLS) || defined(OS_USE_TRACE_SEMIHOSTING_STDOUT)
293#define HANDLER_STDIN (1)
294#define HANDLER_STDOUT (2)
295#define HANDLER_STDERR (3)
299 if (strcmp ((
char*) blk[0],
":tt") == 0)
303 frame->
r0 = HANDLER_STDIN;
306 else if (blk[1] == 4)
308 frame->
r0 = HANDLER_STDOUT;
311 else if (blk[1] == 8)
313 frame->
r0 = HANDLER_STDERR;
318 frame->
r0 = (uint32_t) -1;
323 if ((blk[0] == HANDLER_STDOUT) || (blk[0] == HANDLER_STDERR))
325#if defined(OS_DEBUG_SEMIHOSTING_FAULTS)
326 frame->
r0 = (uint32_t) blk[2]
342#if defined(OS_USE_SEMIHOSTING_SYSCALLS) \
343 || defined(OS_USE_TRACE_SEMIHOSTING_STDOUT) \
344 || defined(OS_USE_TRACE_SEMIHOSTING_DEBUG)
347#if defined(OS_DEBUG_SEMIHOSTING_FAULTS)
349 char ch = *((
char*) r1);
357#if defined(OS_DEBUG_SEMIHOSTING_FAULTS)
359 char* p = ((
char*) r1);
389void __attribute__ ((section(
".after_vectors"),weak,naked))
398 " ldr r2,=HardFault_Handler_C \n"
407void __attribute__ ((section(
".after_vectors"),weak,used))
409 uint32_t lr __attribute__((unused)))
412 uint32_t mmfar = SCB->MMFAR;
413 uint32_t bfar = SCB->BFAR;
414 uint32_t cfsr = SCB->CFSR;
417#if defined(OS_USE_SEMIHOSTING_SYSCALLS) \
418 || defined(OS_USE_TRACE_SEMIHOSTING_STDOUT) \
419 || defined(OS_USE_TRACE_SEMIHOSTING_DEBUG)
426 if (((SCB->DFSR & SCB_DFSR_BKPT_Msk) != 0)
427 && ((SCB->HFSR & SCB_HFSR_DEBUGEVT_Msk) != 0))
429 if (is_semihosting (frame, 0xBE00 + (
AngelSWI & 0xFF)))
432 SCB->HFSR = SCB_HFSR_DEBUGEVT_Msk;
443 dump_exception_stack (frame, cfsr, mmfar, bfar, lr);
447#if defined(__ARM_ARCH_7M__) || defined(__ARM_ARCH_7EM__)
448 if ((CoreDebug->DHCSR & CoreDebug_DHCSR_C_DEBUGEN_Msk) != 0)
465#if defined(__ARM_ARCH_6M__)
474void __attribute__ ((section(
".after_vectors"),weak,naked))
488 " ldr r2,=HardFault_Handler_C \n"
497void __attribute__ ((section(
".after_vectors"),weak,used))
499 uint32_t lr __attribute__((unused)))
506 dump_exception_stack (frame, lr);
510#if defined(__ARM_ARCH_7M__) || defined(__ARM_ARCH_7EM__)
511 if ((CoreDebug->DHCSR & CoreDebug_DHCSR_C_DEBUGEN_Msk) != 0)
528#if defined(__ARM_ARCH_7M__) || defined(__ARM_ARCH_7EM__)
530void __attribute__ ((section(
".after_vectors"),weak))
531MemManage_Handler (
void)
534#if defined(__ARM_ARCH_7M__) || defined(__ARM_ARCH_7EM__)
535 if ((CoreDebug->DHCSR & CoreDebug_DHCSR_C_DEBUGEN_Msk) != 0)
550void __attribute__ ((section(
".after_vectors"),weak,naked))
551BusFault_Handler (
void)
559 " ldr r2,=BusFault_Handler_C \n"
568void __attribute__ ((section(
".after_vectors"),weak,used))
570 uint32_t lr __attribute__((unused)))
573 uint32_t mmfar = SCB->MMFAR;
574 uint32_t bfar = SCB->BFAR;
575 uint32_t cfsr = SCB->CFSR;
578 dump_exception_stack (frame, cfsr, mmfar, bfar, lr);
582#if defined(__ARM_ARCH_7M__) || defined(__ARM_ARCH_7EM__)
583 if ((CoreDebug->DHCSR & CoreDebug_DHCSR_C_DEBUGEN_Msk) != 0)
598void __attribute__ ((section(
".after_vectors"),weak,naked))
599UsageFault_Handler (
void)
607 " ldr r2,=UsageFault_Handler_C \n"
616void __attribute__ ((section(
".after_vectors"),weak,used))
618 uint32_t lr __attribute__((unused)))
621 uint32_t mmfar = SCB->MMFAR;
622 uint32_t bfar = SCB->BFAR;
623 uint32_t cfsr = SCB->CFSR;
626#if defined(OS_DEBUG_SEMIHOSTING_FAULTS)
628 if ((cfsr & (1UL << 16)) != 0)
631 if (is_semihosting (frame, AngelSWITestFaultOpCode))
641 dump_exception_stack (frame, cfsr, mmfar, bfar, lr);
645#if defined(__ARM_ARCH_7M__) || defined(__ARM_ARCH_7EM__)
646 if ((CoreDebug->DHCSR & CoreDebug_DHCSR_C_DEBUGEN_Msk) != 0)
663void __attribute__ ((section(
".after_vectors"),weak))
667#if defined(__ARM_ARCH_7M__) || defined(__ARM_ARCH_7EM__)
668 if ((CoreDebug->DHCSR & CoreDebug_DHCSR_C_DEBUGEN_Msk) != 0)
683#if defined(__ARM_ARCH_7M__) || defined(__ARM_ARCH_7EM__)
685void __attribute__ ((section(
".after_vectors"),weak))
686DebugMon_Handler (
void)
689 if ((CoreDebug->DHCSR & CoreDebug_DHCSR_C_DEBUGEN_Msk) != 0)
703void __attribute__ ((section(
".after_vectors"),weak))
707#if defined(__ARM_ARCH_7M__) || defined(__ARM_ARCH_7EM__)
708 if ((CoreDebug->DHCSR & CoreDebug_DHCSR_C_DEBUGEN_Msk) != 0)
723void __attribute__ ((section(
".after_vectors"),weak))
void PendSV_Handler(void)
void SysTick_Handler(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.
void NVIC_SystemReset(void)
@ 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)