Set processor features in the shared user page.
authorEric Kohl <eric.kohl@reactos.org>
Sun, 24 Oct 2004 12:00:01 +0000 (12:00 +0000)
committerEric Kohl <eric.kohl@reactos.org>
Sun, 24 Oct 2004 12:00:01 +0000 (12:00 +0000)
This fixes bug #387.

svn path=/trunk/; revision=11410

reactos/include/napi/shared_data.h
reactos/ntoskrnl/include/internal/i386/ke.h
reactos/ntoskrnl/ke/i386/kernel.c
reactos/ntoskrnl/ke/main.c

index e5e471e..7a61b62 100644 (file)
@@ -1,7 +1,19 @@
 #ifndef __INCLUDE_NAPI_SHARED_DATA_H
 #define __INCLUDE_NAPI_SHARED_DATA_H
 
-#define PROCESSOR_FEATURES_MAX 64
+#define PF_FLOATING_POINT_PRECISION_ERRATA  0
+#define PF_FLOATING_POINT_EMULATED          1
+#define PF_COMPARE_EXCHANGE_DOUBLE          2
+#define PF_MMX_INSTRUCTIONS_AVAILABLE       3
+#define PF_PPC_MOVEMEM_64BIT_OK             4
+#define PF_ALPHA_BYTE_INSTRUCTIONS          5
+#define PF_XMMI_INSTRUCTIONS_AVAILABLE      6
+#define PF_3DNOW_INSTRUCTIONS_AVAILABLE     7
+#define PF_RDTSC_INSTRUCTION_AVAILABLE      8
+#define PF_PAE_ENABLED                      9
+#define PF_XMMI64_INSTRUCTIONS_AVAILABLE   10
+
+#define PROCESSOR_FEATURES_MAX             64
 
 typedef enum _ALTERNATIVE_ARCHITECTURE_TYPE
 {
index 499450c..c01785a 100644 (file)
 #define KTRAP_FRAME_RESERVED9      (0x8A)
 #define KTRAP_FRAME_SIZE           (0x8C)
 
-#define X86_EFLAGS_VM      0x00020000 /* Virtual Mode */
-#define X86_EFLAGS_ID      0x00200000 /* CPUID detection flag */
+#define X86_EFLAGS_VM           0x00020000 /* Virtual Mode */
+#define X86_EFLAGS_ID           0x00200000 /* CPUID detection flag */
 
-#define X86_CR4_PAE        0x00000020 /* enable physical address extensions */
-#define X86_CR4_PGE        0x00000080 /* enable global pages */
+#define X86_CR4_PAE             0x00000020 /* enable physical address extensions */
+#define X86_CR4_PGE             0x00000080 /* enable global pages */
 
-#define X86_FEATURE_PAE            0x00000040 /* physical address extension is present */      
-#define X86_FEATURE_PGE            0x00002000 /* Page Global Enable */
+#define X86_FEATURE_TSC         0x00000010 /* time stamp counters are present */
+#define X86_FEATURE_PAE         0x00000040 /* physical address extension is present */
+#define X86_FEATURE_CX8         0x00000100 /* CMPXCHG8B instruction present */
+#define X86_FEATURE_PGE         0x00002000 /* Page Global Enable */
+#define X86_FEATURE_MMX         0x00800000 /* MMX extension present */
+#define X86_FEATURE_SSE         0x02000000 /* SSE extension present */
+#define X86_FEATURE_SSE2        0x04000000 /* SSE2 extension present */
+
+#define X86_EXT_FEATURE_3DNOW   0x40000000 /* 3DNOW! extension present */
 
 #ifndef __ASM__
 
@@ -160,6 +167,8 @@ VOID
 KiGdtPrepareForApplicationProcessorInit(ULONG Id);
 VOID
 Ki386InitializeLdt(VOID);
+VOID
+Ki386SetProcessorFeatures(VOID);
 ULONG KeAllocateGdtSelector(ULONG Desc[2]);
 VOID KeFreeGdtSelector(ULONG Entry);
 VOID
index 1d787b6..0360b3d 100644 (file)
@@ -45,6 +45,7 @@ ULONG Ke386L1CacheSize;
 ULONG Ke386L2CacheSize;
 BOOLEAN Ke386NoExecute = FALSE;
 BOOLEAN Ke386Pae = FALSE;
+BOOLEAN Ke386PaeEnabled = FALSE;
 
 /* FUNCTIONS *****************************************************************/
 
@@ -299,6 +300,7 @@ KeInit1(PCHAR CommandLine, PULONG LastKernelAddress)
    if ((Pae && (Ke386CpuidFlags & X86_FEATURE_PAE)) || NoExecute)
    {
       MiEnablePAE((PVOID*)LastKernelAddress);
+      Ke386PaeEnabled = TRUE;
    }
 }
 
@@ -319,7 +321,7 @@ KeInit2(VOID)
          if (Ke386NoExecute)
          {
             DPRINT1("NoExecute is enabled\n");
-        }
+         }
       }
       else
       {
@@ -345,3 +347,25 @@ KeInit2(VOID)
       DPRINT1("Ke386L2CacheSize: %dkB\n", Ke386L2CacheSize);
    }
 }
+
+VOID INIT_FUNCTION
+Ki386SetProcessorFeatures(VOID)
+{
+  SharedUserData->ProcessorFeatures[PF_FLOATING_POINT_PRECISION_ERRATA] = FALSE;
+  SharedUserData->ProcessorFeatures[PF_FLOATING_POINT_EMULATED] = FALSE;
+  SharedUserData->ProcessorFeatures[PF_COMPARE_EXCHANGE_DOUBLE] =
+    (Ke386CpuidFlags & X86_FEATURE_CX8);
+  SharedUserData->ProcessorFeatures[PF_MMX_INSTRUCTIONS_AVAILABLE] =
+    (Ke386CpuidFlags & X86_FEATURE_MMX);
+  SharedUserData->ProcessorFeatures[PF_PPC_MOVEMEM_64BIT_OK] = FALSE;
+  SharedUserData->ProcessorFeatures[PF_ALPHA_BYTE_INSTRUCTIONS] = FALSE;
+  SharedUserData->ProcessorFeatures[PF_XMMI_INSTRUCTIONS_AVAILABLE] = 
+    (Ke386CpuidFlags & X86_FEATURE_SSE);
+  SharedUserData->ProcessorFeatures[PF_3DNOW_INSTRUCTIONS_AVAILABLE] =
+    (Ke386CpuidExFlags & X86_EXT_FEATURE_3DNOW);
+  SharedUserData->ProcessorFeatures[PF_RDTSC_INSTRUCTION_AVAILABLE] =
+    (Ke386CpuidFlags & X86_FEATURE_TSC);
+  SharedUserData->ProcessorFeatures[PF_PAE_ENABLED] = Ke386PaeEnabled;
+  SharedUserData->ProcessorFeatures[PF_XMMI64_INSTRUCTIONS_AVAILABLE] =
+    (Ke386CpuidFlags & X86_FEATURE_SSE2);
+}
index 1957e34..b764509 100644 (file)
@@ -16,7 +16,7 @@
  *  along with this program; if not, write to the Free Software
  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
-/* $Id: main.c,v 1.200 2004/10/22 20:30:47 ekohl Exp $
+/* $Id: main.c,v 1.201 2004/10/24 12:00:01 ekohl Exp $
  *
  * PROJECT:         ReactOS kernel
  * FILE:            ntoskrnl/ke/main.c
@@ -112,7 +112,12 @@ InitSystemSharedUserPage (PCSZ ParameterLine)
     *   There is NO need to do this again.
     */
 
+   Ki386SetProcessorFeatures();
+
    SharedUserData->NtProductType = NtProductWinNt;
+   SharedUserData->ProductTypeIsValid = TRUE;
+   SharedUserData->NtMajorVersion = 5;
+   SharedUserData->NtMinorVersion = 0;
 
    BootDriveFound = FALSE;