/* The TSC counting frequency is determined by using CPUID leaf 0x15. Frequency in MHz = Core XTAL frequency * EBX/EAX. In newer flavors of the CPU, core xtal frequency is returned in ECX or 0 if not supported.  */
UINT64 CpuidCoreClockCalculateTscFrequency(VOID)
/* The TSC counting frequency is determined by using CPUID leaf 0x15. Frequency in MHz = Core XTAL frequency * EBX/EAX. In newer flavors of the CPU, core xtal frequency is returned in ECX or 0 if not supported.  */
UINT64 CpuidCoreClockCalculateTscFrequency(VOID)
{
  UINT64  TscFrequency;
  UINT64  CoreXtalFrequency;
  UINT32  RegEax;
  UINT32  RegEbx;
  UINT32  RegEcx;
  AsmCpuid (CPUID_TIME_STAMP_COUNTER, &RegEax, &RegEbx, &RegEcx, NULL);
  if ((RegEax == 0) || (RegEbx == 0)) {
    ASSERT (RegEax != 0);
    ASSERT (RegEbx != 0);
    return 0;
  }
  if (RegEcx == 0) {
    CoreXtalFrequency = PcdGet64 (PcdCpuCoreCrystalClockFrequency);
  } else {
    CoreXtalFrequency = (UINT64)RegEcx;
  }
  TscFrequency = DivU64x32 (MultU64x32 (CoreXtalFrequency, RegEbx) + (UINT64)(RegEax >> 1), RegEax);
  return TscFrequency;
}