aboutsummaryrefslogtreecommitdiffstats
path: root/os/rt/ports
diff options
context:
space:
mode:
authorgdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2014-06-04 09:40:31 +0000
committergdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2014-06-04 09:40:31 +0000
commit1859a4ba0957bb9aabf1a07feb96a52c9f95ecf7 (patch)
tree77dc730d9250b906926a2275cc9409e0a83b1cfe /os/rt/ports
parent31774bb3d79d528926bf2c0dffa951bda0ba56f1 (diff)
downloadChibiOS-1859a4ba0957bb9aabf1a07feb96a52c9f95ecf7.tar.gz
ChibiOS-1859a4ba0957bb9aabf1a07feb96a52c9f95ecf7.tar.bz2
ChibiOS-1859a4ba0957bb9aabf1a07feb96a52c9f95ecf7.zip
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@6981 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'os/rt/ports')
-rw-r--r--os/rt/ports/ARM/chcore.h67
-rw-r--r--os/rt/ports/ARM/compilers/GCC/chcoreasm.s15
-rw-r--r--os/rt/ports/ARMCMx/chcore_v6m.h2
-rw-r--r--os/rt/ports/ARMCMx/chcore_v7m.h6
4 files changed, 84 insertions, 6 deletions
diff --git a/os/rt/ports/ARM/chcore.h b/os/rt/ports/ARM/chcore.h
index 06b4bb8ed..bafa42ffa 100644
--- a/os/rt/ports/ARM/chcore.h
+++ b/os/rt/ports/ARM/chcore.h
@@ -338,6 +338,9 @@ struct context {
#ifdef __cplusplus
extern "C" {
#endif
+#ifdef THUMB_PRESENT
+ syssts_t _port_get_cpsr(void);
+#endif
#ifdef THUMB
void _port_switch_thumb(thread_t *ntp, thread_t *otp);
#else
@@ -360,6 +363,55 @@ static inline void port_init(void) {
}
/**
+ * @brief Returns a word encoding the current interrupts status.
+ *
+ * @return The interrupts status.
+ */
+static inline syssts_t port_get_irq_status(void) {
+ syssts_t sts;
+
+#ifdef THUMB
+ sts = _port_get_cpsr();
+#else
+ asm volatile ("mrs %[p0], CPSR" : [p0] "=r" (sts) :);
+#endif
+ return sts;
+}
+
+/**
+ * @brief Checks the interrupt status.
+ *
+ * @param[in] sts the interrupt status word
+ *
+ * @return The interrupt status.
+ * @retvel false the word specified a disabled interrupts status.
+ * @retvel true the word specified an enabled interrupts status.
+ */
+static inline bool port_irq_enabled(syssts_t sts) {
+
+ return (sts & 0x80) == 0;
+}
+
+/**
+ * @brief Determines the current execution context.
+ *
+ * @return The execution context.
+ * @retval false not running in ISR mode.
+ * @retval true running in ISR mode.
+ */
+static inline bool port_is_isr_context(void) {
+ syssts_t sts;
+
+#ifdef THUMB
+ sts = _port_get_cpsr();
+#else
+ asm volatile ("mrs %[p0], CPSR" : [p0] "=r" (sts) :);
+#endif
+
+ return (sts & 0x1F) == 0x12;
+}
+
+/**
* @brief Kernel-lock action.
* @details In this port it disables the IRQ sources and keeps FIQ sources
* enabled.
@@ -449,6 +501,21 @@ static inline void port_enable(void) {
#endif
}
+/**
+ * @brief Enters an architecture-dependent IRQ-waiting mode.
+ * @details The function is meant to return when an interrupt becomes pending.
+ * The simplest implementation is an empty function or macro but this
+ * would not take advantage of architecture-specific power saving
+ * modes.
+ * @note Implemented as an inlined @p WFI instruction.
+ */
+static inline void port_wait_for_interrupt(void) {
+
+#if ARM_ENABLE_WFI_IDLE
+ ARM_WFI_IMPL;
+#endif
+}
+
#if CH_CFG_ST_TIMEDELTA > 0
#if !PORT_USE_ALT_TIMER
#include "chcore_timer.h"
diff --git a/os/rt/ports/ARM/compilers/GCC/chcoreasm.s b/os/rt/ports/ARM/compilers/GCC/chcoreasm.s
index c97a7cb0c..4e615a8ce 100644
--- a/os/rt/ports/ARM/compilers/GCC/chcoreasm.s
+++ b/os/rt/ports/ARM/compilers/GCC/chcoreasm.s
@@ -47,13 +47,24 @@
.text
/*
- * Interrupt enable/disable functions, only present if there is THUMB code in
- * the system because those are inlined in ARM code.
+ * The following functions are only present if there is THUMB code in
+ * the system.
*/
#if defined(THUMB_PRESENT)
.balign 16
.code 16
.thumb_func
+ .global _port_get_cpsr
+_port_get_cpsr:
+ mov r0, pc
+ bx r0
+.code 32
+ mrs r0, CPSR
+ bx lr
+
+ .balign 16
+ .code 16
+ .thumb_func
.global _port_disable_thumb
_port_disable_thumb:
mov r3, pc
diff --git a/os/rt/ports/ARMCMx/chcore_v6m.h b/os/rt/ports/ARMCMx/chcore_v6m.h
index 7e74df03f..d8278367d 100644
--- a/os/rt/ports/ARMCMx/chcore_v6m.h
+++ b/os/rt/ports/ARMCMx/chcore_v6m.h
@@ -293,7 +293,7 @@ static inline void port_init(void) {
*/
static inline syssts_t port_get_irq_status(void) {
- return __get_PRIMASK();
+ return (syssts_t)__get_PRIMASK();
}
/**
diff --git a/os/rt/ports/ARMCMx/chcore_v7m.h b/os/rt/ports/ARMCMx/chcore_v7m.h
index db8d71d92..da24783e7 100644
--- a/os/rt/ports/ARMCMx/chcore_v7m.h
+++ b/os/rt/ports/ARMCMx/chcore_v7m.h
@@ -396,12 +396,12 @@ static inline void port_init(void) {
* @return The interrupts status.
*/
static inline syssts_t port_get_irq_status(void) {
- uint32_t sts;
+ syssts_t sts;
#if !CORTEX_SIMPLIFIED_PRIORITY
- sts = __get_BASEPRI();
+ sts = (syssts_t)__get_BASEPRI();
#else /* CORTEX_SIMPLIFIED_PRIORITY */
- sts = __get_PRIMASK();
+ sts = (syssts_t)__get_PRIMASK();
#endif /* CORTEX_SIMPLIFIED_PRIORITY */
return sts;
}