📄 os_cpu_a.s
字号:
;************************************************************************************************
; uC/OS-II
; The Real-Time Kernel
;
; (c) Copyright 1999, Jean J. Labrosse, Weston, FL
; All Rights Reserved
;
; File : OS_CPU_A.S
; By : Jean J. Labrosse
; Modified : Mark D. Medonis, Sekidenko, Inc. 6/18/2002
; Modified : Carlton Heyer, Avnet Design Services 4/28/2004
;************************************************************************************************
;************************************************************************************************
;
; Note: This port uses the movem.l (a7),d0-d7/a0-a6, lea 60(a7)a7
; construct in place of the traditional 68xxx movem.l (a7)+,d0-d7/a0-a6. It
; is perfectly in order to push/pop individual registers using movem.l (a7)+,d2 , etc.
; but it's a bit slower (and more verbose).
;
; The lea instruction is required because the ColdFire can't
; push multiple registers directly to the stack.
;
; Changed OSIntCtxSw for new uC/OS-II version 2.51 features. OSTickISR was changed too, to
; deal with the Stack Pointer in a different way than in the 2.04 version. See the uC/OS-II
; release notes for details on how this is accomplished.
;
; rev 0.b
; Fixed _OSStartHighRdy. The original version was popping D0 back off the stack, when D4 had
; been popped there and used for setting OSRunning to 1. Now getting D4 back off the stack as
; it should be.
; M. Medonis
;
; Modified for the CF5282
; Carlton Heyer
;*************************************************************************************************
IPSBAR .equ 0x40000000
_PIF .equ 0x04
PIT0 .equ 0x00150000
PCSR .equ 0x0
_PIT0_PCSR .equ (IPSBAR + PIT0 + PCSR)
;*************************************************************************************************
; PUBLIC DECLARATIONS
;*************************************************************************************************
.global _OSCtxSw
.global _OSIntCtxSw
.global _OSIntExitCF
.global _OSStartHighRdy
.global _OSTickISR
.global _CPUFormatError
.global _InitVBR
;**************************************************************************************************
; EXTERNAL DECLARATIONS
;**************************************************************************************************
.extern _OSCtxSwCtr
.extern _OSIntExit
.extern _OSIntNesting
.extern _OSLockNesting
.extern _OSPrioCur
.extern _OSPrioHighRdy
.extern _OSRdyGrp
.extern _OSRdyTbl
.extern _OSRunning
.extern _OSTaskSwHook
.extern _OSTCBCur
.extern _OSTCBHighRdy
.extern _OSTCBPrioTbl
.extern _OSTimeTick
.extern _OSUnMapTbl
.extern _OSIntEnter
;*************************************************************************************************
; VECTOR BASE REGISTER INITIALIZATION
;
; This is to set the Vector Base Register to 0x0, in case the startup bootloader moved
; it somewhere else.
;
;*************************************************************************************************
.text
_InitVBR:
MOVE.L #0x20000000,D0 //xuetao changed for running uCOS-II in dbug
//we will use the VBR in SRAM based on 0x20000000
MOVEC D0, VBR
RTS
;**************************************************************************************************
; START HIGHEST PRIORITY TASK READY-TO-RUN
;
; Description: This function is called by OSStart() to start the highest priority task that was
; created by your application before calling OSStart().
;
; Arguments : none
;
; Note(s) : 1) The stack frame is assumed to look as follows:
;
; OSTCBHighRdy->OSTCBStkPtr + 0 ----> D0 Low Memory
; + 4 D1
; + 8 D2
; + 12 D3
; + 16 D4
; + 20 D5
; + 24 D6
; + 28 D7
; + 32 A0
; + 36 A1
; + 40 A2
; + 44 A3
; + 48 A4
; + 52 A5
; + 56 A6
; + 60 Format, Vector, OS_INITIAL_SR
; + 64 task
; + 68 task
; + 72 pdata High Memory
;
; 2) OSStartHighRdy() MUST:
; a) Call OSTaskSwHook() then,
; b) Set OSRunning to TRUE,
; c) Switch to the highest priority task.
;*************************************************************************************************
_OSStartHighRdy:
JSR _OSTaskSwHook ; Invoke user defined context switch hook
MOVE.L D4,-(A7) ;
MOVEQ.L #1, D4
MOVE.B D4,_OSRunning ; Indicate that we are multitasking
MOVE.L (A7)+, D4 ; Bug here! was D0, now D4
MOVE.L (_OSTCBHighRdy),A1 ; Point to TCB of highest priority task ready to run
MOVE.L (A1),A7 ; Get the stack pointer of the task to resume
MOVEM.L (A7),D0-D7/A0-A6 ; Store all the regs
LEA 60(A7),A7 ; Advance the stack pointer
RTE ; Return to task
;************************************************************************************************
; TASK LEVEL CONTEXT SWITCH
;
; Description : This function is called when a task makes a higher priority task ready-to-run.
;
; Arguments : none
;
; 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 (the registers for
; task to suspend need to be saved):
;
; SP + 0 ----> Format, Vector, SR Low Memory
; + 4 PC of task High Memory
;
; 3) The stack frame of the task to resume looks as follows:
;
; OSTCBHighRdy->OSTCBStkPtr + 0 ----> D0 Low Memory
; + 4 D1
; + 8 D2
; + 12 D3
; + 16 D4
; + 20 D5
; + 24 D6
; + 28 D7
; + 32 A0
; + 36 A1
; + 40 A2
; + 44 A3
; + 48 A4
; + 52 A5
; + 56 A6
; + 60 OS_INITIAL_SR (See OS_CPU.H)
; + 64 PC of task High Memory
;
;*****************************************************************************
_OSCtxSw:
LEA -60(A7),A7
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -