From a71a2c173310bc6e0dd37bf1d32dd290f6866435 Mon Sep 17 00:00:00 2001 From: Giovanni Di Sirio Date: Sat, 9 Nov 2019 08:07:20 +0000 Subject: [PATCH] Fixed bug #1056. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@13160 27425a3e-05d8-49a3-a47f-9c15f0e5edd8 --- os/hal/osal/os-less/ARMCMx/osal.h | 15 +++++++++------ readme.txt | 2 ++ 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/os/hal/osal/os-less/ARMCMx/osal.h b/os/hal/osal/os-less/ARMCMx/osal.h index 14ba6b115..5cbd6630b 100644 --- a/os/hal/osal/os-less/ARMCMx/osal.h +++ b/os/hal/osal/os-less/ARMCMx/osal.h @@ -112,6 +112,11 @@ #else #define OSAL_IRQ_MAXIMUM_PRIORITY 1 #endif + +/** + * @brief Converts from numeric priority to BASEPRI register value. + */ +#define OSAL_BASEPRI(priority) ((priority) << (8U - CORTEX_PRIORITY_BITS)) /** @} */ /*===========================================================================*/ @@ -556,7 +561,7 @@ static inline void osalSysLock(void) { #if CORTEX_MODEL == 0 __disable_irq(); #else - __set_BASEPRI(OSAL_IRQ_MAXIMUM_PRIORITY); + __set_BASEPRI(OSAL_BASEPRI(OSAL_IRQ_MAXIMUM_PRIORITY)); #endif } @@ -586,7 +591,7 @@ static inline void osalSysLockFromISR(void) { #if CORTEX_MODEL == 0 __disable_irq(); #else - __set_BASEPRI(OSAL_IRQ_MAXIMUM_PRIORITY); + __set_BASEPRI(OSAL_BASEPRI(OSAL_IRQ_MAXIMUM_PRIORITY)); #endif } @@ -626,7 +631,7 @@ static inline syssts_t osalSysGetStatusAndLockX(void) { __disable_irq(); #else sts = (syssts_t)__get_BASEPRI(); - __set_BASEPRI(OSAL_IRQ_MAXIMUM_PRIORITY); + __set_BASEPRI(OSAL_BASEPRI(OSAL_IRQ_MAXIMUM_PRIORITY)); #endif return sts; } @@ -647,9 +652,7 @@ static inline void osalSysRestoreStatusX(syssts_t sts) { __enable_irq(); } #else - if (sts == (syssts_t)0) { - __set_BASEPRI(0); - } + __set_BASEPRI(sts); #endif } diff --git a/readme.txt b/readme.txt index 6b5a15f77..e514b02ba 100644 --- a/readme.txt +++ b/readme.txt @@ -133,6 +133,8 @@ - HAL: Added a new interface for range-finder devices (used by EX). - HAL: Added mcuconf.h updater tool for STM32F407 (backported to 19.1.1). - NIL: Integrated NIL 4.0. +- FIX: Fixed OS-less Cortex-M OSAL problem with critical zones (bug #1056) + (backported to 19.1.4)(backported to 18.2.3). - FIX: Fixed missing RTCv1 definitions in STM32F37x registry (bug #1054) (backported to 19.1.4). - FIX: Fixed assertion triggered in STM32 OTGv1 driver (bug #1053)