]> git.proxmox.com Git - mirror_edk2.git/blobdiff - Nt32Pkg/CpuRuntimeDxe/Cpu.c
Fix issue that calling GetS3MemoryInfo() with wrong order.
[mirror_edk2.git] / Nt32Pkg / CpuRuntimeDxe / Cpu.c
index c2646e88082693068c3030719adbc8a78c8e0f64..9e7dfbb29fbaabd3d06689676daf8815608e6ac7 100644 (file)
@@ -1,6 +1,6 @@
 /**@file\r
 \r
-Copyright (c) 2006 - 2009, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2006 - 2013, Intel Corporation. All rights reserved.<BR>\r
 This program and the accompanying materials\r
 are licensed and made available under the terms and conditions of the BSD License\r
 which accompanies this distribution.  The full text of the license may be found at\r
@@ -25,6 +25,7 @@ Abstract:
 \r
 #include "CpuDriver.h"\r
 \r
+UINT64  mTimerPeriod;\r
 \r
 CPU_ARCH_PROTOCOL_PRIVATE mCpuTemplate = {\r
   CPU_ARCH_PROT_PRIVATE_SIGNATURE,\r
@@ -38,7 +39,7 @@ CPU_ARCH_PROTOCOL_PRIVATE mCpuTemplate = {
     WinNtRegisterInterruptHandler,\r
     WinNtGetTimerValue,\r
     WinNtSetMemoryAttributes,\r
-    0,\r
+    1,\r
     4\r
   },\r
   {\r
@@ -321,11 +322,18 @@ Returns:
   if (TimerValue == NULL) {\r
     return EFI_INVALID_PARAMETER;\r
   }\r
-\r
-  //\r
-  // No timer supported\r
-  //\r
-  return EFI_UNSUPPORTED;\r
+  \r
+  if (TimerIndex != 0) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+  \r
+  gWinNt->QueryPerformanceCounter ((LARGE_INTEGER *)TimerValue);\r
+  \r
+  if (TimerPeriod != NULL) {\r
+    *TimerPeriod = mTimerPeriod;\r
+  }\r
+  \r
+  return EFI_SUCCESS;\r
 }\r
 \r
 \r
@@ -394,7 +402,7 @@ LogSmbiosData (
   EFI_STATUS         Status;\r
   EFI_SMBIOS_HANDLE  SmbiosHandle;\r
   \r
-  SmbiosHandle = 0;\r
+  SmbiosHandle = SMBIOS_HANDLE_PI_RESERVED;\r
   Status = Smbios->Add (\r
                      Smbios,\r
                      NULL,\r
@@ -459,7 +467,7 @@ Returns:
   ASSERT (CpuVerStrLen <= SMBIOS_STRING_MAX_LENGTH);\r
 \r
 \r
-  TotalSize = sizeof(SMBIOS_TABLE_TYPE4) + CpuVerStrLen + 1 + 1;\r
+  TotalSize = (UINT32)(sizeof(SMBIOS_TABLE_TYPE4) + CpuVerStrLen + 1 + 1);\r
   SmbiosRecord = AllocatePool(TotalSize);\r
   ZeroMem(SmbiosRecord, TotalSize);\r
 \r
@@ -518,8 +526,19 @@ Returns:
 \r
 --*/\r
 {\r
-  EFI_STATUS                Status;\r
+  EFI_STATUS  Status;\r
+  UINT64      Frequency;\r
 \r
+  //\r
+  // Retrieve the frequency of the performance counter in Hz.\r
+  //  \r
+  gWinNt->QueryPerformanceFrequency ((LARGE_INTEGER *)&Frequency);\r
+  \r
+  //\r
+  // Convert frequency in Hz to a clock period in femtoseconds.\r
+  //\r
+  mTimerPeriod = DivU64x64Remainder (1000000000000000, Frequency, NULL);\r
+  \r
   CpuUpdateSmbios ();\r
 \r
   Status = gBS->InstallMultipleProtocolInterfaces (\r