Continue 78K0R development.

This commit is contained in:
Richard Barry 2009-02-03 21:09:16 +00:00
parent 7acae9e570
commit 46425b4099
3 changed files with 64 additions and 75 deletions

View File

@ -37,13 +37,13 @@
Please ensure to read the configuration and relevant port sections of the
online documentation.
http://www.FreeRTOS.org - Documentation, latest information, license and
http://www.FreeRTOS.org - Documentation, latest information, license and
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.
http://www.OpenRTOS.com - Commercial support, development, porting,
http://www.OpenRTOS.com - Commercial support, development, porting,
licensing and training services.
*/
@ -67,7 +67,7 @@
* |--------------------- Zero Flag set
* ---------------------- 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
any details of its type. */
@ -95,19 +95,19 @@ volatile unsigned portSHORT usCriticalNesting = portINITIAL_CRITICAL_NESTING;
__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 );
/*-----------------------------------------------------------*/
/*
* 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.
*
*
* See the header file portable.h.
*/
portSTACK_TYPE *pxPortInitialiseStack( portSTACK_TYPE *pxTopOfStack, pdTASK_CODE pxCode, void *pvParameters )
{
{
unsigned long *pulLocal;
#if configMEMORY_MODE == 1
@ -116,30 +116,31 @@ unsigned long *pulLocal;
pxTopOfStack--;
pulLocal = ( unsigned long * ) pxTopOfStack;
*pulLocal = ( unsigned long ) pvParameters;
pxTopOfStack--;
pxTopOfStack--;
/* Dummy values on the stack because there normaly the return address
of the funtion is written. */
/* Dummy values on the stack because there normaly the return address
of the funtion is written. */
*pxTopOfStack = ( portSTACK_TYPE ) 0xcdcd;
pxTopOfStack--;
*pxTopOfStack = ( portSTACK_TYPE ) 0xcdcd;
pxTopOfStack--;
pxTopOfStack--;
/* Task function start address. */
pulLocal = ( unsigned long * ) pxTopOfStack;
*pulLocal = ( unsigned long ) pxCode;
pxTopOfStack--;
/* Initial PSW value. */
*pxTopOfStack = portPSW;
// *pxTopOfStack = portPSW;
pxTopOfStack--;
/* Task function start address. */
pulLocal = ( unsigned long * ) pxTopOfStack;
*pulLocal = ( ( ( unsigned long ) pxCode ) | portPSW );
pxTopOfStack--;
/* Next general purpose register AX. */
*pxTopOfStack = ( portSTACK_TYPE ) 0x1111;
*pxTopOfStack = ( portSTACK_TYPE ) 0x1111;
pxTopOfStack--;
}
#else
#else
{
pxTopOfStack--;
@ -156,7 +157,7 @@ unsigned long *pulLocal;
*pxTopOfStack = ( portSTACK_TYPE ) pvParameters;
pxTopOfStack--;
}
#endif
#endif
/* HL. */
*pxTopOfStack = ( portSTACK_TYPE ) 0x2222;
@ -173,7 +174,7 @@ unsigned long *pulLocal;
pxTopOfStack--;
*pxTopOfStack = ( portSTACK_TYPE ) portNO_CRITICAL_SECTION_NESTING;
/*
/*
* 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.
*/
@ -203,8 +204,8 @@ void vPortEndScheduler( void )
/*-----------------------------------------------------------*/
/*
* Hardware initialisation to generate the RTOS tick. This uses Channel 5 of
* the Timer Array Unit (TAU). Any other Channel could also be used.
* Hardware initialisation to generate the RTOS tick. This uses Channel 5 of
* the Timer Array Unit (TAU). Any other Channel could also be used.
*/
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. */
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. */
TMMK05 = 1;

View File

@ -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"
;------------------------------------------------------------------------------
@ -47,19 +47,19 @@
PUBLIC vPortStart
; Functions used by scheduler
;------------------------------------------------------------------------------
;------------------------------------------------------------------------------
EXTERN vTaskSwitchContext
EXTERN vTaskIncrementTick
; Variables used by scheduler
;------------------------------------------------------------------------------
;------------------------------------------------------------------------------
EXTERN pxCurrentTCB
EXTERN usCriticalNesting
; Tick ISR Prototype
;------------------------------------------------------------------------------
EXTERN ?CL78K0R_V2_L00
EXTERN ?CL78K0R_V2_L00
PUBWEAK `??MD_INTTM05??INTVEC 68`
PUBLIC MD_INTTM05
@ -72,21 +72,22 @@ MD_INTTM05 SYMBOL "MD_INTTM05"
; portSAVE_CONTEXT MACRO
; Saves the context of the remaining general purpose registers, CS and ES
; (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
;------------------------------------------------------------------------------
portSAVE_CONTEXT MACRO
portSAVE_CONTEXT MACRO
PUSH AX ; save AX Register to stack
PUSH HL
#if configMEMORY_MODE == 1
#if configMEMORY_MODE == 1
MOV A, CS ; save CS register
XCH A, X
MOV A, ES ; save ES register
PUSH AX
#else
#else
MOV A, CS ; save CS register
PUSH AX
#endif
#endif
PUSH DE ; save the remaining general purpose registers
PUSH BC
MOVW AX, usCriticalNesting ; save the usCriticalNesting value
@ -102,7 +103,7 @@ portSAVE_CONTEXT MACRO
; portRESTORE_CONTEXT MACRO
; Restores the context of the Stack Pointer, usCriticalNesting
; 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
@ -114,16 +115,17 @@ portRESTORE_CONTEXT MACRO
MOVW usCriticalNesting, AX
POP BC ; restore the necessary general purpose registers
POP DE
#if configMEMORY_MODE == 1
#if configMEMORY_MODE == 1
POP AX ; restore the ES register
MOV ES, A
MOV ES, A
XCH A, X ; restore the CS register
MOV CS, A
#else
#else
POP AX
MOV CS, A ; restore CS register
#endif
#endif
POP HL ; restore general purpose register HL
POP AX ; restore AX
ENDM
;------------------------------------------------------------------------------
@ -139,16 +141,10 @@ portRESTORE_CONTEXT MACRO
;------------------------------------------------------------------------------
RSEG CODE:CODE
vPortYield:
PUSH PSW ; save Task PSW (Program Status Word)
DI ; global disable interrupt
PUSH AX
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 ...
POP AX
EI ; (re-)enable global interrupts
POP PSW ; restore active task PSW
RET ; ... scheduler decided should run.
RETB
;------------------------------------------------------------------------------
@ -164,18 +160,16 @@ vPortYield:
RSEG CODE:CODE
vPortStart:
portRESTORE_CONTEXT ; Restore the context of whichever task the ...
POP AX
EI ; enable global interrupts
POP PSW ; restore active task PSW
ret ; ... scheduler decided should run.
; POP PSW ; restore active task PSW
reti ; ... scheduler decided should run.
;------------------------------------------------------------------------------
; 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
;
; Call: ISR
; Call: ISR
;
; Output: NONE
;
@ -183,27 +177,16 @@ vPortStart:
#if configUSE_PREEMPTION == 1
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.
call vTaskIncrementTick ; Call the timer tick function.
call vTaskSwitchContext ; Call the scheduler.
portRESTORE_CONTEXT ; Restore the context of whichever task the ...
; ... scheduler decided should run.
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
RETI
#else
MD_INTTM05:
PUSH AX ; save necessary general purpose register...
PUSH AX ; save necessary general purpose register...
PUSH HL ; ...used by the ISR
MOVW AX, CS ; save CS register
PUSH AX
@ -212,7 +195,7 @@ MD_INTTM05:
MOVW CS, AX ; restore CS register
POP HL ; restore used general purpose registers
POP AX
RETI
RETI
#endif
REQUIRE ?CL78K0R_V2_L00
@ -220,11 +203,17 @@ MD_INTTM05:
ORG 68
`??MD_INTTM05??INTVEC 68`:
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)
`?<Initializer for usCriticalNesting>`:
DW 10
;#endif
END

View File

@ -123,12 +123,11 @@ extern volatile unsigned portSHORT usCriticalNesting; \
/*-----------------------------------------------------------*/
/* Task utilities. */
extern void vPortYield( void );
extern void vPortStart( void );
extern void portSAVE_CONTEXT( void );
extern void portRESTORE_CONTEXT( void );
#define portYIELD() vPortYield()
#define portNOP() __asm ( "NOP" )
#define portYIELD() __asm( "BRK" )
#define portNOP() __asm( "NOP" )
/*-----------------------------------------------------------*/
/* Hardwware specifics. */