mirror of
https://github.com/reactos/reactos.git
synced 2025-06-09 20:11:14 +00:00
[BOOTLIB]: Don't use __getcallerseflags() in Archx86IsCpuidSupported -- __readeflags should be good enough.
svn path=/trunk/; revision=73732
This commit is contained in:
parent
61c4b92f67
commit
1566f90e46
3 changed files with 105 additions and 88 deletions
|
@ -1562,6 +1562,11 @@ BlTimeQueryPerformanceCounter (
|
||||||
_Out_opt_ PLARGE_INTEGER Frequency
|
_Out_opt_ PLARGE_INTEGER Frequency
|
||||||
);
|
);
|
||||||
|
|
||||||
|
ULONGLONG
|
||||||
|
BlArchGetPerformanceCounter (
|
||||||
|
VOID
|
||||||
|
);
|
||||||
|
|
||||||
/* RESOURCE LOCALE INTERNATIONALIZATION ROUTINES *****************************/
|
/* RESOURCE LOCALE INTERNATIONALIZATION ROUTINES *****************************/
|
||||||
|
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
|
@ -1655,6 +1660,18 @@ BlStatusError (
|
||||||
|
|
||||||
/* UTILITY ROUTINES **********************************************************/
|
/* UTILITY ROUTINES **********************************************************/
|
||||||
|
|
||||||
|
VOID
|
||||||
|
BlArchCpuId (
|
||||||
|
_In_ ULONG Function,
|
||||||
|
_In_ ULONG SubFunction,
|
||||||
|
_Out_ INT* Result
|
||||||
|
);
|
||||||
|
|
||||||
|
BOOLEAN
|
||||||
|
BlArchIsCpuIdFunctionSupported (
|
||||||
|
_In_ ULONG Function
|
||||||
|
);
|
||||||
|
|
||||||
VOID
|
VOID
|
||||||
BlUtlUpdateProgress (
|
BlUtlUpdateProgress (
|
||||||
_In_ ULONG Percentage,
|
_In_ ULONG Percentage,
|
||||||
|
|
|
@ -776,3 +776,91 @@ BlUtlCheckSum (
|
||||||
|
|
||||||
return PartialSum;
|
return PartialSum;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BOOLEAN
|
||||||
|
Archx86IsCpuidSupported (
|
||||||
|
VOID
|
||||||
|
)
|
||||||
|
{
|
||||||
|
ULONG CallerFlags, Flags;
|
||||||
|
|
||||||
|
/* Read the original flags, and add the CPUID bit */
|
||||||
|
CallerFlags = __readeflags() ^ 0x200000;
|
||||||
|
__writeeflags(CallerFlags);
|
||||||
|
|
||||||
|
/* Read our flags now */
|
||||||
|
Flags = __readeflags();
|
||||||
|
|
||||||
|
/* Check if the bit stuck */
|
||||||
|
return (((CallerFlags ^ Flags) >> 21) & 1) ^ 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOLEAN
|
||||||
|
BlArchIsCpuIdFunctionSupported (
|
||||||
|
_In_ ULONG Function
|
||||||
|
)
|
||||||
|
{
|
||||||
|
BOOLEAN Supported;
|
||||||
|
INT CpuInfo[4];
|
||||||
|
|
||||||
|
/* Check if the CPU supports this instruction */
|
||||||
|
Supported = Archx86IsCpuidSupported();
|
||||||
|
if (!Supported)
|
||||||
|
{
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Check if it's the extended function */
|
||||||
|
if (Function >= 0x80000000)
|
||||||
|
{
|
||||||
|
/* Check if extended functions are supported */
|
||||||
|
__cpuid(CpuInfo, 0x80000000);
|
||||||
|
if ((CpuInfo[0] & 0xFFFFFF00) != 0x80000000)
|
||||||
|
{
|
||||||
|
/* Nope */
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* It's a regular function, get the maximum one supported */
|
||||||
|
__cpuid(CpuInfo, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Check if our function is within bounds */
|
||||||
|
if (Function <= CpuInfo[0])
|
||||||
|
{
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Nope */
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
ULONGLONG
|
||||||
|
BlArchGetPerformanceCounter (
|
||||||
|
VOID
|
||||||
|
)
|
||||||
|
{
|
||||||
|
INT CpuInfo[4];
|
||||||
|
|
||||||
|
/* Serialize with CPUID, if it exists */
|
||||||
|
if (Archx86IsCpuidSupported())
|
||||||
|
{
|
||||||
|
BlArchCpuId(0, 0, CpuInfo);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Read the TSC */
|
||||||
|
return __rdtsc();
|
||||||
|
}
|
||||||
|
|
||||||
|
VOID
|
||||||
|
BlArchCpuId (
|
||||||
|
_In_ ULONG Function,
|
||||||
|
_In_ ULONG SubFunction,
|
||||||
|
_Out_ INT* Result
|
||||||
|
)
|
||||||
|
{
|
||||||
|
/* Use the intrinsic */
|
||||||
|
__cpuidex(Result, Function, SubFunction);
|
||||||
|
}
|
||||||
|
|
|
@ -227,94 +227,6 @@ MmArchTranslateVirtualAddress (
|
||||||
return Descriptor != NULL;
|
return Descriptor != NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOLEAN
|
|
||||||
Archx86IsCpuidSupported (
|
|
||||||
VOID
|
|
||||||
)
|
|
||||||
{
|
|
||||||
ULONG CallerFlags, Flags;
|
|
||||||
|
|
||||||
/* Read the original flags, and add the CPUID bit */
|
|
||||||
CallerFlags = __getcallerseflags() ^ 0x200000;
|
|
||||||
__writeeflags(CallerFlags);
|
|
||||||
|
|
||||||
/* Read our flags now */
|
|
||||||
Flags = __readeflags();
|
|
||||||
|
|
||||||
/* Check if the bit stuck */
|
|
||||||
return (((CallerFlags ^ Flags) >> 21) & 1) ^ 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
BOOLEAN
|
|
||||||
BlArchIsCpuIdFunctionSupported (
|
|
||||||
_In_ ULONG Function
|
|
||||||
)
|
|
||||||
{
|
|
||||||
BOOLEAN Supported;
|
|
||||||
INT CpuInfo[4];
|
|
||||||
|
|
||||||
/* Check if the CPU supports this instruction */
|
|
||||||
Supported = Archx86IsCpuidSupported();
|
|
||||||
if (!Supported)
|
|
||||||
{
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Check if it's the extended function */
|
|
||||||
if (Function >= 0x80000000)
|
|
||||||
{
|
|
||||||
/* Check if extended functions are supported */
|
|
||||||
__cpuid(CpuInfo, 0x80000000);
|
|
||||||
if ((CpuInfo[0] & 0xFFFFFF00) != 0x80000000)
|
|
||||||
{
|
|
||||||
/* Nope */
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
/* It's a regular function, get the maximum one supported */
|
|
||||||
__cpuid(CpuInfo, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Check if our function is within bounds */
|
|
||||||
if (Function <= CpuInfo[0])
|
|
||||||
{
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Nope */
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
VOID
|
|
||||||
BlArchCpuId (
|
|
||||||
_In_ ULONG Function,
|
|
||||||
_In_ ULONG SubFunction,
|
|
||||||
_Out_ INT* Result
|
|
||||||
)
|
|
||||||
{
|
|
||||||
/* Use the intrinsic */
|
|
||||||
__cpuidex(Result, Function, SubFunction);
|
|
||||||
}
|
|
||||||
|
|
||||||
ULONGLONG
|
|
||||||
BlArchGetPerformanceCounter (
|
|
||||||
VOID
|
|
||||||
)
|
|
||||||
{
|
|
||||||
INT CpuInfo[4];
|
|
||||||
|
|
||||||
/* Serialize with CPUID, if it exists */
|
|
||||||
if (Archx86IsCpuidSupported())
|
|
||||||
{
|
|
||||||
BlArchCpuId(0, 0, CpuInfo);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Read the TSC */
|
|
||||||
return __rdtsc();
|
|
||||||
}
|
|
||||||
|
|
||||||
VOID
|
VOID
|
||||||
MmDefpDestroySelfMap (
|
MmDefpDestroySelfMap (
|
||||||
VOID
|
VOID
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue