8 #define PAGE_SIZE 0x1000
15 #define PASSIVE_LEVEL 0
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
24 #define POWER_LEVEL 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
38 #define SharedUserData ((KUSER_SHARED_DATA * const)KI_USER_SHARED_DATA)
41 // Address space layout
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
55 #define MAXIMUM_VECTOR 16
58 // Just read it from the PCR
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
71 // Used to contain PFNs and PFN counts
73 typedef ULONG PFN_COUNT
;
74 typedef ULONG PFN_NUMBER
, *PPFN_NUMBER
;
75 typedef LONG SPFN_NUMBER
, *PSPFN_NUMBER
;
80 typedef struct _KFLOATING_SAVE
83 } KFLOATING_SAVE
, *PKFLOATING_SAVE
;
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)
91 typedef struct _CONTEXT
{
92 /* The flags values within this flag control the contents of
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.
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.
106 The context record is never used as an OUT only parameter. */
110 /* This section is specified/returned if the ContextFlags word contains
111 the flag CONTEXT_INTEGER. */
134 // Processor Control Region
135 // On ARM, it's actually readable from user-mode, much like KUSER_SHARED_DATA
140 (*PKINTERRUPT_ROUTINE
)(VOID
);
146 PKINTERRUPT_ROUTINE InterruptRoutine
[32];
148 ULONG FirstLevelDcacheSize
;
149 ULONG FirstLevelDcacheFillSize
;
150 ULONG FirstLevelIcacheSize
;
151 ULONG FirstLevelIcacheFillSize
;
152 ULONG SecondLevelDcacheSize
;
153 ULONG SecondLevelDcacheFillSize
;
154 ULONG SecondLevelIcacheSize
;
155 ULONG SecondLevelIcacheFillSize
;
159 ULONG DcacheFillSize
;
160 ULONG IcacheAlignment
;
161 ULONG IcacheFillSize
;
163 ULONG ProfileInterval
;
165 ULONG StallExecutionCount
;
166 ULONG StallScaleFactor
;
169 PVOID InstructionBusError
;
171 ULONG AlignedCachePolicy
;
176 struct _KTHREAD
*CurrentThread
;
177 ULONG ReservedVectors
;
179 ULONG SystemReserved
[6];
180 ULONG DcacheAlignment
;
181 ULONG HalReserved
[64];
182 BOOLEAN FirstLevelActive
;
183 BOOLEAN DpcRoutineActive
;
185 BOOLEAN OnInterruptStack
;
186 PVOID SavedInitialStack
;
187 PVOID SavedStackLimit
;
188 PVOID SystemServiceDispatchStart
;
189 PVOID SystemServiceDispatchEnd
;
190 PVOID InterruptStack
;
196 PVOID PerfGlobalGroupMask
;
197 ULONG ContextSwitches
;
201 // Get the current TEB
204 struct _TEB
* NtCurrentTeb(VOID
)
206 return (struct _TEB
*)USERPCR
->Teb
;
211 // IRQL Support on ARM is similar to MIPS/ALPHA
224 KeRaiseIrqlToSynchLevel(
229 KeRaiseIrqlToDpcLevel(
233 #define KeLowerIrql(NewIrql) KfLowerIrql(NewIrql)
234 #define KeRaiseIrql(NewIrql, OldIrql) *(OldIrql) = KfRaiseIrql(NewIrql)
237 // Cache clean and flush
253 #define InterlockedDecrement _InterlockedDecrement
254 #define InterlockedIncrement _InterlockedIncrement
255 #define InterlockedExchange _InterlockedExchange