delete dxs file
[mirror_edk2.git] / Nt32Pkg / MonotonicCounterRuntimeDxe / Metronome.c
CommitLineData
8a4a9d21 1/*++\r
2\r
3Copyright (c) 2006, Intel Corporation\r
4All rights reserved. This program and the accompanying materials\r
5are licensed and made available under the terms and conditions of the BSD License\r
6which accompanies this distribution. The full text of the license may be found at\r
7http://opensource.org/licenses/bsd-license.php\r
8\r
9THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
10WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
11\r
12Module Name:\r
13\r
14 Metronome.c\r
15\r
16Abstract:\r
17\r
18 NT Emulation Metronome Architectural Protocol Driver as defined in DXE CIS\r
19\r
20--*/\r
21\r
22//\r
23// Include common header file for this module.\r
24//\r
25#include "CommonHeader.h"\r
26\r
27#include "Metronome.h"\r
28\r
29//\r
30// Global Variables\r
31//\r
32EFI_METRONOME_ARCH_PROTOCOL mMetronome = {\r
33 WinNtMetronomeDriverWaitForTick,\r
34 TICK_PERIOD\r
35};\r
36\r
37//\r
38// Worker Functions\r
39//\r
40\r
41EFI_STATUS\r
42EFIAPI\r
43WinNtMetronomeDriverWaitForTick (\r
44 IN EFI_METRONOME_ARCH_PROTOCOL *This,\r
45 IN UINT32 TickNumber\r
46 )\r
47/*++\r
48\r
49Routine Description:\r
50\r
51 The WaitForTick() function waits for the number of ticks specified by\r
52 TickNumber from a known time source in the platform. If TickNumber of\r
53 ticks are detected, then EFI_SUCCESS is returned. The actual time passed\r
54 between entry of this function and the first tick is between 0 and\r
55 TickPeriod 100 nS units. If you want to guarantee that at least TickPeriod\r
56 time has elapsed, wait for two ticks. This function waits for a hardware\r
57 event to determine when a tick occurs. It is possible for interrupt\r
58 processing, or exception processing to interrupt the execution of the\r
59 WaitForTick() function. Depending on the hardware source for the ticks, it\r
60 is possible for a tick to be missed. This function cannot guarantee that\r
61 ticks will not be missed. If a timeout occurs waiting for the specified\r
62 number of ticks, then EFI_TIMEOUT is returned.\r
63\r
64Arguments:\r
65\r
66 This - The EFI_METRONOME_ARCH_PROTOCOL instance.\r
67 TickNumber - Number of ticks to wait.\r
68\r
69Returns:\r
70\r
71 EFI_SUCCESS - The wait for the number of ticks specified by TickNumber\r
72 succeeded.\r
73\r
74--*/\r
75{\r
76 UINT64 SleepTime;\r
77\r
78 //\r
79 // Calculate the time to sleep. Win API smallest unit to sleep is 1 millisec\r
80 // Tick Period is in 100ns units, divide by 10000 to convert to ms\r
81 //\r
82 SleepTime = DivU64x32 (MultU64x32 ((UINT64) TickNumber, TICK_PERIOD) + 9999, 10000);\r
83 gWinNt->Sleep ((UINT32) SleepTime);\r
84\r
85 return EFI_SUCCESS;\r
86}\r
87\r
88\r
89EFI_STATUS\r
90EFIAPI\r
91WinNtMetronomeDriverInitialize (\r
92 IN EFI_HANDLE ImageHandle,\r
93 IN EFI_SYSTEM_TABLE *SystemTable\r
94 )\r
95/*++\r
96\r
97Routine Description:\r
98\r
99 Initialize the Metronome Architectural Protocol driver\r
100\r
101Arguments:\r
102\r
103 ImageHandle - ImageHandle of the loaded driver\r
104\r
105\r
106 SystemTable - Pointer to the System Table\r
107\r
108Returns:\r
109\r
110 EFI_SUCCESS - Metronome Architectural Protocol created\r
111\r
112 EFI_OUT_OF_RESOURCES - Not enough resources available to initialize driver.\r
113\r
114 EFI_DEVICE_ERROR - A device error occured attempting to initialize the driver.\r
115\r
116--*/\r
117{\r
118 EFI_STATUS Status;\r
119 EFI_HANDLE Handle;\r
120\r
121\r
122 //\r
123 // Install the Metronome Architectural Protocol onto a new handle\r
124 //\r
125 Handle = NULL;\r
126 Status = gBS->InstallProtocolInterface (\r
127 &Handle,\r
128 &gEfiMetronomeArchProtocolGuid,\r
129 EFI_NATIVE_INTERFACE,\r
130 &mMetronome\r
131 );\r
132\r
133 return Status;\r
134}\r