TianoCore EDK2 master
Loading...
Searching...
No Matches
Metronome.c
Go to the documentation of this file.
1
19#include "Metronome.h"
20
21//
22// Handle for the Metronome Architectural Protocol instance produced by this driver
23//
24EFI_HANDLE mMetronomeHandle = NULL;
25
26//
27// The Metronome Architectural Protocol instance produced by this driver
28//
29EFI_METRONOME_ARCH_PROTOCOL mMetronome = {
31 1 // TickPeriod = 1*100 ns units
32};
33
60EFIAPI
63 IN UINT32 TickNumber
64 )
65{
66 //
67 // Check the value of TickNumber, so a 32-bit overflow can be avoided
68 // when TickNumber of converted to nanosecond units
69 //
70 if (TickNumber < 10000000) {
71 //
72 // If TickNumber is small, then use NanoSecondDelay()
73 //
74 NanoSecondDelay (TickNumber * 100);
75 } else {
76 //
77 // If TickNumber is large, then use MicroSecondDelay()
78 //
79 MicroSecondDelay (TickNumber / 10);
80 }
81
82 return EFI_SUCCESS;
83}
84
96EFIAPI
98 IN EFI_HANDLE ImageHandle,
99 IN EFI_SYSTEM_TABLE *SystemTable
100 )
101{
102 EFI_STATUS Status;
103
104 //
105 // Make sure the Metronome Architectural Protocol is not already installed in the system
106 //
107 ASSERT_PROTOCOL_ALREADY_INSTALLED (NULL, &gEfiMetronomeArchProtocolGuid);
108
109 //
110 // Install on a new handle
111 //
112 Status = gBS->InstallMultipleProtocolInterfaces (
113 &mMetronomeHandle,
114 &gEfiMetronomeArchProtocolGuid,
115 &mMetronome,
116 NULL
117 );
118 ASSERT_EFI_ERROR (Status);
119
120 return Status;
121}
UINTN EFIAPI MicroSecondDelay(IN UINTN MicroSeconds)
UINTN EFIAPI NanoSecondDelay(IN UINTN NanoSeconds)
EFI_STATUS EFIAPI WaitForTick(IN EFI_METRONOME_ARCH_PROTOCOL *This, IN UINT32 TickNumber)
Definition: Metronome.c:80
EFI_STATUS EFIAPI InstallMetronome(IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
Definition: Metronome.c:97
#define NULL
Definition: Base.h:319
#define IN
Definition: Base.h:279
#define ASSERT_EFI_ERROR(StatusParameter)
Definition: DebugLib.h:463
#define ASSERT_PROTOCOL_ALREADY_INSTALLED(Handle, Guid)
Definition: DebugLib.h:536
RETURN_STATUS EFI_STATUS
Definition: UefiBaseType.h:29
VOID * EFI_HANDLE
Definition: UefiBaseType.h:33
#define EFI_SUCCESS
Definition: UefiBaseType.h:112
EFI_BOOT_SERVICES * gBS