📄 os_cpu_a.asm
字号:
.include "C2407_REG_A.h"
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Module OS_CPU_A.ASM
; Purpose : TMS320C2XX Real Time Operating System.
; Language : TMS320C1x/C2x/C2xx/C5x COFF Assembler
; Version 6.60 Copyright (c) 1987-1995 Texas Instruments Incorporated
; Written : Kirby W. Cartwright, The Vanner Power Group, 06/22/98
; Modified :
; Project : Vanner Power Group Modular Controller Project PX-2.
; Copyright : (C) copyright 1998 by Vanner, Inc. All Rights Reserved.
; Notes : we use TI's 'C' interrupt I$$SAVE routine and I$$REST code blocks a lot.
; Unit Tested: 7/29/98, KWC
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
.global I$$SAVE ; externals
.global I$$REST
.global _OSIntEnter
.global _OSIntExit
.global _OSRunning
.global _OSTimeTick ; globally visible internals.
.global _OSTCBCur
.global _OSTCBHighRdy
.global _OSPrioCur
.global _OSPrioHighRdy
.global _OSStartHighRdy
.global _OSTaskSwHook
.global _OSCtxSw
.global _OUTport
.text
.page
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; Routine : _OSStartHighRdy (void OSStartHighRdy(void))
;
; Purpose : START MULTITASKING.
;
; Inputs : None.
;
; Destroys : sp (AR1).
;
; Speed/Size:
;
; Note(s) : assuming current ARP is AR1 the stack pointer. according
; to TI be definition on entering a 'C' routine this
; assumption should be true.
;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
.even
_OSStartHighRdy:
call _OSTaskSwHook
lar AR1,#1
sar AR1,_OSRunning
lar AR1,#_OSTCBCur ; point to the pointer to the highest
; priority task.
lar AR1,* ; point to the highest priority task.
lar AR1,* ; get OSTCBCur->OSTCBStkPtr.
b I$$REST ; go let TI do the hard work.
.page
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; ISR : _OSCtxSw (void OSCtxSw(void))
;
; Purpose : PERFORM A CONTEXT SWITCH (From task level).
;
; Inputs : None.
;
; Destroys : sp (AR1), AR0, AR2.
;
; Speed/Size:
;
; Note(s) : Entered through "intr 31" instruction.
;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
_OSCtxSw:
;.global _OSCtxSw
call I$$SAVE ; save this task's context.
_OSCtxSw_0:
call _OSTaskSwHook
lar AR2,#_OSTCBCur ; point AR2 at the OSTCBCur pointer.
larp AR2 ; make AR2 the currently used address register.
lar AR0,*,AR0 ; point AR0 at current TCB, and switch to using AR0.
sar AR1,* ; save the current task's current
; stack ptr in the current TCB.
lar AR0,#_OSTCBHighRdy ; point to OSTCBHighRdy pointer.
lar AR0,* ; point to the highest priority task that is ready.
lar AR1,*,AR2 ; get the new task's stack ptr, switch
; to using AR2 which points to OSTCBCur pointer.
sar AR0,* ;move _OSTCBHighRdy to _OSTCBCur,
; and switch to using the new current
; stack pointer.
lar AR2,#_OSPrioCur
lar AR0,_OSPrioHighRdy
larp AR2
sar AR0,*,AR1
b I$$REST ; let TI do the hard work of restoring
; this task's context.
.page
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; Routine : _OSIntCtxSw (void OSIntCtxSw(void))
;
; Purpose : PERFORM A CONTEXT SWITCH (From an ISR).
;
; Inputs : None.
;
; Destroys : sp, AR1.
;
; Speed/Size:
;
; Note(s) : The ISR has already saved the current task's context!
; Figuring out how many stack elements to clean-up was
; tough. Hidden compiler automatic allocation.
;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
.even
_OSIntCtxSw:
.global _OSIntCtxSw
pop ; pop-off the return address
; (from call to this routine)
; never to be used...
sbrk #3 ; clean-up the sw stack's pushed
; frame pointer and return address from
; the call to "OSIntExit."
b _OSCtxSw_0 ; the lazy way...
.page
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; ISR : _OSTickISR (void OSTickISR(void))
;
; Purpose : HANDLE TICK ISR.
;
; Inputs : None.
;
; Destroys : sp, AR1.
;
; Speed/Size:
;
; Note(s) :
;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
_OSTickISR:
.global _OSTickISR
call I$$SAVE ; save the interrupted task's context.
clrc INTM ; enable interrupt nesting.
call _OSIntEnter ; inform uC/OS we're in an ISR.
call _OSTimeTick ; increment the uC/OS timer tick.
LDP #0E8H
LACC 2FH
OR #0FFFFH
SACL 2FH
call _OSIntExit ; inform uC/OS we're leaving the
; the ISR; we may exit through
; that path if there is a context switch.
b I$$REST ; still lazy after all these years.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; OUT : OUTPORT
;
; Purpose : OUTPORT.
;
; Inputs : NUM.
;
; Destroys : sp, AR1.
;
; Speed/Size:
;
; Note(s) :
;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
_OUTport:
.global _OUTport
call I$$SAVE ; save the interrupted task's context.
.bss a,1,1
LDP #103H
splk #3h,a
out a,9h
ldp #DP_PF2
splk #0H,MCRB
splk #22H,PCDATDIR
DELAY_S 80H
DELAY_S 80H
DELAY_S 80H
DELAY_S 80H
DELAY_S 80H
DELAY_S 80H
DELAY_S 80H
DELAY_S 80H
DELAY_S 80H
DELAY_S 80H
splk #0H,MCRB
splk #20H,PCDATDIR
b I$$REST ; still lazy after all these years.
.end;</PRE></BODY></HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -