µOS++ IIIe Reference 7.0.0
The third edition of µOS++, a POSIX inspired open source framework, written in C++
Loading...
Searching...
No Matches
exception-handlers.h File Reference
#include <stdint.h>

Go to the source code of this file.

Classes

struct  exception_stack_frame_s
 

Typedefs

typedef struct exception_stack_frame_s exception_stack_frame_t
 

Functions

void HardFault_Handler (void)
 
void HardFault_Handler_C (exception_stack_frame_t *frame, uint32_t lr)
 
void NMI_Handler (void)
 
void PendSV_Handler (void)
 
void Reset_Handler (void)
 
void SVC_Handler (void)
 
void SysTick_Handler (void)
 

Typedef Documentation

◆ exception_stack_frame_t

Function Documentation

◆ HardFault_Handler()

void HardFault_Handler ( void  )

◆ HardFault_Handler_C()

void HardFault_Handler_C ( exception_stack_frame_t frame,
uint32_t  lr 
)

◆ NMI_Handler()

void NMI_Handler ( void  )

Definition at line 117 of file exception-handlers.c.

118{
119#if defined(DEBUG)
120#if defined(__ARM_ARCH_7M__) || defined(__ARM_ARCH_7EM__)
121 if ((CoreDebug->DHCSR & CoreDebug_DHCSR_C_DEBUGEN_Msk) != 0)
122 {
123 __BKPT (0);
124 }
125#else
126 __BKPT (0);
127#endif /* defined(__ARM_ARCH_7M__) || defined(__ARM_ARCH_7EM__) */
128#endif /* defined(DEBUG) */
129
130 while (true)
131 {
132 __NOP ();
133 }
134}

◆ PendSV_Handler()

void PendSV_Handler ( void  )

Definition at line 725 of file exception-handlers.c.

726{
727#if defined(DEBUG)
728#if defined(__ARM_ARCH_7M__) || defined(__ARM_ARCH_7EM__)
729 if ((CoreDebug->DHCSR & CoreDebug_DHCSR_C_DEBUGEN_Msk) != 0)
730 {
731 __BKPT (0);
732 }
733#else
734 __BKPT (0);
735#endif /* defined(__ARM_ARCH_7M__) || defined(__ARM_ARCH_7EM__) */
736#endif /* defined(DEBUG) */
737
738 while (true)
739 {
740 __NOP ();
741 }
742}

◆ Reset_Handler()

void Reset_Handler ( void  )

Definition at line 81 of file exception-handlers.c.

82{
83 // For just in case, when started via QEMU.
84 __asm__ (" MSR msp, %0 " : : "r"(&__stack) :);
85
86 // SCB
87 // https://developer.arm.com/documentation/dui0552/a/cortex-m3-peripherals/system-control-block
88
89 // SCB->VTOR
90 // https://developer.arm.com/documentation/dui0552/a/cortex-m3-peripherals/system-control-block/vector-table-offset-register
91 // Mandatory when running from RAM. Not available on Cortex-M0.
92#if defined(__ARM_ARCH_7M__) || defined(__ARM_ARCH_7EM__)
93 *((uint32_t*)0xE000ED08)
94 = ((uint32_t)_interrupt_vectors & (uint32_t)(~0x3F));
95#endif
96
97#if defined(__ARM_FP)
98 // Enable CP10 and CP11 coprocessor.
99 // SCB->CPACR |= (0xF << 20);
100 *((uint32_t*)0xE000ED88) |= (uint32_t)(0xF << 20);
101
102 // Lazy save.
103 // FPU->FPCCR |= FPU_FPCCR_ASPEN_Msk | FPU_FPCCR_LSPEN_Msk;
104 *((uint32_t*)0xE000EF34) |= (uint32_t)(0x3 << 29);
105#endif // defined(__ARM_FP)
106
107 // Fill the main stack with a pattern, to detect usage and underflow.
108 for (unsigned int* p = &_Heap_Limit; p < &__stack;)
109 {
110 *p++ = OS_INTEGER_RTOS_STACK_FILL_MAGIC; // DEADBEEF
111 }
112
113 _start ();
114}
unsigned int __stack
unsigned int _Heap_Limit
handler_ptr_t _interrupt_vectors[]
void _start(void)
The standard C application entry point.
Definition startup.cpp:241

References __stack, _Heap_Limit, _interrupt_vectors, and _start().

◆ SVC_Handler()

void SVC_Handler ( void  )

Definition at line 685 of file exception-handlers.c.

686{
687#if defined(DEBUG)
688#if defined(__ARM_ARCH_7M__) || defined(__ARM_ARCH_7EM__)
689 if ((CoreDebug->DHCSR & CoreDebug_DHCSR_C_DEBUGEN_Msk) != 0)
690 {
691 __BKPT (0);
692 }
693#else
694 __BKPT (0);
695#endif /* defined(__ARM_ARCH_7M__) || defined(__ARM_ARCH_7EM__) */
696#endif /* defined(DEBUG) */
697
698 while (true)
699 {
700 __NOP ();
701 }
702}

◆ SysTick_Handler()

void SysTick_Handler ( void  )

Definition at line 745 of file exception-handlers.c.

746{
747 // DO NOT loop, just return.
748 // Useful in case someone (like STM HAL) always enables SysTick.
749}