- Implement RtlPrefectMemoryNonTemporal. Patch by Patrick Baggett <baggett.patrick@gmail.com> and myself.

svn path=/trunk/; revision=19742
This commit is contained in:
Alex Ionescu 2005-11-29 02:40:18 +00:00
parent 3b62e7d538
commit 9ff294c54e
3 changed files with 34 additions and 7 deletions

View file

@ -1,11 +1,11 @@
/* /*
* COPYRIGHT: See COPYING in the top level directory * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
* FILE: mem.asm * FILE: mem_asm.S
* PURPOSE: Memory functions * PURPOSE: Memory functions
* PROGRAMMER: Magnus Olsen (magnusolsen@greatlord.com) * PROGRAMMERS: Patrick Baggett (baggett.patrick@gmail.com)
* UPDATE HISTORY: * Alex Ionescu (alex@relsoft.net)
* Created 27/07/2005 * Magnus Olsen (magnusolsen@greatlord.com)
*/ */
.intel_syntax noprefix .intel_syntax noprefix
@ -17,6 +17,7 @@
.globl _RtlFillMemory@12 // [4] (no bug) .globl _RtlFillMemory@12 // [4] (no bug)
.globl _RtlCompareMemoryUlong@12 // [5] (no bug) .globl _RtlCompareMemoryUlong@12 // [5] (no bug)
.globl _RtlCompareMemory@12 // [4] (no bug) .globl _RtlCompareMemory@12 // [4] (no bug)
.globl @RtlPrefetchMemoryNonTemporal@8
/* FUNCTIONS ***************************************************************/ /* FUNCTIONS ***************************************************************/
@ -145,3 +146,18 @@ _RtlCompareMemory@12:
pop edi pop edi
3: 3:
ret 12 // return count ret 12 // return count
@RtlPrefetchMemoryNonTemporal@8:
ret /* Overwritten by ntoskrnl/ke/i386/kernel.c if SSE is supported (see Ki386SetProcessorFeatures() ) */
mov eax, [_Ke386CacheGranularity] // Get cache line size
// This is fastcall, so ecx = address, edx = size
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
ja fetch_next_line // goto fetch_next_line
ret

View file

@ -140,7 +140,7 @@ RtlMoveMemory (
} }
/* /*
* @unimplemented * @implemented
*/ */
VOID VOID
FASTCALL FASTCALL
@ -149,7 +149,9 @@ RtlPrefetchMemoryNonTemporal(
IN SIZE_T Length IN SIZE_T Length
) )
{ {
UNIMPLEMENTED; /* By nature of prefetch, this is non-portable. */
(void)Source;
(void)Length;
} }

View file

@ -22,6 +22,7 @@ static ULONG Ke386CpuidFlags2, Ke386CpuidExFlags, Ke386CpuidExMisc;
ULONG Ke386CacheAlignment; ULONG Ke386CacheAlignment;
CHAR Ke386CpuidModel[49] = {0,}; CHAR Ke386CpuidModel[49] = {0,};
ULONG Ke386L1CacheSize; ULONG Ke386L1CacheSize;
ULONG Ke386CacheGranularity = 0x40; /* FIXME: Default to 64 bytes for RtlPrefetchMemoryNonTemporal(), need real size */
BOOLEAN Ke386NoExecute = FALSE; BOOLEAN Ke386NoExecute = FALSE;
BOOLEAN Ke386Pae = FALSE; BOOLEAN Ke386Pae = FALSE;
BOOLEAN Ke386GlobalPagesEnabled = FALSE; BOOLEAN Ke386GlobalPagesEnabled = FALSE;
@ -476,6 +477,7 @@ KeInit2(VOID)
DPRINT("Ke386CacheAlignment: %d\n", Ke386CacheAlignment); DPRINT("Ke386CacheAlignment: %d\n", Ke386CacheAlignment);
if (Ke386L1CacheSize) if (Ke386L1CacheSize)
{ {
DPRINT("Ke386L1CacheSize: %dkB\n", Ke386L1CacheSize); DPRINT("Ke386L1CacheSize: %dkB\n", Ke386L1CacheSize);
} }
if (Pcr->L2CacheSize) if (Pcr->L2CacheSize)
@ -497,7 +499,7 @@ Ki386SetProcessorFeatures(VOID)
KEY_VALUE_PARTIAL_INFORMATION ValueData; KEY_VALUE_PARTIAL_INFORMATION ValueData;
NTSTATUS Status; NTSTATUS Status;
ULONG FastSystemCallDisable = 0; ULONG FastSystemCallDisable = 0;
SharedUserData->ProcessorFeatures[PF_FLOATING_POINT_PRECISION_ERRATA] = FALSE; SharedUserData->ProcessorFeatures[PF_FLOATING_POINT_PRECISION_ERRATA] = FALSE;
SharedUserData->ProcessorFeatures[PF_FLOATING_POINT_EMULATED] = FALSE; SharedUserData->ProcessorFeatures[PF_FLOATING_POINT_EMULATED] = FALSE;
SharedUserData->ProcessorFeatures[PF_COMPARE_EXCHANGE_DOUBLE] = SharedUserData->ProcessorFeatures[PF_COMPARE_EXCHANGE_DOUBLE] =
@ -516,6 +518,13 @@ Ki386SetProcessorFeatures(VOID)
SharedUserData->ProcessorFeatures[PF_XMMI64_INSTRUCTIONS_AVAILABLE] = SharedUserData->ProcessorFeatures[PF_XMMI64_INSTRUCTIONS_AVAILABLE] =
(Pcr->PrcbData.FeatureBits & X86_FEATURE_SSE2); (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 */
*(PCHAR)RtlPrefetchMemoryNonTemporal = 0x90;
}
/* Does the CPU Support Fast System Call? */ /* Does the CPU Support Fast System Call? */
if (Pcr->PrcbData.FeatureBits & X86_FEATURE_SYSCALL) { if (Pcr->PrcbData.FeatureBits & X86_FEATURE_SYSCALL) {