VirtualBox

source: vbox/trunk/src/VBox/Devices/EFI/Firmware/PcAtChipsetPkg/Library/AcpiTimerLib/DxeStandaloneMmAcpiTimerLib.c@ 105681

最後變更 在這個檔案從105681是 105670,由 vboxsync 提交於 7 月 前

Devices/EFI/FirmwareNew: Merge edk2-stable-202405 and make it build on aarch64, bugref:4643

  • 屬性 svn:eol-style 設為 native
檔案大小: 2.2 KB
 
1/** @file
2 ACPI Timer implements one instance of Timer Library.
3
4 Copyright (c) 2013 - 2023, Intel Corporation. All rights reserved.<BR>
5 SPDX-License-Identifier: BSD-2-Clause-Patent
6
7**/
8
9#include <PiDxe.h>
10#include <Library/TimerLib.h>
11#include <Library/BaseLib.h>
12#include <Library/HobLib.h>
13
14//
15// Cached performance counter frequency
16//
17static UINT64 mAcpiTimerLibTscFrequency = 0;
18
19extern GUID mFrequencyHobGuid;
20
21/**
22 The constructor function enables ACPI IO space.
23
24 If ACPI I/O space not enabled, this function will enable it.
25 It will always return RETURN_SUCCESS.
26
27 @retval EFI_SUCCESS The constructor always returns RETURN_SUCCESS.
28
29**/
30RETURN_STATUS
31EFIAPI
32AcpiTimerLibConstructor (
33 VOID
34 );
35
36/**
37 Calculate TSC frequency.
38
39 The TSC counting frequency is determined by comparing how far it counts
40 during a 101.4 us period as determined by the ACPI timer.
41 The ACPI timer is used because it counts at a known frequency.
42 The TSC is sampled, followed by waiting 363 counts of the ACPI timer,
43 or 101.4 us. The TSC is then sampled again. The difference multiplied by
44 9861 is the TSC frequency. There will be a small error because of the
45 overhead of reading the ACPI timer. An attempt is made to determine and
46 compensate for this error.
47
48 @return The number of TSC counts per second.
49
50**/
51UINT64
52InternalCalculateTscFrequency (
53 VOID
54 );
55
56/**
57 Internal function to retrieves the 64-bit frequency in Hz.
58
59 Internal function to retrieves the 64-bit frequency in Hz.
60
61 @return The frequency in Hz.
62
63**/
64UINT64
65InternalGetPerformanceCounterFrequency (
66 VOID
67 )
68{
69 return mAcpiTimerLibTscFrequency;
70}
71
72/**
73 The constructor function enables ACPI IO space, and caches PerformanceCounterFrequency.
74
75 @retval EFI_SUCCESS The constructor always returns RETURN_SUCCESS.
76
77**/
78EFI_STATUS
79CommonAcpiTimerLibConstructor (
80 VOID
81 )
82{
83 EFI_HOB_GUID_TYPE *GuidHob;
84
85 //
86 // Enable ACPI IO space.
87 //
88 AcpiTimerLibConstructor ();
89
90 //
91 // Initialize PerformanceCounterFrequency
92 //
93 GuidHob = GetFirstGuidHob (&mFrequencyHobGuid);
94 if (GuidHob != NULL) {
95 mAcpiTimerLibTscFrequency = *(UINT64 *)GET_GUID_HOB_DATA (GuidHob);
96 } else {
97 mAcpiTimerLibTscFrequency = InternalCalculateTscFrequency ();
98 }
99
100 return EFI_SUCCESS;
101}
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette