?? os_cpu_a.asm
字號:
;****************************************Copyright (c)****************************************************
;** Guangzou ZLG-MCU Development Co.,LTD.
;** graduate school
;** http://www.zlgmcu.com
;**
;**--------------File Info--------------------------------------------------------------------------------
;** File name: os_cpu_a.asm
;** Last modified Date: 2007.12.12
;** Last Version: 1.0
;** Descriptions: The assembly functions that a uC/OS-II port requires
;** uC/OS-II移植所需要的匯編函數(shù)
;**-------------------------------------------------------------------------------------------------------
;** Created By: Steven Zhou 周紹剛
;** Created date: 2007.12.12
;** Version: 1.0
;** Descriptions: The original version
;**
;**-------------------------------------------------------------------------------------------------------
;** Modified by:
;** Modified date:
;** Version:
;** Description:
;**
;*********************************************************************************************************
;*********************************************************************************************************
; Declarations for the interrupt handlers that are used by the application.
; 本應(yīng)用所用到的聲明
;*********************************************************************************************************
EXTERN OSRunning
EXTERN OSPrioCur
EXTERN OSPrioHighRdy
EXTERN OSTCBCur
EXTERN OSTCBHighRdy
EXTERN OSIntNesting
EXTERN OSIntExit
EXTERN OSTaskSwHook
EXTERN OsEnterSum
;*********************************************************************************************************
; Declarations for the exported functions
; 輸出外部聲明
;*********************************************************************************************************
EXPORT OSStartHighRdy
EXPORT OSCtxSw
EXPORT OSIntCtxSw
EXPORT OSPendSV
EXPORT OS_ENTER_CRITICAL
EXPORT OS_EXIT_CRITICAL
EXPORT intDisAll
;*********************************************************************************************************
; Registers or macros used by this file
; 本文件用到的寄存器和宏
;*********************************************************************************************************
NVIC_INT_CTRL EQU 0xE000ED04 ; Interrupt control state
; register.
; 中斷控制寄存器
NVIC_SYSPRI2 EQU 0xE000ED20 ; System priority register (2)
; 系統(tǒng)優(yōu)先級寄存器(2)
NVIC_PENDSV_PRI EQU 0xFFFF0000 ; PendSV and system tick priority
; (Both are lowest,0xff)
; 軟件中斷和系統(tǒng)節(jié)拍中斷
; (都為最低,0xff).
NVIC_PENDSVSET EQU 0x10000000 ; Value to trigger PendSV
; exception.觸發(fā)軟件中斷的值.
OS_CRITICAL_INT_PRIO EQU (1 << 5) ; Critical setions manage priority
; (equal or bigger number managed)
; 臨界代碼管理的優(yōu)先級(數(shù)值等于
; 或大于被管理)
RSEG CODE:CODE:NOROOT(2)
;*********************************************************************************************************
;** Function name: OS_ENTER_CRITICAL
;** Descriptions: Enter the critical section 進(jìn)入臨界區(qū)
;** Input parameters: None 無
;** Output parameters: None 無
;** Returned value: None 無
;** Created by: Steven Zhou 周紹剛
;** Created Date: 2007.12.12
;**-------------------------------------------------------------------------------------------------------
;** Modified by:
;** Modified date:
;**-------------------------------------------------------------------------------------------------------
;*********************************************************************************************************
OS_ENTER_CRITICAL
IF OS_CRITICAL_INT_PRIO > 0
PUSH {R1,R2}
LDR R1, =OS_CRITICAL_INT_PRIO ; Disable priorities between
; OS_CRITICAL_INT_PRIO & 0xFF
MSR BASEPRI, R1 ; 禁能優(yōu)先級在OS_CRITICAL_INT
; _PRIO到0xFF的中斷
ELSE
CPSID I ; Disable all the interrupts
; 禁能所有中斷
PUSH {R1,R2}
ENDIF
LDR R1, __OS_EnterSum ; OsEnterSum++
LDRB R2, [R1]
ADD R2, R2, #1
STRB R2, [R1]
POP {R1,R2}
BX LR
;*********************************************************************************************************
;** Function name: OS_EXIT_CRITICAL
;** Descriptions: Exit the critical section 退出臨界區(qū)
;** Output parameters: None 無
;** Input parameters: None 無
;** Returned value: None 無
;** Created by: Steven Zhou 周紹剛
;** Created Date: 2007.12.12
;**-------------------------------------------------------------------------------------------------------
;** Modified by:
;** Modified date:
;**-------------------------------------------------------------------------------------------------------
;*********************************************************************************************************
OS_EXIT_CRITICAL
PUSH {R1, R2}
LDR R1, __OS_EnterSum ; OsEnterSum--
LDRB R2, [R1]
SUB R2, R2, #1
STRB R2, [R1]
MOV R1, #0
CMP R2, #0 ; if OsEnterSum=0,enable
; interrupts.
; 如果OsEnterSum=0,開中斷。
IF OS_CRITICAL_INT_PRIO > 0
IT EQ
MSREQ BASEPRI, R1
ELSE
IT EQ
MSREQ PRIMASK, R1
ENDIF
POP {R1, R2}
BX LR
;*********************************************************************************************************
;** Function name: OSStartHighRdy
;** Descriptions: Uses the context switcher to cause the first task to start.
;** 使用調(diào)度器運行第一個任務(wù)
;** Input parameters: None 無
;** Output parameters: None 無
;** Returned value: None 無
;** Created by: Steven Zhou 周紹剛
;** Created Date: 2007.12.12
;**-------------------------------------------------------------------------------------------------------
;** Modified by:
;** Modified date:
;**-------------------------------------------------------------------------------------------------------
;*********************************************************************************************************
OSStartHighRdy
LDR R4, =NVIC_SYSPRI2 ; set the PendSV exception
; priority設(shè)置PendSV優(yōu)先級
LDR R5, =NVIC_PENDSV_PRI
STR R5, [R4]
MOV R4, #0 ; set the PSP to 0 for initial
; context switch call 使PSP等于0
MSR PSP, R4
LDR R4, __OS_Running ; OSRunning = TRUE
MOV R5, #1
STRB R5, [R4]
LDR R4, =NVIC_INT_CTRL ; trigger the PendSV exception
; 觸發(fā)軟件中斷
LDR R5, =NVIC_PENDSVSET
STR R5, [R4]
CPSIE I ; enable interrupts at processor
; level使能所有優(yōu)先級的中斷
OSStartHang
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -