mirror of
https://github.com/FreeRTOS/FreeRTOS-Kernel.git
synced 2025-04-19 21:11:57 -04:00
Just tidy up the RX port files.
This commit is contained in:
parent
a33e3b3979
commit
ac19e40336
|
@ -63,45 +63,44 @@
|
||||||
#include "string.h"
|
#include "string.h"
|
||||||
|
|
||||||
/* Hardware specifics. */
|
/* Hardware specifics. */
|
||||||
#include <machine.h>
|
|
||||||
#include "iodefine.h"
|
#include "iodefine.h"
|
||||||
|
|
||||||
/*-----------------------------------------------------------*/
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
/* Tasks should start with interrupts enabled, therefore PSW is set with U,I,PM
|
/* Tasks should start with interrupts enabled and in Supervisor mode, therefore
|
||||||
flags set and IPL clear. */
|
PSW is set with U and I set, and PM and IPL clear. */
|
||||||
/*
|
|
||||||
U = 1 User stack pointer.
|
|
||||||
I = 1 Interrupts enabled.
|
|
||||||
PM = 0 Supervisor mode.
|
|
||||||
IPL = 0 All interrupt priorities enabled.
|
|
||||||
*/
|
|
||||||
#define portINITIAL_PSW ( ( portSTACK_TYPE ) 0x00030000 )
|
#define portINITIAL_PSW ( ( portSTACK_TYPE ) 0x00030000 )
|
||||||
#define portINITIAL_FPSW ( ( portSTACK_TYPE ) 0x00000100 )
|
#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 );
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Function to start the first task executing.
|
|
||||||
*/
|
|
||||||
void vPortStartFirstTask( void );
|
|
||||||
|
|
||||||
void vPortPendContextSwitch( void );
|
|
||||||
|
|
||||||
static void prvStartFirstTask( void );
|
static void prvStartFirstTask( void );
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Software interrupt handler. Performs the actual context switch (saving and
|
||||||
|
* restoring of registers). Written in asm code as direct register access is
|
||||||
|
* required.
|
||||||
|
*/
|
||||||
static void prvYieldHandler( 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 );
|
void vSoftwareInterruptISR( void );
|
||||||
|
|
||||||
/*-----------------------------------------------------------*/
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
|
/* This is accessed by the inline assembler functions so is file scope for
|
||||||
|
convenience. */
|
||||||
extern void *pxCurrentTCB;
|
extern void *pxCurrentTCB;
|
||||||
|
extern void vTaskSwitchContext( void );
|
||||||
|
|
||||||
/*-----------------------------------------------------------*/
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
|
@ -117,35 +116,48 @@ portSTACK_TYPE *pxPortInitialiseStack( portSTACK_TYPE *pxTopOfStack, pdTASK_CODE
|
||||||
*pxTopOfStack = portINITIAL_PSW;
|
*pxTopOfStack = portINITIAL_PSW;
|
||||||
pxTopOfStack--;
|
pxTopOfStack--;
|
||||||
*pxTopOfStack = ( portSTACK_TYPE ) pxCode;
|
*pxTopOfStack = ( portSTACK_TYPE ) pxCode;
|
||||||
pxTopOfStack--;
|
|
||||||
*pxTopOfStack = 0xffffffff; /* r15. */
|
/* When debugging it can be useful if every register is set to a known
|
||||||
pxTopOfStack--;
|
value. Otherwise code space can be saved by just setting the registers
|
||||||
*pxTopOfStack = 0xeeeeeeee;
|
that need to be set. */
|
||||||
pxTopOfStack--;
|
#ifdef USE_FULL_REGISTER_INITIALISATION
|
||||||
*pxTopOfStack = 0xdddddddd;
|
{
|
||||||
pxTopOfStack--;
|
pxTopOfStack--;
|
||||||
*pxTopOfStack = 0xcccccccc;
|
*pxTopOfStack = 0xffffffff; /* r15. */
|
||||||
pxTopOfStack--;
|
pxTopOfStack--;
|
||||||
*pxTopOfStack = 0xbbbbbbbb;
|
*pxTopOfStack = 0xeeeeeeee;
|
||||||
pxTopOfStack--;
|
pxTopOfStack--;
|
||||||
*pxTopOfStack = 0xaaaaaaaa;
|
*pxTopOfStack = 0xdddddddd;
|
||||||
pxTopOfStack--;
|
pxTopOfStack--;
|
||||||
*pxTopOfStack = 0x99999999;
|
*pxTopOfStack = 0xcccccccc;
|
||||||
pxTopOfStack--;
|
pxTopOfStack--;
|
||||||
*pxTopOfStack = 0x88888888;
|
*pxTopOfStack = 0xbbbbbbbb;
|
||||||
pxTopOfStack--;
|
pxTopOfStack--;
|
||||||
*pxTopOfStack = 0x77777777;
|
*pxTopOfStack = 0xaaaaaaaa;
|
||||||
pxTopOfStack--;
|
pxTopOfStack--;
|
||||||
*pxTopOfStack = 0x66666666;
|
*pxTopOfStack = 0x99999999;
|
||||||
pxTopOfStack--;
|
pxTopOfStack--;
|
||||||
*pxTopOfStack = 0x55555555;
|
*pxTopOfStack = 0x88888888;
|
||||||
pxTopOfStack--;
|
pxTopOfStack--;
|
||||||
*pxTopOfStack = 0x44444444;
|
*pxTopOfStack = 0x77777777;
|
||||||
pxTopOfStack--;
|
pxTopOfStack--;
|
||||||
*pxTopOfStack = 0x33333333;
|
*pxTopOfStack = 0x66666666;
|
||||||
pxTopOfStack--;
|
pxTopOfStack--;
|
||||||
*pxTopOfStack = 0x22222222;
|
*pxTopOfStack = 0x55555555;
|
||||||
pxTopOfStack--;
|
pxTopOfStack--;
|
||||||
|
*pxTopOfStack = 0x44444444;
|
||||||
|
pxTopOfStack--;
|
||||||
|
*pxTopOfStack = 0x33333333;
|
||||||
|
pxTopOfStack--;
|
||||||
|
*pxTopOfStack = 0x22222222;
|
||||||
|
pxTopOfStack--;
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
{
|
||||||
|
pxTopOfStack -= 15;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
*pxTopOfStack = ( portSTACK_TYPE ) pvParameters; /* R1 */
|
*pxTopOfStack = ( portSTACK_TYPE ) pvParameters; /* R1 */
|
||||||
pxTopOfStack--;
|
pxTopOfStack--;
|
||||||
*pxTopOfStack = portINITIAL_FPSW;
|
*pxTopOfStack = portINITIAL_FPSW;
|
||||||
|
@ -197,13 +209,13 @@ static void prvStartFirstTask( void )
|
||||||
/* When starting the scheduler there is nothing that needs moving to the
|
/* When starting the scheduler there is nothing that needs moving to the
|
||||||
interrupt stack because the function is not called from an interrupt.
|
interrupt stack because the function is not called from an interrupt.
|
||||||
Just ensure the current stack is the user stack. */
|
Just ensure the current stack is the user stack. */
|
||||||
SETPSW U
|
SETPSW U
|
||||||
|
|
||||||
/* Obtain the location of the stack associated with which ever task
|
/* Obtain the location of the stack associated with which ever task
|
||||||
pxCurrentTCB is currently pointing to. */
|
pxCurrentTCB is currently pointing to. */
|
||||||
MOV.L #_pxCurrentTCB, R15
|
MOV.L #_pxCurrentTCB, R15
|
||||||
MOV.L [R15], R15
|
MOV.L [R15], R15
|
||||||
MOV.L [R15], R0
|
MOV.L [R15], R0
|
||||||
|
|
||||||
/* Restore the registers from the stack of the task pointed to by
|
/* Restore the registers from the stack of the task pointed to by
|
||||||
pxCurrentTCB. */
|
pxCurrentTCB. */
|
||||||
|
@ -223,9 +235,11 @@ static void prvStartFirstTask( void )
|
||||||
#pragma interrupt ( vTickISR( vect = _VECT( configTICK_VECTOR ), enable ) )
|
#pragma interrupt ( vTickISR( vect = _VECT( configTICK_VECTOR ), enable ) )
|
||||||
void vTickISR( void )
|
void vTickISR( void )
|
||||||
{
|
{
|
||||||
/* Clear the interrupt. */
|
/* Increment the tick, and perform any processing the new tick value
|
||||||
|
necessitates. */
|
||||||
vTaskIncrementTick();
|
vTaskIncrementTick();
|
||||||
|
|
||||||
|
/* Only select a new task if the preemptive scheduler is being used. */
|
||||||
#if( configUSE_PREEMPTION == 1 )
|
#if( configUSE_PREEMPTION == 1 )
|
||||||
taskYIELD();
|
taskYIELD();
|
||||||
#endif
|
#endif
|
||||||
|
@ -250,7 +264,7 @@ static void prvYieldHandler( void )
|
||||||
/* Move the data that was automatically pushed onto the interrupt stack when
|
/* Move the data that was automatically pushed onto the interrupt stack when
|
||||||
the interrupt occurred from the interrupt stack to the user stack.
|
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
|
PUSH.L R15
|
||||||
|
|
||||||
/* Read the user stack pointer. */
|
/* Read the user stack pointer. */
|
||||||
|
@ -260,7 +274,7 @@ static void prvYieldHandler( void )
|
||||||
SUB #12, R15
|
SUB #12, R15
|
||||||
MVTC R15, USP
|
MVTC R15, USP
|
||||||
|
|
||||||
/* Copy the data accross. */
|
/* Copy the data across. */
|
||||||
MOV.L [ R0 ], [ R15 ] ; R15
|
MOV.L [ R0 ], [ R15 ] ; R15
|
||||||
MOV.L 4[ R0 ], 4[ R15 ] ; PC
|
MOV.L 4[ R0 ], 4[ R15 ] ; PC
|
||||||
MOV.L 8[ R0 ], 8[ R15 ] ; PSW
|
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. */
|
/* All the rest of the registers are saved directly to the user stack. */
|
||||||
SETPSW U
|
SETPSW U
|
||||||
|
|
||||||
/* Save the rest of the registers (R15 has been saved already. */
|
/* Save the rest of the general registers (R15 has been saved already). */
|
||||||
PUSHM R1-R14 ; General purpose registers.
|
PUSHM R1-R14
|
||||||
MVFC FPSW, R15 ; Floating point status word.
|
|
||||||
|
/* Save the FPSW and accumulator. */
|
||||||
|
MVFC FPSW, R15
|
||||||
PUSH.L R15
|
PUSH.L R15
|
||||||
MVFACHI R15 ; Accumulator
|
MVFACHI R15
|
||||||
PUSH.L R15
|
PUSH.L R15
|
||||||
MVFACMI R15 ; Accumulator
|
MVFACMI R15 ; Middle order word.
|
||||||
SHLL #16, R15
|
SHLL #16, R15 ; Shifted left as it is restored to the low order word.
|
||||||
PUSH.L R15
|
PUSH.L R15
|
||||||
|
|
||||||
/* Save the stack pointer to the TCB. */
|
/* Save the stack pointer to the TCB. */
|
||||||
|
@ -293,7 +309,7 @@ static void prvYieldHandler( void )
|
||||||
/* Select the next task to run. */
|
/* Select the next task to run. */
|
||||||
BSR.A _vTaskSwitchContext
|
BSR.A _vTaskSwitchContext
|
||||||
|
|
||||||
/* Reset the interrupt mask. */
|
/* Reset the interrupt mask as no more data structure access is required. */
|
||||||
MVTIPL #configKERNEL_INTERRUPT_PRIORITY
|
MVTIPL #configKERNEL_INTERRUPT_PRIORITY
|
||||||
|
|
||||||
/* Load the stack pointer of the task that is now selected as the Running
|
/* Load the stack pointer of the task that is now selected as the Running
|
||||||
|
|
|
@ -92,20 +92,16 @@ portSTACK_TYPE and portBASE_TYPE. */
|
||||||
/*-----------------------------------------------------------*/
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
/* Hardware specifics. */
|
/* Hardware specifics. */
|
||||||
#define portBYTE_ALIGNMENT 8
|
#define portBYTE_ALIGNMENT 8 /* Could make four, according to manual. */
|
||||||
#define portSTACK_GROWTH -1
|
#define portSTACK_GROWTH -1
|
||||||
#define portTICK_RATE_MS ( ( portTickType ) 1000 / configTICK_RATE_HZ )
|
#define portTICK_RATE_MS ( ( portTickType ) 1000 / configTICK_RATE_HZ )
|
||||||
#define portNOP() nop()
|
#define portNOP() nop()
|
||||||
#define portSTART_SCHEDULER_TRAP_NO ( 32 )
|
|
||||||
#define portKERNEL_INTERRUPT_PRIORITY ( 1 )
|
|
||||||
|
|
||||||
/* The location of the software interrupt register. Software interrupts use
|
/* The location of the software interrupt register. Software interrupts use
|
||||||
vector 27. */
|
vector 27. */
|
||||||
#define portITU_SWINTR ( ( unsigned char * ) 0x000872E0 )
|
#define portITU_SWINTR ( ( unsigned char * ) 0x000872E0 )
|
||||||
#define portYIELD() *portITU_SWINTR = 0x01; nop(); nop(); nop(); nop(); nop()
|
#define portYIELD() *portITU_SWINTR = 0x01; nop(); nop(); nop(); nop(); nop()
|
||||||
|
#define portYIELD_FROM_ISR( x ) if( x != pdFALSE ) portYIELD()
|
||||||
extern void vTaskSwitchContext( void );
|
|
||||||
#define portYIELD_FROM_ISR( x ) if( x != pdFALSE ) portYIELD()
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* These macros should be called directly, but through the taskENTER_CRITICAL()
|
* 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 portENABLE_INTERRUPTS() set_ipl( 0 )
|
||||||
#define portDISABLE_INTERRUPTS() set_ipl( configMAX_SYSCALL_INTERRUPT_PRIORITY )
|
#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. */
|
/* Critical nesting counts are stored in the TCB. */
|
||||||
#define portCRITICAL_NESTING_IN_TCB ( 1 )
|
#define portCRITICAL_NESTING_IN_TCB ( 1 )
|
||||||
|
|
||||||
|
@ -126,6 +119,9 @@ extern void vTaskExitCritical( void );
|
||||||
#define portENTER_CRITICAL() vTaskEnterCritical();
|
#define portENTER_CRITICAL() vTaskEnterCritical();
|
||||||
#define portEXIT_CRITICAL() vTaskExitCritical();
|
#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 )
|
||||||
|
|
||||||
/*-----------------------------------------------------------*/
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue