VirtualBox

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

Last change on this file since 107064 was 99404, checked in by vboxsync, 23 months ago

Devices/EFI/FirmwareNew: Update to edk2-stable202302 and make it build, bugref:4643

  • Property svn:eol-style set to native
File size: 1.8 KB
Line 
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 <PiPei.h>
10#include <Library/TimerLib.h>
11#include <Library/BaseLib.h>
12#include <Library/HobLib.h>
13#include <Library/DebugLib.h>
14
15extern GUID mFrequencyHobGuid;
16
17/**
18 Calculate TSC frequency.
19
20 The TSC counting frequency is determined by comparing how far it counts
21 during a 101.4 us period as determined by the ACPI timer.
22 The ACPI timer is used because it counts at a known frequency.
23 The TSC is sampled, followed by waiting 363 counts of the ACPI timer,
24 or 101.4 us. The TSC is then sampled again. The difference multiplied by
25 9861 is the TSC frequency. There will be a small error because of the
26 overhead of reading the ACPI timer. An attempt is made to determine and
27 compensate for this error.
28
29 @return The number of TSC counts per second.
30
31**/
32UINT64
33InternalCalculateTscFrequency (
34 VOID
35 );
36
37/**
38 Internal function to retrieves the 64-bit frequency in Hz.
39
40 Internal function to retrieves the 64-bit frequency in Hz.
41
42 @return The frequency in Hz.
43
44**/
45UINT64
46InternalGetPerformanceCounterFrequency (
47 VOID
48 )
49{
50 UINT64 *PerformanceCounterFrequency;
51 EFI_HOB_GUID_TYPE *GuidHob;
52
53 PerformanceCounterFrequency = NULL;
54 GuidHob = GetFirstGuidHob (&mFrequencyHobGuid);
55 if (GuidHob == NULL) {
56 PerformanceCounterFrequency = (UINT64 *)BuildGuidHob (&mFrequencyHobGuid, sizeof (*PerformanceCounterFrequency));
57 ASSERT (PerformanceCounterFrequency != NULL);
58 *PerformanceCounterFrequency = InternalCalculateTscFrequency ();
59 } else {
60 PerformanceCounterFrequency = (UINT64 *)GET_GUID_HOB_DATA (GuidHob);
61 }
62
63 return *PerformanceCounterFrequency;
64}
Note: See TracBrowser for help on using the repository browser.

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