2 .extern vTaskISRHandler
\r
3 .extern vTaskSwitchContext
\r
4 .extern uxCriticalNesting
\r
7 .global _interrupt_handler
\r
8 .global VPortYieldASM
\r
9 .global vStartFirstTask
\r
12 .macro portSAVE_CONTEXT
\r
13 /* Make room for the context on the stack. */
\r
15 /* Save r31 so it can then be used. */
\r
17 /* Copy the msr into r31 - this is stacked later. */
\r
19 /* Stack general registers. */
\r
48 /* Stack the critical section nesting value. */
\r
49 lwi r3, r0, uxCriticalNesting
\r
51 /* Save the top of stack value to the TCB. */
\r
52 lwi r3, r0, pxCurrentTCB
\r
57 .macro portRESTORE_CONTEXT
\r
58 /* Load the top of stack value from the TCB. */
\r
59 lwi r3, r0, pxCurrentTCB
\r
61 /* Restore the general registers. */
\r
92 /* Load the critical nesting value. */
\r
94 swi r3, r0, uxCriticalNesting
\r
96 /* Obtain the MSR value from the stack. */
\r
99 /* Are interrupts enabled in the MSR? If so return using an return from
\r
100 interrupt instruction to ensure interrupts are enabled only once the task
\r
101 is running again. */
\r
106 /* Reload the rmsr from the stack, clear the enable interrupt bit in the
\r
107 value before saving back to rmsr register, then return enabling interrupts
\r
117 /* Reload the rmsr from the stack, place it in the rmsr register, and
\r
118 return without enabling interrupts. */
\r
132 _interrupt_handler:
\r
134 /* Entered via an interrupt so interrupts must be enabled in msr. */
\r
138 /* Stack the return address. As we entered via an interrupt we do
\r
139 not need to modify the return address prior to stacking. */
\r
141 /* Now switch to use the ISR stack. */
\r
142 lwi r3, r0, pulISRStack
\r
144 bralid r15, vTaskISRHandler
\r
146 portRESTORE_CONTEXT
\r
153 /* Modify the return address so we return to the instruction after the
\r
157 /* Now switch to use the ISR stack. */
\r
158 lwi r3, r0, pulISRStack
\r
160 bralid r15, vTaskSwitchContext
\r
162 portRESTORE_CONTEXT
\r
165 portRESTORE_CONTEXT
\r