]> git.proxmox.com Git - mirror_edk2.git/blobdiff - Nt32Pkg/CpuRuntimeDxe/Cpu.c
Nt32Pkg: Replace BSD License with BSD+Patent License
[mirror_edk2.git] / Nt32Pkg / CpuRuntimeDxe / Cpu.c
index 804c5acdbf2a24c2436b023f3c0c6d520c8861ed..8bf93ae60782c466a2351bcc77e792f44e1df41d 100644 (file)
@@ -1,13 +1,7 @@
 /**@file\r
 \r
-Copyright (c) 2006 - 2009, Intel Corporation\r
-All rights reserved. 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
-http://opensource.org/licenses/bsd-license.php\r
-\r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+Copyright (c) 2006 - 2013, Intel Corporation. All rights reserved.<BR>\r
+SPDX-License-Identifier: BSD-2-Clause-Patent\r
 \r
 Module Name:\r
 \r
@@ -25,6 +19,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 +33,7 @@ CPU_ARCH_PROTOCOL_PRIVATE mCpuTemplate = {
     WinNtRegisterInterruptHandler,\r
     WinNtGetTimerValue,\r
     WinNtSetMemoryAttributes,\r
-    0,\r
+    1,\r
     4\r
   },\r
   {\r
@@ -321,11 +316,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 +396,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 +461,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 +520,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