From: richardbarry Date: Sun, 22 Aug 2010 18:28:48 +0000 (+0000) Subject: Just tidy up the RX port files. X-Git-Tag: V6.1.0~77 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=fb1d749649ebd9fb9a18130c0a35cee9edd6d64f;p=freertos Just tidy up the RX port files. git-svn-id: https://svn.code.sf.net/p/freertos/code/trunk@1058 1d2547de-c912-0410-9cb9-b8ca96c0e9e2 --- diff --git a/Source/portable/Renesas/RX600/port.c b/Source/portable/Renesas/RX600/port.c index 822a77c40..294f6a067 100644 --- a/Source/portable/Renesas/RX600/port.c +++ b/Source/portable/Renesas/RX600/port.c @@ -63,45 +63,44 @@ #include "string.h" /* Hardware specifics. */ -#include #include "iodefine.h" /*-----------------------------------------------------------*/ -/* Tasks should start with interrupts enabled, therefore PSW is set with U,I,PM -flags set and IPL clear. */ -/* - U = 1 User stack pointer. - I = 1 Interrupts enabled. - PM = 0 Supervisor mode. - IPL = 0 All interrupt priorities enabled. -*/ +/* Tasks should start with interrupts enabled and in Supervisor mode, therefore +PSW is set with U and I set, and PM and IPL clear. */ #define portINITIAL_PSW ( ( portSTACK_TYPE ) 0x00030000 ) #define portINITIAL_FPSW ( ( portSTACK_TYPE ) 0x00000100 ) /*-----------------------------------------------------------*/ /* - * + * Function to start the first task executing - written in asm code as direct + * access to registers is required. */ -void vPortYield( void ); +static void prvStartFirstTask( void ); /* - * Function to start the first task executing. + * Software interrupt handler. Performs the actual context switch (saving and + * restoring of registers). Written in asm code as direct register access is + * required. */ -void vPortStartFirstTask( void ); - -void vPortPendContextSwitch( void ); - -static void prvStartFirstTask( void ); - static void prvYieldHandler( void ); +/* + * The entry point for the software interrupt handler. This is the function + * that calls the inline asm function prvYieldHandler(). It is installed in + * the vector table, but the code that installs it is in prvYieldHandler rather + * than using a #pragma. + */ void vSoftwareInterruptISR( void ); /*-----------------------------------------------------------*/ +/* This is accessed by the inline assembler functions so is file scope for +convenience. */ extern void *pxCurrentTCB; +extern void vTaskSwitchContext( void ); /*-----------------------------------------------------------*/ @@ -117,35 +116,48 @@ portSTACK_TYPE *pxPortInitialiseStack( portSTACK_TYPE *pxTopOfStack, pdTASK_CODE *pxTopOfStack = portINITIAL_PSW; pxTopOfStack--; *pxTopOfStack = ( portSTACK_TYPE ) pxCode; - pxTopOfStack--; - *pxTopOfStack = 0xffffffff; /* r15. */ - pxTopOfStack--; - *pxTopOfStack = 0xeeeeeeee; - pxTopOfStack--; - *pxTopOfStack = 0xdddddddd; - pxTopOfStack--; - *pxTopOfStack = 0xcccccccc; - pxTopOfStack--; - *pxTopOfStack = 0xbbbbbbbb; - pxTopOfStack--; - *pxTopOfStack = 0xaaaaaaaa; - pxTopOfStack--; - *pxTopOfStack = 0x99999999; - pxTopOfStack--; - *pxTopOfStack = 0x88888888; - pxTopOfStack--; - *pxTopOfStack = 0x77777777; - pxTopOfStack--; - *pxTopOfStack = 0x66666666; - pxTopOfStack--; - *pxTopOfStack = 0x55555555; - pxTopOfStack--; - *pxTopOfStack = 0x44444444; - pxTopOfStack--; - *pxTopOfStack = 0x33333333; - pxTopOfStack--; - *pxTopOfStack = 0x22222222; - pxTopOfStack--; + + /* When debugging it can be useful if every register is set to a known + value. Otherwise code space can be saved by just setting the registers + that need to be set. */ + #ifdef USE_FULL_REGISTER_INITIALISATION + { + pxTopOfStack--; + *pxTopOfStack = 0xffffffff; /* r15. */ + pxTopOfStack--; + *pxTopOfStack = 0xeeeeeeee; + pxTopOfStack--; + *pxTopOfStack = 0xdddddddd; + pxTopOfStack--; + *pxTopOfStack = 0xcccccccc; + pxTopOfStack--; + *pxTopOfStack = 0xbbbbbbbb; + pxTopOfStack--; + *pxTopOfStack = 0xaaaaaaaa; + pxTopOfStack--; + *pxTopOfStack = 0x99999999; + pxTopOfStack--; + *pxTopOfStack = 0x88888888; + pxTopOfStack--; + *pxTopOfStack = 0x77777777; + pxTopOfStack--; + *pxTopOfStack = 0x66666666; + pxTopOfStack--; + *pxTopOfStack = 0x55555555; + pxTopOfStack--; + *pxTopOfStack = 0x44444444; + pxTopOfStack--; + *pxTopOfStack = 0x33333333; + pxTopOfStack--; + *pxTopOfStack = 0x22222222; + pxTopOfStack--; + } + #else + { + pxTopOfStack -= 15; + } + #endif + *pxTopOfStack = ( portSTACK_TYPE ) pvParameters; /* R1 */ pxTopOfStack--; *pxTopOfStack = portINITIAL_FPSW; @@ -197,13 +209,13 @@ static void prvStartFirstTask( void ) /* When starting the scheduler there is nothing that needs moving to the interrupt stack because the function is not called from an interrupt. Just ensure the current stack is the user stack. */ - SETPSW U + SETPSW U /* Obtain the location of the stack associated with which ever task pxCurrentTCB is currently pointing to. */ - MOV.L #_pxCurrentTCB, R15 - MOV.L [R15], R15 - MOV.L [R15], R0 + MOV.L #_pxCurrentTCB, R15 + MOV.L [R15], R15 + MOV.L [R15], R0 /* Restore the registers from the stack of the task pointed to by pxCurrentTCB. */ @@ -223,9 +235,11 @@ static void prvStartFirstTask( void ) #pragma interrupt ( vTickISR( vect = _VECT( configTICK_VECTOR ), enable ) ) void vTickISR( void ) { - /* Clear the interrupt. */ + /* Increment the tick, and perform any processing the new tick value + necessitates. */ vTaskIncrementTick(); + /* Only select a new task if the preemptive scheduler is being used. */ #if( configUSE_PREEMPTION == 1 ) taskYIELD(); #endif @@ -250,7 +264,7 @@ static void prvYieldHandler( void ) /* Move the data that was automatically pushed onto the interrupt stack when the interrupt occurred from the interrupt stack to the user stack. - R15 is saved before it is used. */ + R15 is saved before it is clobbered. */ PUSH.L R15 /* Read the user stack pointer. */ @@ -260,7 +274,7 @@ static void prvYieldHandler( void ) SUB #12, R15 MVTC R15, USP - /* Copy the data accross. */ + /* Copy the data across. */ MOV.L [ R0 ], [ R15 ] ; R15 MOV.L 4[ R0 ], 4[ R15 ] ; PC MOV.L 8[ R0 ], 8[ R15 ] ; PSW @@ -271,14 +285,16 @@ static void prvYieldHandler( void ) /* All the rest of the registers are saved directly to the user stack. */ SETPSW U - /* Save the rest of the registers (R15 has been saved already. */ - PUSHM R1-R14 ; General purpose registers. - MVFC FPSW, R15 ; Floating point status word. + /* Save the rest of the general registers (R15 has been saved already). */ + PUSHM R1-R14 + + /* Save the FPSW and accumulator. */ + MVFC FPSW, R15 PUSH.L R15 - MVFACHI R15 ; Accumulator + MVFACHI R15 PUSH.L R15 - MVFACMI R15 ; Accumulator - SHLL #16, R15 + MVFACMI R15 ; Middle order word. + SHLL #16, R15 ; Shifted left as it is restored to the low order word. PUSH.L R15 /* Save the stack pointer to the TCB. */ @@ -293,7 +309,7 @@ static void prvYieldHandler( void ) /* Select the next task to run. */ BSR.A _vTaskSwitchContext - /* Reset the interrupt mask. */ + /* Reset the interrupt mask as no more data structure access is required. */ MVTIPL #configKERNEL_INTERRUPT_PRIORITY /* Load the stack pointer of the task that is now selected as the Running diff --git a/Source/portable/Renesas/RX600/portmacro.h b/Source/portable/Renesas/RX600/portmacro.h index 82cf1676b..8919e062e 100644 --- a/Source/portable/Renesas/RX600/portmacro.h +++ b/Source/portable/Renesas/RX600/portmacro.h @@ -92,20 +92,16 @@ portSTACK_TYPE and portBASE_TYPE. */ /*-----------------------------------------------------------*/ /* Hardware specifics. */ -#define portBYTE_ALIGNMENT 8 +#define portBYTE_ALIGNMENT 8 /* Could make four, according to manual. */ #define portSTACK_GROWTH -1 #define portTICK_RATE_MS ( ( portTickType ) 1000 / configTICK_RATE_HZ ) #define portNOP() nop() -#define portSTART_SCHEDULER_TRAP_NO ( 32 ) -#define portKERNEL_INTERRUPT_PRIORITY ( 1 ) /* The location of the software interrupt register. Software interrupts use vector 27. */ #define portITU_SWINTR ( ( unsigned char * ) 0x000872E0 ) #define portYIELD() *portITU_SWINTR = 0x01; nop(); nop(); nop(); nop(); nop() - -extern void vTaskSwitchContext( void ); -#define portYIELD_FROM_ISR( x ) if( x != pdFALSE ) portYIELD() +#define portYIELD_FROM_ISR( x ) if( x != pdFALSE ) portYIELD() /* * These macros should be called directly, but through the taskENTER_CRITICAL() @@ -114,9 +110,6 @@ extern void vTaskSwitchContext( void ); #define portENABLE_INTERRUPTS() set_ipl( 0 ) #define portDISABLE_INTERRUPTS() set_ipl( configMAX_SYSCALL_INTERRUPT_PRIORITY ) -#define portSET_INTERRUPT_MASK_FROM_ISR() get_ipl(); set_ipl( configMAX_SYSCALL_INTERRUPT_PRIORITY ) -#define portCLEAR_INTERRUPT_MASK_FROM_ISR( uxSavedInterruptStatus ) set_ipl( uxSavedInterruptStatus ) - /* Critical nesting counts are stored in the TCB. */ #define portCRITICAL_NESTING_IN_TCB ( 1 ) @@ -126,6 +119,9 @@ extern void vTaskExitCritical( void ); #define portENTER_CRITICAL() vTaskEnterCritical(); #define portEXIT_CRITICAL() vTaskExitCritical(); +/* As this port allows interrupt nesting... */ +#define portSET_INTERRUPT_MASK_FROM_ISR() get_ipl(); set_ipl( configMAX_SYSCALL_INTERRUPT_PRIORITY ) +#define portCLEAR_INTERRUPT_MASK_FROM_ISR( uxSavedInterruptStatus ) set_ipl( uxSavedInterruptStatus ) /*-----------------------------------------------------------*/