;\r
; A special exception to the GPL can be applied should you wish to distribute\r
; a combined work that includes FreeRTOS.org, without being obliged to provide\r
-; the source code for any proprietary components. See the licensing section \r
+; the source code for any proprietary components. See the licensing section\r
; of http://www.FreeRTOS.org for full details of how and when the exception\r
; can be applied.\r
;\r
; ***************************************************************************\r
-; See http://www.FreeRTOS.org for documentation, latest information, license \r
-; and contact details. Please ensure to read the configuration and relevant \r
+; See http://www.FreeRTOS.org for documentation, latest information, license\r
+; and contact details. Please ensure to read the configuration and relevant\r
; port sections of the online documentation.\r
; ***************************************************************************\r
\r
EXTERN vTaskSwitchContext\r
EXTERN pxCurrentTCB\r
EXTERN vTaskIncrementTick\r
+EXTERN uxCriticalNesting\r
\r
; Functions implemented in this file\r
; ----------------------------------\r
; ------------------------------------------------------\r
;\r
; The IAR compiler does not fully support inline assembler, so saving and\r
-; restoring a task context has to be written in an asm file. \r
+; restoring a task context has to be written in an asm file.\r
;\r
; vPortYield() and vPortYieldFromTick() are usually written in C. Doing\r
; so in this case would required calls to be made to portSAVE_CONTEXT() and\r
-; portRESTORE_CONTEXT(). This is dis-advantageous as the context switch \r
-; function would require two extra jump and return instructions over the \r
-; WinAVR equivalent. \r
+; portRESTORE_CONTEXT(). This is dis-advantageous as the context switch\r
+; function would require two extra jump and return instructions over the\r
+; WinAVR equivalent.\r
;\r
-; To avoid this I have opted to implement both vPortYield() and \r
+; To avoid this I have opted to implement both vPortYield() and\r
; vPortYieldFromTick() in this assembly file. For convenience\r
; portSAVE_CONTEXT and portRESTORE_CONTEXT are implemented as macros.\r
\r
st -y, r27\r
st -y, r30\r
st -y, r31\r
+ lds r0, uxCriticalNesting\r
+ st -y, r0 ; Store the critical nesting counter.\r
\r
lds r26, pxCurrentTCB ; Finally save the software stack pointer (Y ...\r
lds r27, pxCurrentTCB + 1 ; ... register) into the TCB.\r
ld r28, x+ ; the TCB into the software stack pointer (...\r
ld r29, x+ ; ... the Y register).\r
\r
+ ld r0, y+\r
+ sts uxCriticalNesting, r0\r
ld r31, y+ ; Restore the registers down to R0. The Y\r
ld r30, y+ ; register is missing from this list as it\r
ld r27, y+ ; has already been restored.\r
- ld r26, y+ \r
+ ld r26, y+\r
ld r25, y+\r
ld r24, y+\r
ld r23, y+\r
; vPortYield() and vPortYieldFromTick()\r
; -------------------------------------\r
;\r
-; Manual and preemptive context switch functions respectively. \r
-; The IAR compiler does not fully support inline assembler, \r
-; so these are implemented here rather than the more usually \r
+; Manual and preemptive context switch functions respectively.\r
+; The IAR compiler does not fully support inline assembler,\r
+; so these are implemented here rather than the more usually\r
; place of within port.c.\r
\r
vPortYield:\r