* Sync up to trunk r55544.
[reactos.git] / include / reactos / arm / armddk.h
1 #ifndef _ARMDDK_
2 #define _ARMDDK_
3
4 //
5 // Page size
6 //
7 #ifndef PAGE_SIZE
8 #define PAGE_SIZE 0x1000
9 #endif
10
11 #ifndef _WINNT_H
12 //
13 // IRQLs
14 //
15 #define PASSIVE_LEVEL 0
16 #define LOW_LEVEL 0
17 #define APC_LEVEL 1
18 #define DISPATCH_LEVEL 2
19 #define SYNCH_LEVEL DISPATCH_LEVEL
20 #define PROFILE_LEVEL 27
21 #define CLOCK1_LEVEL 28
22 #define CLOCK2_LEVEL 28
23 #define IPI_LEVEL 29
24 #define POWER_LEVEL 30
25 #define HIGH_LEVEL 31
26 #endif
27
28 //
29 // FIXME: mmtypes.h?
30 //
31 #define KIP0PCRADDRESS 0xFFDFF000
32 #define KI_USER_SHARED_DATA 0xFFDF0000
33 #define USPCR 0x7FFF0000
34 #define PCR ((KPCR * const)KIP0PCRADDRESS)
35 #define USERPCR ((volatile KPCR * const)USPCR)
36 #define KeGetPcr() PCR
37 #ifndef _WINNT_H
38 #define SharedUserData ((KUSER_SHARED_DATA * const)KI_USER_SHARED_DATA)
39
40 //
41 // Address space layout
42 //
43 extern PVOID MmHighestUserAddress;
44 extern PVOID MmSystemRangeStart;
45 extern ULONG_PTR MmUserProbeAddress;
46 #define MM_HIGHEST_USER_ADDRESS MmHighestUserAddress
47 #define MM_SYSTEM_RANGE_START MmSystemRangeStart
48 #define MM_USER_PROBE_ADDRESS MmUserProbeAddress
49 #define MM_LOWEST_USER_ADDRESS (PVOID)0x10000
50 #define MM_LOWEST_SYSTEM_ADDRESS (PVOID)0xC0800000
51
52 //
53 // Maximum IRQs
54 //
55 #define MAXIMUM_VECTOR 16
56
57 #define KERNEL_STACK_SIZE 12288
58 #define KERNEL_LARGE_STACK_SIZE 61440
59 #define KERNEL_LARGE_STACK_COMMIT 12288
60
61 //
62 // Used to contain PFNs and PFN counts
63 //
64 //typedef ULONG PFN_COUNT;
65 //typedef ULONG PFN_NUMBER, *PPFN_NUMBER;
66 //typedef LONG SPFN_NUMBER, *PSPFN_NUMBER;
67
68 //
69 // Stub
70 //
71 typedef struct _KFLOATING_SAVE
72 {
73 ULONG Reserved;
74 } KFLOATING_SAVE, *PKFLOATING_SAVE;
75
76 /* The following flags control the contents of the CONTEXT structure. */
77 #define CONTEXT_ARM 0x0000040
78 #define CONTEXT_CONTROL (CONTEXT_ARM | 0x00000001L)
79 #define CONTEXT_INTEGER (CONTEXT_ARM | 0x00000002L)
80 #define CONTEXT_FULL (CONTEXT_CONTROL | CONTEXT_INTEGER)
81
82 typedef struct _CONTEXT {
83 /* The flags values within this flag control the contents of
84 a CONTEXT record.
85
86 If the context record is used as an input parameter, then
87 for each portion of the context record controlled by a flag
88 whose value is set, it is assumed that that portion of the
89 context record contains valid context. If the context record
90 is being used to modify a thread's context, then only that
91 portion of the threads context will be modified.
92
93 If the context record is used as an IN OUT parameter to capture
94 the context of a thread, then only those portions of the thread's
95 context corresponding to set flags will be returned.
96
97 The context record is never used as an OUT only parameter. */
98
99 ULONG ContextFlags;
100
101 /* This section is specified/returned if the ContextFlags word contains
102 the flag CONTEXT_INTEGER. */
103 ULONG R0;
104 ULONG R1;
105 ULONG R2;
106 ULONG R3;
107 ULONG R4;
108 ULONG R5;
109 ULONG R6;
110 ULONG R7;
111 ULONG R8;
112 ULONG R9;
113 ULONG R10;
114 ULONG R11;
115 ULONG R12;
116
117 ULONG Sp;
118 ULONG Lr;
119 ULONG Pc;
120 ULONG Psr;
121 } CONTEXT;
122 #endif
123
124 //
125 // Processor Control Region
126 //
127 #ifdef _WINNT_H
128 #define KIRQL ULONG
129 #endif
130
131 typedef struct _NT_TIB_KPCR {
132 struct _EXCEPTION_REGISTRATION_RECORD *ExceptionList;
133 PVOID StackBase;
134 PVOID StackLimit;
135 PVOID SubSystemTib;
136 _ANONYMOUS_UNION union {
137 PVOID FiberData;
138 ULONG Version;
139 } DUMMYUNIONNAME;
140 PVOID ArbitraryUserPointer;
141 struct _NT_TIB_KPCR *Self;
142 } NT_TIB_KPCR,*PNT_TIB_KPCR;
143
144 typedef struct _KPCR
145 {
146 union
147 {
148 NT_TIB_KPCR NtTib;
149 struct
150 {
151 struct _EXCEPTION_REGISTRATION_RECORD *Used_ExceptionList; // Unused
152 PVOID Used_StackBase; // Unused
153 PVOID PerfGlobalGroupMask;
154 PVOID TssCopy; // Unused
155 ULONG ContextSwitches;
156 KAFFINITY SetMemberCopy; // Unused
157 PVOID Used_Self;
158 };
159 };
160 struct _KPCR *Self;
161 struct _KPRCB *Prcb;
162 KIRQL Irql;
163 ULONG IRR; // Unused
164 ULONG IrrActive; // Unused
165 ULONG IDR; // Unused
166 PVOID KdVersionBlock;
167 PVOID IDT; // Unused
168 PVOID GDT; // Unused
169 PVOID TSS; // Unused
170 USHORT MajorVersion;
171 USHORT MinorVersion;
172 KAFFINITY SetMember;
173 ULONG StallScaleFactor;
174 UCHAR SpareUnused;
175 UCHAR Number;
176 UCHAR Spare0;
177 UCHAR SecondLevelCacheAssociativity;
178 ULONG VdmAlert;
179 ULONG KernelReserved[14];
180 ULONG SecondLevelCacheSize;
181 ULONG HalReserved[16];
182 } KPCR, *PKPCR;
183
184 //
185 // Get the current TEB
186 //
187 FORCEINLINE
188 struct _TEB* NtCurrentTeb(VOID)
189 {
190 return (struct _TEB*)USERPCR->Used_Self;
191 }
192
193 NTSYSAPI
194 struct _KTHREAD*
195 NTAPI
196 KeGetCurrentThread(VOID);
197
198 FORCEINLINE
199 NTSTATUS
200 KeSaveFloatingPointState(PVOID FloatingState)
201 {
202 UNREFERENCED_PARAMETER(FloatingState);
203 return STATUS_SUCCESS;
204 }
205
206 FORCEINLINE
207 NTSTATUS
208 KeRestoreFloatingPointState(PVOID FloatingState)
209 {
210 UNREFERENCED_PARAMETER(FloatingState);
211 return STATUS_SUCCESS;
212 }
213
214 extern volatile struct _KSYSTEM_TIME KeTickCount;
215
216 #ifndef YieldProcessor
217 #define YieldProcessor __yield
218 #endif
219
220 #define ASSERT_BREAKPOINT BREAKPOINT_COMMAND_STRING + 1
221
222 #define DbgRaiseAssertionFailure() __break(ASSERT_BREAKPOINT)
223
224 #define PCR_MINOR_VERSION 1
225 #define PCR_MAJOR_VERSION 1
226
227 #define RESULT_ZERO 0
228 #define RESULT_NEGATIVE 1
229 #define RESULT_POSITIVE 2
230
231 DECLSPEC_IMPORT
232 VOID
233 __fastcall
234 KfReleaseSpinLock(
235 IN OUT ULONG_PTR* SpinLock,
236 IN KIRQL NewIrql);
237
238 DECLSPEC_IMPORT
239 KIRQL
240 __fastcall
241 KfAcquireSpinLock(
242 IN OUT ULONG_PTR* SpinLock);
243
244 #ifndef _WINNT_H
245 //
246 // IRQL Support on ARM is similar to MIPS/ALPHA
247 //
248 KIRQL
249 KfRaiseIrql(
250 IN KIRQL NewIrql
251 );
252
253 VOID
254 KfLowerIrql(
255 IN KIRQL NewIrql
256 );
257
258 KIRQL
259 KeRaiseIrqlToSynchLevel(
260 VOID
261 );
262
263 KIRQL
264 KeRaiseIrqlToDpcLevel(
265 VOID
266 );
267
268 #define KeLowerIrql(NewIrql) KfLowerIrql(NewIrql)
269 #define KeRaiseIrql(NewIrql, OldIrql) *(OldIrql) = KfRaiseIrql(NewIrql)
270
271 NTHALAPI
272 KIRQL
273 FASTCALL
274 KfAcquireSpinLock(
275 IN OUT PKSPIN_LOCK SpinLock);
276 #define KeAcquireSpinLock(a,b) *(b) = KfAcquireSpinLock(a)
277
278 NTHALAPI
279 VOID
280 FASTCALL
281 KfReleaseSpinLock(
282 IN OUT PKSPIN_LOCK SpinLock,
283 IN KIRQL NewIrql);
284 #define KeReleaseSpinLock(a,b) KfReleaseSpinLock(a,b)
285
286 NTKERNELAPI
287 VOID
288 FASTCALL
289 KefAcquireSpinLockAtDpcLevel(
290 IN OUT PKSPIN_LOCK SpinLock);
291 #define KeAcquireSpinLockAtDpcLevel(SpinLock) KefAcquireSpinLockAtDpcLevel(SpinLock)
292
293 NTKERNELAPI
294 VOID
295 FASTCALL
296 KefReleaseSpinLockFromDpcLevel(
297 IN OUT PKSPIN_LOCK SpinLock);
298 #define KeReleaseSpinLockFromDpcLevel(SpinLock) KefReleaseSpinLockFromDpcLevel(SpinLock)
299
300 //
301 // Cache clean and flush
302 //
303 VOID
304 HalSweepDcache(
305 VOID
306 );
307
308 VOID
309 HalSweepIcache(
310 VOID
311 );
312
313 FORCEINLINE
314 VOID
315 _KeQueryTickCount(
316 OUT PLARGE_INTEGER CurrentCount)
317 {
318 for (;;) {
319 #ifdef NONAMELESSUNION
320 CurrentCount->s.HighPart = KeTickCount.High1Time;
321 CurrentCount->s.LowPart = KeTickCount.LowPart;
322 if (CurrentCount->s.HighPart == KeTickCount.High2Time) break;
323 #else
324 CurrentCount->HighPart = KeTickCount.High1Time;
325 CurrentCount->LowPart = KeTickCount.LowPart;
326 if (CurrentCount->HighPart == KeTickCount.High2Time) break;
327 #endif
328 YieldProcessor();
329 }
330 }
331 #define KeQueryTickCount(CurrentCount) _KeQueryTickCount(CurrentCount)
332 #endif
333
334 //
335 // Intrinsics
336 //
337 #define InterlockedDecrement _InterlockedDecrement
338 #define InterlockedIncrement _InterlockedIncrement
339 #define InterlockedExchange _InterlockedExchange
340 #endif