aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--os/kernel/templates/chcore.h2
-rw-r--r--os/ports/GCC/ARM/chcore.h2
-rw-r--r--os/ports/GCC/AVR/chcore.c2
-rw-r--r--os/ports/GCC/AVR/chcore.h38
-rw-r--r--os/ports/GCC/MSP430/chcore.c4
-rw-r--r--os/ports/GCC/MSP430/chcore.h40
-rw-r--r--os/ports/GCC/PPC/chcore.h12
-rw-r--r--os/ports/GCC/SIMIA32/chcore.h2
-rw-r--r--os/ports/RC/STM8/chcore.c2
-rw-r--r--os/ports/RC/STM8/chcore.h2
-rw-r--r--os/ports/cosmic/STM8/chcore.c4
-rw-r--r--os/ports/cosmic/STM8/chcore.h2
12 files changed, 62 insertions, 50 deletions
diff --git a/os/kernel/templates/chcore.h b/os/kernel/templates/chcore.h
index 5c8236c7b..416b3f1aa 100644
--- a/os/kernel/templates/chcore.h
+++ b/os/kernel/templates/chcore.h
@@ -151,7 +151,7 @@ struct context {
#define THD_WA_SIZE(n) STACK_ALIGN(sizeof(Thread) + \
sizeof(struct intctx) + \
sizeof(struct extctx) + \
- (n) + (PORT_INT_REQUIRED_STACK))
+ (n) + (PORT_INT_REQUIRED_STACK))
/**
* @brief Static working area allocation.
diff --git a/os/ports/GCC/ARM/chcore.h b/os/ports/GCC/ARM/chcore.h
index c2d2892cd..f23048e4c 100644
--- a/os/ports/GCC/ARM/chcore.h
+++ b/os/ports/GCC/ARM/chcore.h
@@ -249,7 +249,7 @@ struct context {
#define THD_WA_SIZE(n) STACK_ALIGN(sizeof(Thread) + \
sizeof(struct intctx) + \
sizeof(struct extctx) + \
- (n) + (PORT_INT_REQUIRED_STACK))
+ (n) + (PORT_INT_REQUIRED_STACK))
/**
* @brief Static working area allocation.
diff --git a/os/ports/GCC/AVR/chcore.c b/os/ports/GCC/AVR/chcore.c
index 7cb0dda07..58663cd9c 100644
--- a/os/ports/GCC/AVR/chcore.c
+++ b/os/ports/GCC/AVR/chcore.c
@@ -123,7 +123,7 @@ void port_halt(void) {
*/
void _port_thread_start(void) {
- asm volatile ("sei");
+ chSysUnlock();
asm volatile ("movw r24, r4");
asm volatile ("movw r30, r2");
asm volatile ("icall");
diff --git a/os/ports/GCC/AVR/chcore.h b/os/ports/GCC/AVR/chcore.h
index 757488948..744502825 100644
--- a/os/ports/GCC/AVR/chcore.h
+++ b/os/ports/GCC/AVR/chcore.h
@@ -142,15 +142,15 @@ struct context {
* @details This code usually setup the context switching frame represented
* by an @p intctx structure.
*/
-#define SETUP_CONTEXT(workspace, wsize, pf, arg) { \
- tp->p_ctx.sp = (struct intctx*)((uint8_t *)workspace + wsize - \
- sizeof(struct intctx)); \
- tp->p_ctx.sp->r2 = (int)pf; \
- tp->p_ctx.sp->r3 = (int)pf >> 8; \
- tp->p_ctx.sp->r4 = (int)arg; \
- tp->p_ctx.sp->r5 = (int)arg >> 8; \
- tp->p_ctx.sp->pcl = (int)_port_thread_start >> 8; \
- tp->p_ctx.sp->pch = (int)_port_thread_start; \
+#define SETUP_CONTEXT(workspace, wsize, pf, arg) { \
+ tp->p_ctx.sp = (struct intctx*)((uint8_t *)workspace + wsize - \
+ sizeof(struct intctx)); \
+ tp->p_ctx.sp->r2 = (int)pf; \
+ tp->p_ctx.sp->r3 = (int)pf >> 8; \
+ tp->p_ctx.sp->r4 = (int)arg; \
+ tp->p_ctx.sp->r5 = (int)arg >> 8; \
+ tp->p_ctx.sp->pcl = (int)_port_thread_start >> 8; \
+ tp->p_ctx.sp->pch = (int)_port_thread_start; \
}
/**
@@ -185,9 +185,9 @@ struct context {
/**
* @brief Computes the thread working area global size.
*/
-#define THD_WA_SIZE(n) STACK_ALIGN(sizeof(Thread) + \
- (sizeof(struct intctx) - 1) + \
- (sizeof(struct extctx) - 1) + \
+#define THD_WA_SIZE(n) STACK_ALIGN(sizeof(Thread) + \
+ (sizeof(struct intctx) - 1) + \
+ (sizeof(struct extctx) - 1) + \
(n) + (PORT_INT_REQUIRED_STACK))
/**
@@ -204,9 +204,9 @@ struct context {
* @note This code tricks the compiler to save all the specified registers
* by "touching" them.
*/
-#define PORT_IRQ_PROLOGUE() { \
- asm ("" : : : "r18", "r19", "r20", "r21", "r22", "r23", "r24", \
- "r25", "r26", "r27", "r30", "r31"); \
+#define PORT_IRQ_PROLOGUE() { \
+ asm ("" : : : "r18", "r19", "r20", "r21", "r22", "r23", "r24", \
+ "r25", "r26", "r27", "r30", "r31"); \
}
/**
@@ -214,9 +214,11 @@ struct context {
* @details This macro must be inserted at the end of all IRQ handlers
* enabled to invoke system APIs.
*/
-#define PORT_IRQ_EPILOGUE() { \
- if (chSchIsPreemptionRequired()) \
- chSchDoReschedule(); \
+#define PORT_IRQ_EPILOGUE() { \
+ dbg_check_lock(); \
+ if (chSchIsPreemptionRequired()) \
+ chSchDoReschedule(); \
+ dbg_check_unlock(); \
}
/**
diff --git a/os/ports/GCC/MSP430/chcore.c b/os/ports/GCC/MSP430/chcore.c
index d9192177d..ef8ae4967 100644
--- a/os/ports/GCC/MSP430/chcore.c
+++ b/os/ports/GCC/MSP430/chcore.c
@@ -93,8 +93,8 @@ void port_halt(void) {
*/
void _port_thread_start(void) {
- asm volatile ("eint \n\t" \
- "mov r11, r15 \n\t" \
+ chSysUnlock();
+ asm volatile ("mov r11, r15 \n\t" \
"call r10 \n\t" \
"call #chThdExit");
}
diff --git a/os/ports/GCC/MSP430/chcore.h b/os/ports/GCC/MSP430/chcore.h
index bac05608c..3fb0f3591 100644
--- a/os/ports/GCC/MSP430/chcore.h
+++ b/os/ports/GCC/MSP430/chcore.h
@@ -119,13 +119,13 @@ struct context {
* @details This code usually setup the context switching frame represented
* by an @p intctx structure.
*/
-#define SETUP_CONTEXT(workspace, wsize, pf, arg) { \
- tp->p_ctx.sp = (struct intctx *)((uint8_t *)workspace + \
- wsize - \
- sizeof(struct intctx)); \
- tp->p_ctx.sp->r10 = pf; \
- tp->p_ctx.sp->r11 = arg; \
- tp->p_ctx.sp->pc = _port_thread_start; \
+#define SETUP_CONTEXT(workspace, wsize, pf, arg) { \
+ tp->p_ctx.sp = (struct intctx *)((uint8_t *)workspace + \
+ wsize - \
+ sizeof(struct intctx)); \
+ tp->p_ctx.sp->r10 = pf; \
+ tp->p_ctx.sp->r11 = arg; \
+ tp->p_ctx.sp->pc = _port_thread_start; \
}
/**
@@ -159,10 +159,10 @@ struct context {
/**
* @brief Computes the thread working area global size.
*/
-#define THD_WA_SIZE(n) STACK_ALIGN(sizeof(Thread) + \
- sizeof(struct intctx) + \
- sizeof(struct extctx) + \
- (n) + (PORT_INT_REQUIRED_STACK))
+#define THD_WA_SIZE(n) STACK_ALIGN(sizeof(Thread) + \
+ sizeof(struct intctx) + \
+ sizeof(struct extctx) + \
+ (n) + (PORT_INT_REQUIRED_STACK))
/**
* @brief Static working area allocation.
@@ -183,9 +183,11 @@ struct context {
* @details This macro must be inserted at the end of all IRQ handlers
* enabled to invoke system APIs.
*/
-#define PORT_IRQ_EPILOGUE() { \
- if (chSchIsPreemptionRequired()) \
- chSchDoReschedule(); \
+#define PORT_IRQ_EPILOGUE() { \
+ dbg_check_lock(); \
+ if (chSchIsPreemptionRequired()) \
+ chSchDoReschedule(); \
+ dbg_check_unlock(); \
}
/**
@@ -220,7 +222,11 @@ struct context {
/**
* @brief Kernel-lock action from an interrupt handler.
* @details This function is invoked before invoking I-class APIs from
- * interrupt handlers. The implementation is architecture dependent,
+ * interrupt handlers. The implementation is architecture dependen#define PORT_IRQ_EPILOGUE() { \
+ if (chSchIsPreemptionRequired()) \
+ chSchDoReschedule(); \
+}
+ * t,
* in its simplest form it is void.
* @note This function is empty in this port.
*/
@@ -270,8 +276,8 @@ struct context {
*/
#if ENABLE_WFI_IDLE != 0
#ifndef port_wait_for_interrupt
-#define port_wait_for_interrupt() { \
- asm volatile ("nop" : : : "memory"); \
+#define port_wait_for_interrupt() { \
+ asm volatile ("nop" : : : "memory"); \
}
#endif
#else
diff --git a/os/ports/GCC/PPC/chcore.h b/os/ports/GCC/PPC/chcore.h
index 6504532ac..01b31bbb7 100644
--- a/os/ports/GCC/PPC/chcore.h
+++ b/os/ports/GCC/PPC/chcore.h
@@ -221,10 +221,10 @@ struct context {
/**
* @brief Computes the thread working area global size.
*/
-#define THD_WA_SIZE(n) STACK_ALIGN(sizeof(Thread) + \
- sizeof(struct intctx) + \
- sizeof(struct extctx) + \
- (n) + (PORT_INT_REQUIRED_STACK))
+#define THD_WA_SIZE(n) STACK_ALIGN(sizeof(Thread) + \
+ sizeof(struct intctx) + \
+ sizeof(struct extctx) + \
+ (n) + (PORT_INT_REQUIRED_STACK))
/**
* @brief Static working area allocation.
@@ -307,8 +307,8 @@ struct context {
*/
#if ENABLE_WFI_IDLE != 0
#ifndef port_wait_for_interrupt
-#define port_wait_for_interrupt() { \
- asm volatile ("wait" : : : "memory"); \
+#define port_wait_for_interrupt() { \
+ asm volatile ("wait" : : : "memory"); \
}
#endif
#else
diff --git a/os/ports/GCC/SIMIA32/chcore.h b/os/ports/GCC/SIMIA32/chcore.h
index 3d5c62b23..2a9d3d452 100644
--- a/os/ports/GCC/SIMIA32/chcore.h
+++ b/os/ports/GCC/SIMIA32/chcore.h
@@ -144,7 +144,7 @@ struct context {
sizeof(void *) * 4 + \
sizeof(struct intctx) + \
sizeof(struct extctx) + \
- (n) + (PORT_INT_REQUIRED_STACK))
+ (n) + (PORT_INT_REQUIRED_STACK))
/**
* Macro used to allocate a thread working area aligned as both position and
diff --git a/os/ports/RC/STM8/chcore.c b/os/ports/RC/STM8/chcore.c
index d7034e38a..a45f4c27f 100644
--- a/os/ports/RC/STM8/chcore.c
+++ b/os/ports/RC/STM8/chcore.c
@@ -54,8 +54,8 @@ void _port_switch(Thread *otp) {
*/
void _port_thread_start(void) {
+ chSysUnlock();
#pragma ASM
- RIM
POPW X
#pragma ENDASM
}
diff --git a/os/ports/RC/STM8/chcore.h b/os/ports/RC/STM8/chcore.h
index e889cf1d0..c8c2ebb16 100644
--- a/os/ports/RC/STM8/chcore.h
+++ b/os/ports/RC/STM8/chcore.h
@@ -206,8 +206,10 @@ struct stm8_startctx {
* enabled to invoke system APIs.
*/
#define PORT_IRQ_EPILOGUE() { \
+ dbg_check_lock(); \
if (chSchIsPreemptionRequired()) \
chSchDoReschedule(); \
+ dbg_check_unlock(); \
}
/**
diff --git a/os/ports/cosmic/STM8/chcore.c b/os/ports/cosmic/STM8/chcore.c
index c5f1de2d6..3c1807330 100644
--- a/os/ports/cosmic/STM8/chcore.c
+++ b/os/ports/cosmic/STM8/chcore.c
@@ -50,8 +50,8 @@ void _port_switch(Thread *otp) {
*/
void _port_thread_start(void) {
- _asm(" rim \n"
- " popw x \n");
+ chSysUnlock();
+ _asm(" popw x \n");
}
/**
diff --git a/os/ports/cosmic/STM8/chcore.h b/os/ports/cosmic/STM8/chcore.h
index 75bed68cc..9073592aa 100644
--- a/os/ports/cosmic/STM8/chcore.h
+++ b/os/ports/cosmic/STM8/chcore.h
@@ -203,8 +203,10 @@ struct stm8_startctx {
* enabled to invoke system APIs.
*/
#define PORT_IRQ_EPILOGUE() { \
+ dbg_check_lock(); \
if (chSchIsPreemptionRequired()) \
chSchDoReschedule(); \
+ dbg_check_unlock(); \
}
/**