]> git.proxmox.com Git - mirror_edk2.git/blame - UefiCpuPkg/Include/Library/LocalApicLib.h
Fix a bug in GetOptionalStringByIndex() that doesn't handle the case when Index ...
[mirror_edk2.git] / UefiCpuPkg / Include / Library / LocalApicLib.h
CommitLineData
bf73cc4b 1/** @file\r
2 Public include file for Local APIC library.\r
3\r
4 Local APIC library assumes local APIC is enabled. It does not\r
5 handles cases where local APIC is disabled.\r
6\r
7 Copyright (c) 2010, Intel Corporation. All rights reserved.<BR>\r
8 This program and the accompanying materials\r
9 are licensed and made available under the terms and conditions of the BSD License\r
10 which accompanies this distribution. The full text of the license may be found at\r
11 http://opensource.org/licenses/bsd-license.php\r
12\r
13 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
14 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
15\r
16**/\r
17\r
18#ifndef __LOCAL_APIC_LIB_H__\r
19#define __LOCAL_APIC_LIB_H__\r
20\r
21#define LOCAL_APIC_MODE_XAPIC 0x1 ///< xAPIC mode.\r
22#define LOCAL_APIC_MODE_X2APIC 0x2 ///< x2APIC mode.\r
23\r
24/**\r
25 Get the current local APIC mode.\r
26\r
27 If local APIC is disabled, then ASSERT.\r
28\r
29 @retval LOCAL_APIC_MODE_XAPIC current APIC mode is xAPIC.\r
30 @retval LOCAL_APIC_MODE_X2APIC current APIC mode is x2APIC.\r
31**/\r
32UINTN\r
33EFIAPI\r
34GetApicMode (\r
35 VOID\r
36 );\r
37\r
38/**\r
39 Set the current local APIC mode.\r
40\r
41 If the specified local APIC mode is not valid, then ASSERT.\r
42 If the specified local APIC mode can't be set as current, then ASSERT.\r
43\r
44 @param ApicMode APIC mode to be set.\r
45**/\r
46VOID\r
47EFIAPI\r
48SetApicMode (\r
49 IN UINTN ApicMode\r
50 );\r
51\r
52/**\r
53 Get the initial local APIC ID of the executing processor assigned by hardware upon power on or reset.\r
54\r
55 In xAPIC mode, the initial local APIC ID is 8-bit, and may be different from current APIC ID.\r
56 In x2APIC mode, the local APIC ID can't be changed and there is no concept of initial APIC ID. In this case, \r
57 the 32-bit local APIC ID is returned as initial APIC ID.\r
58\r
59 @return 32-bit initial local APIC ID of the executing processor.\r
60**/\r
61UINT32\r
62EFIAPI\r
63GetInitialApicId (\r
64 VOID\r
65 );\r
66\r
67/**\r
68 Get the local APIC ID of the executing processor.\r
69\r
70 @return 32-bit local APIC ID of the executing processor.\r
71**/\r
72UINT32\r
73EFIAPI\r
74GetApicId (\r
75 VOID\r
76 );\r
77\r
78/**\r
79 Send a SMI IPI to a specified target processor.\r
80\r
81 This function returns after the IPI has been accepted by the target processor. \r
82\r
83 @param ApicId Specify the local APIC ID of the target processor.\r
84**/\r
85VOID\r
86EFIAPI\r
87SendSmiIpi (\r
88 IN UINT32 ApicId\r
89 );\r
90\r
91/**\r
92 Send a SMI IPI to all processors excluding self.\r
93\r
94 This function returns after the IPI has been accepted by the target processors. \r
95**/\r
96VOID\r
97EFIAPI\r
98SendSmiIpiAllExcludingSelf (\r
99 VOID\r
100 );\r
101\r
102/**\r
103 Send an INIT IPI to a specified target processor.\r
104\r
105 This function returns after the IPI has been accepted by the target processor. \r
106\r
107 @param ApicId Specify the local APIC ID of the target processor.\r
108**/\r
109VOID\r
110EFIAPI\r
111SendInitIpi (\r
112 IN UINT32 ApicId\r
113 );\r
114\r
115/**\r
116 Send an INIT IPI to all processors excluding self.\r
117\r
118 This function returns after the IPI has been accepted by the target processors. \r
119**/\r
120VOID\r
121EFIAPI\r
122SendInitIpiAllExcludingSelf (\r
123 VOID\r
124 );\r
125\r
126/**\r
127 Send an INIT-Start-up-Start-up IPI sequence to a specified target processor.\r
128\r
129 This function returns after the IPI has been accepted by the target processor. \r
130\r
131 if StartupRoutine >= 1M, then ASSERT.\r
132 if StartupRoutine is not multiple of 4K, then ASSERT.\r
133\r
134 @param ApicId Specify the local APIC ID of the target processor.\r
135 @param StartupRoutine Points to a start-up routine which is below 1M physical\r
136 address and 4K aligned.\r
137**/\r
138VOID\r
139EFIAPI\r
140SendInitSipiSipi (\r
141 IN UINT32 ApicId,\r
142 IN UINT32 StartupRoutine\r
143 );\r
144\r
145/**\r
146 Send an INIT-Start-up-Start-up IPI sequence to all processors excluding self.\r
147\r
148 This function returns after the IPI has been accepted by the target processors. \r
149\r
150 if StartupRoutine >= 1M, then ASSERT.\r
151 if StartupRoutine is not multiple of 4K, then ASSERT.\r
152\r
153 @param StartupRoutine Points to a start-up routine which is below 1M physical\r
154 address and 4K aligned.\r
155**/\r
156VOID\r
157EFIAPI\r
158SendInitSipiSipiAllExcludingSelf (\r
159 IN UINT32 StartupRoutine\r
160 );\r
161\r
162/**\r
163 Programming Virtual Wire Mode.\r
164\r
165 This function programs the local APIC for virtual wire mode following\r
166 the example described in chapter A.3 of the MP 1.4 spec.\r
167\r
168 IOxAPIC is not involved in this type of virtual wire mode.\r
169**/\r
170VOID\r
171EFIAPI\r
172ProgramVirtualWireMode (\r
173 VOID\r
174 );\r
175\r
176/**\r
177 Get the divide value from the DCR (Divide Configuration Register) by which\r
178 the processor's bus clock is divided to form the time base for the APIC timer.\r
179\r
180 @return The divide value is one of 1,2,4,8,16,32,64,128.\r
181**/\r
182UINTN\r
183EFIAPI\r
184GetApicTimerDivisor (\r
185 VOID\r
186 );\r
187\r
188/**\r
189 Read the initial count value from the init-count register.\r
190\r
191 @return The initial count value read from the init-count register.\r
192**/\r
193UINT32\r
194EFIAPI\r
195GetApicTimerInitCount (\r
196 VOID\r
197 );\r
198\r
199/**\r
200 Read the current count value from the current-count register.\r
201\r
202 @return The current count value read from the current-count register.\r
203**/\r
204UINT32\r
205EFIAPI\r
206GetApicTimerCurrentCount (\r
207 VOID\r
208 );\r
209\r
210/**\r
211 Initialize the local APIC timer.\r
212\r
213 The local APIC timer is initialized and enabled.\r
214\r
215 @param DivideValue The divide value for the DCR. It is one of 1,2,4,8,16,32,64,128.\r
216 If it is 0, then use the current divide value in the DCR.\r
217 @param InitCount The initial count value.\r
218 @param PeriodicMode If TRUE, timer mode is peridoic. Othewise, timer mode is one-shot.\r
219 @param Vector The timer interrupt vector number.\r
220**/\r
221VOID\r
222EFIAPI\r
223InitializeApicTimer (\r
224 IN UINTN DivideValue,\r
225 IN UINT32 InitCount,\r
226 IN BOOLEAN PeriodicMode,\r
227 IN UINT8 Vector\r
228 );\r
229\r
230/**\r
231 Enable the local APIC timer interrupt.\r
232**/\r
233VOID\r
234EFIAPI\r
235EnableApicTimerInterrupt (\r
236 VOID\r
237 );\r
238\r
239/**\r
240 Disable the local APIC timer interrupt.\r
241**/\r
242VOID\r
243EFIAPI\r
244DisableApicTimerInterrupt (\r
245 VOID\r
246 );\r
247\r
248/**\r
249 Get the local APIC timer interrupt state.\r
250\r
251 @retval TRUE The local APIC timer interrupt is enabled.\r
252 @retval FALSE The local APIC timer interrupt is disabled.\r
253**/\r
254BOOLEAN\r
255EFIAPI\r
256GetApicTimerInterruptState (\r
257 VOID\r
258 );\r
259\r
260/**\r
261 Send EOI to the local APIC.\r
262**/\r
263VOID\r
264EFIAPI\r
265SendApicEoi (\r
266 VOID\r
267 );\r
268\r
269#endif\r
270\r