📄 os_cpu_a.s
字号:
;********************************************************************************************************
; uC/OS-II
; The Real-Time Kernel
;
; (c) Copyright 1992-2002, Jean J. Labrosse, Weston, FL
; All Rights Reserved
;
;
; S1C33XXX Specific code
;
; GCC33 V3.2
;
; File : OS_CPU_A.S
; By : DuanBo
; Data : 4/2/2005
;********************************************************************************************************
;********************************************************************************************************
; PUBLIC and EXTERNAL REFERENCES
;********************************************************************************************************
.global OSStartHighRdy
.global OSCtxSw
.global OSIntCtxSw
;*********************************************************************************************************
; START MULTITASKING
; void OSStartHighRdy(void)
;
; Note : OSStartHighRdy() MUST:
; a) Call OSTaskSwHook() then,
; b) Set OSRunning to TRUE,
; c) Switch to the highest priority task.
;
; The stack construction:
; P15 -- P0
; PSR
; RETURN ADDR
;*********************************************************************************************************
OSStartHighRdy:
;
xcall OSTaskSwHook ; Call user defined task switch ho
ld.w %r4, 0x1
xld.w %r5, OSRunning
xld.b [%r5], %r4
;
xld.w %r5, [OSTCBHighRdy] ; SS:SP = OSTCBHighRdy->OSTCBStkPtr
ld.w %sp, %r5 ; MOVE _OSTCBHighRdy to SP, for indirectory
; addressing with displacement
xld.w %r4, [%sp+0x0] ; The OSTCBStkPtr is the first component of TCB
ld.w %sp, %r4 ; set the new SP
;
popn %r15
reti ; Run task
;*********************************************************************************************************
; PERFORM A CONTEXT SWITCH (From task level)
; void OSCtxSw(void)
;
; Note(s): 1) Upon entry,
; OSTCBCur points to the OS_TCB of the task to suspend
; OSTCBHighRdy points to the OS_TCB of the task to resume
;
; 2) The stack frame of the task to suspend looks as follows:
;
; SP -> OFFSET of task to suspend (Low memory)
; SEGMENT of task to suspend
; PSW of task to suspend (High memory)
;
;*********************************************************************************************************
OSCtxSw:
xcall OSTaskSwHook ; Call user defined task switch hook
pushn %r15 ; Save current task's context
xld.w %r4, [OSTCBCur] ; Reload DS in case it was altered
ld.w %r5, %sp ; Save the SP to R5
ld.w %sp, %r4 ; Load the OSTCBCur to SP for displacement addressing
ld.w [%sp+0x0], %r5 ; Save the SP to OSTCBCur
xld.w %r4, [OSTCBHighRdy] ; OSTCBCur = OSTCBHighRdy
xld.w %r5, OSTCBCur ;
ld.w [%r5], %r4 ;
xld.w %r4, [OSPrioHighRdy] ; OSPrioCur = OSPrioHighRdy
xld.w %r5, OSPrioCur ;
ld.b [%r5], %r4
xld.w %r4, [OSTCBCur]
ld.w %sp, %r4
ld.w %r5, [%sp+0x0]
ld.w %sp, %r5
popn %r15 ;
reti ; Return to new task
;
;*********************************************************************************************************
; PERFORM A CONTEXT SWITCH (From an ISR)
; void OSIntCtxSw(void)
;
; Note(s): 1) Upon entry,
; OSTCBCur points to the OS_TCB of the task to suspend
; OSTCBHighRdy points to the OS_TCB of the task to resume
;*********************************************************************************************************
OSIntCtxSw:
xcall OSTaskSwHook ; Call user defined task switch hook
xld.w %r4, [OSTCBHighRdy] ; OSTCBCur = OSTCBHighRdy
xld.w %r5, OSTCBCur ;
ld.w [%r5], %r4 ;
xld.w %r4, [OSPrioHighRdy] ; OSPrioCur = OSPrioHighRdy
xld.w %r5, OSPrioCur ;
ld.b [%r5], %r4
xld.w %r4, [OSTCBCur]
ld.w %sp, %r4
ld.w %r5, [%sp+0x0]
ld.w %sp, %r5
popn %r15 ;
reti ; Return to new task
;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -