mirror of
https://github.com/FreeRTOS/FreeRTOS-Kernel.git
synced 2025-04-19 21:11:57 -04:00
Revert to original critical section handling method.
This commit is contained in:
parent
f44fc2c665
commit
991624461f
|
@ -51,10 +51,6 @@ any details of its type. */
|
||||||
typedef void tskTCB;
|
typedef void tskTCB;
|
||||||
extern volatile tskTCB * volatile pxCurrentTCB;
|
extern volatile tskTCB * volatile pxCurrentTCB;
|
||||||
|
|
||||||
/* Constants required to handle critical sections. */
|
|
||||||
#define portNO_CRITICAL_NESTING ( ( unsigned portBASE_TYPE ) 0 )
|
|
||||||
volatile unsigned portLONG ulCriticalNesting = 9999UL;
|
|
||||||
|
|
||||||
/*-----------------------------------------------------------*/
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
#pragma asm
|
#pragma asm
|
||||||
|
@ -66,10 +62,6 @@ volatile unsigned portLONG ulCriticalNesting = 9999UL;
|
||||||
ST MDH, @-R15 ;Store MDH
|
ST MDH, @-R15 ;Store MDH
|
||||||
ST MDL, @-R15 ;Store MDL
|
ST MDL, @-R15 ;Store MDL
|
||||||
|
|
||||||
LDI #_ulCriticalNesting, R0 ;Get the address of the critical nesting counter
|
|
||||||
LD @R0, R0 ;Get the value of the critical nesting counter
|
|
||||||
ST R0, @-R15 ;Store the critical nesting value to the user stack.
|
|
||||||
|
|
||||||
ANDCCR #0xDF ;Switch back to system stack
|
ANDCCR #0xDF ;Switch back to system stack
|
||||||
LD @R15+,R0 ;Store PC to R0
|
LD @R15+,R0 ;Store PC to R0
|
||||||
ORCCR #0x20 ;Switch to user stack
|
ORCCR #0x20 ;Switch to user stack
|
||||||
|
@ -104,10 +96,6 @@ volatile unsigned portLONG ulCriticalNesting = 9999UL;
|
||||||
|
|
||||||
ORCCR #0x20 ;Switch back to retrieve the remaining context
|
ORCCR #0x20 ;Switch back to retrieve the remaining context
|
||||||
|
|
||||||
LDI #_ulCriticalNesting, R0 ;Get the address of the critical nesting counter
|
|
||||||
LD @R15+, R1 ;Get the saved critical nesting value
|
|
||||||
ST R1, @R0 ;Save the critical nesting value into the ulCriticalNesting variable
|
|
||||||
|
|
||||||
LD @R15+, MDL ;Restore MDL
|
LD @R15+, MDL ;Restore MDL
|
||||||
LD @R15+, MDH ;Restore MDH
|
LD @R15+, MDH ;Restore MDH
|
||||||
LDM1 (R14,R13,R12,R11,R10,R9,R8) ;Restore R14-R8
|
LDM1 (R14,R13,R12,R11,R10,R9,R8) ;Restore R14-R8
|
||||||
|
@ -192,11 +180,6 @@ portSTACK_TYPE *pxPortInitialiseStack( portSTACK_TYPE *pxTopOfStack, pdTASK_CODE
|
||||||
*pxTopOfStack = ( portSTACK_TYPE ) 0x22220000; /* MDL */
|
*pxTopOfStack = ( portSTACK_TYPE ) 0x22220000; /* MDL */
|
||||||
pxTopOfStack--;
|
pxTopOfStack--;
|
||||||
|
|
||||||
/* The task starts with its ulCriticalNesting variable set to 0,
|
|
||||||
interrupts being enabled. */
|
|
||||||
*pxTopOfStack = portNO_CRITICAL_NESTING;
|
|
||||||
pxTopOfStack--;
|
|
||||||
|
|
||||||
/* The start of the task code. */
|
/* The start of the task code. */
|
||||||
*pxTopOfStack = ( portSTACK_TYPE ) pxCode; /* PC */
|
*pxTopOfStack = ( portSTACK_TYPE ) pxCode; /* PC */
|
||||||
pxTopOfStack--;
|
pxTopOfStack--;
|
||||||
|
@ -351,32 +334,3 @@ const unsigned portSHORT usReloadValue = ( unsigned portSHORT ) ( ( ( configPER_
|
||||||
#pragma endasm
|
#pragma endasm
|
||||||
/*-----------------------------------------------------------*/
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
void vPortEnterCritical( void )
|
|
||||||
{
|
|
||||||
/* Disable interrupts upto level 30. */
|
|
||||||
#if configKERNEL_INTERRUPT_PRIORITY != 30
|
|
||||||
#error configKERNEL_INTERRUPT_PRIORITY (set in FreeRTOSConfig.h) must match the ILM value set in the following line - 30 (0x1e) being the default.
|
|
||||||
#endif
|
|
||||||
|
|
||||||
__asm(" STILM #1Eh ");
|
|
||||||
|
|
||||||
|
|
||||||
/* Now interrupts are disabled ulCriticalNesting can be accessed
|
|
||||||
directly. Increment ulCriticalNesting to keep a count of how many times
|
|
||||||
portENTER_CRITICAL() has been called. */
|
|
||||||
ulCriticalNesting++;
|
|
||||||
}
|
|
||||||
/*-----------------------------------------------------------*/
|
|
||||||
|
|
||||||
void vPortExitCritical( void )
|
|
||||||
{
|
|
||||||
if( ulCriticalNesting > portNO_CRITICAL_NESTING )
|
|
||||||
{
|
|
||||||
ulCriticalNesting--;
|
|
||||||
if( ulCriticalNesting == portNO_CRITICAL_NESTING )
|
|
||||||
{
|
|
||||||
/* Enable all interrupts */
|
|
||||||
__asm(" STILM #1Fh ");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -78,10 +78,14 @@
|
||||||
/*-----------------------------------------------------------*/
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
/* Critical section management. */
|
/* Critical section management. */
|
||||||
void vPortEnterCritical( void );
|
#define portENTER_CRITICAL() \
|
||||||
void vPortExitCritical( void );
|
__asm(" ST PS,@-R15 "); \
|
||||||
#define portENTER_CRITICAL() vPortEnterCritical()
|
__asm(" ANDCCR #0xef "); \
|
||||||
#define portEXIT_CRITICAL() vPortExitCritical()
|
|
||||||
|
|
||||||
|
#define portEXIT_CRITICAL() \
|
||||||
|
__asm(" LD @R15+,PS "); \
|
||||||
|
|
||||||
#define portDISABLE_INTERRUPTS() __DI();
|
#define portDISABLE_INTERRUPTS() __DI();
|
||||||
#define portENABLE_INTERRUPTS() __EI();
|
#define portENABLE_INTERRUPTS() __EI();
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue