typedef void tskTCB;\r
extern volatile tskTCB * volatile pxCurrentTCB;\r
\r
-/* Constants required to handle critical sections. */\r
-#define portNO_CRITICAL_NESTING ( ( unsigned portBASE_TYPE ) 0 )\r
-volatile unsigned portLONG ulCriticalNesting = 9999UL;\r
-\r
/*-----------------------------------------------------------*/\r
\r
#pragma asm\r
STM1 (R14,R13,R12,R11,R10,R9,R8) ;Store R14-R8\r
ST MDH, @-R15 ;Store MDH\r
ST MDL, @-R15 ;Store MDL\r
-\r
- LDI #_ulCriticalNesting, R0 ;Get the address of the critical nesting counter\r
- LD @R0, R0 ;Get the value of the critical nesting counter\r
- ST R0, @-R15 ;Store the critical nesting value to the user stack.\r
\r
ANDCCR #0xDF ;Switch back to system stack\r
LD @R15+,R0 ;Store PC to R0 \r
\r
ORCCR #0x20 ;Switch back to retrieve the remaining context\r
\r
- LDI #_ulCriticalNesting, R0 ;Get the address of the critical nesting counter\r
- LD @R15+, R1 ;Get the saved critical nesting value\r
- ST R1, @R0 ;Save the critical nesting value into the ulCriticalNesting variable\r
-\r
LD @R15+, MDL ;Restore MDL\r
LD @R15+, MDH ;Restore MDH\r
LDM1 (R14,R13,R12,R11,R10,R9,R8) ;Restore R14-R8\r
*pxTopOfStack = ( portSTACK_TYPE ) 0x22220000; /* MDL */\r
pxTopOfStack--;\r
\r
- /* The task starts with its ulCriticalNesting variable set to 0, \r
- interrupts being enabled. */\r
- *pxTopOfStack = portNO_CRITICAL_NESTING;\r
- pxTopOfStack--;\r
-\r
/* The start of the task code. */\r
*pxTopOfStack = ( portSTACK_TYPE ) pxCode; /* PC */\r
pxTopOfStack--;\r
#pragma endasm\r
/*-----------------------------------------------------------*/\r
\r
-void vPortEnterCritical( void )\r
-{\r
- /* Disable interrupts upto level 30. */\r
- #if configKERNEL_INTERRUPT_PRIORITY != 30\r
- #error configKERNEL_INTERRUPT_PRIORITY (set in FreeRTOSConfig.h) must match the ILM value set in the following line - 30 (0x1e) being the default.\r
- #endif\r
-\r
- __asm(" STILM #1Eh ");\r
- \r
-\r
- /* Now interrupts are disabled ulCriticalNesting can be accessed\r
- directly. Increment ulCriticalNesting to keep a count of how many times\r
- portENTER_CRITICAL() has been called. */\r
- ulCriticalNesting++;\r
-}\r
-/*-----------------------------------------------------------*/ \r
-\r
-void vPortExitCritical( void )\r
-{\r
- if( ulCriticalNesting > portNO_CRITICAL_NESTING )\r
- {\r
- ulCriticalNesting--;\r
- if( ulCriticalNesting == portNO_CRITICAL_NESTING )\r
- {\r
- /* Enable all interrupts */\r
- __asm(" STILM #1Fh ");\r
- }\r
- }\r
-}\r
/*-----------------------------------------------------------*/ \r
\r
/* Critical section management. */\r
-void vPortEnterCritical( void );\r
-void vPortExitCritical( void );\r
-#define portENTER_CRITICAL() vPortEnterCritical()\r
-#define portEXIT_CRITICAL() vPortExitCritical()\r
+#define portENTER_CRITICAL() \\r
+ __asm(" ST PS,@-R15 "); \\r
+ __asm(" ANDCCR #0xef "); \\r
+\r
+\r
+#define portEXIT_CRITICAL() \\r
+ __asm(" LD @R15+,PS "); \\r
+\r
#define portDISABLE_INTERRUPTS() __DI();\r
#define portENABLE_INTERRUPTS() __EI();\r
\r