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