aboutsummaryrefslogtreecommitdiffstats
path: root/os
diff options
context:
space:
mode:
Diffstat (limited to 'os')
-rw-r--r--os/hal/osal/nil/osal.h17
-rw-r--r--os/hal/osal/rt/osal.h17
-rw-r--r--os/hal/templates/osal/osal.h2
-rw-r--r--os/nil/include/nil.h36
-rw-r--r--os/nil/ports/ARMCMx/nilcore.h16
-rw-r--r--os/nil/ports/ARMCMx/nilcore_v7m.h2
-rw-r--r--os/nil/templates/nilcore.h10
-rw-r--r--os/rt/include/chsys.h36
-rw-r--r--os/rt/ports/ARMCMx/chcore.h16
-rw-r--r--os/rt/ports/ARMCMx/chcore_v7m.h2
-rw-r--r--os/rt/templates/chcore.h10
11 files changed, 114 insertions, 50 deletions
diff --git a/os/hal/osal/nil/osal.h b/os/hal/osal/nil/osal.h
index c20e7ef15..84d83d8c2 100644
--- a/os/hal/osal/nil/osal.h
+++ b/os/hal/osal/nil/osal.h
@@ -109,21 +109,6 @@
#endif
/** @} */
-/**
- * @name IRQ-related constants
- * @{
- */
-/**
- * @brief Total priority levels.
- */
-#define OSAL_IRQ_PRIORITY_LEVELS CORTEX_PRIORITY_LEVELS
-
-/**
- * @brief Highest IRQ priority for HAL drivers.
- */
-#define OSAL_IRQ_MAXIMUM_PRIORITY CORTEX_MAX_KERNEL_PRIORITY
-/** @} */
-
/*===========================================================================*/
/* Module pre-compile time settings. */
/*===========================================================================*/
@@ -295,7 +280,7 @@ typedef struct {
/**
* @brief Priority level verification macro.
*/
-#define OSAL_IRQ_IS_VALID_PRIORITY(n) CORTEX_IS_VALID_KERNEL_PRIORITY(n)
+#define OSAL_IRQ_IS_VALID_PRIORITY(n) CH_IRQ_IS_VALID_KERNEL_PRIORITY(n)
/**
* @brief IRQ prologue code.
diff --git a/os/hal/osal/rt/osal.h b/os/hal/osal/rt/osal.h
index 0eff06a24..aae2b5d3f 100644
--- a/os/hal/osal/rt/osal.h
+++ b/os/hal/osal/rt/osal.h
@@ -105,21 +105,6 @@
#endif
/** @} */
-/**
- * @name IRQ-related constants
- * @{
- */
-/**
- * @brief Total priority levels.
- */
-#define OSAL_IRQ_PRIORITY_LEVELS CORTEX_PRIORITY_LEVELS
-
-/**
- * @brief Highest IRQ priority for HAL drivers.
- */
-#define OSAL_IRQ_MAXIMUM_PRIORITY CORTEX_MAX_KERNEL_PRIORITY
-/** @} */
-
/*===========================================================================*/
/* Module pre-compile time settings. */
/*===========================================================================*/
@@ -287,7 +272,7 @@ typedef struct {
/**
* @brief Priority level verification macro.
*/
-#define OSAL_IRQ_IS_VALID_PRIORITY(n) CORTEX_IS_VALID_KERNEL_PRIORITY(n)
+#define OSAL_IRQ_IS_VALID_PRIORITY(n) CH_IRQ_IS_VALID_KERNEL_PRIORITY(n)
/**
* @brief IRQ prologue code.
diff --git a/os/hal/templates/osal/osal.h b/os/hal/templates/osal/osal.h
index 1eb9ec5de..f73070aa4 100644
--- a/os/hal/templates/osal/osal.h
+++ b/os/hal/templates/osal/osal.h
@@ -102,11 +102,13 @@
*/
/**
* @brief Total priority levels.
+ * @brief Implementation not mandatory.
*/
#define OSAL_IRQ_PRIORITY_LEVELS 16U
/**
* @brief Highest IRQ priority for HAL drivers.
+ * @brief Implementation not mandatory.
*/
#define OSAL_IRQ_MAXIMUM_PRIORITY 0U
/** @} */
diff --git a/os/nil/include/nil.h b/os/nil/include/nil.h
index 23ebd05cf..3babb8da9 100644
--- a/os/nil/include/nil.h
+++ b/os/nil/include/nil.h
@@ -492,6 +492,42 @@ struct nil_system {
* @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.
* @note On some architectures this macro can be empty.
diff --git a/os/nil/ports/ARMCMx/nilcore.h b/os/nil/ports/ARMCMx/nilcore.h
index dd5756cf3..8cd0d117a 100644
--- a/os/nil/ports/ARMCMx/nilcore.h
+++ b/os/nil/ports/ARMCMx/nilcore.h
@@ -153,22 +153,22 @@ struct port_intctx {};
#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/nil/ports/ARMCMx/nilcore_v7m.h b/os/nil/ports/ARMCMx/nilcore_v7m.h
index 4e7829d2d..d6317024e 100644
--- a/os/nil/ports/ARMCMx/nilcore_v7m.h
+++ b/os/nil/ports/ARMCMx/nilcore_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/nil/templates/nilcore.h b/os/nil/templates/nilcore.h
index b2b71ce48..1aad42ddc 100644
--- a/os/nil/templates/nilcore.h
+++ b/os/nil/templates/nilcore.h
@@ -160,6 +160,16 @@ struct port_intctx {
(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
* enabled to invoke system APIs.
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
@@ -64,6 +64,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.
* @note On some architectures this macro can be empty.
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
@@ -180,6 +180,16 @@ struct context {
((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
* enabled to invoke system APIs.