MCPcopy Create free account
hub / github.com/CloverHackyColor/CloverBootloader / OcGetTSCFrequency

Function OcGetTSCFrequency

Library/OcCpuLib/FrequencyDetect.c:516–546  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

514}
515
516UINT64
517OcGetTSCFrequency (
518 VOID
519 )
520{
521 UINT64 CPUFrequency;
522 //
523 // For Intel platforms (the vendor check is covered by the callee), prefer
524 // the CPU Frequency derieved from the ART, as the PM timer might not be
525 // available (e.g. 300 series chipsets).
526 // TODO: For AMD, the base clock can be determined from P-registers.
527 //
528 InternalCalculateARTFrequencyIntel (&CPUFrequency, NULL, FALSE);
529 if (CPUFrequency == 0) {
530 CPUFrequency = InternalCalculateVMTFrequency (NULL, NULL);
531 if (CPUFrequency == 0) {
532 CPUFrequency = InternalCalculateTSCFromPMTimer (FALSE);
533 if (CPUFrequency == 0) {
534 //
535 // Assume at least some frequency, so that we always work.
536 //
537 CPUFrequency = OC_FALLBACK_CPU_FREQUENCY;
538 }
539 }
540 }
541 //
542 // For all known models with an invariant TSC, its frequency is equal to the
543 // CPU's specified base clock.
544 //
545 return CPUFrequency;
546}

Callers 1

GetTimingFunction · 0.85

Tested by

no test coverage detected