]>
Commit | Line | Data |
---|---|---|
2ef2b01e A |
1 | /** @file\r |
2 | \r | |
60274cca | 3 | Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>\r |
2ef2b01e | 4 | \r |
60274cca | 5 | This program and the accompanying materials\r |
2ef2b01e A |
6 | are licensed and made available under the terms and conditions of the BSD License\r |
7 | which accompanies this distribution. The full text of the license may be found at\r | |
8 | http://opensource.org/licenses/bsd-license.php\r | |
9 | \r | |
10 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r | |
11 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
12 | \r | |
13 | **/\r | |
14 | \r | |
15 | #include <PiDxe.h>\r | |
16 | \r | |
17 | #include <Library/BaseLib.h>\r | |
18 | #include <Library/DebugLib.h>\r | |
19 | #include <Library/BaseMemoryLib.h>\r | |
20 | #include <Library/UefiBootServicesTableLib.h>\r | |
21 | #include <Library/UefiLib.h>\r | |
22 | #include <Library/PcdLib.h>\r | |
23 | #include <Library/TimerLib.h>\r | |
24 | \r | |
25 | #include <Protocol/Metronome.h>\r | |
26 | \r | |
27 | \r | |
28 | \r | |
29 | /**\r | |
30 | The WaitForTick() function waits for the number of ticks specified by \r | |
31 | TickNumber from a known time source in the platform. If TickNumber of \r | |
32 | ticks are detected, then EFI_SUCCESS is returned. The actual time passed \r | |
33 | between entry of this function and the first tick is between 0 and \r | |
34 | TickPeriod 100 nS units. If you want to guarantee that at least TickPeriod \r | |
35 | time has elapsed, wait for two ticks. This function waits for a hardware \r | |
36 | event to determine when a tick occurs. It is possible for interrupt \r | |
37 | processing, or exception processing to interrupt the execution of the \r | |
38 | WaitForTick() function. Depending on the hardware source for the ticks, it \r | |
39 | is possible for a tick to be missed. This function cannot guarantee that \r | |
40 | ticks will not be missed. If a timeout occurs waiting for the specified \r | |
41 | number of ticks, then EFI_TIMEOUT is returned.\r | |
42 | \r | |
43 | @param This The EFI_METRONOME_ARCH_PROTOCOL instance.\r | |
44 | @param TickNumber Number of ticks to wait.\r | |
45 | \r | |
46 | @retval EFI_SUCCESS The wait for the number of ticks specified by TickNumber\r | |
47 | succeeded.\r | |
48 | @retval EFI_TIMEOUT A timeout occurred waiting for the specified number of ticks.\r | |
49 | \r | |
50 | **/\r | |
51 | EFI_STATUS\r | |
52 | EFIAPI\r | |
53 | WaitForTick (\r | |
54 | IN EFI_METRONOME_ARCH_PROTOCOL *This,\r | |
55 | IN UINT32 TickNumber\r | |
56 | )\r | |
57 | {\r | |
58 | //\r | |
59 | // Fill me in\r | |
60 | //\r | |
61 | MicroSecondDelay (10 * TickNumber);\r | |
62 | return EFI_UNSUPPORTED;\r | |
63 | }\r | |
64 | \r | |
65 | \r | |
66 | \r | |
67 | /**\r | |
7ca9e5a4 | 68 | Interface structure for the Metronome Architectural Protocol.\r |
2ef2b01e A |
69 | \r |
70 | @par Protocol Description:\r | |
71 | This protocol provides access to a known time source in the platform to the\r | |
72 | core. The core uses this known time source to produce core services that \r | |
73 | require calibrated delays. \r | |
74 | \r | |
75 | @param WaitForTick\r | |
76 | Waits for a specified number of ticks from a known time source \r | |
77 | in the platform. The actual time passed between entry of this \r | |
78 | function and the first tick is between 0 and TickPeriod 100 nS \r | |
79 | units. If you want to guarantee that at least TickPeriod time \r | |
80 | has elapsed, wait for two ticks.\r | |
81 | \r | |
82 | @param TickPeriod\r | |
83 | The period of platform's known time source in 100 nS units. \r | |
84 | This value on any platform must be at least 10 uS, and must not \r | |
85 | exceed 200 uS. The value in this field is a constant that must \r | |
86 | not be modified after the Metronome architectural protocol is \r | |
87 | installed. All consumers must treat this as a read-only field.\r | |
88 | \r | |
89 | **/\r | |
90 | EFI_METRONOME_ARCH_PROTOCOL gMetronome = {\r | |
91 | WaitForTick,\r | |
92 | 100 \r | |
93 | };\r | |
94 | \r | |
95 | \r | |
96 | EFI_HANDLE gMetronomeHandle = NULL;\r | |
97 | \r | |
98 | \r | |
99 | \r | |
100 | /**\r | |
101 | Initialize the state information for the CPU Architectural Protocol\r | |
102 | \r | |
103 | @param ImageHandle of the loaded driver\r | |
104 | @param SystemTable Pointer to the System Table\r | |
105 | \r | |
106 | @retval EFI_SUCCESS Protocol registered\r | |
107 | @retval EFI_OUT_OF_RESOURCES Cannot allocate protocol data structure\r | |
108 | @retval EFI_DEVICE_ERROR Hardware problems\r | |
109 | \r | |
110 | **/\r | |
111 | EFI_STATUS\r | |
112 | MetronomeInitialize (\r | |
113 | IN EFI_HANDLE ImageHandle,\r | |
114 | IN EFI_SYSTEM_TABLE *SystemTable\r | |
115 | )\r | |
116 | {\r | |
117 | EFI_STATUS Status;\r | |
118 | \r | |
119 | //\r | |
120 | // Do any hardware init required to make WaitForTick () to work here.\r | |
121 | //\r | |
122 | \r | |
123 | Status = gBS->InstallMultipleProtocolInterfaces (\r | |
124 | &gMetronomeHandle,\r | |
125 | &gEfiMetronomeArchProtocolGuid, &gMetronome,\r | |
126 | NULL\r | |
127 | );\r | |
128 | ASSERT_EFI_ERROR (Status);\r | |
129 | \r | |
130 | return Status;\r | |
131 | }\r | |
132 | \r |