⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ucos2xxa.asm

📁 This code ports the uC/OS operating system by Jean LaBrosse to the TI TMS320C2xx family of DSP s.
💻 ASM
字号:
	.page
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; Module    :   ucos2xxa.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	_OSTimeTick					; globally visible internals.
	.global	_OSTCBCur
	.global	_OSTCBHighRdy
	.global	_OSStartHighRdy

	.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:
    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:
	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,*,AR1              		; move _OSTCBHighRdy to _OSTCBCur,
    									; and switch to using the new current
                                        ; stack pointer.

    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.

	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.


	.end

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -