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