📄 os_cpu_a.s
字号:
;********************************************************************************************************
; uC/OS-II
; The Real-Time Kernel
;
; (c) Copyright 2003, Jean J. Labrosse, Weston, FL
; All Rights Reserved
;
;
; 683xx Specific code
; COSMIC C V4.1
;
; File : OS_CPU_A.S
; By : Jean J. Labrosse
;********************************************************************************************************
;********************************************************************************************************
; CONFIGURATION CONSTANTS
;********************************************************************************************************
;********************************************************************************************************
; I/O PORT ADDRESSES
;********************************************************************************************************
;********************************************************************************************************
; PUBLIC DECLARATIONS
;********************************************************************************************************
xdef _OSCPUSaveSR
xdef _OSCPURestoreSR
xdef _OSCtxSw
xdef _OSIntCtxSw ; Satisfy OSIntExit() in OS_CORE.C
xdef _OSIntExit68K
xdef _OSStartHighRdy
xdef _OSTickISR
;********************************************************************************************************
; EXTERNAL DECLARATIONS
;********************************************************************************************************
xref _OSCtxSwCtr
xref _OSIntExit
xref _OSIntNesting
xref _OSLockNesting
xref _OSPrioCur
xref _OSPrioHighRdy
xref _OSRdyGrp
xref _OSRdyTbl
xref _OSRunning
xref _OSTaskSwHook
xref _OSTCBCur
xref _OSTCBHighRdy
xref _OSTCBPrioTbl
xref _OSTimeTick
xref _OSUnMapTbl
;********************************************************************************************************
; OSCPUSaveSR() for OS_CRITICAL_METHOD #3
;
; Description : This functions implements the OS_CRITICAL_METHOD #3 function to preserve the state of the
; interrupt disable flag in order to be able to restore it later.
;
; Arguments : none
;
; Returns : It is assumed that the return value is placed in the D7 register as expected by the
; compiler.
;********************************************************************************************************
_OSCPUSaveSR:
MOVE.W SR,D7 ; Copy SR into D7
ORI #$0700,SR ; Disable interrupts
RTS
;********************************************************************************************************
; OSCPURestoreSR() for OS_CRITICAL_METHOD #3
;
; Description : This functions implements the OS_CRITICAL_METHOD #function to restore the state of the
; interrupt flag.
;
; Arguments : os_cpu_sr is the contents of the SR to restore. It is assumed that this 'argument' is
; passed in the D7 register of the CPU by the compiler.
;
; Returns : None
;********************************************************************************************************
_OSCPURestoreSR:
MOVE.W D7,SR
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 (H) Low Memory
; + 2 D0 (L)
; + 4 D1 (H)
; + 6 D1 (L)
; + 8 D2 (H)
; + 10 D2 (L)
; + 12 D3 (H)
; + 14 D3 (L)
; + 16 D4 (H)
; + 18 D4 (L)
; + 20 D5 (H)
; + 22 D5 (L)
; + 24 D6 (H)
; + 26 D6 (L)
; + 28 D7 (H)
; + 30 D7 (L)
; + 32 A0 (H)
; + 34 A0 (L)
; + 36 A1 (H)
; + 38 A1 (L)
; + 40 A2 (H)
; + 42 A2 (L)
; + 44 A3 (H)
; + 46 A3 (L)
; + 48 A4 (H)
; + 50 A4 (L)
; + 52 A5 (H)
; + 54 A5 (L)
; + 56 A6 (H)
; + 58 A6 (L)
; + 60 OS_INITIAL_SR
; + 62 task (H)
; + 64 task (L)
; + 66 0x80 + 4 * TRAP#
; + 68 task (H)
; + 70 task (L)
; + 72 pdata (H)
; + 74 pdata (L) 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
ADDQ.B #1,_OSRunning ; Indicate that we are multitasking
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)+,A0-A6/D0-D7 ; Restore the CPU registers
RTE ; Run 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 ----> SR Low Memory
; + 2 0x80 + 4 * TRAP#
; + 4 PC of task (H)
; + 6 PC of task (L) High Memory
;
; 3) The stack frame of the task to resume looks as follows:
;
; OSTCBHighRdy->OSTCBStkPtr + 0 ----> D0 (H) Low Memory
; + 2 D0 (L)
; + 4 D1 (H)
; + 6 D1 (L)
; + 8 D2 (H)
; + 10 D2 (L)
; + 12 D3 (H)
; + 14 D3 (L)
; + 16 D4 (H)
; + 18 D4 (L)
; + 20 D5 (H)
; + 22 D5 (L)
; + 24 D6 (H)
; + 26 D6 (L)
; + 28 D7 (H)
; + 30 D7 (L)
; + 32 A0 (H)
; + 34 A0 (L)
; + 36 A1 (H)
; + 38 A1 (L)
; + 40 A2 (H)
; + 42 A2 (L)
; + 44 A3 (H)
; + 46 A3 (L)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -