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 17 ULONG KeFixedTbEntries; 18 ULONG KiDmaIoCoherency; 19 ULONG KeIcacheFlushCount = 0; 20 ULONG KeDcacheFlushCount; 21 ULONG KeLargestCacheLine = 64; // FIXME: It depends 22 23 /* FUNCTIONS ******************************************************************/ 24 25 VOID 26 KiFlushSingleTb(IN BOOLEAN Invalid, 27 IN PVOID Virtual) 28 { 29 // 30 // Just invalidate it 31 // 32 KeArmInvalidateTlbEntry(Virtual); 33 } 34 35 VOID 36 KeFlushTb(VOID) 37 { 38 // 39 // Flush the entire TLB 40 // 41 KeArmFlushTlb(); 42 } 43 44 VOID 45 NTAPI 46 KeFlushCurrentTb(VOID) 47 { 48 // 49 // Rename? 50 // 51 KeFlushTb(); 52 } 53 54 VOID 55 FASTCALL 56 KeZeroPages(IN PVOID Address, 57 IN ULONG Size) 58 { 59 /* Not using XMMI in this routine */ 60 RtlZeroMemory(Address, Size); 61 } 62 63 VOID 64 NTAPI 65 KiSaveProcessorControlState(OUT PKPROCESSOR_STATE ProcessorState) 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 81 KiRestoreProcessorControlState(PKPROCESSOR_STATE ProcessorState) 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 94 KeInvalidateAllCaches(VOID) 95 { 96 // 97 // Invalidate D cache and I cache 98 // 99 KeArmInvalidateAllCaches(); 100 return TRUE; 101 } 102 103 104 /* PUBLIC FUNCTIONS ***********************************************************/ 105 106 /* 107 * @implemented 108 */ 109 ULONG 110 NTAPI 111 KeGetRecommendedSharedDataAlignment(VOID) 112 { 113 /* Return the global variable */ 114 return KeLargestCacheLine; 115 } 116 117 /* 118 * @implemented 119 */ 120 VOID 121 NTAPI 122 KeFlushEntireTb(IN BOOLEAN Invalid, 123 IN BOOLEAN AllProcessors) 124 { 125 KIRQL OldIrql; 126 127 // 128 // Raise the IRQL for the TB Flush 129 // 130 OldIrql = KeRaiseIrqlToSynchLevel(); 131 132 // 133 // Flush the TB for the Current CPU 134 // 135 KeFlushCurrentTb(); 136 137 // 138 // Return to Original IRQL 139 // 140 KeLowerIrql(OldIrql); 141 } 142 143 /* 144 * @implemented 145 */ 146 VOID 147 NTAPI 148 KeSetDmaIoCoherency(IN ULONG Coherency) 149 { 150 // 151 // Save the coherency globally 152 // 153 KiDmaIoCoherency = Coherency; 154 } 155 156 /* 157 * @implemented 158 */ 159 KAFFINITY 160 NTAPI 161 KeQueryActiveProcessors(VOID) 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 176 KeSaveStateForHibernate(IN PKPROCESSOR_STATE State) 177 { 178 // 179 // Capture the context 180 // 181 RtlCaptureContext(&State->ContextFrame); 182 183 // 184 // Capture the control state 185 // 186 KiSaveProcessorControlState(State); 187 } 188 189 VOID 190 NTAPI 191 KeFlushIoBuffers( 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 206 NtVdmControl(IN ULONG ControlCode, 207 IN PVOID ControlData) 208 { 209 // 210 // Does not exist on ARM 211 // 212 return STATUS_NOT_IMPLEMENTED; 213 } 214 215 NTSTATUS 216 NTAPI 217 NtSetLdtEntries(IN ULONG Selector1, 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 } 227