Sync to trunk head (r42241)
[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 KIPCR 0xFFFFF000
32 #define KI_USER_SHARED_DATA 0xFFFFE000
33 #define USPCR 0x7FFF0000
34 #define PCR ((volatile KPCR * const)KIPCR)
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)0xC1400000
51
52 //
53 // Maximum IRQs
54 //
55 #define MAXIMUM_VECTOR 16
56
57 //
58 // Just read it from the PCR
59 //
60 #define KeGetCurrentProcessorNumber() (int)PCR->Number
61 #define KeGetCurrentIrql() PCR->CurrentIrql
62 #define _KeGetCurrentThread() PCR->CurrentThread
63 #define _KeGetPreviousMode() PCR->CurrentThread->PreviousMode
64 #define _KeIsExecutingDpc() (PCR->DpcRoutineActive != 0)
65 #define KeGetCurrentThread() _KeGetCurrentThread()
66 #define KeGetPreviousMode() _KeGetPreviousMode()
67 #define KeGetDcacheFillSize() PCR->DcacheFillSize
68
69
70 //
71 // Used to contain PFNs and PFN counts
72 //
73 typedef ULONG PFN_COUNT;
74 typedef ULONG PFN_NUMBER, *PPFN_NUMBER;
75 typedef LONG SPFN_NUMBER, *PSPFN_NUMBER;
76
77 //
78 // Stub
79 //
80 typedef struct _KFLOATING_SAVE
81 {
82 ULONG Reserved;
83 } KFLOATING_SAVE, *PKFLOATING_SAVE;
84
85 /* The following flags control the contents of the CONTEXT structure. */
86 #define CONTEXT_ARM 0x0000040
87 #define CONTEXT_CONTROL (CONTEXT_ARM | 0x00000001L)
88 #define CONTEXT_INTEGER (CONTEXT_ARM | 0x00000002L)
89 #define CONTEXT_FULL (CONTEXT_CONTROL | CONTEXT_INTEGER)
90
91 typedef struct _CONTEXT {
92 /* The flags values within this flag control the contents of
93 a CONTEXT record.
94
95 If the context record is used as an input parameter, then
96 for each portion of the context record controlled by a flag
97 whose value is set, it is assumed that that portion of the
98 context record contains valid context. If the context record
99 is being used to modify a thread's context, then only that
100 portion of the threads context will be modified.
101
102 If the context record is used as an IN OUT parameter to capture
103 the context of a thread, then only those portions of the thread's
104 context corresponding to set flags will be returned.
105
106 The context record is never used as an OUT only parameter. */
107
108 ULONG ContextFlags;
109
110 /* This section is specified/returned if the ContextFlags word contains
111 the flag CONTEXT_INTEGER. */
112 ULONG R0;
113 ULONG R1;
114 ULONG R2;
115 ULONG R3;
116 ULONG R4;
117 ULONG R5;
118 ULONG R6;
119 ULONG R7;
120 ULONG R8;
121 ULONG R9;
122 ULONG R10;
123 ULONG R11;
124 ULONG R12;
125
126 ULONG Sp;
127 ULONG Lr;
128 ULONG Pc;
129 ULONG Psr;
130 } CONTEXT;
131 #endif
132
133 //
134 // Processor Control Region
135 // On ARM, it's actually readable from user-mode, much like KUSER_SHARED_DATA
136 //
137 #ifdef _WINNT_H
138 typedef
139 VOID
140 (*PKINTERRUPT_ROUTINE)(VOID);
141 #endif
142 typedef struct _KPCR
143 {
144 ULONG MinorVersion;
145 ULONG MajorVersion;
146 PKINTERRUPT_ROUTINE InterruptRoutine[32];
147 PVOID XcodeDispatch;
148 ULONG FirstLevelDcacheSize;
149 ULONG FirstLevelDcacheFillSize;
150 ULONG FirstLevelIcacheSize;
151 ULONG FirstLevelIcacheFillSize;
152 ULONG SecondLevelDcacheSize;
153 ULONG SecondLevelDcacheFillSize;
154 ULONG SecondLevelIcacheSize;
155 ULONG SecondLevelIcacheFillSize;
156 struct _KPRCB *Prcb;
157 struct _TEB *Teb;
158 PVOID TlsArray;
159 ULONG DcacheFillSize;
160 ULONG IcacheAlignment;
161 ULONG IcacheFillSize;
162 ULONG ProcessorId;
163 ULONG ProfileInterval;
164 ULONG ProfileCount;
165 ULONG StallExecutionCount;
166 ULONG StallScaleFactor;
167 CCHAR Number;
168 PVOID DataBusError;
169 PVOID InstructionBusError;
170 ULONG CachePolicy;
171 ULONG AlignedCachePolicy;
172 UCHAR IrqlMask[32];
173 ULONG IrqlTable[32];
174 UCHAR CurrentIrql;
175 KAFFINITY SetMember;
176 struct _KTHREAD *CurrentThread;
177 ULONG ReservedVectors;
178 KAFFINITY NotMember;
179 ULONG SystemReserved[6];
180 ULONG DcacheAlignment;
181 ULONG HalReserved[64];
182 BOOLEAN FirstLevelActive;
183 BOOLEAN DpcRoutineActive;
184 ULONG CurrentPid;
185 BOOLEAN OnInterruptStack;
186 PVOID SavedInitialStack;
187 PVOID SavedStackLimit;
188 PVOID SystemServiceDispatchStart;
189 PVOID SystemServiceDispatchEnd;
190 PVOID InterruptStack;
191 PVOID PanicStack;
192 PVOID BadVaddr;
193 PVOID InitialStack;
194 PVOID StackLimit;
195 ULONG QuantumEnd;
196 PVOID PerfGlobalGroupMask;
197 ULONG ContextSwitches;
198 } KPCR, *PKPCR;
199
200 //
201 // Get the current TEB
202 //
203 FORCEINLINE
204 struct _TEB* NtCurrentTeb(VOID)
205 {
206 return (struct _TEB*)USERPCR->Teb;
207 }
208
209 #ifndef _WINNT_H
210 //
211 // IRQL Support on ARM is similar to MIPS/ALPHA
212 //
213 KIRQL
214 KfRaiseIrql(
215 IN KIRQL NewIrql
216 );
217
218 VOID
219 KfLowerIrql(
220 IN KIRQL NewIrql
221 );
222
223 KIRQL
224 KeRaiseIrqlToSynchLevel(
225 VOID
226 );
227
228 KIRQL
229 KeRaiseIrqlToDpcLevel(
230 VOID
231 );
232
233 #define KeLowerIrql(NewIrql) KfLowerIrql(NewIrql)
234 #define KeRaiseIrql(NewIrql, OldIrql) *(OldIrql) = KfRaiseIrql(NewIrql)
235
236 //
237 // Cache clean and flush
238 //
239 VOID
240 HalSweepDcache(
241 VOID
242 );
243
244 VOID
245 HalSweepIcache(
246 VOID
247 );
248 #endif
249
250 //
251 // Intrinsics
252 //
253 #define InterlockedDecrement _InterlockedDecrement
254 #define InterlockedIncrement _InterlockedIncrement
255 #define InterlockedExchange _InterlockedExchange
256 #endif