From e530fc1131c00ff25bbf449035a4db01ced60437 Mon Sep 17 00:00:00 2001 From: richardbarry Date: Fri, 9 Sep 2011 16:18:57 +0000 Subject: [PATCH] Tidy up the RL78 port layer. git-svn-id: https://svn.code.sf.net/p/freertos/code/trunk@1591 1d2547de-c912-0410-9cb9-b8ca96c0e9e2 --- Source/portable/IAR/RL78/port.c | 10 +++- Source/portable/IAR/RL78/portasm.s87 | 79 +++++----------------------- Source/portable/IAR/RL78/portmacro.h | 1 - 3 files changed, 22 insertions(+), 68 deletions(-) diff --git a/Source/portable/IAR/RL78/port.c b/Source/portable/IAR/RL78/port.c index e652683e9..b9e898cf1 100644 --- a/Source/portable/IAR/RL78/port.c +++ b/Source/portable/IAR/RL78/port.c @@ -76,7 +76,7 @@ interrupts don't accidentally become enabled before the scheduler is started. */ * |--------------------- Zero Flag set * ---------------------- Global Interrupt Flag set (enabled) */ -#define portPSW ( 0xc6U ) +#define portPSW ( 0xc6UL ) /* The address of the pxCurrentTCB variable, but don't know or need to know its type. */ @@ -100,6 +100,12 @@ volatile unsigned short usCriticalNesting = portINITIAL_CRITICAL_NESTING; */ static void prvSetupTimerInterrupt( void ); +/* + * Defined in portasm.s87, this function starts the scheduler by loading the + * context of the first task to run. + */ +extern void vPortStartFirstTask( void ); + /*-----------------------------------------------------------*/ /* @@ -192,7 +198,7 @@ portBASE_TYPE xPortStartScheduler( void ) prvSetupTimerInterrupt(); /* Restore the context of the first task that is going to run. */ - vPortStart(); + vPortStartFirstTask(); /* Execution should not reach here as the tasks are now running! */ return pdTRUE; diff --git a/Source/portable/IAR/RL78/portasm.s87 b/Source/portable/IAR/RL78/portasm.s87 index 50f621052..c4fa9fb91 100644 --- a/Source/portable/IAR/RL78/portasm.s87 +++ b/Source/portable/IAR/RL78/portasm.s87 @@ -61,40 +61,15 @@ #define CS 0xFFFFC #define ES 0xFFFFD -; Functions implemented in this file -;------------------------------------------------------------------------------ PUBLIC vPortYield - PUBLIC vPortStart + PUBLIC vPortStartFirstTask + PUBLIC vPortTickISR -; Functions used by scheduler -;------------------------------------------------------------------------------ EXTERN vTaskSwitchContext EXTERN vTaskIncrementTick -; Tick ISR Prototype -;------------------------------------------------------------------------------ - EXTERN ?CLRL78_V1_0_L00 - - PUBWEAK `??MD_INTIT??INTVEC 56` - PUBLIC MD_INTIT - -MD_INTIT SYMBOL "MD_INTIT" -`??MD_INTIT??INTVEC 56` SYMBOL "??INTVEC 56", MD_INTIT - - - -;------------------------------------------------------------------------------ -; Yield to another task. Implemented as a software interrupt. The return -; address and PSW will have been saved to the stack automatically before -; this code runs. -; -; Input: NONE -; -; Call: CALL vPortYield -; -; Output: NONE -; -;------------------------------------------------------------------------------ +; FreeRTOS yield handler. This is installed as the BRK software interrupt +; handler. RSEG CODE:CODE vPortYield: portSAVE_CONTEXT ; Save the context of the current task. @@ -103,35 +78,17 @@ vPortYield: retb -;------------------------------------------------------------------------------ -; Restore the context of the first task that is going to run. -; -; Input: NONE -; -; Call: CALL vPortStart -; -; Output: NONE -; -;------------------------------------------------------------------------------ +; Starts the scheduler by restoring the context of the task that will execute +; first. RSEG CODE:CODE -vPortStart: +vPortStartFirstTask: portRESTORE_CONTEXT ; Restore the context of whichever task the ... reti ; An interrupt stack frame is used so the task ; is started using a RETI instruction. -;------------------------------------------------------------------------------ -; Perform the necessary steps of the Tick Count Increment and Task Switch -; depending on the chosen kernel configuration -; -; Input: NONE -; -; Call: ISR -; -; Output: NONE -; -;------------------------------------------------------------------------------ - -MD_INTIT: +; FreeRTOS tick handler. This is installed as the interval timer interrupt +; handler. +vPortTickISR: portSAVE_CONTEXT ; Save the context of the current task. call vTaskIncrementTick ; Call the timer tick function. @@ -142,23 +99,15 @@ MD_INTIT: reti +; Install the interrupt handlers - REQUIRE ?CLRL78_V1_0_L00 - COMMON INTVEC:CODE:ROOT(1) ; Set ISR location to the Interrupt vector table. + COMMON INTVEC:CODE:ROOT(1) ORG 56 -`??MD_INTIT??INTVEC 56`: - DW MD_INTIT + DW vPortTickISR - COMMON INTVEC:CODE:ROOT(1) ; Set ISR location to the Interrupt vector table. + COMMON INTVEC:CODE:ROOT(1) ORG 126 -`??vPortYield??INTVEC 126`: DW vPortYield - ; Set value for the usCriticalNesting. - RSEG NEAR_ID:CONST:SORT:NOROOT(1) -`?`: - DW 10 - -;#endif END \ No newline at end of file diff --git a/Source/portable/IAR/RL78/portmacro.h b/Source/portable/IAR/RL78/portmacro.h index ec873d120..d91b0cb6e 100644 --- a/Source/portable/IAR/RL78/portmacro.h +++ b/Source/portable/IAR/RL78/portmacro.h @@ -140,7 +140,6 @@ extern volatile unsigned short usCriticalNesting; \ /*-----------------------------------------------------------*/ /* Task utilities. */ -extern void vPortStart( void ); #define portYIELD() __asm( "BRK" ) #define portYIELD_FROM_ISR( xHigherPriorityTaskWoken ) if( xHigherPriorityTaskWoken ) vTaskSwitchContext() #define portNOP() __asm( "NOP" ) -- 2.39.5