mirror of
https://github.com/FreeRTOS/FreeRTOS-Kernel.git
synced 2025-04-20 05:21:59 -04:00
Continue 78K0R development.
This commit is contained in:
parent
7acae9e570
commit
46425b4099
|
@ -37,13 +37,13 @@
|
||||||
Please ensure to read the configuration and relevant port sections of the
|
Please ensure to read the configuration and relevant port sections of the
|
||||||
online documentation.
|
online documentation.
|
||||||
|
|
||||||
http://www.FreeRTOS.org - Documentation, latest information, license and
|
http://www.FreeRTOS.org - Documentation, latest information, license and
|
||||||
contact details.
|
contact details.
|
||||||
|
|
||||||
http://www.SafeRTOS.com - A version that is certified for use in safety
|
http://www.SafeRTOS.com - A version that is certified for use in safety
|
||||||
critical systems.
|
critical systems.
|
||||||
|
|
||||||
http://www.OpenRTOS.com - Commercial support, development, porting,
|
http://www.OpenRTOS.com - Commercial support, development, porting,
|
||||||
licensing and training services.
|
licensing and training services.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -67,7 +67,7 @@
|
||||||
* |--------------------- Zero Flag set
|
* |--------------------- Zero Flag set
|
||||||
* ---------------------- Global Interrupt Flag set (enabled)
|
* ---------------------- Global Interrupt Flag set (enabled)
|
||||||
*/
|
*/
|
||||||
#define portPSW (( portSTACK_TYPE ) 0xC600)
|
#define portPSW (0xc6000000UL)
|
||||||
|
|
||||||
/* We require the address of the pxCurrentTCB variable, but don't want to know
|
/* We require the address of the pxCurrentTCB variable, but don't want to know
|
||||||
any details of its type. */
|
any details of its type. */
|
||||||
|
@ -95,19 +95,19 @@ volatile unsigned portSHORT usCriticalNesting = portINITIAL_CRITICAL_NESTING;
|
||||||
__interrupt void MD_INTTM05( void );
|
__interrupt void MD_INTTM05( void );
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Sets up the periodic ISR used for the RTOS tick.
|
* Sets up the periodic ISR used for the RTOS tick.
|
||||||
*/
|
*/
|
||||||
static void prvSetupTimerInterrupt( void );
|
static void prvSetupTimerInterrupt( void );
|
||||||
/*-----------------------------------------------------------*/
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Initialise the stack of a task to look exactly as if a call to
|
* Initialise the stack of a task to look exactly as if a call to
|
||||||
* portSAVE_CONTEXT had been called.
|
* portSAVE_CONTEXT had been called.
|
||||||
*
|
*
|
||||||
* See the header file portable.h.
|
* See the header file portable.h.
|
||||||
*/
|
*/
|
||||||
portSTACK_TYPE *pxPortInitialiseStack( portSTACK_TYPE *pxTopOfStack, pdTASK_CODE pxCode, void *pvParameters )
|
portSTACK_TYPE *pxPortInitialiseStack( portSTACK_TYPE *pxTopOfStack, pdTASK_CODE pxCode, void *pvParameters )
|
||||||
{
|
{
|
||||||
unsigned long *pulLocal;
|
unsigned long *pulLocal;
|
||||||
|
|
||||||
#if configMEMORY_MODE == 1
|
#if configMEMORY_MODE == 1
|
||||||
|
@ -116,30 +116,31 @@ unsigned long *pulLocal;
|
||||||
pxTopOfStack--;
|
pxTopOfStack--;
|
||||||
pulLocal = ( unsigned long * ) pxTopOfStack;
|
pulLocal = ( unsigned long * ) pxTopOfStack;
|
||||||
*pulLocal = ( unsigned long ) pvParameters;
|
*pulLocal = ( unsigned long ) pvParameters;
|
||||||
pxTopOfStack--;
|
pxTopOfStack--;
|
||||||
|
|
||||||
/* Dummy values on the stack because there normaly the return address
|
/* Dummy values on the stack because there normaly the return address
|
||||||
of the funtion is written. */
|
of the funtion is written. */
|
||||||
*pxTopOfStack = ( portSTACK_TYPE ) 0xcdcd;
|
*pxTopOfStack = ( portSTACK_TYPE ) 0xcdcd;
|
||||||
pxTopOfStack--;
|
pxTopOfStack--;
|
||||||
*pxTopOfStack = ( portSTACK_TYPE ) 0xcdcd;
|
*pxTopOfStack = ( portSTACK_TYPE ) 0xcdcd;
|
||||||
pxTopOfStack--;
|
|
||||||
pxTopOfStack--;
|
|
||||||
|
|
||||||
/* Task function start address. */
|
|
||||||
pulLocal = ( unsigned long * ) pxTopOfStack;
|
|
||||||
*pulLocal = ( unsigned long ) pxCode;
|
|
||||||
pxTopOfStack--;
|
pxTopOfStack--;
|
||||||
|
|
||||||
/* Initial PSW value. */
|
/* Initial PSW value. */
|
||||||
*pxTopOfStack = portPSW;
|
// *pxTopOfStack = portPSW;
|
||||||
|
|
||||||
|
pxTopOfStack--;
|
||||||
|
|
||||||
|
|
||||||
|
/* Task function start address. */
|
||||||
|
pulLocal = ( unsigned long * ) pxTopOfStack;
|
||||||
|
*pulLocal = ( ( ( unsigned long ) pxCode ) | portPSW );
|
||||||
pxTopOfStack--;
|
pxTopOfStack--;
|
||||||
|
|
||||||
/* Next general purpose register AX. */
|
/* Next general purpose register AX. */
|
||||||
*pxTopOfStack = ( portSTACK_TYPE ) 0x1111;
|
*pxTopOfStack = ( portSTACK_TYPE ) 0x1111;
|
||||||
pxTopOfStack--;
|
pxTopOfStack--;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
{
|
{
|
||||||
pxTopOfStack--;
|
pxTopOfStack--;
|
||||||
|
|
||||||
|
@ -156,7 +157,7 @@ unsigned long *pulLocal;
|
||||||
*pxTopOfStack = ( portSTACK_TYPE ) pvParameters;
|
*pxTopOfStack = ( portSTACK_TYPE ) pvParameters;
|
||||||
pxTopOfStack--;
|
pxTopOfStack--;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* HL. */
|
/* HL. */
|
||||||
*pxTopOfStack = ( portSTACK_TYPE ) 0x2222;
|
*pxTopOfStack = ( portSTACK_TYPE ) 0x2222;
|
||||||
|
@ -173,7 +174,7 @@ unsigned long *pulLocal;
|
||||||
pxTopOfStack--;
|
pxTopOfStack--;
|
||||||
*pxTopOfStack = ( portSTACK_TYPE ) portNO_CRITICAL_SECTION_NESTING;
|
*pxTopOfStack = ( portSTACK_TYPE ) portNO_CRITICAL_SECTION_NESTING;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Return a pointer to the top of the stack we have generated so this can
|
* Return a pointer to the top of the stack we have generated so this can
|
||||||
* be stored in the task control block for the task.
|
* be stored in the task control block for the task.
|
||||||
*/
|
*/
|
||||||
|
@ -203,8 +204,8 @@ void vPortEndScheduler( void )
|
||||||
/*-----------------------------------------------------------*/
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Hardware initialisation to generate the RTOS tick. This uses Channel 5 of
|
* Hardware initialisation to generate the RTOS tick. This uses Channel 5 of
|
||||||
* the Timer Array Unit (TAU). Any other Channel could also be used.
|
* the Timer Array Unit (TAU). Any other Channel could also be used.
|
||||||
*/
|
*/
|
||||||
static void prvSetupTimerInterrupt( void )
|
static void prvSetupTimerInterrupt( void )
|
||||||
{
|
{
|
||||||
|
@ -214,7 +215,7 @@ static void prvSetupTimerInterrupt( void )
|
||||||
/* To configure the Timer Array Unit all Channels have to first be stopped. */
|
/* To configure the Timer Array Unit all Channels have to first be stopped. */
|
||||||
TT0 = 0xff;
|
TT0 = 0xff;
|
||||||
|
|
||||||
/* Interrupt of Timer Array Unit Channel 5 is disabled to set the interrupt
|
/* Interrupt of Timer Array Unit Channel 5 is disabled to set the interrupt
|
||||||
priority. */
|
priority. */
|
||||||
TMMK05 = 1;
|
TMMK05 = 1;
|
||||||
|
|
||||||
|
|
|
@ -29,7 +29,7 @@
|
||||||
; ***************************************************************************
|
; ***************************************************************************
|
||||||
;
|
;
|
||||||
;------------------------------------------------------------------------------
|
;------------------------------------------------------------------------------
|
||||||
; Note: Select the correct include files for the device used by the application.
|
; Note: Select the correct include files for the device used by the application.
|
||||||
#include "FreeRTOSConfig.h"
|
#include "FreeRTOSConfig.h"
|
||||||
;------------------------------------------------------------------------------
|
;------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
@ -47,19 +47,19 @@
|
||||||
PUBLIC vPortStart
|
PUBLIC vPortStart
|
||||||
|
|
||||||
; Functions used by scheduler
|
; Functions used by scheduler
|
||||||
;------------------------------------------------------------------------------
|
;------------------------------------------------------------------------------
|
||||||
EXTERN vTaskSwitchContext
|
EXTERN vTaskSwitchContext
|
||||||
EXTERN vTaskIncrementTick
|
EXTERN vTaskIncrementTick
|
||||||
|
|
||||||
; Variables used by scheduler
|
; Variables used by scheduler
|
||||||
;------------------------------------------------------------------------------
|
;------------------------------------------------------------------------------
|
||||||
EXTERN pxCurrentTCB
|
EXTERN pxCurrentTCB
|
||||||
EXTERN usCriticalNesting
|
EXTERN usCriticalNesting
|
||||||
|
|
||||||
|
|
||||||
; Tick ISR Prototype
|
; Tick ISR Prototype
|
||||||
;------------------------------------------------------------------------------
|
;------------------------------------------------------------------------------
|
||||||
EXTERN ?CL78K0R_V2_L00
|
EXTERN ?CL78K0R_V2_L00
|
||||||
|
|
||||||
PUBWEAK `??MD_INTTM05??INTVEC 68`
|
PUBWEAK `??MD_INTTM05??INTVEC 68`
|
||||||
PUBLIC MD_INTTM05
|
PUBLIC MD_INTTM05
|
||||||
|
@ -72,21 +72,22 @@ MD_INTTM05 SYMBOL "MD_INTTM05"
|
||||||
; portSAVE_CONTEXT MACRO
|
; portSAVE_CONTEXT MACRO
|
||||||
; Saves the context of the remaining general purpose registers, CS and ES
|
; Saves the context of the remaining general purpose registers, CS and ES
|
||||||
; (only in far memory mode) registers
|
; (only in far memory mode) registers
|
||||||
; the usCriticalNesting Value and the Stack Pointer
|
; the usCriticalNesting Value and the Stack Pointer
|
||||||
; of the active Task onto the task stack
|
; of the active Task onto the task stack
|
||||||
;------------------------------------------------------------------------------
|
;------------------------------------------------------------------------------
|
||||||
portSAVE_CONTEXT MACRO
|
portSAVE_CONTEXT MACRO
|
||||||
|
|
||||||
|
PUSH AX ; save AX Register to stack
|
||||||
PUSH HL
|
PUSH HL
|
||||||
#if configMEMORY_MODE == 1
|
#if configMEMORY_MODE == 1
|
||||||
MOV A, CS ; save CS register
|
MOV A, CS ; save CS register
|
||||||
XCH A, X
|
XCH A, X
|
||||||
MOV A, ES ; save ES register
|
MOV A, ES ; save ES register
|
||||||
PUSH AX
|
PUSH AX
|
||||||
#else
|
#else
|
||||||
MOV A, CS ; save CS register
|
MOV A, CS ; save CS register
|
||||||
PUSH AX
|
PUSH AX
|
||||||
#endif
|
#endif
|
||||||
PUSH DE ; save the remaining general purpose registers
|
PUSH DE ; save the remaining general purpose registers
|
||||||
PUSH BC
|
PUSH BC
|
||||||
MOVW AX, usCriticalNesting ; save the usCriticalNesting value
|
MOVW AX, usCriticalNesting ; save the usCriticalNesting value
|
||||||
|
@ -102,7 +103,7 @@ portSAVE_CONTEXT MACRO
|
||||||
; portRESTORE_CONTEXT MACRO
|
; portRESTORE_CONTEXT MACRO
|
||||||
; Restores the context of the Stack Pointer, usCriticalNesting
|
; Restores the context of the Stack Pointer, usCriticalNesting
|
||||||
; value, general purpose registers and the CS and ES (only in far memory mode)
|
; value, general purpose registers and the CS and ES (only in far memory mode)
|
||||||
; of the selected task from the task stack
|
; of the selected task from the task stack
|
||||||
;------------------------------------------------------------------------------
|
;------------------------------------------------------------------------------
|
||||||
|
|
||||||
portRESTORE_CONTEXT MACRO
|
portRESTORE_CONTEXT MACRO
|
||||||
|
@ -114,16 +115,17 @@ portRESTORE_CONTEXT MACRO
|
||||||
MOVW usCriticalNesting, AX
|
MOVW usCriticalNesting, AX
|
||||||
POP BC ; restore the necessary general purpose registers
|
POP BC ; restore the necessary general purpose registers
|
||||||
POP DE
|
POP DE
|
||||||
#if configMEMORY_MODE == 1
|
#if configMEMORY_MODE == 1
|
||||||
POP AX ; restore the ES register
|
POP AX ; restore the ES register
|
||||||
MOV ES, A
|
MOV ES, A
|
||||||
XCH A, X ; restore the CS register
|
XCH A, X ; restore the CS register
|
||||||
MOV CS, A
|
MOV CS, A
|
||||||
#else
|
#else
|
||||||
POP AX
|
POP AX
|
||||||
MOV CS, A ; restore CS register
|
MOV CS, A ; restore CS register
|
||||||
#endif
|
#endif
|
||||||
POP HL ; restore general purpose register HL
|
POP HL ; restore general purpose register HL
|
||||||
|
POP AX ; restore AX
|
||||||
ENDM
|
ENDM
|
||||||
;------------------------------------------------------------------------------
|
;------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
@ -139,16 +141,10 @@ portRESTORE_CONTEXT MACRO
|
||||||
;------------------------------------------------------------------------------
|
;------------------------------------------------------------------------------
|
||||||
RSEG CODE:CODE
|
RSEG CODE:CODE
|
||||||
vPortYield:
|
vPortYield:
|
||||||
PUSH PSW ; save Task PSW (Program Status Word)
|
|
||||||
DI ; global disable interrupt
|
|
||||||
PUSH AX
|
|
||||||
portSAVE_CONTEXT ; Save the context of the current task.
|
portSAVE_CONTEXT ; Save the context of the current task.
|
||||||
CALL vTaskSwitchContext ; Call the scheduler.
|
call vTaskSwitchContext ; Call the scheduler.
|
||||||
portRESTORE_CONTEXT ; Restore the context of whichever task the ...
|
portRESTORE_CONTEXT ; Restore the context of whichever task the ...
|
||||||
POP AX
|
RETB
|
||||||
EI ; (re-)enable global interrupts
|
|
||||||
POP PSW ; restore active task PSW
|
|
||||||
RET ; ... scheduler decided should run.
|
|
||||||
|
|
||||||
|
|
||||||
;------------------------------------------------------------------------------
|
;------------------------------------------------------------------------------
|
||||||
|
@ -164,18 +160,16 @@ vPortYield:
|
||||||
RSEG CODE:CODE
|
RSEG CODE:CODE
|
||||||
vPortStart:
|
vPortStart:
|
||||||
portRESTORE_CONTEXT ; Restore the context of whichever task the ...
|
portRESTORE_CONTEXT ; Restore the context of whichever task the ...
|
||||||
POP AX
|
; POP PSW ; restore active task PSW
|
||||||
EI ; enable global interrupts
|
reti ; ... scheduler decided should run.
|
||||||
POP PSW ; restore active task PSW
|
|
||||||
ret ; ... scheduler decided should run.
|
|
||||||
|
|
||||||
;------------------------------------------------------------------------------
|
;------------------------------------------------------------------------------
|
||||||
; Perform the necessary steps of the Tick Count Increment and Task Switch
|
; Perform the necessary steps of the Tick Count Increment and Task Switch
|
||||||
; depending on the chosen kernel configuration
|
; depending on the chosen kernel configuration
|
||||||
;
|
;
|
||||||
; Input: NONE
|
; Input: NONE
|
||||||
;
|
;
|
||||||
; Call: ISR
|
; Call: ISR
|
||||||
;
|
;
|
||||||
; Output: NONE
|
; Output: NONE
|
||||||
;
|
;
|
||||||
|
@ -183,27 +177,16 @@ vPortStart:
|
||||||
#if configUSE_PREEMPTION == 1
|
#if configUSE_PREEMPTION == 1
|
||||||
|
|
||||||
MD_INTTM05:
|
MD_INTTM05:
|
||||||
PUSH AX ; create temporary dummy area on stack
|
|
||||||
PUSH AX ; save AX Register to stack
|
|
||||||
MOVW AX, [SP+6] ; get PSW
|
|
||||||
MOVW [SP+2], AX ; write PSW into dummy area on the stack
|
|
||||||
|
|
||||||
portSAVE_CONTEXT ; Save the context of the current task.
|
portSAVE_CONTEXT ; Save the context of the current task.
|
||||||
call vTaskIncrementTick ; Call the timer tick function.
|
call vTaskIncrementTick ; Call the timer tick function.
|
||||||
call vTaskSwitchContext ; Call the scheduler.
|
call vTaskSwitchContext ; Call the scheduler.
|
||||||
portRESTORE_CONTEXT ; Restore the context of whichever task the ...
|
portRESTORE_CONTEXT ; Restore the context of whichever task the ...
|
||||||
; ... scheduler decided should run.
|
RETI
|
||||||
|
|
||||||
MOVW AX, [SP+2] ; get PSW from stack
|
|
||||||
MOVW [SP+6], AX ; write PSW to expected location for reti
|
|
||||||
POP AX ; restore AX
|
|
||||||
MOVW [SP+0], AX ; rewrite dummy stack area to expected value
|
|
||||||
POP AX
|
|
||||||
RETI
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
MD_INTTM05:
|
MD_INTTM05:
|
||||||
PUSH AX ; save necessary general purpose register...
|
PUSH AX ; save necessary general purpose register...
|
||||||
PUSH HL ; ...used by the ISR
|
PUSH HL ; ...used by the ISR
|
||||||
MOVW AX, CS ; save CS register
|
MOVW AX, CS ; save CS register
|
||||||
PUSH AX
|
PUSH AX
|
||||||
|
@ -212,7 +195,7 @@ MD_INTTM05:
|
||||||
MOVW CS, AX ; restore CS register
|
MOVW CS, AX ; restore CS register
|
||||||
POP HL ; restore used general purpose registers
|
POP HL ; restore used general purpose registers
|
||||||
POP AX
|
POP AX
|
||||||
RETI
|
RETI
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
REQUIRE ?CL78K0R_V2_L00
|
REQUIRE ?CL78K0R_V2_L00
|
||||||
|
@ -220,11 +203,17 @@ MD_INTTM05:
|
||||||
ORG 68
|
ORG 68
|
||||||
`??MD_INTTM05??INTVEC 68`:
|
`??MD_INTTM05??INTVEC 68`:
|
||||||
DW MD_INTTM05
|
DW MD_INTTM05
|
||||||
; set value for the usCriticalNesting
|
|
||||||
|
COMMON INTVEC:CODE:ROOT(1) ; set ISR location to the Interrupt vector table
|
||||||
|
ORG 126
|
||||||
|
`??vPortYield??INTVEC 126`:
|
||||||
|
DW vPortYield
|
||||||
|
|
||||||
|
; set value for the usCriticalNesting
|
||||||
RSEG NEAR_ID:CONST:SORT:NOROOT(1)
|
RSEG NEAR_ID:CONST:SORT:NOROOT(1)
|
||||||
`?<Initializer for usCriticalNesting>`:
|
`?<Initializer for usCriticalNesting>`:
|
||||||
DW 10
|
DW 10
|
||||||
|
|
||||||
;#endif
|
;#endif
|
||||||
|
|
||||||
END
|
END
|
|
@ -123,12 +123,11 @@ extern volatile unsigned portSHORT usCriticalNesting; \
|
||||||
/*-----------------------------------------------------------*/
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
/* Task utilities. */
|
/* Task utilities. */
|
||||||
extern void vPortYield( void );
|
|
||||||
extern void vPortStart( void );
|
extern void vPortStart( void );
|
||||||
extern void portSAVE_CONTEXT( void );
|
extern void portSAVE_CONTEXT( void );
|
||||||
extern void portRESTORE_CONTEXT( void );
|
extern void portRESTORE_CONTEXT( void );
|
||||||
#define portYIELD() vPortYield()
|
#define portYIELD() __asm( "BRK" )
|
||||||
#define portNOP() __asm ( "NOP" )
|
#define portNOP() __asm( "NOP" )
|
||||||
/*-----------------------------------------------------------*/
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
/* Hardwware specifics. */
|
/* Hardwware specifics. */
|
||||||
|
|
Loading…
Reference in a new issue