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