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