]> git.proxmox.com Git - mirror_edk2.git/blob - InOsEmuPkg/MetronomeDxe/Metronome.c
Move the check refresh attribute logical out of the option string check logical.
[mirror_edk2.git] / InOsEmuPkg / MetronomeDxe / Metronome.c
1 /*++ @file
2 Emu Emulation Metronome Architectural Protocol Driver as defined in DXE CIS
3
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
10
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.
13
14
15 **/
16
17 #include "Metronome.h"
18
19
20 //
21 // Global Variables
22 //
23 EFI_METRONOME_ARCH_PROTOCOL mMetronome = {
24 EmuMetronomeDriverWaitForTick,
25 TICK_PERIOD
26 };
27
28 //
29 // Worker Functions
30 //
31
32 EFI_STATUS
33 EFIAPI
34 EmuMetronomeDriverWaitForTick (
35 IN EFI_METRONOME_ARCH_PROTOCOL *This,
36 IN UINT32 TickNumber
37 )
38 /*++
39
40 Routine Description:
41
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.
54
55 Arguments:
56
57 This - The EFI_METRONOME_ARCH_PROTOCOL instance.
58 TickNumber - Number of ticks to wait.
59
60 Returns:
61
62 EFI_SUCCESS - The wait for the number of ticks specified by TickNumber
63 succeeded.
64
65 **/
66 {
67 UINT64 SleepTime;
68
69 //
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
72 //
73 SleepTime = DivU64x32 (MultU64x32 ((UINT64) TickNumber, TICK_PERIOD) + 9999, 10000);
74 gEmuThunk->Sleep (SleepTime);
75
76 return EFI_SUCCESS;
77 }
78
79
80 EFI_STATUS
81 EFIAPI
82 EmuMetronomeDriverInitialize (
83 IN EFI_HANDLE ImageHandle,
84 IN EFI_SYSTEM_TABLE *SystemTable
85 )
86 /*++
87
88 Routine Description:
89
90 Initialize the Metronome Architectural Protocol driver
91
92 Arguments:
93
94 ImageHandle - ImageHandle of the loaded driver
95
96
97 SystemTable - Pointer to the System Table
98
99 Returns:
100
101 EFI_SUCCESS - Metronome Architectural Protocol created
102
103 EFI_OUT_OF_RESOURCES - Not enough resources available to initialize driver.
104
105 EFI_DEVICE_ERROR - A device error occured attempting to initialize the driver.
106
107 **/
108 {
109 EFI_STATUS Status;
110 EFI_HANDLE Handle;
111
112
113 //
114 // Install the Metronome Architectural Protocol onto a new handle
115 //
116 Handle = NULL;
117 Status = gBS->InstallProtocolInterface (
118 &Handle,
119 &gEfiMetronomeArchProtocolGuid,
120 EFI_NATIVE_INTERFACE,
121 &mMetronome
122 );
123
124 return Status;
125 }