Also define PAGE_SIZE in armddk.h if it isn't already defined (allows cmlib to compil...
[reactos.git] / reactos / include / reactos / arm / armddk.h
1 #ifndef _ARMDDK_
2 #define _ARMDDK_
3
4 //
5 // IRQLs
6 //
7 #define PASSIVE_LEVEL 0
8 #define LOW_LEVEL 0
9 #define APC_LEVEL 1
10 #define DISPATCH_LEVEL 2
11 #define SYNCH_LEVEL DISPATCH_LEVEL
12 #define PROFILE_LEVEL 27
13 #define CLOCK1_LEVEL 28
14 #define CLOCK2_LEVEL 28
15 #define IPI_LEVEL 29
16 #define POWER_LEVEL 30
17 #define HIGH_LEVEL 31
18
19 //
20 // Page size
21 //
22 #ifndef PAGE_SIZE
23 #define PAGE_SIZE 0x1000
24 #endif
25
26 //
27 // FIXME: mmtypes.h?
28 //
29 #define KIPCR 0xFFFFF000
30 #define KI_USER_SHARED_DATA 0xFFFFE000
31 #define USPCR 0x7FFF0000
32 #define PCR ((volatile KPCR * const)KIPCR)
33 #define USERPCR ((volatile KPCR * const)USPCR)
34
35 //
36 // Maximum IRQs
37 //
38 #define MAXIMUM_VECTOR 16
39
40 //
41 // Just read it from the PCR
42 //
43 #define KeGetCurrentProcessorNumber() (int)PCR->Number
44 #define KeGetCurrentIrql() PCR->CurrentIrql
45 #define _KeGetCurrentThread() PCR->CurrentThread
46 #define _KeGetPreviousMode() PCR->CurrentThread->PreviousMode
47 #define _KeIsExecutingDpc() (PCR->DpcRoutineActive != 0)
48 #define KeGetCurrentThread() _KeGetCurrentThread()
49 #define KeGetPreviousMode() _KeGetPreviousMode()
50 #define KeGetDcacheFillSize() PCR->DcacheFillSize
51
52
53 //
54 // Used to contain PFNs and PFN counts
55 //
56 typedef ULONG PFN_COUNT;
57 typedef ULONG PFN_NUMBER, *PPFN_NUMBER;
58 typedef LONG SPFN_NUMBER, *PSPFN_NUMBER;
59
60 //
61 // Stub
62 //
63 typedef struct _KFLOATING_SAVE
64 {
65 ULONG Reserved;
66 } KFLOATING_SAVE, *PKFLOATING_SAVE;
67
68 #ifndef _WINNT_H
69 /* The following flags control the contents of the CONTEXT structure. */
70 #define CONTEXT_ARM 0x0000040
71 #define CONTEXT_CONTROL (CONTEXT_ARM | 0x00000001L)
72 #define CONTEXT_INTEGER (CONTEXT_ARM | 0x00000002L)
73 #define CONTEXT_FULL (CONTEXT_CONTROL | CONTEXT_INTEGER)
74
75 typedef struct _CONTEXT {
76 /* The flags values within this flag control the contents of
77 a CONTEXT record.
78
79 If the context record is used as an input parameter, then
80 for each portion of the context record controlled by a flag
81 whose value is set, it is assumed that that portion of the
82 context record contains valid context. If the context record
83 is being used to modify a thread's context, then only that
84 portion of the threads context will be modified.
85
86 If the context record is used as an IN OUT parameter to capture
87 the context of a thread, then only those portions of the thread's
88 context corresponding to set flags will be returned.
89
90 The context record is never used as an OUT only parameter. */
91
92 ULONG ContextFlags;
93
94 /* This section is specified/returned if the ContextFlags word contains
95 the flag CONTEXT_INTEGER. */
96 ULONG R0;
97 ULONG R1;
98 ULONG R2;
99 ULONG R3;
100 ULONG R4;
101 ULONG R5;
102 ULONG R6;
103 ULONG R7;
104 ULONG R8;
105 ULONG R9;
106 ULONG R10;
107 ULONG R11;
108 ULONG R12;
109
110 ULONG Sp;
111 ULONG Lr;
112 ULONG Pc;
113 ULONG Psr;
114 } CONTEXT;
115 #endif
116
117 //
118 // Processor Control Region
119 // On ARM, it's actually readable from user-mode, much like KUSER_SHARED_DATA
120 //
121 #ifdef _WINNT_H
122 typedef
123 VOID
124 (*PKINTERRUPT_ROUTINE)(VOID);
125 #endif
126 typedef struct _KPCR
127 {
128 ULONG MinorVersion;
129 ULONG MajorVersion;
130 PKINTERRUPT_ROUTINE InterruptRoutine[MAXIMUM_VECTOR];
131 PVOID XcodeDispatch;
132 ULONG FirstLevelDcacheSize;
133 ULONG FirstLevelDcacheFillSize;
134 ULONG FirstLevelIcacheSize;
135 ULONG FirstLevelIcacheFillSize;
136 ULONG SecondLevelDcacheSize;
137 ULONG SecondLevelDcacheFillSize;
138 ULONG SecondLevelIcacheSize;
139 ULONG SecondLevelIcacheFillSize;
140 struct _KPRCB *Prcb;
141 struct _TEB *Teb;
142 PVOID TlsArray;
143 ULONG DcacheFillSize;
144 ULONG IcacheAlignment;
145 ULONG IcacheFillSize;
146 ULONG ProcessorId;
147 ULONG ProfileInterval;
148 ULONG ProfileCount;
149 ULONG StallExecutionCount;
150 ULONG StallScaleFactor;
151 CCHAR Number;
152 PVOID DataBusError;
153 PVOID InstructionBusError;
154 ULONG CachePolicy;
155 ULONG AlignedCachePolicy;
156 UCHAR IrqlMask[HIGH_LEVEL + 1];
157 ULONG IrqlTable[HIGH_LEVEL + 1];
158 UCHAR CurrentIrql;
159 KAFFINITY SetMember;
160 struct _KTHREAD *CurrentThread;
161 ULONG ReservedVectors;
162 KAFFINITY NotMember;
163 ULONG SystemReserved[6];
164 ULONG DcacheAlignment;
165 ULONG HalReserved[64];
166 BOOLEAN FirstLevelActive;
167 BOOLEAN DpcRoutineActive;
168 ULONG CurrentPid;
169 BOOLEAN OnInterruptStack;
170 PVOID SavedInitialStack;
171 PVOID SavedStackLimit;
172 PVOID SystemServiceDispatchStart;
173 PVOID SystemServiceDispatchEnd;
174 PVOID InterruptStack;
175 PVOID PanicStack;
176 PVOID BadVaddr;
177 PVOID InitialStack;
178 PVOID StackLimit;
179 ULONG QuantumEnd;
180 PVOID PerfGlobalGroupMask;
181 ULONG ContextSwitches;
182 } KPCR, *PKPCR;
183
184 //
185 // Get the current TEB
186 //
187 FORCEINLINE
188 struct _TEB* NtCurrentTeb(VOID)
189 {
190 return (struct _TEB*)USERPCR->Teb;
191 }
192
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
232 #endif