From f053d62e1c53f531e5687f242af4ce6319b9b383 Mon Sep 17 00:00:00 2001 From: RichardBarry Date: Wed, 28 Jan 2009 12:37:04 +0000 Subject: [PATCH] Tidy up and comment. git-svn-id: https://svn.code.sf.net/p/freertos/code/trunk@631 1d2547de-c912-0410-9cb9-b8ca96c0e9e2 --- Source/portable/IAR/V850ES_Fx3/ISR_Support.h | 34 ++++++------ Source/portable/IAR/V850ES_Fx3/port.c | 6 +++ Source/portable/IAR/V850ES_Fx3/portmacro.h | 56 +++++++++----------- 3 files changed, 49 insertions(+), 47 deletions(-) diff --git a/Source/portable/IAR/V850ES_Fx3/ISR_Support.h b/Source/portable/IAR/V850ES_Fx3/ISR_Support.h index efb4cd561..1047a9946 100644 --- a/Source/portable/IAR/V850ES_Fx3/ISR_Support.h +++ b/Source/portable/IAR/V850ES_Fx3/ISR_Support.h @@ -58,12 +58,12 @@ portSAVE_CONTEXT MACRO - add -0x0C,sp ; prepare stack to save necessary values - st.w lp,8[sp] ; store LP to stack + add -0x0C,sp ; prepare stack to save necessary values + st.w lp,8[sp] ; store LP to stack stsr 0,r31 - st.w lp,4[sp] ; store EIPC to stack + st.w lp,4[sp] ; store EIPC to stack stsr 1,lp - st.w lp,0[sp] ; store EIPSW to stack + st.w lp,0[sp] ; store EIPSW to stack #if configDATA_MODE == 1 ; Using the Tiny data model prepare {r20,r21,r22,r23,r24,r25,r26,r27,r28,r29,r30},76,sp ; save general purpose registers sst.w r19,72[ep] @@ -102,10 +102,10 @@ portSAVE_CONTEXT MACRO #endif /* configDATA_MODE */ sst.w r2,8[ep] sst.w r1,4[ep] - MOVHI hi1(usCriticalNesting),r0,r1 ; save usCriticalNesting value to stack + MOVHI hi1(usCriticalNesting),r0,r1 ; save usCriticalNesting value to stack ld.w lw1(usCriticalNesting)[r1],r2 sst.w r2,0[ep] - MOVHI hi1(pxCurrentTCB),r0,r1 ; save SP to top of current TCB + MOVHI hi1(pxCurrentTCB),r0,r1 ; save SP to top of current TCB ld.w lw1(pxCurrentTCB)[r1],r2 st.w sp,0[r2] ENDM @@ -113,17 +113,17 @@ portSAVE_CONTEXT MACRO portRESTORE_CONTEXT MACRO - MOVHI hi1(pxCurrentTCB),r0,r1 ; get Stackpointer address + MOVHI hi1(pxCurrentTCB),r0,r1 ; get Stackpointer address ld.w lw1(pxCurrentTCB)[r1],sp MOV sp,r1 - ld.w 0[r1],sp ; load stackpointer - MOV sp,ep ; set stack pointer to element pointer - sld.w 0[ep],r1 ; load usCriticalNesting value from stack + ld.w 0[r1],sp ; load stackpointer + MOV sp,ep ; set stack pointer to element pointer + sld.w 0[ep],r1 ; load usCriticalNesting value from stack MOVHI hi1(usCriticalNesting),r0,r2 st.w r1,lw1(usCriticalNesting)[r2] - sld.w 4[ep],r1 ; restore general purpose registers + sld.w 4[ep],r1 ; restore general purpose registers sld.w 8[ep],r2 -#if configDATA_MODE == 1 ; Using Tiny data model +#if configDATA_MODE == 1 ; Using Tiny data model sld.w 12[ep],r4 sld.w 16[ep],r5 sld.w 20[ep],r6 @@ -141,7 +141,7 @@ portRESTORE_CONTEXT MACRO sld.w 68[ep],r18 sld.w 72[ep],r19 dispose 76,{r20,r21,r22,r23,r24,r25,r26,r27,r28,r29,r30} -#else ; Using Small/Large data model +#else ; Using Small/Large data model sld.w 12[ep],r5 sld.w 16[ep],r6 sld.w 20[ep],r7 @@ -159,12 +159,12 @@ portRESTORE_CONTEXT MACRO sld.w 68[ep],r19 dispose 72,{r20,r21,r22,r23,r24,r26,r27,r28,r29,r30} #endif /* configDATA_MODE */ - ld.w 0[sp],lp ; restore EIPSW from stack + ld.w 0[sp],lp ; restore EIPSW from stack ldsr lp,1 - ld.w 4[sp],lp ; restore EIPC from stack + ld.w 4[sp],lp ; restore EIPC from stack ldsr lp,0 - ld.w 8[sp],lp ; restore LP from stack - add 0x0C,sp ; set SP to right position + ld.w 8[sp],lp ; restore LP from stack + add 0x0C,sp ; set SP to right position RETI diff --git a/Source/portable/IAR/V850ES_Fx3/port.c b/Source/portable/IAR/V850ES_Fx3/port.c index 4ab01375b..df9fbbb27 100644 --- a/Source/portable/IAR/V850ES_Fx3/port.c +++ b/Source/portable/IAR/V850ES_Fx3/port.c @@ -54,8 +54,11 @@ #include "FreeRTOS.h" #include "task.h" +/* Critical nesting should be initialised to a non zero value so interrupts don't +accidentally get enabled before the scheduler is started. */ #define portINITIAL_CRITICAL_NESTING (( portSTACK_TYPE ) 10) +/* The PSW value assigned to tasks when they start to run for the first time. */ #define portPSW (( portSTACK_TYPE ) 0x00000000) /* We require the address of the pxCurrentTCB variable, but don't want to know @@ -63,11 +66,14 @@ any details of its type. */ typedef void tskTCB; extern volatile tskTCB * volatile pxCurrentTCB; +/* Keeps track of the nesting level of critical sections. */ volatile portSTACK_TYPE usCriticalNesting = portINITIAL_CRITICAL_NESTING; /*-----------------------------------------------------------*/ +/* Sets up the timer to generate the tick interrupt. */ static void prvSetupTimerInterrupt( void ); +/*-----------------------------------------------------------*/ portSTACK_TYPE *pxPortInitialiseStack( portSTACK_TYPE *pxTopOfStack, pdTASK_CODE pxCode, void *pvParameters ) { *pxTopOfStack = ( portSTACK_TYPE ) pxCode; /* Task function start address */ diff --git a/Source/portable/IAR/V850ES_Fx3/portmacro.h b/Source/portable/IAR/V850ES_Fx3/portmacro.h index 55a802b13..92afd1b30 100644 --- a/Source/portable/IAR/V850ES_Fx3/portmacro.h +++ b/Source/portable/IAR/V850ES_Fx3/portmacro.h @@ -91,34 +91,34 @@ extern "C" { /* Critical section control macros. */ #define portNO_CRITICAL_SECTION_NESTING ( ( unsigned portBASE_TYPE ) 0 ) -#define portENTER_CRITICAL() \ -{ \ -extern volatile /*unsigned portSHORT*/ portSTACK_TYPE usCriticalNesting; \ - \ - portDISABLE_INTERRUPTS(); \ - \ - /* Now interrupts are disabled ulCriticalNesting can be accessed */ \ - /* directly. Increment ulCriticalNesting to keep a count of how many */ \ - /* times portENTER_CRITICAL() has been called. */ \ - usCriticalNesting++; \ +#define portENTER_CRITICAL() \ +{ \ +extern volatile /*unsigned portSHORT*/ portSTACK_TYPE usCriticalNesting; \ + \ + portDISABLE_INTERRUPTS(); \ + \ + /* Now interrupts are disabled ulCriticalNesting can be accessed */ \ + /* directly. Increment ulCriticalNesting to keep a count of how many */ \ + /* times portENTER_CRITICAL() has been called. */ \ + usCriticalNesting++; \ } -#define portEXIT_CRITICAL() \ -{ \ -extern volatile /*unsigned portSHORT*/ portSTACK_TYPE usCriticalNesting; \ - \ - if( usCriticalNesting > portNO_CRITICAL_SECTION_NESTING ) \ - { \ - /* Decrement the nesting count as we are leaving a critical section. */ \ - usCriticalNesting--; \ - \ - /* If the nesting level has reached zero then interrupts should be */ \ - /* re-enabled. */ \ - if( usCriticalNesting == portNO_CRITICAL_SECTION_NESTING ) \ - { \ - portENABLE_INTERRUPTS(); \ - } \ - } \ +#define portEXIT_CRITICAL() \ +{ \ +extern volatile /*unsigned portSHORT*/ portSTACK_TYPE usCriticalNesting; \ + \ + if( usCriticalNesting > portNO_CRITICAL_SECTION_NESTING ) \ + { \ + /* Decrement the nesting count as we are leaving a critical section. */ \ + usCriticalNesting--; \ + \ + /* If the nesting level has reached zero then interrupts should be */ \ + /* re-enabled. */ \ + if( usCriticalNesting == portNO_CRITICAL_SECTION_NESTING ) \ + { \ + portENABLE_INTERRUPTS(); \ + } \ + } \ } /*-----------------------------------------------------------*/ @@ -127,7 +127,6 @@ extern void vPortYield( void ); extern void vPortStart( void ); extern void portSAVE_CONTEXT( void ); extern void portRESTORE_CONTEXT( void ); -//#define portYIELD() vPortYield() #define portYIELD() __asm ( "trap 0" ) #define portNOP() __asm ( "NOP" ) extern void vTaskSwitchContext( void ); @@ -146,9 +145,6 @@ extern void vTaskSwitchContext( void ); #define portTASK_FUNCTION( vFunction, pvParameters ) void vFunction( void *pvParameters ) -static __interrupt void MD_INTP0(void); - - #ifdef __cplusplus } #endif -- 2.39.5