[NDK]: Fix definition of ARM PTE/PDE structure.
[reactos.git] / reactos / 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 extern volatile struct _KSYSTEM_TIME KeTickCount;
199
200 #ifndef YieldProcessor
201 #define YieldProcessor __yield
202 #endif
203
204 #define ASSERT_BREAKPOINT BREAKPOINT_COMMAND_STRING + 1
205
206 #define DbgRaiseAssertionFailure() __break(ASSERT_BREAKPOINT)
207
208 #define PCR_MINOR_VERSION 1
209 #define PCR_MAJOR_VERSION 1
210
211 #define RESULT_ZERO 0
212 #define RESULT_NEGATIVE 1
213 #define RESULT_POSITIVE 2
214
215 DECLSPEC_IMPORT
216 VOID
217 __fastcall
218 KfReleaseSpinLock(
219 IN OUT ULONG_PTR* SpinLock,
220 IN KIRQL NewIrql);
221
222 DECLSPEC_IMPORT
223 KIRQL
224 __fastcall
225 KfAcquireSpinLock(
226 IN OUT ULONG_PTR* SpinLock);
227
228 #ifndef _WINNT_H
229 //
230 // IRQL Support on ARM is similar to MIPS/ALPHA
231 //
232 KIRQL
233 KfRaiseIrql(
234 IN KIRQL NewIrql
235 );
236
237 VOID
238 KfLowerIrql(
239 IN KIRQL NewIrql
240 );
241
242 KIRQL
243 KeRaiseIrqlToSynchLevel(
244 VOID
245 );
246
247 KIRQL
248 KeRaiseIrqlToDpcLevel(
249 VOID
250 );
251
252 #define KeLowerIrql(NewIrql) KfLowerIrql(NewIrql)
253 #define KeRaiseIrql(NewIrql, OldIrql) *(OldIrql) = KfRaiseIrql(NewIrql)
254
255 NTHALAPI
256 KIRQL
257 FASTCALL
258 KfAcquireSpinLock(
259 IN OUT PKSPIN_LOCK SpinLock);
260 #define KeAcquireSpinLock(a,b) *(b) = KfAcquireSpinLock(a)
261
262 NTHALAPI
263 VOID
264 FASTCALL
265 KfReleaseSpinLock(
266 IN OUT PKSPIN_LOCK SpinLock,
267 IN KIRQL NewIrql);
268 #define KeReleaseSpinLock(a,b) KfReleaseSpinLock(a,b)
269
270 NTKERNELAPI
271 VOID
272 FASTCALL
273 KefAcquireSpinLockAtDpcLevel(
274 IN OUT PKSPIN_LOCK SpinLock);
275 #define KeAcquireSpinLockAtDpcLevel(SpinLock) KefAcquireSpinLockAtDpcLevel(SpinLock)
276
277 NTKERNELAPI
278 VOID
279 FASTCALL
280 KefReleaseSpinLockFromDpcLevel(
281 IN OUT PKSPIN_LOCK SpinLock);
282 #define KeReleaseSpinLockFromDpcLevel(SpinLock) KefReleaseSpinLockFromDpcLevel(SpinLock)
283
284 //
285 // Cache clean and flush
286 //
287 VOID
288 HalSweepDcache(
289 VOID
290 );
291
292 VOID
293 HalSweepIcache(
294 VOID
295 );
296
297 FORCEINLINE
298 VOID
299 _KeQueryTickCount(
300 OUT PLARGE_INTEGER CurrentCount)
301 {
302 for (;;) {
303 #ifdef NONAMELESSUNION
304 CurrentCount->s.HighPart = KeTickCount.High1Time;
305 CurrentCount->s.LowPart = KeTickCount.LowPart;
306 if (CurrentCount->s.HighPart == KeTickCount.High2Time) break;
307 #else
308 CurrentCount->HighPart = KeTickCount.High1Time;
309 CurrentCount->LowPart = KeTickCount.LowPart;
310 if (CurrentCount->HighPart == KeTickCount.High2Time) break;
311 #endif
312 YieldProcessor();
313 }
314 }
315 #define KeQueryTickCount(CurrentCount) _KeQueryTickCount(CurrentCount)
316 #endif
317
318 //
319 // Intrinsics
320 //
321 #define InterlockedDecrement _InterlockedDecrement
322 #define InterlockedIncrement _InterlockedIncrement
323 #define InterlockedExchange _InterlockedExchange
324 #endif