]>
Commit | Line | Data |
---|---|---|
3eb9473e | 1 | /*++\r |
2 | \r | |
bc7c34af | 3 | Copyright (c) 2004 - 2018, Intel Corporation. All rights reserved.<BR>\r |
2c7e5c2f | 4 | This program and the accompanying materials \r |
3eb9473e | 5 | are licensed and made available under the terms and conditions of the BSD License \r |
6 | which accompanies this distribution. The full text of the license may be found at \r | |
7 | http://opensource.org/licenses/bsd-license.php \r | |
8 | \r | |
9 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r | |
10 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r | |
11 | \r | |
12 | \r | |
13 | Module Name:\r | |
14 | \r | |
15 | EdkIIGlueBaseLib.h\r | |
16 | \r | |
17 | Abstract: \r | |
18 | \r | |
19 | Memory-only library functions with no library constructor/destructor\r | |
20 | \r | |
21 | --*/\r | |
22 | \r | |
23 | #ifndef __EDKII_GLUE_BASE_LIB_H__\r | |
24 | #define __EDKII_GLUE_BASE_LIB_H__\r | |
25 | \r | |
26 | \r | |
27 | //\r | |
28 | // String Functions\r | |
29 | //\r | |
30 | #define StrCpy(_Dest, _Source) GlueStrCpy(_Dest, _Source)\r | |
31 | #define StrnCpy(_Dest, _Source, _Length) GlueStrnCpy(_Dest, _Source, _Length)\r | |
32 | #define StrLen(_String) GlueStrLen(_String)\r | |
33 | #define StrSize(_String) GlueStrSize(_String)\r | |
34 | #define StrCmp(_FristString, _SecondString) GlueStrCmp(_FristString, _SecondString)\r | |
35 | #define StrnCmp(_FirstString, _SecondString, _Length) GlueStrnCmp(_FirstString, _SecondString, _Length)\r | |
36 | #define StrCat(_Dest, _Source) GlueStrCat(_Dest, _Source)\r | |
37 | #define StrnCat(_Dest, _Source, _Length) GlueStrnCat(_Dest, _Source, _Length)\r | |
38 | \r | |
39 | //\r | |
40 | // Linked List\r | |
41 | //\r | |
42 | #define InitializeListHead(_ListHead) GlueInitializeListHead(_ListHead)\r | |
43 | #define InsertHeadList(_ListHead, _Entry ) GlueInsertHeadList(_ListHead, _Entry)\r | |
44 | #define InsertTailList(_ListHead, _Entry) GlueInsertTailList(_ListHead, _Entry)\r | |
45 | #define GetFirstNode(_List) GlueGetFirstNode(_List)\r | |
46 | #define GetNextNode(_List, _Node) GlueGetNextNode(_List, _Node)\r | |
47 | #define IsListEmpty(_ListHead) GlueIsListEmpty(_ListHead)\r | |
48 | #define IsNull(_List, _Node) GlueIsNull(_List, _Node)\r | |
49 | #define IsNodeAtEnd(_List, _Node) GlueIsNodeAtEnd(_List, _Node)\r | |
50 | #define SwapListEntries(_FirstEntry, _SecondEntry) GlueSwapListEntries(_FirstEntry, _SecondEntry)\r | |
51 | #define RemoveEntryList(_Entry) GlueRemoveEntryList(_Entry)\r | |
52 | \r | |
53 | //\r | |
54 | // Math Functions\r | |
55 | //\r | |
56 | #define LShiftU64(_Op, _Count) GlueLShiftU64(_Op, _Count)\r | |
57 | #define RShiftU64(_Op, _Count) GlueRShiftU64(_Op, _Count)\r | |
58 | #define MultU64x32(_Multiplicand, _Multiplier) GlueMultU64x32(_Multiplicand, _Multiplier)\r | |
59 | #define DivU64x32(_Dividend, _Divisor) GlueDivU64x32(_Dividend, _Divisor)\r | |
60 | \r | |
61 | //\r | |
62 | // Others\r | |
63 | //\r | |
64 | #define GetInterruptState() GlueGetInterruptState()\r | |
65 | \r | |
66 | \r | |
67 | //\r | |
68 | // Definitions for architecture specific types\r | |
69 | // These include SPIN_LOCK and BASE_LIBRARY_JUMP_BUFFER\r | |
70 | //\r | |
71 | \r | |
72 | //\r | |
73 | // SPIN_LOCK\r | |
74 | //\r | |
c7f33ca4 | 75 | typedef volatile UINTN SPIN_LOCK;\r |
3eb9473e | 76 | \r |
77 | #if defined (MDE_CPU_IA32)\r | |
78 | //\r | |
79 | // IA32 context buffer used by SetJump() and LongJump()\r | |
80 | //\r | |
81 | typedef struct {\r | |
82 | UINT32 Ebx;\r | |
83 | UINT32 Esi;\r | |
84 | UINT32 Edi;\r | |
85 | UINT32 Ebp;\r | |
86 | UINT32 Esp;\r | |
87 | UINT32 Eip;\r | |
88 | } BASE_LIBRARY_JUMP_BUFFER;\r | |
89 | \r | |
90 | #define BASE_LIBRARY_JUMP_BUFFER_ALIGNMENT 8\r | |
91 | \r | |
3eb9473e | 92 | #elif defined (MDE_CPU_X64)\r |
93 | //\r | |
94 | // X64 context buffer used by SetJump() and LongJump()\r | |
95 | //\r | |
96 | typedef struct {\r | |
97 | UINT64 Rbx;\r | |
98 | UINT64 Rsp;\r | |
99 | UINT64 Rbp;\r | |
100 | UINT64 Rdi;\r | |
101 | UINT64 Rsi;\r | |
102 | UINT64 R12;\r | |
103 | UINT64 R13;\r | |
104 | UINT64 R14;\r | |
105 | UINT64 R15;\r | |
106 | UINT64 Rip;\r | |
287d8d11 LG |
107 | UINT64 MxCsr;\r |
108 | UINT8 XmmBuffer[160]; ///< XMM6-XMM15.\r | |
3eb9473e | 109 | } BASE_LIBRARY_JUMP_BUFFER;\r |
110 | \r | |
111 | #define BASE_LIBRARY_JUMP_BUFFER_ALIGNMENT 8\r | |
112 | \r | |
113 | #elif defined (MDE_CPU_EBC)\r | |
114 | //\r | |
115 | // EBC context buffer used by SetJump() and LongJump()\r | |
116 | //\r | |
117 | typedef struct {\r | |
118 | UINT64 R0;\r | |
119 | UINT64 R1;\r | |
120 | UINT64 R2;\r | |
121 | UINT64 R3;\r | |
122 | UINT64 IP;\r | |
123 | } BASE_LIBRARY_JUMP_BUFFER;\r | |
124 | \r | |
125 | #define BASE_LIBRARY_JUMP_BUFFER_ALIGNMENT 8\r | |
126 | \r | |
127 | #else\r | |
128 | #error Unknown Processor Type\r | |
129 | #endif\r | |
130 | \r | |
131 | //\r | |
132 | // String Services\r | |
133 | //\r | |
134 | \r | |
135 | /**\r | |
136 | Copies one Null-terminated Unicode string to another Null-terminated Unicode\r | |
137 | string and returns the new Unicode string.\r | |
138 | \r | |
139 | This function copies the contents of the Unicode string Source to the Unicode\r | |
140 | string Destination, and returns Destination. If Source and Destination\r | |
141 | overlap, then the results are undefined.\r | |
142 | \r | |
143 | If Destination is NULL, then ASSERT().\r | |
144 | If Destination is not aligned on a 16-bit boundary, then ASSERT().\r | |
145 | If Source is NULL, then ASSERT().\r | |
146 | If Source is not aligned on a 16-bit boundary, then ASSERT().\r | |
147 | If Source and Destination overlap, then ASSERT().\r | |
148 | If PcdMaximumUnicodeStringLength is not zero, and Source contains more than\r | |
149 | PcdMaximumUnicodeStringLength Unicode characters not including the\r | |
150 | Null-terminator, then ASSERT().\r | |
151 | \r | |
152 | @param Destination Pointer to a Null-terminated Unicode string.\r | |
153 | @param Source Pointer to a Null-terminated Unicode string.\r | |
154 | \r | |
155 | @return Destiantion\r | |
156 | \r | |
157 | **/\r | |
158 | CHAR16 *\r | |
159 | EFIAPI\r | |
160 | GlueStrCpy (\r | |
161 | OUT CHAR16 *Destination,\r | |
162 | IN CONST CHAR16 *Source\r | |
163 | );\r | |
c7f33ca4 | 164 | \r |
165 | \r | |
3eb9473e | 166 | /**\r |
167 | Copies one Null-terminated Unicode string with a maximum length to another\r | |
168 | Null-terminated Unicode string with a maximum length and returns the new\r | |
169 | Unicode string.\r | |
170 | \r | |
171 | This function copies the contents of the Unicode string Source to the Unicode\r | |
172 | string Destination, and returns Destination. At most, Length Unicode\r | |
173 | characters are copied from Source to Destination. If Length is 0, then\r | |
174 | Destination is returned unmodified. If Length is greater that the number of\r | |
175 | Unicode characters in Source, then Destination is padded with Null Unicode\r | |
176 | characters. If Source and Destination overlap, then the results are\r | |
177 | undefined.\r | |
178 | \r | |
179 | If Length > 0 and Destination is NULL, then ASSERT().\r | |
180 | If Length > 0 and Destination is not aligned on a 16-bit boundary, then ASSERT().\r | |
181 | If Length > 0 and Source is NULL, then ASSERT().\r | |
182 | If Length > 0 and Source is not aligned on a 16-bit bounadry, then ASSERT().\r | |
183 | If Source and Destination overlap, then ASSERT().\r | |
14c6da21 | 184 | If PcdMaximumUnicodeStringLength is not zero, and Length is greater than \r |
185 | PcdMaximumUnicodeStringLength, then ASSERT().\r | |
3eb9473e | 186 | If PcdMaximumUnicodeStringLength is not zero, and Source contains more than\r |
14c6da21 | 187 | PcdMaximumUnicodeStringLength Unicode characters, not including the Null-terminator,\r |
188 | then ASSERT().\r | |
3eb9473e | 189 | \r |
190 | @param Destination Pointer to a Null-terminated Unicode string.\r | |
191 | @param Source Pointer to a Null-terminated Unicode string.\r | |
192 | @param Length Maximum number of Unicode characters to copy.\r | |
193 | \r | |
194 | @return Destination\r | |
195 | \r | |
196 | **/\r | |
197 | CHAR16 *\r | |
198 | EFIAPI\r | |
199 | GlueStrnCpy (\r | |
200 | OUT CHAR16 *Destination,\r | |
201 | IN CONST CHAR16 *Source,\r | |
202 | IN UINTN Length\r | |
203 | );\r | |
c7f33ca4 | 204 | \r |
205 | \r | |
3eb9473e | 206 | /**\r |
207 | Returns the length of a Null-terminated Unicode string.\r | |
208 | \r | |
209 | This function returns the number of Unicode characters in the Null-terminated\r | |
210 | Unicode string specified by String.\r | |
211 | \r | |
212 | If String is NULL, then ASSERT().\r | |
213 | If String is not aligned on a 16-bit boundary, then ASSERT().\r | |
214 | If PcdMaximumUnicodeStringLength is not zero, and String contains more than\r | |
215 | PcdMaximumUnicodeStringLength Unicode characters not including the\r | |
216 | Null-terminator, then ASSERT().\r | |
217 | \r | |
218 | @param String Pointer to a Null-terminated Unicode string.\r | |
219 | \r | |
220 | @return The length of String.\r | |
221 | \r | |
222 | **/\r | |
223 | UINTN\r | |
224 | EFIAPI\r | |
225 | GlueStrLen (\r | |
226 | IN CONST CHAR16 *String\r | |
227 | );\r | |
c7f33ca4 | 228 | \r |
229 | \r | |
3eb9473e | 230 | /**\r |
231 | Returns the size of a Null-terminated Unicode string in bytes, including the\r | |
232 | Null terminator.\r | |
233 | \r | |
234 | This function returns the size, in bytes, of the Null-terminated Unicode\r | |
235 | string specified by String.\r | |
236 | \r | |
237 | If String is NULL, then ASSERT().\r | |
238 | If String is not aligned on a 16-bit boundary, then ASSERT().\r | |
239 | If PcdMaximumUnicodeStringLength is not zero, and String contains more than\r | |
240 | PcdMaximumUnicodeStringLength Unicode characters not including the\r | |
241 | Null-terminator, then ASSERT().\r | |
242 | \r | |
243 | @param String Pointer to a Null-terminated Unicode string.\r | |
244 | \r | |
245 | @return The size of String.\r | |
246 | \r | |
247 | **/\r | |
248 | UINTN\r | |
249 | EFIAPI\r | |
250 | GlueStrSize (\r | |
251 | IN CONST CHAR16 *String\r | |
252 | );\r | |
c7f33ca4 | 253 | \r |
254 | \r | |
3eb9473e | 255 | /**\r |
256 | Compares two Null-terminated Unicode strings, and returns the difference\r | |
257 | between the first mismatched Unicode characters.\r | |
258 | \r | |
259 | This function compares the Null-terminated Unicode string FirstString to the\r | |
260 | Null-terminated Unicode string SecondString. If FirstString is identical to\r | |
261 | SecondString, then 0 is returned. Otherwise, the value returned is the first\r | |
262 | mismatched Unicode character in SecondString subtracted from the first\r | |
263 | mismatched Unicode character in FirstString.\r | |
264 | \r | |
265 | If FirstString is NULL, then ASSERT().\r | |
266 | If FirstString is not aligned on a 16-bit boundary, then ASSERT().\r | |
267 | If SecondString is NULL, then ASSERT().\r | |
268 | If SecondString is not aligned on a 16-bit boundary, then ASSERT().\r | |
269 | If PcdMaximumUnicodeStringLength is not zero, and FirstString contains more\r | |
270 | than PcdMaximumUnicodeStringLength Unicode characters not including the\r | |
271 | Null-terminator, then ASSERT().\r | |
272 | If PcdMaximumUnicodeStringLength is not zero, and SecondString contains more\r | |
273 | than PcdMaximumUnicodeStringLength Unicode characters not including the\r | |
274 | Null-terminator, then ASSERT().\r | |
275 | \r | |
276 | @param FirstString Pointer to a Null-terminated Unicode string.\r | |
277 | @param SecondString Pointer to a Null-terminated Unicode string.\r | |
278 | \r | |
279 | @retval 0 FirstString is identical to SecondString.\r | |
280 | @retval !=0 FirstString is not identical to SecondString.\r | |
281 | \r | |
282 | **/\r | |
283 | INTN\r | |
284 | EFIAPI\r | |
285 | GlueStrCmp (\r | |
286 | IN CONST CHAR16 *FirstString,\r | |
287 | IN CONST CHAR16 *SecondString\r | |
288 | );\r | |
c7f33ca4 | 289 | \r |
290 | \r | |
3eb9473e | 291 | /**\r |
292 | Compares two Null-terminated Unicode strings with maximum lengths, and\r | |
293 | returns the difference between the first mismatched Unicode characters.\r | |
294 | \r | |
295 | This function compares the Null-terminated Unicode string FirstString to the\r | |
296 | Null-terminated Unicode string SecondString. At most, Length Unicode\r | |
297 | characters will be compared. If Length is 0, then 0 is returned. If\r | |
298 | FirstString is identical to SecondString, then 0 is returned. Otherwise, the\r | |
299 | value returned is the first mismatched Unicode character in SecondString\r | |
300 | subtracted from the first mismatched Unicode character in FirstString.\r | |
301 | \r | |
302 | If Length > 0 and FirstString is NULL, then ASSERT().\r | |
303 | If Length > 0 and FirstString is not aligned on a 16-bit bounadary, then ASSERT().\r | |
304 | If Length > 0 and SecondString is NULL, then ASSERT().\r | |
305 | If Length > 0 and SecondString is not aligned on a 16-bit bounadary, then ASSERT().\r | |
14c6da21 | 306 | If PcdMaximumUnicodeStringLength is not zero, and Length is greater than\r |
307 | PcdMaximumUnicodeStringLength, then ASSERT().\r | |
308 | If PcdMaximumUnicodeStringLength is not zero, and FirstString contains more than\r | |
309 | PcdMaximumUnicodeStringLength Unicode characters, not including the Null-terminator,\r | |
310 | then ASSERT().\r | |
311 | If PcdMaximumUnicodeStringLength is not zero, and SecondString contains more than\r | |
312 | PcdMaximumUnicodeStringLength Unicode characters, not including the Null-terminator,\r | |
313 | then ASSERT().\r | |
3eb9473e | 314 | \r |
315 | @param FirstString Pointer to a Null-terminated Unicode string.\r | |
316 | @param SecondString Pointer to a Null-terminated Unicode string.\r | |
317 | @param Length Maximum number of Unicode characters to compare.\r | |
318 | \r | |
319 | @retval 0 FirstString is identical to SecondString.\r | |
320 | @retval !=0 FirstString is not identical to SecondString.\r | |
321 | \r | |
322 | **/\r | |
323 | INTN\r | |
324 | EFIAPI\r | |
325 | GlueStrnCmp (\r | |
326 | IN CONST CHAR16 *FirstString,\r | |
327 | IN CONST CHAR16 *SecondString,\r | |
328 | IN UINTN Length\r | |
329 | );\r | |
c7f33ca4 | 330 | \r |
331 | \r | |
3eb9473e | 332 | /**\r |
333 | Concatenates one Null-terminated Unicode string to another Null-terminated\r | |
334 | Unicode string, and returns the concatenated Unicode string.\r | |
335 | \r | |
336 | This function concatenates two Null-terminated Unicode strings. The contents\r | |
337 | of Null-terminated Unicode string Source are concatenated to the end of\r | |
338 | Null-terminated Unicode string Destination. The Null-terminated concatenated\r | |
339 | Unicode String is returned. If Source and Destination overlap, then the\r | |
340 | results are undefined.\r | |
341 | \r | |
342 | If Destination is NULL, then ASSERT().\r | |
343 | If Destination is not aligned on a 16-bit bounadary, then ASSERT().\r | |
344 | If Source is NULL, then ASSERT().\r | |
345 | If Source is not aligned on a 16-bit bounadary, then ASSERT().\r | |
346 | If Source and Destination overlap, then ASSERT().\r | |
347 | If PcdMaximumUnicodeStringLength is not zero, and Destination contains more\r | |
348 | than PcdMaximumUnicodeStringLength Unicode characters not including the\r | |
349 | Null-terminator, then ASSERT().\r | |
350 | If PcdMaximumUnicodeStringLength is not zero, and Source contains more than\r | |
351 | PcdMaximumUnicodeStringLength Unicode characters not including the\r | |
352 | Null-terminator, then ASSERT().\r | |
353 | If PcdMaximumUnicodeStringLength is not zero, and concatenating Destination\r | |
354 | and Source results in a Unicode string with more than\r | |
355 | PcdMaximumUnicodeStringLength Unicode characters not including the\r | |
356 | Null-terminator, then ASSERT().\r | |
357 | \r | |
358 | @param Destination Pointer to a Null-terminated Unicode string.\r | |
359 | @param Source Pointer to a Null-terminated Unicode string.\r | |
360 | \r | |
361 | @return Destination\r | |
362 | \r | |
363 | **/\r | |
364 | CHAR16 *\r | |
365 | EFIAPI\r | |
366 | GlueStrCat (\r | |
367 | IN OUT CHAR16 *Destination,\r | |
368 | IN CONST CHAR16 *Source\r | |
369 | );\r | |
c7f33ca4 | 370 | \r |
371 | \r | |
3eb9473e | 372 | /**\r |
373 | Concatenates one Null-terminated Unicode string with a maximum length to the\r | |
374 | end of another Null-terminated Unicode string, and returns the concatenated\r | |
375 | Unicode string.\r | |
376 | \r | |
377 | This function concatenates two Null-terminated Unicode strings. The contents\r | |
378 | of Null-terminated Unicode string Source are concatenated to the end of\r | |
379 | Null-terminated Unicode string Destination, and Destination is returned. At\r | |
380 | most, Length Unicode characters are concatenated from Source to the end of\r | |
381 | Destination, and Destination is always Null-terminated. If Length is 0, then\r | |
382 | Destination is returned unmodified. If Source and Destination overlap, then\r | |
383 | the results are undefined.\r | |
384 | \r | |
385 | If Destination is NULL, then ASSERT().\r | |
386 | If Length > 0 and Destination is not aligned on a 16-bit boundary, then ASSERT().\r | |
387 | If Length > 0 and Source is NULL, then ASSERT().\r | |
388 | If Length > 0 and Source is not aligned on a 16-bit boundary, then ASSERT().\r | |
389 | If Source and Destination overlap, then ASSERT().\r | |
14c6da21 | 390 | If PcdMaximumUnicodeStringLength is not zero, and Length is greater than \r |
391 | PcdMaximumUnicodeStringLength, then ASSERT().\r | |
3eb9473e | 392 | If PcdMaximumUnicodeStringLength is not zero, and Destination contains more\r |
14c6da21 | 393 | than PcdMaximumUnicodeStringLength Unicode characters, not including the\r |
3eb9473e | 394 | Null-terminator, then ASSERT().\r |
395 | If PcdMaximumUnicodeStringLength is not zero, and Source contains more than\r | |
14c6da21 | 396 | PcdMaximumUnicodeStringLength Unicode characters, not including the\r |
3eb9473e | 397 | Null-terminator, then ASSERT().\r |
398 | If PcdMaximumUnicodeStringLength is not zero, and concatenating Destination\r | |
14c6da21 | 399 | and Source results in a Unicode string with more than PcdMaximumUnicodeStringLength\r |
400 | Unicode characters, not including the Null-terminator, then ASSERT().\r | |
3eb9473e | 401 | \r |
402 | @param Destination Pointer to a Null-terminated Unicode string.\r | |
403 | @param Source Pointer to a Null-terminated Unicode string.\r | |
404 | @param Length Maximum number of Unicode characters to concatenate from\r | |
405 | Source.\r | |
406 | \r | |
407 | @return Destination\r | |
408 | \r | |
409 | **/\r | |
410 | CHAR16 *\r | |
411 | EFIAPI\r | |
412 | GlueStrnCat (\r | |
413 | IN OUT CHAR16 *Destination,\r | |
414 | IN CONST CHAR16 *Source,\r | |
415 | IN UINTN Length\r | |
416 | );\r | |
417 | \r | |
418 | /**\r | |
c7f33ca4 | 419 | Returns the first occurance of a Null-terminated Unicode sub-string\r |
3eb9473e | 420 | in a Null-terminated Unicode string.\r |
421 | \r | |
c7f33ca4 | 422 | This function scans the contents of the Null-terminated Unicode string\r |
423 | specified by String and returns the first occurrence of SearchString.\r | |
424 | If SearchString is not found in String, then NULL is returned. If\r | |
425 | the length of SearchString is zero, then String is\r | |
3eb9473e | 426 | returned.\r |
c7f33ca4 | 427 | \r |
3eb9473e | 428 | If String is NULL, then ASSERT().\r |
429 | If String is not aligned on a 16-bit boundary, then ASSERT().\r | |
430 | If SearchString is NULL, then ASSERT().\r | |
431 | If SearchString is not aligned on a 16-bit boundary, then ASSERT().\r | |
432 | \r | |
c7f33ca4 | 433 | If PcdMaximumUnicodeStringLength is not zero, and SearchString\r |
434 | or String contains more than PcdMaximumUnicodeStringLength Unicode\r | |
3eb9473e | 435 | characters not including the Null-terminator, then ASSERT().\r |
436 | \r | |
437 | @param String Pointer to a Null-terminated Unicode string.\r | |
438 | @param SearchString Pointer to a Null-terminated Unicode string to search for.\r | |
439 | \r | |
440 | @retval NULL If the SearchString does not appear in String.\r | |
441 | @retval !NULL If there is a match.\r | |
442 | \r | |
443 | **/\r | |
444 | CHAR16 *\r | |
445 | EFIAPI\r | |
446 | StrStr (\r | |
447 | IN CONST CHAR16 *String,\r | |
448 | IN CONST CHAR16 *SearchString\r | |
449 | );\r | |
450 | \r | |
451 | /**\r | |
c7f33ca4 | 452 | Convert a Null-terminated Unicode decimal string to a value of\r |
3eb9473e | 453 | type UINTN.\r |
454 | \r | |
c7f33ca4 | 455 | This function returns a value of type UINTN by interpreting the contents\r |
456 | of the Unicode string specified by String as a decimal number. The format\r | |
3eb9473e | 457 | of the input Unicode string String is:\r |
c7f33ca4 | 458 | \r |
3eb9473e | 459 | [spaces] [decimal digits].\r |
c7f33ca4 | 460 | \r |
461 | The valid decimal digit character is in the range [0-9]. The\r | |
462 | function will ignore the pad space, which includes spaces or\r | |
463 | tab characters, before [decimal digits]. The running zero in the\r | |
464 | beginning of [decimal digits] will be ignored. Then, the function\r | |
465 | stops at the first character that is a not a valid decimal character\r | |
466 | or a Null-terminator, whichever one comes first.\r | |
467 | \r | |
3eb9473e | 468 | If String is NULL, then ASSERT().\r |
c7f33ca4 | 469 | If String is not aligned in a 16-bit boundary, then ASSERT().\r |
3eb9473e | 470 | If String has only pad spaces, then 0 is returned.\r |
c7f33ca4 | 471 | If String has no pad spaces or valid decimal digits,\r |
3eb9473e | 472 | then 0 is returned.\r |
c7f33ca4 | 473 | If the number represented by String overflows according\r |
3eb9473e | 474 | to the range defined by UINTN, then ASSERT().\r |
c7f33ca4 | 475 | \r |
476 | If PcdMaximumUnicodeStringLength is not zero, and String contains\r | |
477 | more than PcdMaximumUnicodeStringLength Unicode characters not including\r | |
3eb9473e | 478 | the Null-terminator, then ASSERT().\r |
479 | \r | |
480 | @param String Pointer to a Null-terminated Unicode string.\r | |
481 | \r | |
c7f33ca4 | 482 | @retval UINTN\r |
3eb9473e | 483 | \r |
484 | **/\r | |
485 | UINTN\r | |
486 | EFIAPI\r | |
487 | StrDecimalToUintn (\r | |
488 | IN CONST CHAR16 *String\r | |
489 | );\r | |
490 | \r | |
491 | /**\r | |
c7f33ca4 | 492 | Convert a Null-terminated Unicode decimal string to a value of\r |
3eb9473e | 493 | type UINT64.\r |
494 | \r | |
c7f33ca4 | 495 | This function returns a value of type UINT64 by interpreting the contents\r |
496 | of the Unicode string specified by String as a decimal number. The format\r | |
3eb9473e | 497 | of the input Unicode string String is:\r |
c7f33ca4 | 498 | \r |
3eb9473e | 499 | [spaces] [decimal digits].\r |
c7f33ca4 | 500 | \r |
501 | The valid decimal digit character is in the range [0-9]. The\r | |
502 | function will ignore the pad space, which includes spaces or\r | |
503 | tab characters, before [decimal digits]. The running zero in the\r | |
504 | beginning of [decimal digits] will be ignored. Then, the function\r | |
505 | stops at the first character that is a not a valid decimal character\r | |
506 | or a Null-terminator, whichever one comes first.\r | |
507 | \r | |
3eb9473e | 508 | If String is NULL, then ASSERT().\r |
c7f33ca4 | 509 | If String is not aligned in a 16-bit boundary, then ASSERT().\r |
3eb9473e | 510 | If String has only pad spaces, then 0 is returned.\r |
c7f33ca4 | 511 | If String has no pad spaces or valid decimal digits,\r |
3eb9473e | 512 | then 0 is returned.\r |
c7f33ca4 | 513 | If the number represented by String overflows according\r |
3eb9473e | 514 | to the range defined by UINT64, then ASSERT().\r |
c7f33ca4 | 515 | \r |
516 | If PcdMaximumUnicodeStringLength is not zero, and String contains\r | |
517 | more than PcdMaximumUnicodeStringLength Unicode characters not including\r | |
3eb9473e | 518 | the Null-terminator, then ASSERT().\r |
519 | \r | |
520 | @param String Pointer to a Null-terminated Unicode string.\r | |
521 | \r | |
c7f33ca4 | 522 | @retval UINT64\r |
3eb9473e | 523 | \r |
524 | **/\r | |
525 | UINT64\r | |
526 | EFIAPI\r | |
527 | StrDecimalToUint64 (\r | |
528 | IN CONST CHAR16 *String\r | |
529 | );\r | |
c7f33ca4 | 530 | \r |
3eb9473e | 531 | \r |
532 | /**\r | |
533 | Convert a Null-terminated Unicode hexadecimal string to a value of type UINTN.\r | |
534 | \r | |
c7f33ca4 | 535 | This function returns a value of type UINTN by interpreting the contents\r |
536 | of the Unicode string specified by String as a hexadecimal number.\r | |
3eb9473e | 537 | The format of the input Unicode string String is:\r |
c7f33ca4 | 538 | \r |
539 | [spaces][zeros][x][hexadecimal digits].\r | |
540 | \r | |
541 | The valid hexadecimal digit character is in the range [0-9], [a-f] and [A-F].\r | |
542 | The prefix "0x" is optional. Both "x" and "X" is allowed in "0x" prefix.\r | |
543 | If "x" appears in the input string, it must be prefixed with at least one 0.\r | |
544 | The function will ignore the pad space, which includes spaces or tab characters,\r | |
545 | before [zeros], [x] or [hexadecimal digit]. The running zero before [x] or\r | |
546 | [hexadecimal digit] will be ignored. Then, the decoding starts after [x] or the\r | |
547 | first valid hexadecimal digit. Then, the function stops at the first character that is\r | |
3eb9473e | 548 | a not a valid hexadecimal character or NULL, whichever one comes first.\r |
549 | \r | |
550 | If String is NULL, then ASSERT().\r | |
551 | If String is not aligned in a 16-bit boundary, then ASSERT().\r | |
552 | If String has only pad spaces, then zero is returned.\r | |
c7f33ca4 | 553 | If String has no leading pad spaces, leading zeros or valid hexadecimal digits,\r |
3eb9473e | 554 | then zero is returned.\r |
c7f33ca4 | 555 | If the number represented by String overflows according to the range defined by\r |
3eb9473e | 556 | UINTN, then ASSERT().\r |
557 | \r | |
c7f33ca4 | 558 | If PcdMaximumUnicodeStringLength is not zero, and String contains more than\r |
559 | PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator,\r | |
3eb9473e | 560 | then ASSERT().\r |
561 | \r | |
562 | @param String Pointer to a Null-terminated Unicode string.\r | |
563 | \r | |
564 | @retval UINTN\r | |
565 | \r | |
566 | **/\r | |
567 | UINTN\r | |
568 | EFIAPI\r | |
569 | StrHexToUintn (\r | |
570 | IN CONST CHAR16 *String\r | |
571 | );\r | |
572 | \r | |
c7f33ca4 | 573 | \r |
3eb9473e | 574 | /**\r |
575 | Convert a Null-terminated Unicode hexadecimal string to a value of type UINT64.\r | |
576 | \r | |
c7f33ca4 | 577 | This function returns a value of type UINT64 by interpreting the contents\r |
578 | of the Unicode string specified by String as a hexadecimal number.\r | |
579 | The format of the input Unicode string String is\r | |
580 | \r | |
581 | [spaces][zeros][x][hexadecimal digits].\r | |
582 | \r | |
583 | The valid hexadecimal digit character is in the range [0-9], [a-f] and [A-F].\r | |
584 | The prefix "0x" is optional. Both "x" and "X" is allowed in "0x" prefix.\r | |
585 | If "x" appears in the input string, it must be prefixed with at least one 0.\r | |
586 | The function will ignore the pad space, which includes spaces or tab characters,\r | |
587 | before [zeros], [x] or [hexadecimal digit]. The running zero before [x] or\r | |
588 | [hexadecimal digit] will be ignored. Then, the decoding starts after [x] or the\r | |
589 | first valid hexadecimal digit. Then, the function stops at the first character that is\r | |
3eb9473e | 590 | a not a valid hexadecimal character or NULL, whichever one comes first.\r |
591 | \r | |
592 | If String is NULL, then ASSERT().\r | |
593 | If String is not aligned in a 16-bit boundary, then ASSERT().\r | |
594 | If String has only pad spaces, then zero is returned.\r | |
c7f33ca4 | 595 | If String has no leading pad spaces, leading zeros or valid hexadecimal digits,\r |
3eb9473e | 596 | then zero is returned.\r |
c7f33ca4 | 597 | If the number represented by String overflows according to the range defined by\r |
3eb9473e | 598 | UINT64, then ASSERT().\r |
599 | \r | |
c7f33ca4 | 600 | If PcdMaximumUnicodeStringLength is not zero, and String contains more than\r |
601 | PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator,\r | |
3eb9473e | 602 | then ASSERT().\r |
603 | \r | |
604 | @param String Pointer to a Null-terminated Unicode string.\r | |
605 | \r | |
606 | @retval UINT64\r | |
607 | \r | |
608 | **/\r | |
609 | UINT64\r | |
610 | EFIAPI\r | |
611 | StrHexToUint64 (\r | |
612 | IN CONST CHAR16 *String\r | |
613 | );\r | |
614 | \r | |
c7f33ca4 | 615 | \r |
3eb9473e | 616 | /**\r |
c7f33ca4 | 617 | Convert one Null-terminated Unicode string to a Null-terminated\r |
3eb9473e | 618 | ASCII string and returns the ASCII string.\r |
3eb9473e | 619 | \r |
c7f33ca4 | 620 | This function converts the content of the Unicode string Source\r |
621 | to the ASCII string Destination by copying the lower 8 bits of\r | |
622 | each Unicode character. It returns Destination.\r | |
623 | \r | |
624 | If any Unicode characters in Source contain non-zero value in\r | |
3eb9473e | 625 | the upper 8 bits, then ASSERT().\r |
c7f33ca4 | 626 | \r |
3eb9473e | 627 | If Destination is NULL, then ASSERT().\r |
628 | If Source is NULL, then ASSERT().\r | |
629 | If Source is not aligned on a 16-bit boundary, then ASSERT().\r | |
630 | If Source and Destination overlap, then ASSERT().\r | |
c7f33ca4 | 631 | \r |
632 | If PcdMaximumUnicodeStringLength is not zero, and Source contains\r | |
633 | more than PcdMaximumUnicodeStringLength Unicode characters not including\r | |
3eb9473e | 634 | the Null-terminator, then ASSERT().\r |
c7f33ca4 | 635 | \r |
636 | If PcdMaximumAsciiStringLength is not zero, and Source contains more\r | |
637 | than PcdMaximumAsciiStringLength Unicode characters not including the\r | |
3eb9473e | 638 | Null-terminator, then ASSERT().\r |
639 | \r | |
640 | @param Source Pointer to a Null-terminated Unicode string.\r | |
641 | @param Destination Pointer to a Null-terminated ASCII string.\r | |
642 | \r | |
643 | @reture Destination\r | |
644 | \r | |
645 | **/\r | |
646 | CHAR8 *\r | |
647 | EFIAPI\r | |
648 | UnicodeStrToAsciiStr (\r | |
649 | IN CONST CHAR16 *Source,\r | |
650 | OUT CHAR8 *Destination\r | |
651 | );\r | |
652 | \r | |
c7f33ca4 | 653 | \r |
3eb9473e | 654 | /**\r |
655 | Copies one Null-terminated ASCII string to another Null-terminated ASCII\r | |
656 | string and returns the new ASCII string.\r | |
657 | \r | |
658 | This function copies the contents of the ASCII string Source to the ASCII\r | |
659 | string Destination, and returns Destination. If Source and Destination\r | |
660 | overlap, then the results are undefined.\r | |
661 | \r | |
662 | If Destination is NULL, then ASSERT().\r | |
663 | If Source is NULL, then ASSERT().\r | |
664 | If Source and Destination overlap, then ASSERT().\r | |
665 | If PcdMaximumAsciiStringLength is not zero and Source contains more than\r | |
666 | PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,\r | |
667 | then ASSERT().\r | |
668 | \r | |
669 | @param Destination Pointer to a Null-terminated ASCII string.\r | |
670 | @param Source Pointer to a Null-terminated ASCII string.\r | |
671 | \r | |
672 | @return Destination\r | |
673 | \r | |
674 | **/\r | |
675 | CHAR8 *\r | |
676 | EFIAPI\r | |
677 | AsciiStrCpy (\r | |
678 | OUT CHAR8 *Destination,\r | |
679 | IN CONST CHAR8 *Source\r | |
680 | );\r | |
c7f33ca4 | 681 | \r |
682 | \r | |
3eb9473e | 683 | /**\r |
684 | Copies one Null-terminated ASCII string with a maximum length to another\r | |
685 | Null-terminated ASCII string with a maximum length and returns the new ASCII\r | |
686 | string.\r | |
687 | \r | |
688 | This function copies the contents of the ASCII string Source to the ASCII\r | |
689 | string Destination, and returns Destination. At most, Length ASCII characters\r | |
690 | are copied from Source to Destination. If Length is 0, then Destination is\r | |
691 | returned unmodified. If Length is greater that the number of ASCII characters\r | |
692 | in Source, then Destination is padded with Null ASCII characters. If Source\r | |
693 | and Destination overlap, then the results are undefined.\r | |
694 | \r | |
695 | If Destination is NULL, then ASSERT().\r | |
696 | If Source is NULL, then ASSERT().\r | |
697 | If Source and Destination overlap, then ASSERT().\r | |
14c6da21 | 698 | If PcdMaximumAsciiStringLength is not zero, and Length is greater than \r |
699 | PcdMaximumAsciiStringLength, then ASSERT().\r | |
3eb9473e | 700 | If PcdMaximumAsciiStringLength is not zero, and Source contains more than\r |
14c6da21 | 701 | PcdMaximumAsciiStringLength ASCII characters, not including the Null-terminator,\r |
3eb9473e | 702 | then ASSERT().\r |
703 | \r | |
704 | @param Destination Pointer to a Null-terminated ASCII string.\r | |
705 | @param Source Pointer to a Null-terminated ASCII string.\r | |
706 | @param Length Maximum number of ASCII characters to copy.\r | |
707 | \r | |
708 | @return Destination\r | |
709 | \r | |
710 | **/\r | |
711 | CHAR8 *\r | |
712 | EFIAPI\r | |
713 | AsciiStrnCpy (\r | |
714 | OUT CHAR8 *Destination,\r | |
715 | IN CONST CHAR8 *Source,\r | |
716 | IN UINTN Length\r | |
717 | );\r | |
c7f33ca4 | 718 | \r |
719 | \r | |
3eb9473e | 720 | /**\r |
721 | Returns the length of a Null-terminated ASCII string.\r | |
722 | \r | |
723 | This function returns the number of ASCII characters in the Null-terminated\r | |
724 | ASCII string specified by String.\r | |
725 | \r | |
726 | If Length > 0 and Destination is NULL, then ASSERT().\r | |
727 | If Length > 0 and Source is NULL, then ASSERT().\r | |
728 | If PcdMaximumAsciiStringLength is not zero and String contains more than\r | |
729 | PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,\r | |
730 | then ASSERT().\r | |
731 | \r | |
732 | @param String Pointer to a Null-terminated ASCII string.\r | |
733 | \r | |
734 | @return The length of String.\r | |
735 | \r | |
736 | **/\r | |
737 | UINTN\r | |
738 | EFIAPI\r | |
739 | AsciiStrLen (\r | |
740 | IN CONST CHAR8 *String\r | |
741 | );\r | |
c7f33ca4 | 742 | \r |
743 | \r | |
3eb9473e | 744 | /**\r |
745 | Returns the size of a Null-terminated ASCII string in bytes, including the\r | |
746 | Null terminator.\r | |
747 | \r | |
748 | This function returns the size, in bytes, of the Null-terminated ASCII string\r | |
749 | specified by String.\r | |
750 | \r | |
751 | If String is NULL, then ASSERT().\r | |
752 | If PcdMaximumAsciiStringLength is not zero and String contains more than\r | |
753 | PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,\r | |
754 | then ASSERT().\r | |
755 | \r | |
756 | @param String Pointer to a Null-terminated ASCII string.\r | |
757 | \r | |
758 | @return The size of String.\r | |
759 | \r | |
760 | **/\r | |
761 | UINTN\r | |
762 | EFIAPI\r | |
763 | AsciiStrSize (\r | |
764 | IN CONST CHAR8 *String\r | |
765 | );\r | |
c7f33ca4 | 766 | \r |
767 | \r | |
3eb9473e | 768 | /**\r |
769 | Compares two Null-terminated ASCII strings, and returns the difference\r | |
770 | between the first mismatched ASCII characters.\r | |
771 | \r | |
772 | This function compares the Null-terminated ASCII string FirstString to the\r | |
773 | Null-terminated ASCII string SecondString. If FirstString is identical to\r | |
774 | SecondString, then 0 is returned. Otherwise, the value returned is the first\r | |
775 | mismatched ASCII character in SecondString subtracted from the first\r | |
776 | mismatched ASCII character in FirstString.\r | |
777 | \r | |
778 | If FirstString is NULL, then ASSERT().\r | |
779 | If SecondString is NULL, then ASSERT().\r | |
780 | If PcdMaximumAsciiStringLength is not zero and FirstString contains more than\r | |
781 | PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,\r | |
782 | then ASSERT().\r | |
783 | If PcdMaximumAsciiStringLength is not zero and SecondString contains more\r | |
784 | than PcdMaximumAsciiStringLength ASCII characters not including the\r | |
785 | Null-terminator, then ASSERT().\r | |
786 | \r | |
787 | @param FirstString Pointer to a Null-terminated ASCII string.\r | |
788 | @param SecondString Pointer to a Null-terminated ASCII string.\r | |
789 | \r | |
790 | @retval 0 FirstString is identical to SecondString.\r | |
791 | @retval !=0 FirstString is not identical to SecondString.\r | |
792 | \r | |
793 | **/\r | |
794 | INTN\r | |
795 | EFIAPI\r | |
796 | AsciiStrCmp (\r | |
797 | IN CONST CHAR8 *FirstString,\r | |
798 | IN CONST CHAR8 *SecondString\r | |
799 | );\r | |
c7f33ca4 | 800 | \r |
801 | \r | |
3eb9473e | 802 | /**\r |
803 | Performs a case insensitive comparison of two Null-terminated ASCII strings,\r | |
804 | and returns the difference between the first mismatched ASCII characters.\r | |
805 | \r | |
806 | This function performs a case insensitive comparison of the Null-terminated\r | |
807 | ASCII string FirstString to the Null-terminated ASCII string SecondString. If\r | |
808 | FirstString is identical to SecondString, then 0 is returned. Otherwise, the\r | |
809 | value returned is the first mismatched lower case ASCII character in\r | |
810 | SecondString subtracted from the first mismatched lower case ASCII character\r | |
811 | in FirstString.\r | |
812 | \r | |
813 | If FirstString is NULL, then ASSERT().\r | |
814 | If SecondString is NULL, then ASSERT().\r | |
815 | If PcdMaximumAsciiStringLength is not zero and FirstString contains more than\r | |
816 | PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,\r | |
817 | then ASSERT().\r | |
818 | If PcdMaximumAsciiStringLength is not zero and SecondString contains more\r | |
819 | than PcdMaximumAsciiStringLength ASCII characters not including the\r | |
820 | Null-terminator, then ASSERT().\r | |
821 | \r | |
822 | @param FirstString Pointer to a Null-terminated ASCII string.\r | |
823 | @param SecondString Pointer to a Null-terminated ASCII string.\r | |
824 | \r | |
825 | @retval 0 FirstString is identical to SecondString using case insensitive\r | |
826 | comparisons.\r | |
827 | @retval !=0 FirstString is not identical to SecondString using case\r | |
828 | insensitive comparisons.\r | |
829 | \r | |
830 | **/\r | |
831 | INTN\r | |
832 | EFIAPI\r | |
833 | AsciiStriCmp (\r | |
834 | IN CONST CHAR8 *FirstString,\r | |
835 | IN CONST CHAR8 *SecondString\r | |
836 | );\r | |
c7f33ca4 | 837 | \r |
838 | \r | |
3eb9473e | 839 | /**\r |
840 | Compares two Null-terminated ASCII strings with maximum lengths, and returns\r | |
841 | the difference between the first mismatched ASCII characters.\r | |
842 | \r | |
843 | This function compares the Null-terminated ASCII string FirstString to the\r | |
844 | Null-terminated ASCII string SecondString. At most, Length ASCII characters\r | |
845 | will be compared. If Length is 0, then 0 is returned. If FirstString is\r | |
846 | identical to SecondString, then 0 is returned. Otherwise, the value returned\r | |
847 | is the first mismatched ASCII character in SecondString subtracted from the\r | |
848 | first mismatched ASCII character in FirstString.\r | |
849 | \r | |
850 | If Length > 0 and FirstString is NULL, then ASSERT().\r | |
851 | If Length > 0 and SecondString is NULL, then ASSERT().\r | |
14c6da21 | 852 | If PcdMaximumAsciiStringLength is not zero, and Length is greater than \r |
853 | PcdMaximumAsciiStringLength, then ASSERT().\r | |
854 | If PcdMaximumAsciiStringLength is not zero, and FirstString contains more than\r | |
855 | PcdMaximumAsciiStringLength ASCII characters, not including the Null-terminator,\r | |
3eb9473e | 856 | then ASSERT().\r |
14c6da21 | 857 | If PcdMaximumAsciiStringLength is not zero, and SecondString contains more than\r |
858 | PcdMaximumAsciiStringLength ASCII characters, not including the Null-terminator,\r | |
3eb9473e | 859 | then ASSERT().\r |
860 | \r | |
861 | @param FirstString Pointer to a Null-terminated ASCII string.\r | |
862 | @param SecondString Pointer to a Null-terminated ASCII string.\r | |
863 | \r | |
864 | @retval 0 FirstString is identical to SecondString.\r | |
865 | @retval !=0 FirstString is not identical to SecondString.\r | |
866 | \r | |
867 | **/\r | |
868 | INTN\r | |
869 | EFIAPI\r | |
870 | AsciiStrnCmp (\r | |
871 | IN CONST CHAR8 *FirstString,\r | |
872 | IN CONST CHAR8 *SecondString,\r | |
873 | IN UINTN Length\r | |
874 | );\r | |
c7f33ca4 | 875 | \r |
876 | \r | |
3eb9473e | 877 | /**\r |
878 | Concatenates one Null-terminated ASCII string to another Null-terminated\r | |
879 | ASCII string, and returns the concatenated ASCII string.\r | |
880 | \r | |
881 | This function concatenates two Null-terminated ASCII strings. The contents of\r | |
882 | Null-terminated ASCII string Source are concatenated to the end of Null-\r | |
883 | terminated ASCII string Destination. The Null-terminated concatenated ASCII\r | |
884 | String is returned.\r | |
885 | \r | |
886 | If Destination is NULL, then ASSERT().\r | |
887 | If Source is NULL, then ASSERT().\r | |
888 | If PcdMaximumAsciiStringLength is not zero and Destination contains more than\r | |
889 | PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,\r | |
890 | then ASSERT().\r | |
891 | If PcdMaximumAsciiStringLength is not zero and Source contains more than\r | |
892 | PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,\r | |
893 | then ASSERT().\r | |
894 | If PcdMaximumAsciiStringLength is not zero and concatenating Destination and\r | |
895 | Source results in a ASCII string with more than PcdMaximumAsciiStringLength\r | |
896 | ASCII characters, then ASSERT().\r | |
897 | \r | |
898 | @param Destination Pointer to a Null-terminated ASCII string.\r | |
899 | @param Source Pointer to a Null-terminated ASCII string.\r | |
900 | \r | |
901 | @return Destination\r | |
902 | \r | |
903 | **/\r | |
904 | CHAR8 *\r | |
905 | EFIAPI\r | |
906 | AsciiStrCat (\r | |
907 | IN OUT CHAR8 *Destination,\r | |
908 | IN CONST CHAR8 *Source\r | |
909 | );\r | |
c7f33ca4 | 910 | \r |
911 | \r | |
3eb9473e | 912 | /**\r |
913 | Concatenates one Null-terminated ASCII string with a maximum length to the\r | |
914 | end of another Null-terminated ASCII string, and returns the concatenated\r | |
915 | ASCII string.\r | |
916 | \r | |
917 | This function concatenates two Null-terminated ASCII strings. The contents\r | |
918 | of Null-terminated ASCII string Source are concatenated to the end of Null-\r | |
919 | terminated ASCII string Destination, and Destination is returned. At most,\r | |
920 | Length ASCII characters are concatenated from Source to the end of\r | |
921 | Destination, and Destination is always Null-terminated. If Length is 0, then\r | |
922 | Destination is returned unmodified. If Source and Destination overlap, then\r | |
923 | the results are undefined.\r | |
924 | \r | |
925 | If Length > 0 and Destination is NULL, then ASSERT().\r | |
926 | If Length > 0 and Source is NULL, then ASSERT().\r | |
927 | If Source and Destination overlap, then ASSERT().\r | |
14c6da21 | 928 | If PcdMaximumAsciiStringLength is not zero, and Length is greater than\r |
929 | PcdMaximumAsciiStringLength, then ASSERT().\r | |
3eb9473e | 930 | If PcdMaximumAsciiStringLength is not zero, and Destination contains more than\r |
14c6da21 | 931 | PcdMaximumAsciiStringLength ASCII characters, not including the Null-terminator,\r |
3eb9473e | 932 | then ASSERT().\r |
933 | If PcdMaximumAsciiStringLength is not zero, and Source contains more than\r | |
14c6da21 | 934 | PcdMaximumAsciiStringLength ASCII characters, not including the Null-terminator,\r |
3eb9473e | 935 | then ASSERT().\r |
936 | If PcdMaximumAsciiStringLength is not zero, and concatenating Destination and\r | |
937 | Source results in a ASCII string with more than PcdMaximumAsciiStringLength\r | |
14c6da21 | 938 | ASCII characters, not including the Null-terminator, then ASSERT().\r |
3eb9473e | 939 | \r |
940 | @param Destination Pointer to a Null-terminated ASCII string.\r | |
941 | @param Source Pointer to a Null-terminated ASCII string.\r | |
942 | @param Length Maximum number of ASCII characters to concatenate from\r | |
943 | Source.\r | |
944 | \r | |
945 | @return Destination\r | |
946 | \r | |
947 | **/\r | |
948 | CHAR8 *\r | |
949 | EFIAPI\r | |
950 | AsciiStrnCat (\r | |
951 | IN OUT CHAR8 *Destination,\r | |
952 | IN CONST CHAR8 *Source,\r | |
953 | IN UINTN Length\r | |
954 | );\r | |
955 | \r | |
c7f33ca4 | 956 | \r |
3eb9473e | 957 | /**\r |
c7f33ca4 | 958 | Returns the first occurance of a Null-terminated ASCII sub-string\r |
3eb9473e | 959 | in a Null-terminated ASCII string.\r |
960 | \r | |
c7f33ca4 | 961 | This function scans the contents of the ASCII string specified by String\r |
962 | and returns the first occurrence of SearchString. If SearchString is not\r | |
963 | found in String, then NULL is returned. If the length of SearchString is zero,\r | |
3eb9473e | 964 | then String is returned.\r |
c7f33ca4 | 965 | \r |
3eb9473e | 966 | If String is NULL, then ASSERT().\r |
967 | If SearchString is NULL, then ASSERT().\r | |
968 | \r | |
c7f33ca4 | 969 | If PcdMaximumAsciiStringLength is not zero, and SearchString or\r |
970 | String contains more than PcdMaximumAsciiStringLength Unicode characters\r | |
3eb9473e | 971 | not including the Null-terminator, then ASSERT().\r |
972 | \r | |
973 | @param String Pointer to a Null-terminated ASCII string.\r | |
974 | @param SearchString Pointer to a Null-terminated ASCII string to search for.\r | |
975 | \r | |
976 | @retval NULL If the SearchString does not appear in String.\r | |
977 | @retval !NULL If there is a match.\r | |
978 | \r | |
979 | **/\r | |
980 | CHAR8 *\r | |
981 | EFIAPI\r | |
982 | AsciiStrStr (\r | |
983 | IN CONST CHAR8 *String,\r | |
984 | IN CONST CHAR8 *SearchString\r | |
985 | );\r | |
986 | \r | |
c7f33ca4 | 987 | \r |
3eb9473e | 988 | /**\r |
c7f33ca4 | 989 | Convert a Null-terminated ASCII decimal string to a value of type\r |
3eb9473e | 990 | UINTN.\r |
991 | \r | |
c7f33ca4 | 992 | This function returns a value of type UINTN by interpreting the contents\r |
993 | of the ASCII string String as a decimal number. The format of the input\r | |
3eb9473e | 994 | ASCII string String is:\r |
c7f33ca4 | 995 | \r |
3eb9473e | 996 | [spaces] [decimal digits].\r |
c7f33ca4 | 997 | \r |
998 | The valid decimal digit character is in the range [0-9]. The function will\r | |
999 | ignore the pad space, which includes spaces or tab characters, before the digits.\r | |
1000 | The running zero in the beginning of [decimal digits] will be ignored. Then, the\r | |
1001 | function stops at the first character that is a not a valid decimal character or\r | |
3eb9473e | 1002 | Null-terminator, whichever on comes first.\r |
c7f33ca4 | 1003 | \r |
3eb9473e | 1004 | If String has only pad spaces, then 0 is returned.\r |
1005 | If String has no pad spaces or valid decimal digits, then 0 is returned.\r | |
c7f33ca4 | 1006 | If the number represented by String overflows according to the range defined by\r |
3eb9473e | 1007 | UINTN, then ASSERT().\r |
1008 | If String is NULL, then ASSERT().\r | |
c7f33ca4 | 1009 | If PcdMaximumAsciiStringLength is not zero, and String contains more than\r |
1010 | PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,\r | |
3eb9473e | 1011 | then ASSERT().\r |
1012 | \r | |
1013 | @param String Pointer to a Null-terminated ASCII string.\r | |
1014 | \r | |
c7f33ca4 | 1015 | @retval UINTN\r |
3eb9473e | 1016 | \r |
1017 | **/\r | |
1018 | UINTN\r | |
1019 | EFIAPI\r | |
1020 | AsciiStrDecimalToUintn (\r | |
1021 | IN CONST CHAR8 *String\r | |
1022 | );\r | |
1023 | \r | |
c7f33ca4 | 1024 | \r |
3eb9473e | 1025 | /**\r |
c7f33ca4 | 1026 | Convert a Null-terminated ASCII decimal string to a value of type\r |
3eb9473e | 1027 | UINT64.\r |
1028 | \r | |
c7f33ca4 | 1029 | This function returns a value of type UINT64 by interpreting the contents\r |
1030 | of the ASCII string String as a decimal number. The format of the input\r | |
3eb9473e | 1031 | ASCII string String is:\r |
c7f33ca4 | 1032 | \r |
3eb9473e | 1033 | [spaces] [decimal digits].\r |
c7f33ca4 | 1034 | \r |
1035 | The valid decimal digit character is in the range [0-9]. The function will\r | |
1036 | ignore the pad space, which includes spaces or tab characters, before the digits.\r | |
1037 | The running zero in the beginning of [decimal digits] will be ignored. Then, the\r | |
1038 | function stops at the first character that is a not a valid decimal character or\r | |
3eb9473e | 1039 | Null-terminator, whichever on comes first.\r |
c7f33ca4 | 1040 | \r |
3eb9473e | 1041 | If String has only pad spaces, then 0 is returned.\r |
1042 | If String has no pad spaces or valid decimal digits, then 0 is returned.\r | |
c7f33ca4 | 1043 | If the number represented by String overflows according to the range defined by\r |
3eb9473e | 1044 | UINT64, then ASSERT().\r |
1045 | If String is NULL, then ASSERT().\r | |
c7f33ca4 | 1046 | If PcdMaximumAsciiStringLength is not zero, and String contains more than\r |
1047 | PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,\r | |
3eb9473e | 1048 | then ASSERT().\r |
1049 | \r | |
1050 | @param String Pointer to a Null-terminated ASCII string.\r | |
1051 | \r | |
c7f33ca4 | 1052 | @retval UINT64\r |
3eb9473e | 1053 | \r |
1054 | **/\r | |
1055 | UINT64\r | |
1056 | EFIAPI\r | |
1057 | AsciiStrDecimalToUint64 (\r | |
1058 | IN CONST CHAR8 *String\r | |
1059 | );\r | |
1060 | \r | |
c7f33ca4 | 1061 | \r |
3eb9473e | 1062 | /**\r |
1063 | Convert a Null-terminated ASCII hexadecimal string to a value of type UINTN.\r | |
1064 | \r | |
c7f33ca4 | 1065 | This function returns a value of type UINTN by interpreting the contents of\r |
1066 | the ASCII string String as a hexadecimal number. The format of the input ASCII\r | |
3eb9473e | 1067 | string String is:\r |
c7f33ca4 | 1068 | \r |
3eb9473e | 1069 | [spaces][zeros][x][hexadecimal digits].\r |
c7f33ca4 | 1070 | \r |
1071 | The valid hexadecimal digit character is in the range [0-9], [a-f] and [A-F].\r | |
1072 | The prefix "0x" is optional. Both "x" and "X" is allowed in "0x" prefix. If "x"\r | |
1073 | appears in the input string, it must be prefixed with at least one 0. The function\r | |
1074 | will ignore the pad space, which includes spaces or tab characters, before [zeros],\r | |
1075 | [x] or [hexadecimal digits]. The running zero before [x] or [hexadecimal digits]\r | |
1076 | will be ignored. Then, the decoding starts after [x] or the first valid hexadecimal\r | |
1077 | digit. Then, the function stops at the first character that is a not a valid\r | |
3eb9473e | 1078 | hexadecimal character or Null-terminator, whichever on comes first.\r |
c7f33ca4 | 1079 | \r |
3eb9473e | 1080 | If String has only pad spaces, then 0 is returned.\r |
1081 | If String has no leading pad spaces, leading zeros or valid hexadecimal digits, then\r | |
1082 | 0 is returned.\r | |
1083 | \r | |
c7f33ca4 | 1084 | If the number represented by String overflows according to the range defined by UINTN,\r |
3eb9473e | 1085 | then ASSERT().\r |
1086 | If String is NULL, then ASSERT().\r | |
c7f33ca4 | 1087 | If PcdMaximumAsciiStringLength is not zero,\r |
1088 | and String contains more than PcdMaximumAsciiStringLength ASCII characters not including\r | |
3eb9473e | 1089 | the Null-terminator, then ASSERT().\r |
1090 | \r | |
1091 | @param String Pointer to a Null-terminated ASCII string.\r | |
1092 | \r | |
1093 | @retval UINTN\r | |
1094 | \r | |
1095 | **/\r | |
1096 | UINTN\r | |
1097 | EFIAPI\r | |
1098 | AsciiStrHexToUintn (\r | |
1099 | IN CONST CHAR8 *String\r | |
1100 | );\r | |
1101 | \r | |
c7f33ca4 | 1102 | \r |
3eb9473e | 1103 | /**\r |
1104 | Convert a Null-terminated ASCII hexadecimal string to a value of type UINT64.\r | |
1105 | \r | |
c7f33ca4 | 1106 | This function returns a value of type UINT64 by interpreting the contents of\r |
1107 | the ASCII string String as a hexadecimal number. The format of the input ASCII\r | |
3eb9473e | 1108 | string String is:\r |
c7f33ca4 | 1109 | \r |
3eb9473e | 1110 | [spaces][zeros][x][hexadecimal digits].\r |
c7f33ca4 | 1111 | \r |
1112 | The valid hexadecimal digit character is in the range [0-9], [a-f] and [A-F].\r | |
1113 | The prefix "0x" is optional. Both "x" and "X" is allowed in "0x" prefix. If "x"\r | |
1114 | appears in the input string, it must be prefixed with at least one 0. The function\r | |
1115 | will ignore the pad space, which includes spaces or tab characters, before [zeros],\r | |
1116 | [x] or [hexadecimal digits]. The running zero before [x] or [hexadecimal digits]\r | |
1117 | will be ignored. Then, the decoding starts after [x] or the first valid hexadecimal\r | |
1118 | digit. Then, the function stops at the first character that is a not a valid\r | |
3eb9473e | 1119 | hexadecimal character or Null-terminator, whichever on comes first.\r |
c7f33ca4 | 1120 | \r |
3eb9473e | 1121 | If String has only pad spaces, then 0 is returned.\r |
1122 | If String has no leading pad spaces, leading zeros or valid hexadecimal digits, then\r | |
1123 | 0 is returned.\r | |
1124 | \r | |
c7f33ca4 | 1125 | If the number represented by String overflows according to the range defined by UINT64,\r |
3eb9473e | 1126 | then ASSERT().\r |
1127 | If String is NULL, then ASSERT().\r | |
c7f33ca4 | 1128 | If PcdMaximumAsciiStringLength is not zero,\r |
1129 | and String contains more than PcdMaximumAsciiStringLength ASCII characters not including\r | |
3eb9473e | 1130 | the Null-terminator, then ASSERT().\r |
1131 | \r | |
1132 | @param String Pointer to a Null-terminated ASCII string.\r | |
1133 | \r | |
1134 | @retval UINT64\r | |
1135 | \r | |
1136 | **/\r | |
1137 | UINT64\r | |
1138 | EFIAPI\r | |
1139 | AsciiStrHexToUint64 (\r | |
1140 | IN CONST CHAR8 *String\r | |
1141 | );\r | |
1142 | \r | |
c7f33ca4 | 1143 | \r |
3eb9473e | 1144 | /**\r |
c7f33ca4 | 1145 | Convert one Null-terminated ASCII string to a Null-terminated\r |
3eb9473e | 1146 | Unicode string and returns the Unicode string.\r |
1147 | \r | |
c7f33ca4 | 1148 | This function converts the contents of the ASCII string Source to the Unicode\r |
1149 | string Destination, and returns Destination. The function terminates the\r | |
1150 | Unicode string Destination by appending a Null-terminator character at the end.\r | |
1151 | The caller is responsible to make sure Destination points to a buffer with size\r | |
3eb9473e | 1152 | equal or greater than ((AsciiStrLen (Source) + 1) * sizeof (CHAR16)) in bytes.\r |
c7f33ca4 | 1153 | \r |
3eb9473e | 1154 | If Destination is NULL, then ASSERT().\r |
1155 | If Destination is not aligned on a 16-bit boundary, then ASSERT().\r | |
1156 | If Source is NULL, then ASSERT().\r | |
1157 | If Source and Destination overlap, then ASSERT().\r | |
c7f33ca4 | 1158 | If PcdMaximumAsciiStringLength is not zero, and Source contains more than\r |
1159 | PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,\r | |
3eb9473e | 1160 | then ASSERT().\r |
c7f33ca4 | 1161 | If PcdMaximumUnicodeStringLength is not zero, and Source contains more than\r |
1162 | PcdMaximumUnicodeStringLength ASCII characters not including the\r | |
3eb9473e | 1163 | Null-terminator, then ASSERT().\r |
1164 | \r | |
1165 | @param Source Pointer to a Null-terminated ASCII string.\r | |
1166 | @param Destination Pointer to a Null-terminated Unicode string.\r | |
1167 | \r | |
1168 | @reture Destination\r | |
1169 | \r | |
1170 | **/\r | |
1171 | CHAR16 *\r | |
1172 | EFIAPI\r | |
1173 | AsciiStrToUnicodeStr (\r | |
1174 | IN CONST CHAR8 *Source,\r | |
1175 | OUT CHAR16 *Destination\r | |
1176 | );\r | |
1177 | \r | |
c7f33ca4 | 1178 | \r |
3eb9473e | 1179 | /**\r |
1180 | Converts an 8-bit value to an 8-bit BCD value.\r | |
1181 | \r | |
1182 | Converts the 8-bit value specified by Value to BCD. The BCD value is\r | |
1183 | returned.\r | |
1184 | \r | |
1185 | If Value >= 100, then ASSERT().\r | |
1186 | \r | |
1187 | @param Value The 8-bit value to convert to BCD. Range 0..99.\r | |
1188 | \r | |
1189 | @return The BCD value\r | |
1190 | \r | |
1191 | **/\r | |
1192 | UINT8\r | |
1193 | EFIAPI\r | |
1194 | DecimalToBcd8 (\r | |
1195 | IN UINT8 Value\r | |
1196 | );\r | |
1197 | \r | |
c7f33ca4 | 1198 | \r |
3eb9473e | 1199 | /**\r |
1200 | Converts an 8-bit BCD value to an 8-bit value.\r | |
1201 | \r | |
1202 | Converts the 8-bit BCD value specified by Value to an 8-bit value. The 8-bit\r | |
1203 | value is returned.\r | |
1204 | \r | |
1205 | If Value >= 0xA0, then ASSERT().\r | |
1206 | If (Value & 0x0F) >= 0x0A, then ASSERT().\r | |
1207 | \r | |
1208 | @param Value The 8-bit BCD value to convert to an 8-bit value.\r | |
1209 | \r | |
1210 | @return The 8-bit value is returned.\r | |
1211 | \r | |
1212 | **/\r | |
1213 | UINT8\r | |
1214 | EFIAPI\r | |
1215 | BcdToDecimal8 (\r | |
1216 | IN UINT8 Value\r | |
1217 | );\r | |
1218 | \r | |
1219 | //\r | |
1220 | // LIST_ENTRY definition\r | |
1221 | //\r | |
1222 | typedef struct _LIST_ENTRY LIST_ENTRY;\r | |
1223 | \r | |
1224 | struct _LIST_ENTRY {\r | |
1225 | LIST_ENTRY *ForwardLink;\r | |
1226 | LIST_ENTRY *BackLink;\r | |
1227 | };\r | |
1228 | \r | |
1229 | //\r | |
1230 | // Linked List Functions and Macros\r | |
1231 | //\r | |
1232 | \r | |
1233 | /**\r | |
1234 | Initializes the head node of a doubly linked list that is declared as a\r | |
1235 | global variable in a module.\r | |
1236 | \r | |
1237 | Initializes the forward and backward links of a new linked list. After\r | |
1238 | initializing a linked list with this macro, the other linked list functions\r | |
1239 | may be used to add and remove nodes from the linked list. This macro results\r | |
1240 | in smaller executables by initializing the linked list in the data section,\r | |
1241 | instead if calling the InitializeListHead() function to perform the\r | |
1242 | equivalent operation.\r | |
1243 | \r | |
1244 | @param ListHead The head note of a list to initiailize.\r | |
1245 | \r | |
1246 | **/\r | |
1247 | #define INITIALIZE_LIST_HEAD_VARIABLE(ListHead) {&ListHead, &ListHead}\r | |
1248 | \r | |
c7f33ca4 | 1249 | \r |
3eb9473e | 1250 | /**\r |
1251 | Initializes the head node of a doubly linked list, and returns the pointer to\r | |
1252 | the head node of the doubly linked list.\r | |
1253 | \r | |
1254 | Initializes the forward and backward links of a new linked list. After\r | |
1255 | initializing a linked list with this function, the other linked list\r | |
1256 | functions may be used to add and remove nodes from the linked list. It is up\r | |
1257 | to the caller of this function to allocate the memory for ListHead.\r | |
1258 | \r | |
1259 | If ListHead is NULL, then ASSERT().\r | |
1260 | \r | |
1261 | @param ListHead A pointer to the head node of a new doubly linked list.\r | |
1262 | \r | |
1263 | @return ListHead\r | |
1264 | \r | |
1265 | **/\r | |
1266 | LIST_ENTRY *\r | |
1267 | EFIAPI\r | |
1268 | GlueInitializeListHead (\r | |
1269 | IN LIST_ENTRY *ListHead\r | |
1270 | );\r | |
1271 | \r | |
c7f33ca4 | 1272 | \r |
3eb9473e | 1273 | /**\r |
1274 | Adds a node to the beginning of a doubly linked list, and returns the pointer\r | |
1275 | to the head node of the doubly linked list.\r | |
1276 | \r | |
1277 | Adds the node Entry at the beginning of the doubly linked list denoted by\r | |
1278 | ListHead, and returns ListHead.\r | |
1279 | \r | |
1280 | If ListHead is NULL, then ASSERT().\r | |
1281 | If Entry is NULL, then ASSERT().\r | |
1282 | If ListHead was not initialized with InitializeListHead(), then ASSERT().\r | |
1283 | If PcdMaximumLinkedListLenth is not zero, and prior to insertion the number\r | |
1284 | of nodes in ListHead, including the ListHead node, is greater than or\r | |
1285 | equal to PcdMaximumLinkedListLength, then ASSERT().\r | |
1286 | \r | |
1287 | @param ListHead A pointer to the head node of a doubly linked list.\r | |
1288 | @param Entry A pointer to a node that is to be inserted at the beginning\r | |
1289 | of a doubly linked list.\r | |
1290 | \r | |
1291 | @return ListHead\r | |
1292 | \r | |
1293 | **/\r | |
1294 | LIST_ENTRY *\r | |
1295 | EFIAPI\r | |
1296 | GlueInsertHeadList (\r | |
1297 | IN LIST_ENTRY *ListHead,\r | |
1298 | IN LIST_ENTRY *Entry\r | |
1299 | );\r | |
1300 | \r | |
c7f33ca4 | 1301 | \r |
3eb9473e | 1302 | /**\r |
1303 | Adds a node to the end of a doubly linked list, and returns the pointer to\r | |
1304 | the head node of the doubly linked list.\r | |
1305 | \r | |
1306 | Adds the node Entry to the end of the doubly linked list denoted by ListHead,\r | |
1307 | and returns ListHead.\r | |
1308 | \r | |
1309 | If ListHead is NULL, then ASSERT().\r | |
1310 | If Entry is NULL, then ASSERT().\r | |
1311 | If ListHead was not initialized with InitializeListHead(), then ASSERT().\r | |
1312 | If PcdMaximumLinkedListLenth is not zero, and prior to insertion the number\r | |
1313 | of nodes in ListHead, including the ListHead node, is greater than or\r | |
1314 | equal to PcdMaximumLinkedListLength, then ASSERT().\r | |
1315 | \r | |
1316 | @param ListHead A pointer to the head node of a doubly linked list.\r | |
1317 | @param Entry A pointer to a node that is to be added at the end of the\r | |
1318 | doubly linked list.\r | |
1319 | \r | |
1320 | @return ListHead\r | |
1321 | \r | |
1322 | **/\r | |
1323 | LIST_ENTRY *\r | |
1324 | EFIAPI\r | |
1325 | GlueInsertTailList (\r | |
1326 | IN LIST_ENTRY *ListHead,\r | |
1327 | IN LIST_ENTRY *Entry\r | |
1328 | );\r | |
1329 | \r | |
c7f33ca4 | 1330 | \r |
3eb9473e | 1331 | /**\r |
1332 | Retrieves the first node of a doubly linked list.\r | |
1333 | \r | |
1334 | Returns the first node of a doubly linked list. List must have been\r | |
1335 | initialized with InitializeListHead(). If List is empty, then NULL is\r | |
1336 | returned.\r | |
1337 | \r | |
1338 | If List is NULL, then ASSERT().\r | |
1339 | If List was not initialized with InitializeListHead(), then ASSERT().\r | |
1340 | If PcdMaximumLinkedListLenth is not zero, and the number of nodes\r | |
1341 | in List, including the List node, is greater than or equal to\r | |
1342 | PcdMaximumLinkedListLength, then ASSERT().\r | |
1343 | \r | |
1344 | @param List A pointer to the head node of a doubly linked list.\r | |
1345 | \r | |
1346 | @return The first node of a doubly linked list.\r | |
1347 | @retval NULL The list is empty.\r | |
1348 | \r | |
1349 | **/\r | |
1350 | LIST_ENTRY *\r | |
1351 | EFIAPI\r | |
1352 | GlueGetFirstNode (\r | |
1353 | IN CONST LIST_ENTRY *List\r | |
1354 | );\r | |
1355 | \r | |
c7f33ca4 | 1356 | \r |
3eb9473e | 1357 | /**\r |
1358 | Retrieves the next node of a doubly linked list.\r | |
1359 | \r | |
1360 | Returns the node of a doubly linked list that follows Node. List must have\r | |
1361 | been initialized with InitializeListHead(). If List is empty, then List is\r | |
1362 | returned.\r | |
1363 | \r | |
1364 | If List is NULL, then ASSERT().\r | |
1365 | If Node is NULL, then ASSERT().\r | |
1366 | If List was not initialized with InitializeListHead(), then ASSERT().\r | |
1367 | If PcdMaximumLinkedListLenth is not zero, and List contains more than\r | |
1368 | PcdMaximumLinkedListLenth nodes, then ASSERT().\r | |
1369 | If Node is not a node in List, then ASSERT().\r | |
1370 | \r | |
1371 | @param List A pointer to the head node of a doubly linked list.\r | |
1372 | @param Node A pointer to a node in the doubly linked list.\r | |
1373 | \r | |
1374 | @return Pointer to the next node if one exists. Otherwise a null value which\r | |
1375 | is actually List is returned.\r | |
1376 | \r | |
1377 | **/\r | |
1378 | LIST_ENTRY *\r | |
1379 | EFIAPI\r | |
1380 | GlueGetNextNode (\r | |
1381 | IN CONST LIST_ENTRY *List,\r | |
1382 | IN CONST LIST_ENTRY *Node\r | |
1383 | );\r | |
1384 | \r | |
c7f33ca4 | 1385 | \r |
3eb9473e | 1386 | /**\r |
1387 | Checks to see if a doubly linked list is empty or not.\r | |
1388 | \r | |
1389 | Checks to see if the doubly linked list is empty. If the linked list contains\r | |
1390 | zero nodes, this function returns TRUE. Otherwise, it returns FALSE.\r | |
1391 | \r | |
1392 | If ListHead is NULL, then ASSERT().\r | |
1393 | If ListHead was not initialized with InitializeListHead(), then ASSERT().\r | |
1394 | If PcdMaximumLinkedListLenth is not zero, and the number of nodes\r | |
1395 | in List, including the List node, is greater than or equal to\r | |
1396 | PcdMaximumLinkedListLength, then ASSERT().\r | |
1397 | \r | |
1398 | @param ListHead A pointer to the head node of a doubly linked list.\r | |
1399 | \r | |
1400 | @retval TRUE The linked list is empty.\r | |
1401 | @retval FALSE The linked list is not empty.\r | |
1402 | \r | |
1403 | **/\r | |
1404 | BOOLEAN\r | |
1405 | EFIAPI\r | |
1406 | GlueIsListEmpty (\r | |
1407 | IN CONST LIST_ENTRY *ListHead\r | |
1408 | );\r | |
1409 | \r | |
c7f33ca4 | 1410 | \r |
3eb9473e | 1411 | /**\r |
1412 | Determines if a node in a doubly linked list is null.\r | |
1413 | \r | |
1414 | Returns FALSE if Node is one of the nodes in the doubly linked list specified\r | |
1415 | by List. Otherwise, TRUE is returned. List must have been initialized with\r | |
1416 | InitializeListHead().\r | |
1417 | \r | |
1418 | If List is NULL, then ASSERT().\r | |
1419 | If Node is NULL, then ASSERT().\r | |
1420 | If List was not initialized with InitializeListHead(), then ASSERT().\r | |
1421 | If PcdMaximumLinkedListLenth is not zero, and the number of nodes\r | |
1422 | in List, including the List node, is greater than or equal to\r | |
1423 | PcdMaximumLinkedListLength, then ASSERT().\r | |
1424 | If Node is not a node in List and Node is not equal to List, then ASSERT().\r | |
1425 | \r | |
1426 | @param List A pointer to the head node of a doubly linked list.\r | |
1427 | @param Node A pointer to a node in the doubly linked list.\r | |
1428 | \r | |
1429 | @retval TRUE Node is one of the nodes in the doubly linked list.\r | |
1430 | @retval FALSE Node is not one of the nodes in the doubly linked list.\r | |
1431 | \r | |
1432 | **/\r | |
1433 | BOOLEAN\r | |
1434 | EFIAPI\r | |
1435 | GlueIsNull (\r | |
1436 | IN CONST LIST_ENTRY *List,\r | |
1437 | IN CONST LIST_ENTRY *Node\r | |
1438 | );\r | |
1439 | \r | |
c7f33ca4 | 1440 | \r |
3eb9473e | 1441 | /**\r |
1442 | Determines if a node the last node in a doubly linked list.\r | |
1443 | \r | |
1444 | Returns TRUE if Node is the last node in the doubly linked list specified by\r | |
1445 | List. Otherwise, FALSE is returned. List must have been initialized with\r | |
1446 | InitializeListHead().\r | |
1447 | \r | |
1448 | If List is NULL, then ASSERT().\r | |
1449 | If Node is NULL, then ASSERT().\r | |
1450 | If List was not initialized with InitializeListHead(), then ASSERT().\r | |
1451 | If PcdMaximumLinkedListLenth is not zero, and the number of nodes\r | |
1452 | in List, including the List node, is greater than or equal to\r | |
1453 | PcdMaximumLinkedListLength, then ASSERT().\r | |
1454 | If Node is not a node in List, then ASSERT().\r | |
1455 | \r | |
1456 | @param List A pointer to the head node of a doubly linked list.\r | |
1457 | @param Node A pointer to a node in the doubly linked list.\r | |
1458 | \r | |
1459 | @retval TRUE Node is the last node in the linked list.\r | |
1460 | @retval FALSE Node is not the last node in the linked list.\r | |
1461 | \r | |
1462 | **/\r | |
1463 | BOOLEAN\r | |
1464 | EFIAPI\r | |
1465 | GlueIsNodeAtEnd (\r | |
1466 | IN CONST LIST_ENTRY *List,\r | |
1467 | IN CONST LIST_ENTRY *Node\r | |
1468 | );\r | |
1469 | \r | |
c7f33ca4 | 1470 | \r |
3eb9473e | 1471 | /**\r |
1472 | Swaps the location of two nodes in a doubly linked list, and returns the\r | |
1473 | first node after the swap.\r | |
1474 | \r | |
1475 | If FirstEntry is identical to SecondEntry, then SecondEntry is returned.\r | |
1476 | Otherwise, the location of the FirstEntry node is swapped with the location\r | |
1477 | of the SecondEntry node in a doubly linked list. SecondEntry must be in the\r | |
1478 | same double linked list as FirstEntry and that double linked list must have\r | |
1479 | been initialized with InitializeListHead(). SecondEntry is returned after the\r | |
1480 | nodes are swapped.\r | |
1481 | \r | |
1482 | If FirstEntry is NULL, then ASSERT().\r | |
1483 | If SecondEntry is NULL, then ASSERT().\r | |
1484 | If SecondEntry and FirstEntry are not in the same linked list, then ASSERT().\r | |
1485 | If PcdMaximumLinkedListLength is not zero, and the number of nodes in the\r | |
1486 | linked list containing the FirstEntry and SecondEntry nodes, including\r | |
1487 | the FirstEntry and SecondEntry nodes, is greater than or equal to\r | |
1488 | PcdMaximumLinkedListLength, then ASSERT().\r | |
1489 | \r | |
1490 | @param FirstEntry A pointer to a node in a linked list.\r | |
1491 | @param SecondEntry A pointer to another node in the same linked list.\r | |
1492 | \r | |
1493 | **/\r | |
1494 | LIST_ENTRY *\r | |
1495 | EFIAPI\r | |
1496 | GlueSwapListEntries (\r | |
1497 | IN LIST_ENTRY *FirstEntry,\r | |
1498 | IN LIST_ENTRY *SecondEntry\r | |
1499 | );\r | |
1500 | \r | |
c7f33ca4 | 1501 | \r |
3eb9473e | 1502 | /**\r |
1503 | Removes a node from a doubly linked list, and returns the node that follows\r | |
1504 | the removed node.\r | |
1505 | \r | |
1506 | Removes the node Entry from a doubly linked list. It is up to the caller of\r | |
1507 | this function to release the memory used by this node if that is required. On\r | |
1508 | exit, the node following Entry in the doubly linked list is returned. If\r | |
1509 | Entry is the only node in the linked list, then the head node of the linked\r | |
1510 | list is returned.\r | |
1511 | \r | |
1512 | If Entry is NULL, then ASSERT().\r | |
1513 | If Entry is the head node of an empty list, then ASSERT().\r | |
1514 | If PcdMaximumLinkedListLength is not zero, and the number of nodes in the\r | |
1515 | linked list containing Entry, including the Entry node, is greater than\r | |
1516 | or equal to PcdMaximumLinkedListLength, then ASSERT().\r | |
1517 | \r | |
1518 | @param Entry A pointer to a node in a linked list\r | |
1519 | \r | |
1520 | @return Entry\r | |
1521 | \r | |
1522 | **/\r | |
1523 | LIST_ENTRY *\r | |
1524 | EFIAPI\r | |
1525 | GlueRemoveEntryList (\r | |
1526 | IN CONST LIST_ENTRY *Entry\r | |
1527 | );\r | |
1528 | \r | |
1529 | //\r | |
1530 | // Math Services\r | |
1531 | //\r | |
1532 | \r | |
1533 | /**\r | |
1534 | Shifts a 64-bit integer left between 0 and 63 bits. The low bits are filled\r | |
1535 | with zeros. The shifted value is returned.\r | |
1536 | \r | |
1537 | This function shifts the 64-bit value Operand to the left by Count bits. The\r | |
1538 | low Count bits are set to zero. The shifted value is returned.\r | |
1539 | \r | |
1540 | If Count is greater than 63, then ASSERT().\r | |
1541 | \r | |
1542 | @param Operand The 64-bit operand to shift left.\r | |
1543 | @param Count The number of bits to shift left.\r | |
1544 | \r | |
1545 | @return Operand << Count\r | |
1546 | \r | |
1547 | **/\r | |
1548 | UINT64\r | |
1549 | EFIAPI\r | |
1550 | GlueLShiftU64 (\r | |
1551 | IN UINT64 Operand,\r | |
1552 | IN UINTN Count\r | |
1553 | );\r | |
1554 | \r | |
c7f33ca4 | 1555 | \r |
3eb9473e | 1556 | /**\r |
1557 | Shifts a 64-bit integer right between 0 and 63 bits. This high bits are\r | |
1558 | filled with zeros. The shifted value is returned.\r | |
1559 | \r | |
1560 | This function shifts the 64-bit value Operand to the right by Count bits. The\r | |
1561 | high Count bits are set to zero. The shifted value is returned.\r | |
1562 | \r | |
1563 | If Count is greater than 63, then ASSERT().\r | |
1564 | \r | |
1565 | @param Operand The 64-bit operand to shift right.\r | |
1566 | @param Count The number of bits to shift right.\r | |
1567 | \r | |
1568 | @return Operand >> Count\r | |
1569 | \r | |
1570 | **/\r | |
1571 | UINT64\r | |
1572 | EFIAPI\r | |
1573 | GlueRShiftU64 (\r | |
1574 | IN UINT64 Operand,\r | |
1575 | IN UINTN Count\r | |
1576 | );\r | |
1577 | \r | |
c7f33ca4 | 1578 | \r |
3eb9473e | 1579 | /**\r |
1580 | Shifts a 64-bit integer right between 0 and 63 bits. The high bits are filled\r | |
1581 | with original integer's bit 63. The shifted value is returned.\r | |
1582 | \r | |
1583 | This function shifts the 64-bit value Operand to the right by Count bits. The\r | |
1584 | high Count bits are set to bit 63 of Operand. The shifted value is returned.\r | |
1585 | \r | |
1586 | If Count is greater than 63, then ASSERT().\r | |
1587 | \r | |
1588 | @param Operand The 64-bit operand to shift right.\r | |
1589 | @param Count The number of bits to shift right.\r | |
1590 | \r | |
1591 | @return Operand >> Count\r | |
1592 | \r | |
1593 | **/\r | |
1594 | UINT64\r | |
1595 | EFIAPI\r | |
1596 | ARShiftU64 (\r | |
1597 | IN UINT64 Operand,\r | |
1598 | IN UINTN Count\r | |
1599 | );\r | |
1600 | \r | |
c7f33ca4 | 1601 | \r |
3eb9473e | 1602 | /**\r |
1603 | Rotates a 32-bit integer left between 0 and 31 bits, filling the low bits\r | |
1604 | with the high bits that were rotated.\r | |
1605 | \r | |
1606 | This function rotates the 32-bit value Operand to the left by Count bits. The\r | |
1607 | low Count bits are fill with the high Count bits of Operand. The rotated\r | |
1608 | value is returned.\r | |
1609 | \r | |
1610 | If Count is greater than 31, then ASSERT().\r | |
1611 | \r | |
1612 | @param Operand The 32-bit operand to rotate left.\r | |
1613 | @param Count The number of bits to rotate left.\r | |
1614 | \r | |
1615 | @return Operand <<< Count\r | |
1616 | \r | |
1617 | **/\r | |
1618 | UINT32\r | |
1619 | EFIAPI\r | |
1620 | LRotU32 (\r | |
1621 | IN UINT32 Operand,\r | |
1622 | IN UINTN Count\r | |
1623 | );\r | |
1624 | \r | |
c7f33ca4 | 1625 | \r |
3eb9473e | 1626 | /**\r |
1627 | Rotates a 32-bit integer right between 0 and 31 bits, filling the high bits\r | |
1628 | with the low bits that were rotated.\r | |
1629 | \r | |
1630 | This function rotates the 32-bit value Operand to the right by Count bits.\r | |
1631 | The high Count bits are fill with the low Count bits of Operand. The rotated\r | |
1632 | value is returned.\r | |
1633 | \r | |
1634 | If Count is greater than 31, then ASSERT().\r | |
1635 | \r | |
1636 | @param Operand The 32-bit operand to rotate right.\r | |
1637 | @param Count The number of bits to rotate right.\r | |
1638 | \r | |
1639 | @return Operand >>> Count\r | |
1640 | \r | |
1641 | **/\r | |
1642 | UINT32\r | |
1643 | EFIAPI\r | |
1644 | RRotU32 (\r | |
1645 | IN UINT32 Operand,\r | |
1646 | IN UINTN Count\r | |
1647 | );\r | |
1648 | \r | |
c7f33ca4 | 1649 | \r |
3eb9473e | 1650 | /**\r |
1651 | Rotates a 64-bit integer left between 0 and 63 bits, filling the low bits\r | |
1652 | with the high bits that were rotated.\r | |
1653 | \r | |
1654 | This function rotates the 64-bit value Operand to the left by Count bits. The\r | |
1655 | low Count bits are fill with the high Count bits of Operand. The rotated\r | |
1656 | value is returned.\r | |
1657 | \r | |
1658 | If Count is greater than 63, then ASSERT().\r | |
1659 | \r | |
1660 | @param Operand The 64-bit operand to rotate left.\r | |
1661 | @param Count The number of bits to rotate left.\r | |
1662 | \r | |
1663 | @return Operand <<< Count\r | |
1664 | \r | |
1665 | **/\r | |
1666 | UINT64\r | |
1667 | EFIAPI\r | |
1668 | LRotU64 (\r | |
1669 | IN UINT64 Operand,\r | |
1670 | IN UINTN Count\r | |
1671 | );\r | |
1672 | \r | |
c7f33ca4 | 1673 | \r |
3eb9473e | 1674 | /**\r |
1675 | Rotates a 64-bit integer right between 0 and 63 bits, filling the high bits\r | |
1676 | with the high low bits that were rotated.\r | |
1677 | \r | |
1678 | This function rotates the 64-bit value Operand to the right by Count bits.\r | |
1679 | The high Count bits are fill with the low Count bits of Operand. The rotated\r | |
1680 | value is returned.\r | |
1681 | \r | |
1682 | If Count is greater than 63, then ASSERT().\r | |
1683 | \r | |
1684 | @param Operand The 64-bit operand to rotate right.\r | |
1685 | @param Count The number of bits to rotate right.\r | |
1686 | \r | |
1687 | @return Operand >>> Count\r | |
1688 | \r | |
1689 | **/\r | |
1690 | UINT64\r | |
1691 | EFIAPI\r | |
1692 | RRotU64 (\r | |
1693 | IN UINT64 Operand,\r | |
1694 | IN UINTN Count\r | |
1695 | );\r | |
1696 | \r | |
c7f33ca4 | 1697 | \r |
3eb9473e | 1698 | /**\r |
1699 | Returns the bit position of the lowest bit set in a 32-bit value.\r | |
1700 | \r | |
1701 | This function computes the bit position of the lowest bit set in the 32-bit\r | |
1702 | value specified by Operand. If Operand is zero, then -1 is returned.\r | |
1703 | Otherwise, a value between 0 and 31 is returned.\r | |
1704 | \r | |
1705 | @param Operand The 32-bit operand to evaluate.\r | |
1706 | \r | |
1707 | @return Position of the lowest bit set in Operand if found.\r | |
1708 | @retval -1 Operand is zero.\r | |
1709 | \r | |
1710 | **/\r | |
1711 | INTN\r | |
1712 | EFIAPI\r | |
1713 | LowBitSet32 (\r | |
1714 | IN UINT32 Operand\r | |
1715 | );\r | |
1716 | \r | |
c7f33ca4 | 1717 | \r |
3eb9473e | 1718 | /**\r |
1719 | Returns the bit position of the lowest bit set in a 64-bit value.\r | |
1720 | \r | |
1721 | This function computes the bit position of the lowest bit set in the 64-bit\r | |
1722 | value specified by Operand. If Operand is zero, then -1 is returned.\r | |
1723 | Otherwise, a value between 0 and 63 is returned.\r | |
1724 | \r | |
1725 | @param Operand The 64-bit operand to evaluate.\r | |
1726 | \r | |
1727 | @return Position of the lowest bit set in Operand if found.\r | |
1728 | @retval -1 Operand is zero.\r | |
1729 | \r | |
1730 | **/\r | |
1731 | INTN\r | |
1732 | EFIAPI\r | |
1733 | LowBitSet64 (\r | |
1734 | IN UINT64 Operand\r | |
1735 | );\r | |
1736 | \r | |
c7f33ca4 | 1737 | \r |
3eb9473e | 1738 | /**\r |
1739 | Returns the bit position of the highest bit set in a 32-bit value. Equivalent\r | |
1740 | to log2(x).\r | |
1741 | \r | |
1742 | This function computes the bit position of the highest bit set in the 32-bit\r | |
1743 | value specified by Operand. If Operand is zero, then -1 is returned.\r | |
1744 | Otherwise, a value between 0 and 31 is returned.\r | |
1745 | \r | |
1746 | @param Operand The 32-bit operand to evaluate.\r | |
1747 | \r | |
1748 | @return Position of the highest bit set in Operand if found.\r | |
1749 | @retval -1 Operand is zero.\r | |
1750 | \r | |
1751 | **/\r | |
1752 | INTN\r | |
1753 | EFIAPI\r | |
1754 | HighBitSet32 (\r | |
1755 | IN UINT32 Operand\r | |
1756 | );\r | |
1757 | \r | |
c7f33ca4 | 1758 | \r |
3eb9473e | 1759 | /**\r |
1760 | Returns the bit position of the highest bit set in a 64-bit value. Equivalent\r | |
1761 | to log2(x).\r | |
1762 | \r | |
1763 | This function computes the bit position of the highest bit set in the 64-bit\r | |
1764 | value specified by Operand. If Operand is zero, then -1 is returned.\r | |
1765 | Otherwise, a value between 0 and 63 is returned.\r | |
1766 | \r | |
1767 | @param Operand The 64-bit operand to evaluate.\r | |
1768 | \r | |
1769 | @return Position of the highest bit set in Operand if found.\r | |
1770 | @retval -1 Operand is zero.\r | |
1771 | \r | |
1772 | **/\r | |
1773 | INTN\r | |
1774 | EFIAPI\r | |
1775 | HighBitSet64 (\r | |
1776 | IN UINT64 Operand\r | |
1777 | );\r | |
1778 | \r | |
c7f33ca4 | 1779 | \r |
3eb9473e | 1780 | /**\r |
1781 | Returns the value of the highest bit set in a 32-bit value. Equivalent to\r | |
1782 | 1 << HighBitSet32(x).\r | |
1783 | \r | |
1784 | This function computes the value of the highest bit set in the 32-bit value\r | |
1785 | specified by Operand. If Operand is zero, then zero is returned.\r | |
1786 | \r | |
1787 | @param Operand The 32-bit operand to evaluate.\r | |
1788 | \r | |
1789 | @return 1 << HighBitSet32(Operand)\r | |
1790 | @retval 0 Operand is zero.\r | |
1791 | \r | |
1792 | **/\r | |
1793 | UINT32\r | |
1794 | EFIAPI\r | |
1795 | GetPowerOfTwo32 (\r | |
1796 | IN UINT32 Operand\r | |
1797 | );\r | |
1798 | \r | |
c7f33ca4 | 1799 | \r |
3eb9473e | 1800 | /**\r |
1801 | Returns the value of the highest bit set in a 64-bit value. Equivalent to\r | |
1802 | 1 << HighBitSet64(x).\r | |
1803 | \r | |
1804 | This function computes the value of the highest bit set in the 64-bit value\r | |
1805 | specified by Operand. If Operand is zero, then zero is returned.\r | |
1806 | \r | |
1807 | @param Operand The 64-bit operand to evaluate.\r | |
1808 | \r | |
1809 | @return 1 << HighBitSet64(Operand)\r | |
1810 | @retval 0 Operand is zero.\r | |
1811 | \r | |
1812 | **/\r | |
1813 | UINT64\r | |
1814 | EFIAPI\r | |
1815 | GetPowerOfTwo64 (\r | |
1816 | IN UINT64 Operand\r | |
1817 | );\r | |
1818 | \r | |
c7f33ca4 | 1819 | \r |
3eb9473e | 1820 | /**\r |
1821 | Switches the endianess of a 16-bit integer.\r | |
1822 | \r | |
1823 | This function swaps the bytes in a 16-bit unsigned value to switch the value\r | |
1824 | from little endian to big endian or vice versa. The byte swapped value is\r | |
1825 | returned.\r | |
1826 | \r | |
1827 | @param Operand A 16-bit unsigned value.\r | |
1828 | \r | |
1829 | @return The byte swaped Operand.\r | |
1830 | \r | |
1831 | **/\r | |
1832 | UINT16\r | |
1833 | EFIAPI\r | |
1834 | SwapBytes16 (\r | |
1835 | IN UINT16 Value\r | |
1836 | );\r | |
1837 | \r | |
c7f33ca4 | 1838 | \r |
3eb9473e | 1839 | /**\r |
1840 | Switches the endianess of a 32-bit integer.\r | |
1841 | \r | |
1842 | This function swaps the bytes in a 32-bit unsigned value to switch the value\r | |
1843 | from little endian to big endian or vice versa. The byte swapped value is\r | |
1844 | returned.\r | |
1845 | \r | |
1846 | @param Operand A 32-bit unsigned value.\r | |
1847 | \r | |
1848 | @return The byte swaped Operand.\r | |
1849 | \r | |
1850 | **/\r | |
1851 | UINT32\r | |
1852 | EFIAPI\r | |
1853 | SwapBytes32 (\r | |
1854 | IN UINT32 Value\r | |
1855 | );\r | |
1856 | \r | |
c7f33ca4 | 1857 | \r |
3eb9473e | 1858 | /**\r |
1859 | Switches the endianess of a 64-bit integer.\r | |
1860 | \r | |
1861 | This function swaps the bytes in a 64-bit unsigned value to switch the value\r | |
1862 | from little endian to big endian or vice versa. The byte swapped value is\r | |
1863 | returned.\r | |
1864 | \r | |
1865 | @param Operand A 64-bit unsigned value.\r | |
1866 | \r | |
1867 | @return The byte swaped Operand.\r | |
1868 | \r | |
1869 | **/\r | |
1870 | UINT64\r | |
1871 | EFIAPI\r | |
1872 | SwapBytes64 (\r | |
1873 | IN UINT64 Value\r | |
1874 | );\r | |
1875 | \r | |
c7f33ca4 | 1876 | \r |
3eb9473e | 1877 | /**\r |
1878 | Multiples a 64-bit unsigned integer by a 32-bit unsigned integer and\r | |
1879 | generates a 64-bit unsigned result.\r | |
1880 | \r | |
1881 | This function multiples the 64-bit unsigned value Multiplicand by the 32-bit\r | |
1882 | unsigned value Multiplier and generates a 64-bit unsigned result. This 64-\r | |
1883 | bit unsigned result is returned.\r | |
1884 | \r | |
1885 | If the result overflows, then ASSERT().\r | |
1886 | \r | |
1887 | @param Multiplicand A 64-bit unsigned value.\r | |
1888 | @param Multiplier A 32-bit unsigned value.\r | |
1889 | \r | |
1890 | @return Multiplicand * Multiplier\r | |
1891 | \r | |
1892 | **/\r | |
1893 | UINT64\r | |
1894 | EFIAPI\r | |
1895 | GlueMultU64x32 (\r | |
1896 | IN UINT64 Multiplicand,\r | |
1897 | IN UINT32 Multiplier\r | |
1898 | );\r | |
1899 | \r | |
c7f33ca4 | 1900 | \r |
3eb9473e | 1901 | /**\r |
1902 | Multiples a 64-bit unsigned integer by a 64-bit unsigned integer and\r | |
1903 | generates a 64-bit unsigned result.\r | |
1904 | \r | |
1905 | This function multiples the 64-bit unsigned value Multiplicand by the 64-bit\r | |
1906 | unsigned value Multiplier and generates a 64-bit unsigned result. This 64-\r | |
1907 | bit unsigned result is returned.\r | |
1908 | \r | |
1909 | If the result overflows, then ASSERT().\r | |
1910 | \r | |
1911 | @param Multiplicand A 64-bit unsigned value.\r | |
1912 | @param Multiplier A 64-bit unsigned value.\r | |
1913 | \r | |
1914 | @return Multiplicand * Multiplier\r | |
1915 | \r | |
1916 | **/\r | |
1917 | UINT64\r | |
1918 | EFIAPI\r | |
1919 | MultU64x64 (\r | |
1920 | IN UINT64 Multiplicand,\r | |
1921 | IN UINT64 Multiplier\r | |
1922 | );\r | |
1923 | \r | |
c7f33ca4 | 1924 | \r |
3eb9473e | 1925 | /**\r |
1926 | Multiples a 64-bit signed integer by a 64-bit signed integer and generates a\r | |
1927 | 64-bit signed result.\r | |
1928 | \r | |
1929 | This function multiples the 64-bit signed value Multiplicand by the 64-bit\r | |
1930 | signed value Multiplier and generates a 64-bit signed result. This 64-bit\r | |
1931 | signed result is returned.\r | |
1932 | \r | |
1933 | If the result overflows, then ASSERT().\r | |
1934 | \r | |
1935 | @param Multiplicand A 64-bit signed value.\r | |
1936 | @param Multiplier A 64-bit signed value.\r | |
1937 | \r | |
1938 | @return Multiplicand * Multiplier\r | |
1939 | \r | |
1940 | **/\r | |
1941 | INT64\r | |
1942 | EFIAPI\r | |
1943 | MultS64x64 (\r | |
1944 | IN INT64 Multiplicand,\r | |
1945 | IN INT64 Multiplier\r | |
1946 | );\r | |
1947 | \r | |
c7f33ca4 | 1948 | \r |
3eb9473e | 1949 | /**\r |
1950 | Divides a 64-bit unsigned integer by a 32-bit unsigned integer and generates\r | |
1951 | a 64-bit unsigned result.\r | |
1952 | \r | |
1953 | This function divides the 64-bit unsigned value Dividend by the 32-bit\r | |
1954 | unsigned value Divisor and generates a 64-bit unsigned quotient. This\r | |
1955 | function returns the 64-bit unsigned quotient.\r | |
1956 | \r | |
1957 | If Divisor is 0, then ASSERT().\r | |
1958 | \r | |
1959 | @param Dividend A 64-bit unsigned value.\r | |
1960 | @param Divisor A 32-bit unsigned value.\r | |
1961 | \r | |
1962 | @return Dividend / Divisor\r | |
1963 | \r | |
1964 | **/\r | |
1965 | UINT64\r | |
1966 | EFIAPI\r | |
1967 | GlueDivU64x32 (\r | |
1968 | IN UINT64 Dividend,\r | |
1969 | IN UINT32 Divisor\r | |
1970 | );\r | |
1971 | \r | |
c7f33ca4 | 1972 | \r |
3eb9473e | 1973 | /**\r |
1974 | Divides a 64-bit unsigned integer by a 32-bit unsigned integer and generates\r | |
1975 | a 32-bit unsigned remainder.\r | |
1976 | \r | |
1977 | This function divides the 64-bit unsigned value Dividend by the 32-bit\r | |
1978 | unsigned value Divisor and generates a 32-bit remainder. This function\r | |
1979 | returns the 32-bit unsigned remainder.\r | |
1980 | \r | |
1981 | If Divisor is 0, then ASSERT().\r | |
1982 | \r | |
1983 | @param Dividend A 64-bit unsigned value.\r | |
1984 | @param Divisor A 32-bit unsigned value.\r | |
1985 | \r | |
1986 | @return Dividend % Divisor\r | |
1987 | \r | |
1988 | **/\r | |
1989 | UINT32\r | |
1990 | EFIAPI\r | |
1991 | ModU64x32 (\r | |
1992 | IN UINT64 Dividend,\r | |
1993 | IN UINT32 Divisor\r | |
1994 | );\r | |
1995 | \r | |
c7f33ca4 | 1996 | \r |
3eb9473e | 1997 | /**\r |
1998 | Divides a 64-bit unsigned integer by a 32-bit unsigned integer and generates\r | |
1999 | a 64-bit unsigned result and an optional 32-bit unsigned remainder.\r | |
2000 | \r | |
2001 | This function divides the 64-bit unsigned value Dividend by the 32-bit\r | |
2002 | unsigned value Divisor and generates a 64-bit unsigned quotient. If Remainder\r | |
2003 | is not NULL, then the 32-bit unsigned remainder is returned in Remainder.\r | |
2004 | This function returns the 64-bit unsigned quotient.\r | |
2005 | \r | |
2006 | If Divisor is 0, then ASSERT().\r | |
2007 | \r | |
2008 | @param Dividend A 64-bit unsigned value.\r | |
2009 | @param Divisor A 32-bit unsigned value.\r | |
2010 | @param Remainder A pointer to a 32-bit unsigned value. This parameter is\r | |
2011 | optional and may be NULL.\r | |
2012 | \r | |
2013 | @return Dividend / Divisor\r | |
2014 | \r | |
2015 | **/\r | |
2016 | UINT64\r | |
2017 | EFIAPI\r | |
2018 | DivU64x32Remainder (\r | |
2019 | IN UINT64 Dividend,\r | |
2020 | IN UINT32 Divisor,\r | |
2021 | OUT UINT32 *Remainder OPTIONAL\r | |
2022 | );\r | |
2023 | \r | |
c7f33ca4 | 2024 | \r |
3eb9473e | 2025 | /**\r |
2026 | Divides a 64-bit unsigned integer by a 64-bit unsigned integer and generates\r | |
2027 | a 64-bit unsigned result and an optional 64-bit unsigned remainder.\r | |
2028 | \r | |
2029 | This function divides the 64-bit unsigned value Dividend by the 64-bit\r | |
2030 | unsigned value Divisor and generates a 64-bit unsigned quotient. If Remainder\r | |
2031 | is not NULL, then the 64-bit unsigned remainder is returned in Remainder.\r | |
2032 | This function returns the 64-bit unsigned quotient.\r | |
2033 | \r | |
2034 | If Divisor is 0, then ASSERT().\r | |
2035 | \r | |
2036 | @param Dividend A 64-bit unsigned value.\r | |
2037 | @param Divisor A 64-bit unsigned value.\r | |
2038 | @param Remainder A pointer to a 64-bit unsigned value. This parameter is\r | |
2039 | optional and may be NULL.\r | |
2040 | \r | |
2041 | @return Dividend / Divisor\r | |
2042 | \r | |
2043 | **/\r | |
2044 | UINT64\r | |
2045 | EFIAPI\r | |
2046 | DivU64x64Remainder (\r | |
2047 | IN UINT64 Dividend,\r | |
2048 | IN UINT64 Divisor,\r | |
2049 | OUT UINT64 *Remainder OPTIONAL\r | |
2050 | );\r | |
2051 | \r | |
c7f33ca4 | 2052 | \r |
3eb9473e | 2053 | /**\r |
2054 | Divides a 64-bit signed integer by a 64-bit signed integer and generates a\r | |
2055 | 64-bit signed result and a optional 64-bit signed remainder.\r | |
2056 | \r | |
2057 | This function divides the 64-bit signed value Dividend by the 64-bit signed\r | |
2058 | value Divisor and generates a 64-bit signed quotient. If Remainder is not\r | |
2059 | NULL, then the 64-bit signed remainder is returned in Remainder. This\r | |
2060 | function returns the 64-bit signed quotient.\r | |
2061 | \r | |
2062 | If Divisor is 0, then ASSERT().\r | |
2063 | \r | |
2064 | @param Dividend A 64-bit signed value.\r | |
2065 | @param Divisor A 64-bit signed value.\r | |
2066 | @param Remainder A pointer to a 64-bit signed value. This parameter is\r | |
2067 | optional and may be NULL.\r | |
2068 | \r | |
2069 | @return Dividend / Divisor\r | |
2070 | \r | |
2071 | **/\r | |
2072 | INT64\r | |
2073 | EFIAPI\r | |
2074 | DivS64x64Remainder (\r | |
2075 | IN INT64 Dividend,\r | |
2076 | IN INT64 Divisor,\r | |
2077 | OUT INT64 *Remainder OPTIONAL\r | |
2078 | );\r | |
2079 | \r | |
c7f33ca4 | 2080 | \r |
3eb9473e | 2081 | /**\r |
2082 | Reads a 16-bit value from memory that may be unaligned.\r | |
2083 | \r | |
2084 | This function returns the 16-bit value pointed to by Buffer. The function\r | |
2085 | guarantees that the read operation does not produce an alignment fault.\r | |
2086 | \r | |
2087 | If the Buffer is NULL, then ASSERT().\r | |
2088 | \r | |
2089 | @param Buffer Pointer to a 16-bit value that may be unaligned.\r | |
2090 | \r | |
2091 | @return *Uint16\r | |
2092 | \r | |
2093 | **/\r | |
2094 | UINT16\r | |
2095 | EFIAPI\r | |
2096 | ReadUnaligned16 (\r | |
2097 | IN CONST UINT16 *Uint16\r | |
2098 | );\r | |
2099 | \r | |
c7f33ca4 | 2100 | \r |
3eb9473e | 2101 | /**\r |
2102 | Writes a 16-bit value to memory that may be unaligned.\r | |
2103 | \r | |
2104 | This function writes the 16-bit value specified by Value to Buffer. Value is\r | |
2105 | returned. The function guarantees that the write operation does not produce\r | |
2106 | an alignment fault.\r | |
2107 | \r | |
2108 | If the Buffer is NULL, then ASSERT().\r | |
2109 | \r | |
2110 | @param Buffer Pointer to a 16-bit value that may be unaligned.\r | |
2111 | @param Value 16-bit value to write to Buffer.\r | |
2112 | \r | |
2113 | @return Value\r | |
2114 | \r | |
2115 | **/\r | |
2116 | UINT16\r | |
2117 | EFIAPI\r | |
2118 | WriteUnaligned16 (\r | |
2119 | OUT UINT16 *Uint16,\r | |
2120 | IN UINT16 Value\r | |
2121 | );\r | |
2122 | \r | |
c7f33ca4 | 2123 | \r |
3eb9473e | 2124 | /**\r |
2125 | Reads a 24-bit value from memory that may be unaligned.\r | |
2126 | \r | |
2127 | This function returns the 24-bit value pointed to by Buffer. The function\r | |
2128 | guarantees that the read operation does not produce an alignment fault.\r | |
2129 | \r | |
2130 | If the Buffer is NULL, then ASSERT().\r | |
2131 | \r | |
2132 | @param Buffer Pointer to a 24-bit value that may be unaligned.\r | |
2133 | \r | |
2134 | @return The value read.\r | |
2135 | \r | |
2136 | **/\r | |
2137 | UINT32\r | |
2138 | EFIAPI\r | |
2139 | ReadUnaligned24 (\r | |
2140 | IN CONST UINT32 *Buffer\r | |
2141 | );\r | |
2142 | \r | |
c7f33ca4 | 2143 | \r |
3eb9473e | 2144 | /**\r |
2145 | Writes a 24-bit value to memory that may be unaligned.\r | |
2146 | \r | |
2147 | This function writes the 24-bit value specified by Value to Buffer. Value is\r | |
2148 | returned. The function guarantees that the write operation does not produce\r | |
2149 | an alignment fault.\r | |
2150 | \r | |
2151 | If the Buffer is NULL, then ASSERT().\r | |
2152 | \r | |
2153 | @param Buffer Pointer to a 24-bit value that may be unaligned.\r | |
2154 | @param Value 24-bit value to write to Buffer.\r | |
2155 | \r | |
2156 | @return The value written.\r | |
2157 | \r | |
2158 | **/\r | |
2159 | UINT32\r | |
2160 | EFIAPI\r | |
2161 | WriteUnaligned24 (\r | |
2162 | OUT UINT32 *Buffer,\r | |
2163 | IN UINT32 Value\r | |
2164 | );\r | |
2165 | \r | |
c7f33ca4 | 2166 | \r |
3eb9473e | 2167 | /**\r |
2168 | Reads a 32-bit value from memory that may be unaligned.\r | |
2169 | \r | |
2170 | This function returns the 32-bit value pointed to by Buffer. The function\r | |
2171 | guarantees that the read operation does not produce an alignment fault.\r | |
2172 | \r | |
2173 | If the Buffer is NULL, then ASSERT().\r | |
2174 | \r | |
2175 | @param Buffer Pointer to a 32-bit value that may be unaligned.\r | |
2176 | \r | |
2177 | @return *Uint32\r | |
2178 | \r | |
2179 | **/\r | |
2180 | UINT32\r | |
2181 | EFIAPI\r | |
2182 | ReadUnaligned32 (\r | |
2183 | IN CONST UINT32 *Uint32\r | |
2184 | );\r | |
2185 | \r | |
c7f33ca4 | 2186 | \r |
3eb9473e | 2187 | /**\r |
2188 | Writes a 32-bit value to memory that may be unaligned.\r | |
2189 | \r | |
2190 | This function writes the 32-bit value specified by Value to Buffer. Value is\r | |
2191 | returned. The function guarantees that the write operation does not produce\r | |
2192 | an alignment fault.\r | |
2193 | \r | |
2194 | If the Buffer is NULL, then ASSERT().\r | |
2195 | \r | |
2196 | @param Buffer Pointer to a 32-bit value that may be unaligned.\r | |
2197 | @param Value 32-bit value to write to Buffer.\r | |
2198 | \r | |
2199 | @return Value\r | |
2200 | \r | |
2201 | **/\r | |
2202 | UINT32\r | |
2203 | EFIAPI\r | |
2204 | WriteUnaligned32 (\r | |
2205 | OUT UINT32 *Uint32,\r | |
2206 | IN UINT32 Value\r | |
2207 | );\r | |
2208 | \r | |
c7f33ca4 | 2209 | \r |
3eb9473e | 2210 | /**\r |
2211 | Reads a 64-bit value from memory that may be unaligned.\r | |
2212 | \r | |
2213 | This function returns the 64-bit value pointed to by Buffer. The function\r | |
2214 | guarantees that the read operation does not produce an alignment fault.\r | |
2215 | \r | |
2216 | If the Buffer is NULL, then ASSERT().\r | |
2217 | \r | |
2218 | @param Buffer Pointer to a 64-bit value that may be unaligned.\r | |
2219 | \r | |
2220 | @return *Uint64\r | |
2221 | \r | |
2222 | **/\r | |
2223 | UINT64\r | |
2224 | EFIAPI\r | |
2225 | ReadUnaligned64 (\r | |
2226 | IN CONST UINT64 *Uint64\r | |
2227 | );\r | |
2228 | \r | |
c7f33ca4 | 2229 | \r |
3eb9473e | 2230 | /**\r |
2231 | Writes a 64-bit value to memory that may be unaligned.\r | |
2232 | \r | |
2233 | This function writes the 64-bit value specified by Value to Buffer. Value is\r | |
2234 | returned. The function guarantees that the write operation does not produce\r | |
2235 | an alignment fault.\r | |
2236 | \r | |
2237 | If the Buffer is NULL, then ASSERT().\r | |
2238 | \r | |
2239 | @param Buffer Pointer to a 64-bit value that may be unaligned.\r | |
2240 | @param Value 64-bit value to write to Buffer.\r | |
2241 | \r | |
2242 | @return Value\r | |
2243 | \r | |
2244 | **/\r | |
2245 | UINT64\r | |
2246 | EFIAPI\r | |
2247 | WriteUnaligned64 (\r | |
2248 | OUT UINT64 *Uint64,\r | |
2249 | IN UINT64 Value\r | |
2250 | );\r | |
2251 | \r | |
c7f33ca4 | 2252 | \r |
3eb9473e | 2253 | //\r |
2254 | // Bit Field Functions\r | |
2255 | //\r | |
2256 | \r | |
2257 | /**\r | |
2258 | Returns a bit field from an 8-bit value.\r | |
2259 | \r | |
2260 | Returns the bitfield specified by the StartBit and the EndBit from Operand.\r | |
2261 | \r | |
2262 | If 8-bit operations are not supported, then ASSERT().\r | |
2263 | If StartBit is greater than 7, then ASSERT().\r | |
2264 | If EndBit is greater than 7, then ASSERT().\r | |
2265 | If EndBit is less than StartBit, then ASSERT().\r | |
2266 | \r | |
2267 | @param Operand Operand on which to perform the bitfield operation.\r | |
2268 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
2269 | Range 0..7.\r | |
2270 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
2271 | Range 0..7.\r | |
2272 | \r | |
2273 | @return The bit field read.\r | |
2274 | \r | |
2275 | **/\r | |
2276 | UINT8\r | |
2277 | EFIAPI\r | |
2278 | BitFieldRead8 (\r | |
2279 | IN UINT8 Operand,\r | |
2280 | IN UINTN StartBit,\r | |
2281 | IN UINTN EndBit\r | |
2282 | );\r | |
2283 | \r | |
c7f33ca4 | 2284 | \r |
3eb9473e | 2285 | /**\r |
2286 | Writes a bit field to an 8-bit value, and returns the result.\r | |
2287 | \r | |
2288 | Writes Value to the bit field specified by the StartBit and the EndBit in\r | |
2289 | Operand. All other bits in Operand are preserved. The new 8-bit value is\r | |
2290 | returned.\r | |
2291 | \r | |
2292 | If 8-bit operations are not supported, then ASSERT().\r | |
2293 | If StartBit is greater than 7, then ASSERT().\r | |
2294 | If EndBit is greater than 7, then ASSERT().\r | |
2295 | If EndBit is less than StartBit, then ASSERT().\r | |
2296 | \r | |
2297 | @param Operand Operand on which to perform the bitfield operation.\r | |
2298 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
2299 | Range 0..7.\r | |
2300 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
2301 | Range 0..7.\r | |
2302 | @param Value New value of the bit field.\r | |
2303 | \r | |
2304 | @return The new 8-bit value.\r | |
2305 | \r | |
2306 | **/\r | |
2307 | UINT8\r | |
2308 | EFIAPI\r | |
2309 | BitFieldWrite8 (\r | |
2310 | IN UINT8 Operand,\r | |
2311 | IN UINTN StartBit,\r | |
2312 | IN UINTN EndBit,\r | |
2313 | IN UINT8 Value\r | |
2314 | );\r | |
2315 | \r | |
c7f33ca4 | 2316 | \r |
3eb9473e | 2317 | /**\r |
2318 | Reads a bit field from an 8-bit value, performs a bitwise OR, and returns the\r | |
2319 | result.\r | |
2320 | \r | |
2321 | Performs a bitwise inclusive OR between the bit field specified by StartBit\r | |
2322 | and EndBit in Operand and the value specified by OrData. All other bits in\r | |
2323 | Operand are preserved. The new 8-bit value is returned.\r | |
2324 | \r | |
2325 | If 8-bit operations are not supported, then ASSERT().\r | |
2326 | If StartBit is greater than 7, then ASSERT().\r | |
2327 | If EndBit is greater than 7, then ASSERT().\r | |
2328 | If EndBit is less than StartBit, then ASSERT().\r | |
2329 | \r | |
2330 | @param Operand Operand on which to perform the bitfield operation.\r | |
2331 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
2332 | Range 0..7.\r | |
2333 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
2334 | Range 0..7.\r | |
2335 | @param OrData The value to OR with the read value from the value\r | |
2336 | \r | |
2337 | @return The new 8-bit value.\r | |
2338 | \r | |
2339 | **/\r | |
2340 | UINT8\r | |
2341 | EFIAPI\r | |
2342 | BitFieldOr8 (\r | |
2343 | IN UINT8 Operand,\r | |
2344 | IN UINTN StartBit,\r | |
2345 | IN UINTN EndBit,\r | |
2346 | IN UINT8 OrData\r | |
2347 | );\r | |
2348 | \r | |
c7f33ca4 | 2349 | \r |
3eb9473e | 2350 | /**\r |
2351 | Reads a bit field from an 8-bit value, performs a bitwise AND, and returns\r | |
2352 | the result.\r | |
2353 | \r | |
2354 | Performs a bitwise AND between the bit field specified by StartBit and EndBit\r | |
2355 | in Operand and the value specified by AndData. All other bits in Operand are\r | |
2356 | preserved. The new 8-bit value is returned.\r | |
2357 | \r | |
2358 | If 8-bit operations are not supported, then ASSERT().\r | |
2359 | If StartBit is greater than 7, then ASSERT().\r | |
2360 | If EndBit is greater than 7, then ASSERT().\r | |
2361 | If EndBit is less than StartBit, then ASSERT().\r | |
2362 | \r | |
2363 | @param Operand Operand on which to perform the bitfield operation.\r | |
2364 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
2365 | Range 0..7.\r | |
2366 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
2367 | Range 0..7.\r | |
2368 | @param AndData The value to AND with the read value from the value.\r | |
2369 | \r | |
2370 | @return The new 8-bit value.\r | |
2371 | \r | |
2372 | **/\r | |
2373 | UINT8\r | |
2374 | EFIAPI\r | |
2375 | BitFieldAnd8 (\r | |
2376 | IN UINT8 Operand,\r | |
2377 | IN UINTN StartBit,\r | |
2378 | IN UINTN EndBit,\r | |
2379 | IN UINT8 AndData\r | |
2380 | );\r | |
2381 | \r | |
c7f33ca4 | 2382 | \r |
3eb9473e | 2383 | /**\r |
2384 | Reads a bit field from an 8-bit value, performs a bitwise AND followed by a\r | |
2385 | bitwise OR, and returns the result.\r | |
2386 | \r | |
2387 | Performs a bitwise AND between the bit field specified by StartBit and EndBit\r | |
2388 | in Operand and the value specified by AndData, followed by a bitwise\r | |
2389 | inclusive OR with value specified by OrData. All other bits in Operand are\r | |
2390 | preserved. The new 8-bit value is returned.\r | |
2391 | \r | |
2392 | If 8-bit operations are not supported, then ASSERT().\r | |
2393 | If StartBit is greater than 7, then ASSERT().\r | |
2394 | If EndBit is greater than 7, then ASSERT().\r | |
2395 | If EndBit is less than StartBit, then ASSERT().\r | |
2396 | \r | |
2397 | @param Operand Operand on which to perform the bitfield operation.\r | |
2398 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
2399 | Range 0..7.\r | |
2400 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
2401 | Range 0..7.\r | |
2402 | @param AndData The value to AND with the read value from the value.\r | |
2403 | @param OrData The value to OR with the result of the AND operation.\r | |
2404 | \r | |
2405 | @return The new 8-bit value.\r | |
2406 | \r | |
2407 | **/\r | |
2408 | UINT8\r | |
2409 | EFIAPI\r | |
2410 | BitFieldAndThenOr8 (\r | |
2411 | IN UINT8 Operand,\r | |
2412 | IN UINTN StartBit,\r | |
2413 | IN UINTN EndBit,\r | |
2414 | IN UINT8 AndData,\r | |
2415 | IN UINT8 OrData\r | |
2416 | );\r | |
2417 | \r | |
c7f33ca4 | 2418 | \r |
3eb9473e | 2419 | /**\r |
2420 | Returns a bit field from a 16-bit value.\r | |
2421 | \r | |
2422 | Returns the bitfield specified by the StartBit and the EndBit from Operand.\r | |
2423 | \r | |
2424 | If 16-bit operations are not supported, then ASSERT().\r | |
2425 | If StartBit is greater than 15, then ASSERT().\r | |
2426 | If EndBit is greater than 15, then ASSERT().\r | |
2427 | If EndBit is less than StartBit, then ASSERT().\r | |
2428 | \r | |
2429 | @param Operand Operand on which to perform the bitfield operation.\r | |
2430 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
2431 | Range 0..15.\r | |
2432 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
2433 | Range 0..15.\r | |
2434 | \r | |
2435 | @return The bit field read.\r | |
2436 | \r | |
2437 | **/\r | |
2438 | UINT16\r | |
2439 | EFIAPI\r | |
2440 | BitFieldRead16 (\r | |
2441 | IN UINT16 Operand,\r | |
2442 | IN UINTN StartBit,\r | |
2443 | IN UINTN EndBit\r | |
2444 | );\r | |
2445 | \r | |
c7f33ca4 | 2446 | \r |
3eb9473e | 2447 | /**\r |
2448 | Writes a bit field to a 16-bit value, and returns the result.\r | |
2449 | \r | |
2450 | Writes Value to the bit field specified by the StartBit and the EndBit in\r | |
2451 | Operand. All other bits in Operand are preserved. The new 16-bit value is\r | |
2452 | returned.\r | |
2453 | \r | |
2454 | If 16-bit operations are not supported, then ASSERT().\r | |
2455 | If StartBit is greater than 15, then ASSERT().\r | |
2456 | If EndBit is greater than 15, then ASSERT().\r | |
2457 | If EndBit is less than StartBit, then ASSERT().\r | |
2458 | \r | |
2459 | @param Operand Operand on which to perform the bitfield operation.\r | |
2460 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
2461 | Range 0..15.\r | |
2462 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
2463 | Range 0..15.\r | |
2464 | @param Value New value of the bit field.\r | |
2465 | \r | |
2466 | @return The new 16-bit value.\r | |
2467 | \r | |
2468 | **/\r | |
2469 | UINT16\r | |
2470 | EFIAPI\r | |
2471 | BitFieldWrite16 (\r | |
2472 | IN UINT16 Operand,\r | |
2473 | IN UINTN StartBit,\r | |
2474 | IN UINTN EndBit,\r | |
2475 | IN UINT16 Value\r | |
2476 | );\r | |
2477 | \r | |
c7f33ca4 | 2478 | \r |
3eb9473e | 2479 | /**\r |
2480 | Reads a bit field from a 16-bit value, performs a bitwise OR, and returns the\r | |
2481 | result.\r | |
2482 | \r | |
2483 | Performs a bitwise inclusive OR between the bit field specified by StartBit\r | |
2484 | and EndBit in Operand and the value specified by OrData. All other bits in\r | |
2485 | Operand are preserved. The new 16-bit value is returned.\r | |
2486 | \r | |
2487 | If 16-bit operations are not supported, then ASSERT().\r | |
2488 | If StartBit is greater than 15, then ASSERT().\r | |
2489 | If EndBit is greater than 15, then ASSERT().\r | |
2490 | If EndBit is less than StartBit, then ASSERT().\r | |
2491 | \r | |
2492 | @param Operand Operand on which to perform the bitfield operation.\r | |
2493 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
2494 | Range 0..15.\r | |
2495 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
2496 | Range 0..15.\r | |
2497 | @param OrData The value to OR with the read value from the value\r | |
2498 | \r | |
2499 | @return The new 16-bit value.\r | |
2500 | \r | |
2501 | **/\r | |
2502 | UINT16\r | |
2503 | EFIAPI\r | |
2504 | BitFieldOr16 (\r | |
2505 | IN UINT16 Operand,\r | |
2506 | IN UINTN StartBit,\r | |
2507 | IN UINTN EndBit,\r | |
2508 | IN UINT16 OrData\r | |
2509 | );\r | |
2510 | \r | |
c7f33ca4 | 2511 | \r |
3eb9473e | 2512 | /**\r |
2513 | Reads a bit field from a 16-bit value, performs a bitwise AND, and returns\r | |
2514 | the result.\r | |
2515 | \r | |
2516 | Performs a bitwise AND between the bit field specified by StartBit and EndBit\r | |
2517 | in Operand and the value specified by AndData. All other bits in Operand are\r | |
2518 | preserved. The new 16-bit value is returned.\r | |
2519 | \r | |
2520 | If 16-bit operations are not supported, then ASSERT().\r | |
2521 | If StartBit is greater than 15, then ASSERT().\r | |
2522 | If EndBit is greater than 15, then ASSERT().\r | |
2523 | If EndBit is less than StartBit, then ASSERT().\r | |
2524 | \r | |
2525 | @param Operand Operand on which to perform the bitfield operation.\r | |
2526 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
2527 | Range 0..15.\r | |
2528 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
2529 | Range 0..15.\r | |
2530 | @param AndData The value to AND with the read value from the value\r | |
2531 | \r | |
2532 | @return The new 16-bit value.\r | |
2533 | \r | |
2534 | **/\r | |
2535 | UINT16\r | |
2536 | EFIAPI\r | |
2537 | BitFieldAnd16 (\r | |
2538 | IN UINT16 Operand,\r | |
2539 | IN UINTN StartBit,\r | |
2540 | IN UINTN EndBit,\r | |
2541 | IN UINT16 AndData\r | |
2542 | );\r | |
2543 | \r | |
c7f33ca4 | 2544 | \r |
3eb9473e | 2545 | /**\r |
2546 | Reads a bit field from a 16-bit value, performs a bitwise AND followed by a\r | |
2547 | bitwise OR, and returns the result.\r | |
2548 | \r | |
2549 | Performs a bitwise AND between the bit field specified by StartBit and EndBit\r | |
2550 | in Operand and the value specified by AndData, followed by a bitwise\r | |
2551 | inclusive OR with value specified by OrData. All other bits in Operand are\r | |
2552 | preserved. The new 16-bit value is returned.\r | |
2553 | \r | |
2554 | If 16-bit operations are not supported, then ASSERT().\r | |
2555 | If StartBit is greater than 15, then ASSERT().\r | |
2556 | If EndBit is greater than 15, then ASSERT().\r | |
2557 | If EndBit is less than StartBit, then ASSERT().\r | |
2558 | \r | |
2559 | @param Operand Operand on which to perform the bitfield operation.\r | |
2560 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
2561 | Range 0..15.\r | |
2562 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
2563 | Range 0..15.\r | |
2564 | @param AndData The value to AND with the read value from the value.\r | |
2565 | @param OrData The value to OR with the result of the AND operation.\r | |
2566 | \r | |
2567 | @return The new 16-bit value.\r | |
2568 | \r | |
2569 | **/\r | |
2570 | UINT16\r | |
2571 | EFIAPI\r | |
2572 | BitFieldAndThenOr16 (\r | |
2573 | IN UINT16 Operand,\r | |
2574 | IN UINTN StartBit,\r | |
2575 | IN UINTN EndBit,\r | |
2576 | IN UINT16 AndData,\r | |
2577 | IN UINT16 OrData\r | |
2578 | );\r | |
2579 | \r | |
c7f33ca4 | 2580 | \r |
3eb9473e | 2581 | /**\r |
2582 | Returns a bit field from a 32-bit value.\r | |
2583 | \r | |
2584 | Returns the bitfield specified by the StartBit and the EndBit from Operand.\r | |
2585 | \r | |
2586 | If 32-bit operations are not supported, then ASSERT().\r | |
2587 | If StartBit is greater than 31, then ASSERT().\r | |
2588 | If EndBit is greater than 31, then ASSERT().\r | |
2589 | If EndBit is less than StartBit, then ASSERT().\r | |
2590 | \r | |
2591 | @param Operand Operand on which to perform the bitfield operation.\r | |
2592 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
2593 | Range 0..31.\r | |
2594 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
2595 | Range 0..31.\r | |
2596 | \r | |
2597 | @return The bit field read.\r | |
2598 | \r | |
2599 | **/\r | |
2600 | UINT32\r | |
2601 | EFIAPI\r | |
2602 | BitFieldRead32 (\r | |
2603 | IN UINT32 Operand,\r | |
2604 | IN UINTN StartBit,\r | |
2605 | IN UINTN EndBit\r | |
2606 | );\r | |
2607 | \r | |
c7f33ca4 | 2608 | \r |
3eb9473e | 2609 | /**\r |
2610 | Writes a bit field to a 32-bit value, and returns the result.\r | |
2611 | \r | |
2612 | Writes Value to the bit field specified by the StartBit and the EndBit in\r | |
2613 | Operand. All other bits in Operand are preserved. The new 32-bit value is\r | |
2614 | returned.\r | |
2615 | \r | |
2616 | If 32-bit operations are not supported, then ASSERT().\r | |
2617 | If StartBit is greater than 31, then ASSERT().\r | |
2618 | If EndBit is greater than 31, then ASSERT().\r | |
2619 | If EndBit is less than StartBit, then ASSERT().\r | |
2620 | \r | |
2621 | @param Operand Operand on which to perform the bitfield operation.\r | |
2622 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
2623 | Range 0..31.\r | |
2624 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
2625 | Range 0..31.\r | |
2626 | @param Value New value of the bit field.\r | |
2627 | \r | |
2628 | @return The new 32-bit value.\r | |
2629 | \r | |
2630 | **/\r | |
2631 | UINT32\r | |
2632 | EFIAPI\r | |
2633 | BitFieldWrite32 (\r | |
2634 | IN UINT32 Operand,\r | |
2635 | IN UINTN StartBit,\r | |
2636 | IN UINTN EndBit,\r | |
2637 | IN UINT32 Value\r | |
2638 | );\r | |
2639 | \r | |
c7f33ca4 | 2640 | \r |
3eb9473e | 2641 | /**\r |
2642 | Reads a bit field from a 32-bit value, performs a bitwise OR, and returns the\r | |
2643 | result.\r | |
2644 | \r | |
2645 | Performs a bitwise inclusive OR between the bit field specified by StartBit\r | |
2646 | and EndBit in Operand and the value specified by OrData. All other bits in\r | |
2647 | Operand are preserved. The new 32-bit value is returned.\r | |
2648 | \r | |
2649 | If 32-bit operations are not supported, then ASSERT().\r | |
2650 | If StartBit is greater than 31, then ASSERT().\r | |
2651 | If EndBit is greater than 31, then ASSERT().\r | |
2652 | If EndBit is less than StartBit, then ASSERT().\r | |
2653 | \r | |
2654 | @param Operand Operand on which to perform the bitfield operation.\r | |
2655 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
2656 | Range 0..31.\r | |
2657 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
2658 | Range 0..31.\r | |
2659 | @param OrData The value to OR with the read value from the value\r | |
2660 | \r | |
2661 | @return The new 32-bit value.\r | |
2662 | \r | |
2663 | **/\r | |
2664 | UINT32\r | |
2665 | EFIAPI\r | |
2666 | BitFieldOr32 (\r | |
2667 | IN UINT32 Operand,\r | |
2668 | IN UINTN StartBit,\r | |
2669 | IN UINTN EndBit,\r | |
2670 | IN UINT32 OrData\r | |
2671 | );\r | |
2672 | \r | |
c7f33ca4 | 2673 | \r |
3eb9473e | 2674 | /**\r |
2675 | Reads a bit field from a 32-bit value, performs a bitwise AND, and returns\r | |
2676 | the result.\r | |
2677 | \r | |
2678 | Performs a bitwise AND between the bit field specified by StartBit and EndBit\r | |
2679 | in Operand and the value specified by AndData. All other bits in Operand are\r | |
2680 | preserved. The new 32-bit value is returned.\r | |
2681 | \r | |
2682 | If 32-bit operations are not supported, then ASSERT().\r | |
2683 | If StartBit is greater than 31, then ASSERT().\r | |
2684 | If EndBit is greater than 31, then ASSERT().\r | |
2685 | If EndBit is less than StartBit, then ASSERT().\r | |
2686 | \r | |
2687 | @param Operand Operand on which to perform the bitfield operation.\r | |
2688 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
2689 | Range 0..31.\r | |
2690 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
2691 | Range 0..31.\r | |
2692 | @param AndData The value to AND with the read value from the value\r | |
2693 | \r | |
2694 | @return The new 32-bit value.\r | |
2695 | \r | |
2696 | **/\r | |
2697 | UINT32\r | |
2698 | EFIAPI\r | |
2699 | BitFieldAnd32 (\r | |
2700 | IN UINT32 Operand,\r | |
2701 | IN UINTN StartBit,\r | |
2702 | IN UINTN EndBit,\r | |
2703 | IN UINT32 AndData\r | |
2704 | );\r | |
2705 | \r | |
c7f33ca4 | 2706 | \r |
3eb9473e | 2707 | /**\r |
2708 | Reads a bit field from a 32-bit value, performs a bitwise AND followed by a\r | |
2709 | bitwise OR, and returns the result.\r | |
2710 | \r | |
2711 | Performs a bitwise AND between the bit field specified by StartBit and EndBit\r | |
2712 | in Operand and the value specified by AndData, followed by a bitwise\r | |
2713 | inclusive OR with value specified by OrData. All other bits in Operand are\r | |
2714 | preserved. The new 32-bit value is returned.\r | |
2715 | \r | |
2716 | If 32-bit operations are not supported, then ASSERT().\r | |
2717 | If StartBit is greater than 31, then ASSERT().\r | |
2718 | If EndBit is greater than 31, then ASSERT().\r | |
2719 | If EndBit is less than StartBit, then ASSERT().\r | |
2720 | \r | |
2721 | @param Operand Operand on which to perform the bitfield operation.\r | |
2722 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
2723 | Range 0..31.\r | |
2724 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
2725 | Range 0..31.\r | |
2726 | @param AndData The value to AND with the read value from the value.\r | |
2727 | @param OrData The value to OR with the result of the AND operation.\r | |
2728 | \r | |
2729 | @return The new 32-bit value.\r | |
2730 | \r | |
2731 | **/\r | |
2732 | UINT32\r | |
2733 | EFIAPI\r | |
2734 | BitFieldAndThenOr32 (\r | |
2735 | IN UINT32 Operand,\r | |
2736 | IN UINTN StartBit,\r | |
2737 | IN UINTN EndBit,\r | |
2738 | IN UINT32 AndData,\r | |
2739 | IN UINT32 OrData\r | |
2740 | );\r | |
2741 | \r | |
c7f33ca4 | 2742 | \r |
3eb9473e | 2743 | /**\r |
2744 | Returns a bit field from a 64-bit value.\r | |
2745 | \r | |
2746 | Returns the bitfield specified by the StartBit and the EndBit from Operand.\r | |
2747 | \r | |
2748 | If 64-bit operations are not supported, then ASSERT().\r | |
2749 | If StartBit is greater than 63, then ASSERT().\r | |
2750 | If EndBit is greater than 63, then ASSERT().\r | |
2751 | If EndBit is less than StartBit, then ASSERT().\r | |
2752 | \r | |
2753 | @param Operand Operand on which to perform the bitfield operation.\r | |
2754 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
2755 | Range 0..63.\r | |
2756 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
2757 | Range 0..63.\r | |
2758 | \r | |
2759 | @return The bit field read.\r | |
2760 | \r | |
2761 | **/\r | |
2762 | UINT64\r | |
2763 | EFIAPI\r | |
2764 | BitFieldRead64 (\r | |
2765 | IN UINT64 Operand,\r | |
2766 | IN UINTN StartBit,\r | |
2767 | IN UINTN EndBit\r | |
2768 | );\r | |
2769 | \r | |
c7f33ca4 | 2770 | \r |
3eb9473e | 2771 | /**\r |
2772 | Writes a bit field to a 64-bit value, and returns the result.\r | |
2773 | \r | |
2774 | Writes Value to the bit field specified by the StartBit and the EndBit in\r | |
2775 | Operand. All other bits in Operand are preserved. The new 64-bit value is\r | |
2776 | returned.\r | |
2777 | \r | |
2778 | If 64-bit operations are not supported, then ASSERT().\r | |
2779 | If StartBit is greater than 63, then ASSERT().\r | |
2780 | If EndBit is greater than 63, then ASSERT().\r | |
2781 | If EndBit is less than StartBit, then ASSERT().\r | |
2782 | \r | |
2783 | @param Operand Operand on which to perform the bitfield operation.\r | |
2784 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
2785 | Range 0..63.\r | |
2786 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
2787 | Range 0..63.\r | |
2788 | @param Value New value of the bit field.\r | |
2789 | \r | |
2790 | @return The new 64-bit value.\r | |
2791 | \r | |
2792 | **/\r | |
2793 | UINT64\r | |
2794 | EFIAPI\r | |
2795 | BitFieldWrite64 (\r | |
2796 | IN UINT64 Operand,\r | |
2797 | IN UINTN StartBit,\r | |
2798 | IN UINTN EndBit,\r | |
2799 | IN UINT64 Value\r | |
2800 | );\r | |
2801 | \r | |
c7f33ca4 | 2802 | \r |
3eb9473e | 2803 | /**\r |
2804 | Reads a bit field from a 64-bit value, performs a bitwise OR, and returns the\r | |
2805 | result.\r | |
2806 | \r | |
2807 | Performs a bitwise inclusive OR between the bit field specified by StartBit\r | |
2808 | and EndBit in Operand and the value specified by OrData. All other bits in\r | |
2809 | Operand are preserved. The new 64-bit value is returned.\r | |
2810 | \r | |
2811 | If 64-bit operations are not supported, then ASSERT().\r | |
2812 | If StartBit is greater than 63, then ASSERT().\r | |
2813 | If EndBit is greater than 63, then ASSERT().\r | |
2814 | If EndBit is less than StartBit, then ASSERT().\r | |
2815 | \r | |
2816 | @param Operand Operand on which to perform the bitfield operation.\r | |
2817 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
2818 | Range 0..63.\r | |
2819 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
2820 | Range 0..63.\r | |
2821 | @param OrData The value to OR with the read value from the value\r | |
2822 | \r | |
2823 | @return The new 64-bit value.\r | |
2824 | \r | |
2825 | **/\r | |
2826 | UINT64\r | |
2827 | EFIAPI\r | |
2828 | BitFieldOr64 (\r | |
2829 | IN UINT64 Operand,\r | |
2830 | IN UINTN StartBit,\r | |
2831 | IN UINTN EndBit,\r | |
2832 | IN UINT64 OrData\r | |
2833 | );\r | |
2834 | \r | |
c7f33ca4 | 2835 | \r |
3eb9473e | 2836 | /**\r |
2837 | Reads a bit field from a 64-bit value, performs a bitwise AND, and returns\r | |
2838 | the result.\r | |
2839 | \r | |
2840 | Performs a bitwise AND between the bit field specified by StartBit and EndBit\r | |
2841 | in Operand and the value specified by AndData. All other bits in Operand are\r | |
2842 | preserved. The new 64-bit value is returned.\r | |
2843 | \r | |
2844 | If 64-bit operations are not supported, then ASSERT().\r | |
2845 | If StartBit is greater than 63, then ASSERT().\r | |
2846 | If EndBit is greater than 63, then ASSERT().\r | |
2847 | If EndBit is less than StartBit, then ASSERT().\r | |
2848 | \r | |
2849 | @param Operand Operand on which to perform the bitfield operation.\r | |
2850 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
2851 | Range 0..63.\r | |
2852 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
2853 | Range 0..63.\r | |
2854 | @param AndData The value to AND with the read value from the value\r | |
2855 | \r | |
2856 | @return The new 64-bit value.\r | |
2857 | \r | |
2858 | **/\r | |
2859 | UINT64\r | |
2860 | EFIAPI\r | |
2861 | BitFieldAnd64 (\r | |
2862 | IN UINT64 Operand,\r | |
2863 | IN UINTN StartBit,\r | |
2864 | IN UINTN EndBit,\r | |
2865 | IN UINT64 AndData\r | |
2866 | );\r | |
2867 | \r | |
c7f33ca4 | 2868 | \r |
3eb9473e | 2869 | /**\r |
2870 | Reads a bit field from a 64-bit value, performs a bitwise AND followed by a\r | |
2871 | bitwise OR, and returns the result.\r | |
2872 | \r | |
2873 | Performs a bitwise AND between the bit field specified by StartBit and EndBit\r | |
2874 | in Operand and the value specified by AndData, followed by a bitwise\r | |
2875 | inclusive OR with value specified by OrData. All other bits in Operand are\r | |
2876 | preserved. The new 64-bit value is returned.\r | |
2877 | \r | |
2878 | If 64-bit operations are not supported, then ASSERT().\r | |
2879 | If StartBit is greater than 63, then ASSERT().\r | |
2880 | If EndBit is greater than 63, then ASSERT().\r | |
2881 | If EndBit is less than StartBit, then ASSERT().\r | |
2882 | \r | |
2883 | @param Operand Operand on which to perform the bitfield operation.\r | |
2884 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
2885 | Range 0..63.\r | |
2886 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
2887 | Range 0..63.\r | |
2888 | @param AndData The value to AND with the read value from the value.\r | |
2889 | @param OrData The value to OR with the result of the AND operation.\r | |
2890 | \r | |
2891 | @return The new 64-bit value.\r | |
2892 | \r | |
2893 | **/\r | |
2894 | UINT64\r | |
2895 | EFIAPI\r | |
2896 | BitFieldAndThenOr64 (\r | |
2897 | IN UINT64 Operand,\r | |
2898 | IN UINTN StartBit,\r | |
2899 | IN UINTN EndBit,\r | |
2900 | IN UINT64 AndData,\r | |
2901 | IN UINT64 OrData\r | |
2902 | );\r | |
2903 | \r | |
c7f33ca4 | 2904 | \r |
3eb9473e | 2905 | //\r |
2906 | // Base Library Synchronization Functions\r | |
2907 | //\r | |
2908 | \r | |
2909 | /**\r | |
2910 | Retrieves the architecture specific spin lock alignment requirements for\r | |
2911 | optimal spin lock performance.\r | |
2912 | \r | |
2913 | This function retrieves the spin lock alignment requirements for optimal\r | |
2914 | performance on a given CPU architecture. The spin lock alignment must be a\r | |
2915 | power of two and is returned by this function. If there are no alignment\r | |
2916 | requirements, then 1 must be returned. The spin lock synchronization\r | |
2917 | functions must function correctly if the spin lock size and alignment values\r | |
2918 | returned by this function are not used at all. These values are hints to the\r | |
2919 | consumers of the spin lock synchronization functions to obtain optimal spin\r | |
2920 | lock performance.\r | |
2921 | \r | |
2922 | @return The architecture specific spin lock alignment.\r | |
2923 | \r | |
2924 | **/\r | |
2925 | UINTN\r | |
2926 | EFIAPI\r | |
2927 | GetSpinLockProperties (\r | |
2928 | VOID\r | |
2929 | );\r | |
2930 | \r | |
c7f33ca4 | 2931 | \r |
3eb9473e | 2932 | /**\r |
2933 | Initializes a spin lock to the released state and returns the spin lock.\r | |
2934 | \r | |
2935 | This function initializes the spin lock specified by SpinLock to the released\r | |
2936 | state, and returns SpinLock. Optimal performance can be achieved by calling\r | |
2937 | GetSpinLockProperties() to determine the size and alignment requirements for\r | |
2938 | SpinLock.\r | |
2939 | \r | |
2940 | If SpinLock is NULL, then ASSERT().\r | |
2941 | \r | |
2942 | @param SpinLock A pointer to the spin lock to initialize to the released\r | |
2943 | state.\r | |
2944 | \r | |
2945 | @return SpinLock\r | |
2946 | \r | |
2947 | **/\r | |
2948 | SPIN_LOCK *\r | |
2949 | EFIAPI\r | |
2950 | InitializeSpinLock (\r | |
2951 | IN SPIN_LOCK *SpinLock\r | |
2952 | );\r | |
2953 | \r | |
c7f33ca4 | 2954 | \r |
3eb9473e | 2955 | /**\r |
2956 | Waits until a spin lock can be placed in the acquired state.\r | |
2957 | \r | |
2958 | This function checks the state of the spin lock specified by SpinLock. If\r | |
2959 | SpinLock is in the released state, then this function places SpinLock in the\r | |
2960 | acquired state and returns SpinLock. Otherwise, this function waits\r | |
2961 | indefinitely for the spin lock to be released, and then places it in the\r | |
2962 | acquired state and returns SpinLock. All state transitions of SpinLock must\r | |
2963 | be performed using MP safe mechanisms.\r | |
2964 | \r | |
2965 | If SpinLock is NULL, then ASSERT().\r | |
2966 | If SpinLock was not initialized with InitializeSpinLock(), then ASSERT().\r | |
2967 | If PcdSpinLockTimeout is not zero, and SpinLock is can not be acquired in\r | |
2968 | PcdSpinLockTimeout microseconds, then ASSERT().\r | |
2969 | \r | |
2970 | @param SpinLock A pointer to the spin lock to place in the acquired state.\r | |
2971 | \r | |
2972 | @return SpinLock\r | |
2973 | \r | |
2974 | **/\r | |
2975 | SPIN_LOCK *\r | |
2976 | EFIAPI\r | |
2977 | AcquireSpinLock (\r | |
2978 | IN SPIN_LOCK *SpinLock\r | |
2979 | );\r | |
2980 | \r | |
c7f33ca4 | 2981 | \r |
3eb9473e | 2982 | /**\r |
2983 | Attempts to place a spin lock in the acquired state.\r | |
2984 | \r | |
2985 | This function checks the state of the spin lock specified by SpinLock. If\r | |
2986 | SpinLock is in the released state, then this function places SpinLock in the\r | |
2987 | acquired state and returns TRUE. Otherwise, FALSE is returned. All state\r | |
2988 | transitions of SpinLock must be performed using MP safe mechanisms.\r | |
2989 | \r | |
2990 | If SpinLock is NULL, then ASSERT().\r | |
2991 | If SpinLock was not initialized with InitializeSpinLock(), then ASSERT().\r | |
2992 | \r | |
2993 | @param SpinLock A pointer to the spin lock to place in the acquired state.\r | |
2994 | \r | |
2995 | @retval TRUE SpinLock was placed in the acquired state.\r | |
2996 | @retval FALSE SpinLock could not be acquired.\r | |
2997 | \r | |
2998 | **/\r | |
2999 | BOOLEAN\r | |
3000 | EFIAPI\r | |
3001 | AcquireSpinLockOrFail (\r | |
3002 | IN SPIN_LOCK *SpinLock\r | |
3003 | );\r | |
3004 | \r | |
c7f33ca4 | 3005 | \r |
3eb9473e | 3006 | /**\r |
3007 | Releases a spin lock.\r | |
3008 | \r | |
3009 | This function places the spin lock specified by SpinLock in the release state\r | |
3010 | and returns SpinLock.\r | |
3011 | \r | |
3012 | If SpinLock is NULL, then ASSERT().\r | |
3013 | If SpinLock was not initialized with InitializeSpinLock(), then ASSERT().\r | |
3014 | \r | |
3015 | @param SpinLock A pointer to the spin lock to release.\r | |
3016 | \r | |
3017 | @return SpinLock\r | |
3018 | \r | |
3019 | **/\r | |
3020 | SPIN_LOCK *\r | |
3021 | EFIAPI\r | |
3022 | ReleaseSpinLock (\r | |
3023 | IN SPIN_LOCK *SpinLock\r | |
3024 | );\r | |
3025 | \r | |
c7f33ca4 | 3026 | \r |
3eb9473e | 3027 | /**\r |
3028 | Performs an atomic increment of an 32-bit unsigned integer.\r | |
3029 | \r | |
3030 | Performs an atomic increment of the 32-bit unsigned integer specified by\r | |
3031 | Value and returns the incremented value. The increment operation must be\r | |
3032 | performed using MP safe mechanisms. The state of the return value is not\r | |
3033 | guaranteed to be MP safe.\r | |
3034 | \r | |
3035 | If Value is NULL, then ASSERT().\r | |
3036 | \r | |
3037 | @param Value A pointer to the 32-bit value to increment.\r | |
3038 | \r | |
3039 | @return The incremented value.\r | |
3040 | \r | |
3041 | **/\r | |
3042 | UINT32\r | |
3043 | EFIAPI\r | |
3044 | InterlockedIncrement (\r | |
3045 | IN UINT32 *Value\r | |
3046 | );\r | |
3047 | \r | |
c7f33ca4 | 3048 | \r |
3eb9473e | 3049 | /**\r |
3050 | Performs an atomic decrement of an 32-bit unsigned integer.\r | |
3051 | \r | |
3052 | Performs an atomic decrement of the 32-bit unsigned integer specified by\r | |
3053 | Value and returns the decremented value. The decrement operation must be\r | |
3054 | performed using MP safe mechanisms. The state of the return value is not\r | |
3055 | guaranteed to be MP safe.\r | |
3056 | \r | |
3057 | If Value is NULL, then ASSERT().\r | |
3058 | \r | |
3059 | @param Value A pointer to the 32-bit value to decrement.\r | |
3060 | \r | |
3061 | @return The decremented value.\r | |
3062 | \r | |
3063 | **/\r | |
3064 | UINT32\r | |
3065 | EFIAPI\r | |
3066 | InterlockedDecrement (\r | |
3067 | IN UINT32 *Value\r | |
3068 | );\r | |
3069 | \r | |
c7f33ca4 | 3070 | \r |
3eb9473e | 3071 | /**\r |
3072 | Performs an atomic compare exchange operation on a 32-bit unsigned integer.\r | |
3073 | \r | |
3074 | Performs an atomic compare exchange operation on the 32-bit unsigned integer\r | |
3075 | specified by Value. If Value is equal to CompareValue, then Value is set to\r | |
3076 | ExchangeValue and CompareValue is returned. If Value is not equal to CompareValue,\r | |
3077 | then Value is returned. The compare exchange operation must be performed using\r | |
3078 | MP safe mechanisms.\r | |
3079 | \r | |
3080 | If Value is NULL, then ASSERT().\r | |
3081 | \r | |
3082 | @param Value A pointer to the 32-bit value for the compare exchange\r | |
3083 | operation.\r | |
3084 | @param CompareValue 32-bit value used in compare operation.\r | |
3085 | @param ExchangeValue 32-bit value used in exchange operation.\r | |
3086 | \r | |
3087 | @return The original *Value before exchange.\r | |
3088 | \r | |
3089 | **/\r | |
3090 | UINT32\r | |
3091 | EFIAPI\r | |
3092 | InterlockedCompareExchange32 (\r | |
3093 | IN OUT UINT32 *Value,\r | |
3094 | IN UINT32 CompareValue,\r | |
3095 | IN UINT32 ExchangeValue\r | |
3096 | );\r | |
3097 | \r | |
c7f33ca4 | 3098 | \r |
3eb9473e | 3099 | /**\r |
3100 | Performs an atomic compare exchange operation on a 64-bit unsigned integer.\r | |
3101 | \r | |
3102 | Performs an atomic compare exchange operation on the 64-bit unsigned integer specified\r | |
3103 | by Value. If Value is equal to CompareValue, then Value is set to ExchangeValue and\r | |
3104 | CompareValue is returned. If Value is not equal to CompareValue, then Value is returned.\r | |
3105 | The compare exchange operation must be performed using MP safe mechanisms.\r | |
3106 | \r | |
3107 | If Value is NULL, then ASSERT().\r | |
3108 | \r | |
3109 | @param Value A pointer to the 64-bit value for the compare exchange\r | |
3110 | operation.\r | |
3111 | @param CompareValue 64-bit value used in compare operation.\r | |
3112 | @param ExchangeValue 64-bit value used in exchange operation.\r | |
3113 | \r | |
3114 | @return The original *Value before exchange.\r | |
3115 | \r | |
3116 | **/\r | |
3117 | UINT64\r | |
3118 | EFIAPI\r | |
3119 | InterlockedCompareExchange64 (\r | |
3120 | IN OUT UINT64 *Value,\r | |
3121 | IN UINT64 CompareValue,\r | |
3122 | IN UINT64 ExchangeValue\r | |
3123 | );\r | |
3124 | \r | |
c7f33ca4 | 3125 | \r |
3eb9473e | 3126 | /**\r |
3127 | Performs an atomic compare exchange operation on a pointer value.\r | |
3128 | \r | |
3129 | Performs an atomic compare exchange operation on the pointer value specified\r | |
3130 | by Value. If Value is equal to CompareValue, then Value is set to\r | |
3131 | ExchangeValue and CompareValue is returned. If Value is not equal to\r | |
3132 | CompareValue, then Value is returned. The compare exchange operation must be\r | |
3133 | performed using MP safe mechanisms.\r | |
3134 | \r | |
3135 | If Value is NULL, then ASSERT().\r | |
3136 | \r | |
3137 | @param Value A pointer to the pointer value for the compare exchange\r | |
3138 | operation.\r | |
3139 | @param CompareValue Pointer value used in compare operation.\r | |
3140 | @param ExchangeValue Pointer value used in exchange operation.\r | |
3141 | \r | |
3142 | **/\r | |
3143 | VOID *\r | |
3144 | EFIAPI\r | |
3145 | InterlockedCompareExchangePointer (\r | |
3146 | IN OUT VOID **Value,\r | |
3147 | IN VOID *CompareValue,\r | |
3148 | IN VOID *ExchangeValue\r | |
3149 | );\r | |
3150 | \r | |
c7f33ca4 | 3151 | \r |
3eb9473e | 3152 | //\r |
3153 | // Base Library Checksum Functions\r | |
3154 | //\r | |
3155 | \r | |
3156 | /**\r | |
c7f33ca4 | 3157 | Calculate the sum of all elements in a buffer in unit of UINT8.\r |
3eb9473e | 3158 | During calculation, the carry bits are dropped.\r |
3159 | \r | |
c7f33ca4 | 3160 | This function calculates the sum of all elements in a buffer\r |
3161 | in unit of UINT8. The carry bits in result of addition are dropped.\r | |
3162 | The result is returned as UINT8. If Length is Zero, then Zero is\r | |
3eb9473e | 3163 | returned.\r |
c7f33ca4 | 3164 | \r |
3eb9473e | 3165 | If Buffer is NULL, then ASSERT().\r |
c7f33ca4 | 3166 | If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().\r |
3eb9473e | 3167 | \r |
3168 | @param Buffer Pointer to the buffer to carry out the sum operation.\r | |
3169 | @param Length The size, in bytes, of Buffer .\r | |
3170 | \r | |
3171 | @return Sum The sum of Buffer with carry bits dropped during additions.\r | |
3172 | \r | |
3173 | **/\r | |
3174 | UINT8\r | |
3175 | EFIAPI\r | |
3176 | CalculateSum8 (\r | |
3177 | IN CONST UINT8 *Buffer,\r | |
3178 | IN UINTN Length\r | |
3179 | );\r | |
3180 | \r | |
3181 | \r | |
3182 | /**\r | |
c7f33ca4 | 3183 | Returns the two's complement checksum of all elements in a buffer\r |
3eb9473e | 3184 | of 8-bit values.\r |
3185 | \r | |
c7f33ca4 | 3186 | This function first calculates the sum of the 8-bit values in the\r |
3187 | buffer specified by Buffer and Length. The carry bits in the result\r | |
3188 | of addition are dropped. Then, the two's complement of the sum is\r | |
3eb9473e | 3189 | returned. If Length is 0, then 0 is returned.\r |
c7f33ca4 | 3190 | \r |
3eb9473e | 3191 | If Buffer is NULL, then ASSERT().\r |
3192 | If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().\r | |
3193 | \r | |
3194 | \r | |
3195 | @param Buffer Pointer to the buffer to carry out the checksum operation.\r | |
3196 | @param Length The size, in bytes, of Buffer.\r | |
3197 | \r | |
3198 | @return Checksum The 2's complement checksum of Buffer.\r | |
3199 | \r | |
3200 | **/\r | |
3201 | UINT8\r | |
3202 | EFIAPI\r | |
3203 | CalculateCheckSum8 (\r | |
3204 | IN CONST UINT8 *Buffer,\r | |
3205 | IN UINTN Length\r | |
3206 | );\r | |
3207 | \r | |
c7f33ca4 | 3208 | \r |
3eb9473e | 3209 | /**\r |
c7f33ca4 | 3210 | Returns the sum of all elements in a buffer of 16-bit values. During\r |
3eb9473e | 3211 | calculation, the carry bits are dropped.\r |
3212 | \r | |
c7f33ca4 | 3213 | This function calculates the sum of the 16-bit values in the buffer\r |
3214 | specified by Buffer and Length. The carry bits in result of addition are dropped.\r | |
3215 | The 16-bit result is returned. If Length is 0, then 0 is returned.\r | |
3216 | \r | |
3eb9473e | 3217 | If Buffer is NULL, then ASSERT().\r |
3218 | If Buffer is not aligned on a 16-bit boundary, then ASSERT().\r | |
3219 | If Length is not aligned on a 16-bit boundary, then ASSERT().\r | |
3220 | If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().\r | |
3221 | \r | |
3222 | @param Buffer Pointer to the buffer to carry out the sum operation.\r | |
3223 | @param Length The size, in bytes, of Buffer.\r | |
3224 | \r | |
3225 | @return Sum The sum of Buffer with carry bits dropped during additions.\r | |
3226 | \r | |
3227 | **/\r | |
3228 | UINT16\r | |
3229 | EFIAPI\r | |
3230 | CalculateSum16 (\r | |
3231 | IN CONST UINT16 *Buffer,\r | |
3232 | IN UINTN Length\r | |
3233 | );\r | |
3234 | \r | |
c7f33ca4 | 3235 | \r |
3eb9473e | 3236 | /**\r |
c7f33ca4 | 3237 | Returns the two's complement checksum of all elements in a buffer of\r |
3eb9473e | 3238 | 16-bit values.\r |
3239 | \r | |
c7f33ca4 | 3240 | This function first calculates the sum of the 16-bit values in the buffer\r |
3241 | specified by Buffer and Length. The carry bits in the result of addition\r | |
3242 | are dropped. Then, the two's complement of the sum is returned. If Length\r | |
3eb9473e | 3243 | is 0, then 0 is returned.\r |
c7f33ca4 | 3244 | \r |
3eb9473e | 3245 | If Buffer is NULL, then ASSERT().\r |
3246 | If Buffer is not aligned on a 16-bit boundary, then ASSERT().\r | |
3247 | If Length is not aligned on a 16-bit boundary, then ASSERT().\r | |
c7f33ca4 | 3248 | If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().\r |
3eb9473e | 3249 | \r |
3250 | @param Buffer Pointer to the buffer to carry out the checksum operation.\r | |
3251 | @param Length The size, in bytes, of Buffer.\r | |
3252 | \r | |
3253 | @return Checksum The 2's complement checksum of Buffer.\r | |
3254 | \r | |
3255 | **/\r | |
3256 | UINT16\r | |
3257 | EFIAPI\r | |
3258 | CalculateCheckSum16 (\r | |
3259 | IN CONST UINT16 *Buffer,\r | |
3260 | IN UINTN Length\r | |
3261 | );\r | |
3262 | \r | |
c7f33ca4 | 3263 | \r |
3eb9473e | 3264 | /**\r |
c7f33ca4 | 3265 | Returns the sum of all elements in a buffer of 32-bit values. During\r |
3eb9473e | 3266 | calculation, the carry bits are dropped.\r |
3267 | \r | |
c7f33ca4 | 3268 | This function calculates the sum of the 32-bit values in the buffer\r |
3269 | specified by Buffer and Length. The carry bits in result of addition are dropped.\r | |
3270 | The 32-bit result is returned. If Length is 0, then 0 is returned.\r | |
3271 | \r | |
3eb9473e | 3272 | If Buffer is NULL, then ASSERT().\r |
3273 | If Buffer is not aligned on a 32-bit boundary, then ASSERT().\r | |
3274 | If Length is not aligned on a 32-bit boundary, then ASSERT().\r | |
3275 | If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().\r | |
3276 | \r | |
3277 | @param Buffer Pointer to the buffer to carry out the sum operation.\r | |
3278 | @param Length The size, in bytes, of Buffer.\r | |
3279 | \r | |
3280 | @return Sum The sum of Buffer with carry bits dropped during additions.\r | |
3281 | \r | |
3282 | **/\r | |
3283 | UINT32\r | |
3284 | EFIAPI\r | |
3285 | CalculateSum32 (\r | |
3286 | IN CONST UINT32 *Buffer,\r | |
3287 | IN UINTN Length\r | |
3288 | );\r | |
3289 | \r | |
c7f33ca4 | 3290 | \r |
3eb9473e | 3291 | /**\r |
c7f33ca4 | 3292 | Returns the two's complement checksum of all elements in a buffer of\r |
3eb9473e | 3293 | 32-bit values.\r |
3294 | \r | |
c7f33ca4 | 3295 | This function first calculates the sum of the 32-bit values in the buffer\r |
3296 | specified by Buffer and Length. The carry bits in the result of addition\r | |
3297 | are dropped. Then, the two's complement of the sum is returned. If Length\r | |
3eb9473e | 3298 | is 0, then 0 is returned.\r |
c7f33ca4 | 3299 | \r |
3eb9473e | 3300 | If Buffer is NULL, then ASSERT().\r |
3301 | If Buffer is not aligned on a 32-bit boundary, then ASSERT().\r | |
3302 | If Length is not aligned on a 32-bit boundary, then ASSERT().\r | |
c7f33ca4 | 3303 | If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().\r |
3eb9473e | 3304 | \r |
3305 | @param Buffer Pointer to the buffer to carry out the checksum operation.\r | |
3306 | @param Length The size, in bytes, of Buffer.\r | |
3307 | \r | |
3308 | @return Checksum The 2's complement checksum of Buffer.\r | |
3309 | \r | |
3310 | **/\r | |
3311 | UINT32\r | |
3312 | EFIAPI\r | |
3313 | CalculateCheckSum32 (\r | |
3314 | IN CONST UINT32 *Buffer,\r | |
3315 | IN UINTN Length\r | |
3316 | );\r | |
3317 | \r | |
c7f33ca4 | 3318 | \r |
3eb9473e | 3319 | /**\r |
c7f33ca4 | 3320 | Returns the sum of all elements in a buffer of 64-bit values. During\r |
3eb9473e | 3321 | calculation, the carry bits are dropped.\r |
3322 | \r | |
c7f33ca4 | 3323 | This function calculates the sum of the 64-bit values in the buffer\r |
3324 | specified by Buffer and Length. The carry bits in result of addition are dropped.\r | |
3325 | The 64-bit result is returned. If Length is 0, then 0 is returned.\r | |
3326 | \r | |
3eb9473e | 3327 | If Buffer is NULL, then ASSERT().\r |
3328 | If Buffer is not aligned on a 64-bit boundary, then ASSERT().\r | |
3329 | If Length is not aligned on a 64-bit boundary, then ASSERT().\r | |
3330 | If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().\r | |
3331 | \r | |
3332 | @param Buffer Pointer to the buffer to carry out the sum operation.\r | |
3333 | @param Length The size, in bytes, of Buffer.\r | |
3334 | \r | |
3335 | @return Sum The sum of Buffer with carry bits dropped during additions.\r | |
3336 | \r | |
3337 | **/\r | |
3338 | UINT64\r | |
3339 | EFIAPI\r | |
3340 | CalculateSum64 (\r | |
3341 | IN CONST UINT64 *Buffer,\r | |
3342 | IN UINTN Length\r | |
3343 | );\r | |
3344 | \r | |
c7f33ca4 | 3345 | \r |
3eb9473e | 3346 | /**\r |
c7f33ca4 | 3347 | Returns the two's complement checksum of all elements in a buffer of\r |
3eb9473e | 3348 | 64-bit values.\r |
3349 | \r | |
c7f33ca4 | 3350 | This function first calculates the sum of the 64-bit values in the buffer\r |
3351 | specified by Buffer and Length. The carry bits in the result of addition\r | |
3352 | are dropped. Then, the two's complement of the sum is returned. If Length\r | |
3eb9473e | 3353 | is 0, then 0 is returned.\r |
c7f33ca4 | 3354 | \r |
3eb9473e | 3355 | If Buffer is NULL, then ASSERT().\r |
3356 | If Buffer is not aligned on a 64-bit boundary, then ASSERT().\r | |
3357 | If Length is not aligned on a 64-bit boundary, then ASSERT().\r | |
c7f33ca4 | 3358 | If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().\r |
3eb9473e | 3359 | \r |
3360 | @param Buffer Pointer to the buffer to carry out the checksum operation.\r | |
3361 | @param Length The size, in bytes, of Buffer.\r | |
3362 | \r | |
3363 | @return Checksum The 2's complement checksum of Buffer.\r | |
3364 | \r | |
3365 | **/\r | |
3366 | UINT64\r | |
3367 | EFIAPI\r | |
3368 | CalculateCheckSum64 (\r | |
3369 | IN CONST UINT64 *Buffer,\r | |
3370 | IN UINTN Length\r | |
3371 | );\r | |
3372 | \r | |
c7f33ca4 | 3373 | \r |
3eb9473e | 3374 | //\r |
3375 | // Base Library CPU Functions\r | |
3376 | //\r | |
3377 | typedef\r | |
3378 | VOID\r | |
3379 | (EFIAPI *SWITCH_STACK_ENTRY_POINT) (\r | |
3380 | IN VOID *Context1, OPTIONAL\r | |
3381 | IN VOID *Context2 OPTIONAL\r | |
3382 | );\r | |
3383 | \r | |
c7f33ca4 | 3384 | \r |
3eb9473e | 3385 | /**\r |
3386 | Used to serialize load and store operations.\r | |
3387 | \r | |
3388 | All loads and stores that proceed calls to this function are guaranteed to be\r | |
3389 | globally visible when this function returns.\r | |
3390 | \r | |
3391 | **/\r | |
3392 | VOID\r | |
3393 | EFIAPI\r | |
3394 | MemoryFence (\r | |
3395 | VOID\r | |
3396 | );\r | |
3397 | \r | |
c7f33ca4 | 3398 | \r |
3eb9473e | 3399 | /**\r |
3400 | Saves the current CPU context that can be restored with a call to LongJump()\r | |
3401 | and returns 0.\r | |
3402 | \r | |
3403 | Saves the current CPU context in the buffer specified by JumpBuffer and\r | |
3404 | returns 0. The initial call to SetJump() must always return 0. Subsequent\r | |
3405 | calls to LongJump() cause a non-zero value to be returned by SetJump().\r | |
3406 | \r | |
3407 | If JumpBuffer is NULL, then ASSERT().\r | |
3408 | For IPF CPUs, if JumpBuffer is not aligned on a 16-byte boundary, then ASSERT().\r | |
3409 | \r | |
3410 | @param JumpBuffer A pointer to CPU context buffer.\r | |
3411 | \r | |
3412 | @retval 0 Indicates a return from SetJump().\r | |
3413 | \r | |
3414 | **/\r | |
3415 | UINTN\r | |
3416 | EFIAPI\r | |
3417 | SetJump (\r | |
3418 | OUT BASE_LIBRARY_JUMP_BUFFER *JumpBuffer\r | |
3419 | );\r | |
3420 | \r | |
c7f33ca4 | 3421 | \r |
3eb9473e | 3422 | /**\r |
3423 | Restores the CPU context that was saved with SetJump().\r | |
3424 | \r | |
3425 | Restores the CPU context from the buffer specified by JumpBuffer. This\r | |
3426 | function never returns to the caller. Instead is resumes execution based on\r | |
3427 | the state of JumpBuffer.\r | |
3428 | \r | |
3429 | If JumpBuffer is NULL, then ASSERT().\r | |
3430 | For IPF CPUs, if JumpBuffer is not aligned on a 16-byte boundary, then ASSERT().\r | |
3431 | If Value is 0, then ASSERT().\r | |
3432 | \r | |
3433 | @param JumpBuffer A pointer to CPU context buffer.\r | |
3434 | @param Value The value to return when the SetJump() context is\r | |
3435 | restored and must be non-zero.\r | |
3436 | \r | |
3437 | **/\r | |
3438 | VOID\r | |
3439 | EFIAPI\r | |
3440 | LongJump (\r | |
3441 | IN BASE_LIBRARY_JUMP_BUFFER *JumpBuffer,\r | |
3442 | IN UINTN Value\r | |
3443 | );\r | |
3444 | \r | |
c7f33ca4 | 3445 | \r |
3eb9473e | 3446 | /**\r |
3447 | Enables CPU interrupts.\r | |
3448 | \r | |
3449 | Enables CPU interrupts.\r | |
3450 | \r | |
3451 | **/\r | |
3452 | VOID\r | |
3453 | EFIAPI\r | |
3454 | EnableInterrupts (\r | |
3455 | VOID\r | |
3456 | );\r | |
3457 | \r | |
c7f33ca4 | 3458 | \r |
3eb9473e | 3459 | /**\r |
3460 | Disables CPU interrupts.\r | |
3461 | \r | |
3462 | Disables CPU interrupts.\r | |
3463 | \r | |
3464 | **/\r | |
3465 | VOID\r | |
3466 | EFIAPI\r | |
3467 | DisableInterrupts (\r | |
3468 | VOID\r | |
3469 | );\r | |
3470 | \r | |
c7f33ca4 | 3471 | \r |
3eb9473e | 3472 | /**\r |
3473 | Disables CPU interrupts and returns the interrupt state prior to the disable\r | |
3474 | operation.\r | |
3475 | \r | |
3476 | Disables CPU interrupts and returns the interrupt state prior to the disable\r | |
3477 | operation.\r | |
3478 | \r | |
3479 | @retval TRUE CPU interrupts were enabled on entry to this call.\r | |
3480 | @retval FALSE CPU interrupts were disabled on entry to this call.\r | |
3481 | \r | |
3482 | **/\r | |
3483 | BOOLEAN\r | |
3484 | EFIAPI\r | |
3485 | SaveAndDisableInterrupts (\r | |
3486 | VOID\r | |
3487 | );\r | |
3488 | \r | |
c7f33ca4 | 3489 | \r |
3eb9473e | 3490 | /**\r |
3491 | Enables CPU interrupts for the smallest window required to capture any\r | |
3492 | pending interrupts.\r | |
3493 | \r | |
3494 | Enables CPU interrupts for the smallest window required to capture any\r | |
3495 | pending interrupts.\r | |
3496 | \r | |
3497 | **/\r | |
3498 | VOID\r | |
3499 | EFIAPI\r | |
3500 | EnableDisableInterrupts (\r | |
3501 | VOID\r | |
3502 | );\r | |
3503 | \r | |
c7f33ca4 | 3504 | \r |
3eb9473e | 3505 | /**\r |
3506 | Retrieves the current CPU interrupt state.\r | |
3507 | \r | |
3508 | Retrieves the current CPU interrupt state. Returns TRUE is interrupts are\r | |
3509 | currently enabled. Otherwise returns FALSE.\r | |
3510 | \r | |
3511 | @retval TRUE CPU interrupts are enabled.\r | |
3512 | @retval FALSE CPU interrupts are disabled.\r | |
3513 | \r | |
3514 | **/\r | |
3515 | BOOLEAN\r | |
3516 | EFIAPI\r | |
3517 | GlueGetInterruptState (\r | |
3518 | VOID\r | |
3519 | );\r | |
3520 | \r | |
c7f33ca4 | 3521 | \r |
3eb9473e | 3522 | /**\r |
3523 | Set the current CPU interrupt state.\r | |
3524 | \r | |
3525 | Sets the current CPU interrupt state to the state specified by\r | |
3526 | InterruptState. If InterruptState is TRUE, then interrupts are enabled. If\r | |
3527 | InterruptState is FALSE, then interrupts are disabled. InterruptState is\r | |
3528 | returned.\r | |
3529 | \r | |
3530 | @param InterruptState TRUE if interrupts should enabled. FALSE if\r | |
3531 | interrupts should be disabled.\r | |
3532 | \r | |
3533 | @return InterruptState\r | |
3534 | \r | |
3535 | **/\r | |
3536 | BOOLEAN\r | |
3537 | EFIAPI\r | |
3538 | SetInterruptState (\r | |
3539 | IN BOOLEAN InterruptState\r | |
3540 | );\r | |
3541 | \r | |
c7f33ca4 | 3542 | \r |
3eb9473e | 3543 | /**\r |
3544 | Places the CPU in a sleep state until an interrupt is received.\r | |
3545 | \r | |
3546 | Places the CPU in a sleep state until an interrupt is received. If interrupts\r | |
3547 | are disabled prior to calling this function, then the CPU will be placed in a\r | |
3548 | sleep state indefinitely.\r | |
3549 | \r | |
3550 | **/\r | |
3551 | VOID\r | |
3552 | EFIAPI\r | |
3553 | CpuSleep (\r | |
3554 | VOID\r | |
3555 | );\r | |
3556 | \r | |
c7f33ca4 | 3557 | \r |
3eb9473e | 3558 | /**\r |
3559 | Requests CPU to pause for a short period of time.\r | |
3560 | \r | |
3561 | Requests CPU to pause for a short period of time. Typically used in MP\r | |
3562 | systems to prevent memory starvation while waiting for a spin lock.\r | |
3563 | \r | |
3564 | **/\r | |
3565 | VOID\r | |
3566 | EFIAPI\r | |
3567 | CpuPause (\r | |
3568 | VOID\r | |
3569 | );\r | |
3570 | \r | |
c7f33ca4 | 3571 | \r |
3eb9473e | 3572 | /**\r |
3573 | Flushes all the Translation Lookaside Buffers(TLB) entries in a CPU.\r | |
3574 | \r | |
3575 | Flushes all the Translation Lookaside Buffers(TLB) entries in a CPU.\r | |
3576 | \r | |
3577 | **/\r | |
3578 | VOID\r | |
3579 | EFIAPI\r | |
3580 | CpuFlushTlb (\r | |
3581 | VOID\r | |
3582 | );\r | |
3583 | \r | |
c7f33ca4 | 3584 | \r |
3eb9473e | 3585 | /**\r |
3586 | Transfers control to a function starting with a new stack.\r | |
3587 | \r | |
c7f33ca4 | 3588 | Transfers control to the function specified by EntryPoint using the\r |
3589 | new stack specified by NewStack and passing in the parameters specified\r | |
3590 | by Context1 and Context2. Context1 and Context2 are optional and may\r | |
3591 | be NULL. The function EntryPoint must never return. This function\r | |
3592 | supports a variable number of arguments following the NewStack parameter.\r | |
3593 | These additional arguments are ignored on IA-32, x64, and EBC.\r | |
3594 | IPF CPUs expect one additional parameter of type VOID * that specifies\r | |
3595 | the new backing store pointer.\r | |
3eb9473e | 3596 | \r |
3597 | If EntryPoint is NULL, then ASSERT().\r | |
3598 | If NewStack is NULL, then ASSERT().\r | |
3599 | \r | |
3600 | @param EntryPoint A pointer to function to call with the new stack.\r | |
3601 | @param Context1 A pointer to the context to pass into the EntryPoint\r | |
3602 | function.\r | |
3603 | @param Context2 A pointer to the context to pass into the EntryPoint\r | |
3604 | function.\r | |
3605 | @param NewStack A pointer to the new stack to use for the EntryPoint\r | |
3606 | function.\r | |
3607 | \r | |
3608 | **/\r | |
3609 | VOID\r | |
3610 | EFIAPI\r | |
3611 | SwitchStack (\r | |
3612 | IN SWITCH_STACK_ENTRY_POINT EntryPoint,\r | |
3613 | IN VOID *Context1, OPTIONAL\r | |
3614 | IN VOID *Context2, OPTIONAL\r | |
c7f33ca4 | 3615 | IN VOID *NewStack,\r |
3616 | ...\r | |
3eb9473e | 3617 | );\r |
3618 | \r | |
c7f33ca4 | 3619 | \r |
3eb9473e | 3620 | /**\r |
3621 | Generates a breakpoint on the CPU.\r | |
3622 | \r | |
3623 | Generates a breakpoint on the CPU. The breakpoint must be implemented such\r | |
3624 | that code can resume normal execution after the breakpoint.\r | |
3625 | \r | |
3626 | **/\r | |
3627 | VOID\r | |
3628 | EFIAPI\r | |
3629 | CpuBreakpoint (\r | |
3630 | VOID\r | |
3631 | );\r | |
3632 | \r | |
c7f33ca4 | 3633 | \r |
3eb9473e | 3634 | /**\r |
3635 | Executes an infinite loop.\r | |
3636 | \r | |
3637 | Forces the CPU to execute an infinite loop. A debugger may be used to skip\r | |
3638 | past the loop and the code that follows the loop must execute properly. This\r | |
3639 | implies that the infinite loop must not cause the code that follow it to be\r | |
3640 | optimized away.\r | |
3641 | \r | |
3642 | **/\r | |
3643 | VOID\r | |
3644 | EFIAPI\r | |
3645 | CpuDeadLoop (\r | |
3646 | VOID\r | |
3647 | );\r | |
3648 | \r | |
bc7c34af | 3649 | #if defined (MDE_CPU_IA32) || defined (MDE_CPU_X64)\r |
c7f33ca4 | 3650 | //\r |
3651 | // IA32 and X64 Specific Functions\r | |
3652 | //\r | |
3653 | //\r | |
3654 | // Byte packed structure for 16-bit Real Mode EFLAGS\r | |
3655 | //\r | |
3656 | typedef union {\r | |
3657 | struct {\r | |
3658 | UINT32 CF:1; // Carry Flag\r | |
3659 | UINT32 Reserved_0:1; // Reserved\r | |
3660 | UINT32 PF:1; // Parity Flag\r | |
3661 | UINT32 Reserved_1:1; // Reserved\r | |
3662 | UINT32 AF:1; // Auxiliary Carry Flag\r | |
3663 | UINT32 Reserved_2:1; // Reserved\r | |
3664 | UINT32 ZF:1; // Zero Flag\r | |
3665 | UINT32 SF:1; // Sign Flag\r | |
3666 | UINT32 TF:1; // Trap Flag\r | |
3667 | UINT32 IF:1; // Interrupt Enable Flag\r | |
3668 | UINT32 DF:1; // Direction Flag\r | |
3669 | UINT32 OF:1; // Overflow Flag\r | |
3670 | UINT32 IOPL:2; // I/O Privilege Level\r | |
3671 | UINT32 NT:1; // Nested Task\r | |
3672 | UINT32 Reserved_3:1; // Reserved\r | |
3673 | } Bits;\r | |
3eb9473e | 3674 | UINT16 Uint16;\r |
3675 | } IA32_FLAGS16;\r | |
3676 | \r | |
3677 | //\r | |
3678 | // Byte packed structure for EFLAGS/RFLAGS\r | |
3679 | // 32-bits on IA-32\r | |
3680 | // 64-bits on X64. The upper 32-bits on X64 are reserved\r | |
3681 | //\r | |
3682 | typedef union {\r | |
3683 | struct {\r | |
3684 | UINT32 CF:1; // Carry Flag\r | |
3685 | UINT32 Reserved_0:1; // Reserved\r | |
3686 | UINT32 PF:1; // Parity Flag\r | |
3687 | UINT32 Reserved_1:1; // Reserved\r | |
3688 | UINT32 AF:1; // Auxiliary Carry Flag\r | |
3689 | UINT32 Reserved_2:1; // Reserved\r | |
3690 | UINT32 ZF:1; // Zero Flag\r | |
3691 | UINT32 SF:1; // Sign Flag\r | |
3692 | UINT32 TF:1; // Trap Flag\r | |
3693 | UINT32 IF:1; // Interrupt Enable Flag\r | |
3694 | UINT32 DF:1; // Direction Flag\r | |
3695 | UINT32 OF:1; // Overflow Flag\r | |
3696 | UINT32 IOPL:2; // I/O Privilege Level\r | |
3697 | UINT32 NT:1; // Nested Task\r | |
3698 | UINT32 Reserved_3:1; // Reserved\r | |
3699 | UINT32 RF:1; // Resume Flag\r | |
3700 | UINT32 VM:1; // Virtual 8086 Mode\r | |
3701 | UINT32 AC:1; // Alignment Check\r | |
3702 | UINT32 VIF:1; // Virtual Interrupt Flag\r | |
3703 | UINT32 VIP:1; // Virtual Interrupt Pending\r | |
3704 | UINT32 ID:1; // ID Flag\r | |
3705 | UINT32 Reserved_4:10; // Reserved\r | |
3706 | } Bits;\r | |
3707 | UINTN UintN;\r | |
3708 | } IA32_EFLAGS32;\r | |
3709 | \r | |
3710 | //\r | |
3711 | // Byte packed structure for Control Register 0 (CR0)\r | |
3712 | // 32-bits on IA-32\r | |
3713 | // 64-bits on X64. The upper 32-bits on X64 are reserved\r | |
3714 | //\r | |
3715 | typedef union {\r | |
3716 | struct {\r | |
3717 | UINT32 PE:1; // Protection Enable\r | |
3718 | UINT32 MP:1; // Monitor Coprocessor\r | |
3719 | UINT32 EM:1; // Emulation\r | |
3720 | UINT32 TS:1; // Task Switched\r | |
3721 | UINT32 ET:1; // Extension Type\r | |
3722 | UINT32 NE:1; // Numeric Error\r | |
3723 | UINT32 Reserved_0:10; // Reserved\r | |
3724 | UINT32 WP:1; // Write Protect\r | |
3725 | UINT32 Reserved_1:1; // Reserved\r | |
3726 | UINT32 AM:1; // Alignment Mask\r | |
3727 | UINT32 Reserved_2:10; // Reserved\r | |
3728 | UINT32 NW:1; // Mot Write-through\r | |
3729 | UINT32 CD:1; // Cache Disable\r | |
3730 | UINT32 PG:1; // Paging\r | |
3731 | } Bits;\r | |
3732 | UINTN UintN;\r | |
3733 | } IA32_CR0;\r | |
3734 | \r | |
3735 | //\r | |
3736 | // Byte packed structure for Control Register 4 (CR4)\r | |
3737 | // 32-bits on IA-32\r | |
3738 | // 64-bits on X64. The upper 32-bits on X64 are reserved\r | |
3739 | //\r | |
3740 | typedef union {\r | |
3741 | struct {\r | |
3742 | UINT32 VME:1; // Virtual-8086 Mode Extensions\r | |
3743 | UINT32 PVI:1; // Protected-Mode Virtual Interrupts\r | |
3744 | UINT32 TSD:1; // Time Stamp Disable\r | |
3745 | UINT32 DE:1; // Debugging Extensions\r | |
3746 | UINT32 PSE:1; // Page Size Extensions\r | |
3747 | UINT32 PAE:1; // Physical Address Extension\r | |
3748 | UINT32 MCE:1; // Machine Check Enable\r | |
3749 | UINT32 PGE:1; // Page Global Enable\r | |
3750 | UINT32 PCE:1; // Performance Monitoring Counter\r | |
3751 | // Enable\r | |
3752 | UINT32 OSFXSR:1; // Operating System Support for\r | |
3753 | // FXSAVE and FXRSTOR instructions\r | |
3754 | UINT32 OSXMMEXCPT:1; // Operating System Support for\r | |
3755 | // Unmasked SIMD Floating Point\r | |
3756 | // Exceptions\r | |
3757 | UINT32 Reserved_0:2; // Reserved\r | |
3758 | UINT32 VMXE:1; // VMX Enable\r | |
3759 | UINT32 Reserved_1:18; // Reseved\r | |
3760 | } Bits;\r | |
3761 | UINTN UintN;\r | |
3762 | } IA32_CR4;\r | |
3763 | \r | |
3764 | //\r | |
3765 | // Byte packed structure for an IDTR, GDTR, LDTR descriptor\r | |
3766 | /// @bug How to make this structure byte-packed in a compiler independent way?\r | |
3767 | //\r | |
3768 | #pragma pack (1)\r | |
3769 | typedef struct {\r | |
3770 | UINT16 Limit;\r | |
3771 | UINTN Base;\r | |
3772 | } IA32_DESCRIPTOR;\r | |
3773 | #pragma pack ()\r | |
3774 | \r | |
3775 | #define IA32_IDT_GATE_TYPE_TASK 0x85\r | |
3776 | #define IA32_IDT_GATE_TYPE_INTERRUPT_16 0x86\r | |
3777 | #define IA32_IDT_GATE_TYPE_TRAP_16 0x87\r | |
3778 | #define IA32_IDT_GATE_TYPE_INTERRUPT_32 0x8E\r | |
3779 | #define IA32_IDT_GATE_TYPE_TRAP_32 0x8F\r | |
3780 | \r | |
3781 | //\r | |
3782 | // Byte packed structure for an Interrupt Gate Descriptor\r | |
3783 | //\r | |
3784 | typedef union {\r | |
3785 | struct {\r | |
3786 | UINT32 OffsetLow:16; // Offset bits 15..0\r | |
3787 | UINT32 Selector:16; // Selector\r | |
3788 | UINT32 Reserved_0:8; // Reserved\r | |
3789 | UINT32 GateType:8; // Gate Type. See #defines above\r | |
3790 | UINT32 OffsetHigh:16; // Offset bits 31..16\r | |
3791 | } Bits;\r | |
3792 | UINT64 Uint64;\r | |
3793 | } IA32_IDT_GATE_DESCRIPTOR;\r | |
3794 | \r | |
3795 | //\r | |
3796 | // Byte packed structure for an FP/SSE/SSE2 context\r | |
3797 | //\r | |
3798 | typedef struct {\r | |
3799 | UINT8 Buffer[512];\r | |
3800 | } IA32_FX_BUFFER;\r | |
3801 | \r | |
3802 | //\r | |
3803 | // Structures for the 16-bit real mode thunks\r | |
3804 | //\r | |
3805 | typedef struct {\r | |
3806 | UINT32 Reserved1;\r | |
3807 | UINT32 Reserved2;\r | |
3808 | UINT32 Reserved3;\r | |
3809 | UINT32 Reserved4;\r | |
3810 | UINT8 BL;\r | |
3811 | UINT8 BH;\r | |
3812 | UINT16 Reserved5;\r | |
3813 | UINT8 DL;\r | |
3814 | UINT8 DH;\r | |
3815 | UINT16 Reserved6;\r | |
3816 | UINT8 CL;\r | |
3817 | UINT8 CH;\r | |
3818 | UINT16 Reserved7;\r | |
3819 | UINT8 AL;\r | |
3820 | UINT8 AH;\r | |
3821 | UINT16 Reserved8;\r | |
3822 | } IA32_BYTE_REGS;\r | |
3823 | \r | |
3824 | typedef struct {\r | |
3825 | UINT16 DI;\r | |
3826 | UINT16 Reserved1;\r | |
3827 | UINT16 SI;\r | |
3828 | UINT16 Reserved2;\r | |
3829 | UINT16 BP;\r | |
3830 | UINT16 Reserved3;\r | |
3831 | UINT16 SP;\r | |
3832 | UINT16 Reserved4;\r | |
3833 | UINT16 BX;\r | |
3834 | UINT16 Reserved5;\r | |
3835 | UINT16 DX;\r | |
3836 | UINT16 Reserved6;\r | |
3837 | UINT16 CX;\r | |
3838 | UINT16 Reserved7;\r | |
3839 | UINT16 AX;\r | |
3840 | UINT16 Reserved8;\r | |
3841 | } IA32_WORD_REGS;\r | |
3842 | \r | |
3843 | typedef struct {\r | |
3844 | UINT32 EDI;\r | |
3845 | UINT32 ESI;\r | |
3846 | UINT32 EBP;\r | |
3847 | UINT32 ESP;\r | |
3848 | UINT32 EBX;\r | |
3849 | UINT32 EDX;\r | |
3850 | UINT32 ECX;\r | |
3851 | UINT32 EAX;\r | |
3852 | UINT16 DS;\r | |
3853 | UINT16 ES;\r | |
3854 | UINT16 FS;\r | |
3855 | UINT16 GS;\r | |
3856 | IA32_EFLAGS32 EFLAGS;\r | |
3857 | UINT32 Eip;\r | |
3858 | UINT16 CS;\r | |
3859 | UINT16 SS;\r | |
3860 | } IA32_DWORD_REGS;\r | |
3861 | \r | |
3862 | typedef union {\r | |
3863 | IA32_DWORD_REGS E;\r | |
3864 | IA32_WORD_REGS X;\r | |
3865 | IA32_BYTE_REGS H;\r | |
3866 | } IA32_REGISTER_SET;\r | |
3867 | \r | |
3868 | //\r | |
3869 | // Byte packed structure for an 16-bit real mode thunks\r | |
3870 | //\r | |
3871 | typedef struct {\r | |
3872 | IA32_REGISTER_SET *RealModeState;\r | |
3873 | VOID *RealModeBuffer;\r | |
3874 | UINT32 RealModeBufferSize;\r | |
3875 | UINT32 ThunkAttributes;\r | |
3876 | } THUNK_CONTEXT;\r | |
3877 | \r | |
3878 | #define THUNK_ATTRIBUTE_BIG_REAL_MODE 0x00000001\r | |
3879 | #define THUNK_ATTRIBUTE_DISABLE_A20_MASK_INT_15 0x00000002\r | |
3880 | #define THUNK_ATTRIBUTE_DISABLE_A20_MASK_KBD_CTRL 0x00000004\r | |
3881 | \r | |
3882 | /**\r | |
3883 | Retrieves CPUID information.\r | |
3884 | \r | |
3885 | Executes the CPUID instruction with EAX set to the value specified by Index.\r | |
3886 | This function always returns Index.\r | |
3887 | If Eax is not NULL, then the value of EAX after CPUID is returned in Eax.\r | |
3888 | If Ebx is not NULL, then the value of EBX after CPUID is returned in Ebx.\r | |
3889 | If Ecx is not NULL, then the value of ECX after CPUID is returned in Ecx.\r | |
3890 | If Edx is not NULL, then the value of EDX after CPUID is returned in Edx.\r | |
3891 | This function is only available on IA-32 and X64.\r | |
3892 | \r | |
3893 | @param Index The 32-bit value to load into EAX prior to invoking the CPUID\r | |
3894 | instruction.\r | |
3895 | @param Eax Pointer to the 32-bit EAX value returned by the CPUID\r | |
3896 | instruction. This is an optional parameter that may be NULL.\r | |
3897 | @param Ebx Pointer to the 32-bit EBX value returned by the CPUID\r | |
3898 | instruction. This is an optional parameter that may be NULL.\r | |
3899 | @param Ecx Pointer to the 32-bit ECX value returned by the CPUID\r | |
3900 | instruction. This is an optional parameter that may be NULL.\r | |
3901 | @param Edx Pointer to the 32-bit EDX value returned by the CPUID\r | |
3902 | instruction. This is an optional parameter that may be NULL.\r | |
3903 | \r | |
3904 | @return Index\r | |
3905 | \r | |
3906 | **/\r | |
3907 | UINT32\r | |
3908 | EFIAPI\r | |
3909 | AsmCpuid (\r | |
3910 | IN UINT32 Index,\r | |
3911 | OUT UINT32 *Eax, OPTIONAL\r | |
3912 | OUT UINT32 *Ebx, OPTIONAL\r | |
3913 | OUT UINT32 *Ecx, OPTIONAL\r | |
3914 | OUT UINT32 *Edx OPTIONAL\r | |
3915 | );\r | |
3916 | \r | |
c7f33ca4 | 3917 | \r |
3eb9473e | 3918 | /**\r |
3919 | Retrieves CPUID information using an extended leaf identifier.\r | |
3920 | \r | |
3921 | Executes the CPUID instruction with EAX set to the value specified by Index\r | |
3922 | and ECX set to the value specified by SubIndex. This function always returns\r | |
3923 | Index. This function is only available on IA-32 and x64.\r | |
3924 | \r | |
3925 | If Eax is not NULL, then the value of EAX after CPUID is returned in Eax.\r | |
3926 | If Ebx is not NULL, then the value of EBX after CPUID is returned in Ebx.\r | |
3927 | If Ecx is not NULL, then the value of ECX after CPUID is returned in Ecx.\r | |
3928 | If Edx is not NULL, then the value of EDX after CPUID is returned in Edx.\r | |
3929 | \r | |
3930 | @param Index The 32-bit value to load into EAX prior to invoking the\r | |
3931 | CPUID instruction.\r | |
3932 | @param SubIndex The 32-bit value to load into ECX prior to invoking the\r | |
3933 | CPUID instruction.\r | |
3934 | @param Eax Pointer to the 32-bit EAX value returned by the CPUID\r | |
3935 | instruction. This is an optional parameter that may be\r | |
3936 | NULL.\r | |
3937 | @param Ebx Pointer to the 32-bit EBX value returned by the CPUID\r | |
3938 | instruction. This is an optional parameter that may be\r | |
3939 | NULL.\r | |
3940 | @param Ecx Pointer to the 32-bit ECX value returned by the CPUID\r | |
3941 | instruction. This is an optional parameter that may be\r | |
3942 | NULL.\r | |
3943 | @param Edx Pointer to the 32-bit EDX value returned by the CPUID\r | |
3944 | instruction. This is an optional parameter that may be\r | |
3945 | NULL.\r | |
3946 | \r | |
3947 | @return Index\r | |
3948 | \r | |
3949 | **/\r | |
3950 | UINT32\r | |
3951 | EFIAPI\r | |
3952 | AsmCpuidEx (\r | |
3953 | IN UINT32 Index,\r | |
3954 | IN UINT32 SubIndex,\r | |
3955 | OUT UINT32 *Eax, OPTIONAL\r | |
3956 | OUT UINT32 *Ebx, OPTIONAL\r | |
3957 | OUT UINT32 *Ecx, OPTIONAL\r | |
3958 | OUT UINT32 *Edx OPTIONAL\r | |
3959 | );\r | |
3960 | \r | |
c7f33ca4 | 3961 | \r |
3eb9473e | 3962 | /**\r |
3963 | Returns the lower 32-bits of a Machine Specific Register(MSR).\r | |
3964 | \r | |
3965 | Reads and returns the lower 32-bits of the MSR specified by Index.\r | |
3966 | No parameter checking is performed on Index, and some Index values may cause\r | |
3967 | CPU exceptions. The caller must either guarantee that Index is valid, or the\r | |
3968 | caller must set up exception handlers to catch the exceptions. This function\r | |
3969 | is only available on IA-32 and X64.\r | |
3970 | \r | |
3971 | @param Index The 32-bit MSR index to read.\r | |
3972 | \r | |
3973 | @return The lower 32 bits of the MSR identified by Index.\r | |
3974 | \r | |
3975 | **/\r | |
3976 | UINT32\r | |
3977 | EFIAPI\r | |
3978 | AsmReadMsr32 (\r | |
3979 | IN UINT32 Index\r | |
3980 | );\r | |
3981 | \r | |
c7f33ca4 | 3982 | \r |
3eb9473e | 3983 | /**\r |
3984 | Zero-extend a 32-bit value and writes it to a Machine Specific Register(MSR).\r | |
3985 | \r | |
3986 | Writes the 32-bit value specified by Value to the MSR specified by Index. The\r | |
3987 | upper 32-bits of the MSR write are set to zero. The 32-bit value written to\r | |
3988 | the MSR is returned. No parameter checking is performed on Index or Value,\r | |
3989 | and some of these may cause CPU exceptions. The caller must either guarantee\r | |
3990 | that Index and Value are valid, or the caller must establish proper exception\r | |
3991 | handlers. This function is only available on IA-32 and X64.\r | |
3992 | \r | |
3993 | @param Index The 32-bit MSR index to write.\r | |
3994 | @param Value The 32-bit value to write to the MSR.\r | |
3995 | \r | |
3996 | @return Value\r | |
3997 | \r | |
3998 | **/\r | |
3999 | UINT32\r | |
4000 | EFIAPI\r | |
4001 | AsmWriteMsr32 (\r | |
4002 | IN UINT32 Index,\r | |
4003 | IN UINT32 Value\r | |
4004 | );\r | |
4005 | \r | |
c7f33ca4 | 4006 | \r |
3eb9473e | 4007 | /**\r |
4008 | Reads a 64-bit MSR, performs a bitwise inclusive OR on the lower 32-bits, and\r | |
4009 | writes the result back to the 64-bit MSR.\r | |
4010 | \r | |
4011 | Reads the 64-bit MSR specified by Index, performs a bitwise inclusive OR\r | |
4012 | between the lower 32-bits of the read result and the value specified by\r | |
4013 | OrData, and writes the result to the 64-bit MSR specified by Index. The lower\r | |
4014 | 32-bits of the value written to the MSR is returned. No parameter checking is\r | |
4015 | performed on Index or OrData, and some of these may cause CPU exceptions. The\r | |
4016 | caller must either guarantee that Index and OrData are valid, or the caller\r | |
4017 | must establish proper exception handlers. This function is only available on\r | |
4018 | IA-32 and X64.\r | |
4019 | \r | |
4020 | @param Index The 32-bit MSR index to write.\r | |
4021 | @param OrData The value to OR with the read value from the MSR.\r | |
4022 | \r | |
4023 | @return The lower 32-bit value written to the MSR.\r | |
4024 | \r | |
4025 | **/\r | |
4026 | UINT32\r | |
4027 | EFIAPI\r | |
4028 | AsmMsrOr32 (\r | |
4029 | IN UINT32 Index,\r | |
4030 | IN UINT32 OrData\r | |
4031 | );\r | |
4032 | \r | |
c7f33ca4 | 4033 | \r |
3eb9473e | 4034 | /**\r |
4035 | Reads a 64-bit MSR, performs a bitwise AND on the lower 32-bits, and writes\r | |
4036 | the result back to the 64-bit MSR.\r | |
4037 | \r | |
4038 | Reads the 64-bit MSR specified by Index, performs a bitwise AND between the\r | |
4039 | lower 32-bits of the read result and the value specified by AndData, and\r | |
4040 | writes the result to the 64-bit MSR specified by Index. The lower 32-bits of\r | |
4041 | the value written to the MSR is returned. No parameter checking is performed\r | |
4042 | on Index or AndData, and some of these may cause CPU exceptions. The caller\r | |
4043 | must either guarantee that Index and AndData are valid, or the caller must\r | |
4044 | establish proper exception handlers. This function is only available on IA-32\r | |
4045 | and X64.\r | |
4046 | \r | |
4047 | @param Index The 32-bit MSR index to write.\r | |
4048 | @param AndData The value to AND with the read value from the MSR.\r | |
4049 | \r | |
4050 | @return The lower 32-bit value written to the MSR.\r | |
4051 | \r | |
4052 | **/\r | |
4053 | UINT32\r | |
4054 | EFIAPI\r | |
4055 | AsmMsrAnd32 (\r | |
4056 | IN UINT32 Index,\r | |
4057 | IN UINT32 AndData\r | |
4058 | );\r | |
4059 | \r | |
c7f33ca4 | 4060 | \r |
3eb9473e | 4061 | /**\r |
4062 | Reads a 64-bit MSR, performs a bitwise AND followed by a bitwise inclusive OR\r | |
4063 | on the lower 32-bits, and writes the result back to the 64-bit MSR.\r | |
4064 | \r | |
4065 | Reads the 64-bit MSR specified by Index, performs a bitwise AND between the\r | |
4066 | lower 32-bits of the read result and the value specified by AndData\r | |
4067 | preserving the upper 32-bits, performs a bitwise inclusive OR between the\r | |
4068 | result of the AND operation and the value specified by OrData, and writes the\r | |
4069 | result to the 64-bit MSR specified by Address. The lower 32-bits of the value\r | |
4070 | written to the MSR is returned. No parameter checking is performed on Index,\r | |
4071 | AndData, or OrData, and some of these may cause CPU exceptions. The caller\r | |
4072 | must either guarantee that Index, AndData, and OrData are valid, or the\r | |
4073 | caller must establish proper exception handlers. This function is only\r | |
4074 | available on IA-32 and X64.\r | |
4075 | \r | |
4076 | @param Index The 32-bit MSR index to write.\r | |
4077 | @param AndData The value to AND with the read value from the MSR.\r | |
4078 | @param OrData The value to OR with the result of the AND operation.\r | |
4079 | \r | |
4080 | @return The lower 32-bit value written to the MSR.\r | |
4081 | \r | |
4082 | **/\r | |
4083 | UINT32\r | |
4084 | EFIAPI\r | |
4085 | AsmMsrAndThenOr32 (\r | |
4086 | IN UINT32 Index,\r | |
4087 | IN UINT32 AndData,\r | |
4088 | IN UINT32 OrData\r | |
4089 | );\r | |
4090 | \r | |
c7f33ca4 | 4091 | \r |
3eb9473e | 4092 | /**\r |
4093 | Reads a bit field of an MSR.\r | |
4094 | \r | |
4095 | Reads the bit field in the lower 32-bits of a 64-bit MSR. The bit field is\r | |
4096 | specified by the StartBit and the EndBit. The value of the bit field is\r | |
4097 | returned. The caller must either guarantee that Index is valid, or the caller\r | |
4098 | must set up exception handlers to catch the exceptions. This function is only\r | |
4099 | available on IA-32 and X64.\r | |
4100 | \r | |
4101 | If StartBit is greater than 31, then ASSERT().\r | |
4102 | If EndBit is greater than 31, then ASSERT().\r | |
4103 | If EndBit is less than StartBit, then ASSERT().\r | |
4104 | \r | |
4105 | @param Index The 32-bit MSR index to read.\r | |
4106 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
4107 | Range 0..31.\r | |
4108 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
4109 | Range 0..31.\r | |
4110 | \r | |
4111 | @return The bit field read from the MSR.\r | |
4112 | \r | |
4113 | **/\r | |
4114 | UINT32\r | |
4115 | EFIAPI\r | |
4116 | AsmMsrBitFieldRead32 (\r | |
4117 | IN UINT32 Index,\r | |
4118 | IN UINTN StartBit,\r | |
4119 | IN UINTN EndBit\r | |
4120 | );\r | |
4121 | \r | |
c7f33ca4 | 4122 | \r |
3eb9473e | 4123 | /**\r |
4124 | Writes a bit field to an MSR.\r | |
4125 | \r | |
4126 | Writes Value to a bit field in the lower 32-bits of a 64-bit MSR. The bit\r | |
4127 | field is specified by the StartBit and the EndBit. All other bits in the\r | |
4128 | destination MSR are preserved. The lower 32-bits of the MSR written is\r | |
4129 | returned. Extra left bits in Value are stripped. The caller must either\r | |
4130 | guarantee that Index and the data written is valid, or the caller must set up\r | |
4131 | exception handlers to catch the exceptions. This function is only available\r | |
4132 | on IA-32 and X64.\r | |
4133 | \r | |
4134 | If StartBit is greater than 31, then ASSERT().\r | |
4135 | If EndBit is greater than 31, then ASSERT().\r | |
4136 | If EndBit is less than StartBit, then ASSERT().\r | |
4137 | \r | |
4138 | @param Index The 32-bit MSR index to write.\r | |
4139 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
4140 | Range 0..31.\r | |
4141 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
4142 | Range 0..31.\r | |
4143 | @param Value New value of the bit field.\r | |
4144 | \r | |
4145 | @return The lower 32-bit of the value written to the MSR.\r | |
4146 | \r | |
4147 | **/\r | |
4148 | UINT32\r | |
4149 | EFIAPI\r | |
4150 | AsmMsrBitFieldWrite32 (\r | |
4151 | IN UINT32 Index,\r | |
4152 | IN UINTN StartBit,\r | |
4153 | IN UINTN EndBit,\r | |
4154 | IN UINT32 Value\r | |
4155 | );\r | |
4156 | \r | |
c7f33ca4 | 4157 | \r |
3eb9473e | 4158 | /**\r |
4159 | Reads a bit field in a 64-bit MSR, performs a bitwise OR, and writes the\r | |
4160 | result back to the bit field in the 64-bit MSR.\r | |
4161 | \r | |
4162 | Reads the 64-bit MSR specified by Index, performs a bitwise inclusive OR\r | |
4163 | between the read result and the value specified by OrData, and writes the\r | |
4164 | result to the 64-bit MSR specified by Index. The lower 32-bits of the value\r | |
4165 | written to the MSR are returned. Extra left bits in OrData are stripped. The\r | |
4166 | caller must either guarantee that Index and the data written is valid, or\r | |
4167 | the caller must set up exception handlers to catch the exceptions. This\r | |
4168 | function is only available on IA-32 and X64.\r | |
4169 | \r | |
4170 | If StartBit is greater than 31, then ASSERT().\r | |
4171 | If EndBit is greater than 31, then ASSERT().\r | |
4172 | If EndBit is less than StartBit, then ASSERT().\r | |
4173 | \r | |
4174 | @param Index The 32-bit MSR index to write.\r | |
4175 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
4176 | Range 0..31.\r | |
4177 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
4178 | Range 0..31.\r | |
4179 | @param OrData The value to OR with the read value from the MSR.\r | |
4180 | \r | |
4181 | @return The lower 32-bit of the value written to the MSR.\r | |
4182 | \r | |
4183 | **/\r | |
4184 | UINT32\r | |
4185 | EFIAPI\r | |
4186 | AsmMsrBitFieldOr32 (\r | |
4187 | IN UINT32 Index,\r | |
4188 | IN UINTN StartBit,\r | |
4189 | IN UINTN EndBit,\r | |
4190 | IN UINT32 OrData\r | |
4191 | );\r | |
4192 | \r | |
c7f33ca4 | 4193 | \r |
3eb9473e | 4194 | /**\r |
4195 | Reads a bit field in a 64-bit MSR, performs a bitwise AND, and writes the\r | |
4196 | result back to the bit field in the 64-bit MSR.\r | |
4197 | \r | |
4198 | Reads the 64-bit MSR specified by Index, performs a bitwise AND between the\r | |
4199 | read result and the value specified by AndData, and writes the result to the\r | |
4200 | 64-bit MSR specified by Index. The lower 32-bits of the value written to the\r | |
4201 | MSR are returned. Extra left bits in AndData are stripped. The caller must\r | |
4202 | either guarantee that Index and the data written is valid, or the caller must\r | |
4203 | set up exception handlers to catch the exceptions. This function is only\r | |
4204 | available on IA-32 and X64.\r | |
4205 | \r | |
4206 | If StartBit is greater than 31, then ASSERT().\r | |
4207 | If EndBit is greater than 31, then ASSERT().\r | |
4208 | If EndBit is less than StartBit, then ASSERT().\r | |
4209 | \r | |
4210 | @param Index The 32-bit MSR index to write.\r | |
4211 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
4212 | Range 0..31.\r | |
4213 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
4214 | Range 0..31.\r | |
4215 | @param AndData The value to AND with the read value from the MSR.\r | |
4216 | \r | |
4217 | @return The lower 32-bit of the value written to the MSR.\r | |
4218 | \r | |
4219 | **/\r | |
4220 | UINT32\r | |
4221 | EFIAPI\r | |
4222 | AsmMsrBitFieldAnd32 (\r | |
4223 | IN UINT32 Index,\r | |
4224 | IN UINTN StartBit,\r | |
4225 | IN UINTN EndBit,\r | |
4226 | IN UINT32 AndData\r | |
4227 | );\r | |
4228 | \r | |
c7f33ca4 | 4229 | \r |
3eb9473e | 4230 | /**\r |
4231 | Reads a bit field in a 64-bit MSR, performs a bitwise AND followed by a\r | |
4232 | bitwise inclusive OR, and writes the result back to the bit field in the\r | |
4233 | 64-bit MSR.\r | |
4234 | \r | |
4235 | Reads the 64-bit MSR specified by Index, performs a bitwise AND followed by a\r | |
4236 | bitwise inclusive OR between the read result and the value specified by\r | |
4237 | AndData, and writes the result to the 64-bit MSR specified by Index. The\r | |
4238 | lower 32-bits of the value written to the MSR are returned. Extra left bits\r | |
4239 | in both AndData and OrData are stripped. The caller must either guarantee\r | |
4240 | that Index and the data written is valid, or the caller must set up exception\r | |
4241 | handlers to catch the exceptions. This function is only available on IA-32\r | |
4242 | and X64.\r | |
4243 | \r | |
4244 | If StartBit is greater than 31, then ASSERT().\r | |
4245 | If EndBit is greater than 31, then ASSERT().\r | |
4246 | If EndBit is less than StartBit, then ASSERT().\r | |
4247 | \r | |
4248 | @param Index The 32-bit MSR index to write.\r | |
4249 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
4250 | Range 0..31.\r | |
4251 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
4252 | Range 0..31.\r | |
4253 | @param AndData The value to AND with the read value from the MSR.\r | |
4254 | @param OrData The value to OR with the result of the AND operation.\r | |
4255 | \r | |
4256 | @return The lower 32-bit of the value written to the MSR.\r | |
4257 | \r | |
4258 | **/\r | |
4259 | UINT32\r | |
4260 | EFIAPI\r | |
4261 | AsmMsrBitFieldAndThenOr32 (\r | |
4262 | IN UINT32 Index,\r | |
4263 | IN UINTN StartBit,\r | |
4264 | IN UINTN EndBit,\r | |
4265 | IN UINT32 AndData,\r | |
4266 | IN UINT32 OrData\r | |
4267 | );\r | |
4268 | \r | |
c7f33ca4 | 4269 | \r |
3eb9473e | 4270 | /**\r |
4271 | Returns a 64-bit Machine Specific Register(MSR).\r | |
4272 | \r | |
4273 | Reads and returns the 64-bit MSR specified by Index. No parameter checking is\r | |
4274 | performed on Index, and some Index values may cause CPU exceptions. The\r | |
4275 | caller must either guarantee that Index is valid, or the caller must set up\r | |
4276 | exception handlers to catch the exceptions. This function is only available\r | |
4277 | on IA-32 and X64.\r | |
4278 | \r | |
4279 | @param Index The 32-bit MSR index to read.\r | |
4280 | \r | |
4281 | @return The value of the MSR identified by Index.\r | |
4282 | \r | |
4283 | **/\r | |
4284 | UINT64\r | |
4285 | EFIAPI\r | |
4286 | AsmReadMsr64 (\r | |
4287 | IN UINT32 Index\r | |
4288 | );\r | |
4289 | \r | |
c7f33ca4 | 4290 | \r |
3eb9473e | 4291 | /**\r |
4292 | Writes a 64-bit value to a Machine Specific Register(MSR), and returns the\r | |
4293 | value.\r | |
4294 | \r | |
4295 | Writes the 64-bit value specified by Value to the MSR specified by Index. The\r | |
4296 | 64-bit value written to the MSR is returned. No parameter checking is\r | |
4297 | performed on Index or Value, and some of these may cause CPU exceptions. The\r | |
4298 | caller must either guarantee that Index and Value are valid, or the caller\r | |
4299 | must establish proper exception handlers. This function is only available on\r | |
4300 | IA-32 and X64.\r | |
4301 | \r | |
4302 | @param Index The 32-bit MSR index to write.\r | |
4303 | @param Value The 64-bit value to write to the MSR.\r | |
4304 | \r | |
4305 | @return Value\r | |
4306 | \r | |
4307 | **/\r | |
4308 | UINT64\r | |
4309 | EFIAPI\r | |
4310 | AsmWriteMsr64 (\r | |
4311 | IN UINT32 Index,\r | |
4312 | IN UINT64 Value\r | |
4313 | );\r | |
4314 | \r | |
c7f33ca4 | 4315 | \r |
3eb9473e | 4316 | /**\r |
4317 | Reads a 64-bit MSR, performs a bitwise inclusive OR, and writes the result\r | |
4318 | back to the 64-bit MSR.\r | |
4319 | \r | |
4320 | Reads the 64-bit MSR specified by Index, performs a bitwise inclusive OR\r | |
4321 | between the read result and the value specified by OrData, and writes the\r | |
4322 | result to the 64-bit MSR specified by Index. The value written to the MSR is\r | |
4323 | returned. No parameter checking is performed on Index or OrData, and some of\r | |
4324 | these may cause CPU exceptions. The caller must either guarantee that Index\r | |
4325 | and OrData are valid, or the caller must establish proper exception handlers.\r | |
4326 | This function is only available on IA-32 and X64.\r | |
4327 | \r | |
4328 | @param Index The 32-bit MSR index to write.\r | |
4329 | @param OrData The value to OR with the read value from the MSR.\r | |
4330 | \r | |
4331 | @return The value written back to the MSR.\r | |
4332 | \r | |
4333 | **/\r | |
4334 | UINT64\r | |
4335 | EFIAPI\r | |
4336 | AsmMsrOr64 (\r | |
4337 | IN UINT32 Index,\r | |
4338 | IN UINT64 OrData\r | |
4339 | );\r | |
4340 | \r | |
c7f33ca4 | 4341 | \r |
3eb9473e | 4342 | /**\r |
4343 | Reads a 64-bit MSR, performs a bitwise AND, and writes the result back to the\r | |
4344 | 64-bit MSR.\r | |
4345 | \r | |
4346 | Reads the 64-bit MSR specified by Index, performs a bitwise AND between the\r | |
4347 | read result and the value specified by OrData, and writes the result to the\r | |
4348 | 64-bit MSR specified by Index. The value written to the MSR is returned. No\r | |
4349 | parameter checking is performed on Index or OrData, and some of these may\r | |
4350 | cause CPU exceptions. The caller must either guarantee that Index and OrData\r | |
4351 | are valid, or the caller must establish proper exception handlers. This\r | |
4352 | function is only available on IA-32 and X64.\r | |
4353 | \r | |
4354 | @param Index The 32-bit MSR index to write.\r | |
4355 | @param AndData The value to AND with the read value from the MSR.\r | |
4356 | \r | |
4357 | @return The value written back to the MSR.\r | |
4358 | \r | |
4359 | **/\r | |
4360 | UINT64\r | |
4361 | EFIAPI\r | |
4362 | AsmMsrAnd64 (\r | |
4363 | IN UINT32 Index,\r | |
4364 | IN UINT64 AndData\r | |
4365 | );\r | |
4366 | \r | |
c7f33ca4 | 4367 | \r |
3eb9473e | 4368 | /**\r |
4369 | Reads a 64-bit MSR, performs a bitwise AND followed by a bitwise inclusive\r | |
4370 | OR, and writes the result back to the 64-bit MSR.\r | |
4371 | \r | |
4372 | Reads the 64-bit MSR specified by Index, performs a bitwise AND between read\r | |
4373 | result and the value specified by AndData, performs a bitwise inclusive OR\r | |
4374 | between the result of the AND operation and the value specified by OrData,\r | |
4375 | and writes the result to the 64-bit MSR specified by Index. The value written\r | |
4376 | to the MSR is returned. No parameter checking is performed on Index, AndData,\r | |
4377 | or OrData, and some of these may cause CPU exceptions. The caller must either\r | |
4378 | guarantee that Index, AndData, and OrData are valid, or the caller must\r | |
4379 | establish proper exception handlers. This function is only available on IA-32\r | |
4380 | and X64.\r | |
4381 | \r | |
4382 | @param Index The 32-bit MSR index to write.\r | |
4383 | @param AndData The value to AND with the read value from the MSR.\r | |
4384 | @param OrData The value to OR with the result of the AND operation.\r | |
4385 | \r | |
4386 | @return The value written back to the MSR.\r | |
4387 | \r | |
4388 | **/\r | |
4389 | UINT64\r | |
4390 | EFIAPI\r | |
4391 | AsmMsrAndThenOr64 (\r | |
4392 | IN UINT32 Index,\r | |
4393 | IN UINT64 AndData,\r | |
4394 | IN UINT64 OrData\r | |
4395 | );\r | |
4396 | \r | |
c7f33ca4 | 4397 | \r |
3eb9473e | 4398 | /**\r |
4399 | Reads a bit field of an MSR.\r | |
4400 | \r | |
4401 | Reads the bit field in the 64-bit MSR. The bit field is specified by the\r | |
4402 | StartBit and the EndBit. The value of the bit field is returned. The caller\r | |
4403 | must either guarantee that Index is valid, or the caller must set up\r | |
4404 | exception handlers to catch the exceptions. This function is only available\r | |
4405 | on IA-32 and X64.\r | |
4406 | \r | |
4407 | If StartBit is greater than 63, then ASSERT().\r | |
4408 | If EndBit is greater than 63, then ASSERT().\r | |
4409 | If EndBit is less than StartBit, then ASSERT().\r | |
4410 | \r | |
4411 | @param Index The 32-bit MSR index to read.\r | |
4412 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
4413 | Range 0..63.\r | |
4414 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
4415 | Range 0..63.\r | |
4416 | \r | |
4417 | @return The value read from the MSR.\r | |
4418 | \r | |
4419 | **/\r | |
4420 | UINT64\r | |
4421 | EFIAPI\r | |
4422 | AsmMsrBitFieldRead64 (\r | |
4423 | IN UINT32 Index,\r | |
4424 | IN UINTN StartBit,\r | |
4425 | IN UINTN EndBit\r | |
4426 | );\r | |
4427 | \r | |
c7f33ca4 | 4428 | \r |
3eb9473e | 4429 | /**\r |
4430 | Writes a bit field to an MSR.\r | |
4431 | \r | |
4432 | Writes Value to a bit field in a 64-bit MSR. The bit field is specified by\r | |
4433 | the StartBit and the EndBit. All other bits in the destination MSR are\r | |
4434 | preserved. The MSR written is returned. Extra left bits in Value are\r | |
4435 | stripped. The caller must either guarantee that Index and the data written is\r | |
4436 | valid, or the caller must set up exception handlers to catch the exceptions.\r | |
4437 | This function is only available on IA-32 and X64.\r | |
4438 | \r | |
4439 | If StartBit is greater than 63, then ASSERT().\r | |
4440 | If EndBit is greater than 63, then ASSERT().\r | |
4441 | If EndBit is less than StartBit, then ASSERT().\r | |
4442 | \r | |
4443 | @param Index The 32-bit MSR index to write.\r | |
4444 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
4445 | Range 0..63.\r | |
4446 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
4447 | Range 0..63.\r | |
4448 | @param Value New value of the bit field.\r | |
4449 | \r | |
4450 | @return The value written back to the MSR.\r | |
4451 | \r | |
4452 | **/\r | |
4453 | UINT64\r | |
4454 | EFIAPI\r | |
4455 | AsmMsrBitFieldWrite64 (\r | |
4456 | IN UINT32 Index,\r | |
4457 | IN UINTN StartBit,\r | |
4458 | IN UINTN EndBit,\r | |
4459 | IN UINT64 Value\r | |
4460 | );\r | |
4461 | \r | |
c7f33ca4 | 4462 | \r |
3eb9473e | 4463 | /**\r |
4464 | Reads a bit field in a 64-bit MSR, performs a bitwise inclusive OR, and\r | |
4465 | writes the result back to the bit field in the 64-bit MSR.\r | |
4466 | \r | |
4467 | Reads the 64-bit MSR specified by Index, performs a bitwise inclusive OR\r | |
4468 | between the read result and the value specified by OrData, and writes the\r | |
4469 | result to the 64-bit MSR specified by Index. The value written to the MSR is\r | |
4470 | returned. Extra left bits in OrData are stripped. The caller must either\r | |
4471 | guarantee that Index and the data written is valid, or the caller must set up\r | |
4472 | exception handlers to catch the exceptions. This function is only available\r | |
4473 | on IA-32 and X64.\r | |
4474 | \r | |
4475 | If StartBit is greater than 63, then ASSERT().\r | |
4476 | If EndBit is greater than 63, then ASSERT().\r | |
4477 | If EndBit is less than StartBit, then ASSERT().\r | |
4478 | \r | |
4479 | @param Index The 32-bit MSR index to write.\r | |
4480 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
4481 | Range 0..63.\r | |
4482 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
4483 | Range 0..63.\r | |
4484 | @param OrData The value to OR with the read value from the bit field.\r | |
4485 | \r | |
4486 | @return The value written back to the MSR.\r | |
4487 | \r | |
4488 | **/\r | |
4489 | UINT64\r | |
4490 | EFIAPI\r | |
4491 | AsmMsrBitFieldOr64 (\r | |
4492 | IN UINT32 Index,\r | |
4493 | IN UINTN StartBit,\r | |
4494 | IN UINTN EndBit,\r | |
4495 | IN UINT64 OrData\r | |
4496 | );\r | |
4497 | \r | |
c7f33ca4 | 4498 | \r |
3eb9473e | 4499 | /**\r |
4500 | Reads a bit field in a 64-bit MSR, performs a bitwise AND, and writes the\r | |
4501 | result back to the bit field in the 64-bit MSR.\r | |
4502 | \r | |
4503 | Reads the 64-bit MSR specified by Index, performs a bitwise AND between the\r | |
4504 | read result and the value specified by AndData, and writes the result to the\r | |
4505 | 64-bit MSR specified by Index. The value written to the MSR is returned.\r | |
4506 | Extra left bits in AndData are stripped. The caller must either guarantee\r | |
4507 | that Index and the data written is valid, or the caller must set up exception\r | |
4508 | handlers to catch the exceptions. This function is only available on IA-32\r | |
4509 | and X64.\r | |
4510 | \r | |
4511 | If StartBit is greater than 63, then ASSERT().\r | |
4512 | If EndBit is greater than 63, then ASSERT().\r | |
4513 | If EndBit is less than StartBit, then ASSERT().\r | |
4514 | \r | |
4515 | @param Index The 32-bit MSR index to write.\r | |
4516 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
4517 | Range 0..63.\r | |
4518 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
4519 | Range 0..63.\r | |
4520 | @param AndData The value to AND with the read value from the bit field.\r | |
4521 | \r | |
4522 | @return The value written back to the MSR.\r | |
4523 | \r | |
4524 | **/\r | |
4525 | UINT64\r | |
4526 | EFIAPI\r | |
4527 | AsmMsrBitFieldAnd64 (\r | |
4528 | IN UINT32 Index,\r | |
4529 | IN UINTN StartBit,\r | |
4530 | IN UINTN EndBit,\r | |
4531 | IN UINT64 AndData\r | |
4532 | );\r | |
4533 | \r | |
c7f33ca4 | 4534 | \r |
3eb9473e | 4535 | /**\r |
4536 | Reads a bit field in a 64-bit MSR, performs a bitwise AND followed by a\r | |
4537 | bitwise inclusive OR, and writes the result back to the bit field in the\r | |
4538 | 64-bit MSR.\r | |
4539 | \r | |
4540 | Reads the 64-bit MSR specified by Index, performs a bitwise AND followed by\r | |
4541 | a bitwise inclusive OR between the read result and the value specified by\r | |
4542 | AndData, and writes the result to the 64-bit MSR specified by Index. The\r | |
4543 | value written to the MSR is returned. Extra left bits in both AndData and\r | |
4544 | OrData are stripped. The caller must either guarantee that Index and the data\r | |
4545 | written is valid, or the caller must set up exception handlers to catch the\r | |
4546 | exceptions. This function is only available on IA-32 and X64.\r | |
4547 | \r | |
4548 | If StartBit is greater than 63, then ASSERT().\r | |
4549 | If EndBit is greater than 63, then ASSERT().\r | |
4550 | If EndBit is less than StartBit, then ASSERT().\r | |
4551 | \r | |
4552 | @param Index The 32-bit MSR index to write.\r | |
4553 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
4554 | Range 0..63.\r | |
4555 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
4556 | Range 0..63.\r | |
4557 | @param AndData The value to AND with the read value from the bit field.\r | |
4558 | @param OrData The value to OR with the result of the AND operation.\r | |
4559 | \r | |
4560 | @return The value written back to the MSR.\r | |
4561 | \r | |
4562 | **/\r | |
4563 | UINT64\r | |
4564 | EFIAPI\r | |
4565 | AsmMsrBitFieldAndThenOr64 (\r | |
4566 | IN UINT32 Index,\r | |
4567 | IN UINTN StartBit,\r | |
4568 | IN UINTN EndBit,\r | |
4569 | IN UINT64 AndData,\r | |
4570 | IN UINT64 OrData\r | |
4571 | );\r | |
4572 | \r | |
c7f33ca4 | 4573 | \r |
3eb9473e | 4574 | /**\r |
4575 | Reads the current value of the EFLAGS register.\r | |
4576 | \r | |
4577 | Reads and returns the current value of the EFLAGS register. This function is\r | |
4578 | only available on IA-32 and X64. This returns a 32-bit value on IA-32 and a\r | |
4579 | 64-bit value on X64.\r | |
4580 | \r | |
4581 | @return EFLAGS on IA-32 or RFLAGS on X64.\r | |
4582 | \r | |
4583 | **/\r | |
4584 | UINTN\r | |
4585 | EFIAPI\r | |
4586 | AsmReadEflags (\r | |
4587 | VOID\r | |
4588 | );\r | |
4589 | \r | |
c7f33ca4 | 4590 | \r |
3eb9473e | 4591 | /**\r |
4592 | Reads the current value of the Control Register 0 (CR0).\r | |
4593 | \r | |
4594 | Reads and returns the current value of CR0. This function is only available\r | |
4595 | on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on\r | |
4596 | X64.\r | |
4597 | \r | |
4598 | @return The value of the Control Register 0 (CR0).\r | |
4599 | \r | |
4600 | **/\r | |
4601 | UINTN\r | |
4602 | EFIAPI\r | |
4603 | AsmReadCr0 (\r | |
4604 | VOID\r | |
4605 | );\r | |
4606 | \r | |
c7f33ca4 | 4607 | \r |
3eb9473e | 4608 | /**\r |
4609 | Reads the current value of the Control Register 2 (CR2).\r | |
4610 | \r | |
4611 | Reads and returns the current value of CR2. This function is only available\r | |
4612 | on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on\r | |
4613 | X64.\r | |
4614 | \r | |
4615 | @return The value of the Control Register 2 (CR2).\r | |
4616 | \r | |
4617 | **/\r | |
4618 | UINTN\r | |
4619 | EFIAPI\r | |
4620 | AsmReadCr2 (\r | |
4621 | VOID\r | |
4622 | );\r | |
4623 | \r | |
c7f33ca4 | 4624 | \r |
3eb9473e | 4625 | /**\r |
4626 | Reads the current value of the Control Register 3 (CR3).\r | |
4627 | \r | |
4628 | Reads and returns the current value of CR3. This function is only available\r | |
4629 | on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on\r | |
4630 | X64.\r | |
4631 | \r | |
4632 | @return The value of the Control Register 3 (CR3).\r | |
4633 | \r | |
4634 | **/\r | |
4635 | UINTN\r | |
4636 | EFIAPI\r | |
4637 | AsmReadCr3 (\r | |
4638 | VOID\r | |
4639 | );\r | |
4640 | \r | |
c7f33ca4 | 4641 | \r |
3eb9473e | 4642 | /**\r |
4643 | Reads the current value of the Control Register 4 (CR4).\r | |
4644 | \r | |
4645 | Reads and returns the current value of CR4. This function is only available\r | |
4646 | on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on\r | |
4647 | X64.\r | |
4648 | \r | |
4649 | @return The value of the Control Register 4 (CR4).\r | |
4650 | \r | |
4651 | **/\r | |
4652 | UINTN\r | |
4653 | EFIAPI\r | |
4654 | AsmReadCr4 (\r | |
4655 | VOID\r | |
4656 | );\r | |
4657 | \r | |
c7f33ca4 | 4658 | \r |
3eb9473e | 4659 | /**\r |
4660 | Writes a value to Control Register 0 (CR0).\r | |
4661 | \r | |
4662 | Writes and returns a new value to CR0. This function is only available on\r | |
4663 | IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.\r | |
4664 | \r | |
4665 | @param Cr0 The value to write to CR0.\r | |
4666 | \r | |
4667 | @return The value written to CR0.\r | |
4668 | \r | |
4669 | **/\r | |
4670 | UINTN\r | |
4671 | EFIAPI\r | |
4672 | AsmWriteCr0 (\r | |
4673 | UINTN Cr0\r | |
4674 | );\r | |
4675 | \r | |
c7f33ca4 | 4676 | \r |
3eb9473e | 4677 | /**\r |
4678 | Writes a value to Control Register 2 (CR2).\r | |
4679 | \r | |
4680 | Writes and returns a new value to CR2. This function is only available on\r | |
4681 | IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.\r | |
4682 | \r | |
4683 | @param Cr2 The value to write to CR2.\r | |
4684 | \r | |
4685 | @return The value written to CR2.\r | |
4686 | \r | |
4687 | **/\r | |
4688 | UINTN\r | |
4689 | EFIAPI\r | |
4690 | AsmWriteCr2 (\r | |
4691 | UINTN Cr2\r | |
4692 | );\r | |
4693 | \r | |
c7f33ca4 | 4694 | \r |
3eb9473e | 4695 | /**\r |
4696 | Writes a value to Control Register 3 (CR3).\r | |
4697 | \r | |
4698 | Writes and returns a new value to CR3. This function is only available on\r | |
4699 | IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.\r | |
4700 | \r | |
4701 | @param Cr3 The value to write to CR3.\r | |
4702 | \r | |
4703 | @return The value written to CR3.\r | |
4704 | \r | |
4705 | **/\r | |
4706 | UINTN\r | |
4707 | EFIAPI\r | |
4708 | AsmWriteCr3 (\r | |
4709 | UINTN Cr3\r | |
4710 | );\r | |
4711 | \r | |
c7f33ca4 | 4712 | \r |
3eb9473e | 4713 | /**\r |
4714 | Writes a value to Control Register 4 (CR4).\r | |
4715 | \r | |
4716 | Writes and returns a new value to CR4. This function is only available on\r | |
4717 | IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.\r | |
4718 | \r | |
4719 | @param Cr4 The value to write to CR4.\r | |
4720 | \r | |
4721 | @return The value written to CR4.\r | |
4722 | \r | |
4723 | **/\r | |
4724 | UINTN\r | |
4725 | EFIAPI\r | |
4726 | AsmWriteCr4 (\r | |
4727 | UINTN Cr4\r | |
4728 | );\r | |
4729 | \r | |
c7f33ca4 | 4730 | \r |
3eb9473e | 4731 | /**\r |
4732 | Reads the current value of Debug Register 0 (DR0).\r | |
4733 | \r | |
4734 | Reads and returns the current value of DR0. This function is only available\r | |
4735 | on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on\r | |
4736 | X64.\r | |
4737 | \r | |
4738 | @return The value of Debug Register 0 (DR0).\r | |
4739 | \r | |
4740 | **/\r | |
4741 | UINTN\r | |
4742 | EFIAPI\r | |
4743 | AsmReadDr0 (\r | |
4744 | VOID\r | |
4745 | );\r | |
4746 | \r | |
c7f33ca4 | 4747 | \r |
3eb9473e | 4748 | /**\r |
4749 | Reads the current value of Debug Register 1 (DR1).\r | |
4750 | \r | |
4751 | Reads and returns the current value of DR1. This function is only available\r | |
4752 | on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on\r | |
4753 | X64.\r | |
4754 | \r | |
4755 | @return The value of Debug Register 1 (DR1).\r | |
4756 | \r | |
4757 | **/\r | |
4758 | UINTN\r | |
4759 | EFIAPI\r | |
4760 | AsmReadDr1 (\r | |
4761 | VOID\r | |
4762 | );\r | |
4763 | \r | |
c7f33ca4 | 4764 | \r |
3eb9473e | 4765 | /**\r |
4766 | Reads the current value of Debug Register 2 (DR2).\r | |
4767 | \r | |
4768 | Reads and returns the current value of DR2. This function is only available\r | |
4769 | on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on\r | |
4770 | X64.\r | |
4771 | \r | |
4772 | @return The value of Debug Register 2 (DR2).\r | |
4773 | \r | |
4774 | **/\r | |
4775 | UINTN\r | |
4776 | EFIAPI\r | |
4777 | AsmReadDr2 (\r | |
4778 | VOID\r | |
4779 | );\r | |
4780 | \r | |
c7f33ca4 | 4781 | \r |
3eb9473e | 4782 | /**\r |
4783 | Reads the current value of Debug Register 3 (DR3).\r | |
4784 | \r | |
4785 | Reads and returns the current value of DR3. This function is only available\r | |
4786 | on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on\r | |
4787 | X64.\r | |
4788 | \r | |
4789 | @return The value of Debug Register 3 (DR3).\r | |
4790 | \r | |
4791 | **/\r | |
4792 | UINTN\r | |
4793 | EFIAPI\r | |
4794 | AsmReadDr3 (\r | |
4795 | VOID\r | |
4796 | );\r | |
4797 | \r | |
c7f33ca4 | 4798 | \r |
3eb9473e | 4799 | /**\r |
4800 | Reads the current value of Debug Register 4 (DR4).\r | |
4801 | \r | |
4802 | Reads and returns the current value of DR4. This function is only available\r | |
4803 | on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on\r | |
4804 | X64.\r | |
4805 | \r | |
4806 | @return The value of Debug Register 4 (DR4).\r | |
4807 | \r | |
4808 | **/\r | |
4809 | UINTN\r | |
4810 | EFIAPI\r | |
4811 | AsmReadDr4 (\r | |
4812 | VOID\r | |
4813 | );\r | |
4814 | \r | |
c7f33ca4 | 4815 | \r |
3eb9473e | 4816 | /**\r |
4817 | Reads the current value of Debug Register 5 (DR5).\r | |
4818 | \r | |
4819 | Reads and returns the current value of DR5. This function is only available\r | |
4820 | on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on\r | |
4821 | X64.\r | |
4822 | \r | |
4823 | @return The value of Debug Register 5 (DR5).\r | |
4824 | \r | |
4825 | **/\r | |
4826 | UINTN\r | |
4827 | EFIAPI\r | |
4828 | AsmReadDr5 (\r | |
4829 | VOID\r | |
4830 | );\r | |
4831 | \r | |
c7f33ca4 | 4832 | \r |
3eb9473e | 4833 | /**\r |
4834 | Reads the current value of Debug Register 6 (DR6).\r | |
4835 | \r | |
4836 | Reads and returns the current value of DR6. This function is only available\r | |
4837 | on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on\r | |
4838 | X64.\r | |
4839 | \r | |
4840 | @return The value of Debug Register 6 (DR6).\r | |
4841 | \r | |
4842 | **/\r | |
4843 | UINTN\r | |
4844 | EFIAPI\r | |
4845 | AsmReadDr6 (\r | |
4846 | VOID\r | |
4847 | );\r | |
4848 | \r | |
c7f33ca4 | 4849 | \r |
3eb9473e | 4850 | /**\r |
4851 | Reads the current value of Debug Register 7 (DR7).\r | |
4852 | \r | |
4853 | Reads and returns the current value of DR7. This function is only available\r | |
4854 | on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on\r | |
4855 | X64.\r | |
4856 | \r | |
4857 | @return The value of Debug Register 7 (DR7).\r | |
4858 | \r | |
4859 | **/\r | |
4860 | UINTN\r | |
4861 | EFIAPI\r | |
4862 | AsmReadDr7 (\r | |
4863 | VOID\r | |
4864 | );\r | |
4865 | \r | |
c7f33ca4 | 4866 | \r |
3eb9473e | 4867 | /**\r |
4868 | Writes a value to Debug Register 0 (DR0).\r | |
4869 | \r | |
4870 | Writes and returns a new value to DR0. This function is only available on\r | |
4871 | IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.\r | |
4872 | \r | |
4873 | @param Dr0 The value to write to Dr0.\r | |
4874 | \r | |
4875 | @return The value written to Debug Register 0 (DR0).\r | |
4876 | \r | |
4877 | **/\r | |
4878 | UINTN\r | |
4879 | EFIAPI\r | |
4880 | AsmWriteDr0 (\r | |
4881 | UINTN Dr0\r | |
4882 | );\r | |
4883 | \r | |
c7f33ca4 | 4884 | \r |
3eb9473e | 4885 | /**\r |
4886 | Writes a value to Debug Register 1 (DR1).\r | |
4887 | \r | |
4888 | Writes and returns a new value to DR1. This function is only available on\r | |
4889 | IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.\r | |
4890 | \r | |
4891 | @param Dr1 The value to write to Dr1.\r | |
4892 | \r | |
4893 | @return The value written to Debug Register 1 (DR1).\r | |
4894 | \r | |
4895 | **/\r | |
4896 | UINTN\r | |
4897 | EFIAPI\r | |
4898 | AsmWriteDr1 (\r | |
4899 | UINTN Dr1\r | |
4900 | );\r | |
4901 | \r | |
c7f33ca4 | 4902 | \r |
3eb9473e | 4903 | /**\r |
4904 | Writes a value to Debug Register 2 (DR2).\r | |
4905 | \r | |
4906 | Writes and returns a new value to DR2. This function is only available on\r | |
4907 | IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.\r | |
4908 | \r | |
4909 | @param Dr2 The value to write to Dr2.\r | |
4910 | \r | |
4911 | @return The value written to Debug Register 2 (DR2).\r | |
4912 | \r | |
4913 | **/\r | |
4914 | UINTN\r | |
4915 | EFIAPI\r | |
4916 | AsmWriteDr2 (\r | |
4917 | UINTN Dr2\r | |
4918 | );\r | |
4919 | \r | |
c7f33ca4 | 4920 | \r |
3eb9473e | 4921 | /**\r |
4922 | Writes a value to Debug Register 3 (DR3).\r | |
4923 | \r | |
4924 | Writes and returns a new value to DR3. This function is only available on\r | |
4925 | IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.\r | |
4926 | \r | |
4927 | @param Dr3 The value to write to Dr3.\r | |
4928 | \r | |
4929 | @return The value written to Debug Register 3 (DR3).\r | |
4930 | \r | |
4931 | **/\r | |
4932 | UINTN\r | |
4933 | EFIAPI\r | |
4934 | AsmWriteDr3 (\r | |
4935 | UINTN Dr3\r | |
4936 | );\r | |
4937 | \r | |
c7f33ca4 | 4938 | \r |
3eb9473e | 4939 | /**\r |
4940 | Writes a value to Debug Register 4 (DR4).\r | |
4941 | \r | |
4942 | Writes and returns a new value to DR4. This function is only available on\r | |
4943 | IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.\r | |
4944 | \r | |
4945 | @param Dr4 The value to write to Dr4.\r | |
4946 | \r | |
4947 | @return The value written to Debug Register 4 (DR4).\r | |
4948 | \r | |
4949 | **/\r | |
4950 | UINTN\r | |
4951 | EFIAPI\r | |
4952 | AsmWriteDr4 (\r | |
4953 | UINTN Dr4\r | |
4954 | );\r | |
4955 | \r | |
c7f33ca4 | 4956 | \r |
3eb9473e | 4957 | /**\r |
4958 | Writes a value to Debug Register 5 (DR5).\r | |
4959 | \r | |
4960 | Writes and returns a new value to DR5. This function is only available on\r | |
4961 | IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.\r | |
4962 | \r | |
4963 | @param Dr5 The value to write to Dr5.\r | |
4964 | \r | |
4965 | @return The value written to Debug Register 5 (DR5).\r | |
4966 | \r | |
4967 | **/\r | |
4968 | UINTN\r | |
4969 | EFIAPI\r | |
4970 | AsmWriteDr5 (\r | |
4971 | UINTN Dr5\r | |
4972 | );\r | |
4973 | \r | |
c7f33ca4 | 4974 | \r |
3eb9473e | 4975 | /**\r |
4976 | Writes a value to Debug Register 6 (DR6).\r | |
4977 | \r | |
4978 | Writes and returns a new value to DR6. This function is only available on\r | |
4979 | IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.\r | |
4980 | \r | |
4981 | @param Dr6 The value to write to Dr6.\r | |
4982 | \r | |
4983 | @return The value written to Debug Register 6 (DR6).\r | |
4984 | \r | |
4985 | **/\r | |
4986 | UINTN\r | |
4987 | EFIAPI\r | |
4988 | AsmWriteDr6 (\r | |
4989 | UINTN Dr6\r | |
4990 | );\r | |
4991 | \r | |
c7f33ca4 | 4992 | \r |
3eb9473e | 4993 | /**\r |
4994 | Writes a value to Debug Register 7 (DR7).\r | |
4995 | \r | |
4996 | Writes and returns a new value to DR7. This function is only available on\r | |
4997 | IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.\r | |
4998 | \r | |
4999 | @param Dr7 The value to write to Dr7.\r | |
5000 | \r | |
5001 | @return The value written to Debug Register 7 (DR7).\r | |
5002 | \r | |
5003 | **/\r | |
5004 | UINTN\r | |
5005 | EFIAPI\r | |
5006 | AsmWriteDr7 (\r | |
5007 | UINTN Dr7\r | |
5008 | );\r | |
5009 | \r | |
c7f33ca4 | 5010 | \r |
3eb9473e | 5011 | /**\r |
5012 | Reads the current value of Code Segment Register (CS).\r | |
5013 | \r | |
5014 | Reads and returns the current value of CS. This function is only available on\r | |
5015 | IA-32 and X64.\r | |
5016 | \r | |
5017 | @return The current value of CS.\r | |
5018 | \r | |
5019 | **/\r | |
5020 | UINT16\r | |
5021 | EFIAPI\r | |
5022 | AsmReadCs (\r | |
5023 | VOID\r | |
5024 | );\r | |
5025 | \r | |
c7f33ca4 | 5026 | \r |
3eb9473e | 5027 | /**\r |
5028 | Reads the current value of Data Segment Register (DS).\r | |
5029 | \r | |
5030 | Reads and returns the current value of DS. This function is only available on\r | |
5031 | IA-32 and X64.\r | |
5032 | \r | |
5033 | @return The current value of DS.\r | |
5034 | \r | |
5035 | **/\r | |
5036 | UINT16\r | |
5037 | EFIAPI\r | |
5038 | AsmReadDs (\r | |
5039 | VOID\r | |
5040 | );\r | |
5041 | \r | |
c7f33ca4 | 5042 | \r |
3eb9473e | 5043 | /**\r |
5044 | Reads the current value of Extra Segment Register (ES).\r | |
5045 | \r | |
5046 | Reads and returns the current value of ES. This function is only available on\r | |
5047 | IA-32 and X64.\r | |
5048 | \r | |
5049 | @return The current value of ES.\r | |
5050 | \r | |
5051 | **/\r | |
5052 | UINT16\r | |
5053 | EFIAPI\r | |
5054 | AsmReadEs (\r | |
5055 | VOID\r | |
5056 | );\r | |
5057 | \r | |
c7f33ca4 | 5058 | \r |
3eb9473e | 5059 | /**\r |
5060 | Reads the current value of FS Data Segment Register (FS).\r | |
5061 | \r | |
5062 | Reads and returns the current value of FS. This function is only available on\r | |
5063 | IA-32 and X64.\r | |
5064 | \r | |
5065 | @return The current value of FS.\r | |
5066 | \r | |
5067 | **/\r | |
5068 | UINT16\r | |
5069 | EFIAPI\r | |
5070 | AsmReadFs (\r | |
5071 | VOID\r | |
5072 | );\r | |
5073 | \r | |
c7f33ca4 | 5074 | \r |
3eb9473e | 5075 | /**\r |
5076 | Reads the current value of GS Data Segment Register (GS).\r | |
5077 | \r | |
5078 | Reads and returns the current value of GS. This function is only available on\r | |
5079 | IA-32 and X64.\r | |
5080 | \r | |
5081 | @return The current value of GS.\r | |
5082 | \r | |
5083 | **/\r | |
5084 | UINT16\r | |
5085 | EFIAPI\r | |
5086 | AsmReadGs (\r | |
5087 | VOID\r | |
5088 | );\r | |
5089 | \r | |
c7f33ca4 | 5090 | \r |
3eb9473e | 5091 | /**\r |
5092 | Reads the current value of Stack Segment Register (SS).\r | |
5093 | \r | |
5094 | Reads and returns the current value of SS. This function is only available on\r | |
5095 | IA-32 and X64.\r | |
5096 | \r | |
5097 | @return The current value of SS.\r | |
5098 | \r | |
5099 | **/\r | |
5100 | UINT16\r | |
5101 | EFIAPI\r | |
5102 | AsmReadSs (\r | |
5103 | VOID\r | |
5104 | );\r | |
5105 | \r | |
c7f33ca4 | 5106 | \r |
3eb9473e | 5107 | /**\r |
5108 | Reads the current value of Task Register (TR).\r | |
5109 | \r | |
5110 | Reads and returns the current value of TR. This function is only available on\r | |
5111 | IA-32 and X64.\r | |
5112 | \r | |
5113 | @return The current value of TR.\r | |
5114 | \r | |
5115 | **/\r | |
5116 | UINT16\r | |
5117 | EFIAPI\r | |
5118 | AsmReadTr (\r | |
5119 | VOID\r | |
5120 | );\r | |
5121 | \r | |
c7f33ca4 | 5122 | \r |
3eb9473e | 5123 | /**\r |
5124 | Reads the current Global Descriptor Table Register(GDTR) descriptor.\r | |
5125 | \r | |
5126 | Reads and returns the current GDTR descriptor and returns it in Gdtr. This\r | |
5127 | function is only available on IA-32 and X64.\r | |
5128 | \r | |
5129 | If Gdtr is NULL, then ASSERT().\r | |
5130 | \r | |
5131 | @param Gdtr Pointer to a GDTR descriptor.\r | |
5132 | \r | |
5133 | **/\r | |
5134 | VOID\r | |
5135 | EFIAPI\r | |
5136 | AsmReadGdtr (\r | |
5137 | OUT IA32_DESCRIPTOR *Gdtr\r | |
5138 | );\r | |
5139 | \r | |
c7f33ca4 | 5140 | \r |
3eb9473e | 5141 | /**\r |
5142 | Writes the current Global Descriptor Table Register (GDTR) descriptor.\r | |
5143 | \r | |
5144 | Writes and the current GDTR descriptor specified by Gdtr. This function is\r | |
5145 | only available on IA-32 and X64.\r | |
5146 | \r | |
5147 | If Gdtr is NULL, then ASSERT().\r | |
5148 | \r | |
5149 | @param Gdtr Pointer to a GDTR descriptor.\r | |
5150 | \r | |
5151 | **/\r | |
5152 | VOID\r | |
5153 | EFIAPI\r | |
5154 | AsmWriteGdtr (\r | |
5155 | IN CONST IA32_DESCRIPTOR *Gdtr\r | |
5156 | );\r | |
5157 | \r | |
c7f33ca4 | 5158 | \r |
3eb9473e | 5159 | /**\r |
5160 | Reads the current Interrupt Descriptor Table Register(GDTR) descriptor.\r | |
5161 | \r | |
5162 | Reads and returns the current IDTR descriptor and returns it in Idtr. This\r | |
5163 | function is only available on IA-32 and X64.\r | |
5164 | \r | |
5165 | If Idtr is NULL, then ASSERT().\r | |
5166 | \r | |
5167 | @param Idtr Pointer to a IDTR descriptor.\r | |
5168 | \r | |
5169 | **/\r | |
5170 | VOID\r | |
5171 | EFIAPI\r | |
5172 | AsmReadIdtr (\r | |
5173 | OUT IA32_DESCRIPTOR *Idtr\r | |
5174 | );\r | |
5175 | \r | |
c7f33ca4 | 5176 | \r |
3eb9473e | 5177 | /**\r |
5178 | Writes the current Interrupt Descriptor Table Register(GDTR) descriptor.\r | |
5179 | \r | |
5180 | Writes the current IDTR descriptor and returns it in Idtr. This function is\r | |
5181 | only available on IA-32 and X64.\r | |
5182 | \r | |
5183 | If Idtr is NULL, then ASSERT().\r | |
5184 | \r | |
5185 | @param Idtr Pointer to a IDTR descriptor.\r | |
5186 | \r | |
5187 | **/\r | |
5188 | VOID\r | |
5189 | EFIAPI\r | |
5190 | AsmWriteIdtr (\r | |
5191 | IN CONST IA32_DESCRIPTOR *Idtr\r | |
5192 | );\r | |
5193 | \r | |
c7f33ca4 | 5194 | \r |
3eb9473e | 5195 | /**\r |
5196 | Reads the current Local Descriptor Table Register(LDTR) selector.\r | |
5197 | \r | |
5198 | Reads and returns the current 16-bit LDTR descriptor value. This function is\r | |
5199 | only available on IA-32 and X64.\r | |
5200 | \r | |
5201 | @return The current selector of LDT.\r | |
5202 | \r | |
5203 | **/\r | |
5204 | UINT16\r | |
5205 | EFIAPI\r | |
5206 | AsmReadLdtr (\r | |
5207 | VOID\r | |
5208 | );\r | |
5209 | \r | |
c7f33ca4 | 5210 | \r |
3eb9473e | 5211 | /**\r |
5212 | Writes the current Local Descriptor Table Register (GDTR) selector.\r | |
5213 | \r | |
5214 | Writes and the current LDTR descriptor specified by Ldtr. This function is\r | |
5215 | only available on IA-32 and X64.\r | |
5216 | \r | |
5217 | @param Ldtr 16-bit LDTR selector value.\r | |
5218 | \r | |
5219 | **/\r | |
5220 | VOID\r | |
5221 | EFIAPI\r | |
5222 | AsmWriteLdtr (\r | |
5223 | IN UINT16 Ldtr\r | |
5224 | );\r | |
5225 | \r | |
c7f33ca4 | 5226 | \r |
3eb9473e | 5227 | /**\r |
5228 | Save the current floating point/SSE/SSE2 context to a buffer.\r | |
5229 | \r | |
5230 | Saves the current floating point/SSE/SSE2 state to the buffer specified by\r | |
5231 | Buffer. Buffer must be aligned on a 16-byte boundary. This function is only\r | |
5232 | available on IA-32 and X64.\r | |
5233 | \r | |
5234 | If Buffer is NULL, then ASSERT().\r | |
5235 | If Buffer is not aligned on a 16-byte boundary, then ASSERT().\r | |
5236 | \r | |
5237 | @param Buffer Pointer to a buffer to save the floating point/SSE/SSE2 context.\r | |
5238 | \r | |
5239 | **/\r | |
5240 | VOID\r | |
5241 | EFIAPI\r | |
5242 | AsmFxSave (\r | |
5243 | OUT IA32_FX_BUFFER *Buffer\r | |
5244 | );\r | |
5245 | \r | |
c7f33ca4 | 5246 | \r |
3eb9473e | 5247 | /**\r |
5248 | Restores the current floating point/SSE/SSE2 context from a buffer.\r | |
5249 | \r | |
5250 | Restores the current floating point/SSE/SSE2 state from the buffer specified\r | |
5251 | by Buffer. Buffer must be aligned on a 16-byte boundary. This function is\r | |
5252 | only available on IA-32 and X64.\r | |
5253 | \r | |
5254 | If Buffer is NULL, then ASSERT().\r | |
5255 | If Buffer is not aligned on a 16-byte boundary, then ASSERT().\r | |
5256 | If Buffer was not saved with AsmFxSave(), then ASSERT().\r | |
5257 | \r | |
5258 | @param Buffer Pointer to a buffer to save the floating point/SSE/SSE2 context.\r | |
5259 | \r | |
5260 | **/\r | |
5261 | VOID\r | |
5262 | EFIAPI\r | |
5263 | AsmFxRestore (\r | |
5264 | IN CONST IA32_FX_BUFFER *Buffer\r | |
5265 | );\r | |
5266 | \r | |
c7f33ca4 | 5267 | \r |
3eb9473e | 5268 | /**\r |
5269 | Reads the current value of 64-bit MMX Register #0 (MM0).\r | |
5270 | \r | |
5271 | Reads and returns the current value of MM0. This function is only available\r | |
5272 | on IA-32 and X64.\r | |
5273 | \r | |
5274 | @return The current value of MM0.\r | |
5275 | \r | |
5276 | **/\r | |
5277 | UINT64\r | |
5278 | EFIAPI\r | |
5279 | AsmReadMm0 (\r | |
5280 | VOID\r | |
5281 | );\r | |
5282 | \r | |
c7f33ca4 | 5283 | \r |
3eb9473e | 5284 | /**\r |
5285 | Reads the current value of 64-bit MMX Register #1 (MM1).\r | |
5286 | \r | |
5287 | Reads and returns the current value of MM1. This function is only available\r | |
5288 | on IA-32 and X64.\r | |
5289 | \r | |
5290 | @return The current value of MM1.\r | |
5291 | \r | |
5292 | **/\r | |
5293 | UINT64\r | |
5294 | EFIAPI\r | |
5295 | AsmReadMm1 (\r | |
5296 | VOID\r | |
5297 | );\r | |
5298 | \r | |
c7f33ca4 | 5299 | \r |
3eb9473e | 5300 | /**\r |
5301 | Reads the current value of 64-bit MMX Register #2 (MM2).\r | |
5302 | \r | |
5303 | Reads and returns the current value of MM2. This function is only available\r | |
5304 | on IA-32 and X64.\r | |
5305 | \r | |
5306 | @return The current value of MM2.\r | |
5307 | \r | |
5308 | **/\r | |
5309 | UINT64\r | |
5310 | EFIAPI\r | |
5311 | AsmReadMm2 (\r | |
5312 | VOID\r | |
5313 | );\r | |
5314 | \r | |
c7f33ca4 | 5315 | \r |
3eb9473e | 5316 | /**\r |
5317 | Reads the current value of 64-bit MMX Register #3 (MM3).\r | |
5318 | \r | |
5319 | Reads and returns the current value of MM3. This function is only available\r | |
5320 | on IA-32 and X64.\r | |
5321 | \r | |
5322 | @return The current value of MM3.\r | |
5323 | \r | |
5324 | **/\r | |
5325 | UINT64\r | |
5326 | EFIAPI\r | |
5327 | AsmReadMm3 (\r | |
5328 | VOID\r | |
5329 | );\r | |
5330 | \r | |
c7f33ca4 | 5331 | \r |
3eb9473e | 5332 | /**\r |
5333 | Reads the current value of 64-bit MMX Register #4 (MM4).\r | |
5334 | \r | |
5335 | Reads and returns the current value of MM4. This function is only available\r | |
5336 | on IA-32 and X64.\r | |
5337 | \r | |
5338 | @return The current value of MM4.\r | |
5339 | \r | |
5340 | **/\r | |
5341 | UINT64\r | |
5342 | EFIAPI\r | |
5343 | AsmReadMm4 (\r | |
5344 | VOID\r | |
5345 | );\r | |
5346 | \r | |
c7f33ca4 | 5347 | \r |
3eb9473e | 5348 | /**\r |
5349 | Reads the current value of 64-bit MMX Register #5 (MM5).\r | |
5350 | \r | |
5351 | Reads and returns the current value of MM5. This function is only available\r | |
5352 | on IA-32 and X64.\r | |
5353 | \r | |
5354 | @return The current value of MM5.\r | |
5355 | \r | |
5356 | **/\r | |
5357 | UINT64\r | |
5358 | EFIAPI\r | |
5359 | AsmReadMm5 (\r | |
5360 | VOID\r | |
5361 | );\r | |
5362 | \r | |
c7f33ca4 | 5363 | \r |
3eb9473e | 5364 | /**\r |
5365 | Reads the current value of 64-bit MMX Register #6 (MM6).\r | |
5366 | \r | |
5367 | Reads and returns the current value of MM6. This function is only available\r | |
5368 | on IA-32 and X64.\r | |
5369 | \r | |
5370 | @return The current value of MM6.\r | |
5371 | \r | |
5372 | **/\r | |
5373 | UINT64\r | |
5374 | EFIAPI\r | |
5375 | AsmReadMm6 (\r | |
5376 | VOID\r | |
5377 | );\r | |
5378 | \r | |
c7f33ca4 | 5379 | \r |
3eb9473e | 5380 | /**\r |
5381 | Reads the current value of 64-bit MMX Register #7 (MM7).\r | |
5382 | \r | |
5383 | Reads and returns the current value of MM7. This function is only available\r | |
5384 | on IA-32 and X64.\r | |
5385 | \r | |
5386 | @return The current value of MM7.\r | |
5387 | \r | |
5388 | **/\r | |
5389 | UINT64\r | |
5390 | EFIAPI\r | |
5391 | AsmReadMm7 (\r | |
5392 | VOID\r | |
5393 | );\r | |
5394 | \r | |
c7f33ca4 | 5395 | \r |
3eb9473e | 5396 | /**\r |
5397 | Writes the current value of 64-bit MMX Register #0 (MM0).\r | |
5398 | \r | |
5399 | Writes the current value of MM0. This function is only available on IA32 and\r | |
5400 | X64.\r | |
5401 | \r | |
5402 | @param Value The 64-bit value to write to MM0.\r | |
5403 | \r | |
5404 | **/\r | |
5405 | VOID\r | |
5406 | EFIAPI\r | |
5407 | AsmWriteMm0 (\r | |
5408 | IN UINT64 Value\r | |
5409 | );\r | |
5410 | \r | |
c7f33ca4 | 5411 | \r |
3eb9473e | 5412 | /**\r |
5413 | Writes the current value of 64-bit MMX Register #1 (MM1).\r | |
5414 | \r | |
5415 | Writes the current value of MM1. This function is only available on IA32 and\r | |
5416 | X64.\r | |
5417 | \r | |
5418 | @param Value The 64-bit value to write to MM1.\r | |
5419 | \r | |
5420 | **/\r | |
5421 | VOID\r | |
5422 | EFIAPI\r | |
5423 | AsmWriteMm1 (\r | |
5424 | IN UINT64 Value\r | |
5425 | );\r | |
5426 | \r | |
c7f33ca4 | 5427 | \r |
3eb9473e | 5428 | /**\r |
5429 | Writes the current value of 64-bit MMX Register #2 (MM2).\r | |
5430 | \r | |
5431 | Writes the current value of MM2. This function is only available on IA32 and\r | |
5432 | X64.\r | |
5433 | \r | |
5434 | @param Value The 64-bit value to write to MM2.\r | |
5435 | \r | |
5436 | **/\r | |
5437 | VOID\r | |
5438 | EFIAPI\r | |
5439 | AsmWriteMm2 (\r | |
5440 | IN UINT64 Value\r | |
5441 | );\r | |
5442 | \r | |
c7f33ca4 | 5443 | \r |
3eb9473e | 5444 | /**\r |
5445 | Writes the current value of 64-bit MMX Register #3 (MM3).\r | |
5446 | \r | |
5447 | Writes the current value of MM3. This function is only available on IA32 and\r | |
5448 | X64.\r | |
5449 | \r | |
5450 | @param Value The 64-bit value to write to MM3.\r | |
5451 | \r | |
5452 | **/\r | |
5453 | VOID\r | |
5454 | EFIAPI\r | |
5455 | AsmWriteMm3 (\r | |
5456 | IN UINT64 Value\r | |
5457 | );\r | |
5458 | \r | |
c7f33ca4 | 5459 | \r |
3eb9473e | 5460 | /**\r |
5461 | Writes the current value of 64-bit MMX Register #4 (MM4).\r | |
5462 | \r | |
5463 | Writes the current value of MM4. This function is only available on IA32 and\r | |
5464 | X64.\r | |
5465 | \r | |
5466 | @param Value The 64-bit value to write to MM4.\r | |
5467 | \r | |
5468 | **/\r | |
5469 | VOID\r | |
5470 | EFIAPI\r | |
5471 | AsmWriteMm4 (\r | |
5472 | IN UINT64 Value\r | |
5473 | );\r | |
5474 | \r | |
c7f33ca4 | 5475 | \r |
3eb9473e | 5476 | /**\r |
5477 | Writes the current value of 64-bit MMX Register #5 (MM5).\r | |
5478 | \r | |
5479 | Writes the current value of MM5. This function is only available on IA32 and\r | |
5480 | X64.\r | |
5481 | \r | |
5482 | @param Value The 64-bit value to write to MM5.\r | |
5483 | \r | |
5484 | **/\r | |
5485 | VOID\r | |
5486 | EFIAPI\r | |
5487 | AsmWriteMm5 (\r | |
5488 | IN UINT64 Value\r | |
5489 | );\r | |
5490 | \r | |
c7f33ca4 | 5491 | \r |
3eb9473e | 5492 | /**\r |
5493 | Writes the current value of 64-bit MMX Register #6 (MM6).\r | |
5494 | \r | |
5495 | Writes the current value of MM6. This function is only available on IA32 and\r | |
5496 | X64.\r | |
5497 | \r | |
5498 | @param Value The 64-bit value to write to MM6.\r | |
5499 | \r | |
5500 | **/\r | |
5501 | VOID\r | |
5502 | EFIAPI\r | |
5503 | AsmWriteMm6 (\r | |
5504 | IN UINT64 Value\r | |
5505 | );\r | |
5506 | \r | |
c7f33ca4 | 5507 | \r |
3eb9473e | 5508 | /**\r |
5509 | Writes the current value of 64-bit MMX Register #7 (MM7).\r | |
5510 | \r | |
5511 | Writes the current value of MM7. This function is only available on IA32 and\r | |
5512 | X64.\r | |
5513 | \r | |
5514 | @param Value The 64-bit value to write to MM7.\r | |
5515 | \r | |
5516 | **/\r | |
5517 | VOID\r | |
5518 | EFIAPI\r | |
5519 | AsmWriteMm7 (\r | |
5520 | IN UINT64 Value\r | |
5521 | );\r | |
5522 | \r | |
c7f33ca4 | 5523 | \r |
3eb9473e | 5524 | /**\r |
5525 | Reads the current value of Time Stamp Counter (TSC).\r | |
5526 | \r | |
5527 | Reads and returns the current value of TSC. This function is only available\r | |
5528 | on IA-32 and X64.\r | |
5529 | \r | |
5530 | @return The current value of TSC\r | |
5531 | \r | |
5532 | **/\r | |
5533 | UINT64\r | |
5534 | EFIAPI\r | |
5535 | AsmReadTsc (\r | |
5536 | VOID\r | |
5537 | );\r | |
5538 | \r | |
c7f33ca4 | 5539 | \r |
3eb9473e | 5540 | /**\r |
5541 | Reads the current value of a Performance Counter (PMC).\r | |
5542 | \r | |
5543 | Reads and returns the current value of performance counter specified by\r | |
5544 | Index. This function is only available on IA-32 and X64.\r | |
5545 | \r | |
5546 | @param Index The 32-bit Performance Counter index to read.\r | |
5547 | \r | |
5548 | @return The value of the PMC specified by Index.\r | |
5549 | \r | |
5550 | **/\r | |
5551 | UINT64\r | |
5552 | EFIAPI\r | |
5553 | AsmReadPmc (\r | |
5554 | IN UINT32 Index\r | |
5555 | );\r | |
5556 | \r | |
c7f33ca4 | 5557 | \r |
3eb9473e | 5558 | /**\r |
5559 | Sets up a monitor buffer that is used by AsmMwait().\r | |
5560 | \r | |
5561 | Executes a MONITOR instruction with the register state specified by Eax, Ecx\r | |
5562 | and Edx. Returns Eax. This function is only available on IA-32 and X64.\r | |
5563 | \r | |
5564 | @param Eax The value to load into EAX or RAX before executing the MONITOR\r | |
5565 | instruction.\r | |
5566 | @param Ecx The value to load into ECX or RCX before executing the MONITOR\r | |
5567 | instruction.\r | |
5568 | @param Edx The value to load into EDX or RDX before executing the MONITOR\r | |
5569 | instruction.\r | |
5570 | \r | |
5571 | @return Eax\r | |
5572 | \r | |
5573 | **/\r | |
5574 | UINTN\r | |
5575 | EFIAPI\r | |
5576 | AsmMonitor (\r | |
5577 | IN UINTN Eax,\r | |
5578 | IN UINTN Ecx,\r | |
5579 | IN UINTN Edx\r | |
5580 | );\r | |
5581 | \r | |
c7f33ca4 | 5582 | \r |
3eb9473e | 5583 | /**\r |
5584 | Executes an MWAIT instruction.\r | |
5585 | \r | |
5586 | Executes an MWAIT instruction with the register state specified by Eax and\r | |
5587 | Ecx. Returns Eax. This function is only available on IA-32 and X64.\r | |
5588 | \r | |
5589 | @param Eax The value to load into EAX or RAX before executing the MONITOR\r | |
5590 | instruction.\r | |
5591 | @param Ecx The value to load into ECX or RCX before executing the MONITOR\r | |
5592 | instruction.\r | |
5593 | \r | |
5594 | @return Eax\r | |
5595 | \r | |
5596 | **/\r | |
5597 | UINTN\r | |
5598 | EFIAPI\r | |
5599 | AsmMwait (\r | |
5600 | IN UINTN Eax,\r | |
5601 | IN UINTN Ecx\r | |
5602 | );\r | |
5603 | \r | |
c7f33ca4 | 5604 | \r |
3eb9473e | 5605 | /**\r |
5606 | Executes a WBINVD instruction.\r | |
5607 | \r | |
5608 | Executes a WBINVD instruction. This function is only available on IA-32 and\r | |
5609 | X64.\r | |
5610 | \r | |
5611 | **/\r | |
5612 | VOID\r | |
5613 | EFIAPI\r | |
5614 | AsmWbinvd (\r | |
5615 | VOID\r | |
5616 | );\r | |
5617 | \r | |
c7f33ca4 | 5618 | \r |
3eb9473e | 5619 | /**\r |
5620 | Executes a INVD instruction.\r | |
5621 | \r | |
5622 | Executes a INVD instruction. This function is only available on IA-32 and\r | |
5623 | X64.\r | |
5624 | \r | |
5625 | **/\r | |
5626 | VOID\r | |
5627 | EFIAPI\r | |
5628 | AsmInvd (\r | |
5629 | VOID\r | |
5630 | );\r | |
5631 | \r | |
c7f33ca4 | 5632 | \r |
3eb9473e | 5633 | /**\r |
5634 | Flushes a cache line from all the instruction and data caches within the\r | |
5635 | coherency domain of the CPU.\r | |
5636 | \r | |
5637 | Flushed the cache line specified by LinearAddress, and returns LinearAddress.\r | |
5638 | This function is only available on IA-32 and X64.\r | |
5639 | \r | |
5640 | @param LinearAddress The address of the cache line to flush. If the CPU is\r | |
5641 | in a physical addressing mode, then LinearAddress is a\r | |
5642 | physical address. If the CPU is in a virtual\r | |
5643 | addressing mode, then LinearAddress is a virtual\r | |
5644 | address.\r | |
5645 | \r | |
5646 | @return LinearAddress\r | |
5647 | **/\r | |
5648 | VOID *\r | |
5649 | EFIAPI\r | |
5650 | AsmFlushCacheLine (\r | |
5651 | IN VOID *LinearAddress\r | |
5652 | );\r | |
5653 | \r | |
c7f33ca4 | 5654 | \r |
3eb9473e | 5655 | /**\r |
5656 | Enables the 32-bit paging mode on the CPU.\r | |
5657 | \r | |
5658 | Enables the 32-bit paging mode on the CPU. CR0, CR3, CR4, and the page tables\r | |
5659 | must be properly initialized prior to calling this service. This function\r | |
5660 | assumes the current execution mode is 32-bit protected mode. This function is\r | |
5661 | only available on IA-32. After the 32-bit paging mode is enabled, control is\r | |
5662 | transferred to the function specified by EntryPoint using the new stack\r | |
5663 | specified by NewStack and passing in the parameters specified by Context1 and\r | |
5664 | Context2. Context1 and Context2 are optional and may be NULL. The function\r | |
5665 | EntryPoint must never return.\r | |
5666 | \r | |
5667 | If the current execution mode is not 32-bit protected mode, then ASSERT().\r | |
5668 | If EntryPoint is NULL, then ASSERT().\r | |
5669 | If NewStack is NULL, then ASSERT().\r | |
5670 | \r | |
5671 | There are a number of constraints that must be followed before calling this\r | |
5672 | function:\r | |
5673 | 1) Interrupts must be disabled.\r | |
5674 | 2) The caller must be in 32-bit protected mode with flat descriptors. This\r | |
5675 | means all descriptors must have a base of 0 and a limit of 4GB.\r | |
5676 | 3) CR0 and CR4 must be compatible with 32-bit protected mode with flat\r | |
5677 | descriptors.\r | |
5678 | 4) CR3 must point to valid page tables that will be used once the transition\r | |
5679 | is complete, and those page tables must guarantee that the pages for this\r | |
5680 | function and the stack are identity mapped.\r | |
5681 | \r | |
5682 | @param EntryPoint A pointer to function to call with the new stack after\r | |
5683 | paging is enabled.\r | |
5684 | @param Context1 A pointer to the context to pass into the EntryPoint\r | |
5685 | function as the first parameter after paging is enabled.\r | |
5686 | @param Context2 A pointer to the context to pass into the EntryPoint\r | |
5687 | function as the second parameter after paging is enabled.\r | |
5688 | @param NewStack A pointer to the new stack to use for the EntryPoint\r | |
5689 | function after paging is enabled.\r | |
5690 | \r | |
5691 | **/\r | |
5692 | VOID\r | |
5693 | EFIAPI\r | |
5694 | AsmEnablePaging32 (\r | |
5695 | IN SWITCH_STACK_ENTRY_POINT EntryPoint,\r | |
5696 | IN VOID *Context1, OPTIONAL\r | |
5697 | IN VOID *Context2, OPTIONAL\r | |
5698 | IN VOID *NewStack\r | |
5699 | );\r | |
5700 | \r | |
c7f33ca4 | 5701 | \r |
3eb9473e | 5702 | /**\r |
5703 | Disables the 32-bit paging mode on the CPU.\r | |
5704 | \r | |
5705 | Disables the 32-bit paging mode on the CPU and returns to 32-bit protected\r | |
5706 | mode. This function assumes the current execution mode is 32-paged protected\r | |
5707 | mode. This function is only available on IA-32. After the 32-bit paging mode\r | |
5708 | is disabled, control is transferred to the function specified by EntryPoint\r | |
5709 | using the new stack specified by NewStack and passing in the parameters\r | |
5710 | specified by Context1 and Context2. Context1 and Context2 are optional and\r | |
5711 | may be NULL. The function EntryPoint must never return.\r | |
5712 | \r | |
5713 | If the current execution mode is not 32-bit paged mode, then ASSERT().\r | |
5714 | If EntryPoint is NULL, then ASSERT().\r | |
5715 | If NewStack is NULL, then ASSERT().\r | |
5716 | \r | |
5717 | There are a number of constraints that must be followed before calling this\r | |
5718 | function:\r | |
5719 | 1) Interrupts must be disabled.\r | |
5720 | 2) The caller must be in 32-bit paged mode.\r | |
5721 | 3) CR0, CR3, and CR4 must be compatible with 32-bit paged mode.\r | |
5722 | 4) CR3 must point to valid page tables that guarantee that the pages for\r | |
5723 | this function and the stack are identity mapped.\r | |
5724 | \r | |
5725 | @param EntryPoint A pointer to function to call with the new stack after\r | |
5726 | paging is disabled.\r | |
5727 | @param Context1 A pointer to the context to pass into the EntryPoint\r | |
5728 | function as the first parameter after paging is disabled.\r | |
5729 | @param Context2 A pointer to the context to pass into the EntryPoint\r | |
5730 | function as the second parameter after paging is\r | |
5731 | disabled.\r | |
5732 | @param NewStack A pointer to the new stack to use for the EntryPoint\r | |
5733 | function after paging is disabled.\r | |
5734 | \r | |
5735 | **/\r | |
5736 | VOID\r | |
5737 | EFIAPI\r | |
5738 | AsmDisablePaging32 (\r | |
5739 | IN SWITCH_STACK_ENTRY_POINT EntryPoint,\r | |
5740 | IN VOID *Context1, OPTIONAL\r | |
5741 | IN VOID *Context2, OPTIONAL\r | |
5742 | IN VOID *NewStack\r | |
5743 | );\r | |
5744 | \r | |
c7f33ca4 | 5745 | \r |
3eb9473e | 5746 | /**\r |
5747 | Enables the 64-bit paging mode on the CPU.\r | |
5748 | \r | |
5749 | Enables the 64-bit paging mode on the CPU. CR0, CR3, CR4, and the page tables\r | |
5750 | must be properly initialized prior to calling this service. This function\r | |
5751 | assumes the current execution mode is 32-bit protected mode with flat\r | |
5752 | descriptors. This function is only available on IA-32. After the 64-bit\r | |
5753 | paging mode is enabled, control is transferred to the function specified by\r | |
5754 | EntryPoint using the new stack specified by NewStack and passing in the\r | |
5755 | parameters specified by Context1 and Context2. Context1 and Context2 are\r | |
5756 | optional and may be 0. The function EntryPoint must never return.\r | |
5757 | \r | |
5758 | If the current execution mode is not 32-bit protected mode with flat\r | |
5759 | descriptors, then ASSERT().\r | |
5760 | If EntryPoint is 0, then ASSERT().\r | |
5761 | If NewStack is 0, then ASSERT().\r | |
5762 | \r | |
5763 | @param Cs The 16-bit selector to load in the CS before EntryPoint\r | |
5764 | is called. The descriptor in the GDT that this selector\r | |
5765 | references must be setup for long mode.\r | |
5766 | @param EntryPoint The 64-bit virtual address of the function to call with\r | |
5767 | the new stack after paging is enabled.\r | |
5768 | @param Context1 The 64-bit virtual address of the context to pass into\r | |
5769 | the EntryPoint function as the first parameter after\r | |
5770 | paging is enabled.\r | |
5771 | @param Context2 The 64-bit virtual address of the context to pass into\r | |
5772 | the EntryPoint function as the second parameter after\r | |
5773 | paging is enabled.\r | |
5774 | @param NewStack The 64-bit virtual address of the new stack to use for\r | |
5775 | the EntryPoint function after paging is enabled.\r | |
5776 | \r | |
5777 | **/\r | |
5778 | VOID\r | |
5779 | EFIAPI\r | |
5780 | AsmEnablePaging64 (\r | |
5781 | IN UINT16 CodeSelector,\r | |
5782 | IN UINT64 EntryPoint,\r | |
5783 | IN UINT64 Context1, OPTIONAL\r | |
5784 | IN UINT64 Context2, OPTIONAL\r | |
5785 | IN UINT64 NewStack\r | |
5786 | );\r | |
5787 | \r | |
c7f33ca4 | 5788 | \r |
3eb9473e | 5789 | /**\r |
5790 | Disables the 64-bit paging mode on the CPU.\r | |
5791 | \r | |
5792 | Disables the 64-bit paging mode on the CPU and returns to 32-bit protected\r | |
5793 | mode. This function assumes the current execution mode is 64-paging mode.\r | |
5794 | This function is only available on X64. After the 64-bit paging mode is\r | |
5795 | disabled, control is transferred to the function specified by EntryPoint\r | |
5796 | using the new stack specified by NewStack and passing in the parameters\r | |
5797 | specified by Context1 and Context2. Context1 and Context2 are optional and\r | |
5798 | may be 0. The function EntryPoint must never return.\r | |
5799 | \r | |
5800 | If the current execution mode is not 64-bit paged mode, then ASSERT().\r | |
5801 | If EntryPoint is 0, then ASSERT().\r | |
5802 | If NewStack is 0, then ASSERT().\r | |
5803 | \r | |
5804 | @param Cs The 16-bit selector to load in the CS before EntryPoint\r | |
5805 | is called. The descriptor in the GDT that this selector\r | |
5806 | references must be setup for 32-bit protected mode.\r | |
5807 | @param EntryPoint The 64-bit virtual address of the function to call with\r | |
5808 | the new stack after paging is disabled.\r | |
5809 | @param Context1 The 64-bit virtual address of the context to pass into\r | |
5810 | the EntryPoint function as the first parameter after\r | |
5811 | paging is disabled.\r | |
5812 | @param Context2 The 64-bit virtual address of the context to pass into\r | |
5813 | the EntryPoint function as the second parameter after\r | |
5814 | paging is disabled.\r | |
5815 | @param NewStack The 64-bit virtual address of the new stack to use for\r | |
5816 | the EntryPoint function after paging is disabled.\r | |
5817 | \r | |
5818 | **/\r | |
5819 | VOID\r | |
5820 | EFIAPI\r | |
5821 | AsmDisablePaging64 (\r | |
5822 | IN UINT16 CodeSelector,\r | |
5823 | IN UINT32 EntryPoint,\r | |
5824 | IN UINT32 Context1, OPTIONAL\r | |
5825 | IN UINT32 Context2, OPTIONAL\r | |
5826 | IN UINT32 NewStack\r | |
5827 | );\r | |
5828 | \r | |
c7f33ca4 | 5829 | \r |
3eb9473e | 5830 | //\r |
5831 | // 16-bit thunking services\r | |
5832 | //\r | |
5833 | \r | |
5834 | /**\r | |
5835 | Retrieves the properties for 16-bit thunk functions.\r | |
5836 | \r | |
5837 | Computes the size of the buffer and stack below 1MB required to use the\r | |
5838 | AsmPrepareThunk16(), AsmThunk16() and AsmPrepareAndThunk16() functions. This\r | |
5839 | buffer size is returned in RealModeBufferSize, and the stack size is returned\r | |
5840 | in ExtraStackSize. If parameters are passed to the 16-bit real mode code,\r | |
5841 | then the actual minimum stack size is ExtraStackSize plus the maximum number\r | |
5842 | of bytes that need to be passed to the 16-bit real mode code.\r | |
5843 | \r | |
5844 | If RealModeBufferSize is NULL, then ASSERT().\r | |
5845 | If ExtraStackSize is NULL, then ASSERT().\r | |
5846 | \r | |
5847 | @param RealModeBufferSize A pointer to the size of the buffer below 1MB\r | |
5848 | required to use the 16-bit thunk functions.\r | |
5849 | @param ExtraStackSize A pointer to the extra size of stack below 1MB\r | |
5850 | that the 16-bit thunk functions require for\r | |
5851 | temporary storage in the transition to and from\r | |
5852 | 16-bit real mode.\r | |
5853 | \r | |
5854 | **/\r | |
5855 | VOID\r | |
5856 | EFIAPI\r | |
5857 | AsmGetThunk16Properties (\r | |
5858 | OUT UINT32 *RealModeBufferSize,\r | |
5859 | OUT UINT32 *ExtraStackSize\r | |
5860 | );\r | |
5861 | \r | |
c7f33ca4 | 5862 | \r |
3eb9473e | 5863 | /**\r |
5864 | Prepares all structures a code required to use AsmThunk16().\r | |
5865 | \r | |
5866 | Prepares all structures and code required to use AsmThunk16().\r | |
5867 | \r | |
5868 | If ThunkContext is NULL, then ASSERT().\r | |
5869 | \r | |
5870 | @param ThunkContext A pointer to the context structure that describes the\r | |
5871 | 16-bit real mode code to call.\r | |
5872 | \r | |
5873 | **/\r | |
5874 | VOID\r | |
5875 | EFIAPI\r | |
5876 | AsmPrepareThunk16 (\r | |
5877 | OUT THUNK_CONTEXT *ThunkContext\r | |
5878 | );\r | |
5879 | \r | |
c7f33ca4 | 5880 | \r |
3eb9473e | 5881 | /**\r |
5882 | Transfers control to a 16-bit real mode entry point and returns the results.\r | |
5883 | \r | |
5884 | Transfers control to a 16-bit real mode entry point and returns the results.\r | |
5885 | AsmPrepareThunk16() must be called with ThunkContext before this function is\r | |
5886 | used.\r | |
5887 | \r | |
5888 | If ThunkContext is NULL, then ASSERT().\r | |
5889 | If AsmPrepareThunk16() was not previously called with ThunkContext, then ASSERT().\r | |
5890 | \r | |
5891 | @param ThunkContext A pointer to the context structure that describes the\r | |
5892 | 16-bit real mode code to call.\r | |
5893 | \r | |
5894 | **/\r | |
5895 | VOID\r | |
5896 | EFIAPI\r | |
5897 | AsmThunk16 (\r | |
5898 | IN OUT THUNK_CONTEXT *ThunkContext\r | |
5899 | );\r | |
5900 | \r | |
c7f33ca4 | 5901 | \r |
3eb9473e | 5902 | /**\r |
5903 | Prepares all structures and code for a 16-bit real mode thunk, transfers\r | |
5904 | control to a 16-bit real mode entry point, and returns the results.\r | |
5905 | \r | |
5906 | Prepares all structures and code for a 16-bit real mode thunk, transfers\r | |
5907 | control to a 16-bit real mode entry point, and returns the results. If the\r | |
5908 | caller only need to perform a single 16-bit real mode thunk, then this\r | |
5909 | service should be used. If the caller intends to make more than one 16-bit\r | |
5910 | real mode thunk, then it is more efficient if AsmPrepareThunk16() is called\r | |
5911 | once and AsmThunk16() can be called for each 16-bit real mode thunk.\r | |
5912 | \r | |
5913 | If ThunkContext is NULL, then ASSERT().\r | |
5914 | \r | |
5915 | @param ThunkContext A pointer to the context structure that describes the\r | |
5916 | 16-bit real mode code to call.\r | |
5917 | \r | |
5918 | **/\r | |
5919 | VOID\r | |
5920 | EFIAPI\r | |
5921 | AsmPrepareAndThunk16 (\r | |
5922 | IN OUT THUNK_CONTEXT *ThunkContext\r | |
5923 | );\r | |
5924 | \r | |
c7f33ca4 | 5925 | #else\r |
3eb9473e | 5926 | \r |
5927 | #endif\r | |
5928 | \r | |
c7f33ca4 | 5929 | #endif\r |