ReactOS  0.4.14-dev-98-gb0d4763
cpu.c
Go to the documentation of this file.
1 /*
2  * PROJECT: ReactOS Kernel
3  * LICENSE: BSD - See COPYING.ARM in the top level directory
4  * FILE: ntoskrnl/ke/arm/cpu.c
5  * PURPOSE: Implements routines for ARM CPU support
6  * PROGRAMMERS: ReactOS Portable Systems Group
7  */
8 
9 /* INCLUDES *******************************************************************/
10 
11 #include <ntoskrnl.h>
12 #define NDEBUG
13 #include <debug.h>
14 
15 /* GLOBALS ********************************************************************/
16 
21 ULONG KeLargestCacheLine = 64; // FIXME: It depends
22 
23 /* FUNCTIONS ******************************************************************/
24 
25 VOID
27  IN PVOID Virtual)
28 {
29  //
30  // Just invalidate it
31  //
32  KeArmInvalidateTlbEntry(Virtual);
33 }
34 
35 VOID
37 {
38  //
39  // Flush the entire TLB
40  //
41  KeArmFlushTlb();
42 }
43 
44 VOID
45 NTAPI
47 {
48  //
49  // Rename?
50  //
51  KeFlushTb();
52 }
53 
54 VOID
57  IN ULONG Size)
58 {
59  /* Not using XMMI in this routine */
61 }
62 
63 VOID
64 NTAPI
66 {
67  //
68  // Save some critical stuff we use
69  //
70  __debugbreak();
71 #if 0
72  ProcessorState->SpecialRegisters.ControlRegister = KeArmControlRegisterGet();
73  ProcessorState->SpecialRegisters.LockdownRegister = KeArmLockdownRegisterGet();
74  ProcessorState->SpecialRegisters.CacheRegister = KeArmCacheRegisterGet();
75  ProcessorState->SpecialRegisters.StatusRegister = KeArmStatusRegisterGet();
76 #endif
77 }
78 
79 VOID
80 NTAPI
82 {
83  __debugbreak();
84 #if 0
85  KeArmControlRegisterSet(ProcessorState->SpecialRegisters.ControlRegister);
86  KeArmLockdownRegisterSet(ProcessorState->SpecialRegisters.LockdownRegister);
87  KeArmCacheRegisterSet(ProcessorState->SpecialRegisters.CacheRegister);
88  KeArmStatusRegisterSet(ProcessorState->SpecialRegisters.StatusRegister);
89 #endif
90 }
91 
92 BOOLEAN
93 NTAPI
95 {
96  //
97  // Invalidate D cache and I cache
98  //
100  return TRUE;
101 }
102 
103 
104 /* PUBLIC FUNCTIONS ***********************************************************/
105 
106 /*
107  * @implemented
108  */
109 ULONG
110 NTAPI
112 {
113  /* Return the global variable */
114  return KeLargestCacheLine;
115 }
116 
117 /*
118  * @implemented
119  */
120 VOID
121 NTAPI
123  IN BOOLEAN AllProcessors)
124 {
125  KIRQL OldIrql;
126 
127  //
128  // Raise the IRQL for the TB Flush
129  //
131 
132  //
133  // Flush the TB for the Current CPU
134  //
136 
137  //
138  // Return to Original IRQL
139  //
141 }
142 
143 /*
144  * @implemented
145  */
146 VOID
147 NTAPI
149 {
150  //
151  // Save the coherency globally
152  //
153  KiDmaIoCoherency = Coherency;
154 }
155 
156 /*
157  * @implemented
158  */
159 KAFFINITY
160 NTAPI
162 {
163  PAGED_CODE();
164 
165  //
166  // Simply return the number of active processors
167  //
168  return KeActiveProcessors;
169 }
170 
171 /*
172  * @implemented
173  */
174 VOID
175 __cdecl
177 {
178  //
179  // Capture the context
180  //
181  RtlCaptureContext(&State->ContextFrame);
182 
183  //
184  // Capture the control state
185  //
187 }
188 
189 VOID
190 NTAPI
192  _In_ PMDL Mdl,
193  _In_ BOOLEAN ReadOperation,
194  _In_ BOOLEAN DmaOperation)
195 {
196  DbgBreakPoint();
197 }
198 
199 /* SYSTEM CALLS NOT VALID ON THIS CPU *****************************************/
200 
201 /*
202  * @implemented
203  */
204 NTSTATUS
205 NTAPI
207  IN PVOID ControlData)
208 {
209  //
210  // Does not exist on ARM
211  //
212  return STATUS_NOT_IMPLEMENTED;
213 }
214 
215 NTSTATUS
216 NTAPI
218  IN LDT_ENTRY LdtEntry1,
219  IN ULONG Selector2,
220  IN LDT_ENTRY LdtEntry2)
221 {
222  //
223  // Does not exist on ARM
224  //
225  return STATUS_NOT_IMPLEMENTED;
226 }
#define IN
Definition: typedefs.h:38
FORCEINLINE ARM_CACHE_REGISTER KeArmCacheRegisterGet(VOID)
Definition: intrin_i.h:109
#define TRUE
Definition: types.h:120
VOID NTAPI KiSaveProcessorControlState(OUT PKPROCESSOR_STATE ProcessorState)
Definition: cpu.c:372
#define KeLowerIrql(oldIrql)
Definition: env_spec_w32.h:602
#define __cdecl
Definition: accygwin.h:79
FORCEINLINE ARM_CONTROL_REGISTER KeArmControlRegisterGet(VOID)
Definition: intrin_i.h:18
#define STATUS_NOT_IMPLEMENTED
Definition: ntstatus.h:225
FORCEINLINE VOID KeArmInvalidateTlbEntry(IN PVOID Address)
Definition: intrin_i.h:185
LONG NTSTATUS
Definition: precomp.h:26
FORCEINLINE VOID KeArmLockdownRegisterSet(IN ARM_LOCKDOWN_REGISTER LockdownRegister)
Definition: intrin_i.h:165
KSPECIAL_REGISTERS SpecialRegisters
Definition: ketypes.h:530
void DbgBreakPoint()
Definition: mach.c:553
NTSYSAPI VOID NTAPI RtlCaptureContext(_Out_ PCONTEXT ContextRecord)
#define FASTCALL
Definition: nt_native.h:50
void __cdecl __debugbreak(void)
Definition: intrin_ppc.h:698
ULONG KeIcacheFlushCount
Definition: cpu.c:19
#define PAGED_CODE()
Definition: video.h:57
ULONG NTAPI KeGetRecommendedSharedDataAlignment(VOID)
Definition: cpu.c:471
UCHAR KIRQL
Definition: env_spec_w32.h:591
NTSTATUS(* NTAPI)(IN PFILE_FULL_EA_INFORMATION EaBuffer, IN ULONG EaLength, OUT PULONG ErrorOffset)
Definition: IoEaTest.cpp:117
VOID NTAPI KeFlushCurrentTb(VOID)
Definition: cpu.c:322
NTSTATUS NTAPI NtSetLdtEntries(IN ULONG Selector1, IN LDT_ENTRY LdtEntry1, IN ULONG Selector2, IN LDT_ENTRY LdtEntry2)
Definition: cpu.c:217
FORCEINLINE ARM_STATUS_REGISTER KeArmStatusRegisterGet(VOID)
Definition: intrin_i.h:122
FORCEINLINE VOID KeArmControlRegisterSet(IN ARM_CONTROL_REGISTER ControlRegister)
Definition: intrin_i.h:135
unsigned char BOOLEAN
static WCHAR Address[46]
Definition: ping.c:68
_IRQL_requires_same_ typedef _In_ ULONG ControlCode
Definition: wmitypes.h:55
ULONG KeFixedTbEntries
Definition: cpu.c:17
ULONG KiDmaIoCoherency
Definition: cpu.c:33
VOID NTAPI KeFlushEntireTb(IN BOOLEAN Invalid, IN BOOLEAN AllProcessors)
Definition: cpu.c:413
BOOLEAN NTAPI KeInvalidateAllCaches(VOID)
Definition: cpu.c:459
VOID __cdecl KeSaveStateForHibernate(IN PKPROCESSOR_STATE State)
Definition: cpu.c:482
KAFFINITY NTAPI KeQueryActiveProcessors(VOID)
Definition: cpu.c:433
FORCEINLINE ARM_LOCKDOWN_REGISTER KeArmLockdownRegisterGet(VOID)
Definition: intrin_i.h:83
VOID KiFlushSingleTb(IN BOOLEAN Invalid, IN PVOID Virtual)
Definition: cpu.c:26
VOID KeFlushTb(VOID)
Definition: cpu.c:36
_Requires_lock_held_ Interrupt _Releases_lock_ Interrupt _In_ _IRQL_restores_ KIRQL OldIrql
Definition: kefuncs.h:803
VOID NTAPI KiRestoreProcessorControlState(PKPROCESSOR_STATE ProcessorState)
Definition: cpu.c:330
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:359
KAFFINITY KeActiveProcessors
Definition: krnlinit.c:23
Definition: compat.h:428
#define _In_
Definition: no_sal2.h:204
FORCEINLINE VOID KeArmInvalidateAllCaches(VOID)
Definition: intrin_i.h:195
ULONG KeDcacheFlushCount
Definition: cpu.c:20
VOID NTAPI KeSetDmaIoCoherency(IN ULONG Coherency)
Definition: cpu.c:496
ULONG_PTR KAFFINITY
Definition: compat.h:75
VOID FASTCALL KeZeroPages(IN PVOID Address, IN ULONG Size)
Definition: cpu.c:56
#define OUT
Definition: typedefs.h:39
unsigned int ULONG
Definition: retypes.h:1
ULONG KeLargestCacheLine
Definition: cpu.c:32
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
VOID NTAPI KeFlushIoBuffers(_In_ PMDL Mdl, _In_ BOOLEAN ReadOperation, _In_ BOOLEAN DmaOperation)
Definition: cpu.c:191
NTSTATUS NTAPI NtVdmControl(IN ULONG ControlCode, IN PVOID ControlData)
Definition: cpu.c:206
FORCEINLINE VOID KeArmFlushTlb(VOID)
Definition: intrin_i.h:175
KIRQL NTAPI KeRaiseIrqlToSynchLevel(VOID)
Definition: pic.c:156