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

📄 os_cpu_a.s

📁 摩托罗拉 ColdFire 5206E 在UCOSII上的移植代码
💻 S
📖 第 1 页 / 共 2 页
字号:
;************************************************************************************************
;                                     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 - An Advanced Energy Company
;               mark.medonis@aei.com
;		Paul S. Carpenter
;		Northern Computers, Inc.
;		paul.carpenter@eng.nciaccess.com
;               5/03/2002
;************************************************************************************************


;************************************************************************************************
;
; Note: This port uses the MOVEM.L (A7),D0-D7/A0-A6, LEA 60(A7),A7	     
; construct in place of the traditional 68k style 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.	    
;*************************************************************************************************

IMMADDR .equ    0x10000000
sTER0   .equ    (IMMADDR+0x111)
REF_EVENT .equ  0x02


;*************************************************************************************************
;                                   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 #0x00000000,D0
   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)+, D0              ;  

   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 + -