2 Emu Emulation Metronome Architectural Protocol Driver as defined in DXE CIS
4 Copyright (c) 2006 - 2008, Intel Corporation. All rights reserved.<BR>
5 Portions copyright (c) 2010 - 2011, Apple Inc. All rights reserved.
6 This program and the accompanying materials
7 are licensed and made available under the terms and conditions of the BSD License
8 which accompanies this distribution. The full text of the license may be found at
9 http://opensource.org/licenses/bsd-license.php
11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
17 #include "Metronome.h"
23 EFI_METRONOME_ARCH_PROTOCOL mMetronome
= {
24 EmuMetronomeDriverWaitForTick
,
34 EmuMetronomeDriverWaitForTick (
35 IN EFI_METRONOME_ARCH_PROTOCOL
*This
,
42 The WaitForTick() function waits for the number of ticks specified by
43 TickNumber from a known time source in the platform. If TickNumber of
44 ticks are detected, then EFI_SUCCESS is returned. The actual time passed
45 between entry of this function and the first tick is between 0 and
46 TickPeriod 100 nS units. If you want to guarantee that at least TickPeriod
47 time has elapsed, wait for two ticks. This function waits for a hardware
48 event to determine when a tick occurs. It is possible for interrupt
49 processing, or exception processing to interrupt the execution of the
50 WaitForTick() function. Depending on the hardware source for the ticks, it
51 is possible for a tick to be missed. This function cannot guarantee that
52 ticks will not be missed. If a timeout occurs waiting for the specified
53 number of ticks, then EFI_TIMEOUT is returned.
57 This - The EFI_METRONOME_ARCH_PROTOCOL instance.
58 TickNumber - Number of ticks to wait.
62 EFI_SUCCESS - The wait for the number of ticks specified by TickNumber
70 // Calculate the time to sleep. Emu smallest unit to sleep is 1 millisec
71 // Tick Period is in 100ns units, divide by 10000 to convert to ms
73 SleepTime
= DivU64x32 (MultU64x32 ((UINT64
) TickNumber
, TICK_PERIOD
) + 9999, 10000);
74 gEmuThunk
->Sleep (SleepTime
);
82 EmuMetronomeDriverInitialize (
83 IN EFI_HANDLE ImageHandle
,
84 IN EFI_SYSTEM_TABLE
*SystemTable
90 Initialize the Metronome Architectural Protocol driver
94 ImageHandle - ImageHandle of the loaded driver
97 SystemTable - Pointer to the System Table
101 EFI_SUCCESS - Metronome Architectural Protocol created
103 EFI_OUT_OF_RESOURCES - Not enough resources available to initialize driver.
105 EFI_DEVICE_ERROR - A device error occured attempting to initialize the driver.
114 // Install the Metronome Architectural Protocol onto a new handle
117 Status
= gBS
->InstallProtocolInterface (
119 &gEfiMetronomeArchProtocolGuid
,
120 EFI_NATIVE_INTERFACE
,