Files
slimbootloader/BootloaderCommonPkg/Library/TimeStampLib/TimeStampLib.c
T
Maurice Ma 9a4407018d [QEMU] Fix NOOPT build failure
This patch fixed NOOPT build failure for QEMU.
It fixed #871.

Signed-off-by: Maurice Ma <maurice.ma@intel.com>
2020-10-12 13:00:44 -07:00

47 lines
687 B
C

/** @file
Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
SPDX-License-Identifier: BSD-2-Clause-Patent
**/
#include <Library/BaseLib.h>
/**
Read current timestamp.
@return 64 bit current timestampe value.
**/
UINT64
EFIAPI
ReadTimeStamp (
VOID
)
{
return AsmReadTsc();
}
/**
Get timestamp frequency in KHZ.
@return Timestamp frequency in KHZ.
**/
UINT32
EFIAPI
GetTimeStampFrequency (
VOID
)
{
UINT8 Ratio;
Ratio = (UINT8)((UINT32)AsmReadMsr64 (0xCE) >> 8);
if (Ratio == 0) {
// This might be QEMU case
Ratio = 8;
}
// Ratio * 100000
return (UINT32)(Ratio * 100000);
}