82e6d9fdd72326285382f58472b29624d098143c
[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 } KPCR, *PKPCR;
177
178 //
179 // Get the current TEB
180 //
181 FORCEINLINE
182 struct _TEB* NtCurrentTeb(VOID)
183 {
184 return (struct _TEB*)USERPCR->Used_Self;
185 }
186
187 NTSYSAPI
188 PKTHREAD
189 NTAPI
190 KeGetCurrentThread(VOID);
191
192 #ifndef _WINNT_H
193 //
194 // IRQL Support on ARM is similar to MIPS/ALPHA
195 //
196 KIRQL
197 KfRaiseIrql(
198 IN KIRQL NewIrql
199 );
200
201 VOID
202 KfLowerIrql(
203 IN KIRQL NewIrql
204 );
205
206 KIRQL
207 KeRaiseIrqlToSynchLevel(
208 VOID
209 );
210
211 KIRQL
212 KeRaiseIrqlToDpcLevel(
213 VOID
214 );
215
216 #define KeLowerIrql(NewIrql) KfLowerIrql(NewIrql)
217 #define KeRaiseIrql(NewIrql, OldIrql) *(OldIrql) = KfRaiseIrql(NewIrql)
218
219 //
220 // Cache clean and flush
221 //
222 VOID
223 HalSweepDcache(
224 VOID
225 );
226
227 VOID
228 HalSweepIcache(
229 VOID
230 );
231 #endif
232
233 //
234 // Intrinsics
235 //
236 #define InterlockedDecrement _InterlockedDecrement
237 #define InterlockedIncrement _InterlockedIncrement
238 #define InterlockedExchange _InterlockedExchange
239 #endif