]>
Commit | Line | Data |
---|---|---|
d668c8bc AP |
1 | /** @file\r |
2 | Private data structures\r | |
3 | \r | |
4 | Copyright (c) 2005 - 2018, Intel Corporation. All rights reserved.<BR>\r | |
5 | Copyright (c) 2019, Citrix Systems, Inc.\r | |
6 | \r | |
7 | SPDX-License-Identifier: BSD-2-Clause-Patent\r | |
8 | **/\r | |
9 | \r | |
10 | #ifndef _TIMER_H_\r | |
11 | #define _TIMER_H_\r | |
12 | \r | |
13 | #include <PiDxe.h>\r | |
14 | \r | |
15 | #include <Protocol/Cpu.h>\r | |
16 | #include <Protocol/Timer.h>\r | |
17 | \r | |
18 | #include <Register/LocalApic.h>\r | |
19 | \r | |
20 | #include <Library/UefiBootServicesTableLib.h>\r | |
21 | #include <Library/BaseLib.h>\r | |
22 | #include <Library/DebugLib.h>\r | |
23 | #include <Library/LocalApicLib.h>\r | |
24 | #include <Library/PcdLib.h>\r | |
25 | \r | |
26 | // The default timer tick duration is set to 10 ms = 100000 100 ns units\r | |
27 | //\r | |
28 | #define DEFAULT_TIMER_TICK_DURATION 100000\r | |
29 | \r | |
30 | //\r | |
31 | // The Timer Vector use for interrupt\r | |
32 | //\r | |
33 | #define LOCAL_APIC_TIMER_VECTOR 32\r | |
34 | \r | |
35 | //\r | |
36 | // Function Prototypes\r | |
37 | //\r | |
38 | /**\r | |
39 | Initialize the Timer Architectural Protocol driver\r | |
40 | \r | |
41 | @param ImageHandle ImageHandle of the loaded driver\r | |
42 | @param SystemTable Pointer to the System Table\r | |
43 | \r | |
44 | @retval EFI_SUCCESS Timer Architectural Protocol created\r | |
45 | @retval EFI_OUT_OF_RESOURCES Not enough resources available to initialize driver.\r | |
46 | @retval EFI_DEVICE_ERROR A device error occurred attempting to initialize the driver.\r | |
47 | \r | |
48 | **/\r | |
49 | EFI_STATUS\r | |
50 | EFIAPI\r | |
51 | TimerDriverInitialize (\r | |
52 | IN EFI_HANDLE ImageHandle,\r | |
53 | IN EFI_SYSTEM_TABLE *SystemTable\r | |
54 | )\r | |
55 | ;\r | |
56 | \r | |
57 | /**\r | |
58 | \r | |
59 | This function adjusts the period of timer interrupts to the value specified\r | |
60 | by TimerPeriod. If the timer period is updated, then the selected timer\r | |
61 | period is stored in EFI_TIMER.TimerPeriod, and EFI_SUCCESS is returned. If\r | |
62 | the timer hardware is not programmable, then EFI_UNSUPPORTED is returned.\r | |
63 | If an error occurs while attempting to update the timer period, then the\r | |
64 | timer hardware will be put back in its state prior to this call, and\r | |
65 | EFI_DEVICE_ERROR is returned. If TimerPeriod is 0, then the timer interrupt\r | |
66 | is disabled. This is not the same as disabling the CPU's interrupts.\r | |
67 | Instead, it must either turn off the timer hardware, or it must adjust the\r | |
68 | interrupt controller so that a CPU interrupt is not generated when the timer\r | |
69 | interrupt fires.\r | |
70 | \r | |
71 | \r | |
72 | @param This The EFI_TIMER_ARCH_PROTOCOL instance.\r | |
73 | @param NotifyFunction The rate to program the timer interrupt in 100 nS units. If\r | |
74 | the timer hardware is not programmable, then EFI_UNSUPPORTED is\r | |
75 | returned. If the timer is programmable, then the timer period\r | |
76 | will be rounded up to the nearest timer period that is supported\r | |
77 | by the timer hardware. If TimerPeriod is set to 0, then the\r | |
78 | timer interrupts will be disabled.\r | |
79 | \r | |
80 | @retval EFI_SUCCESS The timer period was changed.\r | |
81 | @retval EFI_UNSUPPORTED The platform cannot change the period of the timer interrupt.\r | |
82 | @retval EFI_DEVICE_ERROR The timer period could not be changed due to a device error.\r | |
83 | \r | |
84 | **/\r | |
85 | EFI_STATUS\r | |
86 | EFIAPI\r | |
87 | TimerDriverRegisterHandler (\r | |
88 | IN EFI_TIMER_ARCH_PROTOCOL *This,\r | |
89 | IN EFI_TIMER_NOTIFY NotifyFunction\r | |
90 | )\r | |
91 | ;\r | |
92 | \r | |
93 | /**\r | |
94 | \r | |
95 | This function adjusts the period of timer interrupts to the value specified\r | |
96 | by TimerPeriod. If the timer period is updated, then the selected timer\r | |
97 | period is stored in EFI_TIMER.TimerPeriod, and EFI_SUCCESS is returned. If\r | |
98 | the timer hardware is not programmable, then EFI_UNSUPPORTED is returned.\r | |
99 | If an error occurs while attempting to update the timer period, then the\r | |
100 | timer hardware will be put back in its state prior to this call, and\r | |
101 | EFI_DEVICE_ERROR is returned. If TimerPeriod is 0, then the timer interrupt\r | |
102 | is disabled. This is not the same as disabling the CPU's interrupts.\r | |
103 | Instead, it must either turn off the timer hardware, or it must adjust the\r | |
104 | interrupt controller so that a CPU interrupt is not generated when the timer\r | |
105 | interrupt fires.\r | |
106 | \r | |
107 | \r | |
108 | @param This The EFI_TIMER_ARCH_PROTOCOL instance.\r | |
109 | @param TimerPeriod The rate to program the timer interrupt in 100 nS units. If\r | |
110 | the timer hardware is not programmable, then EFI_UNSUPPORTED is\r | |
111 | returned. If the timer is programmable, then the timer period\r | |
112 | will be rounded up to the nearest timer period that is supported\r | |
113 | by the timer hardware. If TimerPeriod is set to 0, then the\r | |
114 | timer interrupts will be disabled.\r | |
115 | \r | |
116 | @retval EFI_SUCCESS The timer period was changed.\r | |
117 | @retval EFI_UNSUPPORTED The platform cannot change the period of the timer interrupt.\r | |
118 | @retval EFI_DEVICE_ERROR The timer period could not be changed due to a device error.\r | |
119 | \r | |
120 | **/\r | |
121 | EFI_STATUS\r | |
122 | EFIAPI\r | |
123 | TimerDriverSetTimerPeriod (\r | |
124 | IN EFI_TIMER_ARCH_PROTOCOL *This,\r | |
125 | IN UINT64 TimerPeriod\r | |
126 | )\r | |
127 | ;\r | |
128 | \r | |
129 | /**\r | |
130 | \r | |
131 | This function retrieves the period of timer interrupts in 100 ns units,\r | |
132 | returns that value in TimerPeriod, and returns EFI_SUCCESS. If TimerPeriod\r | |
133 | is NULL, then EFI_INVALID_PARAMETER is returned. If a TimerPeriod of 0 is\r | |
134 | returned, then the timer is currently disabled.\r | |
135 | \r | |
136 | \r | |
137 | @param This The EFI_TIMER_ARCH_PROTOCOL instance.\r | |
138 | @param TimerPeriod A pointer to the timer period to retrieve in 100 ns units. If\r | |
139 | 0 is returned, then the timer is currently disabled.\r | |
140 | \r | |
141 | @retval EFI_SUCCESS The timer period was returned in TimerPeriod.\r | |
142 | @retval EFI_INVALID_PARAMETER TimerPeriod is NULL.\r | |
143 | \r | |
144 | **/\r | |
145 | EFI_STATUS\r | |
146 | EFIAPI\r | |
147 | TimerDriverGetTimerPeriod (\r | |
148 | IN EFI_TIMER_ARCH_PROTOCOL *This,\r | |
149 | OUT UINT64 *TimerPeriod\r | |
150 | )\r | |
151 | ;\r | |
152 | \r | |
153 | /**\r | |
154 | \r | |
155 | This function generates a soft timer interrupt. If the platform does not support soft\r | |
156 | timer interrupts, then EFI_UNSUPPORTED is returned. Otherwise, EFI_SUCCESS is returned.\r | |
157 | If a handler has been registered through the EFI_TIMER_ARCH_PROTOCOL.RegisterHandler()\r | |
158 | service, then a soft timer interrupt will be generated. If the timer interrupt is\r | |
159 | enabled when this service is called, then the registered handler will be invoked. The\r | |
160 | registered handler should not be able to distinguish a hardware-generated timer\r | |
161 | interrupt from a software-generated timer interrupt.\r | |
162 | \r | |
163 | \r | |
164 | @param This The EFI_TIMER_ARCH_PROTOCOL instance.\r | |
165 | \r | |
166 | @retval EFI_SUCCESS The soft timer interrupt was generated.\r | |
167 | @retval EFI_UNSUPPORTED The platform does not support the generation of soft timer interrupts.\r | |
168 | \r | |
169 | **/\r | |
170 | EFI_STATUS\r | |
171 | EFIAPI\r | |
172 | TimerDriverGenerateSoftInterrupt (\r | |
173 | IN EFI_TIMER_ARCH_PROTOCOL *This\r | |
174 | )\r | |
175 | ;\r | |
176 | \r | |
177 | #endif\r |