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