VirtualBox

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

最後變更 在這個檔案從105668是 99404,由 vboxsync 提交於 2 年 前

Devices/EFI/FirmwareNew: Update to edk2-stable202302 and make it build, 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 - 2018, 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
14extern GUID mFrequencyHobGuid;
15
16/**
17 The constructor function enables ACPI IO space.
18
19 If ACPI I/O space not enabled, this function will enable it.
20 It will always return RETURN_SUCCESS.
21
22 @retval EFI_SUCCESS The constructor always returns RETURN_SUCCESS.
23
24**/
25RETURN_STATUS
26EFIAPI
27AcpiTimerLibConstructor (
28 VOID
29 );
30
31/**
32 Calculate TSC frequency.
33
34 The TSC counting frequency is determined by comparing how far it counts
35 during a 101.4 us period as determined by the ACPI timer.
36 The ACPI timer is used because it counts at a known frequency.
37 The TSC is sampled, followed by waiting 363 counts of the ACPI timer,
38 or 101.4 us. The TSC is then sampled again. The difference multiplied by
39 9861 is the TSC frequency. There will be a small error because of the
40 overhead of reading the ACPI timer. An attempt is made to determine and
41 compensate for this error.
42
43 @return The number of TSC counts per second.
44
45**/
46UINT64
47InternalCalculateTscFrequency (
48 VOID
49 );
50
51//
52// Cached performance counter frequency
53//
54UINT64 mPerformanceCounterFrequency = 0;
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 mPerformanceCounterFrequency;
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 mPerformanceCounterFrequency = *(UINT64 *)GET_GUID_HOB_DATA (GuidHob);
96 } else {
97 mPerformanceCounterFrequency = 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