]> git.proxmox.com Git - mirror_edk2.git/blame - MdePkg/Include/Library/BaseLib.h
Add 2 functions to UefiLib library class: CatSPrint and CatVSPrint.
[mirror_edk2.git] / MdePkg / Include / Library / BaseLib.h
CommitLineData
ac644614 1/** @file\r
50a64e5b 2 Provides string functions, linked list functions, math functions, synchronization\r
1a2f870c 3 functions, and CPU architecture-specific functions.\r
ac644614 4\r
1955808d 5Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>\r
9df063a0
HT
6Portions copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>\r
7This program and the accompanying materials\r
50a64e5b 8are licensed and made available under the terms and conditions of the BSD License\r
9which accompanies this distribution. The full text of the license may be found at\r
af2dc6a7 10http://opensource.org/licenses/bsd-license.php.\r
ac644614 11\r
50a64e5b 12THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
13WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
ac644614 14\r
15**/\r
16\r
17#ifndef __BASE_LIB__\r
18#define __BASE_LIB__\r
19\r
1106ffe1 20//\r
1a2f870c 21// Definitions for architecture-specific types\r
1106ffe1 22//\r
ac644614 23#if defined (MDE_CPU_IA32)\r
fc30687f 24///\r
af2dc6a7 25/// The IA-32 architecture context buffer used by SetJump() and LongJump().\r
fc30687f 26///\r
ac644614 27typedef struct {\r
28 UINT32 Ebx;\r
29 UINT32 Esi;\r
30 UINT32 Edi;\r
31 UINT32 Ebp;\r
32 UINT32 Esp;\r
33 UINT32 Eip;\r
34} BASE_LIBRARY_JUMP_BUFFER;\r
35\r
36#define BASE_LIBRARY_JUMP_BUFFER_ALIGNMENT 4\r
37\r
aa4df547 38#endif // defined (MDE_CPU_IA32)\r
39\r
40#if defined (MDE_CPU_IPF)\r
ac644614 41\r
fc30687f 42///\r
af2dc6a7 43/// The Itanium architecture context buffer used by SetJump() and LongJump().\r
fc30687f 44///\r
ac644614 45typedef struct {\r
46 UINT64 F2[2];\r
47 UINT64 F3[2];\r
48 UINT64 F4[2];\r
49 UINT64 F5[2];\r
50 UINT64 F16[2];\r
51 UINT64 F17[2];\r
52 UINT64 F18[2];\r
53 UINT64 F19[2];\r
54 UINT64 F20[2];\r
55 UINT64 F21[2];\r
56 UINT64 F22[2];\r
57 UINT64 F23[2];\r
58 UINT64 F24[2];\r
59 UINT64 F25[2];\r
60 UINT64 F26[2];\r
61 UINT64 F27[2];\r
62 UINT64 F28[2];\r
63 UINT64 F29[2];\r
64 UINT64 F30[2];\r
65 UINT64 F31[2];\r
66 UINT64 R4;\r
67 UINT64 R5;\r
68 UINT64 R6;\r
69 UINT64 R7;\r
70 UINT64 SP;\r
71 UINT64 BR0;\r
72 UINT64 BR1;\r
73 UINT64 BR2;\r
74 UINT64 BR3;\r
75 UINT64 BR4;\r
76 UINT64 BR5;\r
77 UINT64 InitialUNAT;\r
78 UINT64 AfterSpillUNAT;\r
79 UINT64 PFS;\r
80 UINT64 BSP;\r
81 UINT64 Predicates;\r
82 UINT64 LoopCount;\r
83 UINT64 FPSR;\r
84} BASE_LIBRARY_JUMP_BUFFER;\r
85\r
86#define BASE_LIBRARY_JUMP_BUFFER_ALIGNMENT 0x10\r
87\r
aa4df547 88#endif // defined (MDE_CPU_IPF)\r
89\r
90#if defined (MDE_CPU_X64)\r
fc30687f 91///\r
af2dc6a7 92/// The x64 architecture context buffer used by SetJump() and LongJump().\r
fc30687f 93///\r
ac644614 94typedef struct {\r
95 UINT64 Rbx;\r
96 UINT64 Rsp;\r
97 UINT64 Rbp;\r
98 UINT64 Rdi;\r
99 UINT64 Rsi;\r
100 UINT64 R12;\r
101 UINT64 R13;\r
102 UINT64 R14;\r
103 UINT64 R15;\r
104 UINT64 Rip;\r
9b9641c6 105 UINT64 MxCsr;\r
af2dc6a7 106 UINT8 XmmBuffer[160]; ///< XMM6-XMM15.\r
ac644614 107} BASE_LIBRARY_JUMP_BUFFER;\r
108\r
109#define BASE_LIBRARY_JUMP_BUFFER_ALIGNMENT 8\r
110\r
aa4df547 111#endif // defined (MDE_CPU_X64)\r
112\r
113#if defined (MDE_CPU_EBC)\r
fc30687f 114///\r
af2dc6a7 115/// The EBC context buffer used by SetJump() and LongJump().\r
fc30687f 116///\r
ac644614 117typedef 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
aa4df547 127#endif // defined (MDE_CPU_EBC)\r
ac644614 128\r
ebd04fc2 129#if defined (MDE_CPU_ARM)\r
130\r
131typedef struct {\r
af2dc6a7 132 UINT32 R3; ///< A copy of R13.\r
01a54966 133 UINT32 R4;\r
134 UINT32 R5;\r
135 UINT32 R6;\r
136 UINT32 R7;\r
137 UINT32 R8;\r
138 UINT32 R9;\r
139 UINT32 R10;\r
140 UINT32 R11;\r
141 UINT32 R12;\r
142 UINT32 R14;\r
ebd04fc2 143} BASE_LIBRARY_JUMP_BUFFER;\r
144\r
145#define BASE_LIBRARY_JUMP_BUFFER_ALIGNMENT 4\r
146\r
147#endif // defined (MDE_CPU_ARM)\r
148\r
ac644614 149//\r
150// String Services\r
151//\r
152\r
153/**\r
154 Copies one Null-terminated Unicode string to another Null-terminated Unicode\r
155 string and returns the new Unicode string.\r
156\r
157 This function copies the contents of the Unicode string Source to the Unicode\r
158 string Destination, and returns Destination. If Source and Destination\r
159 overlap, then the results are undefined.\r
160\r
161 If Destination is NULL, then ASSERT().\r
162 If Destination is not aligned on a 16-bit boundary, then ASSERT().\r
163 If Source is NULL, then ASSERT().\r
164 If Source is not aligned on a 16-bit boundary, then ASSERT().\r
165 If Source and Destination overlap, then ASSERT().\r
166 If PcdMaximumUnicodeStringLength is not zero, and Source contains more than\r
167 PcdMaximumUnicodeStringLength Unicode characters not including the\r
168 Null-terminator, then ASSERT().\r
169\r
af2dc6a7 170 @param Destination The pointer to a Null-terminated Unicode string.\r
171 @param Source The pointer to a Null-terminated Unicode string.\r
ac644614 172\r
9aa049d9 173 @return Destination.\r
ac644614 174\r
175**/\r
176CHAR16 *\r
177EFIAPI\r
178StrCpy (\r
179 OUT CHAR16 *Destination,\r
180 IN CONST CHAR16 *Source\r
181 );\r
182\r
183\r
184/**\r
af2dc6a7 185 Copies up to a specified length from one Null-terminated Unicode string to \r
17f695ed 186 another Null-terminated Unicode string and returns the new Unicode string.\r
ac644614 187\r
188 This function copies the contents of the Unicode string Source to the Unicode\r
189 string Destination, and returns Destination. At most, Length Unicode\r
190 characters are copied from Source to Destination. If Length is 0, then\r
191 Destination is returned unmodified. If Length is greater that the number of\r
192 Unicode characters in Source, then Destination is padded with Null Unicode\r
193 characters. If Source and Destination overlap, then the results are\r
194 undefined.\r
195\r
196 If Length > 0 and Destination is NULL, then ASSERT().\r
197 If Length > 0 and Destination is not aligned on a 16-bit boundary, then ASSERT().\r
198 If Length > 0 and Source is NULL, then ASSERT().\r
77f863ee 199 If Length > 0 and Source is not aligned on a 16-bit boundary, then ASSERT().\r
ac644614 200 If Source and Destination overlap, then ASSERT().\r
50c247fd 201 If PcdMaximumUnicodeStringLength is not zero, and Length is greater than \r
202 PcdMaximumUnicodeStringLength, then ASSERT().\r
ac644614 203 If PcdMaximumUnicodeStringLength is not zero, and Source contains more than\r
50c247fd 204 PcdMaximumUnicodeStringLength Unicode characters, not including the Null-terminator,\r
205 then ASSERT().\r
ac644614 206\r
af2dc6a7 207 @param Destination The pointer to a Null-terminated Unicode string.\r
208 @param Source The pointer to a Null-terminated Unicode string.\r
209 @param Length The maximum number of Unicode characters to copy.\r
ac644614 210\r
9aa049d9 211 @return Destination.\r
ac644614 212\r
213**/\r
214CHAR16 *\r
215EFIAPI\r
216StrnCpy (\r
217 OUT CHAR16 *Destination,\r
218 IN CONST CHAR16 *Source,\r
219 IN UINTN Length\r
220 );\r
221\r
222\r
223/**\r
224 Returns the length of a Null-terminated Unicode string.\r
225\r
226 This function returns the number of Unicode characters in the Null-terminated\r
227 Unicode string specified by String.\r
228\r
229 If String is NULL, then ASSERT().\r
230 If String is not aligned on a 16-bit boundary, then ASSERT().\r
231 If PcdMaximumUnicodeStringLength is not zero, and String contains more than\r
232 PcdMaximumUnicodeStringLength Unicode characters not including the\r
233 Null-terminator, then ASSERT().\r
234\r
235 @param String Pointer to a Null-terminated Unicode string.\r
236\r
237 @return The length of String.\r
238\r
239**/\r
240UINTN\r
241EFIAPI\r
242StrLen (\r
243 IN CONST CHAR16 *String\r
244 );\r
245\r
246\r
247/**\r
248 Returns the size of a Null-terminated Unicode string in bytes, including the\r
249 Null terminator.\r
250\r
17f695ed 251 This function returns the size, in bytes, of the Null-terminated Unicode string \r
252 specified by String.\r
ac644614 253\r
254 If String is NULL, then ASSERT().\r
255 If String is not aligned on a 16-bit boundary, then ASSERT().\r
256 If PcdMaximumUnicodeStringLength is not zero, and String contains more than\r
257 PcdMaximumUnicodeStringLength Unicode characters not including the\r
258 Null-terminator, then ASSERT().\r
259\r
af2dc6a7 260 @param String The pointer to a Null-terminated Unicode string.\r
ac644614 261\r
262 @return The size of String.\r
263\r
264**/\r
265UINTN\r
266EFIAPI\r
267StrSize (\r
268 IN CONST CHAR16 *String\r
269 );\r
270\r
271\r
272/**\r
273 Compares two Null-terminated Unicode strings, and returns the difference\r
274 between the first mismatched Unicode characters.\r
275\r
276 This function compares the Null-terminated Unicode string FirstString to the\r
277 Null-terminated Unicode string SecondString. If FirstString is identical to\r
278 SecondString, then 0 is returned. Otherwise, the value returned is the first\r
279 mismatched Unicode character in SecondString subtracted from the first\r
280 mismatched Unicode character in FirstString.\r
281\r
282 If FirstString is NULL, then ASSERT().\r
283 If FirstString is not aligned on a 16-bit boundary, then ASSERT().\r
284 If SecondString is NULL, then ASSERT().\r
285 If SecondString is not aligned on a 16-bit boundary, then ASSERT().\r
286 If PcdMaximumUnicodeStringLength is not zero, and FirstString contains more\r
287 than PcdMaximumUnicodeStringLength Unicode characters not including the\r
288 Null-terminator, then ASSERT().\r
289 If PcdMaximumUnicodeStringLength is not zero, and SecondString contains more\r
af2dc6a7 290 than PcdMaximumUnicodeStringLength Unicode characters, not including the\r
ac644614 291 Null-terminator, then ASSERT().\r
292\r
af2dc6a7 293 @param FirstString The pointer to a Null-terminated Unicode string.\r
294 @param SecondString The pointer to a Null-terminated Unicode string.\r
ac644614 295\r
1106ffe1 296 @retval 0 FirstString is identical to SecondString.\r
297 @return others FirstString is not identical to SecondString.\r
ac644614 298\r
299**/\r
300INTN\r
301EFIAPI\r
302StrCmp (\r
303 IN CONST CHAR16 *FirstString,\r
304 IN CONST CHAR16 *SecondString\r
305 );\r
306\r
307\r
308/**\r
17f695ed 309 Compares up to a specified length the contents of two Null-terminated Unicode strings,\r
310 and returns the difference between the first mismatched Unicode characters.\r
311 \r
ac644614 312 This function compares the Null-terminated Unicode string FirstString to the\r
313 Null-terminated Unicode string SecondString. At most, Length Unicode\r
314 characters will be compared. If Length is 0, then 0 is returned. If\r
315 FirstString is identical to SecondString, then 0 is returned. Otherwise, the\r
316 value returned is the first mismatched Unicode character in SecondString\r
317 subtracted from the first mismatched Unicode character in FirstString.\r
318\r
319 If Length > 0 and FirstString is NULL, then ASSERT().\r
77f863ee 320 If Length > 0 and FirstString is not aligned on a 16-bit boundary, then ASSERT().\r
ac644614 321 If Length > 0 and SecondString is NULL, then ASSERT().\r
77f863ee 322 If Length > 0 and SecondString is not aligned on a 16-bit boundary, then ASSERT().\r
50c247fd 323 If PcdMaximumUnicodeStringLength is not zero, and Length is greater than\r
324 PcdMaximumUnicodeStringLength, then ASSERT().\r
325 If PcdMaximumUnicodeStringLength is not zero, and FirstString contains more than\r
326 PcdMaximumUnicodeStringLength Unicode characters, not including the Null-terminator,\r
327 then ASSERT().\r
328 If PcdMaximumUnicodeStringLength is not zero, and SecondString contains more than\r
329 PcdMaximumUnicodeStringLength Unicode characters, not including the Null-terminator,\r
330 then ASSERT().\r
ac644614 331\r
af2dc6a7 332 @param FirstString The pointer to a Null-terminated Unicode string.\r
333 @param SecondString The pointer to a Null-terminated Unicode string.\r
334 @param Length The maximum number of Unicode characters to compare.\r
ac644614 335\r
1106ffe1 336 @retval 0 FirstString is identical to SecondString.\r
337 @return others FirstString is not identical to SecondString.\r
ac644614 338\r
339**/\r
340INTN\r
341EFIAPI\r
342StrnCmp (\r
343 IN CONST CHAR16 *FirstString,\r
344 IN CONST CHAR16 *SecondString,\r
345 IN UINTN Length\r
346 );\r
347\r
348\r
349/**\r
350 Concatenates one Null-terminated Unicode string to another Null-terminated\r
351 Unicode string, and returns the concatenated Unicode string.\r
352\r
353 This function concatenates two Null-terminated Unicode strings. The contents\r
354 of Null-terminated Unicode string Source are concatenated to the end of\r
355 Null-terminated Unicode string Destination. The Null-terminated concatenated\r
356 Unicode String is returned. If Source and Destination overlap, then the\r
357 results are undefined.\r
358\r
359 If Destination is NULL, then ASSERT().\r
77f863ee 360 If Destination is not aligned on a 16-bit boundary, then ASSERT().\r
ac644614 361 If Source is NULL, then ASSERT().\r
77f863ee 362 If Source is not aligned on a 16-bit boundary, then ASSERT().\r
ac644614 363 If Source and Destination overlap, then ASSERT().\r
364 If PcdMaximumUnicodeStringLength is not zero, and Destination contains more\r
af2dc6a7 365 than PcdMaximumUnicodeStringLength Unicode characters, not including the\r
ac644614 366 Null-terminator, then ASSERT().\r
367 If PcdMaximumUnicodeStringLength is not zero, and Source contains more than\r
af2dc6a7 368 PcdMaximumUnicodeStringLength Unicode characters, not including the\r
ac644614 369 Null-terminator, then ASSERT().\r
370 If PcdMaximumUnicodeStringLength is not zero, and concatenating Destination\r
371 and Source results in a Unicode string with more than\r
af2dc6a7 372 PcdMaximumUnicodeStringLength Unicode characters, not including the\r
ac644614 373 Null-terminator, then ASSERT().\r
374\r
af2dc6a7 375 @param Destination The pointer to a Null-terminated Unicode string.\r
376 @param Source The pointer to a Null-terminated Unicode string.\r
ac644614 377\r
9aa049d9 378 @return Destination.\r
ac644614 379\r
380**/\r
381CHAR16 *\r
382EFIAPI\r
383StrCat (\r
384 IN OUT CHAR16 *Destination,\r
385 IN CONST CHAR16 *Source\r
386 );\r
387\r
388\r
389/**\r
17f695ed 390 Concatenates up to a specified length one Null-terminated Unicode to the end \r
391 of another Null-terminated Unicode string, and returns the concatenated \r
ac644614 392 Unicode string.\r
393\r
394 This function concatenates two Null-terminated Unicode strings. The contents\r
395 of Null-terminated Unicode string Source are concatenated to the end of\r
396 Null-terminated Unicode string Destination, and Destination is returned. At\r
397 most, Length Unicode characters are concatenated from Source to the end of\r
398 Destination, and Destination is always Null-terminated. If Length is 0, then\r
399 Destination is returned unmodified. If Source and Destination overlap, then\r
400 the results are undefined.\r
401\r
402 If Destination is NULL, then ASSERT().\r
403 If Length > 0 and Destination is not aligned on a 16-bit boundary, then ASSERT().\r
404 If Length > 0 and Source is NULL, then ASSERT().\r
405 If Length > 0 and Source is not aligned on a 16-bit boundary, then ASSERT().\r
406 If Source and Destination overlap, then ASSERT().\r
50c247fd 407 If PcdMaximumUnicodeStringLength is not zero, and Length is greater than \r
408 PcdMaximumUnicodeStringLength, then ASSERT().\r
ac644614 409 If PcdMaximumUnicodeStringLength is not zero, and Destination contains more\r
50c247fd 410 than PcdMaximumUnicodeStringLength Unicode characters, not including the\r
ac644614 411 Null-terminator, then ASSERT().\r
412 If PcdMaximumUnicodeStringLength is not zero, and Source contains more than\r
50c247fd 413 PcdMaximumUnicodeStringLength Unicode characters, not including the\r
ac644614 414 Null-terminator, then ASSERT().\r
415 If PcdMaximumUnicodeStringLength is not zero, and concatenating Destination\r
50c247fd 416 and Source results in a Unicode string with more than PcdMaximumUnicodeStringLength\r
417 Unicode characters, not including the Null-terminator, then ASSERT().\r
ac644614 418\r
af2dc6a7 419 @param Destination The pointer to a Null-terminated Unicode string.\r
420 @param Source The pointer to a Null-terminated Unicode string.\r
421 @param Length The maximum number of Unicode characters to concatenate from\r
ac644614 422 Source.\r
423\r
9aa049d9 424 @return Destination.\r
ac644614 425\r
426**/\r
427CHAR16 *\r
428EFIAPI\r
429StrnCat (\r
430 IN OUT CHAR16 *Destination,\r
431 IN CONST CHAR16 *Source,\r
432 IN UINTN Length\r
433 );\r
434\r
435/**\r
9aa049d9 436 Returns the first occurrence of a Null-terminated Unicode sub-string\r
ac644614 437 in a Null-terminated Unicode string.\r
438\r
439 This function scans the contents of the Null-terminated Unicode string\r
440 specified by String and returns the first occurrence of SearchString.\r
441 If SearchString is not found in String, then NULL is returned. If\r
af2dc6a7 442 the length of SearchString is zero, then String is returned.\r
ac644614 443\r
444 If String is NULL, then ASSERT().\r
445 If String is not aligned on a 16-bit boundary, then ASSERT().\r
446 If SearchString is NULL, then ASSERT().\r
447 If SearchString is not aligned on a 16-bit boundary, then ASSERT().\r
448\r
449 If PcdMaximumUnicodeStringLength is not zero, and SearchString\r
450 or String contains more than PcdMaximumUnicodeStringLength Unicode\r
af2dc6a7 451 characters, not including the Null-terminator, then ASSERT().\r
ac644614 452\r
af2dc6a7 453 @param String The pointer to a Null-terminated Unicode string.\r
454 @param SearchString The pointer to a Null-terminated Unicode string to search for.\r
ac644614 455\r
456 @retval NULL If the SearchString does not appear in String.\r
1106ffe1 457 @return others If there is a match.\r
ac644614 458\r
459**/\r
460CHAR16 *\r
461EFIAPI\r
462StrStr (\r
17f695ed 463 IN CONST CHAR16 *String,\r
464 IN CONST CHAR16 *SearchString\r
ac644614 465 );\r
466\r
467/**\r
468 Convert a Null-terminated Unicode decimal string to a value of\r
469 type UINTN.\r
470\r
471 This function returns a value of type UINTN by interpreting the contents\r
472 of the Unicode string specified by String as a decimal number. The format\r
473 of the input Unicode string String is:\r
474\r
475 [spaces] [decimal digits].\r
476\r
477 The valid decimal digit character is in the range [0-9]. The\r
478 function will ignore the pad space, which includes spaces or\r
479 tab characters, before [decimal digits]. The running zero in the\r
480 beginning of [decimal digits] will be ignored. Then, the function\r
481 stops at the first character that is a not a valid decimal character\r
482 or a Null-terminator, whichever one comes first.\r
483\r
484 If String is NULL, then ASSERT().\r
485 If String is not aligned in a 16-bit boundary, then ASSERT().\r
486 If String has only pad spaces, then 0 is returned.\r
487 If String has no pad spaces or valid decimal digits,\r
488 then 0 is returned.\r
489 If the number represented by String overflows according\r
490 to the range defined by UINTN, then ASSERT().\r
491\r
492 If PcdMaximumUnicodeStringLength is not zero, and String contains\r
493 more than PcdMaximumUnicodeStringLength Unicode characters not including\r
494 the Null-terminator, then ASSERT().\r
495\r
af2dc6a7 496 @param String The pointer to a Null-terminated Unicode string.\r
ac644614 497\r
38bbd3d9 498 @retval Value translated from String.\r
ac644614 499\r
500**/\r
501UINTN\r
502EFIAPI\r
503StrDecimalToUintn (\r
17f695ed 504 IN CONST CHAR16 *String\r
ac644614 505 );\r
506\r
507/**\r
508 Convert a Null-terminated Unicode decimal string to a value of\r
509 type UINT64.\r
510\r
511 This function returns a value of type UINT64 by interpreting the contents\r
512 of the Unicode string specified by String as a decimal number. The format\r
513 of the input Unicode string String is:\r
514\r
515 [spaces] [decimal digits].\r
516\r
517 The valid decimal digit character is in the range [0-9]. The\r
518 function will ignore the pad space, which includes spaces or\r
519 tab characters, before [decimal digits]. The running zero in the\r
520 beginning of [decimal digits] will be ignored. Then, the function\r
521 stops at the first character that is a not a valid decimal character\r
522 or a Null-terminator, whichever one comes first.\r
523\r
524 If String is NULL, then ASSERT().\r
525 If String is not aligned in a 16-bit boundary, then ASSERT().\r
526 If String has only pad spaces, then 0 is returned.\r
527 If String has no pad spaces or valid decimal digits,\r
528 then 0 is returned.\r
529 If the number represented by String overflows according\r
530 to the range defined by UINT64, then ASSERT().\r
531\r
532 If PcdMaximumUnicodeStringLength is not zero, and String contains\r
533 more than PcdMaximumUnicodeStringLength Unicode characters not including\r
534 the Null-terminator, then ASSERT().\r
535\r
af2dc6a7 536 @param String The pointer to a Null-terminated Unicode string.\r
ac644614 537\r
38bbd3d9 538 @retval Value translated from String.\r
ac644614 539\r
540**/\r
541UINT64\r
542EFIAPI\r
543StrDecimalToUint64 (\r
17f695ed 544 IN CONST CHAR16 *String\r
ac644614 545 );\r
546 \r
547\r
548/**\r
549 Convert a Null-terminated Unicode hexadecimal string to a value of type UINTN.\r
550\r
551 This function returns a value of type UINTN by interpreting the contents\r
552 of the Unicode string specified by String as a hexadecimal number.\r
553 The format of the input Unicode string String is:\r
554\r
555 [spaces][zeros][x][hexadecimal digits].\r
556\r
557 The valid hexadecimal digit character is in the range [0-9], [a-f] and [A-F].\r
558 The prefix "0x" is optional. Both "x" and "X" is allowed in "0x" prefix.\r
559 If "x" appears in the input string, it must be prefixed with at least one 0.\r
560 The function will ignore the pad space, which includes spaces or tab characters,\r
561 before [zeros], [x] or [hexadecimal digit]. The running zero before [x] or\r
562 [hexadecimal digit] will be ignored. Then, the decoding starts after [x] or the\r
af2dc6a7 563 first valid hexadecimal digit. Then, the function stops at the first character \r
564 that is a not a valid hexadecimal character or NULL, whichever one comes first.\r
ac644614 565\r
566 If String is NULL, then ASSERT().\r
567 If String is not aligned in a 16-bit boundary, then ASSERT().\r
568 If String has only pad spaces, then zero is returned.\r
569 If String has no leading pad spaces, leading zeros or valid hexadecimal digits,\r
570 then zero is returned.\r
571 If the number represented by String overflows according to the range defined by\r
572 UINTN, then ASSERT().\r
573\r
574 If PcdMaximumUnicodeStringLength is not zero, and String contains more than\r
575 PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator,\r
576 then ASSERT().\r
577\r
af2dc6a7 578 @param String The pointer to a Null-terminated Unicode string.\r
ac644614 579\r
38bbd3d9 580 @retval Value translated from String.\r
ac644614 581\r
582**/\r
583UINTN\r
584EFIAPI\r
585StrHexToUintn (\r
17f695ed 586 IN CONST CHAR16 *String\r
ac644614 587 );\r
588\r
589\r
590/**\r
591 Convert a Null-terminated Unicode hexadecimal string to a value of type UINT64.\r
592\r
593 This function returns a value of type UINT64 by interpreting the contents\r
594 of the Unicode string specified by String as a hexadecimal number.\r
595 The format of the input Unicode string String is\r
596\r
597 [spaces][zeros][x][hexadecimal digits].\r
598\r
599 The valid hexadecimal digit character is in the range [0-9], [a-f] and [A-F].\r
600 The prefix "0x" is optional. Both "x" and "X" is allowed in "0x" prefix.\r
601 If "x" appears in the input string, it must be prefixed with at least one 0.\r
602 The function will ignore the pad space, which includes spaces or tab characters,\r
603 before [zeros], [x] or [hexadecimal digit]. The running zero before [x] or\r
604 [hexadecimal digit] will be ignored. Then, the decoding starts after [x] or the\r
605 first valid hexadecimal digit. Then, the function stops at the first character that is\r
606 a not a valid hexadecimal character or NULL, whichever one comes first.\r
607\r
608 If String is NULL, then ASSERT().\r
609 If String is not aligned in a 16-bit boundary, then ASSERT().\r
610 If String has only pad spaces, then zero is returned.\r
611 If String has no leading pad spaces, leading zeros or valid hexadecimal digits,\r
612 then zero is returned.\r
613 If the number represented by String overflows according to the range defined by\r
614 UINT64, then ASSERT().\r
615\r
616 If PcdMaximumUnicodeStringLength is not zero, and String contains more than\r
617 PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator,\r
618 then ASSERT().\r
619\r
af2dc6a7 620 @param String The pointer to a Null-terminated Unicode string.\r
ac644614 621\r
38bbd3d9 622 @retval Value translated from String.\r
ac644614 623\r
624**/\r
625UINT64\r
626EFIAPI\r
627StrHexToUint64 (\r
17f695ed 628 IN CONST CHAR16 *String\r
ac644614 629 );\r
630\r
ac644614 631/**\r
17f695ed 632 Convert a Null-terminated Unicode string to a Null-terminated\r
ac644614 633 ASCII string and returns the ASCII string.\r
634\r
635 This function converts the content of the Unicode string Source\r
636 to the ASCII string Destination by copying the lower 8 bits of\r
637 each Unicode character. It returns Destination.\r
638\r
d3e0289c 639 The caller is responsible to make sure Destination points to a buffer with size\r
640 equal or greater than ((StrLen (Source) + 1) * sizeof (CHAR8)) in bytes.\r
641\r
ac644614 642 If any Unicode characters in Source contain non-zero value in\r
643 the upper 8 bits, then ASSERT().\r
644\r
645 If Destination is NULL, then ASSERT().\r
646 If Source is NULL, then ASSERT().\r
647 If Source is not aligned on a 16-bit boundary, then ASSERT().\r
648 If Source and Destination overlap, then ASSERT().\r
649\r
650 If PcdMaximumUnicodeStringLength is not zero, and Source contains\r
651 more than PcdMaximumUnicodeStringLength Unicode characters not including\r
652 the Null-terminator, then ASSERT().\r
653\r
654 If PcdMaximumAsciiStringLength is not zero, and Source contains more\r
655 than PcdMaximumAsciiStringLength Unicode characters not including the\r
656 Null-terminator, then ASSERT().\r
657\r
af2dc6a7 658 @param Source The pointer to a Null-terminated Unicode string.\r
659 @param Destination The pointer to a Null-terminated ASCII string.\r
ac644614 660\r
9aa049d9 661 @return Destination.\r
ac644614 662\r
663**/\r
664CHAR8 *\r
665EFIAPI\r
666UnicodeStrToAsciiStr (\r
17f695ed 667 IN CONST CHAR16 *Source,\r
668 OUT CHAR8 *Destination\r
ac644614 669 );\r
670\r
671\r
672/**\r
673 Copies one Null-terminated ASCII string to another Null-terminated ASCII\r
674 string and returns the new ASCII string.\r
675\r
676 This function copies the contents of the ASCII string Source to the ASCII\r
677 string Destination, and returns Destination. If Source and Destination\r
678 overlap, then the results are undefined.\r
679\r
680 If Destination is NULL, then ASSERT().\r
681 If Source is NULL, then ASSERT().\r
682 If Source and Destination overlap, then ASSERT().\r
683 If PcdMaximumAsciiStringLength is not zero and Source contains more than\r
684 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,\r
685 then ASSERT().\r
686\r
af2dc6a7 687 @param Destination The pointer to a Null-terminated ASCII string.\r
688 @param Source The pointer to a Null-terminated ASCII string.\r
ac644614 689\r
690 @return Destination\r
691\r
692**/\r
693CHAR8 *\r
694EFIAPI\r
695AsciiStrCpy (\r
696 OUT CHAR8 *Destination,\r
697 IN CONST CHAR8 *Source\r
698 );\r
699\r
700\r
701/**\r
17f695ed 702 Copies up to a specified length one Null-terminated ASCII string to another \r
703 Null-terminated ASCII string and returns the new ASCII string.\r
ac644614 704\r
705 This function copies the contents of the ASCII string Source to the ASCII\r
706 string Destination, and returns Destination. At most, Length ASCII characters\r
707 are copied from Source to Destination. If Length is 0, then Destination is\r
708 returned unmodified. If Length is greater that the number of ASCII characters\r
709 in Source, then Destination is padded with Null ASCII characters. If Source\r
710 and Destination overlap, then the results are undefined.\r
711\r
712 If Destination is NULL, then ASSERT().\r
713 If Source is NULL, then ASSERT().\r
714 If Source and Destination overlap, then ASSERT().\r
50c247fd 715 If PcdMaximumAsciiStringLength is not zero, and Length is greater than \r
716 PcdMaximumAsciiStringLength, then ASSERT().\r
ac644614 717 If PcdMaximumAsciiStringLength is not zero, and Source contains more than\r
50c247fd 718 PcdMaximumAsciiStringLength ASCII characters, not including the Null-terminator,\r
ac644614 719 then ASSERT().\r
720\r
af2dc6a7 721 @param Destination The pointer to a Null-terminated ASCII string.\r
722 @param Source The pointer to a Null-terminated ASCII string.\r
723 @param Length The maximum number of ASCII characters to copy.\r
ac644614 724\r
725 @return Destination\r
726\r
727**/\r
728CHAR8 *\r
729EFIAPI\r
730AsciiStrnCpy (\r
731 OUT CHAR8 *Destination,\r
732 IN CONST CHAR8 *Source,\r
733 IN UINTN Length\r
734 );\r
735\r
736\r
737/**\r
738 Returns the length of a Null-terminated ASCII string.\r
739\r
740 This function returns the number of ASCII characters in the Null-terminated\r
741 ASCII string specified by String.\r
742\r
743 If Length > 0 and Destination is NULL, then ASSERT().\r
744 If Length > 0 and Source is NULL, then ASSERT().\r
745 If PcdMaximumAsciiStringLength is not zero and String contains more than\r
746 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,\r
747 then ASSERT().\r
748\r
af2dc6a7 749 @param String The pointer to a Null-terminated ASCII string.\r
ac644614 750\r
751 @return The length of String.\r
752\r
753**/\r
754UINTN\r
755EFIAPI\r
756AsciiStrLen (\r
757 IN CONST CHAR8 *String\r
758 );\r
759\r
760\r
761/**\r
762 Returns the size of a Null-terminated ASCII string in bytes, including the\r
763 Null terminator.\r
764\r
765 This function returns the size, in bytes, of the Null-terminated ASCII string\r
766 specified by String.\r
767\r
768 If String is NULL, then ASSERT().\r
769 If PcdMaximumAsciiStringLength is not zero and String contains more than\r
770 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,\r
771 then ASSERT().\r
772\r
af2dc6a7 773 @param String The pointer to a Null-terminated ASCII string.\r
ac644614 774\r
775 @return The size of String.\r
776\r
777**/\r
778UINTN\r
779EFIAPI\r
780AsciiStrSize (\r
781 IN CONST CHAR8 *String\r
782 );\r
783\r
784\r
785/**\r
786 Compares two Null-terminated ASCII strings, and returns the difference\r
787 between the first mismatched ASCII characters.\r
788\r
789 This function compares the Null-terminated ASCII string FirstString to the\r
790 Null-terminated ASCII string SecondString. If FirstString is identical to\r
791 SecondString, then 0 is returned. Otherwise, the value returned is the first\r
792 mismatched ASCII character in SecondString subtracted from the first\r
793 mismatched ASCII character in FirstString.\r
794\r
795 If FirstString is NULL, then ASSERT().\r
796 If SecondString is NULL, then ASSERT().\r
797 If PcdMaximumAsciiStringLength is not zero and FirstString contains more than\r
798 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,\r
799 then ASSERT().\r
800 If PcdMaximumAsciiStringLength is not zero and SecondString contains more\r
801 than PcdMaximumAsciiStringLength ASCII characters not including the\r
802 Null-terminator, then ASSERT().\r
803\r
af2dc6a7 804 @param FirstString The pointer to a Null-terminated ASCII string.\r
805 @param SecondString The pointer to a Null-terminated ASCII string.\r
ac644614 806\r
17f695ed 807 @retval ==0 FirstString is identical to SecondString.\r
808 @retval !=0 FirstString is not identical to SecondString.\r
ac644614 809\r
810**/\r
811INTN\r
812EFIAPI\r
813AsciiStrCmp (\r
814 IN CONST CHAR8 *FirstString,\r
815 IN CONST CHAR8 *SecondString\r
816 );\r
817\r
818\r
819/**\r
820 Performs a case insensitive comparison of two Null-terminated ASCII strings,\r
821 and returns the difference between the first mismatched ASCII characters.\r
822\r
823 This function performs a case insensitive comparison of the Null-terminated\r
824 ASCII string FirstString to the Null-terminated ASCII string SecondString. If\r
825 FirstString is identical to SecondString, then 0 is returned. Otherwise, the\r
826 value returned is the first mismatched lower case ASCII character in\r
827 SecondString subtracted from the first mismatched lower case ASCII character\r
828 in FirstString.\r
829\r
830 If FirstString is NULL, then ASSERT().\r
831 If SecondString is NULL, then ASSERT().\r
832 If PcdMaximumAsciiStringLength is not zero and FirstString contains more than\r
833 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,\r
834 then ASSERT().\r
835 If PcdMaximumAsciiStringLength is not zero and SecondString contains more\r
836 than PcdMaximumAsciiStringLength ASCII characters not including the\r
837 Null-terminator, then ASSERT().\r
838\r
af2dc6a7 839 @param FirstString The pointer to a Null-terminated ASCII string.\r
840 @param SecondString The pointer to a Null-terminated ASCII string.\r
ac644614 841\r
17f695ed 842 @retval ==0 FirstString is identical to SecondString using case insensitive\r
1106ffe1 843 comparisons.\r
17f695ed 844 @retval !=0 FirstString is not identical to SecondString using case\r
1106ffe1 845 insensitive comparisons.\r
ac644614 846\r
847**/\r
848INTN\r
849EFIAPI\r
850AsciiStriCmp (\r
851 IN CONST CHAR8 *FirstString,\r
852 IN CONST CHAR8 *SecondString\r
853 );\r
854\r
855\r
856/**\r
857 Compares two Null-terminated ASCII strings with maximum lengths, and returns\r
858 the difference between the first mismatched ASCII characters.\r
859\r
860 This function compares the Null-terminated ASCII string FirstString to the\r
861 Null-terminated ASCII string SecondString. At most, Length ASCII characters\r
862 will be compared. If Length is 0, then 0 is returned. If FirstString is\r
863 identical to SecondString, then 0 is returned. Otherwise, the value returned\r
864 is the first mismatched ASCII character in SecondString subtracted from the\r
865 first mismatched ASCII character in FirstString.\r
866\r
867 If Length > 0 and FirstString is NULL, then ASSERT().\r
868 If Length > 0 and SecondString is NULL, then ASSERT().\r
50c247fd 869 If PcdMaximumAsciiStringLength is not zero, and Length is greater than \r
870 PcdMaximumAsciiStringLength, then ASSERT().\r
871 If PcdMaximumAsciiStringLength is not zero, and FirstString contains more than\r
872 PcdMaximumAsciiStringLength ASCII characters, not including the Null-terminator,\r
ac644614 873 then ASSERT().\r
50c247fd 874 If PcdMaximumAsciiStringLength is not zero, and SecondString contains more than\r
875 PcdMaximumAsciiStringLength ASCII characters, not including the Null-terminator,\r
ac644614 876 then ASSERT().\r
877\r
af2dc6a7 878 @param FirstString The pointer to a Null-terminated ASCII string.\r
879 @param SecondString The pointer to a Null-terminated ASCII string.\r
880 @param Length The maximum number of ASCII characters for compare.\r
ac644614 881 \r
17f695ed 882 @retval ==0 FirstString is identical to SecondString.\r
883 @retval !=0 FirstString is not identical to SecondString.\r
ac644614 884\r
885**/\r
886INTN\r
887EFIAPI\r
888AsciiStrnCmp (\r
889 IN CONST CHAR8 *FirstString,\r
890 IN CONST CHAR8 *SecondString,\r
891 IN UINTN Length\r
892 );\r
893\r
894\r
895/**\r
896 Concatenates one Null-terminated ASCII string to another Null-terminated\r
897 ASCII string, and returns the concatenated ASCII string.\r
898\r
899 This function concatenates two Null-terminated ASCII strings. The contents of\r
900 Null-terminated ASCII string Source are concatenated to the end of Null-\r
901 terminated ASCII string Destination. The Null-terminated concatenated ASCII\r
902 String is returned.\r
903\r
904 If Destination is NULL, then ASSERT().\r
905 If Source is NULL, then ASSERT().\r
906 If PcdMaximumAsciiStringLength is not zero and Destination contains more than\r
907 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,\r
908 then ASSERT().\r
909 If PcdMaximumAsciiStringLength is not zero and Source contains more than\r
910 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,\r
911 then ASSERT().\r
912 If PcdMaximumAsciiStringLength is not zero and concatenating Destination and\r
913 Source results in a ASCII string with more than PcdMaximumAsciiStringLength\r
914 ASCII characters, then ASSERT().\r
915\r
af2dc6a7 916 @param Destination The pointer to a Null-terminated ASCII string.\r
917 @param Source The pointer to a Null-terminated ASCII string.\r
ac644614 918\r
919 @return Destination\r
920\r
921**/\r
922CHAR8 *\r
923EFIAPI\r
924AsciiStrCat (\r
925 IN OUT CHAR8 *Destination,\r
926 IN CONST CHAR8 *Source\r
927 );\r
928\r
929\r
930/**\r
17f695ed 931 Concatenates up to a specified length one Null-terminated ASCII string to \r
932 the end of another Null-terminated ASCII string, and returns the \r
933 concatenated ASCII string.\r
ac644614 934\r
935 This function concatenates two Null-terminated ASCII strings. The contents\r
936 of Null-terminated ASCII string Source are concatenated to the end of Null-\r
937 terminated ASCII string Destination, and Destination is returned. At most,\r
938 Length ASCII characters are concatenated from Source to the end of\r
939 Destination, and Destination is always Null-terminated. If Length is 0, then\r
940 Destination is returned unmodified. If Source and Destination overlap, then\r
941 the results are undefined.\r
942\r
943 If Length > 0 and Destination is NULL, then ASSERT().\r
944 If Length > 0 and Source is NULL, then ASSERT().\r
945 If Source and Destination overlap, then ASSERT().\r
50c247fd 946 If PcdMaximumAsciiStringLength is not zero, and Length is greater than\r
947 PcdMaximumAsciiStringLength, then ASSERT().\r
ac644614 948 If PcdMaximumAsciiStringLength is not zero, and Destination contains more than\r
50c247fd 949 PcdMaximumAsciiStringLength ASCII characters, not including the Null-terminator,\r
ac644614 950 then ASSERT().\r
951 If PcdMaximumAsciiStringLength is not zero, and Source contains more than\r
50c247fd 952 PcdMaximumAsciiStringLength ASCII characters, not including the Null-terminator,\r
ac644614 953 then ASSERT().\r
954 If PcdMaximumAsciiStringLength is not zero, and concatenating Destination and\r
955 Source results in a ASCII string with more than PcdMaximumAsciiStringLength\r
50c247fd 956 ASCII characters, not including the Null-terminator, then ASSERT().\r
ac644614 957\r
af2dc6a7 958 @param Destination The pointer to a Null-terminated ASCII string.\r
959 @param Source The pointer to a Null-terminated ASCII string.\r
960 @param Length The maximum number of ASCII characters to concatenate from\r
ac644614 961 Source.\r
962\r
963 @return Destination\r
964\r
965**/\r
966CHAR8 *\r
967EFIAPI\r
968AsciiStrnCat (\r
969 IN OUT CHAR8 *Destination,\r
970 IN CONST CHAR8 *Source,\r
971 IN UINTN Length\r
972 );\r
973\r
974\r
975/**\r
9aa049d9 976 Returns the first occurrence of a Null-terminated ASCII sub-string\r
ac644614 977 in a Null-terminated ASCII string.\r
978\r
979 This function scans the contents of the ASCII string specified by String\r
980 and returns the first occurrence of SearchString. If SearchString is not\r
981 found in String, then NULL is returned. If the length of SearchString is zero,\r
982 then String is returned.\r
983\r
984 If String is NULL, then ASSERT().\r
985 If SearchString is NULL, then ASSERT().\r
986\r
987 If PcdMaximumAsciiStringLength is not zero, and SearchString or\r
988 String contains more than PcdMaximumAsciiStringLength Unicode characters\r
989 not including the Null-terminator, then ASSERT().\r
990\r
af2dc6a7 991 @param String The pointer to a Null-terminated ASCII string.\r
992 @param SearchString The pointer to a Null-terminated ASCII string to search for.\r
ac644614 993\r
994 @retval NULL If the SearchString does not appear in String.\r
17f695ed 995 @retval others If there is a match return the first occurrence of SearchingString.\r
9aa049d9 996 If the length of SearchString is zero,return String.\r
ac644614 997\r
998**/\r
999CHAR8 *\r
1000EFIAPI\r
1001AsciiStrStr (\r
17f695ed 1002 IN CONST CHAR8 *String,\r
1003 IN CONST CHAR8 *SearchString\r
ac644614 1004 );\r
1005\r
1006\r
1007/**\r
1008 Convert a Null-terminated ASCII decimal string to a value of type\r
1009 UINTN.\r
1010\r
1011 This function returns a value of type UINTN by interpreting the contents\r
1012 of the ASCII string String as a decimal number. The format of the input\r
1013 ASCII string String is:\r
1014\r
1015 [spaces] [decimal digits].\r
1016\r
1017 The valid decimal digit character is in the range [0-9]. The function will\r
1018 ignore the pad space, which includes spaces or tab characters, before the digits.\r
1019 The running zero in the beginning of [decimal digits] will be ignored. Then, the\r
1020 function stops at the first character that is a not a valid decimal character or\r
1021 Null-terminator, whichever on comes first.\r
1022\r
1023 If String has only pad spaces, then 0 is returned.\r
1024 If String has no pad spaces or valid decimal digits, then 0 is returned.\r
1025 If the number represented by String overflows according to the range defined by\r
1026 UINTN, then ASSERT().\r
1027 If String is NULL, then ASSERT().\r
1028 If PcdMaximumAsciiStringLength is not zero, and String contains more than\r
1029 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,\r
1030 then ASSERT().\r
1031\r
af2dc6a7 1032 @param String The pointer to a Null-terminated ASCII string.\r
ac644614 1033\r
af2dc6a7 1034 @retval The value translated from String.\r
ac644614 1035\r
1036**/\r
1037UINTN\r
1038EFIAPI\r
1039AsciiStrDecimalToUintn (\r
1040 IN CONST CHAR8 *String\r
1041 );\r
1042\r
1043\r
1044/**\r
1045 Convert a Null-terminated ASCII decimal string to a value of type\r
1046 UINT64.\r
1047\r
1048 This function returns a value of type UINT64 by interpreting the contents\r
1049 of the ASCII string String as a decimal number. The format of the input\r
1050 ASCII string String is:\r
1051\r
1052 [spaces] [decimal digits].\r
1053\r
1054 The valid decimal digit character is in the range [0-9]. The function will\r
1055 ignore the pad space, which includes spaces or tab characters, before the digits.\r
1056 The running zero in the beginning of [decimal digits] will be ignored. Then, the\r
1057 function stops at the first character that is a not a valid decimal character or\r
1058 Null-terminator, whichever on comes first.\r
1059\r
1060 If String has only pad spaces, then 0 is returned.\r
1061 If String has no pad spaces or valid decimal digits, then 0 is returned.\r
1062 If the number represented by String overflows according to the range defined by\r
1063 UINT64, then ASSERT().\r
1064 If String is NULL, then ASSERT().\r
1065 If PcdMaximumAsciiStringLength is not zero, and String contains more than\r
1066 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,\r
1067 then ASSERT().\r
1068\r
af2dc6a7 1069 @param String The pointer to a Null-terminated ASCII string.\r
ac644614 1070\r
38bbd3d9 1071 @retval Value translated from String.\r
ac644614 1072\r
1073**/\r
1074UINT64\r
1075EFIAPI\r
1076AsciiStrDecimalToUint64 (\r
17f695ed 1077 IN CONST CHAR8 *String\r
ac644614 1078 );\r
1079\r
1080\r
1081/**\r
1082 Convert a Null-terminated ASCII hexadecimal string to a value of type UINTN.\r
1083\r
1084 This function returns a value of type UINTN by interpreting the contents of\r
1085 the ASCII string String as a hexadecimal number. The format of the input ASCII\r
1086 string String is:\r
1087\r
1088 [spaces][zeros][x][hexadecimal digits].\r
1089\r
1090 The valid hexadecimal digit character is in the range [0-9], [a-f] and [A-F].\r
1091 The prefix "0x" is optional. Both "x" and "X" is allowed in "0x" prefix. If "x"\r
1092 appears in the input string, it must be prefixed with at least one 0. The function\r
1093 will ignore the pad space, which includes spaces or tab characters, before [zeros],\r
1094 [x] or [hexadecimal digits]. The running zero before [x] or [hexadecimal digits]\r
1095 will be ignored. Then, the decoding starts after [x] or the first valid hexadecimal\r
1096 digit. Then, the function stops at the first character that is a not a valid\r
1097 hexadecimal character or Null-terminator, whichever on comes first.\r
1098\r
1099 If String has only pad spaces, then 0 is returned.\r
1100 If String has no leading pad spaces, leading zeros or valid hexadecimal digits, then\r
1101 0 is returned.\r
1102\r
1103 If the number represented by String overflows according to the range defined by UINTN,\r
1104 then ASSERT().\r
1105 If String is NULL, then ASSERT().\r
1106 If PcdMaximumAsciiStringLength is not zero,\r
1107 and String contains more than PcdMaximumAsciiStringLength ASCII characters not including\r
1108 the Null-terminator, then ASSERT().\r
1109\r
af2dc6a7 1110 @param String The pointer to a Null-terminated ASCII string.\r
ac644614 1111\r
38bbd3d9 1112 @retval Value translated from String.\r
ac644614 1113\r
1114**/\r
1115UINTN\r
1116EFIAPI\r
1117AsciiStrHexToUintn (\r
17f695ed 1118 IN CONST CHAR8 *String\r
ac644614 1119 );\r
1120\r
1121\r
1122/**\r
1123 Convert a Null-terminated ASCII hexadecimal string to a value of type UINT64.\r
1124\r
1125 This function returns a value of type UINT64 by interpreting the contents of\r
1126 the ASCII string String as a hexadecimal number. The format of the input ASCII\r
1127 string String is:\r
1128\r
1129 [spaces][zeros][x][hexadecimal digits].\r
1130\r
1131 The valid hexadecimal digit character is in the range [0-9], [a-f] and [A-F].\r
1132 The prefix "0x" is optional. Both "x" and "X" is allowed in "0x" prefix. If "x"\r
1133 appears in the input string, it must be prefixed with at least one 0. The function\r
1134 will ignore the pad space, which includes spaces or tab characters, before [zeros],\r
1135 [x] or [hexadecimal digits]. The running zero before [x] or [hexadecimal digits]\r
1136 will be ignored. Then, the decoding starts after [x] or the first valid hexadecimal\r
1137 digit. Then, the function stops at the first character that is a not a valid\r
1138 hexadecimal character or Null-terminator, whichever on comes first.\r
1139\r
1140 If String has only pad spaces, then 0 is returned.\r
1141 If String has no leading pad spaces, leading zeros or valid hexadecimal digits, then\r
1142 0 is returned.\r
1143\r
1144 If the number represented by String overflows according to the range defined by UINT64,\r
1145 then ASSERT().\r
1146 If String is NULL, then ASSERT().\r
1147 If PcdMaximumAsciiStringLength is not zero,\r
1148 and String contains more than PcdMaximumAsciiStringLength ASCII characters not including\r
1149 the Null-terminator, then ASSERT().\r
1150\r
af2dc6a7 1151 @param String The pointer to a Null-terminated ASCII string.\r
ac644614 1152\r
38bbd3d9 1153 @retval Value translated from String.\r
ac644614 1154\r
1155**/\r
1156UINT64\r
1157EFIAPI\r
1158AsciiStrHexToUint64 (\r
17f695ed 1159 IN CONST CHAR8 *String\r
ac644614 1160 );\r
1161\r
1162\r
1163/**\r
1164 Convert one Null-terminated ASCII string to a Null-terminated\r
1165 Unicode string and returns the Unicode string.\r
1166\r
1167 This function converts the contents of the ASCII string Source to the Unicode\r
1168 string Destination, and returns Destination. The function terminates the\r
1169 Unicode string Destination by appending a Null-terminator character at the end.\r
1170 The caller is responsible to make sure Destination points to a buffer with size\r
1171 equal or greater than ((AsciiStrLen (Source) + 1) * sizeof (CHAR16)) in bytes.\r
1172\r
1173 If Destination is NULL, then ASSERT().\r
1174 If Destination is not aligned on a 16-bit boundary, then ASSERT().\r
1175 If Source is NULL, then ASSERT().\r
1176 If Source and Destination overlap, then ASSERT().\r
1177 If PcdMaximumAsciiStringLength is not zero, and Source contains more than\r
1178 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,\r
1179 then ASSERT().\r
1180 If PcdMaximumUnicodeStringLength is not zero, and Source contains more than\r
1181 PcdMaximumUnicodeStringLength ASCII characters not including the\r
1182 Null-terminator, then ASSERT().\r
1183\r
af2dc6a7 1184 @param Source The pointer to a Null-terminated ASCII string.\r
1185 @param Destination The pointer to a Null-terminated Unicode string.\r
ac644614 1186\r
9aa049d9 1187 @return Destination.\r
ac644614 1188\r
1189**/\r
1190CHAR16 *\r
1191EFIAPI\r
1192AsciiStrToUnicodeStr (\r
17f695ed 1193 IN CONST CHAR8 *Source,\r
1194 OUT CHAR16 *Destination\r
ac644614 1195 );\r
1196\r
1197\r
1198/**\r
1199 Converts an 8-bit value to an 8-bit BCD value.\r
1200\r
1201 Converts the 8-bit value specified by Value to BCD. The BCD value is\r
1202 returned.\r
1203\r
1204 If Value >= 100, then ASSERT().\r
1205\r
1206 @param Value The 8-bit value to convert to BCD. Range 0..99.\r
1207\r
9aa049d9 1208 @return The BCD value.\r
ac644614 1209\r
1210**/\r
1211UINT8\r
1212EFIAPI\r
1213DecimalToBcd8 (\r
1214 IN UINT8 Value\r
1215 );\r
1216\r
1217\r
1218/**\r
1219 Converts an 8-bit BCD value to an 8-bit value.\r
1220\r
1221 Converts the 8-bit BCD value specified by Value to an 8-bit value. The 8-bit\r
1222 value is returned.\r
1223\r
1224 If Value >= 0xA0, then ASSERT().\r
1225 If (Value & 0x0F) >= 0x0A, then ASSERT().\r
1226\r
1227 @param Value The 8-bit BCD value to convert to an 8-bit value.\r
1228\r
1229 @return The 8-bit value is returned.\r
1230\r
1231**/\r
1232UINT8\r
1233EFIAPI\r
1234BcdToDecimal8 (\r
1235 IN UINT8 Value\r
1236 );\r
1237\r
1238\r
1239//\r
1240// Linked List Functions and Macros\r
1241//\r
1242\r
1243/**\r
1244 Initializes the head node of a doubly linked list that is declared as a\r
1245 global variable in a module.\r
1246\r
1247 Initializes the forward and backward links of a new linked list. After\r
1248 initializing a linked list with this macro, the other linked list functions\r
1249 may be used to add and remove nodes from the linked list. This macro results\r
1250 in smaller executables by initializing the linked list in the data section,\r
1251 instead if calling the InitializeListHead() function to perform the\r
1252 equivalent operation.\r
1253\r
77f863ee 1254 @param ListHead The head note of a list to initialize.\r
ac644614 1255\r
1256**/\r
17f695ed 1257#define INITIALIZE_LIST_HEAD_VARIABLE(ListHead) {&(ListHead), &(ListHead)}\r
ac644614 1258\r
1259\r
1260/**\r
1261 Initializes the head node of a doubly linked list, and returns the pointer to\r
1262 the head node of the doubly linked list.\r
1263\r
1264 Initializes the forward and backward links of a new linked list. After\r
1265 initializing a linked list with this function, the other linked list\r
1266 functions may be used to add and remove nodes from the linked list. It is up\r
1267 to the caller of this function to allocate the memory for ListHead.\r
1268\r
1269 If ListHead is NULL, then ASSERT().\r
1270\r
1271 @param ListHead A pointer to the head node of a new doubly linked list.\r
1272\r
1273 @return ListHead\r
1274\r
1275**/\r
1276LIST_ENTRY *\r
1277EFIAPI\r
1278InitializeListHead (\r
aa0583c7 1279 IN OUT LIST_ENTRY *ListHead\r
ac644614 1280 );\r
1281\r
1282\r
1283/**\r
1284 Adds a node to the beginning of a doubly linked list, and returns the pointer\r
1285 to the head node of the doubly linked list.\r
1286\r
1287 Adds the node Entry at the beginning of the doubly linked list denoted by\r
1288 ListHead, and returns ListHead.\r
1289\r
1290 If ListHead is NULL, then ASSERT().\r
1291 If Entry is NULL, then ASSERT().\r
17f695ed 1292 If ListHead was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or\r
1293 InitializeListHead(), then ASSERT().\r
ac644614 1294 If PcdMaximumLinkedListLenth is not zero, and prior to insertion the number\r
1295 of nodes in ListHead, including the ListHead node, is greater than or\r
1296 equal to PcdMaximumLinkedListLength, then ASSERT().\r
1297\r
1298 @param ListHead A pointer to the head node of a doubly linked list.\r
1299 @param Entry A pointer to a node that is to be inserted at the beginning\r
1300 of a doubly linked list.\r
1301\r
1302 @return ListHead\r
1303\r
1304**/\r
1305LIST_ENTRY *\r
1306EFIAPI\r
1307InsertHeadList (\r
aa0583c7 1308 IN OUT LIST_ENTRY *ListHead,\r
1309 IN OUT LIST_ENTRY *Entry\r
ac644614 1310 );\r
1311\r
1312\r
1313/**\r
1314 Adds a node to the end of a doubly linked list, and returns the pointer to\r
1315 the head node of the doubly linked list.\r
1316\r
1317 Adds the node Entry to the end of the doubly linked list denoted by ListHead,\r
1318 and returns ListHead.\r
1319\r
1320 If ListHead is NULL, then ASSERT().\r
1321 If Entry is NULL, then ASSERT().\r
17f695ed 1322 If ListHead was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or \r
1323 InitializeListHead(), then ASSERT().\r
ac644614 1324 If PcdMaximumLinkedListLenth is not zero, and prior to insertion the number\r
1325 of nodes in ListHead, including the ListHead node, is greater than or\r
1326 equal to PcdMaximumLinkedListLength, then ASSERT().\r
1327\r
1328 @param ListHead A pointer to the head node of a doubly linked list.\r
1329 @param Entry A pointer to a node that is to be added at the end of the\r
1330 doubly linked list.\r
1331\r
1332 @return ListHead\r
1333\r
1334**/\r
1335LIST_ENTRY *\r
1336EFIAPI\r
1337InsertTailList (\r
aa0583c7 1338 IN OUT LIST_ENTRY *ListHead,\r
1339 IN OUT LIST_ENTRY *Entry\r
ac644614 1340 );\r
1341\r
1342\r
1343/**\r
1344 Retrieves the first node of a doubly linked list.\r
1345\r
17f695ed 1346 Returns the first node of a doubly linked list. List must have been \r
1347 initialized with INTIALIZE_LIST_HEAD_VARIABLE() or InitializeListHead().\r
1348 If List is empty, then List is returned.\r
ac644614 1349\r
1350 If List is NULL, then ASSERT().\r
17f695ed 1351 If List was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or \r
1352 InitializeListHead(), then ASSERT().\r
ac644614 1353 If PcdMaximumLinkedListLenth is not zero, and the number of nodes\r
1354 in List, including the List node, is greater than or equal to\r
1355 PcdMaximumLinkedListLength, then ASSERT().\r
1356\r
1357 @param List A pointer to the head node of a doubly linked list.\r
1358\r
1359 @return The first node of a doubly linked list.\r
1360 @retval NULL The list is empty.\r
1361\r
1362**/\r
1363LIST_ENTRY *\r
1364EFIAPI\r
1365GetFirstNode (\r
1366 IN CONST LIST_ENTRY *List\r
1367 );\r
1368\r
1369\r
1370/**\r
1371 Retrieves the next node of a doubly linked list.\r
1372\r
17f695ed 1373 Returns the node of a doubly linked list that follows Node. \r
1374 List must have been initialized with INTIALIZE_LIST_HEAD_VARIABLE()\r
1375 or InitializeListHead(). If List is empty, then List is returned.\r
ac644614 1376\r
1377 If List is NULL, then ASSERT().\r
1378 If Node is NULL, then ASSERT().\r
17f695ed 1379 If List was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or \r
1380 InitializeListHead(), then ASSERT().\r
ac644614 1381 If PcdMaximumLinkedListLenth is not zero, and List contains more than\r
1382 PcdMaximumLinkedListLenth nodes, then ASSERT().\r
1081f624 1383 If PcdVerifyNodeInList is TRUE and Node is not a node in List, then ASSERT().\r
ac644614 1384\r
1385 @param List A pointer to the head node of a doubly linked list.\r
1386 @param Node A pointer to a node in the doubly linked list.\r
1387\r
af2dc6a7 1388 @return The pointer to the next node if one exists. Otherwise List is returned.\r
ac644614 1389\r
1390**/\r
1391LIST_ENTRY *\r
1392EFIAPI\r
1393GetNextNode (\r
1394 IN CONST LIST_ENTRY *List,\r
1395 IN CONST LIST_ENTRY *Node\r
1396 );\r
1397\r
cbca8de5 1398 \r
1399/**\r
1400 Retrieves the previous node of a doubly linked list.\r
1401 \r
1402 Returns the node of a doubly linked list that precedes Node. \r
1403 List must have been initialized with INTIALIZE_LIST_HEAD_VARIABLE()\r
1404 or InitializeListHead(). If List is empty, then List is returned.\r
1405 \r
1406 If List is NULL, then ASSERT().\r
1407 If Node is NULL, then ASSERT().\r
1408 If List was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or \r
1409 InitializeListHead(), then ASSERT().\r
1410 If PcdMaximumLinkedListLenth is not zero, and List contains more than\r
1411 PcdMaximumLinkedListLenth nodes, then ASSERT().\r
1412 If PcdVerifyNodeInList is TRUE and Node is not a node in List, then ASSERT().\r
1413 \r
1414 @param List A pointer to the head node of a doubly linked list.\r
1415 @param Node A pointer to a node in the doubly linked list.\r
1416 \r
af2dc6a7 1417 @return The pointer to the previous node if one exists. Otherwise List is returned.\r
cbca8de5 1418 \r
1419**/\r
1420LIST_ENTRY *\r
1421EFIAPI\r
1422GetPreviousNode (\r
1423 IN CONST LIST_ENTRY *List,\r
1424 IN CONST LIST_ENTRY *Node\r
1425 );\r
ac644614 1426\r
cbca8de5 1427 \r
ac644614 1428/**\r
1429 Checks to see if a doubly linked list is empty or not.\r
1430\r
1431 Checks to see if the doubly linked list is empty. If the linked list contains\r
1432 zero nodes, this function returns TRUE. Otherwise, it returns FALSE.\r
1433\r
1434 If ListHead is NULL, then ASSERT().\r
17f695ed 1435 If ListHead was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or \r
1436 InitializeListHead(), then ASSERT().\r
ac644614 1437 If PcdMaximumLinkedListLenth is not zero, and the number of nodes\r
1438 in List, including the List node, is greater than or equal to\r
1439 PcdMaximumLinkedListLength, then ASSERT().\r
1440\r
1441 @param ListHead A pointer to the head node of a doubly linked list.\r
1442\r
1443 @retval TRUE The linked list is empty.\r
1444 @retval FALSE The linked list is not empty.\r
1445\r
1446**/\r
1447BOOLEAN\r
1448EFIAPI\r
1449IsListEmpty (\r
1450 IN CONST LIST_ENTRY *ListHead\r
1451 );\r
1452\r
1453\r
1454/**\r
aa0583c7 1455 Determines if a node in a doubly linked list is the head node of a the same\r
1456 doubly linked list. This function is typically used to terminate a loop that\r
1457 traverses all the nodes in a doubly linked list starting with the head node.\r
ac644614 1458\r
aa0583c7 1459 Returns TRUE if Node is equal to List. Returns FALSE if Node is one of the\r
1460 nodes in the doubly linked list specified by List. List must have been\r
17f695ed 1461 initialized with INTIALIZE_LIST_HEAD_VARIABLE() or InitializeListHead().\r
ac644614 1462\r
1463 If List is NULL, then ASSERT().\r
1464 If Node is NULL, then ASSERT().\r
17f695ed 1465 If List was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or InitializeListHead(), \r
1466 then ASSERT().\r
ac644614 1467 If PcdMaximumLinkedListLenth is not zero, and the number of nodes\r
1468 in List, including the List node, is greater than or equal to\r
1469 PcdMaximumLinkedListLength, then ASSERT().\r
1081f624 1470 If PcdVerifyNodeInList is TRUE and Node is not a node in List the and Node is not equal \r
1471 to List, then ASSERT().\r
ac644614 1472\r
1473 @param List A pointer to the head node of a doubly linked list.\r
1474 @param Node A pointer to a node in the doubly linked list.\r
1475\r
1955808d
LG
1476 @retval TRUE Node is the head of the doubly-linked list pointed by List.\r
1477 @retval FALSE Node is not the head of the doubly-linked list pointed by List.\r
ac644614 1478\r
1479**/\r
1480BOOLEAN\r
1481EFIAPI\r
1482IsNull (\r
1483 IN CONST LIST_ENTRY *List,\r
1484 IN CONST LIST_ENTRY *Node\r
1485 );\r
1486\r
1487\r
1488/**\r
1489 Determines if a node the last node in a doubly linked list.\r
1490\r
1491 Returns TRUE if Node is the last node in the doubly linked list specified by\r
1492 List. Otherwise, FALSE is returned. List must have been initialized with\r
17f695ed 1493 INTIALIZE_LIST_HEAD_VARIABLE() or InitializeListHead().\r
ac644614 1494\r
1495 If List is NULL, then ASSERT().\r
1496 If Node is NULL, then ASSERT().\r
17f695ed 1497 If List was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or\r
1498 InitializeListHead(), then ASSERT().\r
ac644614 1499 If PcdMaximumLinkedListLenth is not zero, and the number of nodes\r
1500 in List, including the List node, is greater than or equal to\r
1501 PcdMaximumLinkedListLength, then ASSERT().\r
1081f624 1502 If PcdVerifyNodeInList is TRUE and Node is not a node in List, then ASSERT().\r
ac644614 1503\r
1504 @param List A pointer to the head node of a doubly linked list.\r
1505 @param Node A pointer to a node in the doubly linked list.\r
1506\r
1507 @retval TRUE Node is the last node in the linked list.\r
1508 @retval FALSE Node is not the last node in the linked list.\r
1509\r
1510**/\r
1511BOOLEAN\r
1512EFIAPI\r
1513IsNodeAtEnd (\r
1514 IN CONST LIST_ENTRY *List,\r
1515 IN CONST LIST_ENTRY *Node\r
1516 );\r
1517\r
1518\r
1519/**\r
1520 Swaps the location of two nodes in a doubly linked list, and returns the\r
1521 first node after the swap.\r
1522\r
1523 If FirstEntry is identical to SecondEntry, then SecondEntry is returned.\r
1524 Otherwise, the location of the FirstEntry node is swapped with the location\r
1525 of the SecondEntry node in a doubly linked list. SecondEntry must be in the\r
1526 same double linked list as FirstEntry and that double linked list must have\r
17f695ed 1527 been initialized with INTIALIZE_LIST_HEAD_VARIABLE() or InitializeListHead(). \r
1528 SecondEntry is returned after the nodes are swapped.\r
ac644614 1529\r
1530 If FirstEntry is NULL, then ASSERT().\r
1531 If SecondEntry is NULL, then ASSERT().\r
1081f624 1532 If PcdVerifyNodeInList is TRUE and SecondEntry and FirstEntry are not in the \r
1533 same linked list, then ASSERT().\r
ac644614 1534 If PcdMaximumLinkedListLength is not zero, and the number of nodes in the\r
1535 linked list containing the FirstEntry and SecondEntry nodes, including\r
1536 the FirstEntry and SecondEntry nodes, is greater than or equal to\r
1537 PcdMaximumLinkedListLength, then ASSERT().\r
1538\r
1539 @param FirstEntry A pointer to a node in a linked list.\r
1540 @param SecondEntry A pointer to another node in the same linked list.\r
38bbd3d9 1541 \r
9aa049d9 1542 @return SecondEntry.\r
ac644614 1543\r
1544**/\r
1545LIST_ENTRY *\r
1546EFIAPI\r
1547SwapListEntries (\r
aa0583c7 1548 IN OUT LIST_ENTRY *FirstEntry,\r
1549 IN OUT LIST_ENTRY *SecondEntry\r
ac644614 1550 );\r
1551\r
1552\r
1553/**\r
1554 Removes a node from a doubly linked list, and returns the node that follows\r
1555 the removed node.\r
1556\r
1557 Removes the node Entry from a doubly linked list. It is up to the caller of\r
1558 this function to release the memory used by this node if that is required. On\r
1559 exit, the node following Entry in the doubly linked list is returned. If\r
1560 Entry is the only node in the linked list, then the head node of the linked\r
1561 list is returned.\r
1562\r
1563 If Entry is NULL, then ASSERT().\r
1564 If Entry is the head node of an empty list, then ASSERT().\r
1565 If PcdMaximumLinkedListLength is not zero, and the number of nodes in the\r
1566 linked list containing Entry, including the Entry node, is greater than\r
1567 or equal to PcdMaximumLinkedListLength, then ASSERT().\r
1568\r
9aa049d9 1569 @param Entry A pointer to a node in a linked list.\r
ac644614 1570\r
9aa049d9 1571 @return Entry.\r
ac644614 1572\r
1573**/\r
1574LIST_ENTRY *\r
1575EFIAPI\r
1576RemoveEntryList (\r
1577 IN CONST LIST_ENTRY *Entry\r
1578 );\r
1579\r
1580//\r
1581// Math Services\r
1582//\r
1583\r
1584/**\r
1585 Shifts a 64-bit integer left between 0 and 63 bits. The low bits are filled\r
1586 with zeros. The shifted value is returned.\r
1587\r
1588 This function shifts the 64-bit value Operand to the left by Count bits. The\r
1589 low Count bits are set to zero. The shifted value is returned.\r
1590\r
1591 If Count is greater than 63, then ASSERT().\r
1592\r
1593 @param Operand The 64-bit operand to shift left.\r
1594 @param Count The number of bits to shift left.\r
1595\r
9aa049d9 1596 @return Operand << Count.\r
ac644614 1597\r
1598**/\r
1599UINT64\r
1600EFIAPI\r
1601LShiftU64 (\r
1602 IN UINT64 Operand,\r
1603 IN UINTN Count\r
1604 );\r
1605\r
1606\r
1607/**\r
1608 Shifts a 64-bit integer right between 0 and 63 bits. This high bits are\r
1609 filled with zeros. The shifted value is returned.\r
1610\r
1611 This function shifts the 64-bit value Operand to the right by Count bits. The\r
1612 high Count bits are set to zero. The shifted value is returned.\r
1613\r
1614 If Count is greater than 63, then ASSERT().\r
1615\r
1616 @param Operand The 64-bit operand to shift right.\r
1617 @param Count The number of bits to shift right.\r
1618\r
1619 @return Operand >> Count\r
1620\r
1621**/\r
1622UINT64\r
1623EFIAPI\r
1624RShiftU64 (\r
1625 IN UINT64 Operand,\r
1626 IN UINTN Count\r
1627 );\r
1628\r
1629\r
1630/**\r
1631 Shifts a 64-bit integer right between 0 and 63 bits. The high bits are filled\r
1632 with original integer's bit 63. The shifted value is returned.\r
1633\r
1634 This function shifts the 64-bit value Operand to the right by Count bits. The\r
1635 high Count bits are set to bit 63 of Operand. The shifted value is returned.\r
1636\r
1637 If Count is greater than 63, then ASSERT().\r
1638\r
1639 @param Operand The 64-bit operand to shift right.\r
1640 @param Count The number of bits to shift right.\r
1641\r
1642 @return Operand >> Count\r
1643\r
1644**/\r
1645UINT64\r
1646EFIAPI\r
1647ARShiftU64 (\r
1648 IN UINT64 Operand,\r
1649 IN UINTN Count\r
1650 );\r
1651\r
1652\r
1653/**\r
1654 Rotates a 32-bit integer left between 0 and 31 bits, filling the low bits\r
1655 with the high bits that were rotated.\r
1656\r
1657 This function rotates the 32-bit value Operand to the left by Count bits. The\r
1658 low Count bits are fill with the high Count bits of Operand. The rotated\r
1659 value is returned.\r
1660\r
1661 If Count is greater than 31, then ASSERT().\r
1662\r
1663 @param Operand The 32-bit operand to rotate left.\r
1664 @param Count The number of bits to rotate left.\r
1665\r
17f695ed 1666 @return Operand << Count\r
ac644614 1667\r
1668**/\r
1669UINT32\r
1670EFIAPI\r
1671LRotU32 (\r
1672 IN UINT32 Operand,\r
1673 IN UINTN Count\r
1674 );\r
1675\r
1676\r
1677/**\r
1678 Rotates a 32-bit integer right between 0 and 31 bits, filling the high bits\r
1679 with the low bits that were rotated.\r
1680\r
1681 This function rotates the 32-bit value Operand to the right by Count bits.\r
1682 The high Count bits are fill with the low Count bits of Operand. The rotated\r
1683 value is returned.\r
1684\r
1685 If Count is greater than 31, then ASSERT().\r
1686\r
1687 @param Operand The 32-bit operand to rotate right.\r
1688 @param Count The number of bits to rotate right.\r
1689\r
2fe241a2 1690 @return Operand >> Count\r
ac644614 1691\r
1692**/\r
1693UINT32\r
1694EFIAPI\r
1695RRotU32 (\r
1696 IN UINT32 Operand,\r
1697 IN UINTN Count\r
1698 );\r
1699\r
1700\r
1701/**\r
1702 Rotates a 64-bit integer left between 0 and 63 bits, filling the low bits\r
1703 with the high bits that were rotated.\r
1704\r
1705 This function rotates the 64-bit value Operand to the left by Count bits. The\r
1706 low Count bits are fill with the high Count bits of Operand. The rotated\r
1707 value is returned.\r
1708\r
1709 If Count is greater than 63, then ASSERT().\r
1710\r
1711 @param Operand The 64-bit operand to rotate left.\r
1712 @param Count The number of bits to rotate left.\r
1713\r
17f695ed 1714 @return Operand << Count\r
ac644614 1715\r
1716**/\r
1717UINT64\r
1718EFIAPI\r
1719LRotU64 (\r
1720 IN UINT64 Operand,\r
1721 IN UINTN Count\r
1722 );\r
1723\r
1724\r
1725/**\r
1726 Rotates a 64-bit integer right between 0 and 63 bits, filling the high bits\r
1727 with the high low bits that were rotated.\r
1728\r
1729 This function rotates the 64-bit value Operand to the right by Count bits.\r
1730 The high Count bits are fill with the low Count bits of Operand. The rotated\r
1731 value is returned.\r
1732\r
1733 If Count is greater than 63, then ASSERT().\r
1734\r
1735 @param Operand The 64-bit operand to rotate right.\r
1736 @param Count The number of bits to rotate right.\r
1737\r
17f695ed 1738 @return Operand >> Count\r
ac644614 1739\r
1740**/\r
1741UINT64\r
1742EFIAPI\r
1743RRotU64 (\r
1744 IN UINT64 Operand,\r
1745 IN UINTN Count\r
1746 );\r
1747\r
1748\r
1749/**\r
1750 Returns the bit position of the lowest bit set in a 32-bit value.\r
1751\r
1752 This function computes the bit position of the lowest bit set in the 32-bit\r
1753 value specified by Operand. If Operand is zero, then -1 is returned.\r
1754 Otherwise, a value between 0 and 31 is returned.\r
1755\r
1756 @param Operand The 32-bit operand to evaluate.\r
1757\r
9aa049d9 1758 @retval 0..31 The lowest bit set in Operand was found.\r
17f695ed 1759 @retval -1 Operand is zero.\r
ac644614 1760\r
1761**/\r
1762INTN\r
1763EFIAPI\r
1764LowBitSet32 (\r
1765 IN UINT32 Operand\r
1766 );\r
1767\r
1768\r
1769/**\r
1770 Returns the bit position of the lowest bit set in a 64-bit value.\r
1771\r
1772 This function computes the bit position of the lowest bit set in the 64-bit\r
1773 value specified by Operand. If Operand is zero, then -1 is returned.\r
1774 Otherwise, a value between 0 and 63 is returned.\r
1775\r
1776 @param Operand The 64-bit operand to evaluate.\r
1777\r
9aa049d9 1778 @retval 0..63 The lowest bit set in Operand was found.\r
17f695ed 1779 @retval -1 Operand is zero.\r
1780\r
ac644614 1781\r
1782**/\r
1783INTN\r
1784EFIAPI\r
1785LowBitSet64 (\r
1786 IN UINT64 Operand\r
1787 );\r
1788\r
1789\r
1790/**\r
1791 Returns the bit position of the highest bit set in a 32-bit value. Equivalent\r
1792 to log2(x).\r
1793\r
1794 This function computes the bit position of the highest bit set in the 32-bit\r
1795 value specified by Operand. If Operand is zero, then -1 is returned.\r
1796 Otherwise, a value between 0 and 31 is returned.\r
1797\r
1798 @param Operand The 32-bit operand to evaluate.\r
1799\r
9aa049d9 1800 @retval 0..31 Position of the highest bit set in Operand if found.\r
17f695ed 1801 @retval -1 Operand is zero.\r
ac644614 1802\r
1803**/\r
1804INTN\r
1805EFIAPI\r
1806HighBitSet32 (\r
1807 IN UINT32 Operand\r
1808 );\r
1809\r
1810\r
1811/**\r
1812 Returns the bit position of the highest bit set in a 64-bit value. Equivalent\r
1813 to log2(x).\r
1814\r
1815 This function computes the bit position of the highest bit set in the 64-bit\r
1816 value specified by Operand. If Operand is zero, then -1 is returned.\r
1817 Otherwise, a value between 0 and 63 is returned.\r
1818\r
1819 @param Operand The 64-bit operand to evaluate.\r
1820\r
9aa049d9 1821 @retval 0..63 Position of the highest bit set in Operand if found.\r
17f695ed 1822 @retval -1 Operand is zero.\r
ac644614 1823\r
1824**/\r
1825INTN\r
1826EFIAPI\r
1827HighBitSet64 (\r
1828 IN UINT64 Operand\r
1829 );\r
1830\r
1831\r
1832/**\r
1833 Returns the value of the highest bit set in a 32-bit value. Equivalent to\r
17f695ed 1834 1 << log2(x).\r
ac644614 1835\r
1836 This function computes the value of the highest bit set in the 32-bit value\r
1837 specified by Operand. If Operand is zero, then zero is returned.\r
1838\r
1839 @param Operand The 32-bit operand to evaluate.\r
1840\r
1841 @return 1 << HighBitSet32(Operand)\r
1842 @retval 0 Operand is zero.\r
1843\r
1844**/\r
1845UINT32\r
1846EFIAPI\r
1847GetPowerOfTwo32 (\r
1848 IN UINT32 Operand\r
1849 );\r
1850\r
1851\r
1852/**\r
1853 Returns the value of the highest bit set in a 64-bit value. Equivalent to\r
17f695ed 1854 1 << log2(x).\r
ac644614 1855\r
1856 This function computes the value of the highest bit set in the 64-bit value\r
1857 specified by Operand. If Operand is zero, then zero is returned.\r
1858\r
1859 @param Operand The 64-bit operand to evaluate.\r
1860\r
1861 @return 1 << HighBitSet64(Operand)\r
1862 @retval 0 Operand is zero.\r
1863\r
1864**/\r
1865UINT64\r
1866EFIAPI\r
1867GetPowerOfTwo64 (\r
1868 IN UINT64 Operand\r
1869 );\r
1870\r
1871\r
1872/**\r
af2dc6a7 1873 Switches the endianness of a 16-bit integer.\r
ac644614 1874\r
1875 This function swaps the bytes in a 16-bit unsigned value to switch the value\r
1876 from little endian to big endian or vice versa. The byte swapped value is\r
1877 returned.\r
1878\r
2a53dabf 1879 @param Value A 16-bit unsigned value.\r
ac644614 1880\r
efb23117 1881 @return The byte swapped Value.\r
ac644614 1882\r
1883**/\r
1884UINT16\r
1885EFIAPI\r
1886SwapBytes16 (\r
1887 IN UINT16 Value\r
1888 );\r
1889\r
1890\r
1891/**\r
af2dc6a7 1892 Switches the endianness of a 32-bit integer.\r
ac644614 1893\r
1894 This function swaps the bytes in a 32-bit unsigned value to switch the value\r
1895 from little endian to big endian or vice versa. The byte swapped value is\r
1896 returned.\r
1897\r
2a53dabf 1898 @param Value A 32-bit unsigned value.\r
ac644614 1899\r
efb23117 1900 @return The byte swapped Value.\r
ac644614 1901\r
1902**/\r
1903UINT32\r
1904EFIAPI\r
1905SwapBytes32 (\r
1906 IN UINT32 Value\r
1907 );\r
1908\r
1909\r
1910/**\r
af2dc6a7 1911 Switches the endianness of a 64-bit integer.\r
ac644614 1912\r
1913 This function swaps the bytes in a 64-bit unsigned value to switch the value\r
1914 from little endian to big endian or vice versa. The byte swapped value is\r
1915 returned.\r
1916\r
2a53dabf 1917 @param Value A 64-bit unsigned value.\r
ac644614 1918\r
efb23117 1919 @return The byte swapped Value.\r
ac644614 1920\r
1921**/\r
1922UINT64\r
1923EFIAPI\r
1924SwapBytes64 (\r
1925 IN UINT64 Value\r
1926 );\r
1927\r
1928\r
1929/**\r
1930 Multiples a 64-bit unsigned integer by a 32-bit unsigned integer and\r
1931 generates a 64-bit unsigned result.\r
1932\r
1933 This function multiples the 64-bit unsigned value Multiplicand by the 32-bit\r
1934 unsigned value Multiplier and generates a 64-bit unsigned result. This 64-\r
1935 bit unsigned result is returned.\r
1936\r
ac644614 1937 @param Multiplicand A 64-bit unsigned value.\r
1938 @param Multiplier A 32-bit unsigned value.\r
1939\r
1940 @return Multiplicand * Multiplier\r
1941\r
1942**/\r
1943UINT64\r
1944EFIAPI\r
1945MultU64x32 (\r
1946 IN UINT64 Multiplicand,\r
1947 IN UINT32 Multiplier\r
1948 );\r
1949\r
1950\r
1951/**\r
1952 Multiples a 64-bit unsigned integer by a 64-bit unsigned integer and\r
1953 generates a 64-bit unsigned result.\r
1954\r
1955 This function multiples the 64-bit unsigned value Multiplicand by the 64-bit\r
1956 unsigned value Multiplier and generates a 64-bit unsigned result. This 64-\r
1957 bit unsigned result is returned.\r
1958\r
ac644614 1959 @param Multiplicand A 64-bit unsigned value.\r
1960 @param Multiplier A 64-bit unsigned value.\r
1961\r
af2dc6a7 1962 @return Multiplicand * Multiplier.\r
ac644614 1963\r
1964**/\r
1965UINT64\r
1966EFIAPI\r
1967MultU64x64 (\r
1968 IN UINT64 Multiplicand,\r
1969 IN UINT64 Multiplier\r
1970 );\r
1971\r
1972\r
1973/**\r
1974 Multiples a 64-bit signed integer by a 64-bit signed integer and generates a\r
1975 64-bit signed result.\r
1976\r
1977 This function multiples the 64-bit signed value Multiplicand by the 64-bit\r
1978 signed value Multiplier and generates a 64-bit signed result. This 64-bit\r
1979 signed result is returned.\r
1980\r
ac644614 1981 @param Multiplicand A 64-bit signed value.\r
1982 @param Multiplier A 64-bit signed value.\r
1983\r
1984 @return Multiplicand * Multiplier\r
1985\r
1986**/\r
1987INT64\r
1988EFIAPI\r
1989MultS64x64 (\r
1990 IN INT64 Multiplicand,\r
1991 IN INT64 Multiplier\r
1992 );\r
1993\r
1994\r
1995/**\r
1996 Divides a 64-bit unsigned integer by a 32-bit unsigned integer and generates\r
1997 a 64-bit unsigned result.\r
1998\r
1999 This function divides the 64-bit unsigned value Dividend by the 32-bit\r
2000 unsigned value Divisor and generates a 64-bit unsigned quotient. This\r
2001 function returns the 64-bit unsigned quotient.\r
2002\r
2003 If Divisor is 0, then ASSERT().\r
2004\r
2005 @param Dividend A 64-bit unsigned value.\r
2006 @param Divisor A 32-bit unsigned value.\r
2007\r
af2dc6a7 2008 @return Dividend / Divisor.\r
ac644614 2009\r
2010**/\r
2011UINT64\r
2012EFIAPI\r
2013DivU64x32 (\r
2014 IN UINT64 Dividend,\r
2015 IN UINT32 Divisor\r
2016 );\r
2017\r
2018\r
2019/**\r
2020 Divides a 64-bit unsigned integer by a 32-bit unsigned integer and generates\r
2021 a 32-bit unsigned remainder.\r
2022\r
2023 This function divides the 64-bit unsigned value Dividend by the 32-bit\r
2024 unsigned value Divisor and generates a 32-bit remainder. This function\r
2025 returns the 32-bit unsigned remainder.\r
2026\r
2027 If Divisor is 0, then ASSERT().\r
2028\r
2029 @param Dividend A 64-bit unsigned value.\r
2030 @param Divisor A 32-bit unsigned value.\r
2031\r
af2dc6a7 2032 @return Dividend % Divisor.\r
ac644614 2033\r
2034**/\r
2035UINT32\r
2036EFIAPI\r
2037ModU64x32 (\r
2038 IN UINT64 Dividend,\r
2039 IN UINT32 Divisor\r
2040 );\r
2041\r
2042\r
2043/**\r
2044 Divides a 64-bit unsigned integer by a 32-bit unsigned integer and generates\r
2045 a 64-bit unsigned result and an optional 32-bit unsigned remainder.\r
2046\r
2047 This function divides the 64-bit unsigned value Dividend by the 32-bit\r
2048 unsigned value Divisor and generates a 64-bit unsigned quotient. If Remainder\r
2049 is not NULL, then the 32-bit unsigned remainder is returned in Remainder.\r
2050 This function returns the 64-bit unsigned quotient.\r
2051\r
2052 If Divisor is 0, then ASSERT().\r
2053\r
2054 @param Dividend A 64-bit unsigned value.\r
2055 @param Divisor A 32-bit unsigned value.\r
2056 @param Remainder A pointer to a 32-bit unsigned value. This parameter is\r
2057 optional and may be NULL.\r
2058\r
af2dc6a7 2059 @return Dividend / Divisor.\r
ac644614 2060\r
2061**/\r
2062UINT64\r
2063EFIAPI\r
2064DivU64x32Remainder (\r
2065 IN UINT64 Dividend,\r
2066 IN UINT32 Divisor,\r
2067 OUT UINT32 *Remainder OPTIONAL\r
2068 );\r
2069\r
2070\r
2071/**\r
2072 Divides a 64-bit unsigned integer by a 64-bit unsigned integer and generates\r
2073 a 64-bit unsigned result and an optional 64-bit unsigned remainder.\r
2074\r
2075 This function divides the 64-bit unsigned value Dividend by the 64-bit\r
2076 unsigned value Divisor and generates a 64-bit unsigned quotient. If Remainder\r
2077 is not NULL, then the 64-bit unsigned remainder is returned in Remainder.\r
2078 This function returns the 64-bit unsigned quotient.\r
2079\r
2080 If Divisor is 0, then ASSERT().\r
2081\r
2082 @param Dividend A 64-bit unsigned value.\r
2083 @param Divisor A 64-bit unsigned value.\r
2084 @param Remainder A pointer to a 64-bit unsigned value. This parameter is\r
2085 optional and may be NULL.\r
2086\r
af2dc6a7 2087 @return Dividend / Divisor.\r
ac644614 2088\r
2089**/\r
2090UINT64\r
2091EFIAPI\r
2092DivU64x64Remainder (\r
2093 IN UINT64 Dividend,\r
2094 IN UINT64 Divisor,\r
2095 OUT UINT64 *Remainder OPTIONAL\r
2096 );\r
2097\r
2098\r
2099/**\r
2100 Divides a 64-bit signed integer by a 64-bit signed integer and generates a\r
2101 64-bit signed result and a optional 64-bit signed remainder.\r
2102\r
2103 This function divides the 64-bit signed value Dividend by the 64-bit signed\r
2104 value Divisor and generates a 64-bit signed quotient. If Remainder is not\r
2105 NULL, then the 64-bit signed remainder is returned in Remainder. This\r
2106 function returns the 64-bit signed quotient.\r
2107\r
9aa049d9 2108 It is the caller's responsibility to not call this function with a Divisor of 0.\r
17f695ed 2109 If Divisor is 0, then the quotient and remainder should be assumed to be \r
2110 the largest negative integer.\r
2111\r
ac644614 2112 If Divisor is 0, then ASSERT().\r
2113\r
2114 @param Dividend A 64-bit signed value.\r
2115 @param Divisor A 64-bit signed value.\r
2116 @param Remainder A pointer to a 64-bit signed value. This parameter is\r
2117 optional and may be NULL.\r
2118\r
af2dc6a7 2119 @return Dividend / Divisor.\r
ac644614 2120\r
2121**/\r
2122INT64\r
2123EFIAPI\r
2124DivS64x64Remainder (\r
2125 IN INT64 Dividend,\r
2126 IN INT64 Divisor,\r
2127 OUT INT64 *Remainder OPTIONAL\r
2128 );\r
2129\r
2130\r
2131/**\r
2132 Reads a 16-bit value from memory that may be unaligned.\r
2133\r
2134 This function returns the 16-bit value pointed to by Buffer. The function\r
2135 guarantees that the read operation does not produce an alignment fault.\r
2136\r
2137 If the Buffer is NULL, then ASSERT().\r
2138\r
af2dc6a7 2139 @param Buffer The pointer to a 16-bit value that may be unaligned.\r
ac644614 2140\r
5385a579 2141 @return The 16-bit value read from Buffer.\r
ac644614 2142\r
2143**/\r
2144UINT16\r
2145EFIAPI\r
2146ReadUnaligned16 (\r
5385a579 2147 IN CONST UINT16 *Buffer\r
ac644614 2148 );\r
2149\r
2150\r
2151/**\r
2152 Writes a 16-bit value to memory that may be unaligned.\r
2153\r
2154 This function writes the 16-bit value specified by Value to Buffer. Value is\r
2155 returned. The function guarantees that the write operation does not produce\r
2156 an alignment fault.\r
2157\r
2158 If the Buffer is NULL, then ASSERT().\r
2159\r
af2dc6a7 2160 @param Buffer The pointer to a 16-bit value that may be unaligned.\r
ac644614 2161 @param Value 16-bit value to write to Buffer.\r
2162\r
5385a579 2163 @return The 16-bit value to write to Buffer.\r
ac644614 2164\r
2165**/\r
2166UINT16\r
2167EFIAPI\r
2168WriteUnaligned16 (\r
5385a579 2169 OUT UINT16 *Buffer,\r
2170 IN UINT16 Value\r
ac644614 2171 );\r
2172\r
2173\r
2174/**\r
2175 Reads a 24-bit value from memory that may be unaligned.\r
2176\r
2177 This function returns the 24-bit value pointed to by Buffer. The function\r
2178 guarantees that the read operation does not produce an alignment fault.\r
2179\r
2180 If the Buffer is NULL, then ASSERT().\r
2181\r
af2dc6a7 2182 @param Buffer The pointer to a 24-bit value that may be unaligned.\r
ac644614 2183\r
5385a579 2184 @return The 24-bit value read from Buffer.\r
ac644614 2185\r
2186**/\r
2187UINT32\r
2188EFIAPI\r
2189ReadUnaligned24 (\r
5385a579 2190 IN CONST UINT32 *Buffer\r
ac644614 2191 );\r
2192\r
2193\r
2194/**\r
2195 Writes a 24-bit value to memory that may be unaligned.\r
2196\r
2197 This function writes the 24-bit value specified by Value to Buffer. Value is\r
2198 returned. The function guarantees that the write operation does not produce\r
2199 an alignment fault.\r
2200\r
2201 If the Buffer is NULL, then ASSERT().\r
2202\r
af2dc6a7 2203 @param Buffer The pointer to a 24-bit value that may be unaligned.\r
ac644614 2204 @param Value 24-bit value to write to Buffer.\r
2205\r
5385a579 2206 @return The 24-bit value to write to Buffer.\r
ac644614 2207\r
2208**/\r
2209UINT32\r
2210EFIAPI\r
2211WriteUnaligned24 (\r
5385a579 2212 OUT UINT32 *Buffer,\r
2213 IN UINT32 Value\r
ac644614 2214 );\r
2215\r
2216\r
2217/**\r
2218 Reads a 32-bit value from memory that may be unaligned.\r
2219\r
2220 This function returns the 32-bit value pointed to by Buffer. The function\r
2221 guarantees that the read operation does not produce an alignment fault.\r
2222\r
2223 If the Buffer is NULL, then ASSERT().\r
2224\r
af2dc6a7 2225 @param Buffer The pointer to a 32-bit value that may be unaligned.\r
ac644614 2226\r
5385a579 2227 @return The 32-bit value read from Buffer.\r
ac644614 2228\r
2229**/\r
2230UINT32\r
2231EFIAPI\r
2232ReadUnaligned32 (\r
5385a579 2233 IN CONST UINT32 *Buffer\r
ac644614 2234 );\r
2235\r
2236\r
2237/**\r
2238 Writes a 32-bit value to memory that may be unaligned.\r
2239\r
2240 This function writes the 32-bit value specified by Value to Buffer. Value is\r
2241 returned. The function guarantees that the write operation does not produce\r
2242 an alignment fault.\r
2243\r
2244 If the Buffer is NULL, then ASSERT().\r
2245\r
af2dc6a7 2246 @param Buffer The pointer to a 32-bit value that may be unaligned.\r
ac644614 2247 @param Value 32-bit value to write to Buffer.\r
2248\r
5385a579 2249 @return The 32-bit value to write to Buffer.\r
ac644614 2250\r
2251**/\r
2252UINT32\r
2253EFIAPI\r
2254WriteUnaligned32 (\r
5385a579 2255 OUT UINT32 *Buffer,\r
2256 IN UINT32 Value\r
ac644614 2257 );\r
2258\r
2259\r
2260/**\r
2261 Reads a 64-bit value from memory that may be unaligned.\r
2262\r
2263 This function returns the 64-bit value pointed to by Buffer. The function\r
2264 guarantees that the read operation does not produce an alignment fault.\r
2265\r
2266 If the Buffer is NULL, then ASSERT().\r
2267\r
af2dc6a7 2268 @param Buffer The pointer to a 64-bit value that may be unaligned.\r
ac644614 2269\r
5385a579 2270 @return The 64-bit value read from Buffer.\r
ac644614 2271\r
2272**/\r
2273UINT64\r
2274EFIAPI\r
2275ReadUnaligned64 (\r
5385a579 2276 IN CONST UINT64 *Buffer\r
ac644614 2277 );\r
2278\r
2279\r
2280/**\r
2281 Writes a 64-bit value to memory that may be unaligned.\r
2282\r
2283 This function writes the 64-bit value specified by Value to Buffer. Value is\r
2284 returned. The function guarantees that the write operation does not produce\r
2285 an alignment fault.\r
2286\r
2287 If the Buffer is NULL, then ASSERT().\r
2288\r
af2dc6a7 2289 @param Buffer The pointer to a 64-bit value that may be unaligned.\r
ac644614 2290 @param Value 64-bit value to write to Buffer.\r
2291\r
5385a579 2292 @return The 64-bit value to write to Buffer.\r
ac644614 2293\r
2294**/\r
2295UINT64\r
2296EFIAPI\r
2297WriteUnaligned64 (\r
5385a579 2298 OUT UINT64 *Buffer,\r
2299 IN UINT64 Value\r
ac644614 2300 );\r
2301\r
2302\r
2303//\r
2304// Bit Field Functions\r
2305//\r
2306\r
2307/**\r
2308 Returns a bit field from an 8-bit value.\r
2309\r
2310 Returns the bitfield specified by the StartBit and the EndBit from Operand.\r
2311\r
2312 If 8-bit operations are not supported, then ASSERT().\r
2313 If StartBit is greater than 7, then ASSERT().\r
2314 If EndBit is greater than 7, then ASSERT().\r
2315 If EndBit is less than StartBit, then ASSERT().\r
2316\r
2317 @param Operand Operand on which to perform the bitfield operation.\r
2318 @param StartBit The ordinal of the least significant bit in the bit field.\r
2319 Range 0..7.\r
2320 @param EndBit The ordinal of the most significant bit in the bit field.\r
2321 Range 0..7.\r
2322\r
2323 @return The bit field read.\r
2324\r
2325**/\r
2326UINT8\r
2327EFIAPI\r
2328BitFieldRead8 (\r
2329 IN UINT8 Operand,\r
2330 IN UINTN StartBit,\r
2331 IN UINTN EndBit\r
2332 );\r
2333\r
2334\r
2335/**\r
2336 Writes a bit field to an 8-bit value, and returns the result.\r
2337\r
2338 Writes Value to the bit field specified by the StartBit and the EndBit in\r
2339 Operand. All other bits in Operand are preserved. The new 8-bit value is\r
2340 returned.\r
2341\r
2342 If 8-bit operations are not supported, then ASSERT().\r
2343 If StartBit is greater than 7, then ASSERT().\r
2344 If EndBit is greater than 7, then ASSERT().\r
2345 If EndBit is less than StartBit, then ASSERT().\r
2346\r
2347 @param Operand Operand on which to perform the bitfield operation.\r
2348 @param StartBit The ordinal of the least significant bit in the bit field.\r
2349 Range 0..7.\r
2350 @param EndBit The ordinal of the most significant bit in the bit field.\r
2351 Range 0..7.\r
2352 @param Value New value of the bit field.\r
2353\r
2354 @return The new 8-bit value.\r
2355\r
2356**/\r
2357UINT8\r
2358EFIAPI\r
2359BitFieldWrite8 (\r
2360 IN UINT8 Operand,\r
2361 IN UINTN StartBit,\r
2362 IN UINTN EndBit,\r
2363 IN UINT8 Value\r
2364 );\r
2365\r
2366\r
2367/**\r
2368 Reads a bit field from an 8-bit value, performs a bitwise OR, and returns the\r
2369 result.\r
2370\r
62991af2 2371 Performs a bitwise OR between the bit field specified by StartBit\r
ac644614 2372 and EndBit in Operand and the value specified by OrData. All other bits in\r
2373 Operand are preserved. The new 8-bit value is returned.\r
2374\r
2375 If 8-bit operations are not supported, then ASSERT().\r
2376 If StartBit is greater than 7, then ASSERT().\r
2377 If EndBit is greater than 7, then ASSERT().\r
2378 If EndBit is less than StartBit, then ASSERT().\r
2379\r
2380 @param Operand Operand on which to perform the bitfield operation.\r
2381 @param StartBit The ordinal of the least significant bit in the bit field.\r
2382 Range 0..7.\r
2383 @param EndBit The ordinal of the most significant bit in the bit field.\r
2384 Range 0..7.\r
2385 @param OrData The value to OR with the read value from the value\r
2386\r
2387 @return The new 8-bit value.\r
2388\r
2389**/\r
2390UINT8\r
2391EFIAPI\r
2392BitFieldOr8 (\r
2393 IN UINT8 Operand,\r
2394 IN UINTN StartBit,\r
2395 IN UINTN EndBit,\r
2396 IN UINT8 OrData\r
2397 );\r
2398\r
2399\r
2400/**\r
2401 Reads a bit field from an 8-bit value, performs a bitwise AND, and returns\r
2402 the result.\r
2403\r
2404 Performs a bitwise AND between the bit field specified by StartBit and EndBit\r
2405 in Operand and the value specified by AndData. All other bits in Operand are\r
2406 preserved. The new 8-bit value is returned.\r
2407\r
2408 If 8-bit operations are not supported, then ASSERT().\r
2409 If StartBit is greater than 7, then ASSERT().\r
2410 If EndBit is greater than 7, then ASSERT().\r
2411 If EndBit is less than StartBit, then ASSERT().\r
2412\r
2413 @param Operand Operand on which to perform the bitfield operation.\r
2414 @param StartBit The ordinal of the least significant bit in the bit field.\r
2415 Range 0..7.\r
2416 @param EndBit The ordinal of the most significant bit in the bit field.\r
2417 Range 0..7.\r
2418 @param AndData The value to AND with the read value from the value.\r
2419\r
2420 @return The new 8-bit value.\r
2421\r
2422**/\r
2423UINT8\r
2424EFIAPI\r
2425BitFieldAnd8 (\r
2426 IN UINT8 Operand,\r
2427 IN UINTN StartBit,\r
2428 IN UINTN EndBit,\r
2429 IN UINT8 AndData\r
2430 );\r
2431\r
2432\r
2433/**\r
2434 Reads a bit field from an 8-bit value, performs a bitwise AND followed by a\r
2435 bitwise OR, and returns the result.\r
2436\r
2437 Performs a bitwise AND between the bit field specified by StartBit and EndBit\r
62991af2 2438 in Operand and the value specified by AndData, followed by a bitwise \r
2439 OR with value specified by OrData. All other bits in Operand are\r
ac644614 2440 preserved. The new 8-bit value is returned.\r
2441\r
2442 If 8-bit operations are not supported, then ASSERT().\r
2443 If StartBit is greater than 7, then ASSERT().\r
2444 If EndBit is greater than 7, then ASSERT().\r
2445 If EndBit is less than StartBit, then ASSERT().\r
2446\r
2447 @param Operand Operand on which to perform the bitfield operation.\r
2448 @param StartBit The ordinal of the least significant bit in the bit field.\r
2449 Range 0..7.\r
2450 @param EndBit The ordinal of the most significant bit in the bit field.\r
2451 Range 0..7.\r
2452 @param AndData The value to AND with the read value from the value.\r
2453 @param OrData The value to OR with the result of the AND operation.\r
2454\r
2455 @return The new 8-bit value.\r
2456\r
2457**/\r
2458UINT8\r
2459EFIAPI\r
2460BitFieldAndThenOr8 (\r
2461 IN UINT8 Operand,\r
2462 IN UINTN StartBit,\r
2463 IN UINTN EndBit,\r
2464 IN UINT8 AndData,\r
2465 IN UINT8 OrData\r
2466 );\r
2467\r
2468\r
2469/**\r
2470 Returns a bit field from a 16-bit value.\r
2471\r
2472 Returns the bitfield specified by the StartBit and the EndBit from Operand.\r
2473\r
2474 If 16-bit operations are not supported, then ASSERT().\r
2475 If StartBit is greater than 15, then ASSERT().\r
2476 If EndBit is greater than 15, then ASSERT().\r
2477 If EndBit is less than StartBit, then ASSERT().\r
2478\r
2479 @param Operand Operand on which to perform the bitfield operation.\r
2480 @param StartBit The ordinal of the least significant bit in the bit field.\r
2481 Range 0..15.\r
2482 @param EndBit The ordinal of the most significant bit in the bit field.\r
2483 Range 0..15.\r
2484\r
2485 @return The bit field read.\r
2486\r
2487**/\r
2488UINT16\r
2489EFIAPI\r
2490BitFieldRead16 (\r
2491 IN UINT16 Operand,\r
2492 IN UINTN StartBit,\r
2493 IN UINTN EndBit\r
2494 );\r
2495\r
2496\r
2497/**\r
2498 Writes a bit field to a 16-bit value, and returns the result.\r
2499\r
2500 Writes Value to the bit field specified by the StartBit and the EndBit in\r
2501 Operand. All other bits in Operand are preserved. The new 16-bit value is\r
2502 returned.\r
2503\r
2504 If 16-bit operations are not supported, then ASSERT().\r
2505 If StartBit is greater than 15, then ASSERT().\r
2506 If EndBit is greater than 15, then ASSERT().\r
2507 If EndBit is less than StartBit, then ASSERT().\r
2508\r
2509 @param Operand Operand on which to perform the bitfield operation.\r
2510 @param StartBit The ordinal of the least significant bit in the bit field.\r
2511 Range 0..15.\r
2512 @param EndBit The ordinal of the most significant bit in the bit field.\r
2513 Range 0..15.\r
2514 @param Value New value of the bit field.\r
2515\r
2516 @return The new 16-bit value.\r
2517\r
2518**/\r
2519UINT16\r
2520EFIAPI\r
2521BitFieldWrite16 (\r
2522 IN UINT16 Operand,\r
2523 IN UINTN StartBit,\r
2524 IN UINTN EndBit,\r
2525 IN UINT16 Value\r
2526 );\r
2527\r
2528\r
2529/**\r
2530 Reads a bit field from a 16-bit value, performs a bitwise OR, and returns the\r
2531 result.\r
2532\r
62991af2 2533 Performs a bitwise OR between the bit field specified by StartBit\r
ac644614 2534 and EndBit in Operand and the value specified by OrData. All other bits in\r
2535 Operand are preserved. The new 16-bit value is returned.\r
2536\r
2537 If 16-bit operations are not supported, then ASSERT().\r
2538 If StartBit is greater than 15, then ASSERT().\r
2539 If EndBit is greater than 15, then ASSERT().\r
2540 If EndBit is less than StartBit, then ASSERT().\r
2541\r
2542 @param Operand Operand on which to perform the bitfield operation.\r
2543 @param StartBit The ordinal of the least significant bit in the bit field.\r
2544 Range 0..15.\r
2545 @param EndBit The ordinal of the most significant bit in the bit field.\r
2546 Range 0..15.\r
2547 @param OrData The value to OR with the read value from the value\r
2548\r
2549 @return The new 16-bit value.\r
2550\r
2551**/\r
2552UINT16\r
2553EFIAPI\r
2554BitFieldOr16 (\r
2555 IN UINT16 Operand,\r
2556 IN UINTN StartBit,\r
2557 IN UINTN EndBit,\r
2558 IN UINT16 OrData\r
2559 );\r
2560\r
2561\r
2562/**\r
2563 Reads a bit field from a 16-bit value, performs a bitwise AND, and returns\r
2564 the result.\r
2565\r
2566 Performs a bitwise AND between the bit field specified by StartBit and EndBit\r
2567 in Operand and the value specified by AndData. All other bits in Operand are\r
2568 preserved. The new 16-bit value is returned.\r
2569\r
2570 If 16-bit operations are not supported, then ASSERT().\r
2571 If StartBit is greater than 15, then ASSERT().\r
2572 If EndBit is greater than 15, then ASSERT().\r
2573 If EndBit is less than StartBit, then ASSERT().\r
2574\r
2575 @param Operand Operand on which to perform the bitfield operation.\r
2576 @param StartBit The ordinal of the least significant bit in the bit field.\r
2577 Range 0..15.\r
2578 @param EndBit The ordinal of the most significant bit in the bit field.\r
2579 Range 0..15.\r
2580 @param AndData The value to AND with the read value from the value\r
2581\r
2582 @return The new 16-bit value.\r
2583\r
2584**/\r
2585UINT16\r
2586EFIAPI\r
2587BitFieldAnd16 (\r
2588 IN UINT16 Operand,\r
2589 IN UINTN StartBit,\r
2590 IN UINTN EndBit,\r
2591 IN UINT16 AndData\r
2592 );\r
2593\r
2594\r
2595/**\r
2596 Reads a bit field from a 16-bit value, performs a bitwise AND followed by a\r
2597 bitwise OR, and returns the result.\r
2598\r
2599 Performs a bitwise AND between the bit field specified by StartBit and EndBit\r
62991af2 2600 in Operand and the value specified by AndData, followed by a bitwise \r
2601 OR with value specified by OrData. All other bits in Operand are\r
ac644614 2602 preserved. The new 16-bit value is returned.\r
2603\r
2604 If 16-bit operations are not supported, then ASSERT().\r
2605 If StartBit is greater than 15, then ASSERT().\r
2606 If EndBit is greater than 15, then ASSERT().\r
2607 If EndBit is less than StartBit, then ASSERT().\r
2608\r
2609 @param Operand Operand on which to perform the bitfield operation.\r
2610 @param StartBit The ordinal of the least significant bit in the bit field.\r
2611 Range 0..15.\r
2612 @param EndBit The ordinal of the most significant bit in the bit field.\r
2613 Range 0..15.\r
2614 @param AndData The value to AND with the read value from the value.\r
2615 @param OrData The value to OR with the result of the AND operation.\r
2616\r
2617 @return The new 16-bit value.\r
2618\r
2619**/\r
2620UINT16\r
2621EFIAPI\r
2622BitFieldAndThenOr16 (\r
2623 IN UINT16 Operand,\r
2624 IN UINTN StartBit,\r
2625 IN UINTN EndBit,\r
2626 IN UINT16 AndData,\r
2627 IN UINT16 OrData\r
2628 );\r
2629\r
2630\r
2631/**\r
2632 Returns a bit field from a 32-bit value.\r
2633\r
2634 Returns the bitfield specified by the StartBit and the EndBit from Operand.\r
2635\r
2636 If 32-bit operations are not supported, then ASSERT().\r
2637 If StartBit is greater than 31, then ASSERT().\r
2638 If EndBit is greater than 31, then ASSERT().\r
2639 If EndBit is less than StartBit, then ASSERT().\r
2640\r
2641 @param Operand Operand on which to perform the bitfield operation.\r
2642 @param StartBit The ordinal of the least significant bit in the bit field.\r
2643 Range 0..31.\r
2644 @param EndBit The ordinal of the most significant bit in the bit field.\r
2645 Range 0..31.\r
2646\r
2647 @return The bit field read.\r
2648\r
2649**/\r
2650UINT32\r
2651EFIAPI\r
2652BitFieldRead32 (\r
2653 IN UINT32 Operand,\r
2654 IN UINTN StartBit,\r
2655 IN UINTN EndBit\r
2656 );\r
2657\r
2658\r
2659/**\r
2660 Writes a bit field to a 32-bit value, and returns the result.\r
2661\r
2662 Writes Value to the bit field specified by the StartBit and the EndBit in\r
2663 Operand. All other bits in Operand are preserved. The new 32-bit value is\r
2664 returned.\r
2665\r
2666 If 32-bit operations are not supported, then ASSERT().\r
2667 If StartBit is greater than 31, then ASSERT().\r
2668 If EndBit is greater than 31, then ASSERT().\r
2669 If EndBit is less than StartBit, then ASSERT().\r
2670\r
2671 @param Operand Operand on which to perform the bitfield operation.\r
2672 @param StartBit The ordinal of the least significant bit in the bit field.\r
2673 Range 0..31.\r
2674 @param EndBit The ordinal of the most significant bit in the bit field.\r
2675 Range 0..31.\r
2676 @param Value New value of the bit field.\r
2677\r
2678 @return The new 32-bit value.\r
2679\r
2680**/\r
2681UINT32\r
2682EFIAPI\r
2683BitFieldWrite32 (\r
2684 IN UINT32 Operand,\r
2685 IN UINTN StartBit,\r
2686 IN UINTN EndBit,\r
2687 IN UINT32 Value\r
2688 );\r
2689\r
2690\r
2691/**\r
2692 Reads a bit field from a 32-bit value, performs a bitwise OR, and returns the\r
2693 result.\r
2694\r
62991af2 2695 Performs a bitwise OR between the bit field specified by StartBit\r
ac644614 2696 and EndBit in Operand and the value specified by OrData. All other bits in\r
2697 Operand are preserved. The new 32-bit value is returned.\r
2698\r
2699 If 32-bit operations are not supported, then ASSERT().\r
2700 If StartBit is greater than 31, then ASSERT().\r
2701 If EndBit is greater than 31, then ASSERT().\r
2702 If EndBit is less than StartBit, then ASSERT().\r
2703\r
2704 @param Operand Operand on which to perform the bitfield operation.\r
2705 @param StartBit The ordinal of the least significant bit in the bit field.\r
2706 Range 0..31.\r
2707 @param EndBit The ordinal of the most significant bit in the bit field.\r
2708 Range 0..31.\r
af2dc6a7 2709 @param OrData The value to OR with the read value from the value.\r
ac644614 2710\r
2711 @return The new 32-bit value.\r
2712\r
2713**/\r
2714UINT32\r
2715EFIAPI\r
2716BitFieldOr32 (\r
2717 IN UINT32 Operand,\r
2718 IN UINTN StartBit,\r
2719 IN UINTN EndBit,\r
2720 IN UINT32 OrData\r
2721 );\r
2722\r
2723\r
2724/**\r
2725 Reads a bit field from a 32-bit value, performs a bitwise AND, and returns\r
2726 the result.\r
2727\r
2728 Performs a bitwise AND between the bit field specified by StartBit and EndBit\r
2729 in Operand and the value specified by AndData. All other bits in Operand are\r
2730 preserved. The new 32-bit value is returned.\r
2731\r
2732 If 32-bit operations are not supported, then ASSERT().\r
2733 If StartBit is greater than 31, then ASSERT().\r
2734 If EndBit is greater than 31, then ASSERT().\r
2735 If EndBit is less than StartBit, then ASSERT().\r
2736\r
2737 @param Operand Operand on which to perform the bitfield operation.\r
2738 @param StartBit The ordinal of the least significant bit in the bit field.\r
2739 Range 0..31.\r
2740 @param EndBit The ordinal of the most significant bit in the bit field.\r
2741 Range 0..31.\r
2742 @param AndData The value to AND with the read value from the value\r
2743\r
2744 @return The new 32-bit value.\r
2745\r
2746**/\r
2747UINT32\r
2748EFIAPI\r
2749BitFieldAnd32 (\r
2750 IN UINT32 Operand,\r
2751 IN UINTN StartBit,\r
2752 IN UINTN EndBit,\r
2753 IN UINT32 AndData\r
2754 );\r
2755\r
2756\r
2757/**\r
2758 Reads a bit field from a 32-bit value, performs a bitwise AND followed by a\r
2759 bitwise OR, and returns the result.\r
2760\r
2761 Performs a bitwise AND between the bit field specified by StartBit and EndBit\r
62991af2 2762 in Operand and the value specified by AndData, followed by a bitwise \r
2763 OR with value specified by OrData. All other bits in Operand are\r
ac644614 2764 preserved. The new 32-bit value is returned.\r
2765\r
2766 If 32-bit operations are not supported, then ASSERT().\r
2767 If StartBit is greater than 31, then ASSERT().\r
2768 If EndBit is greater than 31, then ASSERT().\r
2769 If EndBit is less than StartBit, then ASSERT().\r
2770\r
2771 @param Operand Operand on which to perform the bitfield operation.\r
2772 @param StartBit The ordinal of the least significant bit in the bit field.\r
2773 Range 0..31.\r
2774 @param EndBit The ordinal of the most significant bit in the bit field.\r
2775 Range 0..31.\r
2776 @param AndData The value to AND with the read value from the value.\r
2777 @param OrData The value to OR with the result of the AND operation.\r
2778\r
2779 @return The new 32-bit value.\r
2780\r
2781**/\r
2782UINT32\r
2783EFIAPI\r
2784BitFieldAndThenOr32 (\r
2785 IN UINT32 Operand,\r
2786 IN UINTN StartBit,\r
2787 IN UINTN EndBit,\r
2788 IN UINT32 AndData,\r
2789 IN UINT32 OrData\r
2790 );\r
2791\r
2792\r
2793/**\r
2794 Returns a bit field from a 64-bit value.\r
2795\r
2796 Returns the bitfield specified by the StartBit and the EndBit from Operand.\r
2797\r
2798 If 64-bit operations are not supported, then ASSERT().\r
2799 If StartBit is greater than 63, then ASSERT().\r
2800 If EndBit is greater than 63, then ASSERT().\r
2801 If EndBit is less than StartBit, then ASSERT().\r
2802\r
2803 @param Operand Operand on which to perform the bitfield operation.\r
2804 @param StartBit The ordinal of the least significant bit in the bit field.\r
2805 Range 0..63.\r
2806 @param EndBit The ordinal of the most significant bit in the bit field.\r
2807 Range 0..63.\r
2808\r
2809 @return The bit field read.\r
2810\r
2811**/\r
2812UINT64\r
2813EFIAPI\r
2814BitFieldRead64 (\r
2815 IN UINT64 Operand,\r
2816 IN UINTN StartBit,\r
2817 IN UINTN EndBit\r
2818 );\r
2819\r
2820\r
2821/**\r
2822 Writes a bit field to a 64-bit value, and returns the result.\r
2823\r
2824 Writes Value to the bit field specified by the StartBit and the EndBit in\r
2825 Operand. All other bits in Operand are preserved. The new 64-bit value is\r
2826 returned.\r
2827\r
2828 If 64-bit operations are not supported, then ASSERT().\r
2829 If StartBit is greater than 63, then ASSERT().\r
2830 If EndBit is greater than 63, then ASSERT().\r
2831 If EndBit is less than StartBit, then ASSERT().\r
2832\r
2833 @param Operand Operand on which to perform the bitfield operation.\r
2834 @param StartBit The ordinal of the least significant bit in the bit field.\r
2835 Range 0..63.\r
2836 @param EndBit The ordinal of the most significant bit in the bit field.\r
2837 Range 0..63.\r
2838 @param Value New value of the bit field.\r
2839\r
2840 @return The new 64-bit value.\r
2841\r
2842**/\r
2843UINT64\r
2844EFIAPI\r
2845BitFieldWrite64 (\r
2846 IN UINT64 Operand,\r
2847 IN UINTN StartBit,\r
2848 IN UINTN EndBit,\r
2849 IN UINT64 Value\r
2850 );\r
2851\r
2852\r
2853/**\r
2854 Reads a bit field from a 64-bit value, performs a bitwise OR, and returns the\r
2855 result.\r
2856\r
62991af2 2857 Performs a bitwise OR between the bit field specified by StartBit\r
ac644614 2858 and EndBit in Operand and the value specified by OrData. All other bits in\r
2859 Operand are preserved. The new 64-bit value is returned.\r
2860\r
2861 If 64-bit operations are not supported, then ASSERT().\r
2862 If StartBit is greater than 63, then ASSERT().\r
2863 If EndBit is greater than 63, then ASSERT().\r
2864 If EndBit is less than StartBit, then ASSERT().\r
2865\r
2866 @param Operand Operand on which to perform the bitfield operation.\r
2867 @param StartBit The ordinal of the least significant bit in the bit field.\r
2868 Range 0..63.\r
2869 @param EndBit The ordinal of the most significant bit in the bit field.\r
2870 Range 0..63.\r
2871 @param OrData The value to OR with the read value from the value\r
2872\r
2873 @return The new 64-bit value.\r
2874\r
2875**/\r
2876UINT64\r
2877EFIAPI\r
2878BitFieldOr64 (\r
2879 IN UINT64 Operand,\r
2880 IN UINTN StartBit,\r
2881 IN UINTN EndBit,\r
2882 IN UINT64 OrData\r
2883 );\r
2884\r
2885\r
2886/**\r
2887 Reads a bit field from a 64-bit value, performs a bitwise AND, and returns\r
2888 the result.\r
2889\r
2890 Performs a bitwise AND between the bit field specified by StartBit and EndBit\r
2891 in Operand and the value specified by AndData. All other bits in Operand are\r
2892 preserved. The new 64-bit value is returned.\r
2893\r
2894 If 64-bit operations are not supported, then ASSERT().\r
2895 If StartBit is greater than 63, then ASSERT().\r
2896 If EndBit is greater than 63, then ASSERT().\r
2897 If EndBit is less than StartBit, then ASSERT().\r
2898\r
2899 @param Operand Operand on which to perform the bitfield operation.\r
2900 @param StartBit The ordinal of the least significant bit in the bit field.\r
2901 Range 0..63.\r
2902 @param EndBit The ordinal of the most significant bit in the bit field.\r
2903 Range 0..63.\r
2904 @param AndData The value to AND with the read value from the value\r
2905\r
2906 @return The new 64-bit value.\r
2907\r
2908**/\r
2909UINT64\r
2910EFIAPI\r
2911BitFieldAnd64 (\r
2912 IN UINT64 Operand,\r
2913 IN UINTN StartBit,\r
2914 IN UINTN EndBit,\r
2915 IN UINT64 AndData\r
2916 );\r
2917\r
2918\r
2919/**\r
2920 Reads a bit field from a 64-bit value, performs a bitwise AND followed by a\r
2921 bitwise OR, and returns the result.\r
2922\r
2923 Performs a bitwise AND between the bit field specified by StartBit and EndBit\r
62991af2 2924 in Operand and the value specified by AndData, followed by a bitwise \r
2925 OR with value specified by OrData. All other bits in Operand are\r
ac644614 2926 preserved. The new 64-bit value is returned.\r
2927\r
2928 If 64-bit operations are not supported, then ASSERT().\r
2929 If StartBit is greater than 63, then ASSERT().\r
2930 If EndBit is greater than 63, then ASSERT().\r
2931 If EndBit is less than StartBit, then ASSERT().\r
2932\r
2933 @param Operand Operand on which to perform the bitfield operation.\r
2934 @param StartBit The ordinal of the least significant bit in the bit field.\r
2935 Range 0..63.\r
2936 @param EndBit The ordinal of the most significant bit in the bit field.\r
2937 Range 0..63.\r
2938 @param AndData The value to AND with the read value from the value.\r
2939 @param OrData The value to OR with the result of the AND operation.\r
2940\r
2941 @return The new 64-bit value.\r
2942\r
2943**/\r
2944UINT64\r
2945EFIAPI\r
2946BitFieldAndThenOr64 (\r
2947 IN UINT64 Operand,\r
2948 IN UINTN StartBit,\r
2949 IN UINTN EndBit,\r
2950 IN UINT64 AndData,\r
2951 IN UINT64 OrData\r
2952 );\r
2953\r
ac644614 2954//\r
2955// Base Library Checksum Functions\r
2956//\r
2957\r
2958/**\r
17f695ed 2959 Returns the sum of all elements in a buffer in unit of UINT8.\r
ac644614 2960 During calculation, the carry bits are dropped.\r
2961\r
2962 This function calculates the sum of all elements in a buffer\r
2963 in unit of UINT8. The carry bits in result of addition are dropped.\r
2964 The result is returned as UINT8. If Length is Zero, then Zero is\r
2965 returned.\r
2966\r
2967 If Buffer is NULL, then ASSERT().\r
2968 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().\r
2969\r
af2dc6a7 2970 @param Buffer The pointer to the buffer to carry out the sum operation.\r
17f695ed 2971 @param Length The size, in bytes, of Buffer.\r
ac644614 2972\r
2973 @return Sum The sum of Buffer with carry bits dropped during additions.\r
2974\r
2975**/\r
2976UINT8\r
2977EFIAPI\r
2978CalculateSum8 (\r
ee6c452c 2979 IN CONST UINT8 *Buffer,\r
2980 IN UINTN Length\r
ac644614 2981 );\r
2982\r
2983\r
2984/**\r
2985 Returns the two's complement checksum of all elements in a buffer\r
2986 of 8-bit values.\r
2987\r
2988 This function first calculates the sum of the 8-bit values in the\r
2989 buffer specified by Buffer and Length. The carry bits in the result\r
2990 of addition are dropped. Then, the two's complement of the sum is\r
2991 returned. If Length is 0, then 0 is returned.\r
2992\r
2993 If Buffer is NULL, then ASSERT().\r
2994 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().\r
2995\r
af2dc6a7 2996 @param Buffer The pointer to the buffer to carry out the checksum operation.\r
1106ffe1 2997 @param Length The size, in bytes, of Buffer.\r
ac644614 2998\r
af2dc6a7 2999 @return Checksum The two's complement checksum of Buffer.\r
ac644614 3000\r
3001**/\r
3002UINT8\r
3003EFIAPI\r
3004CalculateCheckSum8 (\r
ee6c452c 3005 IN CONST UINT8 *Buffer,\r
3006 IN UINTN Length\r
ac644614 3007 );\r
3008\r
3009\r
3010/**\r
3011 Returns the sum of all elements in a buffer of 16-bit values. During\r
3012 calculation, the carry bits are dropped.\r
3013\r
3014 This function calculates the sum of the 16-bit values in the buffer\r
3015 specified by Buffer and Length. The carry bits in result of addition are dropped.\r
3016 The 16-bit result is returned. If Length is 0, then 0 is returned.\r
3017\r
3018 If Buffer is NULL, then ASSERT().\r
3019 If Buffer is not aligned on a 16-bit boundary, then ASSERT().\r
3020 If Length is not aligned on a 16-bit boundary, then ASSERT().\r
3021 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().\r
3022\r
af2dc6a7 3023 @param Buffer The pointer to the buffer to carry out the sum operation.\r
1106ffe1 3024 @param Length The size, in bytes, of Buffer.\r
ac644614 3025\r
3026 @return Sum The sum of Buffer with carry bits dropped during additions.\r
3027\r
3028**/\r
3029UINT16\r
3030EFIAPI\r
3031CalculateSum16 (\r
ee6c452c 3032 IN CONST UINT16 *Buffer,\r
3033 IN UINTN Length\r
ac644614 3034 );\r
3035\r
3036\r
3037/**\r
3038 Returns the two's complement checksum of all elements in a buffer of\r
3039 16-bit values.\r
3040\r
3041 This function first calculates the sum of the 16-bit values in the buffer\r
3042 specified by Buffer and Length. The carry bits in the result of addition\r
3043 are dropped. Then, the two's complement of the sum is returned. If Length\r
3044 is 0, then 0 is returned.\r
3045\r
3046 If Buffer is NULL, then ASSERT().\r
3047 If Buffer is not aligned on a 16-bit boundary, then ASSERT().\r
3048 If Length is not aligned on a 16-bit boundary, then ASSERT().\r
3049 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().\r
3050\r
af2dc6a7 3051 @param Buffer The pointer to the buffer to carry out the checksum operation.\r
1106ffe1 3052 @param Length The size, in bytes, of Buffer.\r
ac644614 3053\r
af2dc6a7 3054 @return Checksum The two's complement checksum of Buffer.\r
ac644614 3055\r
3056**/\r
3057UINT16\r
3058EFIAPI\r
3059CalculateCheckSum16 (\r
ee6c452c 3060 IN CONST UINT16 *Buffer,\r
3061 IN UINTN Length\r
ac644614 3062 );\r
3063\r
3064\r
3065/**\r
17f695ed 3066 Returns the sum of all elements in a buffer of 32-bit values. During\r
ac644614 3067 calculation, the carry bits are dropped.\r
3068\r
3069 This function calculates the sum of the 32-bit values in the buffer\r
3070 specified by Buffer and Length. The carry bits in result of addition are dropped.\r
17f695ed 3071 The 32-bit result is returned. If Length is 0, then 0 is returned.\r
ac644614 3072\r
3073 If Buffer is NULL, then ASSERT().\r
3074 If Buffer is not aligned on a 32-bit boundary, then ASSERT().\r
3075 If Length is not aligned on a 32-bit boundary, then ASSERT().\r
3076 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().\r
3077\r
af2dc6a7 3078 @param Buffer The pointer to the buffer to carry out the sum operation.\r
1106ffe1 3079 @param Length The size, in bytes, of Buffer.\r
ac644614 3080\r
3081 @return Sum The sum of Buffer with carry bits dropped during additions.\r
3082\r
3083**/\r
3084UINT32\r
3085EFIAPI\r
3086CalculateSum32 (\r
ee6c452c 3087 IN CONST UINT32 *Buffer,\r
3088 IN UINTN Length\r
ac644614 3089 );\r
3090\r
3091\r
3092/**\r
3093 Returns the two's complement checksum of all elements in a buffer of\r
3094 32-bit values.\r
3095\r
3096 This function first calculates the sum of the 32-bit values in the buffer\r
3097 specified by Buffer and Length. The carry bits in the result of addition\r
3098 are dropped. Then, the two's complement of the sum is returned. If Length\r
3099 is 0, then 0 is returned.\r
3100\r
3101 If Buffer is NULL, then ASSERT().\r
3102 If Buffer is not aligned on a 32-bit boundary, then ASSERT().\r
3103 If Length is not aligned on a 32-bit boundary, then ASSERT().\r
3104 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().\r
3105\r
af2dc6a7 3106 @param Buffer The pointer to the buffer to carry out the checksum operation.\r
1106ffe1 3107 @param Length The size, in bytes, of Buffer.\r
ac644614 3108\r
af2dc6a7 3109 @return Checksum The two's complement checksum of Buffer.\r
ac644614 3110\r
3111**/\r
3112UINT32\r
3113EFIAPI\r
3114CalculateCheckSum32 (\r
ee6c452c 3115 IN CONST UINT32 *Buffer,\r
3116 IN UINTN Length\r
ac644614 3117 );\r
3118\r
3119\r
3120/**\r
3121 Returns the sum of all elements in a buffer of 64-bit values. During\r
3122 calculation, the carry bits are dropped.\r
3123\r
3124 This function calculates the sum of the 64-bit values in the buffer\r
3125 specified by Buffer and Length. The carry bits in result of addition are dropped.\r
3126 The 64-bit result is returned. If Length is 0, then 0 is returned.\r
3127\r
3128 If Buffer is NULL, then ASSERT().\r
3129 If Buffer is not aligned on a 64-bit boundary, then ASSERT().\r
3130 If Length is not aligned on a 64-bit boundary, then ASSERT().\r
3131 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().\r
3132\r
af2dc6a7 3133 @param Buffer The pointer to the buffer to carry out the sum operation.\r
1106ffe1 3134 @param Length The size, in bytes, of Buffer.\r
ac644614 3135\r
3136 @return Sum The sum of Buffer with carry bits dropped during additions.\r
3137\r
3138**/\r
3139UINT64\r
3140EFIAPI\r
3141CalculateSum64 (\r
ee6c452c 3142 IN CONST UINT64 *Buffer,\r
3143 IN UINTN Length\r
ac644614 3144 );\r
3145\r
3146\r
3147/**\r
3148 Returns the two's complement checksum of all elements in a buffer of\r
3149 64-bit values.\r
3150\r
3151 This function first calculates the sum of the 64-bit values in the buffer\r
3152 specified by Buffer and Length. The carry bits in the result of addition\r
3153 are dropped. Then, the two's complement of the sum is returned. If Length\r
3154 is 0, then 0 is returned.\r
3155\r
3156 If Buffer is NULL, then ASSERT().\r
3157 If Buffer is not aligned on a 64-bit boundary, then ASSERT().\r
3158 If Length is not aligned on a 64-bit boundary, then ASSERT().\r
3159 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().\r
3160\r
af2dc6a7 3161 @param Buffer The pointer to the buffer to carry out the checksum operation.\r
1106ffe1 3162 @param Length The size, in bytes, of Buffer.\r
ac644614 3163\r
af2dc6a7 3164 @return Checksum The two's complement checksum of Buffer.\r
ac644614 3165\r
3166**/\r
3167UINT64\r
3168EFIAPI\r
3169CalculateCheckSum64 (\r
ee6c452c 3170 IN CONST UINT64 *Buffer,\r
3171 IN UINTN Length\r
ac644614 3172 );\r
3173\r
3174\r
d75f9fc2 3175//\r
3176// Base Library CPU Functions\r
3177//\r
3178\r
3179/**\r
3180 Function entry point used when a stack switch is requested with SwitchStack()\r
3181\r
3182 @param Context1 Context1 parameter passed into SwitchStack().\r
3183 @param Context2 Context2 parameter passed into SwitchStack().\r
3184\r
3185**/\r
ac644614 3186typedef\r
3187VOID\r
9810cdd8 3188(EFIAPI *SWITCH_STACK_ENTRY_POINT)(\r
ac644614 3189 IN VOID *Context1, OPTIONAL\r
3190 IN VOID *Context2 OPTIONAL\r
3191 );\r
3192\r
3193\r
3194/**\r
3195 Used to serialize load and store operations.\r
3196\r
3197 All loads and stores that proceed calls to this function are guaranteed to be\r
3198 globally visible when this function returns.\r
3199\r
3200**/\r
3201VOID\r
3202EFIAPI\r
3203MemoryFence (\r
3204 VOID\r
3205 );\r
3206\r
3207\r
3208/**\r
3209 Saves the current CPU context that can be restored with a call to LongJump()\r
3210 and returns 0.\r
3211\r
3212 Saves the current CPU context in the buffer specified by JumpBuffer and\r
3213 returns 0. The initial call to SetJump() must always return 0. Subsequent\r
3214 calls to LongJump() cause a non-zero value to be returned by SetJump().\r
3215\r
3216 If JumpBuffer is NULL, then ASSERT().\r
1a2f870c 3217 For Itanium processors, if JumpBuffer is not aligned on a 16-byte boundary, then ASSERT().\r
17f695ed 3218 \r
3219 NOTE: The structure BASE_LIBRARY_JUMP_BUFFER is CPU architecture specific.\r
3220 The same structure must never be used for more than one CPU architecture context.\r
3221 For example, a BASE_LIBRARY_JUMP_BUFFER allocated by an IA-32 module must never be used from an x64 module. \r
3222 SetJump()/LongJump() is not currently supported for the EBC processor type. \r
ac644614 3223\r
3224 @param JumpBuffer A pointer to CPU context buffer.\r
3225\r
3226 @retval 0 Indicates a return from SetJump().\r
3227\r
3228**/\r
3229UINTN\r
3230EFIAPI\r
3231SetJump (\r
3232 OUT BASE_LIBRARY_JUMP_BUFFER *JumpBuffer\r
3233 );\r
3234\r
3235\r
3236/**\r
3237 Restores the CPU context that was saved with SetJump().\r
3238\r
3239 Restores the CPU context from the buffer specified by JumpBuffer. This\r
3240 function never returns to the caller. Instead is resumes execution based on\r
3241 the state of JumpBuffer.\r
3242\r
3243 If JumpBuffer is NULL, then ASSERT().\r
1a2f870c 3244 For Itanium processors, if JumpBuffer is not aligned on a 16-byte boundary, then ASSERT().\r
ac644614 3245 If Value is 0, then ASSERT().\r
3246\r
3247 @param JumpBuffer A pointer to CPU context buffer.\r
3248 @param Value The value to return when the SetJump() context is\r
3249 restored and must be non-zero.\r
3250\r
3251**/\r
3252VOID\r
3253EFIAPI\r
3254LongJump (\r
3255 IN BASE_LIBRARY_JUMP_BUFFER *JumpBuffer,\r
3256 IN UINTN Value\r
3257 );\r
3258\r
3259\r
3260/**\r
3261 Enables CPU interrupts.\r
3262\r
ac644614 3263**/\r
3264VOID\r
3265EFIAPI\r
3266EnableInterrupts (\r
3267 VOID\r
3268 );\r
3269\r
3270\r
3271/**\r
3272 Disables CPU interrupts.\r
3273\r
ac644614 3274**/\r
3275VOID\r
3276EFIAPI\r
3277DisableInterrupts (\r
3278 VOID\r
3279 );\r
3280\r
3281\r
3282/**\r
3283 Disables CPU interrupts and returns the interrupt state prior to the disable\r
3284 operation.\r
3285\r
ac644614 3286 @retval TRUE CPU interrupts were enabled on entry to this call.\r
3287 @retval FALSE CPU interrupts were disabled on entry to this call.\r
3288\r
3289**/\r
3290BOOLEAN\r
3291EFIAPI\r
3292SaveAndDisableInterrupts (\r
3293 VOID\r
3294 );\r
3295\r
3296\r
3297/**\r
3298 Enables CPU interrupts for the smallest window required to capture any\r
3299 pending interrupts.\r
3300\r
ac644614 3301**/\r
3302VOID\r
3303EFIAPI\r
3304EnableDisableInterrupts (\r
3305 VOID\r
3306 );\r
3307\r
3308\r
3309/**\r
3310 Retrieves the current CPU interrupt state.\r
3311\r
af2dc6a7 3312 Returns TRUE if interrupts are currently enabled. Otherwise\r
38bbd3d9 3313 returns FALSE.\r
ac644614 3314\r
3315 @retval TRUE CPU interrupts are enabled.\r
3316 @retval FALSE CPU interrupts are disabled.\r
3317\r
3318**/\r
3319BOOLEAN\r
3320EFIAPI\r
3321GetInterruptState (\r
3322 VOID\r
3323 );\r
3324\r
3325\r
3326/**\r
3327 Set the current CPU interrupt state.\r
3328\r
3329 Sets the current CPU interrupt state to the state specified by\r
3330 InterruptState. If InterruptState is TRUE, then interrupts are enabled. If\r
3331 InterruptState is FALSE, then interrupts are disabled. InterruptState is\r
3332 returned.\r
3333\r
3334 @param InterruptState TRUE if interrupts should enabled. FALSE if\r
3335 interrupts should be disabled.\r
3336\r
3337 @return InterruptState\r
3338\r
3339**/\r
3340BOOLEAN\r
3341EFIAPI\r
3342SetInterruptState (\r
3343 IN BOOLEAN InterruptState\r
3344 );\r
3345\r
3346\r
3347/**\r
3348 Requests CPU to pause for a short period of time.\r
3349\r
3350 Requests CPU to pause for a short period of time. Typically used in MP\r
3351 systems to prevent memory starvation while waiting for a spin lock.\r
3352\r
3353**/\r
3354VOID\r
3355EFIAPI\r
3356CpuPause (\r
3357 VOID\r
3358 );\r
3359\r
3360\r
3361/**\r
3362 Transfers control to a function starting with a new stack.\r
3363\r
3364 Transfers control to the function specified by EntryPoint using the\r
3365 new stack specified by NewStack and passing in the parameters specified\r
3366 by Context1 and Context2. Context1 and Context2 are optional and may\r
3367 be NULL. The function EntryPoint must never return. This function\r
3368 supports a variable number of arguments following the NewStack parameter.\r
1a2f870c 3369 These additional arguments are ignored on IA-32, x64, and EBC architectures.\r
3370 Itanium processors expect one additional parameter of type VOID * that specifies\r
ac644614 3371 the new backing store pointer.\r
3372\r
3373 If EntryPoint is NULL, then ASSERT().\r
3374 If NewStack is NULL, then ASSERT().\r
3375\r
3376 @param EntryPoint A pointer to function to call with the new stack.\r
3377 @param Context1 A pointer to the context to pass into the EntryPoint\r
3378 function.\r
3379 @param Context2 A pointer to the context to pass into the EntryPoint\r
3380 function.\r
3381 @param NewStack A pointer to the new stack to use for the EntryPoint\r
3382 function.\r
af2dc6a7 3383 @param ... This variable argument list is ignored for IA-32, x64, and \r
3384 EBC architectures. For Itanium processors, this variable \r
3385 argument list is expected to contain a single parameter of \r
3386 type VOID * that specifies the new backing store pointer.\r
42eedea9 3387\r
ac644614 3388\r
3389**/\r
3390VOID\r
3391EFIAPI\r
3392SwitchStack (\r
3393 IN SWITCH_STACK_ENTRY_POINT EntryPoint,\r
3394 IN VOID *Context1, OPTIONAL\r
3395 IN VOID *Context2, OPTIONAL\r
3396 IN VOID *NewStack,\r
3397 ...\r
3398 );\r
3399\r
3400\r
3401/**\r
3402 Generates a breakpoint on the CPU.\r
3403\r
3404 Generates a breakpoint on the CPU. The breakpoint must be implemented such\r
3405 that code can resume normal execution after the breakpoint.\r
3406\r
3407**/\r
3408VOID\r
3409EFIAPI\r
3410CpuBreakpoint (\r
3411 VOID\r
3412 );\r
3413\r
3414\r
3415/**\r
3416 Executes an infinite loop.\r
3417\r
3418 Forces the CPU to execute an infinite loop. A debugger may be used to skip\r
3419 past the loop and the code that follows the loop must execute properly. This\r
3420 implies that the infinite loop must not cause the code that follow it to be\r
3421 optimized away.\r
3422\r
3423**/\r
3424VOID\r
3425EFIAPI\r
3426CpuDeadLoop (\r
3427 VOID\r
3428 );\r
2fe241a2 3429 \r
ac644614 3430#if defined (MDE_CPU_IPF)\r
3431\r
3432/**\r
3433 Flush a range of cache lines in the cache coherency domain of the calling\r
3434 CPU.\r
3435\r
cc39b88b 3436 Flushes the cache lines specified by Address and Length. If Address is not aligned \r
3437 on a cache line boundary, then entire cache line containing Address is flushed. \r
3438 If Address + Length is not aligned on a cache line boundary, then the entire cache \r
3439 line containing Address + Length - 1 is flushed. This function may choose to flush \r
3440 the entire cache if that is more efficient than flushing the specified range. If \r
3441 Length is 0, the no cache lines are flushed. Address is returned. \r
1a2f870c 3442 This function is only available on Itanium processors.\r
ac644614 3443\r
3444 If Length is greater than (MAX_ADDRESS - Address + 1), then ASSERT().\r
3445\r
3446 @param Address The base address of the instruction lines to invalidate. If\r
3447 the CPU is in a physical addressing mode, then Address is a\r
3448 physical address. If the CPU is in a virtual addressing mode,\r
3449 then Address is a virtual address.\r
3450\r
3451 @param Length The number of bytes to invalidate from the instruction cache.\r
3452\r
cc39b88b 3453 @return Address.\r
ac644614 3454\r
3455**/\r
3456VOID *\r
3457EFIAPI\r
cc39b88b 3458AsmFlushCacheRange (\r
ac644614 3459 IN VOID *Address,\r
3460 IN UINTN Length\r
3461 );\r
3462\r
3463\r
3464/**\r
af2dc6a7 3465 Executes an FC instruction.\r
3466 Executes an FC instruction on the cache line specified by Address.\r
ac644614 3467 The cache line size affected is at least 32-bytes (aligned on a 32-byte boundary).\r
1a2f870c 3468 An implementation may flush a larger region. This function is only available on Itanium processors.\r
ac644614 3469\r
ee6c452c 3470 @param Address The Address of cache line to be flushed.\r
ac644614 3471\r
3472 @return The address of FC instruction executed.\r
3473\r
3474**/\r
3475UINT64\r
3476EFIAPI\r
3477AsmFc (\r
3478 IN UINT64 Address\r
3479 );\r
3480\r
3481\r
3482/**\r
af2dc6a7 3483 Executes an FC.I instruction.\r
3484 Executes an FC.I instruction on the cache line specified by Address.\r
ac644614 3485 The cache line size affected is at least 32-bytes (aligned on a 32-byte boundary).\r
1a2f870c 3486 An implementation may flush a larger region. This function is only available on Itanium processors.\r
ac644614 3487\r
ee6c452c 3488 @param Address The Address of cache line to be flushed.\r
ac644614 3489\r
af2dc6a7 3490 @return The address of the FC.I instruction executed.\r
ac644614 3491\r
3492**/\r
3493UINT64\r
3494EFIAPI\r
3495AsmFci (\r
3496 IN UINT64 Address\r
3497 );\r
3498\r
3499\r
3500/**\r
3501 Reads the current value of a Processor Identifier Register (CPUID).\r
17f695ed 3502 \r
3503 Reads and returns the current value of Processor Identifier Register specified by Index. \r
ac644614 3504 The Index of largest implemented CPUID (One less than the number of implemented CPUID\r
3505 registers) is determined by CPUID [3] bits {7:0}.\r
3506 No parameter checking is performed on Index. If the Index value is beyond the\r
3507 implemented CPUID register range, a Reserved Register/Field fault may occur. The caller\r
3508 must either guarantee that Index is valid, or the caller must set up fault handlers to\r
1a2f870c 3509 catch the faults. This function is only available on Itanium processors.\r
ac644614 3510\r
ee6c452c 3511 @param Index The 8-bit Processor Identifier Register index to read.\r
ac644614 3512\r
3513 @return The current value of Processor Identifier Register specified by Index.\r
3514\r
3515**/\r
3516UINT64\r
3517EFIAPI\r
3518AsmReadCpuid (\r
3519 IN UINT8 Index\r
3520 );\r
3521\r
3522\r
3523/**\r
3524 Reads the current value of 64-bit Processor Status Register (PSR).\r
1a2f870c 3525 This function is only available on Itanium processors.\r
ac644614 3526\r
3527 @return The current value of PSR.\r
3528\r
3529**/\r
3530UINT64\r
3531EFIAPI\r
3532AsmReadPsr (\r
3533 VOID\r
3534 );\r
3535\r
3536\r
3537/**\r
3538 Writes the current value of 64-bit Processor Status Register (PSR).\r
22388319 3539\r
ac644614 3540 No parameter checking is performed on Value. All bits of Value corresponding to\r
22388319 3541 reserved fields of PSR must be 0 or a Reserved Register/Field fault may occur.\r
3542 The caller must either guarantee that Value is valid, or the caller must set up\r
1a2f870c 3543 fault handlers to catch the faults. This function is only available on Itanium processors.\r
ac644614 3544\r
ee6c452c 3545 @param Value The 64-bit value to write to PSR.\r
ac644614 3546\r
3547 @return The 64-bit value written to the PSR.\r
3548\r
3549**/\r
3550UINT64\r
3551EFIAPI\r
3552AsmWritePsr (\r
3553 IN UINT64 Value\r
3554 );\r
3555\r
3556\r
3557/**\r
3558 Reads the current value of 64-bit Kernel Register #0 (KR0).\r
2fe241a2 3559 \r
3560 Reads and returns the current value of KR0. \r
1a2f870c 3561 This function is only available on Itanium processors.\r
ac644614 3562\r
3563 @return The current value of KR0.\r
3564\r
3565**/\r
3566UINT64\r
3567EFIAPI\r
3568AsmReadKr0 (\r
3569 VOID\r
3570 );\r
3571\r
3572\r
3573/**\r
3574 Reads the current value of 64-bit Kernel Register #1 (KR1).\r
2fe241a2 3575\r
3576 Reads and returns the current value of KR1. \r
1a2f870c 3577 This function is only available on Itanium processors.\r
ac644614 3578\r
3579 @return The current value of KR1.\r
3580\r
3581**/\r
3582UINT64\r
3583EFIAPI\r
3584AsmReadKr1 (\r
3585 VOID\r
3586 );\r
3587\r
3588\r
3589/**\r
3590 Reads the current value of 64-bit Kernel Register #2 (KR2).\r
2fe241a2 3591\r
3592 Reads and returns the current value of KR2. \r
1a2f870c 3593 This function is only available on Itanium processors.\r
ac644614 3594\r
3595 @return The current value of KR2.\r
3596\r
3597**/\r
3598UINT64\r
3599EFIAPI\r
3600AsmReadKr2 (\r
3601 VOID\r
3602 );\r
3603\r
3604\r
3605/**\r
3606 Reads the current value of 64-bit Kernel Register #3 (KR3).\r
2fe241a2 3607\r
3608 Reads and returns the current value of KR3. \r
1a2f870c 3609 This function is only available on Itanium processors.\r
ac644614 3610\r
3611 @return The current value of KR3.\r
3612\r
3613**/\r
3614UINT64\r
3615EFIAPI\r
3616AsmReadKr3 (\r
3617 VOID\r
3618 );\r
3619\r
3620\r
3621/**\r
3622 Reads the current value of 64-bit Kernel Register #4 (KR4).\r
ac644614 3623\r
2fe241a2 3624 Reads and returns the current value of KR4. \r
1a2f870c 3625 This function is only available on Itanium processors.\r
2fe241a2 3626 \r
ac644614 3627 @return The current value of KR4.\r
3628\r
3629**/\r
3630UINT64\r
3631EFIAPI\r
3632AsmReadKr4 (\r
3633 VOID\r
3634 );\r
3635\r
3636\r
3637/**\r
3638 Reads the current value of 64-bit Kernel Register #5 (KR5).\r
2fe241a2 3639\r
3640 Reads and returns the current value of KR5. \r
1a2f870c 3641 This function is only available on Itanium processors.\r
ac644614 3642\r
3643 @return The current value of KR5.\r
3644\r
3645**/\r
3646UINT64\r
3647EFIAPI\r
3648AsmReadKr5 (\r
3649 VOID\r
3650 );\r
3651\r
3652\r
3653/**\r
3654 Reads the current value of 64-bit Kernel Register #6 (KR6).\r
2fe241a2 3655\r
3656 Reads and returns the current value of KR6. \r
1a2f870c 3657 This function is only available on Itanium processors.\r
ac644614 3658\r
3659 @return The current value of KR6.\r
3660\r
3661**/\r
3662UINT64\r
3663EFIAPI\r
3664AsmReadKr6 (\r
3665 VOID\r
3666 );\r
3667\r
3668\r
3669/**\r
3670 Reads the current value of 64-bit Kernel Register #7 (KR7).\r
2fe241a2 3671\r
3672 Reads and returns the current value of KR7. \r
1a2f870c 3673 This function is only available on Itanium processors.\r
ac644614 3674\r
3675 @return The current value of KR7.\r
3676\r
3677**/\r
3678UINT64\r
3679EFIAPI\r
3680AsmReadKr7 (\r
3681 VOID\r
3682 );\r
3683\r
3684\r
3685/**\r
3686 Write the current value of 64-bit Kernel Register #0 (KR0).\r
2fe241a2 3687 \r
3688 Writes the current value of KR0. The 64-bit value written to \r
1a2f870c 3689 the KR0 is returned. This function is only available on Itanium processors.\r
ac644614 3690\r
ee6c452c 3691 @param Value The 64-bit value to write to KR0.\r
ac644614 3692\r
3693 @return The 64-bit value written to the KR0.\r
3694\r
3695**/\r
3696UINT64\r
3697EFIAPI\r
3698AsmWriteKr0 (\r
3699 IN UINT64 Value\r
3700 );\r
3701\r
3702\r
3703/**\r
3704 Write the current value of 64-bit Kernel Register #1 (KR1).\r
2fe241a2 3705\r
3706 Writes the current value of KR1. The 64-bit value written to \r
1a2f870c 3707 the KR1 is returned. This function is only available on Itanium processors.\r
ac644614 3708\r
ee6c452c 3709 @param Value The 64-bit value to write to KR1.\r
ac644614 3710\r
3711 @return The 64-bit value written to the KR1.\r
3712\r
3713**/\r
3714UINT64\r
3715EFIAPI\r
3716AsmWriteKr1 (\r
3717 IN UINT64 Value\r
3718 );\r
3719\r
3720\r
3721/**\r
3722 Write the current value of 64-bit Kernel Register #2 (KR2).\r
2fe241a2 3723\r
3724 Writes the current value of KR2. The 64-bit value written to \r
1a2f870c 3725 the KR2 is returned. This function is only available on Itanium processors.\r
ac644614 3726\r
ee6c452c 3727 @param Value The 64-bit value to write to KR2.\r
ac644614 3728\r
3729 @return The 64-bit value written to the KR2.\r
3730\r
3731**/\r
3732UINT64\r
3733EFIAPI\r
3734AsmWriteKr2 (\r
3735 IN UINT64 Value\r
3736 );\r
3737\r
3738\r
3739/**\r
3740 Write the current value of 64-bit Kernel Register #3 (KR3).\r
2fe241a2 3741\r
3742 Writes the current value of KR3. The 64-bit value written to \r
1a2f870c 3743 the KR3 is returned. This function is only available on Itanium processors.\r
ac644614 3744\r
ee6c452c 3745 @param Value The 64-bit value to write to KR3.\r
ac644614 3746\r
3747 @return The 64-bit value written to the KR3.\r
3748\r
3749**/\r
3750UINT64\r
3751EFIAPI\r
3752AsmWriteKr3 (\r
3753 IN UINT64 Value\r
3754 );\r
3755\r
3756\r
3757/**\r
3758 Write the current value of 64-bit Kernel Register #4 (KR4).\r
2fe241a2 3759\r
3760 Writes the current value of KR4. The 64-bit value written to \r
1a2f870c 3761 the KR4 is returned. This function is only available on Itanium processors.\r
ac644614 3762\r
ee6c452c 3763 @param Value The 64-bit value to write to KR4.\r
ac644614 3764\r
3765 @return The 64-bit value written to the KR4.\r
3766\r
3767**/\r
3768UINT64\r
3769EFIAPI\r
3770AsmWriteKr4 (\r
3771 IN UINT64 Value\r
3772 );\r
3773\r
3774\r
3775/**\r
3776 Write the current value of 64-bit Kernel Register #5 (KR5).\r
2fe241a2 3777\r
3778 Writes the current value of KR5. The 64-bit value written to \r
1a2f870c 3779 the KR5 is returned. This function is only available on Itanium processors.\r
ac644614 3780\r
ee6c452c 3781 @param Value The 64-bit value to write to KR5.\r
ac644614 3782\r
3783 @return The 64-bit value written to the KR5.\r
3784\r
3785**/\r
3786UINT64\r
3787EFIAPI\r
3788AsmWriteKr5 (\r
3789 IN UINT64 Value\r
3790 );\r
3791\r
3792\r
3793/**\r
3794 Write the current value of 64-bit Kernel Register #6 (KR6).\r
2fe241a2 3795\r
3796 Writes the current value of KR6. The 64-bit value written to \r
1a2f870c 3797 the KR6 is returned. This function is only available on Itanium processors.\r
ac644614 3798\r
ee6c452c 3799 @param Value The 64-bit value to write to KR6.\r
ac644614 3800\r
3801 @return The 64-bit value written to the KR6.\r
3802\r
3803**/\r
3804UINT64\r
3805EFIAPI\r
3806AsmWriteKr6 (\r
3807 IN UINT64 Value\r
3808 );\r
3809\r
3810\r
3811/**\r
3812 Write the current value of 64-bit Kernel Register #7 (KR7).\r
2fe241a2 3813\r
3814 Writes the current value of KR7. The 64-bit value written to \r
1a2f870c 3815 the KR7 is returned. This function is only available on Itanium processors.\r
ac644614 3816\r
ee6c452c 3817 @param Value The 64-bit value to write to KR7.\r
ac644614 3818\r
3819 @return The 64-bit value written to the KR7.\r
3820\r
3821**/\r
3822UINT64\r
3823EFIAPI\r
3824AsmWriteKr7 (\r
3825 IN UINT64 Value\r
3826 );\r
3827\r
3828\r
3829/**\r
3830 Reads the current value of Interval Timer Counter Register (ITC).\r
2fe241a2 3831 \r
3832 Reads and returns the current value of ITC.\r
1a2f870c 3833 This function is only available on Itanium processors.\r
ac644614 3834\r
3835 @return The current value of ITC.\r
3836\r
3837**/\r
3838UINT64\r
3839EFIAPI\r
3840AsmReadItc (\r
3841 VOID\r
3842 );\r
3843\r
3844\r
3845/**\r
3846 Reads the current value of Interval Timer Vector Register (ITV).\r
2fe241a2 3847 \r
3848 Reads and returns the current value of ITV. \r
1a2f870c 3849 This function is only available on Itanium processors.\r
ac644614 3850\r
3851 @return The current value of ITV.\r
3852\r
3853**/\r
3854UINT64\r
3855EFIAPI\r
3856AsmReadItv (\r
3857 VOID\r
3858 );\r
3859\r
3860\r
3861/**\r
3862 Reads the current value of Interval Timer Match Register (ITM).\r
2fe241a2 3863 \r
3864 Reads and returns the current value of ITM.\r
1a2f870c 3865 This function is only available on Itanium processors.\r
ac644614 3866\r
3867 @return The current value of ITM.\r
3868**/\r
3869UINT64\r
3870EFIAPI\r
3871AsmReadItm (\r
3872 VOID\r
3873 );\r
3874\r
3875\r
3876/**\r
3877 Writes the current value of 64-bit Interval Timer Counter Register (ITC).\r
2fe241a2 3878 \r
3879 Writes the current value of ITC. The 64-bit value written to the ITC is returned. \r
1a2f870c 3880 This function is only available on Itanium processors.\r
ac644614 3881\r
ee6c452c 3882 @param Value The 64-bit value to write to ITC.\r
ac644614 3883\r
3884 @return The 64-bit value written to the ITC.\r
3885\r
3886**/\r
3887UINT64\r
3888EFIAPI\r
3889AsmWriteItc (\r
3890 IN UINT64 Value\r
3891 );\r
3892\r
3893\r
3894/**\r
3895 Writes the current value of 64-bit Interval Timer Match Register (ITM).\r
2fe241a2 3896 \r
3897 Writes the current value of ITM. The 64-bit value written to the ITM is returned. \r
1a2f870c 3898 This function is only available on Itanium processors.\r
ac644614 3899\r
ee6c452c 3900 @param Value The 64-bit value to write to ITM.\r
ac644614 3901\r
3902 @return The 64-bit value written to the ITM.\r
3903\r
3904**/\r
3905UINT64\r
3906EFIAPI\r
3907AsmWriteItm (\r
3908 IN UINT64 Value\r
3909 );\r
3910\r
3911\r
3912/**\r
3913 Writes the current value of 64-bit Interval Timer Vector Register (ITV).\r
2fe241a2 3914 \r
3915 Writes the current value of ITV. The 64-bit value written to the ITV is returned. \r
ac644614 3916 No parameter checking is performed on Value. All bits of Value corresponding to\r
3917 reserved fields of ITV must be 0 or a Reserved Register/Field fault may occur.\r
3918 The caller must either guarantee that Value is valid, or the caller must set up\r
3919 fault handlers to catch the faults.\r
1a2f870c 3920 This function is only available on Itanium processors.\r
ac644614 3921\r
ee6c452c 3922 @param Value The 64-bit value to write to ITV.\r
ac644614 3923\r
3924 @return The 64-bit value written to the ITV.\r
3925\r
3926**/\r
3927UINT64\r
3928EFIAPI\r
3929AsmWriteItv (\r
3930 IN UINT64 Value\r
3931 );\r
3932\r
3933\r
3934/**\r
3935 Reads the current value of Default Control Register (DCR).\r
2fe241a2 3936 \r
1a2f870c 3937 Reads and returns the current value of DCR. This function is only available on Itanium processors.\r
ac644614 3938\r
3939 @return The current value of DCR.\r
3940\r
3941**/\r
3942UINT64\r
3943EFIAPI\r
3944AsmReadDcr (\r
3945 VOID\r
3946 );\r
3947\r
3948\r
3949/**\r
3950 Reads the current value of Interruption Vector Address Register (IVA).\r
2fe241a2 3951 \r
1a2f870c 3952 Reads and returns the current value of IVA. This function is only available on Itanium processors.\r
ac644614 3953\r
3954 @return The current value of IVA.\r
3955**/\r
3956UINT64\r
3957EFIAPI\r
3958AsmReadIva (\r
3959 VOID\r
3960 );\r
3961\r
3962\r
3963/**\r
3964 Reads the current value of Page Table Address Register (PTA).\r
2fe241a2 3965 \r
1a2f870c 3966 Reads and returns the current value of PTA. This function is only available on Itanium processors.\r
ac644614 3967\r
3968 @return The current value of PTA.\r
3969\r
3970**/\r
3971UINT64\r
3972EFIAPI\r
3973AsmReadPta (\r
3974 VOID\r
3975 );\r
3976\r
3977\r
3978/**\r
3979 Writes the current value of 64-bit Default Control Register (DCR).\r
2fe241a2 3980 \r
3981 Writes the current value of DCR. The 64-bit value written to the DCR is returned. \r
ac644614 3982 No parameter checking is performed on Value. All bits of Value corresponding to\r
3983 reserved fields of DCR must be 0 or a Reserved Register/Field fault may occur.\r
3984 The caller must either guarantee that Value is valid, or the caller must set up\r
3985 fault handlers to catch the faults.\r
1a2f870c 3986 This function is only available on Itanium processors.\r
ac644614 3987\r
ee6c452c 3988 @param Value The 64-bit value to write to DCR.\r
ac644614 3989\r
3990 @return The 64-bit value written to the DCR.\r
3991\r
3992**/\r
3993UINT64\r
3994EFIAPI\r
3995AsmWriteDcr (\r
3996 IN UINT64 Value\r
3997 );\r
3998\r
3999\r
4000/**\r
4001 Writes the current value of 64-bit Interruption Vector Address Register (IVA).\r
2fe241a2 4002 \r
4003 Writes the current value of IVA. The 64-bit value written to the IVA is returned. \r
ac644614 4004 The size of vector table is 32 K bytes and is 32 K bytes aligned\r
4005 the low 15 bits of Value is ignored when written.\r
1a2f870c 4006 This function is only available on Itanium processors.\r
ac644614 4007\r
ee6c452c 4008 @param Value The 64-bit value to write to IVA.\r
ac644614 4009\r
4010 @return The 64-bit value written to the IVA.\r
4011\r
4012**/\r
4013UINT64\r
4014EFIAPI\r
4015AsmWriteIva (\r
4016 IN UINT64 Value\r
4017 );\r
4018\r
4019\r
4020/**\r
4021 Writes the current value of 64-bit Page Table Address Register (PTA).\r
2fe241a2 4022 \r
4023 Writes the current value of PTA. The 64-bit value written to the PTA is returned. \r
ac644614 4024 No parameter checking is performed on Value. All bits of Value corresponding to\r
4025 reserved fields of DCR must be 0 or a Reserved Register/Field fault may occur.\r
4026 The caller must either guarantee that Value is valid, or the caller must set up\r
4027 fault handlers to catch the faults.\r
1a2f870c 4028 This function is only available on Itanium processors.\r
ac644614 4029\r
ee6c452c 4030 @param Value The 64-bit value to write to PTA.\r
ac644614 4031\r
4032 @return The 64-bit value written to the PTA.\r
4033**/\r
4034UINT64\r
4035EFIAPI\r
4036AsmWritePta (\r
4037 IN UINT64 Value\r
4038 );\r
4039\r
4040\r
4041/**\r
4042 Reads the current value of Local Interrupt ID Register (LID).\r
2fe241a2 4043 \r
1a2f870c 4044 Reads and returns the current value of LID. This function is only available on Itanium processors.\r
ac644614 4045\r
4046 @return The current value of LID.\r
4047\r
4048**/\r
4049UINT64\r
4050EFIAPI\r
4051AsmReadLid (\r
4052 VOID\r
4053 );\r
4054\r
4055\r
4056/**\r
4057 Reads the current value of External Interrupt Vector Register (IVR).\r
2fe241a2 4058 \r
1a2f870c 4059 Reads and returns the current value of IVR. This function is only available on Itanium processors. \r
ac644614 4060\r
4061 @return The current value of IVR.\r
4062\r
4063**/\r
4064UINT64\r
4065EFIAPI\r
4066AsmReadIvr (\r
4067 VOID\r
4068 );\r
4069\r
4070\r
4071/**\r
4072 Reads the current value of Task Priority Register (TPR).\r
2fe241a2 4073 \r
1a2f870c 4074 Reads and returns the current value of TPR. This function is only available on Itanium processors. \r
ac644614 4075\r
4076 @return The current value of TPR.\r
4077\r
4078**/\r
4079UINT64\r
4080EFIAPI\r
4081AsmReadTpr (\r
4082 VOID\r
4083 );\r
4084\r
4085\r
4086/**\r
4087 Reads the current value of External Interrupt Request Register #0 (IRR0).\r
2fe241a2 4088 \r
1a2f870c 4089 Reads and returns the current value of IRR0. This function is only available on Itanium processors. \r
ac644614 4090\r
4091 @return The current value of IRR0.\r
4092\r
4093**/\r
4094UINT64\r
4095EFIAPI\r
4096AsmReadIrr0 (\r
4097 VOID\r
4098 );\r
4099\r
4100\r
4101/**\r
4102 Reads the current value of External Interrupt Request Register #1 (IRR1).\r
2fe241a2 4103 \r
1a2f870c 4104 Reads and returns the current value of IRR1. This function is only available on Itanium processors. \r
ac644614 4105\r
4106 @return The current value of IRR1.\r
4107\r
4108**/\r
4109UINT64\r
4110EFIAPI\r
4111AsmReadIrr1 (\r
4112 VOID\r
4113 );\r
4114\r
4115\r
4116/**\r
4117 Reads the current value of External Interrupt Request Register #2 (IRR2).\r
2fe241a2 4118 \r
1a2f870c 4119 Reads and returns the current value of IRR2. This function is only available on Itanium processors.\r
ac644614 4120\r
4121 @return The current value of IRR2.\r
4122\r
4123**/\r
4124UINT64\r
4125EFIAPI\r
4126AsmReadIrr2 (\r
4127 VOID\r
4128 );\r
4129\r
4130\r
4131/**\r
4132 Reads the current value of External Interrupt Request Register #3 (IRR3).\r
2fe241a2 4133 \r
1a2f870c 4134 Reads and returns the current value of IRR3. This function is only available on Itanium processors. \r
ac644614 4135\r
4136 @return The current value of IRR3.\r
4137\r
4138**/\r
4139UINT64\r
4140EFIAPI\r
4141AsmReadIrr3 (\r
4142 VOID\r
4143 );\r
4144\r
4145\r
4146/**\r
4147 Reads the current value of Performance Monitor Vector Register (PMV).\r
2fe241a2 4148 \r
1a2f870c 4149 Reads and returns the current value of PMV. This function is only available on Itanium processors. \r
ac644614 4150\r
4151 @return The current value of PMV.\r
4152\r
4153**/\r
4154UINT64\r
4155EFIAPI\r
4156AsmReadPmv (\r
4157 VOID\r
4158 );\r
4159\r
4160\r
4161/**\r
4162 Reads the current value of Corrected Machine Check Vector Register (CMCV).\r
2fe241a2 4163 \r
1a2f870c 4164 Reads and returns the current value of CMCV. This function is only available on Itanium processors.\r
ac644614 4165\r
4166 @return The current value of CMCV.\r
4167\r
4168**/\r
4169UINT64\r
4170EFIAPI\r
4171AsmReadCmcv (\r
4172 VOID\r
4173 );\r
4174\r
4175\r
4176/**\r
4177 Reads the current value of Local Redirection Register #0 (LRR0).\r
2fe241a2 4178 \r
1a2f870c 4179 Reads and returns the current value of LRR0. This function is only available on Itanium processors. \r
ac644614 4180\r
4181 @return The current value of LRR0.\r
4182\r
4183**/\r
4184UINT64\r
4185EFIAPI\r
4186AsmReadLrr0 (\r
4187 VOID\r
4188 );\r
4189\r
4190\r
4191/**\r
4192 Reads the current value of Local Redirection Register #1 (LRR1).\r
2fe241a2 4193 \r
1a2f870c 4194 Reads and returns the current value of LRR1. This function is only available on Itanium processors.\r
ac644614 4195\r
4196 @return The current value of LRR1.\r
4197\r
4198**/\r
4199UINT64\r
4200EFIAPI\r
4201AsmReadLrr1 (\r
4202 VOID\r
4203 );\r
4204\r
4205\r
4206/**\r
4207 Writes the current value of 64-bit Page Local Interrupt ID Register (LID).\r
2fe241a2 4208 \r
4209 Writes the current value of LID. The 64-bit value written to the LID is returned. \r
ac644614 4210 No parameter checking is performed on Value. All bits of Value corresponding to\r
4211 reserved fields of LID must be 0 or a Reserved Register/Field fault may occur.\r
4212 The caller must either guarantee that Value is valid, or the caller must set up\r
4213 fault handlers to catch the faults.\r
1a2f870c 4214 This function is only available on Itanium processors.\r
ac644614 4215\r
ee6c452c 4216 @param Value The 64-bit value to write to LID.\r
ac644614 4217\r
4218 @return The 64-bit value written to the LID.\r
4219\r
4220**/\r
4221UINT64\r
4222EFIAPI\r
4223AsmWriteLid (\r
4224 IN UINT64 Value\r
4225 );\r
4226\r
4227\r
4228/**\r
4229 Writes the current value of 64-bit Task Priority Register (TPR).\r
2fe241a2 4230 \r
4231 Writes the current value of TPR. The 64-bit value written to the TPR is returned. \r
ac644614 4232 No parameter checking is performed on Value. All bits of Value corresponding to\r
4233 reserved fields of TPR must be 0 or a Reserved Register/Field fault may occur.\r
4234 The caller must either guarantee that Value is valid, or the caller must set up\r
4235 fault handlers to catch the faults.\r
1a2f870c 4236 This function is only available on Itanium processors.\r
ac644614 4237\r
ee6c452c 4238 @param Value The 64-bit value to write to TPR.\r
ac644614 4239\r
4240 @return The 64-bit value written to the TPR.\r
4241\r
4242**/\r
4243UINT64\r
4244EFIAPI\r
4245AsmWriteTpr (\r
4246 IN UINT64 Value\r
4247 );\r
4248\r
4249\r
4250/**\r
4251 Performs a write operation on End OF External Interrupt Register (EOI).\r
2fe241a2 4252 \r
1a2f870c 4253 Writes a value of 0 to the EOI Register. This function is only available on Itanium processors.\r
ac644614 4254\r
4255**/\r
4256VOID\r
4257EFIAPI\r
4258AsmWriteEoi (\r
4259 VOID\r
4260 );\r
4261\r
4262\r
4263/**\r
4264 Writes the current value of 64-bit Performance Monitor Vector Register (PMV).\r
2fe241a2 4265 \r
4266 Writes the current value of PMV. The 64-bit value written to the PMV is returned. \r
ac644614 4267 No parameter checking is performed on Value. All bits of Value corresponding\r
4268 to reserved fields of PMV must be 0 or a Reserved Register/Field fault may occur.\r
4269 The caller must either guarantee that Value is valid, or the caller must set up\r
4270 fault handlers to catch the faults.\r
1a2f870c 4271 This function is only available on Itanium processors.\r
ac644614 4272\r
ee6c452c 4273 @param Value The 64-bit value to write to PMV.\r
ac644614 4274\r
4275 @return The 64-bit value written to the PMV.\r
4276\r
4277**/\r
4278UINT64\r
4279EFIAPI\r
4280AsmWritePmv (\r
4281 IN UINT64 Value\r
4282 );\r
4283\r
4284\r
4285/**\r
4286 Writes the current value of 64-bit Corrected Machine Check Vector Register (CMCV).\r
2fe241a2 4287 \r
4288 Writes the current value of CMCV. The 64-bit value written to the CMCV is returned. \r
ac644614 4289 No parameter checking is performed on Value. All bits of Value corresponding\r
4290 to reserved fields of CMCV must be 0 or a Reserved Register/Field fault may occur.\r
4291 The caller must either guarantee that Value is valid, or the caller must set up\r
4292 fault handlers to catch the faults.\r
1a2f870c 4293 This function is only available on Itanium processors.\r
ac644614 4294\r
ee6c452c 4295 @param Value The 64-bit value to write to CMCV.\r
ac644614 4296\r
4297 @return The 64-bit value written to the CMCV.\r
4298\r
4299**/\r
4300UINT64\r
4301EFIAPI\r
4302AsmWriteCmcv (\r
4303 IN UINT64 Value\r
4304 );\r
4305\r
4306\r
4307/**\r
4308 Writes the current value of 64-bit Local Redirection Register #0 (LRR0).\r
2fe241a2 4309 \r
4310 Writes the current value of LRR0. The 64-bit value written to the LRR0 is returned. \r
ac644614 4311 No parameter checking is performed on Value. All bits of Value corresponding\r
4312 to reserved fields of LRR0 must be 0 or a Reserved Register/Field fault may occur.\r
4313 The caller must either guarantee that Value is valid, or the caller must set up\r
4314 fault handlers to catch the faults.\r
1a2f870c 4315 This function is only available on Itanium processors.\r
ac644614 4316\r
ee6c452c 4317 @param Value The 64-bit value to write to LRR0.\r
ac644614 4318\r
4319 @return The 64-bit value written to the LRR0.\r
4320\r
4321**/\r
4322UINT64\r
4323EFIAPI\r
4324AsmWriteLrr0 (\r
4325 IN UINT64 Value\r
4326 );\r
4327\r
4328\r
4329/**\r
4330 Writes the current value of 64-bit Local Redirection Register #1 (LRR1).\r
2fe241a2 4331 \r
4332 Writes the current value of LRR1. The 64-bit value written to the LRR1 is returned. \r
ac644614 4333 No parameter checking is performed on Value. All bits of Value corresponding\r
4334 to reserved fields of LRR1 must be 0 or a Reserved Register/Field fault may occur.\r
4335 The caller must either guarantee that Value is valid, or the caller must\r
4336 set up fault handlers to catch the faults.\r
1a2f870c 4337 This function is only available on Itanium processors.\r
ac644614 4338\r
ee6c452c 4339 @param Value The 64-bit value to write to LRR1.\r
ac644614 4340\r
4341 @return The 64-bit value written to the LRR1.\r
4342\r
4343**/\r
4344UINT64\r
4345EFIAPI\r
4346AsmWriteLrr1 (\r
4347 IN UINT64 Value\r
4348 );\r
4349\r
4350\r
4351/**\r
4352 Reads the current value of Instruction Breakpoint Register (IBR).\r
4353 \r
4354 The Instruction Breakpoint Registers are used in pairs. The even numbered\r
4355 registers contain breakpoint addresses, and the odd numbered registers contain\r
af2dc6a7 4356 breakpoint mask conditions. At least four instruction registers pairs are implemented\r
ac644614 4357 on all processor models. Implemented registers are contiguous starting with\r
4358 register 0. No parameter checking is performed on Index, and if the Index value\r
4359 is beyond the implemented IBR register range, a Reserved Register/Field fault may\r
4360 occur. The caller must either guarantee that Index is valid, or the caller must\r
4361 set up fault handlers to catch the faults.\r
1a2f870c 4362 This function is only available on Itanium processors.\r
ac644614 4363\r
ee6c452c 4364 @param Index The 8-bit Instruction Breakpoint Register index to read.\r
ac644614 4365\r
4366 @return The current value of Instruction Breakpoint Register specified by Index.\r
4367\r
4368**/\r
4369UINT64\r
4370EFIAPI\r
4371AsmReadIbr (\r
4372 IN UINT8 Index\r
4373 );\r
4374\r
4375\r
4376/**\r
4377 Reads the current value of Data Breakpoint Register (DBR).\r
4378\r
4379 The Data Breakpoint Registers are used in pairs. The even numbered registers\r
4380 contain breakpoint addresses, and odd numbered registers contain breakpoint\r
af2dc6a7 4381 mask conditions. At least four data registers pairs are implemented on all processor\r
ac644614 4382 models. Implemented registers are contiguous starting with register 0.\r
4383 No parameter checking is performed on Index. If the Index value is beyond\r
4384 the implemented DBR register range, a Reserved Register/Field fault may occur.\r
4385 The caller must either guarantee that Index is valid, or the caller must set up\r
4386 fault handlers to catch the faults.\r
1a2f870c 4387 This function is only available on Itanium processors.\r
ac644614 4388\r
ee6c452c 4389 @param Index The 8-bit Data Breakpoint Register index to read.\r
ac644614 4390\r
4391 @return The current value of Data Breakpoint Register specified by Index.\r
4392\r
4393**/\r
4394UINT64\r
4395EFIAPI\r
4396AsmReadDbr (\r
4397 IN UINT8 Index\r
4398 );\r
4399\r
4400\r
4401/**\r
4402 Reads the current value of Performance Monitor Configuration Register (PMC).\r
4403\r
af2dc6a7 4404 All processor implementations provide at least four performance counters\r
4405 (PMC/PMD [4]...PMC/PMD [7] pairs), and four performance monitor counter overflow\r
ac644614 4406 status registers (PMC [0]... PMC [3]). Processor implementations may provide\r
4407 additional implementation-dependent PMC and PMD to increase the number of\r
4408 'generic' performance counters (PMC/PMD pairs). The remainder of PMC and PMD\r
4409 register set is implementation dependent. No parameter checking is performed\r
4410 on Index. If the Index value is beyond the implemented PMC register range,\r
4411 zero value will be returned.\r
1a2f870c 4412 This function is only available on Itanium processors.\r
ac644614 4413\r
ee6c452c 4414 @param Index The 8-bit Performance Monitor Configuration Register index to read.\r
ac644614 4415\r
2fe241a2 4416 @return The current value of Performance Monitor Configuration Register\r
4417 specified by Index.\r
ac644614 4418\r
4419**/\r
4420UINT64\r
4421EFIAPI\r
4422AsmReadPmc (\r
4423 IN UINT8 Index\r
4424 );\r
4425\r
4426\r
4427/**\r
4428 Reads the current value of Performance Monitor Data Register (PMD).\r
4429\r
4430 All processor implementations provide at least 4 performance counters\r
4431 (PMC/PMD [4]...PMC/PMD [7] pairs), and 4 performance monitor counter\r
4432 overflow status registers (PMC [0]... PMC [3]). Processor implementations may\r
4433 provide additional implementation-dependent PMC and PMD to increase the number\r
4434 of 'generic' performance counters (PMC/PMD pairs). The remainder of PMC and PMD\r
4435 register set is implementation dependent. No parameter checking is performed\r
4436 on Index. If the Index value is beyond the implemented PMD register range,\r
4437 zero value will be returned.\r
1a2f870c 4438 This function is only available on Itanium processors.\r
ac644614 4439\r
ee6c452c 4440 @param Index The 8-bit Performance Monitor Data Register index to read.\r
ac644614 4441\r
4442 @return The current value of Performance Monitor Data Register specified by Index.\r
4443\r
4444**/\r
4445UINT64\r
4446EFIAPI\r
4447AsmReadPmd (\r
4448 IN UINT8 Index\r
4449 );\r
4450\r
4451\r
4452/**\r
4453 Writes the current value of 64-bit Instruction Breakpoint Register (IBR).\r
4454\r
4455 Writes current value of Instruction Breakpoint Register specified by Index.\r
4456 The Instruction Breakpoint Registers are used in pairs. The even numbered\r
4457 registers contain breakpoint addresses, and odd numbered registers contain\r
af2dc6a7 4458 breakpoint mask conditions. At least four instruction registers pairs are implemented\r
ac644614 4459 on all processor models. Implemented registers are contiguous starting with\r
4460 register 0. No parameter checking is performed on Index. If the Index value\r
4461 is beyond the implemented IBR register range, a Reserved Register/Field fault may\r
4462 occur. The caller must either guarantee that Index is valid, or the caller must\r
4463 set up fault handlers to catch the faults.\r
1a2f870c 4464 This function is only available on Itanium processors.\r
ac644614 4465\r
ee6c452c 4466 @param Index The 8-bit Instruction Breakpoint Register index to write.\r
4467 @param Value The 64-bit value to write to IBR.\r
ac644614 4468\r
4469 @return The 64-bit value written to the IBR.\r
4470\r
4471**/\r
4472UINT64\r
4473EFIAPI\r
4474AsmWriteIbr (\r
4475 IN UINT8 Index,\r
4476 IN UINT64 Value\r
4477 );\r
4478\r
4479\r
4480/**\r
4481 Writes the current value of 64-bit Data Breakpoint Register (DBR).\r
4482\r
4483 Writes current value of Data Breakpoint Register specified by Index.\r
4484 The Data Breakpoint Registers are used in pairs. The even numbered registers\r
4485 contain breakpoint addresses, and odd numbered registers contain breakpoint\r
af2dc6a7 4486 mask conditions. At least four data registers pairs are implemented on all processor\r
ac644614 4487 models. Implemented registers are contiguous starting with register 0. No parameter\r
4488 checking is performed on Index. If the Index value is beyond the implemented\r
4489 DBR register range, a Reserved Register/Field fault may occur. The caller must\r
4490 either guarantee that Index is valid, or the caller must set up fault handlers to\r
4491 catch the faults.\r
1a2f870c 4492 This function is only available on Itanium processors.\r
ac644614 4493\r
ee6c452c 4494 @param Index The 8-bit Data Breakpoint Register index to write.\r
4495 @param Value The 64-bit value to write to DBR.\r
ac644614 4496\r
4497 @return The 64-bit value written to the DBR.\r
4498\r
4499**/\r
4500UINT64\r
4501EFIAPI\r
4502AsmWriteDbr (\r
4503 IN UINT8 Index,\r
4504 IN UINT64 Value\r
4505 );\r
4506\r
4507\r
4508/**\r
4509 Writes the current value of 64-bit Performance Monitor Configuration Register (PMC).\r
4510\r
4511 Writes current value of Performance Monitor Configuration Register specified by Index.\r
af2dc6a7 4512 All processor implementations provide at least four performance counters\r
4513 (PMC/PMD [4]...PMC/PMD [7] pairs), and four performance monitor counter overflow status\r
ac644614 4514 registers (PMC [0]... PMC [3]). Processor implementations may provide additional\r
4515 implementation-dependent PMC and PMD to increase the number of 'generic' performance\r
4516 counters (PMC/PMD pairs). The remainder of PMC and PMD register set is implementation\r
4517 dependent. No parameter checking is performed on Index. If the Index value is\r
4518 beyond the implemented PMC register range, the write is ignored.\r
1a2f870c 4519 This function is only available on Itanium processors.\r
ac644614 4520\r
ee6c452c 4521 @param Index The 8-bit Performance Monitor Configuration Register index to write.\r
4522 @param Value The 64-bit value to write to PMC.\r
ac644614 4523\r
4524 @return The 64-bit value written to the PMC.\r
4525\r
4526**/\r
4527UINT64\r
4528EFIAPI\r
4529AsmWritePmc (\r
4530 IN UINT8 Index,\r
4531 IN UINT64 Value\r
4532 );\r
4533\r
4534\r
4535/**\r
4536 Writes the current value of 64-bit Performance Monitor Data Register (PMD).\r
4537\r
4538 Writes current value of Performance Monitor Data Register specified by Index.\r
af2dc6a7 4539 All processor implementations provide at least four performance counters\r
4540 (PMC/PMD [4]...PMC/PMD [7] pairs), and four performance monitor counter overflow\r
ac644614 4541 status registers (PMC [0]... PMC [3]). Processor implementations may provide\r
4542 additional implementation-dependent PMC and PMD to increase the number of 'generic'\r
4543 performance counters (PMC/PMD pairs). The remainder of PMC and PMD register set\r
4544 is implementation dependent. No parameter checking is performed on Index. If the\r
4545 Index value is beyond the implemented PMD register range, the write is ignored.\r
1a2f870c 4546 This function is only available on Itanium processors.\r
ac644614 4547\r
ee6c452c 4548 @param Index The 8-bit Performance Monitor Data Register index to write.\r
4549 @param Value The 64-bit value to write to PMD.\r
ac644614 4550\r
4551 @return The 64-bit value written to the PMD.\r
4552\r
4553**/\r
4554UINT64\r
4555EFIAPI\r
4556AsmWritePmd (\r
4557 IN UINT8 Index,\r
4558 IN UINT64 Value\r
4559 );\r
4560\r
4561\r
4562/**\r
4563 Reads the current value of 64-bit Global Pointer (GP).\r
4564\r
4565 Reads and returns the current value of GP.\r
1a2f870c 4566 This function is only available on Itanium processors.\r
ac644614 4567\r
4568 @return The current value of GP.\r
4569\r
4570**/\r
4571UINT64\r
4572EFIAPI\r
4573AsmReadGp (\r
4574 VOID\r
4575 );\r
4576\r
4577\r
4578/**\r
4579 Write the current value of 64-bit Global Pointer (GP).\r
4580\r
4581 Writes the current value of GP. The 64-bit value written to the GP is returned.\r
4582 No parameter checking is performed on Value.\r
1a2f870c 4583 This function is only available on Itanium processors.\r
ac644614 4584\r
4585 @param Value The 64-bit value to write to GP.\r
4586\r
4587 @return The 64-bit value written to the GP.\r
4588\r
4589**/\r
4590UINT64\r
4591EFIAPI\r
4592AsmWriteGp (\r
4593 IN UINT64 Value\r
4594 );\r
4595\r
4596\r
4597/**\r
4598 Reads the current value of 64-bit Stack Pointer (SP).\r
4599\r
4600 Reads and returns the current value of SP.\r
1a2f870c 4601 This function is only available on Itanium processors.\r
ac644614 4602\r
4603 @return The current value of SP.\r
4604\r
4605**/\r
4606UINT64\r
4607EFIAPI\r
4608AsmReadSp (\r
4609 VOID\r
4610 );\r
4611\r
4612\r
aad6137d 4613///\r
af2dc6a7 4614/// Valid Index value for AsmReadControlRegister().\r
aad6137d 4615///\r
4616#define IPF_CONTROL_REGISTER_DCR 0\r
4617#define IPF_CONTROL_REGISTER_ITM 1\r
4618#define IPF_CONTROL_REGISTER_IVA 2\r
4619#define IPF_CONTROL_REGISTER_PTA 8\r
4620#define IPF_CONTROL_REGISTER_IPSR 16\r
4621#define IPF_CONTROL_REGISTER_ISR 17\r
4622#define IPF_CONTROL_REGISTER_IIP 19\r
4623#define IPF_CONTROL_REGISTER_IFA 20\r
4624#define IPF_CONTROL_REGISTER_ITIR 21\r
4625#define IPF_CONTROL_REGISTER_IIPA 22\r
4626#define IPF_CONTROL_REGISTER_IFS 23\r
4627#define IPF_CONTROL_REGISTER_IIM 24\r
4628#define IPF_CONTROL_REGISTER_IHA 25\r
4629#define IPF_CONTROL_REGISTER_LID 64\r
4630#define IPF_CONTROL_REGISTER_IVR 65\r
4631#define IPF_CONTROL_REGISTER_TPR 66\r
4632#define IPF_CONTROL_REGISTER_EOI 67\r
4633#define IPF_CONTROL_REGISTER_IRR0 68\r
4634#define IPF_CONTROL_REGISTER_IRR1 69\r
4635#define IPF_CONTROL_REGISTER_IRR2 70\r
4636#define IPF_CONTROL_REGISTER_IRR3 71\r
4637#define IPF_CONTROL_REGISTER_ITV 72\r
4638#define IPF_CONTROL_REGISTER_PMV 73\r
4639#define IPF_CONTROL_REGISTER_CMCV 74\r
4640#define IPF_CONTROL_REGISTER_LRR0 80\r
4641#define IPF_CONTROL_REGISTER_LRR1 81\r
4642\r
4643/**\r
4644 Reads a 64-bit control register.\r
4645\r
af2dc6a7 4646 Reads and returns the control register specified by Index. The valid Index valued \r
4647 are defined above in "Related Definitions".\r
4648 If Index is invalid then 0xFFFFFFFFFFFFFFFF is returned. This function is only \r
4649 available on Itanium processors.\r
aad6137d 4650\r
4651 @param Index The index of the control register to read.\r
4652\r
4653 @return The control register specified by Index.\r
4654\r
4655**/\r
4656UINT64\r
4657EFIAPI\r
4658AsmReadControlRegister (\r
4659 IN UINT64 Index\r
4660 );\r
4661\r
4662\r
4663///\r
af2dc6a7 4664/// Valid Index value for AsmReadApplicationRegister().\r
aad6137d 4665///\r
4666#define IPF_APPLICATION_REGISTER_K0 0\r
4667#define IPF_APPLICATION_REGISTER_K1 1\r
4668#define IPF_APPLICATION_REGISTER_K2 2\r
4669#define IPF_APPLICATION_REGISTER_K3 3\r
4670#define IPF_APPLICATION_REGISTER_K4 4\r
4671#define IPF_APPLICATION_REGISTER_K5 5\r
4672#define IPF_APPLICATION_REGISTER_K6 6\r
4673#define IPF_APPLICATION_REGISTER_K7 7\r
4674#define IPF_APPLICATION_REGISTER_RSC 16\r
4675#define IPF_APPLICATION_REGISTER_BSP 17\r
4676#define IPF_APPLICATION_REGISTER_BSPSTORE 18\r
4677#define IPF_APPLICATION_REGISTER_RNAT 19\r
4678#define IPF_APPLICATION_REGISTER_FCR 21\r
4679#define IPF_APPLICATION_REGISTER_EFLAG 24\r
4680#define IPF_APPLICATION_REGISTER_CSD 25\r
4681#define IPF_APPLICATION_REGISTER_SSD 26\r
4682#define IPF_APPLICATION_REGISTER_CFLG 27\r
4683#define IPF_APPLICATION_REGISTER_FSR 28\r
4684#define IPF_APPLICATION_REGISTER_FIR 29\r
4685#define IPF_APPLICATION_REGISTER_FDR 30\r
4686#define IPF_APPLICATION_REGISTER_CCV 32\r
4687#define IPF_APPLICATION_REGISTER_UNAT 36\r
4688#define IPF_APPLICATION_REGISTER_FPSR 40\r
4689#define IPF_APPLICATION_REGISTER_ITC 44\r
4690#define IPF_APPLICATION_REGISTER_PFS 64\r
4691#define IPF_APPLICATION_REGISTER_LC 65\r
4692#define IPF_APPLICATION_REGISTER_EC 66\r
4693\r
4694/**\r
4695 Reads a 64-bit application register.\r
4696\r
af2dc6a7 4697 Reads and returns the application register specified by Index. The valid Index \r
4698 valued are defined above in "Related Definitions".\r
4699 If Index is invalid then 0xFFFFFFFFFFFFFFFF is returned. This function is only \r
4700 available on Itanium processors.\r
aad6137d 4701\r
4702 @param Index The index of the application register to read.\r
4703\r
4704 @return The application register specified by Index.\r
4705\r
4706**/\r
4707UINT64\r
4708EFIAPI\r
4709AsmReadApplicationRegister (\r
4710 IN UINT64 Index\r
4711 );\r
4712\r
4713\r
59e0bb0c 4714/**\r
4715 Reads the current value of a Machine Specific Register (MSR).\r
4716\r
4717 Reads and returns the current value of the Machine Specific Register specified by Index. No\r
4718 parameter checking is performed on Index, and if the Index value is beyond the implemented MSR\r
4719 register range, a Reserved Register/Field fault may occur. The caller must either guarantee that\r
4720 Index is valid, or the caller must set up fault handlers to catch the faults. This function is\r
1a2f870c 4721 only available on Itanium processors.\r
59e0bb0c 4722\r
4723 @param Index The 8-bit Machine Specific Register index to read.\r
4724\r
4725 @return The current value of the Machine Specific Register specified by Index. \r
4726\r
4727**/\r
4728UINT64\r
4729EFIAPI\r
4730AsmReadMsr (\r
4731 IN UINT8 Index \r
4732 );\r
4733\r
4734\r
4735/**\r
4736 Writes the current value of a Machine Specific Register (MSR).\r
4737\r
4738 Writes Value to the Machine Specific Register specified by Index. Value is returned. No\r
4739 parameter checking is performed on Index, and if the Index value is beyond the implemented MSR\r
4740 register range, a Reserved Register/Field fault may occur. The caller must either guarantee that\r
4741 Index is valid, or the caller must set up fault handlers to catch the faults. This function is\r
1a2f870c 4742 only available on Itanium processors.\r
59e0bb0c 4743\r
4744 @param Index The 8-bit Machine Specific Register index to write.\r
4745 @param Value The 64-bit value to write to the Machine Specific Register.\r
4746\r
4747 @return The 64-bit value to write to the Machine Specific Register. \r
4748\r
4749**/\r
4750UINT64\r
4751EFIAPI\r
4752AsmWriteMsr (\r
4753 IN UINT8 Index, \r
4754 IN UINT64 Value \r
4755 );\r
4756\r
4757\r
ac644614 4758/**\r
4759 Determines if the CPU is currently executing in virtual, physical, or mixed mode.\r
4760\r
4761 Determines the current execution mode of the CPU.\r
4762 If the CPU is in virtual mode(PSR.RT=1, PSR.DT=1, PSR.IT=1), then 1 is returned.\r
4763 If the CPU is in physical mode(PSR.RT=0, PSR.DT=0, PSR.IT=0), then 0 is returned.\r
4764 If the CPU is not in physical mode or virtual mode, then it is in mixed mode,\r
4765 and -1 is returned.\r
1a2f870c 4766 This function is only available on Itanium processors.\r
ac644614 4767\r
17f695ed 4768 @retval 1 The CPU is in virtual mode.\r
4769 @retval 0 The CPU is in physical mode.\r
4770 @retval -1 The CPU is in mixed mode.\r
ac644614 4771\r
4772**/\r
4773INT64\r
4774EFIAPI\r
4775AsmCpuVirtual (\r
4776 VOID\r
4777 );\r
4778\r
4779\r
4780/**\r
4781 Makes a PAL procedure call.\r
4782\r
4783 This is a wrapper function to make a PAL procedure call. Based on the Index\r
4784 value this API will make static or stacked PAL call. The following table\r
4785 describes the usage of PAL Procedure Index Assignment. Architected procedures\r
4786 may be designated as required or optional. If a PAL procedure is specified\r
4787 as optional, a unique return code of 0xFFFFFFFFFFFFFFFF is returned in the\r
4788 Status field of the PAL_CALL_RETURN structure.\r
4789 This indicates that the procedure is not present in this PAL implementation.\r
4790 It is the caller's responsibility to check for this return code after calling\r
4791 any optional PAL procedure.\r
4792 No parameter checking is performed on the 5 input parameters, but there are\r
4793 some common rules that the caller should follow when making a PAL call. Any\r
4794 address passed to PAL as buffers for return parameters must be 8-byte aligned.\r
4795 Unaligned addresses may cause undefined results. For those parameters defined\r
4796 as reserved or some fields defined as reserved must be zero filled or the invalid\r
4797 argument return value may be returned or undefined result may occur during the\r
4798 execution of the procedure. If the PalEntryPoint does not point to a valid\r
4799 PAL entry point then the system behavior is undefined. This function is only\r
1a2f870c 4800 available on Itanium processors.\r
ac644614 4801\r
ee6c452c 4802 @param PalEntryPoint The PAL procedure calls entry point.\r
4803 @param Index The PAL procedure Index number.\r
4804 @param Arg2 The 2nd parameter for PAL procedure calls.\r
4805 @param Arg3 The 3rd parameter for PAL procedure calls.\r
4806 @param Arg4 The 4th parameter for PAL procedure calls.\r
ac644614 4807\r
4808 @return structure returned from the PAL Call procedure, including the status and return value.\r
4809\r
4810**/\r
4811PAL_CALL_RETURN\r
4812EFIAPI\r
4813AsmPalCall (\r
4814 IN UINT64 PalEntryPoint,\r
4815 IN UINT64 Index,\r
4816 IN UINT64 Arg2,\r
4817 IN UINT64 Arg3,\r
4818 IN UINT64 Arg4\r
4819 );\r
fd163050 4820#endif\r
ac644614 4821\r
fd163050 4822#if defined (MDE_CPU_IA32) || defined (MDE_CPU_X64)\r
1106ffe1 4823///\r
af2dc6a7 4824/// IA32 and x64 Specific Functions.\r
4825/// Byte packed structure for 16-bit Real Mode EFLAGS.\r
1106ffe1 4826///\r
ac644614 4827typedef union {\r
4828 struct {\r
af2dc6a7 4829 UINT32 CF:1; ///< Carry Flag.\r
4830 UINT32 Reserved_0:1; ///< Reserved.\r
4831 UINT32 PF:1; ///< Parity Flag.\r
4832 UINT32 Reserved_1:1; ///< Reserved.\r
4833 UINT32 AF:1; ///< Auxiliary Carry Flag.\r
4834 UINT32 Reserved_2:1; ///< Reserved.\r
4835 UINT32 ZF:1; ///< Zero Flag.\r
4836 UINT32 SF:1; ///< Sign Flag.\r
4837 UINT32 TF:1; ///< Trap Flag.\r
4838 UINT32 IF:1; ///< Interrupt Enable Flag.\r
4839 UINT32 DF:1; ///< Direction Flag.\r
4840 UINT32 OF:1; ///< Overflow Flag.\r
4841 UINT32 IOPL:2; ///< I/O Privilege Level.\r
4842 UINT32 NT:1; ///< Nested Task.\r
4843 UINT32 Reserved_3:1; ///< Reserved.\r
ac644614 4844 } Bits;\r
4845 UINT16 Uint16;\r
4846} IA32_FLAGS16;\r
4847\r
1106ffe1 4848///\r
af2dc6a7 4849/// Byte packed structure for EFLAGS/RFLAGS.\r
4850/// 32-bits on IA-32.\r
4851/// 64-bits on x64. The upper 32-bits on x64 are reserved.\r
1106ffe1 4852///\r
ac644614 4853typedef union {\r
4854 struct {\r
af2dc6a7 4855 UINT32 CF:1; ///< Carry Flag.\r
4856 UINT32 Reserved_0:1; ///< Reserved.\r
4857 UINT32 PF:1; ///< Parity Flag.\r
4858 UINT32 Reserved_1:1; ///< Reserved.\r
4859 UINT32 AF:1; ///< Auxiliary Carry Flag.\r
4860 UINT32 Reserved_2:1; ///< Reserved.\r
4861 UINT32 ZF:1; ///< Zero Flag.\r
4862 UINT32 SF:1; ///< Sign Flag.\r
4863 UINT32 TF:1; ///< Trap Flag.\r
4864 UINT32 IF:1; ///< Interrupt Enable Flag.\r
4865 UINT32 DF:1; ///< Direction Flag.\r
4866 UINT32 OF:1; ///< Overflow Flag.\r
4867 UINT32 IOPL:2; ///< I/O Privilege Level.\r
4868 UINT32 NT:1; ///< Nested Task.\r
4869 UINT32 Reserved_3:1; ///< Reserved.\r
4870 UINT32 RF:1; ///< Resume Flag.\r
4871 UINT32 VM:1; ///< Virtual 8086 Mode.\r
4872 UINT32 AC:1; ///< Alignment Check.\r
4873 UINT32 VIF:1; ///< Virtual Interrupt Flag.\r
4874 UINT32 VIP:1; ///< Virtual Interrupt Pending.\r
4875 UINT32 ID:1; ///< ID Flag.\r
4876 UINT32 Reserved_4:10; ///< Reserved.\r
ac644614 4877 } Bits;\r
4878 UINTN UintN;\r
4879} IA32_EFLAGS32;\r
4880\r
1106ffe1 4881///\r
af2dc6a7 4882/// Byte packed structure for Control Register 0 (CR0).\r
4883/// 32-bits on IA-32.\r
4884/// 64-bits on x64. The upper 32-bits on x64 are reserved.\r
1106ffe1 4885///\r
ac644614 4886typedef union {\r
4887 struct {\r
af2dc6a7 4888 UINT32 PE:1; ///< Protection Enable.\r
4889 UINT32 MP:1; ///< Monitor Coprocessor.\r
4890 UINT32 EM:1; ///< Emulation.\r
4891 UINT32 TS:1; ///< Task Switched.\r
4892 UINT32 ET:1; ///< Extension Type.\r
4893 UINT32 NE:1; ///< Numeric Error.\r
4894 UINT32 Reserved_0:10; ///< Reserved.\r
4895 UINT32 WP:1; ///< Write Protect.\r
4896 UINT32 Reserved_1:1; ///< Reserved.\r
4897 UINT32 AM:1; ///< Alignment Mask.\r
4898 UINT32 Reserved_2:10; ///< Reserved.\r
4899 UINT32 NW:1; ///< Mot Write-through.\r
4900 UINT32 CD:1; ///< Cache Disable.\r
4901 UINT32 PG:1; ///< Paging.\r
ac644614 4902 } Bits;\r
4903 UINTN UintN;\r
4904} IA32_CR0;\r
4905\r
1106ffe1 4906///\r
af2dc6a7 4907/// Byte packed structure for Control Register 4 (CR4).\r
4908/// 32-bits on IA-32.\r
4909/// 64-bits on x64. The upper 32-bits on x64 are reserved.\r
1106ffe1 4910///\r
ac644614 4911typedef union {\r
4912 struct {\r
af2dc6a7 4913 UINT32 VME:1; ///< Virtual-8086 Mode Extensions.\r
4914 UINT32 PVI:1; ///< Protected-Mode Virtual Interrupts.\r
4915 UINT32 TSD:1; ///< Time Stamp Disable.\r
4916 UINT32 DE:1; ///< Debugging Extensions.\r
4917 UINT32 PSE:1; ///< Page Size Extensions.\r
4918 UINT32 PAE:1; ///< Physical Address Extension.\r
4919 UINT32 MCE:1; ///< Machine Check Enable.\r
4920 UINT32 PGE:1; ///< Page Global Enable.\r
2a53dabf 4921 UINT32 PCE:1; ///< Performance Monitoring Counter\r
af2dc6a7 4922 ///< Enable.\r
2a53dabf
LG
4923 UINT32 OSFXSR:1; ///< Operating System Support for\r
4924 ///< FXSAVE and FXRSTOR instructions\r
4925 UINT32 OSXMMEXCPT:1; ///< Operating System Support for\r
4926 ///< Unmasked SIMD Floating Point\r
af2dc6a7 4927 ///< Exceptions.\r
4928 UINT32 Reserved_0:2; ///< Reserved.\r
2a53dabf 4929 UINT32 VMXE:1; ///< VMX Enable\r
af2dc6a7 4930 UINT32 Reserved_1:18; ///< Reserved.\r
ac644614 4931 } Bits;\r
4932 UINTN UintN;\r
4933} IA32_CR4;\r
4934\r
1106ffe1 4935///\r
af2dc6a7 4936/// Byte packed structure for an IDTR, GDTR, LDTR descriptor.\r
1106ffe1 4937///\r
ac644614 4938#pragma pack (1)\r
4939typedef struct {\r
4940 UINT16 Limit;\r
4941 UINTN Base;\r
4942} IA32_DESCRIPTOR;\r
4943#pragma pack ()\r
4944\r
4945#define IA32_IDT_GATE_TYPE_TASK 0x85\r
4946#define IA32_IDT_GATE_TYPE_INTERRUPT_16 0x86\r
4947#define IA32_IDT_GATE_TYPE_TRAP_16 0x87\r
4948#define IA32_IDT_GATE_TYPE_INTERRUPT_32 0x8E\r
4949#define IA32_IDT_GATE_TYPE_TRAP_32 0x8F\r
4950\r
6f4aad3b 4951\r
4952#if defined (MDE_CPU_IA32)\r
1106ffe1 4953///\r
af2dc6a7 4954/// Byte packed structure for an IA-32 Interrupt Gate Descriptor.\r
1106ffe1 4955///\r
dc317713 4956typedef union {\r
4957 struct {\r
af2dc6a7 4958 UINT32 OffsetLow:16; ///< Offset bits 15..0.\r
4959 UINT32 Selector:16; ///< Selector.\r
4960 UINT32 Reserved_0:8; ///< Reserved.\r
4961 UINT32 GateType:8; ///< Gate Type. See #defines above.\r
4962 UINT32 OffsetHigh:16; ///< Offset bits 31..16.\r
dc317713 4963 } Bits;\r
4964 UINT64 Uint64;\r
4965} IA32_IDT_GATE_DESCRIPTOR;\r
4966\r
4967#endif\r
4968\r
4969#if defined (MDE_CPU_X64)\r
6f4aad3b 4970///\r
af2dc6a7 4971/// Byte packed structure for an x64 Interrupt Gate Descriptor.\r
6f4aad3b 4972///\r
ac644614 4973typedef union {\r
4974 struct {\r
af2dc6a7 4975 UINT32 OffsetLow:16; ///< Offset bits 15..0.\r
4976 UINT32 Selector:16; ///< Selector.\r
4977 UINT32 Reserved_0:8; ///< Reserved.\r
4978 UINT32 GateType:8; ///< Gate Type. See #defines above.\r
4979 UINT32 OffsetHigh:16; ///< Offset bits 31..16.\r
4980 UINT32 OffsetUpper:32; ///< Offset bits 63..32.\r
4981 UINT32 Reserved_1:32; ///< Reserved.\r
ac644614 4982 } Bits;\r
6f4aad3b 4983 struct {\r
4984 UINT64 Uint64;\r
4985 UINT64 Uint64_1;\r
4986 } Uint128; \r
ac644614 4987} IA32_IDT_GATE_DESCRIPTOR;\r
4988\r
dc317713 4989#endif\r
4990\r
1106ffe1 4991///\r
af2dc6a7 4992/// Byte packed structure for an FP/SSE/SSE2 context.\r
1106ffe1 4993///\r
ac644614 4994typedef struct {\r
4995 UINT8 Buffer[512];\r
4996} IA32_FX_BUFFER;\r
4997\r
1106ffe1 4998///\r
af2dc6a7 4999/// Structures for the 16-bit real mode thunks.\r
1106ffe1 5000///\r
ac644614 5001typedef struct {\r
5002 UINT32 Reserved1;\r
5003 UINT32 Reserved2;\r
5004 UINT32 Reserved3;\r
5005 UINT32 Reserved4;\r
5006 UINT8 BL;\r
5007 UINT8 BH;\r
5008 UINT16 Reserved5;\r
5009 UINT8 DL;\r
5010 UINT8 DH;\r
5011 UINT16 Reserved6;\r
5012 UINT8 CL;\r
5013 UINT8 CH;\r
5014 UINT16 Reserved7;\r
5015 UINT8 AL;\r
5016 UINT8 AH;\r
5017 UINT16 Reserved8;\r
5018} IA32_BYTE_REGS;\r
5019\r
5020typedef struct {\r
5021 UINT16 DI;\r
5022 UINT16 Reserved1;\r
5023 UINT16 SI;\r
5024 UINT16 Reserved2;\r
5025 UINT16 BP;\r
5026 UINT16 Reserved3;\r
5027 UINT16 SP;\r
5028 UINT16 Reserved4;\r
5029 UINT16 BX;\r
5030 UINT16 Reserved5;\r
5031 UINT16 DX;\r
5032 UINT16 Reserved6;\r
5033 UINT16 CX;\r
5034 UINT16 Reserved7;\r
5035 UINT16 AX;\r
5036 UINT16 Reserved8;\r
5037} IA32_WORD_REGS;\r
5038\r
5039typedef struct {\r
5040 UINT32 EDI;\r
5041 UINT32 ESI;\r
5042 UINT32 EBP;\r
5043 UINT32 ESP;\r
5044 UINT32 EBX;\r
5045 UINT32 EDX;\r
5046 UINT32 ECX;\r
5047 UINT32 EAX;\r
5048 UINT16 DS;\r
5049 UINT16 ES;\r
5050 UINT16 FS;\r
5051 UINT16 GS;\r
5052 IA32_EFLAGS32 EFLAGS;\r
5053 UINT32 Eip;\r
5054 UINT16 CS;\r
5055 UINT16 SS;\r
5056} IA32_DWORD_REGS;\r
5057\r
5058typedef union {\r
5059 IA32_DWORD_REGS E;\r
5060 IA32_WORD_REGS X;\r
5061 IA32_BYTE_REGS H;\r
5062} IA32_REGISTER_SET;\r
5063\r
1106ffe1 5064///\r
af2dc6a7 5065/// Byte packed structure for an 16-bit real mode thunks.\r
1106ffe1 5066///\r
ac644614 5067typedef struct {\r
5068 IA32_REGISTER_SET *RealModeState;\r
5069 VOID *RealModeBuffer;\r
5070 UINT32 RealModeBufferSize;\r
5071 UINT32 ThunkAttributes;\r
5072} THUNK_CONTEXT;\r
5073\r
5074#define THUNK_ATTRIBUTE_BIG_REAL_MODE 0x00000001\r
5075#define THUNK_ATTRIBUTE_DISABLE_A20_MASK_INT_15 0x00000002\r
5076#define THUNK_ATTRIBUTE_DISABLE_A20_MASK_KBD_CTRL 0x00000004\r
5077\r
5078/**\r
5079 Retrieves CPUID information.\r
5080\r
5081 Executes the CPUID instruction with EAX set to the value specified by Index.\r
5082 This function always returns Index.\r
5083 If Eax is not NULL, then the value of EAX after CPUID is returned in Eax.\r
5084 If Ebx is not NULL, then the value of EBX after CPUID is returned in Ebx.\r
5085 If Ecx is not NULL, then the value of ECX after CPUID is returned in Ecx.\r
5086 If Edx is not NULL, then the value of EDX after CPUID is returned in Edx.\r
030cd1a2 5087 This function is only available on IA-32 and x64.\r
ac644614 5088\r
5089 @param Index The 32-bit value to load into EAX prior to invoking the CPUID\r
5090 instruction.\r
af2dc6a7 5091 @param Eax The pointer to the 32-bit EAX value returned by the CPUID\r
ac644614 5092 instruction. This is an optional parameter that may be NULL.\r
af2dc6a7 5093 @param Ebx The pointer to the 32-bit EBX value returned by the CPUID\r
ac644614 5094 instruction. This is an optional parameter that may be NULL.\r
af2dc6a7 5095 @param Ecx The pointer to the 32-bit ECX value returned by the CPUID\r
ac644614 5096 instruction. This is an optional parameter that may be NULL.\r
af2dc6a7 5097 @param Edx The pointer to the 32-bit EDX value returned by the CPUID\r
ac644614 5098 instruction. This is an optional parameter that may be NULL.\r
5099\r
2fe241a2 5100 @return Index.\r
ac644614 5101\r
5102**/\r
5103UINT32\r
5104EFIAPI\r
5105AsmCpuid (\r
5106 IN UINT32 Index,\r
5107 OUT UINT32 *Eax, OPTIONAL\r
5108 OUT UINT32 *Ebx, OPTIONAL\r
5109 OUT UINT32 *Ecx, OPTIONAL\r
5110 OUT UINT32 *Edx OPTIONAL\r
5111 );\r
5112\r
5113\r
5114/**\r
5115 Retrieves CPUID information using an extended leaf identifier.\r
5116\r
5117 Executes the CPUID instruction with EAX set to the value specified by Index\r
5118 and ECX set to the value specified by SubIndex. This function always returns\r
5119 Index. This function is only available on IA-32 and x64.\r
5120\r
5121 If Eax is not NULL, then the value of EAX after CPUID is returned in Eax.\r
5122 If Ebx is not NULL, then the value of EBX after CPUID is returned in Ebx.\r
5123 If Ecx is not NULL, then the value of ECX after CPUID is returned in Ecx.\r
5124 If Edx is not NULL, then the value of EDX after CPUID is returned in Edx.\r
5125\r
5126 @param Index The 32-bit value to load into EAX prior to invoking the\r
5127 CPUID instruction.\r
5128 @param SubIndex The 32-bit value to load into ECX prior to invoking the\r
5129 CPUID instruction.\r
af2dc6a7 5130 @param Eax The pointer to the 32-bit EAX value returned by the CPUID\r
ac644614 5131 instruction. This is an optional parameter that may be\r
5132 NULL.\r
af2dc6a7 5133 @param Ebx The pointer to the 32-bit EBX value returned by the CPUID\r
ac644614 5134 instruction. This is an optional parameter that may be\r
5135 NULL.\r
af2dc6a7 5136 @param Ecx The pointer to the 32-bit ECX value returned by the CPUID\r
ac644614 5137 instruction. This is an optional parameter that may be\r
5138 NULL.\r
af2dc6a7 5139 @param Edx The pointer to the 32-bit EDX value returned by the CPUID\r
ac644614 5140 instruction. This is an optional parameter that may be\r
5141 NULL.\r
5142\r
2fe241a2 5143 @return Index.\r
ac644614 5144\r
5145**/\r
5146UINT32\r
5147EFIAPI\r
5148AsmCpuidEx (\r
5149 IN UINT32 Index,\r
5150 IN UINT32 SubIndex,\r
5151 OUT UINT32 *Eax, OPTIONAL\r
5152 OUT UINT32 *Ebx, OPTIONAL\r
5153 OUT UINT32 *Ecx, OPTIONAL\r
5154 OUT UINT32 *Edx OPTIONAL\r
5155 );\r
5156\r
5157\r
be5f1614 5158/**\r
5159 Set CD bit and clear NW bit of CR0 followed by a WBINVD.\r
5160\r
5161 Disables the caches by setting the CD bit of CR0 to 1, clearing the NW bit of CR0 to 0,\r
5162 and executing a WBINVD instruction. This function is only available on IA-32 and x64.\r
5163\r
5164**/\r
5165VOID\r
5166EFIAPI\r
5167AsmDisableCache (\r
5168 VOID\r
5169 );\r
5170\r
5171\r
5172/**\r
5173 Perform a WBINVD and clear both the CD and NW bits of CR0.\r
5174\r
5175 Enables the caches by executing a WBINVD instruction and then clear both the CD and NW\r
5176 bits of CR0 to 0. This function is only available on IA-32 and x64.\r
5177\r
5178**/\r
5179VOID\r
5180EFIAPI\r
5181AsmEnableCache (\r
5182 VOID\r
5183 );\r
5184\r
5185\r
ac644614 5186/**\r
5187 Returns the lower 32-bits of a Machine Specific Register(MSR).\r
5188\r
5189 Reads and returns the lower 32-bits of the MSR specified by Index.\r
5190 No parameter checking is performed on Index, and some Index values may cause\r
5191 CPU exceptions. The caller must either guarantee that Index is valid, or the\r
5192 caller must set up exception handlers to catch the exceptions. This function\r
030cd1a2 5193 is only available on IA-32 and x64.\r
ac644614 5194\r
5195 @param Index The 32-bit MSR index to read.\r
5196\r
5197 @return The lower 32 bits of the MSR identified by Index.\r
5198\r
5199**/\r
5200UINT32\r
5201EFIAPI\r
5202AsmReadMsr32 (\r
5203 IN UINT32 Index\r
5204 );\r
5205\r
5206\r
5207/**\r
17f695ed 5208 Writes a 32-bit value to a Machine Specific Register(MSR), and returns the value.\r
5209 The upper 32-bits of the MSR are set to zero.\r
ac644614 5210\r
5211 Writes the 32-bit value specified by Value to the MSR specified by Index. The\r
5212 upper 32-bits of the MSR write are set to zero. The 32-bit value written to\r
5213 the MSR is returned. No parameter checking is performed on Index or Value,\r
5214 and some of these may cause CPU exceptions. The caller must either guarantee\r
5215 that Index and Value are valid, or the caller must establish proper exception\r
030cd1a2 5216 handlers. This function is only available on IA-32 and x64.\r
ac644614 5217\r
5218 @param Index The 32-bit MSR index to write.\r
5219 @param Value The 32-bit value to write to the MSR.\r
5220\r
5221 @return Value\r
5222\r
5223**/\r
5224UINT32\r
5225EFIAPI\r
5226AsmWriteMsr32 (\r
5227 IN UINT32 Index,\r
5228 IN UINT32 Value\r
5229 );\r
5230\r
5231\r
5232/**\r
62991af2 5233 Reads a 64-bit MSR, performs a bitwise OR on the lower 32-bits, and\r
ac644614 5234 writes the result back to the 64-bit MSR.\r
5235\r
62991af2 5236 Reads the 64-bit MSR specified by Index, performs a bitwise OR\r
ac644614 5237 between the lower 32-bits of the read result and the value specified by\r
5238 OrData, and writes the result to the 64-bit MSR specified by Index. The lower\r
5239 32-bits of the value written to the MSR is returned. No parameter checking is\r
5240 performed on Index or OrData, and some of these may cause CPU exceptions. The\r
5241 caller must either guarantee that Index and OrData are valid, or the caller\r
5242 must establish proper exception handlers. This function is only available on\r
030cd1a2 5243 IA-32 and x64.\r
ac644614 5244\r
5245 @param Index The 32-bit MSR index to write.\r
5246 @param OrData The value to OR with the read value from the MSR.\r
5247\r
5248 @return The lower 32-bit value written to the MSR.\r
5249\r
5250**/\r
5251UINT32\r
5252EFIAPI\r
5253AsmMsrOr32 (\r
5254 IN UINT32 Index,\r
5255 IN UINT32 OrData\r
5256 );\r
5257\r
5258\r
5259/**\r
5260 Reads a 64-bit MSR, performs a bitwise AND on the lower 32-bits, and writes\r
5261 the result back to the 64-bit MSR.\r
5262\r
5263 Reads the 64-bit MSR specified by Index, performs a bitwise AND between the\r
5264 lower 32-bits of the read result and the value specified by AndData, and\r
5265 writes the result to the 64-bit MSR specified by Index. The lower 32-bits of\r
5266 the value written to the MSR is returned. No parameter checking is performed\r
5267 on Index or AndData, and some of these may cause CPU exceptions. The caller\r
5268 must either guarantee that Index and AndData are valid, or the caller must\r
5269 establish proper exception handlers. This function is only available on IA-32\r
030cd1a2 5270 and x64.\r
ac644614 5271\r
5272 @param Index The 32-bit MSR index to write.\r
5273 @param AndData The value to AND with the read value from the MSR.\r
5274\r
5275 @return The lower 32-bit value written to the MSR.\r
5276\r
5277**/\r
5278UINT32\r
5279EFIAPI\r
5280AsmMsrAnd32 (\r
5281 IN UINT32 Index,\r
5282 IN UINT32 AndData\r
5283 );\r
5284\r
5285\r
5286/**\r
62991af2 5287 Reads a 64-bit MSR, performs a bitwise AND followed by a bitwise OR\r
ac644614 5288 on the lower 32-bits, and writes the result back to the 64-bit MSR.\r
5289\r
5290 Reads the 64-bit MSR specified by Index, performs a bitwise AND between the\r
5291 lower 32-bits of the read result and the value specified by AndData\r
62991af2 5292 preserving the upper 32-bits, performs a bitwise OR between the\r
ac644614 5293 result of the AND operation and the value specified by OrData, and writes the\r
5294 result to the 64-bit MSR specified by Address. The lower 32-bits of the value\r
5295 written to the MSR is returned. No parameter checking is performed on Index,\r
5296 AndData, or OrData, and some of these may cause CPU exceptions. The caller\r
5297 must either guarantee that Index, AndData, and OrData are valid, or the\r
5298 caller must establish proper exception handlers. This function is only\r
030cd1a2 5299 available on IA-32 and x64.\r
ac644614 5300\r
5301 @param Index The 32-bit MSR index to write.\r
5302 @param AndData The value to AND with the read value from the MSR.\r
5303 @param OrData The value to OR with the result of the AND operation.\r
5304\r
5305 @return The lower 32-bit value written to the MSR.\r
5306\r
5307**/\r
5308UINT32\r
5309EFIAPI\r
5310AsmMsrAndThenOr32 (\r
5311 IN UINT32 Index,\r
5312 IN UINT32 AndData,\r
5313 IN UINT32 OrData\r
5314 );\r
5315\r
5316\r
5317/**\r
5318 Reads a bit field of an MSR.\r
5319\r
5320 Reads the bit field in the lower 32-bits of a 64-bit MSR. The bit field is\r
5321 specified by the StartBit and the EndBit. The value of the bit field is\r
5322 returned. The caller must either guarantee that Index is valid, or the caller\r
5323 must set up exception handlers to catch the exceptions. This function is only\r
030cd1a2 5324 available on IA-32 and x64.\r
ac644614 5325\r
5326 If StartBit is greater than 31, then ASSERT().\r
5327 If EndBit is greater than 31, then ASSERT().\r
5328 If EndBit is less than StartBit, then ASSERT().\r
5329\r
5330 @param Index The 32-bit MSR index to read.\r
5331 @param StartBit The ordinal of the least significant bit in the bit field.\r
5332 Range 0..31.\r
5333 @param EndBit The ordinal of the most significant bit in the bit field.\r
5334 Range 0..31.\r
5335\r
5336 @return The bit field read from the MSR.\r
5337\r
5338**/\r
5339UINT32\r
5340EFIAPI\r
5341AsmMsrBitFieldRead32 (\r
5342 IN UINT32 Index,\r
5343 IN UINTN StartBit,\r
5344 IN UINTN EndBit\r
5345 );\r
5346\r
5347\r
5348/**\r
5349 Writes a bit field to an MSR.\r
5350\r
2fe241a2 5351 Writes Value to a bit field in the lower 32-bits of a 64-bit MSR. The bit\r
ac644614 5352 field is specified by the StartBit and the EndBit. All other bits in the\r
5353 destination MSR are preserved. The lower 32-bits of the MSR written is\r
62991af2 5354 returned. The caller must either guarantee that Index and the data written \r
5355 is valid, or the caller must set up exception handlers to catch the exceptions. \r
5356 This function is only available on IA-32 and x64.\r
ac644614 5357\r
5358 If StartBit is greater than 31, then ASSERT().\r
5359 If EndBit is greater than 31, then ASSERT().\r
5360 If EndBit is less than StartBit, then ASSERT().\r
5361\r
5362 @param Index The 32-bit MSR index to write.\r
5363 @param StartBit The ordinal of the least significant bit in the bit field.\r
5364 Range 0..31.\r
5365 @param EndBit The ordinal of the most significant bit in the bit field.\r
5366 Range 0..31.\r
5367 @param Value New value of the bit field.\r
5368\r
5369 @return The lower 32-bit of the value written to the MSR.\r
5370\r
5371**/\r
5372UINT32\r
5373EFIAPI\r
5374AsmMsrBitFieldWrite32 (\r
5375 IN UINT32 Index,\r
5376 IN UINTN StartBit,\r
5377 IN UINTN EndBit,\r
5378 IN UINT32 Value\r
5379 );\r
5380\r
5381\r
5382/**\r
5383 Reads a bit field in a 64-bit MSR, performs a bitwise OR, and writes the\r
5384 result back to the bit field in the 64-bit MSR.\r
5385\r
62991af2 5386 Reads the 64-bit MSR specified by Index, performs a bitwise OR\r
ac644614 5387 between the read result and the value specified by OrData, and writes the\r
5388 result to the 64-bit MSR specified by Index. The lower 32-bits of the value\r
5389 written to the MSR are returned. Extra left bits in OrData are stripped. The\r
5390 caller must either guarantee that Index and the data written is valid, or\r
5391 the caller must set up exception handlers to catch the exceptions. This\r
030cd1a2 5392 function is only available on IA-32 and x64.\r
ac644614 5393\r
5394 If StartBit is greater than 31, then ASSERT().\r
5395 If EndBit is greater than 31, then ASSERT().\r
5396 If EndBit is less than StartBit, then ASSERT().\r
5397\r
5398 @param Index The 32-bit MSR index to write.\r
5399 @param StartBit The ordinal of the least significant bit in the bit field.\r
5400 Range 0..31.\r
5401 @param EndBit The ordinal of the most significant bit in the bit field.\r
5402 Range 0..31.\r
5403 @param OrData The value to OR with the read value from the MSR.\r
5404\r
5405 @return The lower 32-bit of the value written to the MSR.\r
5406\r
5407**/\r
5408UINT32\r
5409EFIAPI\r
5410AsmMsrBitFieldOr32 (\r
5411 IN UINT32 Index,\r
5412 IN UINTN StartBit,\r
5413 IN UINTN EndBit,\r
5414 IN UINT32 OrData\r
5415 );\r
5416\r
5417\r
5418/**\r
5419 Reads a bit field in a 64-bit MSR, performs a bitwise AND, and writes the\r
5420 result back to the bit field in the 64-bit MSR.\r
5421\r
5422 Reads the 64-bit MSR specified by Index, performs a bitwise AND between the\r
5423 read result and the value specified by AndData, and writes the result to the\r
5424 64-bit MSR specified by Index. The lower 32-bits of the value written to the\r
5425 MSR are returned. Extra left bits in AndData are stripped. The caller must\r
5426 either guarantee that Index and the data written is valid, or the caller must\r
5427 set up exception handlers to catch the exceptions. This function is only\r
030cd1a2 5428 available on IA-32 and x64.\r
ac644614 5429\r
5430 If StartBit is greater than 31, then ASSERT().\r
5431 If EndBit is greater than 31, then ASSERT().\r
5432 If EndBit is less than StartBit, then ASSERT().\r
5433\r
5434 @param Index The 32-bit MSR index to write.\r
5435 @param StartBit The ordinal of the least significant bit in the bit field.\r
5436 Range 0..31.\r
5437 @param EndBit The ordinal of the most significant bit in the bit field.\r
5438 Range 0..31.\r
5439 @param AndData The value to AND with the read value from the MSR.\r
5440\r
5441 @return The lower 32-bit of the value written to the MSR.\r
5442\r
5443**/\r
5444UINT32\r
5445EFIAPI\r
5446AsmMsrBitFieldAnd32 (\r
5447 IN UINT32 Index,\r
5448 IN UINTN StartBit,\r
5449 IN UINTN EndBit,\r
5450 IN UINT32 AndData\r
5451 );\r
5452\r
5453\r
5454/**\r
5455 Reads a bit field in a 64-bit MSR, performs a bitwise AND followed by a\r
62991af2 5456 bitwise OR, and writes the result back to the bit field in the\r
ac644614 5457 64-bit MSR.\r
5458\r
5459 Reads the 64-bit MSR specified by Index, performs a bitwise AND followed by a\r
62991af2 5460 bitwise OR between the read result and the value specified by\r
ac644614 5461 AndData, and writes the result to the 64-bit MSR specified by Index. The\r
5462 lower 32-bits of the value written to the MSR are returned. Extra left bits\r
5463 in both AndData and OrData are stripped. The caller must either guarantee\r
5464 that Index and the data written is valid, or the caller must set up exception\r
5465 handlers to catch the exceptions. This function is only available on IA-32\r
030cd1a2 5466 and x64.\r
ac644614 5467\r
5468 If StartBit is greater than 31, then ASSERT().\r
5469 If EndBit is greater than 31, then ASSERT().\r
5470 If EndBit is less than StartBit, then ASSERT().\r
5471\r
5472 @param Index The 32-bit MSR index to write.\r
5473 @param StartBit The ordinal of the least significant bit in the bit field.\r
5474 Range 0..31.\r
5475 @param EndBit The ordinal of the most significant bit in the bit field.\r
5476 Range 0..31.\r
5477 @param AndData The value to AND with the read value from the MSR.\r
5478 @param OrData The value to OR with the result of the AND operation.\r
5479\r
5480 @return The lower 32-bit of the value written to the MSR.\r
5481\r
5482**/\r
5483UINT32\r
5484EFIAPI\r
5485AsmMsrBitFieldAndThenOr32 (\r
5486 IN UINT32 Index,\r
5487 IN UINTN StartBit,\r
5488 IN UINTN EndBit,\r
5489 IN UINT32 AndData,\r
5490 IN UINT32 OrData\r
5491 );\r
5492\r
5493\r
5494/**\r
5495 Returns a 64-bit Machine Specific Register(MSR).\r
5496\r
5497 Reads and returns the 64-bit MSR specified by Index. No parameter checking is\r
5498 performed on Index, and some Index values may cause CPU exceptions. The\r
5499 caller must either guarantee that Index is valid, or the caller must set up\r
5500 exception handlers to catch the exceptions. This function is only available\r
030cd1a2 5501 on IA-32 and x64.\r
ac644614 5502\r
5503 @param Index The 32-bit MSR index to read.\r
5504\r
5505 @return The value of the MSR identified by Index.\r
5506\r
5507**/\r
5508UINT64\r
5509EFIAPI\r
5510AsmReadMsr64 (\r
5511 IN UINT32 Index\r
5512 );\r
5513\r
5514\r
5515/**\r
5516 Writes a 64-bit value to a Machine Specific Register(MSR), and returns the\r
5517 value.\r
5518\r
5519 Writes the 64-bit value specified by Value to the MSR specified by Index. The\r
5520 64-bit value written to the MSR is returned. No parameter checking is\r
5521 performed on Index or Value, and some of these may cause CPU exceptions. The\r
5522 caller must either guarantee that Index and Value are valid, or the caller\r
5523 must establish proper exception handlers. This function is only available on\r
030cd1a2 5524 IA-32 and x64.\r
ac644614 5525\r
5526 @param Index The 32-bit MSR index to write.\r
5527 @param Value The 64-bit value to write to the MSR.\r
5528\r
5529 @return Value\r
5530\r
5531**/\r
5532UINT64\r
5533EFIAPI\r
5534AsmWriteMsr64 (\r
5535 IN UINT32 Index,\r
5536 IN UINT64 Value\r
5537 );\r
5538\r
5539\r
5540/**\r
62991af2 5541 Reads a 64-bit MSR, performs a bitwise OR, and writes the result\r
ac644614 5542 back to the 64-bit MSR.\r
5543\r
62991af2 5544 Reads the 64-bit MSR specified by Index, performs a bitwise OR\r
ac644614 5545 between the read result and the value specified by OrData, and writes the\r
5546 result to the 64-bit MSR specified by Index. The value written to the MSR is\r
5547 returned. No parameter checking is performed on Index or OrData, and some of\r
5548 these may cause CPU exceptions. The caller must either guarantee that Index\r
5549 and OrData are valid, or the caller must establish proper exception handlers.\r
030cd1a2 5550 This function is only available on IA-32 and x64.\r
ac644614 5551\r
5552 @param Index The 32-bit MSR index to write.\r
5553 @param OrData The value to OR with the read value from the MSR.\r
5554\r
5555 @return The value written back to the MSR.\r
5556\r
5557**/\r
5558UINT64\r
5559EFIAPI\r
5560AsmMsrOr64 (\r
5561 IN UINT32 Index,\r
5562 IN UINT64 OrData\r
5563 );\r
5564\r
5565\r
5566/**\r
5567 Reads a 64-bit MSR, performs a bitwise AND, and writes the result back to the\r
5568 64-bit MSR.\r
5569\r
5570 Reads the 64-bit MSR specified by Index, performs a bitwise AND between the\r
5571 read result and the value specified by OrData, and writes the result to the\r
5572 64-bit MSR specified by Index. The value written to the MSR is returned. No\r
5573 parameter checking is performed on Index or OrData, and some of these may\r
5574 cause CPU exceptions. The caller must either guarantee that Index and OrData\r
5575 are valid, or the caller must establish proper exception handlers. This\r
030cd1a2 5576 function is only available on IA-32 and x64.\r
ac644614 5577\r
5578 @param Index The 32-bit MSR index to write.\r
5579 @param AndData The value to AND with the read value from the MSR.\r
5580\r
5581 @return The value written back to the MSR.\r
5582\r
5583**/\r
5584UINT64\r
5585EFIAPI\r
5586AsmMsrAnd64 (\r
5587 IN UINT32 Index,\r
5588 IN UINT64 AndData\r
5589 );\r
5590\r
5591\r
5592/**\r
62991af2 5593 Reads a 64-bit MSR, performs a bitwise AND followed by a bitwise \r
ac644614 5594 OR, and writes the result back to the 64-bit MSR.\r
5595\r
5596 Reads the 64-bit MSR specified by Index, performs a bitwise AND between read\r
62991af2 5597 result and the value specified by AndData, performs a bitwise OR\r
ac644614 5598 between the result of the AND operation and the value specified by OrData,\r
5599 and writes the result to the 64-bit MSR specified by Index. The value written\r
5600 to the MSR is returned. No parameter checking is performed on Index, AndData,\r
5601 or OrData, and some of these may cause CPU exceptions. The caller must either\r
5602 guarantee that Index, AndData, and OrData are valid, or the caller must\r
5603 establish proper exception handlers. This function is only available on IA-32\r
030cd1a2 5604 and x64.\r
ac644614 5605\r
5606 @param Index The 32-bit MSR index to write.\r
5607 @param AndData The value to AND with the read value from the MSR.\r
5608 @param OrData The value to OR with the result of the AND operation.\r
5609\r
5610 @return The value written back to the MSR.\r
5611\r
5612**/\r
5613UINT64\r
5614EFIAPI\r
5615AsmMsrAndThenOr64 (\r
5616 IN UINT32 Index,\r
5617 IN UINT64 AndData,\r
5618 IN UINT64 OrData\r
5619 );\r
5620\r
5621\r
5622/**\r
5623 Reads a bit field of an MSR.\r
5624\r
5625 Reads the bit field in the 64-bit MSR. The bit field is specified by the\r
5626 StartBit and the EndBit. The value of the bit field is returned. The caller\r
5627 must either guarantee that Index is valid, or the caller must set up\r
5628 exception handlers to catch the exceptions. This function is only available\r
030cd1a2 5629 on IA-32 and x64.\r
ac644614 5630\r
5631 If StartBit is greater than 63, then ASSERT().\r
5632 If EndBit is greater than 63, then ASSERT().\r
5633 If EndBit is less than StartBit, then ASSERT().\r
5634\r
5635 @param Index The 32-bit MSR index to read.\r
5636 @param StartBit The ordinal of the least significant bit in the bit field.\r
5637 Range 0..63.\r
5638 @param EndBit The ordinal of the most significant bit in the bit field.\r
5639 Range 0..63.\r
5640\r
5641 @return The value read from the MSR.\r
5642\r
5643**/\r
5644UINT64\r
5645EFIAPI\r
5646AsmMsrBitFieldRead64 (\r
5647 IN UINT32 Index,\r
5648 IN UINTN StartBit,\r
5649 IN UINTN EndBit\r
5650 );\r
5651\r
5652\r
5653/**\r
5654 Writes a bit field to an MSR.\r
5655\r
5656 Writes Value to a bit field in a 64-bit MSR. The bit field is specified by\r
5657 the StartBit and the EndBit. All other bits in the destination MSR are\r
62991af2 5658 preserved. The MSR written is returned. The caller must either guarantee \r
5659 that Index and the data written is valid, or the caller must set up exception \r
5660 handlers to catch the exceptions. This function is only available on IA-32 and x64.\r
ac644614 5661\r
5662 If StartBit is greater than 63, then ASSERT().\r
5663 If EndBit is greater than 63, then ASSERT().\r
5664 If EndBit is less than StartBit, then ASSERT().\r
5665\r
5666 @param Index The 32-bit MSR index to write.\r
5667 @param StartBit The ordinal of the least significant bit in the bit field.\r
5668 Range 0..63.\r
5669 @param EndBit The ordinal of the most significant bit in the bit field.\r
5670 Range 0..63.\r
5671 @param Value New value of the bit field.\r
5672\r
5673 @return The value written back to the MSR.\r
5674\r
5675**/\r
5676UINT64\r
5677EFIAPI\r
5678AsmMsrBitFieldWrite64 (\r
5679 IN UINT32 Index,\r
5680 IN UINTN StartBit,\r
5681 IN UINTN EndBit,\r
5682 IN UINT64 Value\r
5683 );\r
5684\r
5685\r
5686/**\r
62991af2 5687 Reads a bit field in a 64-bit MSR, performs a bitwise OR, and\r
ac644614 5688 writes the result back to the bit field in the 64-bit MSR.\r
5689\r
62991af2 5690 Reads the 64-bit MSR specified by Index, performs a bitwise OR\r
ac644614 5691 between the read result and the value specified by OrData, and writes the\r
5692 result to the 64-bit MSR specified by Index. The value written to the MSR is\r
5693 returned. Extra left bits in OrData are stripped. The caller must either\r
5694 guarantee that Index and the data written is valid, or the caller must set up\r
5695 exception handlers to catch the exceptions. This function is only available\r
030cd1a2 5696 on IA-32 and x64.\r
ac644614 5697\r
5698 If StartBit is greater than 63, then ASSERT().\r
5699 If EndBit is greater than 63, then ASSERT().\r
5700 If EndBit is less than StartBit, then ASSERT().\r
5701\r
5702 @param Index The 32-bit MSR index to write.\r
5703 @param StartBit The ordinal of the least significant bit in the bit field.\r
5704 Range 0..63.\r
5705 @param EndBit The ordinal of the most significant bit in the bit field.\r
5706 Range 0..63.\r
5707 @param OrData The value to OR with the read value from the bit field.\r
5708\r
5709 @return The value written back to the MSR.\r
5710\r
5711**/\r
5712UINT64\r
5713EFIAPI\r
5714AsmMsrBitFieldOr64 (\r
5715 IN UINT32 Index,\r
5716 IN UINTN StartBit,\r
5717 IN UINTN EndBit,\r
5718 IN UINT64 OrData\r
5719 );\r
5720\r
5721\r
5722/**\r
5723 Reads a bit field in a 64-bit MSR, performs a bitwise AND, and writes the\r
5724 result back to the bit field in the 64-bit MSR.\r
5725\r
5726 Reads the 64-bit MSR specified by Index, performs a bitwise AND between the\r
5727 read result and the value specified by AndData, and writes the result to the\r
5728 64-bit MSR specified by Index. The value written to the MSR is returned.\r
5729 Extra left bits in AndData are stripped. The caller must either guarantee\r
5730 that Index and the data written is valid, or the caller must set up exception\r
5731 handlers to catch the exceptions. This function is only available on IA-32\r
030cd1a2 5732 and x64.\r
ac644614 5733\r
5734 If StartBit is greater than 63, then ASSERT().\r
5735 If EndBit is greater than 63, then ASSERT().\r
5736 If EndBit is less than StartBit, then ASSERT().\r
5737\r
5738 @param Index The 32-bit MSR index to write.\r
5739 @param StartBit The ordinal of the least significant bit in the bit field.\r
5740 Range 0..63.\r
5741 @param EndBit The ordinal of the most significant bit in the bit field.\r
5742 Range 0..63.\r
5743 @param AndData The value to AND with the read value from the bit field.\r
5744\r
5745 @return The value written back to the MSR.\r
5746\r
5747**/\r
5748UINT64\r
5749EFIAPI\r
5750AsmMsrBitFieldAnd64 (\r
5751 IN UINT32 Index,\r
5752 IN UINTN StartBit,\r
5753 IN UINTN EndBit,\r
5754 IN UINT64 AndData\r
5755 );\r
5756\r
5757\r
5758/**\r
5759 Reads a bit field in a 64-bit MSR, performs a bitwise AND followed by a\r
62991af2 5760 bitwise OR, and writes the result back to the bit field in the\r
ac644614 5761 64-bit MSR.\r
5762\r
5763 Reads the 64-bit MSR specified by Index, performs a bitwise AND followed by\r
62991af2 5764 a bitwise OR between the read result and the value specified by\r
ac644614 5765 AndData, and writes the result to the 64-bit MSR specified by Index. The\r
5766 value written to the MSR is returned. Extra left bits in both AndData and\r
5767 OrData are stripped. The caller must either guarantee that Index and the data\r
5768 written is valid, or the caller must set up exception handlers to catch the\r
030cd1a2 5769 exceptions. This function is only available on IA-32 and x64.\r
ac644614 5770\r
5771 If StartBit is greater than 63, then ASSERT().\r
5772 If EndBit is greater than 63, then ASSERT().\r
5773 If EndBit is less than StartBit, then ASSERT().\r
5774\r
5775 @param Index The 32-bit MSR index to write.\r
5776 @param StartBit The ordinal of the least significant bit in the bit field.\r
5777 Range 0..63.\r
5778 @param EndBit The ordinal of the most significant bit in the bit field.\r
5779 Range 0..63.\r
5780 @param AndData The value to AND with the read value from the bit field.\r
5781 @param OrData The value to OR with the result of the AND operation.\r
5782\r
5783 @return The value written back to the MSR.\r
5784\r
5785**/\r
5786UINT64\r
5787EFIAPI\r
5788AsmMsrBitFieldAndThenOr64 (\r
5789 IN UINT32 Index,\r
5790 IN UINTN StartBit,\r
5791 IN UINTN EndBit,\r
5792 IN UINT64 AndData,\r
5793 IN UINT64 OrData\r
5794 );\r
5795\r
5796\r
5797/**\r
5798 Reads the current value of the EFLAGS register.\r
5799\r
5800 Reads and returns the current value of the EFLAGS register. This function is\r
030cd1a2 5801 only available on IA-32 and x64. This returns a 32-bit value on IA-32 and a\r
5802 64-bit value on x64.\r
ac644614 5803\r
030cd1a2 5804 @return EFLAGS on IA-32 or RFLAGS on x64.\r
ac644614 5805\r
5806**/\r
5807UINTN\r
5808EFIAPI\r
5809AsmReadEflags (\r
5810 VOID\r
5811 );\r
5812\r
5813\r
5814/**\r
5815 Reads the current value of the Control Register 0 (CR0).\r
5816\r
5817 Reads and returns the current value of CR0. This function is only available\r
030cd1a2 5818 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on\r
5819 x64.\r
ac644614 5820\r
5821 @return The value of the Control Register 0 (CR0).\r
5822\r
5823**/\r
5824UINTN\r
5825EFIAPI\r
5826AsmReadCr0 (\r
5827 VOID\r
5828 );\r
5829\r
5830\r
5831/**\r
5832 Reads the current value of the Control Register 2 (CR2).\r
5833\r
5834 Reads and returns the current value of CR2. This function is only available\r
030cd1a2 5835 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on\r
5836 x64.\r
ac644614 5837\r
5838 @return The value of the Control Register 2 (CR2).\r
5839\r
5840**/\r
5841UINTN\r
5842EFIAPI\r
5843AsmReadCr2 (\r
5844 VOID\r
5845 );\r
5846\r
5847\r
5848/**\r
5849 Reads the current value of the Control Register 3 (CR3).\r
5850\r
5851 Reads and returns the current value of CR3. This function is only available\r
030cd1a2 5852 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on\r
5853 x64.\r
ac644614 5854\r
5855 @return The value of the Control Register 3 (CR3).\r
5856\r
5857**/\r
5858UINTN\r
5859EFIAPI\r
5860AsmReadCr3 (\r
5861 VOID\r
5862 );\r
5863\r
5864\r
5865/**\r
5866 Reads the current value of the Control Register 4 (CR4).\r
5867\r
5868 Reads and returns the current value of CR4. This function is only available\r
030cd1a2 5869 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on\r
5870 x64.\r
ac644614 5871\r
5872 @return The value of the Control Register 4 (CR4).\r
5873\r
5874**/\r
5875UINTN\r
5876EFIAPI\r
5877AsmReadCr4 (\r
5878 VOID\r
5879 );\r
5880\r
5881\r
5882/**\r
5883 Writes a value to Control Register 0 (CR0).\r
5884\r
5885 Writes and returns a new value to CR0. This function is only available on\r
030cd1a2 5886 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.\r
ac644614 5887\r
5888 @param Cr0 The value to write to CR0.\r
5889\r
5890 @return The value written to CR0.\r
5891\r
5892**/\r
5893UINTN\r
5894EFIAPI\r
5895AsmWriteCr0 (\r
5896 UINTN Cr0\r
5897 );\r
5898\r
5899\r
5900/**\r
5901 Writes a value to Control Register 2 (CR2).\r
5902\r
5903 Writes and returns a new value to CR2. This function is only available on\r
030cd1a2 5904 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.\r
ac644614 5905\r
5906 @param Cr2 The value to write to CR2.\r
5907\r
5908 @return The value written to CR2.\r
5909\r
5910**/\r
5911UINTN\r
5912EFIAPI\r
5913AsmWriteCr2 (\r
5914 UINTN Cr2\r
5915 );\r
5916\r
5917\r
5918/**\r
5919 Writes a value to Control Register 3 (CR3).\r
5920\r
5921 Writes and returns a new value to CR3. This function is only available on\r
030cd1a2 5922 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.\r
ac644614 5923\r
5924 @param Cr3 The value to write to CR3.\r
5925\r
5926 @return The value written to CR3.\r
5927\r
5928**/\r
5929UINTN\r
5930EFIAPI\r
5931AsmWriteCr3 (\r
5932 UINTN Cr3\r
5933 );\r
5934\r
5935\r
5936/**\r
5937 Writes a value to Control Register 4 (CR4).\r
5938\r
5939 Writes and returns a new value to CR4. This function is only available on\r
030cd1a2 5940 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.\r
ac644614 5941\r
5942 @param Cr4 The value to write to CR4.\r
5943\r
5944 @return The value written to CR4.\r
5945\r
5946**/\r
5947UINTN\r
5948EFIAPI\r
5949AsmWriteCr4 (\r
5950 UINTN Cr4\r
5951 );\r
5952\r
5953\r
5954/**\r
5955 Reads the current value of Debug Register 0 (DR0).\r
5956\r
5957 Reads and returns the current value of DR0. This function is only available\r
030cd1a2 5958 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on\r
5959 x64.\r
ac644614 5960\r
5961 @return The value of Debug Register 0 (DR0).\r
5962\r
5963**/\r
5964UINTN\r
5965EFIAPI\r
5966AsmReadDr0 (\r
5967 VOID\r
5968 );\r
5969\r
5970\r
5971/**\r
5972 Reads the current value of Debug Register 1 (DR1).\r
5973\r
5974 Reads and returns the current value of DR1. This function is only available\r
030cd1a2 5975 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on\r
5976 x64.\r
ac644614 5977\r
5978 @return The value of Debug Register 1 (DR1).\r
5979\r
5980**/\r
5981UINTN\r
5982EFIAPI\r
5983AsmReadDr1 (\r
5984 VOID\r
5985 );\r
5986\r
5987\r
5988/**\r
5989 Reads the current value of Debug Register 2 (DR2).\r
5990\r
5991 Reads and returns the current value of DR2. This function is only available\r
030cd1a2 5992 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on\r
5993 x64.\r
ac644614 5994\r
5995 @return The value of Debug Register 2 (DR2).\r
5996\r
5997**/\r
5998UINTN\r
5999EFIAPI\r
6000AsmReadDr2 (\r
6001 VOID\r
6002 );\r
6003\r
6004\r
6005/**\r
6006 Reads the current value of Debug Register 3 (DR3).\r
6007\r
6008 Reads and returns the current value of DR3. This function is only available\r
030cd1a2 6009 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on\r
6010 x64.\r
ac644614 6011\r
6012 @return The value of Debug Register 3 (DR3).\r
6013\r
6014**/\r
6015UINTN\r
6016EFIAPI\r
6017AsmReadDr3 (\r
6018 VOID\r
6019 );\r
6020\r
6021\r
6022/**\r
6023 Reads the current value of Debug Register 4 (DR4).\r
6024\r
6025 Reads and returns the current value of DR4. This function is only available\r
030cd1a2 6026 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on\r
6027 x64.\r
ac644614 6028\r
6029 @return The value of Debug Register 4 (DR4).\r
6030\r
6031**/\r
6032UINTN\r
6033EFIAPI\r
6034AsmReadDr4 (\r
6035 VOID\r
6036 );\r
6037\r
6038\r
6039/**\r
6040 Reads the current value of Debug Register 5 (DR5).\r
6041\r
6042 Reads and returns the current value of DR5. This function is only available\r
030cd1a2 6043 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on\r
6044 x64.\r
ac644614 6045\r
6046 @return The value of Debug Register 5 (DR5).\r
6047\r
6048**/\r
6049UINTN\r
6050EFIAPI\r
6051AsmReadDr5 (\r
6052 VOID\r
6053 );\r
6054\r
6055\r
6056/**\r
6057 Reads the current value of Debug Register 6 (DR6).\r
6058\r
6059 Reads and returns the current value of DR6. This function is only available\r
030cd1a2 6060 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on\r
6061 x64.\r
ac644614 6062\r
6063 @return The value of Debug Register 6 (DR6).\r
6064\r
6065**/\r
6066UINTN\r
6067EFIAPI\r
6068AsmReadDr6 (\r
6069 VOID\r
6070 );\r
6071\r
6072\r
6073/**\r
6074 Reads the current value of Debug Register 7 (DR7).\r
6075\r
6076 Reads and returns the current value of DR7. This function is only available\r
030cd1a2 6077 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on\r
6078 x64.\r
ac644614 6079\r
6080 @return The value of Debug Register 7 (DR7).\r
6081\r
6082**/\r
6083UINTN\r
6084EFIAPI\r
6085AsmReadDr7 (\r
6086 VOID\r
6087 );\r
6088\r
6089\r
6090/**\r
6091 Writes a value to Debug Register 0 (DR0).\r
6092\r
6093 Writes and returns a new value to DR0. This function is only available on\r
030cd1a2 6094 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.\r
ac644614 6095\r
6096 @param Dr0 The value to write to Dr0.\r
6097\r
6098 @return The value written to Debug Register 0 (DR0).\r
6099\r
6100**/\r
6101UINTN\r
6102EFIAPI\r
6103AsmWriteDr0 (\r
6104 UINTN Dr0\r
6105 );\r
6106\r
6107\r
6108/**\r
6109 Writes a value to Debug Register 1 (DR1).\r
6110\r
6111 Writes and returns a new value to DR1. This function is only available on\r
030cd1a2 6112 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.\r
ac644614 6113\r
6114 @param Dr1 The value to write to Dr1.\r
6115\r
6116 @return The value written to Debug Register 1 (DR1).\r
6117\r
6118**/\r
6119UINTN\r
6120EFIAPI\r
6121AsmWriteDr1 (\r
6122 UINTN Dr1\r
6123 );\r
6124\r
6125\r
6126/**\r
6127 Writes a value to Debug Register 2 (DR2).\r
6128\r
6129 Writes and returns a new value to DR2. This function is only available on\r
030cd1a2 6130 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.\r
ac644614 6131\r
6132 @param Dr2 The value to write to Dr2.\r
6133\r
6134 @return The value written to Debug Register 2 (DR2).\r
6135\r
6136**/\r
6137UINTN\r
6138EFIAPI\r
6139AsmWriteDr2 (\r
6140 UINTN Dr2\r
6141 );\r
6142\r
6143\r
6144/**\r
6145 Writes a value to Debug Register 3 (DR3).\r
6146\r
6147 Writes and returns a new value to DR3. This function is only available on\r
030cd1a2 6148 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.\r
ac644614 6149\r
6150 @param Dr3 The value to write to Dr3.\r
6151\r
6152 @return The value written to Debug Register 3 (DR3).\r
6153\r
6154**/\r
6155UINTN\r
6156EFIAPI\r
6157AsmWriteDr3 (\r
6158 UINTN Dr3\r
6159 );\r
6160\r
6161\r
6162/**\r
6163 Writes a value to Debug Register 4 (DR4).\r
6164\r
6165 Writes and returns a new value to DR4. This function is only available on\r
030cd1a2 6166 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.\r
ac644614 6167\r
6168 @param Dr4 The value to write to Dr4.\r
6169\r
6170 @return The value written to Debug Register 4 (DR4).\r
6171\r
6172**/\r
6173UINTN\r
6174EFIAPI\r
6175AsmWriteDr4 (\r
6176 UINTN Dr4\r
6177 );\r
6178\r
6179\r
6180/**\r
6181 Writes a value to Debug Register 5 (DR5).\r
6182\r
6183 Writes and returns a new value to DR5. This function is only available on\r
030cd1a2 6184 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.\r
ac644614 6185\r
6186 @param Dr5 The value to write to Dr5.\r
6187\r
6188 @return The value written to Debug Register 5 (DR5).\r
6189\r
6190**/\r
6191UINTN\r
6192EFIAPI\r
6193AsmWriteDr5 (\r
6194 UINTN Dr5\r
6195 );\r
6196\r
6197\r
6198/**\r
6199 Writes a value to Debug Register 6 (DR6).\r
6200\r
6201 Writes and returns a new value to DR6. This function is only available on\r
030cd1a2 6202 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.\r
ac644614 6203\r
6204 @param Dr6 The value to write to Dr6.\r
6205\r
6206 @return The value written to Debug Register 6 (DR6).\r
6207\r
6208**/\r
6209UINTN\r
6210EFIAPI\r
6211AsmWriteDr6 (\r
6212 UINTN Dr6\r
6213 );\r
6214\r
6215\r
6216/**\r
6217 Writes a value to Debug Register 7 (DR7).\r
6218\r
6219 Writes and returns a new value to DR7. This function is only available on\r
030cd1a2 6220 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.\r
ac644614 6221\r
6222 @param Dr7 The value to write to Dr7.\r
6223\r
6224 @return The value written to Debug Register 7 (DR7).\r
6225\r
6226**/\r
6227UINTN\r
6228EFIAPI\r
6229AsmWriteDr7 (\r
6230 UINTN Dr7\r
6231 );\r
6232\r
6233\r
6234/**\r
6235 Reads the current value of Code Segment Register (CS).\r
6236\r
6237 Reads and returns the current value of CS. This function is only available on\r
030cd1a2 6238 IA-32 and x64.\r
ac644614 6239\r
6240 @return The current value of CS.\r
6241\r
6242**/\r
6243UINT16\r
6244EFIAPI\r
6245AsmReadCs (\r
6246 VOID\r
6247 );\r
6248\r
6249\r
6250/**\r
6251 Reads the current value of Data Segment Register (DS).\r
6252\r
6253 Reads and returns the current value of DS. This function is only available on\r
030cd1a2 6254 IA-32 and x64.\r
ac644614 6255\r
6256 @return The current value of DS.\r
6257\r
6258**/\r
6259UINT16\r
6260EFIAPI\r
6261AsmReadDs (\r
6262 VOID\r
6263 );\r
6264\r
6265\r
6266/**\r
6267 Reads the current value of Extra Segment Register (ES).\r
6268\r
6269 Reads and returns the current value of ES. This function is only available on\r
030cd1a2 6270 IA-32 and x64.\r
ac644614 6271\r
6272 @return The current value of ES.\r
6273\r
6274**/\r
6275UINT16\r
6276EFIAPI\r
6277AsmReadEs (\r
6278 VOID\r
6279 );\r
6280\r
6281\r
6282/**\r
6283 Reads the current value of FS Data Segment Register (FS).\r
6284\r
6285 Reads and returns the current value of FS. This function is only available on\r
030cd1a2 6286 IA-32 and x64.\r
ac644614 6287\r
6288 @return The current value of FS.\r
6289\r
6290**/\r
6291UINT16\r
6292EFIAPI\r
6293AsmReadFs (\r
6294 VOID\r
6295 );\r
6296\r
6297\r
6298/**\r
6299 Reads the current value of GS Data Segment Register (GS).\r
6300\r
6301 Reads and returns the current value of GS. This function is only available on\r
030cd1a2 6302 IA-32 and x64.\r
ac644614 6303\r
6304 @return The current value of GS.\r
6305\r
6306**/\r
6307UINT16\r
6308EFIAPI\r
6309AsmReadGs (\r
6310 VOID\r
6311 );\r
6312\r
6313\r
6314/**\r
6315 Reads the current value of Stack Segment Register (SS).\r
6316\r
6317 Reads and returns the current value of SS. This function is only available on\r
030cd1a2 6318 IA-32 and x64.\r
ac644614 6319\r
6320 @return The current value of SS.\r
6321\r
6322**/\r
6323UINT16\r
6324EFIAPI\r
6325AsmReadSs (\r
6326 VOID\r
6327 );\r
6328\r
6329\r
6330/**\r
6331 Reads the current value of Task Register (TR).\r
6332\r
6333 Reads and returns the current value of TR. This function is only available on\r
030cd1a2 6334 IA-32 and x64.\r
ac644614 6335\r
6336 @return The current value of TR.\r
6337\r
6338**/\r
6339UINT16\r
6340EFIAPI\r
6341AsmReadTr (\r
6342 VOID\r
6343 );\r
6344\r
6345\r
6346/**\r
6347 Reads the current Global Descriptor Table Register(GDTR) descriptor.\r
6348\r
6349 Reads and returns the current GDTR descriptor and returns it in Gdtr. This\r
030cd1a2 6350 function is only available on IA-32 and x64.\r
ac644614 6351\r
6352 If Gdtr is NULL, then ASSERT().\r
6353\r
af2dc6a7 6354 @param Gdtr The pointer to a GDTR descriptor.\r
ac644614 6355\r
6356**/\r
6357VOID\r
6358EFIAPI\r
6359AsmReadGdtr (\r
6360 OUT IA32_DESCRIPTOR *Gdtr\r
6361 );\r
6362\r
6363\r
6364/**\r
6365 Writes the current Global Descriptor Table Register (GDTR) descriptor.\r
6366\r
6367 Writes and the current GDTR descriptor specified by Gdtr. This function is\r
030cd1a2 6368 only available on IA-32 and x64.\r
ac644614 6369\r
6370 If Gdtr is NULL, then ASSERT().\r
6371\r
af2dc6a7 6372 @param Gdtr The pointer to a GDTR descriptor.\r
ac644614 6373\r
6374**/\r
6375VOID\r
6376EFIAPI\r
6377AsmWriteGdtr (\r
6378 IN CONST IA32_DESCRIPTOR *Gdtr\r
6379 );\r
6380\r
6381\r
6382/**\r
17f695ed 6383 Reads the current Interrupt Descriptor Table Register(IDTR) descriptor.\r
ac644614 6384\r
6385 Reads and returns the current IDTR descriptor and returns it in Idtr. This\r
030cd1a2 6386 function is only available on IA-32 and x64.\r
ac644614 6387\r
6388 If Idtr is NULL, then ASSERT().\r
6389\r
af2dc6a7 6390 @param Idtr The pointer to a IDTR descriptor.\r
ac644614 6391\r
6392**/\r
6393VOID\r
6394EFIAPI\r
6395AsmReadIdtr (\r
6396 OUT IA32_DESCRIPTOR *Idtr\r
6397 );\r
6398\r
6399\r
6400/**\r
17f695ed 6401 Writes the current Interrupt Descriptor Table Register(IDTR) descriptor.\r
ac644614 6402\r
6403 Writes the current IDTR descriptor and returns it in Idtr. This function is\r
030cd1a2 6404 only available on IA-32 and x64.\r
ac644614 6405\r
6406 If Idtr is NULL, then ASSERT().\r
6407\r
af2dc6a7 6408 @param Idtr The pointer to a IDTR descriptor.\r
ac644614 6409\r
6410**/\r
6411VOID\r
6412EFIAPI\r
6413AsmWriteIdtr (\r
6414 IN CONST IA32_DESCRIPTOR *Idtr\r
6415 );\r
6416\r
6417\r
6418/**\r
6419 Reads the current Local Descriptor Table Register(LDTR) selector.\r
6420\r
6421 Reads and returns the current 16-bit LDTR descriptor value. This function is\r
030cd1a2 6422 only available on IA-32 and x64.\r
ac644614 6423\r
6424 @return The current selector of LDT.\r
6425\r
6426**/\r
6427UINT16\r
6428EFIAPI\r
6429AsmReadLdtr (\r
6430 VOID\r
6431 );\r
6432\r
6433\r
6434/**\r
17f695ed 6435 Writes the current Local Descriptor Table Register (LDTR) selector.\r
ac644614 6436\r
6437 Writes and the current LDTR descriptor specified by Ldtr. This function is\r
030cd1a2 6438 only available on IA-32 and x64.\r
ac644614 6439\r
6440 @param Ldtr 16-bit LDTR selector value.\r
6441\r
6442**/\r
6443VOID\r
6444EFIAPI\r
6445AsmWriteLdtr (\r
6446 IN UINT16 Ldtr\r
6447 );\r
6448\r
6449\r
6450/**\r
6451 Save the current floating point/SSE/SSE2 context to a buffer.\r
6452\r
6453 Saves the current floating point/SSE/SSE2 state to the buffer specified by\r
6454 Buffer. Buffer must be aligned on a 16-byte boundary. This function is only\r
030cd1a2 6455 available on IA-32 and x64.\r
ac644614 6456\r
6457 If Buffer is NULL, then ASSERT().\r
6458 If Buffer is not aligned on a 16-byte boundary, then ASSERT().\r
6459\r
af2dc6a7 6460 @param Buffer The pointer to a buffer to save the floating point/SSE/SSE2 context.\r
ac644614 6461\r
6462**/\r
6463VOID\r
6464EFIAPI\r
6465AsmFxSave (\r
6466 OUT IA32_FX_BUFFER *Buffer\r
6467 );\r
6468\r
6469\r
6470/**\r
6471 Restores the current floating point/SSE/SSE2 context from a buffer.\r
6472\r
6473 Restores the current floating point/SSE/SSE2 state from the buffer specified\r
6474 by Buffer. Buffer must be aligned on a 16-byte boundary. This function is\r
030cd1a2 6475 only available on IA-32 and x64.\r
ac644614 6476\r
6477 If Buffer is NULL, then ASSERT().\r
6478 If Buffer is not aligned on a 16-byte boundary, then ASSERT().\r
6479 If Buffer was not saved with AsmFxSave(), then ASSERT().\r
6480\r
af2dc6a7 6481 @param Buffer The pointer to a buffer to save the floating point/SSE/SSE2 context.\r
ac644614 6482\r
6483**/\r
6484VOID\r
6485EFIAPI\r
6486AsmFxRestore (\r
6487 IN CONST IA32_FX_BUFFER *Buffer\r
6488 );\r
6489\r
6490\r
6491/**\r
6492 Reads the current value of 64-bit MMX Register #0 (MM0).\r
6493\r
6494 Reads and returns the current value of MM0. This function is only available\r
030cd1a2 6495 on IA-32 and x64.\r
ac644614 6496\r
6497 @return The current value of MM0.\r
6498\r
6499**/\r
6500UINT64\r
6501EFIAPI\r
6502AsmReadMm0 (\r
6503 VOID\r
6504 );\r
6505\r
6506\r
6507/**\r
6508 Reads the current value of 64-bit MMX Register #1 (MM1).\r
6509\r
6510 Reads and returns the current value of MM1. This function is only available\r
030cd1a2 6511 on IA-32 and x64.\r
ac644614 6512\r
6513 @return The current value of MM1.\r
6514\r
6515**/\r
6516UINT64\r
6517EFIAPI\r
6518AsmReadMm1 (\r
6519 VOID\r
6520 );\r
6521\r
6522\r
6523/**\r
6524 Reads the current value of 64-bit MMX Register #2 (MM2).\r
6525\r
6526 Reads and returns the current value of MM2. This function is only available\r
030cd1a2 6527 on IA-32 and x64.\r
ac644614 6528\r
6529 @return The current value of MM2.\r
6530\r
6531**/\r
6532UINT64\r
6533EFIAPI\r
6534AsmReadMm2 (\r
6535 VOID\r
6536 );\r
6537\r
6538\r
6539/**\r
6540 Reads the current value of 64-bit MMX Register #3 (MM3).\r
6541\r
6542 Reads and returns the current value of MM3. This function is only available\r
030cd1a2 6543 on IA-32 and x64.\r
ac644614 6544\r
6545 @return The current value of MM3.\r
6546\r
6547**/\r
6548UINT64\r
6549EFIAPI\r
6550AsmReadMm3 (\r
6551 VOID\r
6552 );\r
6553\r
6554\r
6555/**\r
6556 Reads the current value of 64-bit MMX Register #4 (MM4).\r
6557\r
6558 Reads and returns the current value of MM4. This function is only available\r
030cd1a2 6559 on IA-32 and x64.\r
ac644614 6560\r
6561 @return The current value of MM4.\r
6562\r
6563**/\r
6564UINT64\r
6565EFIAPI\r
6566AsmReadMm4 (\r
6567 VOID\r
6568 );\r
6569\r
6570\r
6571/**\r
6572 Reads the current value of 64-bit MMX Register #5 (MM5).\r
6573\r
6574 Reads and returns the current value of MM5. This function is only available\r
030cd1a2 6575 on IA-32 and x64.\r
ac644614 6576\r
6577 @return The current value of MM5.\r
6578\r
6579**/\r
6580UINT64\r
6581EFIAPI\r
6582AsmReadMm5 (\r
6583 VOID\r
6584 );\r
6585\r
6586\r
6587/**\r
6588 Reads the current value of 64-bit MMX Register #6 (MM6).\r
6589\r
6590 Reads and returns the current value of MM6. This function is only available\r
030cd1a2 6591 on IA-32 and x64.\r
ac644614 6592\r
6593 @return The current value of MM6.\r
6594\r
6595**/\r
6596UINT64\r
6597EFIAPI\r
6598AsmReadMm6 (\r
6599 VOID\r
6600 );\r
6601\r
6602\r
6603/**\r
6604 Reads the current value of 64-bit MMX Register #7 (MM7).\r
6605\r
6606 Reads and returns the current value of MM7. This function is only available\r
030cd1a2 6607 on IA-32 and x64.\r
ac644614 6608\r
6609 @return The current value of MM7.\r
6610\r
6611**/\r
6612UINT64\r
6613EFIAPI\r
6614AsmReadMm7 (\r
6615 VOID\r
6616 );\r
6617\r
6618\r
6619/**\r
6620 Writes the current value of 64-bit MMX Register #0 (MM0).\r
6621\r
6622 Writes the current value of MM0. This function is only available on IA32 and\r
030cd1a2 6623 x64.\r
ac644614 6624\r
6625 @param Value The 64-bit value to write to MM0.\r
6626\r
6627**/\r
6628VOID\r
6629EFIAPI\r
6630AsmWriteMm0 (\r
6631 IN UINT64 Value\r
6632 );\r
6633\r
6634\r
6635/**\r
6636 Writes the current value of 64-bit MMX Register #1 (MM1).\r
6637\r
6638 Writes the current value of MM1. This function is only available on IA32 and\r
030cd1a2 6639 x64.\r
ac644614 6640\r
6641 @param Value The 64-bit value to write to MM1.\r
6642\r
6643**/\r
6644VOID\r
6645EFIAPI\r
6646AsmWriteMm1 (\r
6647 IN UINT64 Value\r
6648 );\r
6649\r
6650\r
6651/**\r
6652 Writes the current value of 64-bit MMX Register #2 (MM2).\r
6653\r
6654 Writes the current value of MM2. This function is only available on IA32 and\r
030cd1a2 6655 x64.\r
ac644614 6656\r
6657 @param Value The 64-bit value to write to MM2.\r
6658\r
6659**/\r
6660VOID\r
6661EFIAPI\r
6662AsmWriteMm2 (\r
6663 IN UINT64 Value\r
6664 );\r
6665\r
6666\r
6667/**\r
6668 Writes the current value of 64-bit MMX Register #3 (MM3).\r
6669\r
6670 Writes the current value of MM3. This function is only available on IA32 and\r
030cd1a2 6671 x64.\r
ac644614 6672\r
6673 @param Value The 64-bit value to write to MM3.\r
6674\r
6675**/\r
6676VOID\r
6677EFIAPI\r
6678AsmWriteMm3 (\r
6679 IN UINT64 Value\r
6680 );\r
6681\r
6682\r
6683/**\r
6684 Writes the current value of 64-bit MMX Register #4 (MM4).\r
6685\r
6686 Writes the current value of MM4. This function is only available on IA32 and\r
030cd1a2 6687 x64.\r
ac644614 6688\r
6689 @param Value The 64-bit value to write to MM4.\r
6690\r
6691**/\r
6692VOID\r
6693EFIAPI\r
6694AsmWriteMm4 (\r
6695 IN UINT64 Value\r
6696 );\r
6697\r
6698\r
6699/**\r
6700 Writes the current value of 64-bit MMX Register #5 (MM5).\r
6701\r
6702 Writes the current value of MM5. This function is only available on IA32 and\r
030cd1a2 6703 x64.\r
ac644614 6704\r
6705 @param Value The 64-bit value to write to MM5.\r
6706\r
6707**/\r
6708VOID\r
6709EFIAPI\r
6710AsmWriteMm5 (\r
6711 IN UINT64 Value\r
6712 );\r
6713\r
6714\r
6715/**\r
6716 Writes the current value of 64-bit MMX Register #6 (MM6).\r
6717\r
6718 Writes the current value of MM6. This function is only available on IA32 and\r
030cd1a2 6719 x64.\r
ac644614 6720\r
6721 @param Value The 64-bit value to write to MM6.\r
6722\r
6723**/\r
6724VOID\r
6725EFIAPI\r
6726AsmWriteMm6 (\r
6727 IN UINT64 Value\r
6728 );\r
6729\r
6730\r
6731/**\r
6732 Writes the current value of 64-bit MMX Register #7 (MM7).\r
6733\r
6734 Writes the current value of MM7. This function is only available on IA32 and\r
030cd1a2 6735 x64.\r
ac644614 6736\r
6737 @param Value The 64-bit value to write to MM7.\r
6738\r
6739**/\r
6740VOID\r
6741EFIAPI\r
6742AsmWriteMm7 (\r
6743 IN UINT64 Value\r
6744 );\r
6745\r
6746\r
6747/**\r
6748 Reads the current value of Time Stamp Counter (TSC).\r
6749\r
6750 Reads and returns the current value of TSC. This function is only available\r
030cd1a2 6751 on IA-32 and x64.\r
ac644614 6752\r
6753 @return The current value of TSC\r
6754\r
6755**/\r
6756UINT64\r
6757EFIAPI\r
6758AsmReadTsc (\r
6759 VOID\r
6760 );\r
6761\r
6762\r
6763/**\r
6764 Reads the current value of a Performance Counter (PMC).\r
6765\r
6766 Reads and returns the current value of performance counter specified by\r
030cd1a2 6767 Index. This function is only available on IA-32 and x64.\r
ac644614 6768\r
6769 @param Index The 32-bit Performance Counter index to read.\r
6770\r
6771 @return The value of the PMC specified by Index.\r
6772\r
6773**/\r
6774UINT64\r
6775EFIAPI\r
6776AsmReadPmc (\r
6777 IN UINT32 Index\r
6778 );\r
6779\r
6780\r
6781/**\r
6782 Sets up a monitor buffer that is used by AsmMwait().\r
6783\r
6784 Executes a MONITOR instruction with the register state specified by Eax, Ecx\r
030cd1a2 6785 and Edx. Returns Eax. This function is only available on IA-32 and x64.\r
ac644614 6786\r
6787 @param Eax The value to load into EAX or RAX before executing the MONITOR\r
6788 instruction.\r
6789 @param Ecx The value to load into ECX or RCX before executing the MONITOR\r
6790 instruction.\r
6791 @param Edx The value to load into EDX or RDX before executing the MONITOR\r
6792 instruction.\r
6793\r
6794 @return Eax\r
6795\r
6796**/\r
6797UINTN\r
6798EFIAPI\r
6799AsmMonitor (\r
6800 IN UINTN Eax,\r
6801 IN UINTN Ecx,\r
6802 IN UINTN Edx\r
6803 );\r
6804\r
6805\r
6806/**\r
6807 Executes an MWAIT instruction.\r
6808\r
6809 Executes an MWAIT instruction with the register state specified by Eax and\r
030cd1a2 6810 Ecx. Returns Eax. This function is only available on IA-32 and x64.\r
ac644614 6811\r
6812 @param Eax The value to load into EAX or RAX before executing the MONITOR\r
6813 instruction.\r
6814 @param Ecx The value to load into ECX or RCX before executing the MONITOR\r
6815 instruction.\r
6816\r
6817 @return Eax\r
6818\r
6819**/\r
6820UINTN\r
6821EFIAPI\r
6822AsmMwait (\r
6823 IN UINTN Eax,\r
6824 IN UINTN Ecx\r
6825 );\r
6826\r
6827\r
6828/**\r
6829 Executes a WBINVD instruction.\r
6830\r
6831 Executes a WBINVD instruction. This function is only available on IA-32 and\r
030cd1a2 6832 x64.\r
ac644614 6833\r
6834**/\r
6835VOID\r
6836EFIAPI\r
6837AsmWbinvd (\r
6838 VOID\r
6839 );\r
6840\r
6841\r
6842/**\r
6843 Executes a INVD instruction.\r
6844\r
6845 Executes a INVD instruction. This function is only available on IA-32 and\r
030cd1a2 6846 x64.\r
ac644614 6847\r
6848**/\r
6849VOID\r
6850EFIAPI\r
6851AsmInvd (\r
6852 VOID\r
6853 );\r
6854\r
6855\r
6856/**\r
6857 Flushes a cache line from all the instruction and data caches within the\r
6858 coherency domain of the CPU.\r
6859\r
6860 Flushed the cache line specified by LinearAddress, and returns LinearAddress.\r
030cd1a2 6861 This function is only available on IA-32 and x64.\r
ac644614 6862\r
6863 @param LinearAddress The address of the cache line to flush. If the CPU is\r
6864 in a physical addressing mode, then LinearAddress is a\r
6865 physical address. If the CPU is in a virtual\r
6866 addressing mode, then LinearAddress is a virtual\r
6867 address.\r
6868\r
af2dc6a7 6869 @return LinearAddress.\r
ac644614 6870**/\r
6871VOID *\r
6872EFIAPI\r
6873AsmFlushCacheLine (\r
6874 IN VOID *LinearAddress\r
6875 );\r
6876\r
6877\r
6878/**\r
6879 Enables the 32-bit paging mode on the CPU.\r
6880\r
6881 Enables the 32-bit paging mode on the CPU. CR0, CR3, CR4, and the page tables\r
6882 must be properly initialized prior to calling this service. This function\r
6883 assumes the current execution mode is 32-bit protected mode. This function is\r
6884 only available on IA-32. After the 32-bit paging mode is enabled, control is\r
6885 transferred to the function specified by EntryPoint using the new stack\r
6886 specified by NewStack and passing in the parameters specified by Context1 and\r
6887 Context2. Context1 and Context2 are optional and may be NULL. The function\r
6888 EntryPoint must never return.\r
6889\r
6890 If the current execution mode is not 32-bit protected mode, then ASSERT().\r
6891 If EntryPoint is NULL, then ASSERT().\r
6892 If NewStack is NULL, then ASSERT().\r
6893\r
6894 There are a number of constraints that must be followed before calling this\r
6895 function:\r
6896 1) Interrupts must be disabled.\r
6897 2) The caller must be in 32-bit protected mode with flat descriptors. This\r
6898 means all descriptors must have a base of 0 and a limit of 4GB.\r
6899 3) CR0 and CR4 must be compatible with 32-bit protected mode with flat\r
6900 descriptors.\r
6901 4) CR3 must point to valid page tables that will be used once the transition\r
6902 is complete, and those page tables must guarantee that the pages for this\r
6903 function and the stack are identity mapped.\r
6904\r
6905 @param EntryPoint A pointer to function to call with the new stack after\r
6906 paging is enabled.\r
6907 @param Context1 A pointer to the context to pass into the EntryPoint\r
6908 function as the first parameter after paging is enabled.\r
6909 @param Context2 A pointer to the context to pass into the EntryPoint\r
6910 function as the second parameter after paging is enabled.\r
6911 @param NewStack A pointer to the new stack to use for the EntryPoint\r
6912 function after paging is enabled.\r
6913\r
6914**/\r
6915VOID\r
6916EFIAPI\r
6917AsmEnablePaging32 (\r
6918 IN SWITCH_STACK_ENTRY_POINT EntryPoint,\r
6919 IN VOID *Context1, OPTIONAL\r
6920 IN VOID *Context2, OPTIONAL\r
6921 IN VOID *NewStack\r
6922 );\r
6923\r
6924\r
6925/**\r
6926 Disables the 32-bit paging mode on the CPU.\r
6927\r
6928 Disables the 32-bit paging mode on the CPU and returns to 32-bit protected\r
6929 mode. This function assumes the current execution mode is 32-paged protected\r
6930 mode. This function is only available on IA-32. After the 32-bit paging mode\r
6931 is disabled, control is transferred to the function specified by EntryPoint\r
6932 using the new stack specified by NewStack and passing in the parameters\r
6933 specified by Context1 and Context2. Context1 and Context2 are optional and\r
6934 may be NULL. The function EntryPoint must never return.\r
6935\r
6936 If the current execution mode is not 32-bit paged mode, then ASSERT().\r
6937 If EntryPoint is NULL, then ASSERT().\r
6938 If NewStack is NULL, then ASSERT().\r
6939\r
6940 There are a number of constraints that must be followed before calling this\r
6941 function:\r
6942 1) Interrupts must be disabled.\r
6943 2) The caller must be in 32-bit paged mode.\r
6944 3) CR0, CR3, and CR4 must be compatible with 32-bit paged mode.\r
6945 4) CR3 must point to valid page tables that guarantee that the pages for\r
6946 this function and the stack are identity mapped.\r
6947\r
6948 @param EntryPoint A pointer to function to call with the new stack after\r
6949 paging is disabled.\r
6950 @param Context1 A pointer to the context to pass into the EntryPoint\r
6951 function as the first parameter after paging is disabled.\r
6952 @param Context2 A pointer to the context to pass into the EntryPoint\r
6953 function as the second parameter after paging is\r
6954 disabled.\r
6955 @param NewStack A pointer to the new stack to use for the EntryPoint\r
6956 function after paging is disabled.\r
6957\r
6958**/\r
6959VOID\r
6960EFIAPI\r
6961AsmDisablePaging32 (\r
6962 IN SWITCH_STACK_ENTRY_POINT EntryPoint,\r
6963 IN VOID *Context1, OPTIONAL\r
6964 IN VOID *Context2, OPTIONAL\r
6965 IN VOID *NewStack\r
6966 );\r
6967\r
6968\r
6969/**\r
6970 Enables the 64-bit paging mode on the CPU.\r
6971\r
6972 Enables the 64-bit paging mode on the CPU. CR0, CR3, CR4, and the page tables\r
6973 must be properly initialized prior to calling this service. This function\r
6974 assumes the current execution mode is 32-bit protected mode with flat\r
6975 descriptors. This function is only available on IA-32. After the 64-bit\r
6976 paging mode is enabled, control is transferred to the function specified by\r
6977 EntryPoint using the new stack specified by NewStack and passing in the\r
6978 parameters specified by Context1 and Context2. Context1 and Context2 are\r
6979 optional and may be 0. The function EntryPoint must never return.\r
6980\r
6981 If the current execution mode is not 32-bit protected mode with flat\r
6982 descriptors, then ASSERT().\r
6983 If EntryPoint is 0, then ASSERT().\r
6984 If NewStack is 0, then ASSERT().\r
6985\r
17f695ed 6986 @param Cs The 16-bit selector to load in the CS before EntryPoint\r
ac644614 6987 is called. The descriptor in the GDT that this selector\r
6988 references must be setup for long mode.\r
6989 @param EntryPoint The 64-bit virtual address of the function to call with\r
6990 the new stack after paging is enabled.\r
6991 @param Context1 The 64-bit virtual address of the context to pass into\r
6992 the EntryPoint function as the first parameter after\r
6993 paging is enabled.\r
6994 @param Context2 The 64-bit virtual address of the context to pass into\r
6995 the EntryPoint function as the second parameter after\r
6996 paging is enabled.\r
6997 @param NewStack The 64-bit virtual address of the new stack to use for\r
6998 the EntryPoint function after paging is enabled.\r
6999\r
7000**/\r
7001VOID\r
7002EFIAPI\r
7003AsmEnablePaging64 (\r
17f695ed 7004 IN UINT16 Cs,\r
ac644614 7005 IN UINT64 EntryPoint,\r
7006 IN UINT64 Context1, OPTIONAL\r
7007 IN UINT64 Context2, OPTIONAL\r
7008 IN UINT64 NewStack\r
7009 );\r
7010\r
7011\r
7012/**\r
7013 Disables the 64-bit paging mode on the CPU.\r
7014\r
7015 Disables the 64-bit paging mode on the CPU and returns to 32-bit protected\r
7016 mode. This function assumes the current execution mode is 64-paging mode.\r
030cd1a2 7017 This function is only available on x64. After the 64-bit paging mode is\r
ac644614 7018 disabled, control is transferred to the function specified by EntryPoint\r
7019 using the new stack specified by NewStack and passing in the parameters\r
7020 specified by Context1 and Context2. Context1 and Context2 are optional and\r
7021 may be 0. The function EntryPoint must never return.\r
7022\r
7023 If the current execution mode is not 64-bit paged mode, then ASSERT().\r
7024 If EntryPoint is 0, then ASSERT().\r
7025 If NewStack is 0, then ASSERT().\r
7026\r
17f695ed 7027 @param Cs The 16-bit selector to load in the CS before EntryPoint\r
ac644614 7028 is called. The descriptor in the GDT that this selector\r
7029 references must be setup for 32-bit protected mode.\r
7030 @param EntryPoint The 64-bit virtual address of the function to call with\r
7031 the new stack after paging is disabled.\r
7032 @param Context1 The 64-bit virtual address of the context to pass into\r
7033 the EntryPoint function as the first parameter after\r
7034 paging is disabled.\r
7035 @param Context2 The 64-bit virtual address of the context to pass into\r
7036 the EntryPoint function as the second parameter after\r
7037 paging is disabled.\r
7038 @param NewStack The 64-bit virtual address of the new stack to use for\r
7039 the EntryPoint function after paging is disabled.\r
7040\r
7041**/\r
7042VOID\r
7043EFIAPI\r
7044AsmDisablePaging64 (\r
17f695ed 7045 IN UINT16 Cs,\r
ac644614 7046 IN UINT32 EntryPoint,\r
7047 IN UINT32 Context1, OPTIONAL\r
7048 IN UINT32 Context2, OPTIONAL\r
7049 IN UINT32 NewStack\r
7050 );\r
7051\r
7052\r
7053//\r
7054// 16-bit thunking services\r
7055//\r
7056\r
7057/**\r
7058 Retrieves the properties for 16-bit thunk functions.\r
7059\r
7060 Computes the size of the buffer and stack below 1MB required to use the\r
7061 AsmPrepareThunk16(), AsmThunk16() and AsmPrepareAndThunk16() functions. This\r
7062 buffer size is returned in RealModeBufferSize, and the stack size is returned\r
7063 in ExtraStackSize. If parameters are passed to the 16-bit real mode code,\r
7064 then the actual minimum stack size is ExtraStackSize plus the maximum number\r
7065 of bytes that need to be passed to the 16-bit real mode code.\r
52fa075c 7066 \r
ac644614 7067 If RealModeBufferSize is NULL, then ASSERT().\r
7068 If ExtraStackSize is NULL, then ASSERT().\r
7069\r
7070 @param RealModeBufferSize A pointer to the size of the buffer below 1MB\r
7071 required to use the 16-bit thunk functions.\r
7072 @param ExtraStackSize A pointer to the extra size of stack below 1MB\r
7073 that the 16-bit thunk functions require for\r
7074 temporary storage in the transition to and from\r
7075 16-bit real mode.\r
7076\r
7077**/\r
7078VOID\r
7079EFIAPI\r
7080AsmGetThunk16Properties (\r
7081 OUT UINT32 *RealModeBufferSize,\r
7082 OUT UINT32 *ExtraStackSize\r
7083 );\r
7084\r
7085\r
7086/**\r
7087 Prepares all structures a code required to use AsmThunk16().\r
7088\r
7089 Prepares all structures and code required to use AsmThunk16().\r
52fa075c 7090 \r
8243b089 7091 This interface is limited to be used in either physical mode or virtual modes with paging enabled where the\r
7092 virtual to physical mappings for ThunkContext.RealModeBuffer is mapped 1:1.\r
ac644614 7093\r
7094 If ThunkContext is NULL, then ASSERT().\r
7095\r
7096 @param ThunkContext A pointer to the context structure that describes the\r
7097 16-bit real mode code to call.\r
7098\r
7099**/\r
7100VOID\r
7101EFIAPI\r
7102AsmPrepareThunk16 (\r
7103 OUT THUNK_CONTEXT *ThunkContext\r
7104 );\r
7105\r
7106\r
7107/**\r
7108 Transfers control to a 16-bit real mode entry point and returns the results.\r
7109\r
7110 Transfers control to a 16-bit real mode entry point and returns the results.\r
17f695ed 7111 AsmPrepareThunk16() must be called with ThunkContext before this function is used.\r
7112 This function must be called with interrupts disabled.\r
7113\r
7114 The register state from the RealModeState field of ThunkContext is restored just prior \r
7115 to calling the 16-bit real mode entry point. This includes the EFLAGS field of RealModeState, \r
7116 which is used to set the interrupt state when a 16-bit real mode entry point is called.\r
7117 Control is transferred to the 16-bit real mode entry point specified by the CS and Eip fields of RealModeState.\r
7118 The stack is initialized to the SS and ESP fields of RealModeState. Any parameters passed to \r
7119 the 16-bit real mode code must be populated by the caller at SS:ESP prior to calling this function. \r
7120 The 16-bit real mode entry point is invoked with a 16-bit CALL FAR instruction,\r
7121 so when accessing stack contents, the 16-bit real mode code must account for the 16-bit segment \r
7122 and 16-bit offset of the return address that were pushed onto the stack. The 16-bit real mode entry \r
7123 point must exit with a RETF instruction. The register state is captured into RealModeState immediately \r
7124 after the RETF instruction is executed.\r
7125 \r
7126 If EFLAGS specifies interrupts enabled, or any of the 16-bit real mode code enables interrupts, \r
7127 or any of the 16-bit real mode code makes a SW interrupt, then the caller is responsible for making sure \r
7128 the IDT at address 0 is initialized to handle any HW or SW interrupts that may occur while in 16-bit real mode. \r
7129 \r
7130 If EFLAGS specifies interrupts enabled, or any of the 16-bit real mode code enables interrupts, \r
7131 then the caller is responsible for making sure the 8259 PIC is in a state compatible with 16-bit real mode. \r
7132 This includes the base vectors, the interrupt masks, and the edge/level trigger mode.\r
7133 \r
7134 If THUNK_ATTRIBUTE_BIG_REAL_MODE is set in the ThunkAttributes field of ThunkContext, then the user code \r
7135 is invoked in big real mode. Otherwise, the user code is invoked in 16-bit real mode with 64KB segment limits.\r
7136 \r
7137 If neither THUNK_ATTRIBUTE_DISABLE_A20_MASK_INT_15 nor THUNK_ATTRIBUTE_DISABLE_A20_MASK_KBD_CTRL are set in \r
7138 ThunkAttributes, then it is assumed that the user code did not enable the A20 mask, and no attempt is made to \r
7139 disable the A20 mask.\r
7140 \r
7141 If THUNK_ATTRIBUTE_DISABLE_A20_MASK_INT_15 is set and THUNK_ATTRIBUTE_DISABLE_A20_MASK_KBD_CTRL is clear in \r
7142 ThunkAttributes, then attempt to use the INT 15 service to disable the A20 mask. If this INT 15 call fails, \r
7143 then attempt to disable the A20 mask by directly accessing the 8042 keyboard controller I/O ports.\r
7144 \r
7145 If THUNK_ATTRIBUTE_DISABLE_A20_MASK_INT_15 is clear and THUNK_ATTRIBUTE_DISABLE_A20_MASK_KBD_CTRL is set in \r
7146 ThunkAttributes, then attempt to disable the A20 mask by directly accessing the 8042 keyboard controller I/O ports.\r
7147 \r
ac644614 7148 If ThunkContext is NULL, then ASSERT().\r
7149 If AsmPrepareThunk16() was not previously called with ThunkContext, then ASSERT().\r
17f695ed 7150 If both THUNK_ATTRIBUTE_DISABLE_A20_MASK_INT_15 and THUNK_ATTRIBUTE_DISABLE_A20_MASK_KBD_CTRL are set in \r
7151 ThunkAttributes, then ASSERT().\r
ac644614 7152\r
8243b089 7153 This interface is limited to be used in either physical mode or virtual modes with paging enabled where the\r
af2dc6a7 7154 virtual to physical mappings for ThunkContext.RealModeBuffer are mapped 1:1.\r
52fa075c 7155\r
ac644614 7156 @param ThunkContext A pointer to the context structure that describes the\r
7157 16-bit real mode code to call.\r
7158\r
7159**/\r
7160VOID\r
7161EFIAPI\r
7162AsmThunk16 (\r
7163 IN OUT THUNK_CONTEXT *ThunkContext\r
7164 );\r
7165\r
7166\r
7167/**\r
7168 Prepares all structures and code for a 16-bit real mode thunk, transfers\r
7169 control to a 16-bit real mode entry point, and returns the results.\r
7170\r
7171 Prepares all structures and code for a 16-bit real mode thunk, transfers\r
7172 control to a 16-bit real mode entry point, and returns the results. If the\r
7173 caller only need to perform a single 16-bit real mode thunk, then this\r
7174 service should be used. If the caller intends to make more than one 16-bit\r
7175 real mode thunk, then it is more efficient if AsmPrepareThunk16() is called\r
7176 once and AsmThunk16() can be called for each 16-bit real mode thunk.\r
7177\r
8243b089 7178 This interface is limited to be used in either physical mode or virtual modes with paging enabled where the\r
7179 virtual to physical mappings for ThunkContext.RealModeBuffer is mapped 1:1.\r
52fa075c 7180\r
17f695ed 7181 See AsmPrepareThunk16() and AsmThunk16() for the detailed description and ASSERT() conditions.\r
ac644614 7182\r
7183 @param ThunkContext A pointer to the context structure that describes the\r
7184 16-bit real mode code to call.\r
7185\r
7186**/\r
7187VOID\r
7188EFIAPI\r
7189AsmPrepareAndThunk16 (\r
7190 IN OUT THUNK_CONTEXT *ThunkContext\r
7191 );\r
7192\r
ac644614 7193#endif\r
e3a7917f 7194#endif\r
ac644614 7195\r
7196\r