OpenCore  1.0.4
OpenCore Bootloader
Loading...
Searching...
No Matches
FrequencyDetect.c File Reference
#include <Uefi.h>
#include <Guid/OcVariable.h>
#include <Guid/AppleHob.h>
#include <Guid/ApplePlatformInfo.h>
#include <Guid/AcpiDescription.h>
#include <IndustryStandard/CpuId.h>
#include <IndustryStandard/GenericIch.h>
#include <IndustryStandard/McpMemoryController.h>
#include <Protocol/PciIo.h>
#include <Pi/PiBootMode.h>
#include <Pi/PiHob.h>
#include <Library/BaseLib.h>
#include <Library/BaseMemoryLib.h>
#include <Library/BaseOverflowLib.h>
#include <Library/DebugLib.h>
#include <Library/HobLib.h>
#include <Library/IoLib.h>
#include <Library/MemoryAllocationLib.h>
#include <Library/OcCpuLib.h>
#include <Library/PciLib.h>
#include <Library/OcMiscLib.h>
#include <Library/OcVariableLib.h>
#include <Library/UefiBootServicesTableLib.h>
#include <Library/UefiRuntimeServicesTableLib.h>
#include <IndustryStandard/ProcessorInfo.h>
#include <Register/Msr.h>
#include "OcCpuInternals.h"

Go to the source code of this file.

Functions

UINTN InternalGetPmTimerAddr (OUT CONST CHAR8 **Type OPTIONAL)
 
UINT64 InternalCalculateTSCFromPMTimer (IN BOOLEAN Recalculate)
 
STATIC UINT64 InternalSelectAppleFsbFrequency (IN UINT64 *FsbFrequency, IN UINT32 FsbFrequncyCount)
 
UINT64 InternalCalculateTSCFromApplePlatformInfo (OUT UINT64 *FSBFrequency OPTIONAL, IN BOOLEAN Recalculate)
 
UINT64 InternalCalculateARTFrequencyIntel (OUT UINT64 *CPUFrequency, OUT UINT64 *TscAdjustPtr OPTIONAL, IN BOOLEAN Recalculate)
 
UINT64 InternalCalculateVMTFrequency (OUT UINT64 *FSBFrequency OPTIONAL, OUT BOOLEAN *UnderHypervisor OPTIONAL)
 
UINT64 OcGetTSCFrequency (VOID)
 

Detailed Description

Copyright (C) 2016 - 2017, The HermitCrabs Lab. All rights reserved.

All rights reserved.

This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at http://opensource.org/licenses/bsd-license.php

THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.

Definition in file FrequencyDetect.c.

Function Documentation

◆ InternalCalculateARTFrequencyIntel()

UINT64 InternalCalculateARTFrequencyIntel ( OUT UINT64 * CPUFrequency,
OUT UINT64 *TscAdjustPtr OPTIONAL,
IN BOOLEAN Recalculate )

Calculate the ART frequency and derieve the CPU frequency for Intel CPUs

Parameters
[out]CPUFrequencyThe derieved CPU frequency.
[out]TscAdjustPtrAdjustment value for TSC, optional.
[in]RecalculateDo not re-use previously cached information.
Return values
Thecalculated ART frequency.

Definition at line 474 of file FrequencyDetect.c.

◆ InternalCalculateTSCFromApplePlatformInfo()

UINT64 InternalCalculateTSCFromApplePlatformInfo ( OUT UINT64 *FSBFrequency OPTIONAL,
IN BOOLEAN Recalculate )

Calculate the TSC frequency via Apple Platform Info

Parameters
[out]FSBFrequencyUpdated FSB frequency, optional.
[in]RecalculateDo not re-use previously cached information.
Return values
Thecalculated TSC frequency.

Definition at line 345 of file FrequencyDetect.c.

◆ InternalCalculateTSCFromPMTimer()

UINT64 InternalCalculateTSCFromPMTimer ( IN BOOLEAN Recalculate)

Calculate the TSC frequency via PM timer

Parameters
[in]RecalculateDo not re-use previously cached information.
Return values
Thecalculated TSC frequency.

Definition at line 173 of file FrequencyDetect.c.

◆ InternalCalculateVMTFrequency()

UINT64 InternalCalculateVMTFrequency ( OUT UINT64 *FSBFrequency OPTIONAL,
OUT BOOLEAN *UnderHypervisor OPTIONAL )

Calculate the CPU frequency via VMT for hypervisors

Parameters
[out]FSBFrequencyFSB frequency, optional.
[out]UnderHypervisorHypervisor status, optional.
Return values
CPUfrequency or 0.

Definition at line 646 of file FrequencyDetect.c.

◆ InternalGetPmTimerAddr()

UINTN InternalGetPmTimerAddr ( OUT CONST CHAR8 **Type OPTIONAL)

Obtain ACPI PM timer address for this BSP.

Parameters
[out]TypeAddress source type, optional.
Return values
ACPIPM timer address or 0.

Definition at line 46 of file FrequencyDetect.c.

◆ InternalSelectAppleFsbFrequency()

STATIC UINT64 InternalSelectAppleFsbFrequency ( IN UINT64 * FsbFrequency,
IN UINT32 FsbFrequncyCount )

Definition at line 288 of file FrequencyDetect.c.

◆ OcGetTSCFrequency()

UINT64 OcGetTSCFrequency ( VOID )

Obtain CPU's invariant TSC frequency.

Return values
CPU'sTSC frequency or OC_FALLBACK_CPU_FREQUENCY.

Definition at line 762 of file FrequencyDetect.c.