VirtualBox

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

最後變更 在這個檔案從77662是 77662,由 vboxsync 提交於 6 年 前

EFI: First step in UDK2018 merge. Does not build yet.

  • 屬性 svn:eol-style 設為 native
檔案大小: 2.8 KB
 
1/** @file
2 ACPI Timer implements one instance of Timer Library.
3
4 Copyright (c) 2013 - 2016, Intel Corporation. All rights reserved.<BR>
5 This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
9
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
12
13**/
14
15#include <PiDxe.h>
16#include <Library/TimerLib.h>
17#include <Library/BaseLib.h>
18#include <Library/HobLib.h>
19
20extern GUID mFrequencyHobGuid;
21
22/**
23 The constructor function enables ACPI IO space.
24
25 If ACPI I/O space not enabled, this function will enable it.
26 It will always return RETURN_SUCCESS.
27
28 @retval EFI_SUCCESS The constructor always returns RETURN_SUCCESS.
29
30**/
31RETURN_STATUS
32EFIAPI
33AcpiTimerLibConstructor (
34 VOID
35 );
36
37/**
38 Calculate TSC frequency.
39
40 The TSC counting frequency is determined by comparing how far it counts
41 during a 101.4 us period as determined by the ACPI timer.
42 The ACPI timer is used because it counts at a known frequency.
43 The TSC is sampled, followed by waiting 363 counts of the ACPI timer,
44 or 101.4 us. The TSC is then sampled again. The difference multiplied by
45 9861 is the TSC frequency. There will be a small error because of the
46 overhead of reading the ACPI timer. An attempt is made to determine and
47 compensate for this error.
48
49 @return The number of TSC counts per second.
50
51**/
52UINT64
53InternalCalculateTscFrequency (
54 VOID
55 );
56
57//
58// Cached performance counter frequency
59//
60UINT64 mPerformanceCounterFrequency = 0;
61
62/**
63 Internal function to retrieves the 64-bit frequency in Hz.
64
65 Internal function to retrieves the 64-bit frequency in Hz.
66
67 @return The frequency in Hz.
68
69**/
70UINT64
71InternalGetPerformanceCounterFrequency (
72 VOID
73 )
74{
75 return mPerformanceCounterFrequency;
76}
77
78/**
79 The constructor function enables ACPI IO space, and caches PerformanceCounterFrequency.
80
81 @param ImageHandle The firmware allocated handle for the EFI image.
82 @param SystemTable A pointer to the EFI System Table.
83
84 @retval EFI_SUCCESS The constructor always returns RETURN_SUCCESS.
85
86**/
87EFI_STATUS
88EFIAPI
89DxeAcpiTimerLibConstructor (
90 IN EFI_HANDLE ImageHandle,
91 IN EFI_SYSTEM_TABLE *SystemTable
92 )
93{
94 EFI_HOB_GUID_TYPE *GuidHob;
95
96 //
97 // Enable ACPI IO space.
98 //
99 AcpiTimerLibConstructor ();
100
101 //
102 // Initialize PerformanceCounterFrequency
103 //
104 GuidHob = GetFirstGuidHob (&mFrequencyHobGuid);
105 if (GuidHob != NULL) {
106 mPerformanceCounterFrequency = *(UINT64*)GET_GUID_HOB_DATA (GuidHob);
107 } else {
108 mPerformanceCounterFrequency = InternalCalculateTscFrequency ();
109 }
110
111 return EFI_SUCCESS;
112}
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

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