git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@3670 35acf78f-673a-0410-8e92-d51de3d6d3f4

This commit is contained in:
gdisirio 2011-12-28 09:09:50 +00:00
parent 3b3e0f7712
commit f32ad2889e
8 changed files with 39 additions and 46 deletions

View File

@ -7,7 +7,7 @@ Compiler: IAR C/C++ Compiler for ARM 6.30.3.33228
*** ChibiOS/RT test suite *** ChibiOS/RT test suite
*** ***
*** Kernel: 2.3.5unstable *** Kernel: 2.3.5unstable
*** Compiled: Dec 27 2011 - 15:57:01 *** Compiled: Dec 28 2011 - 10:01:37
*** Compiler: IAR *** Compiler: IAR
*** Architecture: ARMv7-ME *** Architecture: ARMv7-ME
*** Core Variant: Cortex-M4 *** Core Variant: Cortex-M4

View File

@ -133,7 +133,9 @@ __attribute__((naked))
#endif #endif
void _port_switch_from_isr(void) { void _port_switch_from_isr(void) {
dbg_check_lock();
chSchDoReschedule(); chSchDoReschedule();
dbg_check_unlock();
asm volatile ("_port_exit_from_isr:" : : : "memory"); asm volatile ("_port_exit_from_isr:" : : : "memory");
#if CORTEX_ALTERNATE_SWITCH #if CORTEX_ALTERNATE_SWITCH
SCB_ICSR = ICSR_PENDSVSET; SCB_ICSR = ICSR_PENDSVSET;

View File

@ -206,6 +206,23 @@ struct intctx {};
#endif /* defined(__DOXYGEN__) */ #endif /* defined(__DOXYGEN__) */
/**
* @brief Excludes the default @p chSchIsPreemptionRequired()implementation.
*/
#define PORT_OPTIMIZED_ISPREEMPTIONREQUIRED
#if (CH_TIME_QUANTUM > 0) || defined(__DOXYGEN__)
/**
* @brief Inlineable version of this kernel function.
*/
#define chSchIsPreemptionRequired() \
(rlist.r_preempt ? firstprio(&rlist.r_queue) > currp->p_prio : \
firstprio(&rlist.r_queue) >= currp->p_prio)
#else /* CH_TIME_QUANTUM == 0 */
#define chSchIsPreemptionRequired() \
(firstprio(&rlist.r_queue) > currp->p_prio)
#endif /* CH_TIME_QUANTUM == 0 */
#endif /* _FROM_ASM_ */ #endif /* _FROM_ASM_ */
#endif /* _CHCORE_H_ */ #endif /* _CHCORE_H_ */

View File

@ -103,8 +103,20 @@ void _port_irq_epilogue(regarm_t lr) {
ctxp = (struct extctx *)__get_PSP(); ctxp = (struct extctx *)__get_PSP();
ctxp--; ctxp--;
__set_PSP((unsigned long)ctxp); __set_PSP((unsigned long)ctxp);
ctxp->pc = (regarm_t)_port_switch_from_isr;
ctxp->xpsr = (regarm_t)0x01000000; ctxp->xpsr = (regarm_t)0x01000000;
/* The exit sequence is different depending on if a preemption is
required or not.*/
if (chSchIsPreemptionRequired()) {
/* Preemption is required we need to enforce a context switch.*/
ctxp->pc = (regarm_t)_port_switch_from_isr;
}
else {
/* Preemption not required, we just need to exit the exception
atomically.*/
ctxp->pc = (regarm_t)_port_exit_from_isr;
}
/* Note, returning without unlocking is intentional, this is done in /* Note, returning without unlocking is intentional, this is done in
order to keep the rest of the context switching atomic.*/ order to keep the rest of the context switching atomic.*/
} }

View File

@ -352,32 +352,14 @@ struct context {
} }
#endif #endif
#if 0
/**
* @brief Excludes the default @p chSchIsPreemptionRequired()implementation.
*/
#define PORT_OPTIMIZED_ISPREEMPTIONREQUIRED
#if (CH_TIME_QUANTUM > 0) || defined(__DOXYGEN__)
/**
* @brief Inlineable version of this kernel function.
*/
#define chSchIsPreemptionRequired() \
(rlist.r_preempt ? firstprio(&rlist.r_queue) > currp->p_prio : \
firstprio(&rlist.r_queue) >= currp->p_prio)
#else /* CH_TIME_QUANTUM == 0 */
#define chSchIsPreemptionRequired() \
(firstprio(&rlist.r_queue) > currp->p_prio)
#endif /* CH_TIME_QUANTUM == 0 */
#endif
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
void port_halt(void); void port_halt(void);
void _port_switch(Thread *ntp, Thread *otp);
void _port_irq_epilogue(regarm_t lr); void _port_irq_epilogue(regarm_t lr);
void _port_switch_from_isr(void); void _port_switch_from_isr(void);
void _port_exit_from_isr(void);
void _port_switch(Thread *ntp, Thread *otp);
void _port_thread_start(void); void _port_thread_start(void);
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@ -171,7 +171,6 @@ void _port_irq_epilogue(void) {
else { else {
/* Preemption not required, we just need to exit the exception /* Preemption not required, we just need to exit the exception
atomically.*/ atomically.*/
void _port_exit_from_isr(void);
ctxp->pc = (regarm_t)_port_exit_from_isr; ctxp->pc = (regarm_t)_port_exit_from_isr;
} }

View File

@ -469,31 +469,15 @@ struct context {
} }
#endif #endif
/**
* @brief Excludes the default @p chSchIsPreemptionRequired()implementation.
*/
#define PORT_OPTIMIZED_ISPREEMPTIONREQUIRED
#if (CH_TIME_QUANTUM > 0) || defined(__DOXYGEN__)
/**
* @brief Inlineable version of this kernel function.
*/
#define chSchIsPreemptionRequired() \
(rlist.r_preempt ? firstprio(&rlist.r_queue) > currp->p_prio : \
firstprio(&rlist.r_queue) >= currp->p_prio)
#else /* CH_TIME_QUANTUM == 0 */
#define chSchIsPreemptionRequired() \
(firstprio(&rlist.r_queue) > currp->p_prio)
#endif /* CH_TIME_QUANTUM == 0 */
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
void port_halt(void); void port_halt(void);
void _port_init(void); void _port_init(void);
void _port_switch(Thread *ntp, Thread *otp);
void _port_irq_epilogue(void); void _port_irq_epilogue(void);
void _port_switch_from_isr(void); void _port_switch_from_isr(void);
void _port_exit_from_isr(void);
void _port_switch(Thread *ntp, Thread *otp);
void _port_thread_start(void); void _port_thread_start(void);
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@ -37,7 +37,6 @@ SCB_ICSR SET 0xE000ED04
SECTION .text:CODE:NOROOT(2) SECTION .text:CODE:NOROOT(2)
EXTERN chThdExit EXTERN chThdExit
EXTERN chSchIsPreemptionRequired
EXTERN chSchDoReschedule EXTERN chSchDoReschedule
#if CH_DBG_SYSTEM_STATE_CHECK #if CH_DBG_SYSTEM_STATE_CHECK
EXTERN dbg_check_unlock EXTERN dbg_check_unlock
@ -87,18 +86,16 @@ _port_thread_start:
* Exception handlers return here for context switching. * Exception handlers return here for context switching.
*/ */
PUBLIC _port_switch_from_isr PUBLIC _port_switch_from_isr
PUBLIC _port_exit_from_isr
_port_switch_from_isr: _port_switch_from_isr:
#if CH_DBG_SYSTEM_STATE_CHECK #if CH_DBG_SYSTEM_STATE_CHECK
bl dbg_check_lock bl dbg_check_lock
#endif #endif
bl chSchIsPreemptionRequired
cmp r0, #0
beq noresch
bl chSchDoReschedule bl chSchDoReschedule
noresch:
#if CH_DBG_SYSTEM_STATE_CHECK #if CH_DBG_SYSTEM_STATE_CHECK
bl dbg_check_unlock bl dbg_check_unlock
#endif #endif
_port_exit_from_isr:
ldr r2, =SCB_ICSR ldr r2, =SCB_ICSR
movs r3, #128 movs r3, #128
#if CORTEX_ALTERNATE_SWITCH #if CORTEX_ALTERNATE_SWITCH