From 25c944f87f69c46efe23e998152c9c48365e51b0 Mon Sep 17 00:00:00 2001 From: Giovanni Di Sirio Date: Fri, 27 Mar 2015 09:51:45 +0000 Subject: git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@7816 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/rt/include/chsys.h | 36 ++++++++++++++++++++++++++++++++++++ os/rt/ports/ARMCMx/chcore.h | 16 ++++++++-------- os/rt/ports/ARMCMx/chcore_v7m.h | 2 +- os/rt/templates/chcore.h | 10 ++++++++++ 4 files changed, 55 insertions(+), 9 deletions(-) (limited to 'os/rt') diff --git a/os/rt/include/chsys.h b/os/rt/include/chsys.h index 888e98b5c..9d1bff204 100644 --- a/os/rt/include/chsys.h +++ b/os/rt/include/chsys.h @@ -63,6 +63,42 @@ /** * @name ISRs abstraction macros */ +/** + * @brief Priority level validation macro. + * @details This macro determines if the passed value is a valid priority + * level for the underlying architecture. + * + * @param[in] prio the priority level + * @return Priority range result. + * @false if the priority is invalid or if the architecture + * does not support priorities. + * @true if the priority is valid. + */ +#if defined(PORT_IRQ_IS_VALID_PRIORITY) || defined(__DOXYGEN__) +#define CH_IRQ_IS_VALID_PRIORITY(prio) \ + PORT_IRQ_IS_VALID_PRIORITY(prio) +#else +#define CH_IRQ_IS_VALID_PRIORITY(prio) false +#endif + +/** + * @brief Priority level validation macro. + * @details This macro determines if the passed value is a valid priority + * level that cannot preempt the kernel critical zone. + * + * @param[in] prio the priority level + * @return Priority range result. + * @false if the priority is invalid or if the architecture + * does not support priorities. + * @true if the priority is valid. + */ +#if defined(PORT_IRQ_IS_VALID_KERNEL_PRIORITY) || defined(__DOXYGEN__) +#define CH_IRQ_IS_VALID_KERNEL_PRIORITY(prio) \ + PORT_IRQ_IS_VALID_KERNEL_PRIORITY(prio) +#else +#define CH_IRQ_IS_VALID_KERNEL_PRIORITY(prio) false +#endif + /** * @brief IRQ handler enter code. * @note Usually IRQ handlers functions are also declared naked. diff --git a/os/rt/ports/ARMCMx/chcore.h b/os/rt/ports/ARMCMx/chcore.h index abf0b4596..11d14234e 100644 --- a/os/rt/ports/ARMCMx/chcore.h +++ b/os/rt/ports/ARMCMx/chcore.h @@ -163,22 +163,22 @@ struct context { #define CORTEX_MAXIMUM_PRIORITY 0U /** - * @brief Priority level verification macro. + * @brief Priority level to priority mask conversion macro. */ -#define CORTEX_IS_VALID_PRIORITY(n) \ - (((n) >= 0) && ((n) < CORTEX_PRIORITY_LEVELS)) +#define CORTEX_PRIO_MASK(n) \ + ((n) << (8U - (unsigned)CORTEX_PRIORITY_BITS)) /** * @brief Priority level verification macro. */ -#define CORTEX_IS_VALID_KERNEL_PRIORITY(n) \ - (((n) >= CORTEX_MAX_KERNEL_PRIORITY) && ((n) < CORTEX_PRIORITY_LEVELS)) +#define PORT_IRQ_IS_VALID_PRIORITY(n) \ + (((n) >= 0U) && ((n) < CORTEX_PRIORITY_LEVELS)) /** - * @brief Priority level to priority mask conversion macro. + * @brief Priority level verification macro. */ -#define CORTEX_PRIO_MASK(n) \ - ((n) << (8U - (unsigned)CORTEX_PRIORITY_BITS)) +#define PORT_IRQ_IS_VALID_KERNEL_PRIORITY(n) \ + (((n) >= CORTEX_MAX_KERNEL_PRIORITY) && ((n) < CORTEX_PRIORITY_LEVELS)) /*===========================================================================*/ /* External declarations. */ diff --git a/os/rt/ports/ARMCMx/chcore_v7m.h b/os/rt/ports/ARMCMx/chcore_v7m.h index b437a8fad..37e087102 100644 --- a/os/rt/ports/ARMCMx/chcore_v7m.h +++ b/os/rt/ports/ARMCMx/chcore_v7m.h @@ -110,7 +110,7 @@ */ #if !defined(CORTEX_PRIORITY_SVCALL) #define CORTEX_PRIORITY_SVCALL (CORTEX_MAXIMUM_PRIORITY + 1U) -#elif !CORTEX_IS_VALID_PRIORITY(CORTEX_PRIORITY_SVCALL) +#elif !PORT_IRQ_IS_VALID_PRIORITY(CORTEX_PRIORITY_SVCALL) /* If it is externally redefined then better perform a validity check on it.*/ #error "invalid priority level specified for CORTEX_PRIORITY_SVCALL" #endif diff --git a/os/rt/templates/chcore.h b/os/rt/templates/chcore.h index 39d173608..bcc47a0f4 100644 --- a/os/rt/templates/chcore.h +++ b/os/rt/templates/chcore.h @@ -179,6 +179,16 @@ struct context { sizeof(struct port_extctx) + \ ((size_t)(n)) + ((size_t)(PORT_INT_REQUIRED_STACK))) +/** + * @brief Priority level verification macro. + */ +#define PORT_IRQ_IS_VALID_PRIORITY(n) false + +/** + * @brief Priority level verification macro. + */ +#define PORT_IRQ_IS_VALID_KERNEL_PRIORITY(n) false + /** * @brief IRQ prologue code. * @details This macro must be inserted at the start of all IRQ handlers -- cgit v1.2.3