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

@ -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. */
@ -124,15 +124,16 @@ unsigned long *pulLocal;
pxTopOfStack--; pxTopOfStack--;
*pxTopOfStack = ( portSTACK_TYPE ) 0xcdcd; *pxTopOfStack = ( portSTACK_TYPE ) 0xcdcd;
pxTopOfStack--; pxTopOfStack--;
/* Initial PSW value. */
// *pxTopOfStack = portPSW;
pxTopOfStack--; pxTopOfStack--;
/* Task function start address. */ /* Task function start address. */
pulLocal = ( unsigned long * ) pxTopOfStack; pulLocal = ( unsigned long * ) pxTopOfStack;
*pulLocal = ( unsigned long ) pxCode; *pulLocal = ( ( ( unsigned long ) pxCode ) | portPSW );
pxTopOfStack--;
/* Initial PSW value. */
*pxTopOfStack = portPSW;
pxTopOfStack--; pxTopOfStack--;
/* Next general purpose register AX. */ /* Next general purpose register AX. */

View file

@ -77,6 +77,7 @@ MD_INTTM05 SYMBOL "MD_INTTM05"
;------------------------------------------------------------------------------ ;------------------------------------------------------------------------------
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
@ -124,6 +125,7 @@ portRESTORE_CONTEXT MACRO
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,10 +160,8 @@ 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
@ -183,22 +177,11 @@ 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.
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 #else
@ -220,7 +203,13 @@ 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

View file

@ -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. */