|
1 // Copyright (c) 1995-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of the License "Symbian Foundation License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // e32\include\u32exec.h |
|
15 // |
|
16 // |
|
17 |
|
18 /** |
|
19 @file |
|
20 @internalComponent |
|
21 */ |
|
22 |
|
23 #ifndef __U32EXEC_H__ |
|
24 #define __U32EXEC_H__ |
|
25 #include <u32std.h> |
|
26 #include <cpudefs.h> |
|
27 |
|
28 #ifdef __KERNEL_MODE__ |
|
29 #define EXEC_INT64 Int64 |
|
30 #define EXEC_TIME TTimeK |
|
31 #else |
|
32 #define EXEC_INT64 TInt64 |
|
33 #define EXEC_TIME TInt64 |
|
34 #endif |
|
35 |
|
36 #define __EXECDECL__ __NAKED__ |
|
37 |
|
38 #if defined(__WINS__) |
|
39 |
|
40 // Executive call macros for WINS |
|
41 |
|
42 #define EXECUTIVE_FAST 0x00800000 |
|
43 #define EXECUTIVE_SLOW 0x00000000 |
|
44 |
|
45 #define __DISPATCH(func) \ |
|
46 __asm lea edx, [esp + 0x4] \ |
|
47 __asm mov ecx, (func) \ |
|
48 __asm jmp [TheDispatcher] |
|
49 |
|
50 #define FAST_EXEC0(n) __DISPATCH((n)|EXECUTIVE_FAST) |
|
51 #define FAST_EXEC1(n) __DISPATCH((n)|EXECUTIVE_FAST) |
|
52 #define SLOW_EXEC0(n) __DISPATCH((n)|EXECUTIVE_SLOW) |
|
53 #define SLOW_EXEC1(n) __DISPATCH((n)|EXECUTIVE_SLOW) |
|
54 #define SLOW_EXEC2(n) __DISPATCH((n)|EXECUTIVE_SLOW) |
|
55 #define SLOW_EXEC3(n) __DISPATCH((n)|EXECUTIVE_SLOW) |
|
56 #define SLOW_EXEC4(n) __DISPATCH((n)|EXECUTIVE_SLOW) |
|
57 |
|
58 #define KFAST_EXEC0(n) __DISPATCH((n)|EXECUTIVE_FAST) |
|
59 #define KFAST_EXEC1(n) __DISPATCH((n)|EXECUTIVE_FAST) |
|
60 #define KSLOW_EXEC0(n) __DISPATCH((n)|EXECUTIVE_SLOW) |
|
61 #define KSLOW_EXEC1(n) __DISPATCH((n)|EXECUTIVE_SLOW) |
|
62 #define KSLOW_EXEC2(n) __DISPATCH((n)|EXECUTIVE_SLOW) |
|
63 #define KSLOW_EXEC3(n) __DISPATCH((n)|EXECUTIVE_SLOW) |
|
64 #define KSLOW_EXEC4(n) __DISPATCH((n)|EXECUTIVE_SLOW) |
|
65 |
|
66 #elif defined(__CPU_X86) |
|
67 |
|
68 // Executive call macros for X86 |
|
69 #ifdef __GCC32__ |
|
70 #define FAST_EXEC0(n) asm("mov eax, %0": :"i"(n)); \ |
|
71 asm("int 0x20 \n ret") |
|
72 #define FAST_EXEC1(n) asm("mov eax, %0": :"i"(n)); \ |
|
73 asm("mov ecx, [esp+4] \n int 0x20 \n ret") |
|
74 #define SLOW_EXEC0(n) asm("mov eax, %0": :"i"(n)); \ |
|
75 asm("int 0x21 \n ret") |
|
76 #define SLOW_EXEC1(n) asm("mov eax, %0": :"i"(n)); \ |
|
77 asm("mov ecx, [esp+4] \n int 0x21 \n ret") |
|
78 #define SLOW_EXEC2(n) asm("mov eax, %0": :"i"(n)); \ |
|
79 asm("mov ecx, [esp+4] \n mov edx, [esp+8] \n int 0x21 \n ret") |
|
80 #define SLOW_EXEC3(n) asm("mov eax, %0": :"i"(n)); \ |
|
81 asm("push ebx \n" \ |
|
82 "mov ecx, [esp+8] \n" \ |
|
83 "mov edx, [esp+12]\n" \ |
|
84 "mov ebx, [esp+16]\n" \ |
|
85 "int 0x21 \n" \ |
|
86 "pop ebx \n" \ |
|
87 "ret") |
|
88 |
|
89 #define SLOW_EXEC4(n) asm("mov eax, %0": :"i"(n)); \ |
|
90 asm("push ebx \n" \ |
|
91 "push esi \n" \ |
|
92 "mov ecx, [esp+12]\n" \ |
|
93 "mov edx, [esp+16]\n" \ |
|
94 "mov ebx, [esp+20]\n" \ |
|
95 "mov esi, [esp+24]\n" \ |
|
96 "int 0x21 \n" \ |
|
97 "pop esi \n" \ |
|
98 "pop ebx \n" \ |
|
99 "ret") |
|
100 #else |
|
101 #define FAST_EXEC0(n) _asm mov eax, n _asm int 20h _asm ret |
|
102 #define FAST_EXEC1(n) _asm mov eax, n _asm mov ecx, [esp+4] _asm int 20h _asm ret |
|
103 |
|
104 #define SLOW_EXEC0(n) _asm mov eax, n _asm int 21h _asm ret |
|
105 #define SLOW_EXEC1(n) _asm mov eax, n _asm mov ecx, [esp+4] _asm int 21h _asm ret |
|
106 #define SLOW_EXEC2(n) _asm mov eax, n _asm mov ecx, [esp+4] _asm mov edx, [esp+8] _asm int 21h _asm ret |
|
107 |
|
108 #define SLOW_EXEC3(n) _asm mov eax, n \ |
|
109 _asm push ebx \ |
|
110 _asm mov ecx, [esp+8] \ |
|
111 _asm mov edx, [esp+12] \ |
|
112 _asm mov ebx, [esp+16] \ |
|
113 _asm int 21h \ |
|
114 _asm pop ebx \ |
|
115 _asm ret |
|
116 |
|
117 #define SLOW_EXEC4(n) _asm mov eax, n \ |
|
118 _asm push ebx \ |
|
119 _asm push esi \ |
|
120 _asm mov ecx, [esp+12] \ |
|
121 _asm mov edx, [esp+16] \ |
|
122 _asm mov ebx, [esp+20] \ |
|
123 _asm mov esi, [esp+24] \ |
|
124 _asm int 21h \ |
|
125 _asm pop esi \ |
|
126 _asm pop ebx \ |
|
127 _asm ret |
|
128 #endif |
|
129 |
|
130 #define KFAST_EXEC0(n) FAST_EXEC0(n) |
|
131 #define KFAST_EXEC1(n) FAST_EXEC1(n) |
|
132 #define KSLOW_EXEC0(n) SLOW_EXEC0(n) |
|
133 #define KSLOW_EXEC1(n) SLOW_EXEC1(n) |
|
134 #define KSLOW_EXEC2(n) SLOW_EXEC2(n) |
|
135 #define KSLOW_EXEC3(n) SLOW_EXEC3(n) |
|
136 #define KSLOW_EXEC4(n) SLOW_EXEC4(n) |
|
137 |
|
138 #elif defined(__CPU_ARM) |
|
139 |
|
140 // Executive call macros for ARM |
|
141 |
|
142 #define EXECUTIVE_FAST 0x00800000 |
|
143 #define EXECUTIVE_SLOW 0x00000000 |
|
144 |
|
145 #define __DISPATCH(n) \ |
|
146 asm("swi %a0" : : "i" (n)); \ |
|
147 __JUMP(,lr); |
|
148 |
|
149 #define FAST_EXEC0(n) __DISPATCH((n)|EXECUTIVE_FAST) |
|
150 #define FAST_EXEC1(n) __DISPATCH((n)|EXECUTIVE_FAST) |
|
151 #define SLOW_EXEC0(n) __DISPATCH((n)|EXECUTIVE_SLOW) |
|
152 #define SLOW_EXEC1(n) __DISPATCH((n)|EXECUTIVE_SLOW) |
|
153 #define SLOW_EXEC2(n) __DISPATCH((n)|EXECUTIVE_SLOW) |
|
154 #define SLOW_EXEC3(n) __DISPATCH((n)|EXECUTIVE_SLOW) |
|
155 #define SLOW_EXEC4(n) __DISPATCH((n)|EXECUTIVE_SLOW) |
|
156 |
|
157 #define __KDISPATCH(n) \ |
|
158 asm("stmfd sp!, {ip,lr} "); \ |
|
159 asm("swi %a0" : : "i" (n)); \ |
|
160 __POPRET("ip,"); |
|
161 |
|
162 #define KFAST_EXEC0(n) __KDISPATCH((n)|EXECUTIVE_FAST) |
|
163 #define KFAST_EXEC1(n) __KDISPATCH((n)|EXECUTIVE_FAST) |
|
164 #define KSLOW_EXEC0(n) __KDISPATCH((n)|EXECUTIVE_SLOW) |
|
165 #define KSLOW_EXEC1(n) __KDISPATCH((n)|EXECUTIVE_SLOW) |
|
166 #define KSLOW_EXEC2(n) __KDISPATCH((n)|EXECUTIVE_SLOW) |
|
167 #define KSLOW_EXEC3(n) __KDISPATCH((n)|EXECUTIVE_SLOW) |
|
168 #define KSLOW_EXEC4(n) __KDISPATCH((n)|EXECUTIVE_SLOW) |
|
169 |
|
170 #define __DISPATCH_NR(n) \ |
|
171 asm("swi %a0" : : "i" (n)); |
|
172 |
|
173 #define FAST_EXEC0_NR(n) __DISPATCH_NR((n)|EXECUTIVE_FAST) |
|
174 #define FAST_EXEC1_NR(n) __DISPATCH_NR((n)|EXECUTIVE_FAST) |
|
175 #define SLOW_EXEC0_NR(n) __DISPATCH_NR((n)|EXECUTIVE_SLOW) |
|
176 #define SLOW_EXEC1_NR(n) __DISPATCH_NR((n)|EXECUTIVE_SLOW) |
|
177 #define SLOW_EXEC2_NR(n) __DISPATCH_NR((n)|EXECUTIVE_SLOW) |
|
178 #define SLOW_EXEC3_NR(n) __DISPATCH_NR((n)|EXECUTIVE_SLOW) |
|
179 #define SLOW_EXEC4_NR(n) __DISPATCH_NR((n)|EXECUTIVE_SLOW) |
|
180 |
|
181 #define __KDISPATCH_NR(n) \ |
|
182 asm("swi %a0" : : "i" (n)); |
|
183 |
|
184 #define KFAST_EXEC0_NR(n) __KDISPATCH_NR((n)|EXECUTIVE_FAST) |
|
185 #define KFAST_EXEC1_NR(n) __KDISPATCH_NR((n)|EXECUTIVE_FAST) |
|
186 #define KSLOW_EXEC0_NR(n) __KDISPATCH_NR((n)|EXECUTIVE_SLOW) |
|
187 #define KSLOW_EXEC1_NR(n) __KDISPATCH_NR((n)|EXECUTIVE_SLOW) |
|
188 #define KSLOW_EXEC2_NR(n) __KDISPATCH_NR((n)|EXECUTIVE_SLOW) |
|
189 #define KSLOW_EXEC3_NR(n) __KDISPATCH_NR((n)|EXECUTIVE_SLOW) |
|
190 #define KSLOW_EXEC4_NR(n) __KDISPATCH_NR((n)|EXECUTIVE_SLOW) |
|
191 |
|
192 #else |
|
193 #error Unknown CPU |
|
194 #endif |
|
195 |
|
196 #ifdef __LEAVE_EQUALS_THROW__ |
|
197 // Hide TTrap to catch unwary uses of the old cleanup |
|
198 // mechanism at compile time |
|
199 class TTrap; |
|
200 #endif //__LEAVE_EQUALS_THROW__ |
|
201 |
|
202 #include <exec_enum.h> |
|
203 #ifndef __TOOLS2__ |
|
204 #include <e32btrace.h> |
|
205 #endif |
|
206 #include <exec_user.h> |
|
207 |
|
208 #endif |