--- trunk/reactos/lib/rtl/i386/mem_asm.S 2005-11-30 00:17:14 UTC (rev 19763)
+++ trunk/reactos/lib/rtl/i386/mem_asm.S 2005-11-30 00:25:48 UTC (rev 19764)
@@ -151,13 +151,12 @@
@RtlPrefetchMemoryNonTemporal@8:
ret /* Overwritten by ntoskrnl/ke/i386/kernel.c if SSE is supported (see Ki386SetProcessorFeatures() ) */
- mov eax, [_Ke386CacheGranularity] // Get cache line size
+ mov eax, [_Ke386CacheAlignment] // Get cache line size
// This is fastcall, so ecx = address, edx = size
- fetch_next_line:
+fetch_next_line:
prefetchnta byte ptr [ecx] // prefechnta(address)
- sub edx, eax // count = count - cache_line_size
add ecx, eax // address = address + cache_line_size
- cmp edx, 0 // if(count) > 0
+ sub edx, eax // count = count - cache_line_size
ja fetch_next_line // goto fetch_next_line
ret
--- trunk/reactos/ntoskrnl/ke/i386/kernel.c 2005-11-30 00:17:14 UTC (rev 19763)
+++ trunk/reactos/ntoskrnl/ke/i386/kernel.c 2005-11-30 00:25:48 UTC (rev 19764)
@@ -22,7 +22,6 @@
ULONG Ke386CacheAlignment;
CHAR Ke386CpuidModel[49] = {0,};
ULONG Ke386L1CacheSize;
-ULONG Ke386CacheGranularity = 0x40; /* FIXME: Default to 64 bytes for RtlPrefetchMemoryNonTemporal(), need real size */
BOOLEAN Ke386NoExecute = FALSE;
BOOLEAN Ke386Pae = FALSE;
BOOLEAN Ke386GlobalPagesEnabled = FALSE;
@@ -418,6 +417,18 @@
/* Target EIP. */
Ke386Wrmsr(0x176, (ULONG_PTR)KiFastCallEntry, 0);
}
+
+ /* Does the CPU Support 'prefetchnta' (SSE) */
+ if(KPCR->PrcbData.FeatureBits & X86_FEATURE_SSE)
+ {
+ ULONG Protect;
+
+ Protect = MmGetPageProtect(NULL, (PVOID)RtlPrefetchMemoryNonTemporal);
+ MmSetPageProtect(NULL, (PVOID)RtlPrefetchMemoryNonTemporal, Protect | PAGE_IS_WRITABLE);
+ /* Replace the ret by a nop */
+ *(PCHAR)RtlPrefetchMemoryNonTemporal = 0x90;
+ MmSetPageProtect(NULL, (PVOID)RtlPrefetchMemoryNonTemporal, Protect);
+ }
}
VOID
@@ -523,13 +534,6 @@
SharedUserData->ProcessorFeatures[PF_XMMI64_INSTRUCTIONS_AVAILABLE] =
(Pcr->PrcbData.FeatureBits & X86_FEATURE_SSE2);
- /* Does the CPU Support 'prefetchnta' (SSE) */
- if(Pcr->PrcbData.FeatureBits & X86_FEATURE_SSE)
- {
- /* Replace the ret by a nop */
- /* FIXME - *(PCHAR)RtlPrefetchMemoryNonTemporal = 0x90; */
- }
-
/* Does the CPU Support Fast System Call? */
if (Pcr->PrcbData.FeatureBits & X86_FEATURE_SYSCALL) {