?? swixxxx.s
字號:
;/*****************************************************************************/
;/* SWI.S: SWI Handler */
;/*****************************************************************************/
;/* This file is part of the uVision/ARM development tools. */
;/* Copyright (c) 2005-2006 Keil Software. All rights reserved. */
;/* This software may only be used under the terms of a valid, current, */
;/* end user licence from KEIL for a compatible version of KEIL software */
;/* development tools. Nothing else gives you the right to use this software. */
;/*****************************************************************************/
T_Bit EQU 0x20
PRESERVE8 ; 8-Byte aligned Stack
AREA SWI_Area, CODE, READONLY
ARM
EXPORT SWI_Handler
SWI_Handler
MRS R12, SPSR ; Get SPSR
TST R12, #T_Bit ; Check Thumb Bit
LDRNEH R12, [LR,#-2] ; Thumb: Load Halfword
BICNE R12, R12, #0xFF00 ; Extract SWI Number
LDREQ R12, [LR,#-4] ; ARM: Load Word
BICEQ R12, R12, #0xFF000000 ; Extract SWI Number
CMP R12, #0;//SWI號判斷,R12=0--os_switch_tasks,R12=1~7---SWI1~SWI7
BNE User_swi
;/*------------------- os_switch_tasks ------------------------*/
STMDB SP,{SP}^ ;ARTX專用SWI0
NOP
LDMDB SP,{R1}
MRS R12,SPSR
STMDB R1!,{R4-R7,R12,LR}
LDR R4,=os_runtask ; os_runtask->tsk_stack
LDR R4,[R4,#0x0]
STR R1,[R4,#0x0024];#TCB_TSTACK]
MOV R4,R0
ADR R12, SWI_Table;?SWI?Table+4
LDR R12,[R12,#0x0] ; SWI function address
MOV LR, PC ; Return Address
BX R12 ; Call SWI Function
LDR LR,[R4,#0x0024];#TCB_TSTACK]; p_new->tsk_stack
LDRB R0,[R4,#0x0021];#TCB_FCTX] ; p_new->full_ctx
CMP R0,#0x0
BNE Full_ctx
LDMIA R14!,{R4-R8,R12}
MSR SPSR_cxsf,R8
STMDB SP,{LR}
LDMDB SP,{SP}^ ; Set User SP
NOP
MOVS PC,R12 ; RETI
Full_ctx
ADD R0,LR,#64
LDMDB R0,{R1-R3} ; LR, CPSR (R3=dummy)
MSR SPSR_cxsf,R2 ; Set User CPSR
STMDB SP,{R0-R1}
LDMDB SP,{SP,LR}^ ; Set User SP,LR
NOP ; required for generic ARM7TDMI support
LDMIA LR,{R0-R12} ; Restore R12-R0
LDR LR,[LR,#60] ; PC
MOVS PC,LR ; RETI
; /*------------------- User SWI -------------------------------*/
User_swi STMDB SP!,{R8,LR} ;SWI1~SWI7
LDR R8,SWI_Count
CMP R12,R8
BCS SWI_Dead
ADR R8,SWI_Table
LDR R12, [R8,R12,LSL #2] ; Load SWI Function Address
MOV LR,PC
BX R12 ; Call SWI function
LDMIA SP!,{R8,PC}^;執行SWI命令入口
;擴展SWI命令
SWI_Dead B SWI_Dead ; None Existing SWI
SWI_Cnt EQU (SWI_End-SWI_Table)/4
SWI_Count DCD SWI_Cnt
IMPORT __SWI_0;ARTX
IMPORT __SWI_1
IMPORT __SWI_2
IMPORT __SWI_3
IMPORT __SWI_4
IMPORT __SWI_5
IMPORT __SWI_6;ARTX
IMPORT __SWI_7;ARTX
; IMPORT __SWI_8
; EXPORT __SWI_8
SWI_Table
DCD __SWI_0 ; SWI 0 Function Entry
DCD __SWI_1 ; SWI 1 Function Entry
DCD __SWI_2 ; SWI 2 Function Entry
DCD __SWI_3 ; SWI 3 Function Entry
DCD __SWI_4 ; SWI 4 Function Entry
DCD __SWI_5 ; SWI 5 Function Entry
DCD __SWI_6 ; SWI 6 Function Entry
DCD __SWI_7 ; SWI 7 Function Entry
; DCD __SWI_8
SWI_End
IMPORT os_runtask
DCD os_runtask
END
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -