Skip to content

Instantly share code, notes, and snippets.

@DragoonAethis
Created November 6, 2018 12:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DragoonAethis/7df6d8fb35c4f1932ec42bacbcbf73a8 to your computer and use it in GitHub Desktop.
Save DragoonAethis/7df6d8fb35c4f1932ec42bacbcbf73a8 to your computer and use it in GitHub Desktop.
SET EDK2_PATH=%BUILDTOOLSDIR%\UDK\2018
SET EDK_TOOLS_PATH=%EDK2_PATH%\BaseTools
SET EDK_TOOLS_BIN=%EDK_TOOLS_PATH%\Bin\Win32
SET PATH=%EDK2_PATH%;%PATH%
set WORKSPACE=%CD%
set PACKAGES_PATH=%EDK2_PATH%
call edksetup.bat
build -t VS2017 -a X64 --buildtarget=RELEASE -p UefiTimerCheck.dsc -m UefiTimerCheck.inf
#include <Uefi.h>
#include <Library/UefiLib.h>
#include <Library/TimerLib.h>
#include <Library/DebugLib.h>
#include <Library/UefiBootServicesTableLib.h>
#include <Library/UefiApplicationEntryPoint.h>
EFI_STATUS EFIAPI
UefiMain (
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
) {
AsciiPrint ("Timer Check - Press Enter to exit...\n");
UINT64 timeNs = 0, timeMs = 0, perfHz = 0, startVal = 0, endVal = 0;
EFI_INPUT_KEY Key;
do {
AsciiPrint ("Running GetPerformanceCounterProperties...\n");
perfHz = GetPerformanceCounterProperties(&startVal, &endVal);
AsciiPrint ("Running GetPerformanceCounter + GetTimeInNanoSecond...\n");
timeNs = GetTimeInNanoSecond(GetPerformanceCounter());
timeMs = timeNs / 1000000;
AsciiPrint ("Ms: 0x%16X | Ns: 0x%16X | PerfHz: 0x%16X | StartVal: 0x%16X | EndVal: 0x%16X \n",
timeMs, timeNs, perfHz, startVal, endVal);
gST->ConIn->ReadKeyStroke (gST->ConIn, &Key);
} while (Key.UnicodeChar != 0xD);
return EFI_SUCCESS;
}
[Defines]
PLATFORM_NAME = UefiTimerCheck
PLATFORM_GUID = d8c3b2d5-d264-4f5d-913c-3acb1c661eb8
PLATFORM_VERSION = 1.0
DSC_SPECIFICATION = 0x00010005
SUPPORTED_ARCHITECTURES = X64|AARCH64
BUILD_TARGETS = DEBUG|RELEASE
SKUID_IDENTIFIER = DEFAULT
[SkuIds]
0|DEFAULT
[LibraryClasses]
BaseLib|MdePkg/Library/BaseLib/BaseLib.inf
BaseMemoryLib|MdePkg/Library/BaseMemoryLib/BaseMemoryLib.inf
MemoryAllocationLib|MdePkg/Library/UefiMemoryAllocationLib/UefiMemoryAllocationLib.inf
UefiLib|MdePkg/Library/UefiLib/UefiLib.inf
UefiApplicationEntryPoint|MdePkg/Library/UefiApplicationEntryPoint/UefiApplicationEntryPoint.inf
UefiBootServicesTableLib|MdePkg/Library/UefiBootServicesTableLib/UefiBootServicesTableLib.inf
UefiRuntimeServicesTableLib|MdePkg/Library/UefiRuntimeServicesTableLib/UefiRuntimeServicesTableLib.inf
DebugLib|MdePkg/Library/UefiDebugLibConOut/UefiDebugLibConOut.inf
DebugPrintErrorLevelLib|MdePkg/Library/BaseDebugPrintErrorLevelLib/BaseDebugPrintErrorLevelLib.inf
PrintLib|MdePkg/Library/BasePrintLib/BasePrintLib.inf
PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf
DevicePathLib|MdePkg/Library/UefiDevicePathLib/UefiDevicePathLib.inf
SynchronizationLib|MdePkg/Library/BaseSynchronizationLib/BaseSynchronizationLib.inf
# Platform freezes :<
#TimerLib|MdePkg/Library/BaseTimerLibNullTemplate/BaseTimerLibNullTemplate.inf
# All zeroes :|
#TimerLib|MdePkg/Library/SecPeiDxeTimerLibCpu/SecPeiDxeTimerLibCpu.inf
#IoLib|MdePkg/Library/BaseIoLibIntrinsic/BaseIoLibIntrinsic.inf
# Platform freezes :<
#TimerLib|PcAtChipsetPkg/Library/AcpiTimerLib/DxeAcpiTimerLib.inf
#IoLib|MdePkg/Library/BaseIoLibIntrinsic/BaseIoLibIntrinsic.inf
#PciLib|MdePkg/Library/BasePciLibPciExpress/BasePciLibPciExpress.inf
#PciExpressLib|MdePkg/Library/BasePciExpressLib/BasePciExpressLib.inf
#HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf
[Components]
UefiTimerCheck.inf
[Defines]
INF_VERSION = 0x00010005
BASE_NAME = UefiTimerCheck
FILE_GUID = c52ff074-97d5-4983-afc7-9eb915c59ce3
MODULE_TYPE = UEFI_APPLICATION
VERSION_STRING = 1.0
ENTRY_POINT = UefiMain
VALID_ARCHITECTURES = X64 AARCH64
[Sources]
UefiTimerCheck.c
[Packages]
StdLib/StdLib.dec
MdePkg/MdePkg.dec
MdeModulePkg/MdeModulePkg.dec
[LibraryClasses]
UefiLib
BaseLib
TimerLib
BaseMemoryLib
MemoryAllocationLib
UefiBootServicesTableLib
UefiApplicationEntryPoint
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment