1 |
;/*****************************************************************************/ |
---|
2 |
;/* SWI.S: SWI Handler */ |
---|
3 |
;/*****************************************************************************/ |
---|
4 |
;/* This file is part of the uVision/ARM development tools. */ |
---|
5 |
;/* Copyright (c) 2005-2006 Keil Software. All rights reserved. */ |
---|
6 |
;/* This software may only be used under the terms of a valid, current, */ |
---|
7 |
;/* end user licence from KEIL for a compatible version of KEIL software */ |
---|
8 |
;/* development tools. Nothing else gives you the right to use this software. */ |
---|
9 |
;/*****************************************************************************/ |
---|
10 |
|
---|
11 |
T_Bit EQU 0x20 |
---|
12 |
|
---|
13 |
PRESERVE8 ; 8-Byte aligned Stack |
---|
14 |
AREA SWI_Area, CODE, READONLY |
---|
15 |
ARM |
---|
16 |
|
---|
17 |
EXPORT SWI_Handler |
---|
18 |
SWI_Handler |
---|
19 |
|
---|
20 |
STMFD SP!, {R12, LR} ; Store R12, LR |
---|
21 |
MRS R12, SPSR ; Get SPSR |
---|
22 |
STMFD SP!, {R8, R12} ; Store R8, SPSR |
---|
23 |
TST R12, #T_Bit ; Check Thumb Bit |
---|
24 |
LDRNEH R12, [LR,#-2] ; Thumb: Load Halfword |
---|
25 |
BICNE R12, R12, #0xFF00 ; Extract SWI Number |
---|
26 |
LDREQ R12, [LR,#-4] ; ARM: Load Word |
---|
27 |
BICEQ R12, R12, #0xFF000000 ; Extract SWI Number |
---|
28 |
|
---|
29 |
LDR R8, SWI_Count |
---|
30 |
CMP R12, R8 |
---|
31 |
BHS SWI_Dead ; Overflow |
---|
32 |
ADR R8, SWI_Table |
---|
33 |
LDR R12, [R8,R12,LSL #2] ; Load SWI Function Address |
---|
34 |
MOV LR, PC ; Return Address |
---|
35 |
BX R12 ; Call SWI Function |
---|
36 |
|
---|
37 |
LDMFD SP!, {R8, R12} ; Load R8, SPSR |
---|
38 |
MSR SPSR_cxsf, R12 ; Set SPSR |
---|
39 |
LDMFD SP!, {R12, PC}^ ; Restore R12 and Return |
---|
40 |
|
---|
41 |
SWI_Dead B SWI_Dead ; None Existing SWI |
---|
42 |
|
---|
43 |
SWI_Cnt EQU (SWI_End-SWI_Table)/4 |
---|
44 |
SWI_Count DCD SWI_Cnt |
---|
45 |
|
---|
46 |
IMPORT __SWI_8 |
---|
47 |
|
---|
48 |
SWI_Table |
---|
49 |
DCD SWI_Dead ; SWI 0 Function Entry used by RTX |
---|
50 |
DCD SWI_Dead ; SWI 1 Function Entry used by RTX |
---|
51 |
DCD SWI_Dead ; SWI 2 Function Entry used by RTX |
---|
52 |
DCD SWI_Dead ; SWI 3 Function Entry used by RTX |
---|
53 |
DCD SWI_Dead ; SWI 4 Function Entry used by RTX |
---|
54 |
DCD SWI_Dead ; SWI 5 Function Entry used by RTX |
---|
55 |
DCD SWI_Dead ; SWI 6 Function Entry used by RTX |
---|
56 |
DCD SWI_Dead ; SWI 7 Function Entry used by RTX |
---|
57 |
DCD __SWI_8 ; SWI 8 Function Entry |
---|
58 |
; ... |
---|
59 |
SWI_End |
---|
60 |
|
---|
61 |
|
---|
62 |
END |
---|