diff --git a/os/ports/GCC/ARMCMx/chcore.h b/os/ports/GCC/ARMCMx/chcore.h index 5d45b00fd..224d09c68 100644 --- a/os/ports/GCC/ARMCMx/chcore.h +++ b/os/ports/GCC/ARMCMx/chcore.h @@ -73,7 +73,8 @@ #define CORTEX_MAXIMUM_PRIORITY 0 /** - * @brief Disabled value for BASEPRI register. + * @brief Disabled value for BASEPRI register. + * @note ARMv7-M architecture only. */ #define CORTEX_BASEPRI_DISABLED 0 @@ -155,7 +156,9 @@ /** * @brief BASEPRI level within kernel lock. - * @note This value must not mask the SVCALL priority level. + * @note This value must not mask the SVCALL priority level or the + * kernel would hard fault. + * @note ARMv7-M architecture only. */ #ifndef CORTEX_BASEPRI_KERNEL #define CORTEX_BASEPRI_KERNEL CORTEX_PRIORITY_MASK(CORTEX_PRIORITY_SVCALL+1) @@ -204,7 +207,7 @@ #endif /*===========================================================================*/ -/* Port implementation part. */ +/* Port implementation part (common). */ /*===========================================================================*/ /** @@ -228,6 +231,27 @@ struct context { }; #endif +/** + * @brief Enforces a correct alignment for a stack area size value. + */ +#define STACK_ALIGN(n) ((((n) - 1) | (sizeof(stkalign_t) - 1)) + 1) + +/** + * @brief Computes the thread working area global size. + */ +#define THD_WA_SIZE(n) STACK_ALIGN(sizeof(Thread) + \ + sizeof(struct intctx) + \ + sizeof(struct extctx) + \ + (n) + (INT_REQUIRED_STACK)) + +/** + * @brief Static working area allocation. + * @details This macro is used to allocate a static thread working area + * aligned as both position and size. + */ +#define WORKING_AREA(s, n) stkalign_t s[THD_WA_SIZE(n) / sizeof(stkalign_t)]; + +/* Includes the architecture-specific implementation part.*/ #if defined(CH_ARCHITECTURE_ARM_v6M) #include "chcore_v6m.h" #elif defined(CH_ARCHITECTURE_ARM_v7M) diff --git a/os/ports/GCC/ARMCMx/chcore_v6m.h b/os/ports/GCC/ARMCMx/chcore_v6m.h index 7aff774bc..f031f6272 100644 --- a/os/ports/GCC/ARMCMx/chcore_v6m.h +++ b/os/ports/GCC/ARMCMx/chcore_v6m.h @@ -123,26 +123,6 @@ struct intctx { #define INT_REQUIRED_STACK 8 #endif -/** - * @brief Enforces a correct alignment for a stack area size value. - */ -#define STACK_ALIGN(n) ((((n) - 1) | (sizeof(stkalign_t) - 1)) + 1) - -/** - * @brief Computes the thread working area global size. - */ -#define THD_WA_SIZE(n) STACK_ALIGN(sizeof(Thread) + \ - sizeof(struct intctx) + \ - sizeof(struct extctx) + \ - (n) + (INT_REQUIRED_STACK)) - -/** - * @brief Static working area allocation. - * @details This macro is used to allocate a static thread working area - * aligned as both position and size. - */ -#define WORKING_AREA(s, n) stkalign_t s[THD_WA_SIZE(n) / sizeof(stkalign_t)]; - /** * @brief IRQ prologue code. * @details This macro must be inserted at the start of all IRQ handlers diff --git a/os/ports/GCC/ARMCMx/chcore_v7m.h b/os/ports/GCC/ARMCMx/chcore_v7m.h index 804f6357e..b575376ea 100644 --- a/os/ports/GCC/ARMCMx/chcore_v7m.h +++ b/os/ports/GCC/ARMCMx/chcore_v7m.h @@ -116,26 +116,6 @@ struct intctx { #define INT_REQUIRED_STACK 0 #endif -/** - * @brief Enforces a correct alignment for a stack area size value. - */ -#define STACK_ALIGN(n) ((((n) - 1) | (sizeof(stkalign_t) - 1)) + 1) - -/** - * @brief Computes the thread working area global size. - */ -#define THD_WA_SIZE(n) STACK_ALIGN(sizeof(Thread) + \ - sizeof(struct intctx) + \ - sizeof(struct extctx) + \ - (n) + (INT_REQUIRED_STACK)) - -/** - * @brief Static working area allocation. - * @details This macro is used to allocate a static thread working area - * aligned as both position and size. - */ -#define WORKING_AREA(s, n) stkalign_t s[THD_WA_SIZE(n) / sizeof(stkalign_t)]; - /** * @brief IRQ prologue code. * @details This macro must be inserted at the start of all IRQ handlers