diff options
author | gdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4> | 2011-08-07 09:00:12 +0000 |
---|---|---|
committer | gdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4> | 2011-08-07 09:00:12 +0000 |
commit | 075ff711f1c9cf031fa4708c6b704f120d9a509d (patch) | |
tree | 534cedaa24e11fe2149e781cfe577ef0323a9ed8 /os/ports | |
parent | 0c276798fd9ed7c2d91abd54d8fb2f3a20147130 (diff) | |
download | ChibiOS-075ff711f1c9cf031fa4708c6b704f120d9a509d.tar.gz ChibiOS-075ff711f1c9cf031fa4708c6b704f120d9a509d.tar.bz2 ChibiOS-075ff711f1c9cf031fa4708c6b704f120d9a509d.zip |
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@3192 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'os/ports')
-rw-r--r-- | os/ports/GCC/ARMCMx/LPC11xx/vectors.c | 4 | ||||
-rw-r--r-- | os/ports/GCC/ARMCMx/LPC13xx/vectors.c | 4 | ||||
-rw-r--r-- | os/ports/GCC/ARMCMx/STM32/port.mk | 3 | ||||
-rw-r--r-- | os/ports/GCC/ARMCMx/STM32/vectors.c | 4 | ||||
-rw-r--r-- | os/ports/GCC/ARMCMx/chcore_v6m.h | 4 | ||||
-rw-r--r-- | os/ports/GCC/ARMCMx/chcore_v7m.c | 10 | ||||
-rw-r--r-- | os/ports/GCC/ARMCMx/chcore_v7m.h | 23 | ||||
-rw-r--r-- | os/ports/GCC/ARMCMx/crt0.c | 25 |
8 files changed, 38 insertions, 39 deletions
diff --git a/os/ports/GCC/ARMCMx/LPC11xx/vectors.c b/os/ports/GCC/ARMCMx/LPC11xx/vectors.c index 63b343ea2..527d82836 100644 --- a/os/ports/GCC/ARMCMx/LPC11xx/vectors.c +++ b/os/ports/GCC/ARMCMx/LPC11xx/vectors.c @@ -31,7 +31,7 @@ #include "ch.h"
#if !defined(__DOXYGEN__)
-extern void __ram_end__(void);
+extern void __main_stack_end__(void);
extern void ResetHandler(void);
extern void NMIVector(void);
extern void HardFaultVector(void);
@@ -88,7 +88,7 @@ extern void VectorBC(void); __attribute__ ((section("vectors")))
#endif
void (*_vectors[])(void) = {
- __ram_end__, ResetHandler, NMIVector, HardFaultVector,
+ __main_stack_end__, ResetHandler, NMIVector, HardFaultVector,
MemManageVector, BusFaultVector, UsageFaultVector, Vector1C,
Vector20, Vector24, Vector28, SVCallVector,
DebugMonitorVector, Vector34, PendSVVector, SysTickVector,
diff --git a/os/ports/GCC/ARMCMx/LPC13xx/vectors.c b/os/ports/GCC/ARMCMx/LPC13xx/vectors.c index 1e27c4fc8..14bc798dd 100644 --- a/os/ports/GCC/ARMCMx/LPC13xx/vectors.c +++ b/os/ports/GCC/ARMCMx/LPC13xx/vectors.c @@ -31,7 +31,7 @@ #include "ch.h"
#if !defined(__DOXYGEN__)
-extern void __ram_end__(void);
+extern void __main_stack_end__(void);
extern void ResetHandler(void);
extern void NMIVector(void);
extern void HardFaultVector(void);
@@ -112,7 +112,7 @@ extern void Vector11C(void); __attribute__ ((section("vectors")))
#endif
void (*_vectors[])(void) = {
- __ram_end__, ResetHandler, NMIVector, HardFaultVector,
+ __main_stack_end__, ResetHandler, NMIVector, HardFaultVector,
MemManageVector, BusFaultVector, UsageFaultVector, Vector1C,
Vector20, Vector24, Vector28, SVCallVector,
DebugMonitorVector, Vector34, PendSVVector, SysTickVector,
diff --git a/os/ports/GCC/ARMCMx/STM32/port.mk b/os/ports/GCC/ARMCMx/STM32/port.mk index 104b22e42..1e5a51a8d 100644 --- a/os/ports/GCC/ARMCMx/STM32/port.mk +++ b/os/ports/GCC/ARMCMx/STM32/port.mk @@ -9,3 +9,6 @@ PORTASM = PORTINC = ${CHIBIOS}/os/ports/GCC/ARMCMx \
${CHIBIOS}/os/ports/GCC/ARMCMx/STM32
+
+PORTLD = ${CHIBIOS}/os/ports/GCC/ARMCMx/STM32/ld
+
diff --git a/os/ports/GCC/ARMCMx/STM32/vectors.c b/os/ports/GCC/ARMCMx/STM32/vectors.c index f12e2e867..e4d1bcb28 100644 --- a/os/ports/GCC/ARMCMx/STM32/vectors.c +++ b/os/ports/GCC/ARMCMx/STM32/vectors.c @@ -38,7 +38,7 @@ #endif
#if !defined(__DOXYGEN__)
-extern void __ram_end__(void);
+extern void __main_stack_end__(void);
extern void ResetHandler(void);
extern void NMIVector(void);
extern void HardFaultVector(void);
@@ -138,7 +138,7 @@ extern void Vector14C(void); __attribute__ ((section("vectors")))
#endif
void (*_vectors[])(void) = {
- __ram_end__, ResetHandler, NMIVector, HardFaultVector,
+ __main_stack_end__, ResetHandler, NMIVector, HardFaultVector,
MemManageVector, BusFaultVector, UsageFaultVector, Vector1C,
Vector20, Vector24, Vector28, SVCallVector,
DebugMonitorVector, Vector34, PendSVVector, SysTickVector,
diff --git a/os/ports/GCC/ARMCMx/chcore_v6m.h b/os/ports/GCC/ARMCMx/chcore_v6m.h index 2141ee468..bb6e6083b 100644 --- a/os/ports/GCC/ARMCMx/chcore_v6m.h +++ b/os/ports/GCC/ARMCMx/chcore_v6m.h @@ -242,8 +242,8 @@ struct intctx { #define port_switch(ntp, otp) _port_switch(ntp, otp)
#else
#define port_switch(ntp, otp) { \
- register struct intctx *r13 asm ("r13"); \
- if ((void *)(r13 - 1) < (void *)(otp + 1)) \
+ register struct intctx *r13 asm ("r13"); \
+ if ((stkalign_t *)(r13 - 1) < otp->p_stklimit) \
chDbgPanic("stack overflow"); \
_port_switch(ntp, otp); \
}
diff --git a/os/ports/GCC/ARMCMx/chcore_v7m.c b/os/ports/GCC/ARMCMx/chcore_v7m.c index 897c90a96..39711ce79 100644 --- a/os/ports/GCC/ARMCMx/chcore_v7m.c +++ b/os/ports/GCC/ARMCMx/chcore_v7m.c @@ -166,15 +166,7 @@ void _port_switch_from_isr(void) { #if !defined(__DOXYGEN__)
__attribute__((naked))
#endif
-void port_switch(Thread *ntp, Thread *otp) {
-
-#if CH_DBG_ENABLE_STACK_CHECK
- /* Stack overflow check, if enabled.*/
- register struct intctx *r13 asm ("r13");
- if ((void *)(r13 - 1) < (void *)(otp + 1))
- asm volatile ("movs r0, #0 \n\t"
- "b chDbgPanic");
-#endif /* CH_DBG_ENABLE_STACK_CHECK */
+void _port_switch(Thread *ntp, Thread *otp) {
PUSH_CONTEXT();
diff --git a/os/ports/GCC/ARMCMx/chcore_v7m.h b/os/ports/GCC/ARMCMx/chcore_v7m.h index 297bd4e54..afb3ac21d 100644 --- a/os/ports/GCC/ARMCMx/chcore_v7m.h +++ b/os/ports/GCC/ARMCMx/chcore_v7m.h @@ -314,11 +314,32 @@ struct intctx { #define port_wait_for_interrupt()
#endif
+/**
+ * @brief Performs a context switch between two threads.
+ * @details This is the most critical code in any port, this function
+ * is responsible for the context switch between 2 threads.
+ * @note The implementation of this code affects <b>directly</b> the context
+ * switch performance so optimize here as much as you can.
+ *
+ * @param[in] ntp the thread to be switched in
+ * @param[in] otp the thread to be switched out
+ */
+#if !defined(CH_DBG_ENABLE_STACK_CHECK) || defined(__DOXYGEN__)
+#define port_switch(ntp, otp) _port_switch(ntp, otp)
+#else
+#define port_switch(ntp, otp) { \
+ register struct intctx *r13 asm ("r13"); \
+ if ((stkalign_t *)(r13 - 1) < otp->p_stklimit) \
+ chDbgPanic("stack overflow"); \
+ _port_switch(ntp, otp); \
+}
+#endif
+
#ifdef __cplusplus
extern "C" {
#endif
void port_halt(void);
- void port_switch(Thread *ntp, Thread *otp);
+ void _port_switch(Thread *ntp, Thread *otp);
void _port_irq_epilogue(void);
void _port_switch_from_isr(void);
void _port_thread_start(void);
diff --git a/os/ports/GCC/ARMCMx/crt0.c b/os/ports/GCC/ARMCMx/crt0.c index 0bb88dd83..73dca119e 100644 --- a/os/ports/GCC/ARMCMx/crt0.c +++ b/os/ports/GCC/ARMCMx/crt0.c @@ -73,28 +73,11 @@ typedef funcp_t * funcpp_t; #define SYMVAL(sym) (uint32_t)(((uint8_t *)&(sym)) - ((uint8_t *)0))
/**
- * @brief Ram end.
+ * @brief Main thread stack initial position.
* @details This symbol must be exported by the linker script and represents
- * the location after the last RAM location.
+ * the main thread stack initial position.
*/
-extern uint8_t __ram_end__;
-
-/**
- * @brief Main stack size.
- * @details This symbol must be exported by the linker script and represents
- * the main stack size.
- * @note The main stack is the stack where interrupts and exceptions are
- * processed.
- */
-extern uint8_t __main_stack_size__;
-
-/**
- * @brief Process stack size.
- * @details This symbol must be exported by the linker script and represents
- * the process stack size.
- * @note The process stack is the stack used by the @p main() function.
- */
-extern uint8_t __process_stack_size__;
+extern uint8_t __process_stack_end__;
/**
* @brief ROM image of the data segment start.
@@ -206,7 +189,7 @@ void ResetHandler(void) { main stack is assumed to be allocated starting from @p __ram_end__
extending downward.*/
asm volatile ("cpsid i");
- psp = SYMVAL(__ram_end__) - SYMVAL(__main_stack_size__);
+ psp = SYMVAL(__process_stack_end__);
asm volatile ("msr PSP, %0" : : "r" (psp));
ctl = CRT0_CONTROL_INIT;
|