Author: tkreuzer
Date: Wed Dec 3 11:24:40 2008
New Revision: 37822
URL:
http://svn.reactos.org/svn/reactos?rev=37822&view=rev
Log:
- Implement iInitializeCouFeatures, replacing KiSetCR0Bits. This allows us to save /
restore xmm registers
- check supported cpu features
Modified:
branches/ros-amd64-bringup/reactos/ntoskrnl/include/internal/amd64/ke.h
branches/ros-amd64-bringup/reactos/ntoskrnl/ke/amd64/cpu.c
branches/ros-amd64-bringup/reactos/ntoskrnl/ke/amd64/kiinit.c
Modified: branches/ros-amd64-bringup/reactos/ntoskrnl/include/internal/amd64/ke.h
URL:
http://svn.reactos.org/svn/reactos/branches/ros-amd64-bringup/reactos/ntosk…
==============================================================================
--- branches/ros-amd64-bringup/reactos/ntoskrnl/include/internal/amd64/ke.h [iso-8859-1]
(original)
+++ branches/ros-amd64-bringup/reactos/ntoskrnl/include/internal/amd64/ke.h [iso-8859-1]
Wed Dec 3 11:24:40 2008
@@ -120,10 +120,6 @@
VOID
NTAPI
-KiSetCR0Bits(VOID);
-
-VOID
-NTAPI
KiGetCacheInformation(VOID);
BOOLEAN
@@ -145,6 +141,10 @@
ULONG
NTAPI
KiGetFeatureBits(VOID);
+
+VOID
+NTAPI
+KiInitializeCpuFeatures();
ULONG KeAllocateGdtSelector(ULONG Desc[2]);
VOID KeFreeGdtSelector(ULONG Entry);
Modified: branches/ros-amd64-bringup/reactos/ntoskrnl/ke/amd64/cpu.c
URL:
http://svn.reactos.org/svn/reactos/branches/ros-amd64-bringup/reactos/ntosk…
==============================================================================
--- branches/ros-amd64-bringup/reactos/ntoskrnl/ke/amd64/cpu.c [iso-8859-1] (original)
+++ branches/ros-amd64-bringup/reactos/ntoskrnl/ke/amd64/cpu.c [iso-8859-1] Wed Dec 3
11:24:40 2008
@@ -240,6 +240,21 @@
VOID
NTAPI
+KiInitializeCpuFeatures()
+{
+ /* Enable Write-Protection */
+ __writecr0(__readcr0() | CR0_WP);
+
+ /* Disable fpu monitoring */
+ __writecr0(__readcr0() & ~CR0_MP);
+
+ /* Enable fx save restore support */
+ __writecr4(__readcr4() | CR4_FXSR);
+
+}
+
+VOID
+NTAPI
KiGetCacheInformation(VOID)
{
PKIPCR Pcr = (PKIPCR)KeGetPcr();
@@ -348,23 +363,6 @@
VOID
-NTAPI
-KiSetCR0Bits(VOID)
-{
- ULONG64 Cr0;
-
- /* Save current CR0 */
- Cr0 = __readcr0();
-
- /* If this is a 486, enable Write-Protection */
- if (KeGetCurrentPrcb()->CpuType > 3) Cr0 |= CR0_WP;
-
- /* Set new Cr0 */
- __writecr0(Cr0);
-}
-
-
-VOID
FASTCALL
Ki386InitializeTss(IN PKTSS64 Tss,
IN PKIDTENTRY Idt,
Modified: branches/ros-amd64-bringup/reactos/ntoskrnl/ke/amd64/kiinit.c
URL:
http://svn.reactos.org/svn/reactos/branches/ros-amd64-bringup/reactos/ntosk…
==============================================================================
--- branches/ros-amd64-bringup/reactos/ntoskrnl/ke/amd64/kiinit.c [iso-8859-1] (original)
+++ branches/ros-amd64-bringup/reactos/ntoskrnl/ke/amd64/kiinit.c [iso-8859-1] Wed Dec 3
11:24:40 2008
@@ -4,6 +4,7 @@
* FILE: ntoskrnl/ke/i386/kiinit.c
* PURPOSE: Kernel Initialization for x86 CPUs
* PROGRAMMERS: Alex Ionescu (alex.ionescu(a)reactos.org)
+ * Timo Kreuzer (timo.kreuzer(a)reactos.org)
*/
/* INCLUDES *****************************************************************/
@@ -11,6 +12,9 @@
#include <ntoskrnl.h>
#define NDEBUG
#include <debug.h>
+
+#define REQUIRED_FEATURE_BITS (KF_RDTSC|KF_CR4|KF_CMPXCHG8B|KF_XMMI|KF_XMMI64| \
+ KF_NX_BIT)
/* GLOBALS *******************************************************************/
@@ -393,7 +397,6 @@
IN CCHAR Number,
IN PLOADER_PARAMETER_BLOCK LoaderBlock)
{
- BOOLEAN NpxPresent;
ULONG FeatureBits;
ULONG PageDirectory[2];
PVOID DpcStack;
@@ -401,14 +404,20 @@
/* Detect and set the CPU Type */
KiSetProcessorType();
- /* Set CR0 features based on detected CPU */
- KiSetCR0Bits();
-
/* Initialize the Power Management Support for this PRCB */
// PoInitializePrcb(Prcb);
/* Get the processor features for the CPU */
FeatureBits = KiGetFeatureBits();
+
+ /* Check if we support all needed features */
+ if ((FeatureBits & REQUIRED_FEATURE_BITS) != REQUIRED_FEATURE_BITS)
+ {
+ /* If not, bugcheck system */
+ DPRINT1("CPU doesn't have needed features! Has: 0x%x, required:
0x%x\n",
+ FeatureBits, REQUIRED_FEATURE_BITS);
+ KeBugCheck(0);
+ }
/* Set the default NX policy (opt-in) */
SharedUserData->NXSupportPolicy = NX_SUPPORT_POLICY_OPTIN;
@@ -442,6 +451,9 @@
/* Save feature bits */
Prcb->FeatureBits = FeatureBits;
+
+ /* Initialize the CPU features */
+ KiInitializeCpuFeatures();
/* Save CPU state */
KiSaveProcessorControlState(&Prcb->ProcessorState);
@@ -461,7 +473,7 @@
KeNodeBlock[0]->ProcessorMask = Prcb->SetMember;
/* Set boot-level flags */
- KeI386NpxPresent = NpxPresent;
+ KeI386NpxPresent = TRUE;
KeI386CpuType = Prcb->CpuType;
KeI386CpuStep = Prcb->CpuStep;
KeProcessorArchitecture = PROCESSOR_ARCHITECTURE_INTEL;
@@ -758,9 +770,12 @@
/* Check for break-in */
// if (KdPollBreakIn()) DbgBreakPointWithStatus(1);
}
+DPRINT1("after KdInitSystem\n");
/* Raise to HIGH_LEVEL */
KfRaiseIrql(HIGH_LEVEL);
+
+FrLdrDbgPrint("before KiSetupStackAndInitializeKernel\n");
/* Switch to new kernel stack and start kernel bootstrapping */
KiSetupStackAndInitializeKernel(&KiInitialProcess.Pcb,