]> git.proxmox.com Git - mirror_edk2.git/blame - PcAtChipsetPkg/8254TimerDxe/Timer.h
RefRefine soma code to make code run safely.
[mirror_edk2.git] / PcAtChipsetPkg / 8254TimerDxe / Timer.h
CommitLineData
18c97f53 1/** @file\r
2 Private data structures\r
eb16e240 3\r
95d48e82 4Copyright (c) 2005 - 2010, Intel Corporation. All rights reserved.<BR>\r
18c97f53 5This program and the accompanying materials \r
eb16e240 6are licensed and made available under the terms and conditions of the BSD License \r
7which accompanies this distribution. The full text of the license may be found at \r
8http://opensource.org/licenses/bsd-license.php \r
9 \r
10THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r
11WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r
18c97f53 12**/\r
eb16e240 13\r
14#ifndef _TIMER_H_\r
15#define _TIMER_H_\r
16\r
17#include <PiDxe.h>\r
18\r
19#include <Protocol/Cpu.h>\r
eb16e240 20#include <Protocol/Legacy8259.h>\r
21#include <Protocol/Timer.h>\r
22\r
23#include <Library/UefiBootServicesTableLib.h>\r
24#include <Library/BaseLib.h>\r
25#include <Library/DebugLib.h>\r
2952f72d 26#include <Library/IoLib.h>\r
eb16e240 27\r
28//\r
29// The PCAT 8253/8254 has an input clock at 1.193182 MHz and Timer 0 is\r
30// initialized as a 16 bit free running counter that generates an interrupt(IRQ0)\r
31// each time the counter rolls over.\r
32//\r
33// 65536 counts\r
34// ---------------- * 1,000,000 uS/S = 54925.4 uS = 549254 * 100 ns\r
35// 1,193,182 Hz\r
36//\r
2952f72d 37// The default timer tick duration is set to 10 ms = 100000 100 ns units\r
38//\r
39#define DEFAULT_TIMER_TICK_DURATION 100000\r
eb16e240 40#define TIMER_CONTROL_PORT 0x43\r
41#define TIMER0_COUNT_PORT 0x40\r
42\r
43//\r
44// Function Prototypes\r
45//\r
18c97f53 46/**\r
47 Initialize the Timer Architectural Protocol driver\r
48\r
49 @param ImageHandle ImageHandle of the loaded driver\r
50 @param SystemTable Pointer to the System Table\r
51\r
52 @retval EFI_SUCCESS Timer Architectural Protocol created\r
53 @retval EFI_OUT_OF_RESOURCES Not enough resources available to initialize driver.\r
54 @retval EFI_DEVICE_ERROR A device error occured attempting to initialize the driver.\r
55\r
56**/\r
eb16e240 57EFI_STATUS\r
58EFIAPI\r
59TimerDriverInitialize (\r
60 IN EFI_HANDLE ImageHandle,\r
61 IN EFI_SYSTEM_TABLE *SystemTable\r
62 )\r
eb16e240 63;\r
64\r
18c97f53 65/**\r
66\r
67 This function adjusts the period of timer interrupts to the value specified\r
68 by TimerPeriod. If the timer period is updated, then the selected timer\r
69 period is stored in EFI_TIMER.TimerPeriod, and EFI_SUCCESS is returned. If\r
70 the timer hardware is not programmable, then EFI_UNSUPPORTED is returned.\r
71 If an error occurs while attempting to update the timer period, then the\r
72 timer hardware will be put back in its state prior to this call, and\r
73 EFI_DEVICE_ERROR is returned. If TimerPeriod is 0, then the timer interrupt\r
74 is disabled. This is not the same as disabling the CPU's interrupts.\r
75 Instead, it must either turn off the timer hardware, or it must adjust the\r
76 interrupt controller so that a CPU interrupt is not generated when the timer\r
77 interrupt fires.\r
78\r
79\r
80 @param This The EFI_TIMER_ARCH_PROTOCOL instance.\r
24115e44 81 @param NotifyFunction The rate to program the timer interrupt in 100 nS units. If\r
18c97f53 82 the timer hardware is not programmable, then EFI_UNSUPPORTED is\r
83 returned. If the timer is programmable, then the timer period\r
84 will be rounded up to the nearest timer period that is supported\r
85 by the timer hardware. If TimerPeriod is set to 0, then the\r
86 timer interrupts will be disabled.\r
87\r
88 @retval EFI_SUCCESS The timer period was changed.\r
89 @retval EFI_UNSUPPORTED The platform cannot change the period of the timer interrupt.\r
90 @retval EFI_DEVICE_ERROR The timer period could not be changed due to a device error.\r
91\r
92**/\r
eb16e240 93EFI_STATUS\r
94EFIAPI\r
95TimerDriverRegisterHandler (\r
96 IN EFI_TIMER_ARCH_PROTOCOL *This,\r
97 IN EFI_TIMER_NOTIFY NotifyFunction\r
98 )\r
eb16e240 99;\r
100\r
18c97f53 101/**\r
102\r
103 This function adjusts the period of timer interrupts to the value specified\r
104 by TimerPeriod. If the timer period is updated, then the selected timer\r
105 period is stored in EFI_TIMER.TimerPeriod, and EFI_SUCCESS is returned. If\r
106 the timer hardware is not programmable, then EFI_UNSUPPORTED is returned.\r
107 If an error occurs while attempting to update the timer period, then the\r
108 timer hardware will be put back in its state prior to this call, and\r
109 EFI_DEVICE_ERROR is returned. If TimerPeriod is 0, then the timer interrupt\r
110 is disabled. This is not the same as disabling the CPU's interrupts.\r
111 Instead, it must either turn off the timer hardware, or it must adjust the\r
112 interrupt controller so that a CPU interrupt is not generated when the timer\r
113 interrupt fires.\r
114\r
115\r
116 @param This The EFI_TIMER_ARCH_PROTOCOL instance.\r
117 @param TimerPeriod The rate to program the timer interrupt in 100 nS units. If\r
118 the timer hardware is not programmable, then EFI_UNSUPPORTED is\r
119 returned. If the timer is programmable, then the timer period\r
120 will be rounded up to the nearest timer period that is supported\r
121 by the timer hardware. If TimerPeriod is set to 0, then the\r
122 timer interrupts will be disabled.\r
123\r
124 @retval EFI_SUCCESS The timer period was changed.\r
125 @retval EFI_UNSUPPORTED The platform cannot change the period of the timer interrupt.\r
126 @retval EFI_DEVICE_ERROR The timer period could not be changed due to a device error.\r
127\r
128**/\r
eb16e240 129EFI_STATUS\r
130EFIAPI\r
131TimerDriverSetTimerPeriod (\r
132 IN EFI_TIMER_ARCH_PROTOCOL *This,\r
133 IN UINT64 TimerPeriod\r
134 )\r
18c97f53 135;\r
eb16e240 136\r
18c97f53 137/**\r
eb16e240 138\r
18c97f53 139 This function retrieves the period of timer interrupts in 100 ns units,\r
140 returns that value in TimerPeriod, and returns EFI_SUCCESS. If TimerPeriod\r
141 is NULL, then EFI_INVALID_PARAMETER is returned. If a TimerPeriod of 0 is\r
142 returned, then the timer is currently disabled.\r
eb16e240 143\r
eb16e240 144\r
18c97f53 145 @param This The EFI_TIMER_ARCH_PROTOCOL instance.\r
146 @param TimerPeriod A pointer to the timer period to retrieve in 100 ns units. If\r
147 0 is returned, then the timer is currently disabled.\r
eb16e240 148\r
18c97f53 149 @retval EFI_SUCCESS The timer period was returned in TimerPeriod.\r
150 @retval EFI_INVALID_PARAMETER TimerPeriod is NULL.\r
eb16e240 151\r
18c97f53 152**/\r
eb16e240 153EFI_STATUS\r
154EFIAPI\r
155TimerDriverGetTimerPeriod (\r
156 IN EFI_TIMER_ARCH_PROTOCOL *This,\r
157 OUT UINT64 *TimerPeriod\r
158 )\r
18c97f53 159;\r
eb16e240 160\r
18c97f53 161/**\r
eb16e240 162\r
18c97f53 163 This function generates a soft timer interrupt. If the platform does not support soft\r
164 timer interrupts, then EFI_UNSUPPORTED is returned. Otherwise, EFI_SUCCESS is returned.\r
165 If a handler has been registered through the EFI_TIMER_ARCH_PROTOCOL.RegisterHandler()\r
166 service, then a soft timer interrupt will be generated. If the timer interrupt is\r
167 enabled when this service is called, then the registered handler will be invoked. The\r
168 registered handler should not be able to distinguish a hardware-generated timer\r
169 interrupt from a software-generated timer interrupt.\r
eb16e240 170\r
eb16e240 171\r
18c97f53 172 @param This The EFI_TIMER_ARCH_PROTOCOL instance.\r
eb16e240 173\r
18c97f53 174 @retval EFI_SUCCESS The soft timer interrupt was generated.\r
175 @retval EFI_UNSUPPORTEDT The platform does not support the generation of soft timer interrupts.\r
eb16e240 176\r
18c97f53 177**/\r
eb16e240 178EFI_STATUS\r
179EFIAPI\r
180TimerDriverGenerateSoftInterrupt (\r
181 IN EFI_TIMER_ARCH_PROTOCOL *This\r
182 )\r
eb16e240 183;\r
184\r
185#endif\r