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

master
gdisirio 2010-04-13 17:29:54 +00:00
parent 676bb610cb
commit c406099319
4 changed files with 62 additions and 64 deletions

View File

@ -64,13 +64,13 @@ __attribute__((naked))
#endif #endif
void _port_switch_from_irq(void) { void _port_switch_from_irq(void) {
/* Note, saves r4 to make space for the PC.*/ /* Note, saves r4 to make space for the PC.*/
asm volatile ("push {r0, r1, r2, r3, r4} \n\t" \ asm volatile ("push {r0, r1, r2, r3, r4} \n\t"
"mrs r0, APSR \n\t" \ "mrs r0, APSR \n\t"
"mov r1, r12 \n\t" \ "mov r1, r12 \n\t"
"push {r0, r1, lr} \n\t" \ "push {r0, r1, lr} \n\t"
"ldr r0, =_port_saved_pc \n\t" \ "ldr r0, =_port_saved_pc \n\t"
"ldr r0, [r0] \n\t" \ "ldr r0, [r0] \n\t"
"add r0, r0, #1 \n\t" \ "add r0, r0, #1 \n\t"
"str r0, [sp, #28]"); "str r0, [sp, #28]");
chSchDoRescheduleI(); chSchDoRescheduleI();
@ -80,11 +80,11 @@ void _port_switch_from_irq(void) {
possibility that the stack is filled by continuous and saturating possibility that the stack is filled by continuous and saturating
interrupts that would not allow that last words to be pulled out of interrupts that would not allow that last words to be pulled out of
the stack.*/ the stack.*/
asm volatile ("pop {r0, r1, r2} \n\t" \ asm volatile ("pop {r0, r1, r2} \n\t"
"mov r12, r1 \n\t" \ "mov r12, r1 \n\t"
"msr APSR, r0 \n\t" \ "msr APSR, r0 \n\t"
"mov lr, r2 \n\t" \ "mov lr, r2 \n\t"
"cpsie i \n\t" \ "cpsie i \n\t"
"pop {r0, r1, r2, r3, pc}"); "pop {r0, r1, r2, r3, pc}");
} }
@ -145,8 +145,8 @@ void port_switch(Thread *ntp, Thread *otp) {
void _port_thread_start(void) { void _port_thread_start(void) {
port_unlock(); port_unlock();
asm volatile ("mov r0, r5 \n\t" \ asm volatile ("mov r0, r5 \n\t"
"blx r4 \n\t" \ "blx r4 \n\t"
"bl chThdExit"); "bl chThdExit");
} }

View File

@ -129,9 +129,9 @@ struct intctx {
* enabled to invoke system APIs. * enabled to invoke system APIs.
*/ */
#define PORT_IRQ_PROLOGUE() { \ #define PORT_IRQ_PROLOGUE() { \
chSysLockFromIsr(); \ port_lock_from_isr(); \
_port_irq_nesting++; \ _port_irq_nesting++; \
chSysUnlockFromIsr(); \ port_unlock_from_isr(); \
} }
/** /**
@ -140,7 +140,7 @@ struct intctx {
* enabled to invoke system APIs. * enabled to invoke system APIs.
*/ */
#define PORT_IRQ_EPILOGUE() { \ #define PORT_IRQ_EPILOGUE() { \
chSysLockFromIsr(); \ port_lock_from_isr(); \
if ((--_port_irq_nesting == 0) && chSchIsRescRequiredExI()) { \ if ((--_port_irq_nesting == 0) && chSchIsRescRequiredExI()) { \
register struct cmxctx *ctxp; \ register struct cmxctx *ctxp; \
\ \
@ -149,7 +149,7 @@ struct intctx {
ctxp->pc = _port_switch_from_irq; \ ctxp->pc = _port_switch_from_irq; \
return; \ return; \
} \ } \
chSysUnlockFromIsr(); \ port_unlock_from_isr(); \
} }
/** /**

View File

@ -63,7 +63,7 @@ CH_IRQ_HANDLER(SysTickVector) {
void SVCallVector(void) { void SVCallVector(void) {
register struct extctx *ctxp; register struct extctx *ctxp;
/* Discardig the current exception context and positioning the stack to /* Discarding the current exception context and positioning the stack to
point to the real one.*/ point to the real one.*/
asm volatile ("mrs %0, PSP" : "=r" (ctxp) : ); asm volatile ("mrs %0, PSP" : "=r" (ctxp) : );
ctxp++; ctxp++;
@ -94,9 +94,7 @@ void _port_irq_epilogue(void) {
/** /**
* @brief Post-IRQ switch code. * @brief Post-IRQ switch code.
* @details On entry the stack and the registers are restored by the exception * @details Exception handlers return here for context switching.
* return, the PC value is stored in @p _port_saved_pc, the interrupts
* are disabled.
*/ */
#if !defined(__DOXYGEN__) #if !defined(__DOXYGEN__)
__attribute__((naked)) __attribute__((naked))
@ -155,8 +153,8 @@ void port_switch(Thread *ntp, Thread *otp) {
void _port_thread_start(void) { void _port_thread_start(void) {
port_unlock(); port_unlock();
asm volatile ("mov r0, r5 \n\t" \ asm volatile ("mov r0, r5 \n\t"
"blx r4 \n\t" \ "blx r4 \n\t"
"bl chThdExit"); "bl chThdExit");
} }

View File

@ -164,7 +164,7 @@ struct intctx {
* @brief Kernel-unlock action. * @brief Kernel-unlock action.
* @details Usually this function just disables interrupts but may perform * @details Usually this function just disables interrupts but may perform
* more actions. * more actions.
* @note In this port this it lowers the base priority to kernel level. * @note In this port this it lowers the base priority to user level.
*/ */
#if CH_OPTIMIZE_SPEED #if CH_OPTIMIZE_SPEED
#define port_unlock() { \ #define port_unlock() { \