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