summaryrefslogtreecommitdiffstats
path: root/PcAtChipsetPkg/Library/AcpiTimerLib/DxeAcpiTimerLib.c
diff options
context:
space:
mode:
authorLiming Gao <liming.gao@intel.com>2018-01-23 10:24:04 +0800
committerLiming Gao <liming.gao@intel.com>2018-02-06 13:37:01 +0800
commitfd501a798402fdc8ce3fe4e7de3927658889b555 (patch)
tree4674645d3570e2d1f6a1263c9e4bf4ccaeda8494 /PcAtChipsetPkg/Library/AcpiTimerLib/DxeAcpiTimerLib.c
parent84391f57955bc92fb81c81410a022bed4d3304b3 (diff)
downloadedk2-fd501a798402fdc8ce3fe4e7de3927658889b555.tar.gz
PcAtChipsetPkg: Add PeiAcpiTimerLib to save Frequency in HOB
In V2: 1) Update PeiAcpiTimerLib base name to PeiAcpiTimerLib 2) Update PeiAcpiTimerLib to add the missing constructor to enable ACPI IO space 3) Update DxeAcpiTimerLib to cache frequency in constructor. PeiAcpiTimerLib caches PerformanceCounterFrequency in HOB, then Pei and Dxe AcpiTimerLib can share the same PerformanceCounterFrequency. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Liming Gao <liming.gao@intel.com> Cc: Star Zeng <star.zeng@intel.com> Reviewed-by: Star Zeng <star.zeng@intel.com>
Diffstat (limited to 'PcAtChipsetPkg/Library/AcpiTimerLib/DxeAcpiTimerLib.c')
-rw-r--r--PcAtChipsetPkg/Library/AcpiTimerLib/DxeAcpiTimerLib.c57
1 files changed, 54 insertions, 3 deletions
diff --git a/PcAtChipsetPkg/Library/AcpiTimerLib/DxeAcpiTimerLib.c b/PcAtChipsetPkg/Library/AcpiTimerLib/DxeAcpiTimerLib.c
index b141c680fb..67e18a1360 100644
--- a/PcAtChipsetPkg/Library/AcpiTimerLib/DxeAcpiTimerLib.c
+++ b/PcAtChipsetPkg/Library/AcpiTimerLib/DxeAcpiTimerLib.c
@@ -12,9 +12,27 @@
**/
-#include <Base.h>
+#include <PiDxe.h>
#include <Library/TimerLib.h>
#include <Library/BaseLib.h>
+#include <Library/HobLib.h>
+
+extern GUID mFrequencyHobGuid;
+
+/**
+ The constructor function enables ACPI IO space.
+
+ If ACPI I/O space not enabled, this function will enable it.
+ It will always return RETURN_SUCCESS.
+
+ @retval EFI_SUCCESS The constructor always returns RETURN_SUCCESS.
+
+**/
+RETURN_STATUS
+EFIAPI
+AcpiTimerLibConstructor (
+ VOID
+ );
/**
Calculate TSC frequency.
@@ -54,8 +72,41 @@ InternalGetPerformanceCounterFrequency (
VOID
)
{
- if (mPerformanceCounterFrequency == 0) {
+ return mPerformanceCounterFrequency;
+}
+
+/**
+ The constructor function enables ACPI IO space, and caches PerformanceCounterFrequency.
+
+ @param ImageHandle The firmware allocated handle for the EFI image.
+ @param SystemTable A pointer to the EFI System Table.
+
+ @retval EFI_SUCCESS The constructor always returns RETURN_SUCCESS.
+
+**/
+EFI_STATUS
+EFIAPI
+DxeAcpiTimerLibConstructor (
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
+ )
+{
+ EFI_HOB_GUID_TYPE *GuidHob;
+
+ //
+ // Enable ACPI IO space.
+ //
+ AcpiTimerLibConstructor ();
+
+ //
+ // Initialize PerformanceCounterFrequency
+ //
+ GuidHob = GetFirstGuidHob (&mFrequencyHobGuid);
+ if (GuidHob != NULL) {
+ mPerformanceCounterFrequency = *(UINT64*)GET_GUID_HOB_DATA (GuidHob);
+ } else {
mPerformanceCounterFrequency = InternalCalculateTscFrequency ();
}
- return mPerformanceCounterFrequency;
+
+ return EFI_SUCCESS;
}