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

@ -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