Skip to content

Commit deb9d0a

Browse files
committed
Correct C lib hooks implementation for Cortex-A profile
1 parent d857efa commit deb9d0a

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

CMSIS/RTOS2/FreeRTOS/Source/clib_os.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,16 @@ void *__user_perthread_libspace (void) {
136136

137137
#ifndef RTE_CMSIS_Compiler_OS_Interface_RTOS2_LOCKS
138138

139+
#if (__ARM_ARCH_7A__ == 1U)
140+
/* CPSR mode bitmasks */
141+
#define CPSR_MODE_USER 0x10U
142+
#define CPSR_MODE_SYSTEM 0x1FU
143+
144+
#define IS_IRQ_MODE() ((__get_mode() != CPSR_MODE_USER) && (__get_mode() != CPSR_MODE_SYSTEM))
145+
#else
146+
#define IS_IRQ_MODE() (__get_IPSR() != 0U)
147+
#endif
148+
139149
/* Define the number of Mutexes used by standard C/C++ library for stream protection */
140150
#ifndef OS_MUTEX_CLIB_NUM
141151
#define OS_MUTEX_CLIB_NUM 5
@@ -156,7 +166,7 @@ __USED void _mutex_free (mutex *m);
156166

157167
/* Check if processor is in Thread or Handler mode */
158168
static uint32_t is_thread_mode (void) {
159-
if (__get_IPSR() == 0U) {
169+
if (IS_IRQ_MODE() != 0) {
160170
return 1U; /* Thread mode */
161171
} else {
162172
return 0U; /* Handler mode */

0 commit comments

Comments
 (0)