2 Provides string functions, linked list functions, math functions, synchronization
3 functions, and CPU architecture-specific functions.
5 Copyright (c) 2006 - 2013, Intel Corporation. All rights reserved.<BR>
6 Portions copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>
7 This program and the accompanying materials
8 are licensed and made available under the terms and conditions of the BSD License
9 which accompanies this distribution. The full text of the license may be found at
10 http://opensource.org/licenses/bsd-license.php.
12 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
13 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
20 FILE_LICENCE ( BSD3 );
23 // Definitions for architecture-specific types
25 #if defined (MDE_CPU_IA32)
27 /// The IA-32 architecture context buffer used by SetJump() and LongJump().
36 } BASE_LIBRARY_JUMP_BUFFER;
38 #define BASE_LIBRARY_JUMP_BUFFER_ALIGNMENT 4
40 #endif // defined (MDE_CPU_IA32)
42 #if defined (MDE_CPU_IPF)
45 /// The Itanium architecture context buffer used by SetJump() and LongJump().
80 UINT64 AfterSpillUNAT;
86 } BASE_LIBRARY_JUMP_BUFFER;
88 #define BASE_LIBRARY_JUMP_BUFFER_ALIGNMENT 0x10
90 #endif // defined (MDE_CPU_IPF)
92 #if defined (MDE_CPU_X64)
94 /// The x64 architecture context buffer used by SetJump() and LongJump().
108 UINT8 XmmBuffer[160]; ///< XMM6-XMM15.
109 } BASE_LIBRARY_JUMP_BUFFER;
111 #define BASE_LIBRARY_JUMP_BUFFER_ALIGNMENT 8
113 #endif // defined (MDE_CPU_X64)
115 #if defined (MDE_CPU_EBC)
117 /// The EBC context buffer used by SetJump() and LongJump().
125 } BASE_LIBRARY_JUMP_BUFFER;
127 #define BASE_LIBRARY_JUMP_BUFFER_ALIGNMENT 8
129 #endif // defined (MDE_CPU_EBC)
131 #if defined (MDE_CPU_ARM)
134 UINT32 R3; ///< A copy of R13.
145 } BASE_LIBRARY_JUMP_BUFFER;
147 #define BASE_LIBRARY_JUMP_BUFFER_ALIGNMENT 4
149 #endif // defined (MDE_CPU_ARM)
151 #if defined (MDE_CPU_AARCH64)
177 } BASE_LIBRARY_JUMP_BUFFER;
179 #define BASE_LIBRARY_JUMP_BUFFER_ALIGNMENT 8
181 #endif // defined (MDE_CPU_AARCH64)
189 Copies one Null-terminated Unicode string to another Null-terminated Unicode
190 string and returns the new Unicode string.
192 This function copies the contents of the Unicode string Source to the Unicode
193 string Destination, and returns Destination. If Source and Destination
194 overlap, then the results are undefined.
196 If Destination is NULL, then ASSERT().
197 If Destination is not aligned on a 16-bit boundary, then ASSERT().
198 If Source is NULL, then ASSERT().
199 If Source is not aligned on a 16-bit boundary, then ASSERT().
200 If Source and Destination overlap, then ASSERT().
201 If PcdMaximumUnicodeStringLength is not zero, and Source contains more than
202 PcdMaximumUnicodeStringLength Unicode characters not including the
203 Null-terminator, then ASSERT().
205 @param Destination The pointer to a Null-terminated Unicode string.
206 @param Source The pointer to a Null-terminated Unicode string.
214 OUT CHAR16 *Destination,
215 IN CONST CHAR16 *Source
220 Copies up to a specified length from one Null-terminated Unicode string to
221 another Null-terminated Unicode string and returns the new Unicode string.
223 This function copies the contents of the Unicode string Source to the Unicode
224 string Destination, and returns Destination. At most, Length Unicode
225 characters are copied from Source to Destination. If Length is 0, then
226 Destination is returned unmodified. If Length is greater that the number of
227 Unicode characters in Source, then Destination is padded with Null Unicode
228 characters. If Source and Destination overlap, then the results are
231 If Length > 0 and Destination is NULL, then ASSERT().
232 If Length > 0 and Destination is not aligned on a 16-bit boundary, then ASSERT().
233 If Length > 0 and Source is NULL, then ASSERT().
234 If Length > 0 and Source is not aligned on a 16-bit boundary, then ASSERT().
235 If Source and Destination overlap, then ASSERT().
236 If PcdMaximumUnicodeStringLength is not zero, and Length is greater than
237 PcdMaximumUnicodeStringLength, then ASSERT().
238 If PcdMaximumUnicodeStringLength is not zero, and Source contains more than
239 PcdMaximumUnicodeStringLength Unicode characters, not including the Null-terminator,
242 @param Destination The pointer to a Null-terminated Unicode string.
243 @param Source The pointer to a Null-terminated Unicode string.
244 @param Length The maximum number of Unicode characters to copy.
252 OUT CHAR16 *Destination,
253 IN CONST CHAR16 *Source,
259 Returns the length of a Null-terminated Unicode string.
261 This function returns the number of Unicode characters in the Null-terminated
262 Unicode string specified by String.
264 If String is NULL, then ASSERT().
265 If String is not aligned on a 16-bit boundary, then ASSERT().
266 If PcdMaximumUnicodeStringLength is not zero, and String contains more than
267 PcdMaximumUnicodeStringLength Unicode characters not including the
268 Null-terminator, then ASSERT().
270 @param String Pointer to a Null-terminated Unicode string.
272 @return The length of String.
278 IN CONST CHAR16 *String
283 Returns the size of a Null-terminated Unicode string in bytes, including the
286 This function returns the size, in bytes, of the Null-terminated Unicode string
289 If String is NULL, then ASSERT().
290 If String is not aligned on a 16-bit boundary, then ASSERT().
291 If PcdMaximumUnicodeStringLength is not zero, and String contains more than
292 PcdMaximumUnicodeStringLength Unicode characters not including the
293 Null-terminator, then ASSERT().
295 @param String The pointer to a Null-terminated Unicode string.
297 @return The size of String.
303 IN CONST CHAR16 *String
308 Compares two Null-terminated Unicode strings, and returns the difference
309 between the first mismatched Unicode characters.
311 This function compares the Null-terminated Unicode string FirstString to the
312 Null-terminated Unicode string SecondString. If FirstString is identical to
313 SecondString, then 0 is returned. Otherwise, the value returned is the first
314 mismatched Unicode character in SecondString subtracted from the first
315 mismatched Unicode character in FirstString.
317 If FirstString is NULL, then ASSERT().
318 If FirstString is not aligned on a 16-bit boundary, then ASSERT().
319 If SecondString is NULL, then ASSERT().
320 If SecondString is not aligned on a 16-bit boundary, then ASSERT().
321 If PcdMaximumUnicodeStringLength is not zero, and FirstString contains more
322 than PcdMaximumUnicodeStringLength Unicode characters not including the
323 Null-terminator, then ASSERT().
324 If PcdMaximumUnicodeStringLength is not zero, and SecondString contains more
325 than PcdMaximumUnicodeStringLength Unicode characters, not including the
326 Null-terminator, then ASSERT().
328 @param FirstString The pointer to a Null-terminated Unicode string.
329 @param SecondString The pointer to a Null-terminated Unicode string.
331 @retval 0 FirstString is identical to SecondString.
332 @return others FirstString is not identical to SecondString.
338 IN CONST CHAR16 *FirstString,
339 IN CONST CHAR16 *SecondString
344 Compares up to a specified length the contents of two Null-terminated Unicode strings,
345 and returns the difference between the first mismatched Unicode characters.
347 This function compares the Null-terminated Unicode string FirstString to the
348 Null-terminated Unicode string SecondString. At most, Length Unicode
349 characters will be compared. If Length is 0, then 0 is returned. If
350 FirstString is identical to SecondString, then 0 is returned. Otherwise, the
351 value returned is the first mismatched Unicode character in SecondString
352 subtracted from the first mismatched Unicode character in FirstString.
354 If Length > 0 and FirstString is NULL, then ASSERT().
355 If Length > 0 and FirstString is not aligned on a 16-bit boundary, then ASSERT().
356 If Length > 0 and SecondString is NULL, then ASSERT().
357 If Length > 0 and SecondString is not aligned on a 16-bit boundary, then ASSERT().
358 If PcdMaximumUnicodeStringLength is not zero, and Length is greater than
359 PcdMaximumUnicodeStringLength, then ASSERT().
360 If PcdMaximumUnicodeStringLength is not zero, and FirstString contains more than
361 PcdMaximumUnicodeStringLength Unicode characters, not including the Null-terminator,
363 If PcdMaximumUnicodeStringLength is not zero, and SecondString contains more than
364 PcdMaximumUnicodeStringLength Unicode characters, not including the Null-terminator,
367 @param FirstString The pointer to a Null-terminated Unicode string.
368 @param SecondString The pointer to a Null-terminated Unicode string.
369 @param Length The maximum number of Unicode characters to compare.
371 @retval 0 FirstString is identical to SecondString.
372 @return others FirstString is not identical to SecondString.
378 IN CONST CHAR16 *FirstString,
379 IN CONST CHAR16 *SecondString,
385 Concatenates one Null-terminated Unicode string to another Null-terminated
386 Unicode string, and returns the concatenated Unicode string.
388 This function concatenates two Null-terminated Unicode strings. The contents
389 of Null-terminated Unicode string Source are concatenated to the end of
390 Null-terminated Unicode string Destination. The Null-terminated concatenated
391 Unicode String is returned. If Source and Destination overlap, then the
392 results are undefined.
394 If Destination is NULL, then ASSERT().
395 If Destination is not aligned on a 16-bit boundary, then ASSERT().
396 If Source is NULL, then ASSERT().
397 If Source is not aligned on a 16-bit boundary, then ASSERT().
398 If Source and Destination overlap, then ASSERT().
399 If PcdMaximumUnicodeStringLength is not zero, and Destination contains more
400 than PcdMaximumUnicodeStringLength Unicode characters, not including the
401 Null-terminator, then ASSERT().
402 If PcdMaximumUnicodeStringLength is not zero, and Source contains more than
403 PcdMaximumUnicodeStringLength Unicode characters, not including the
404 Null-terminator, then ASSERT().
405 If PcdMaximumUnicodeStringLength is not zero, and concatenating Destination
406 and Source results in a Unicode string with more than
407 PcdMaximumUnicodeStringLength Unicode characters, not including the
408 Null-terminator, then ASSERT().
410 @param Destination The pointer to a Null-terminated Unicode string.
411 @param Source The pointer to a Null-terminated Unicode string.
419 IN OUT CHAR16 *Destination,
420 IN CONST CHAR16 *Source
425 Concatenates up to a specified length one Null-terminated Unicode to the end
426 of another Null-terminated Unicode string, and returns the concatenated
429 This function concatenates two Null-terminated Unicode strings. The contents
430 of Null-terminated Unicode string Source are concatenated to the end of
431 Null-terminated Unicode string Destination, and Destination is returned. At
432 most, Length Unicode characters are concatenated from Source to the end of
433 Destination, and Destination is always Null-terminated. If Length is 0, then
434 Destination is returned unmodified. If Source and Destination overlap, then
435 the results are undefined.
437 If Destination is NULL, then ASSERT().
438 If Length > 0 and Destination is not aligned on a 16-bit boundary, then ASSERT().
439 If Length > 0 and Source is NULL, then ASSERT().
440 If Length > 0 and Source is not aligned on a 16-bit boundary, then ASSERT().
441 If Source and Destination overlap, then ASSERT().
442 If PcdMaximumUnicodeStringLength is not zero, and Length is greater than
443 PcdMaximumUnicodeStringLength, then ASSERT().
444 If PcdMaximumUnicodeStringLength is not zero, and Destination contains more
445 than PcdMaximumUnicodeStringLength Unicode characters, not including the
446 Null-terminator, then ASSERT().
447 If PcdMaximumUnicodeStringLength is not zero, and Source contains more than
448 PcdMaximumUnicodeStringLength Unicode characters, not including the
449 Null-terminator, then ASSERT().
450 If PcdMaximumUnicodeStringLength is not zero, and concatenating Destination
451 and Source results in a Unicode string with more than PcdMaximumUnicodeStringLength
452 Unicode characters, not including the Null-terminator, then ASSERT().
454 @param Destination The pointer to a Null-terminated Unicode string.
455 @param Source The pointer to a Null-terminated Unicode string.
456 @param Length The maximum number of Unicode characters to concatenate from
465 IN OUT CHAR16 *Destination,
466 IN CONST CHAR16 *Source,
471 Returns the first occurrence of a Null-terminated Unicode sub-string
472 in a Null-terminated Unicode string.
474 This function scans the contents of the Null-terminated Unicode string
475 specified by String and returns the first occurrence of SearchString.
476 If SearchString is not found in String, then NULL is returned. If
477 the length of SearchString is zero, then String is returned.
479 If String is NULL, then ASSERT().
480 If String is not aligned on a 16-bit boundary, then ASSERT().
481 If SearchString is NULL, then ASSERT().
482 If SearchString is not aligned on a 16-bit boundary, then ASSERT().
484 If PcdMaximumUnicodeStringLength is not zero, and SearchString
485 or String contains more than PcdMaximumUnicodeStringLength Unicode
486 characters, not including the Null-terminator, then ASSERT().
488 @param String The pointer to a Null-terminated Unicode string.
489 @param SearchString The pointer to a Null-terminated Unicode string to search for.
491 @retval NULL If the SearchString does not appear in String.
492 @return others If there is a match.
498 IN CONST CHAR16 *String,
499 IN CONST CHAR16 *SearchString
503 Convert a Null-terminated Unicode decimal string to a value of
506 This function returns a value of type UINTN by interpreting the contents
507 of the Unicode string specified by String as a decimal number. The format
508 of the input Unicode string String is:
510 [spaces] [decimal digits].
512 The valid decimal digit character is in the range [0-9]. The
513 function will ignore the pad space, which includes spaces or
514 tab characters, before [decimal digits]. The running zero in the
515 beginning of [decimal digits] will be ignored. Then, the function
516 stops at the first character that is a not a valid decimal character
517 or a Null-terminator, whichever one comes first.
519 If String is NULL, then ASSERT().
520 If String is not aligned in a 16-bit boundary, then ASSERT().
521 If String has only pad spaces, then 0 is returned.
522 If String has no pad spaces or valid decimal digits,
524 If the number represented by String overflows according
525 to the range defined by UINTN, then ASSERT().
527 If PcdMaximumUnicodeStringLength is not zero, and String contains
528 more than PcdMaximumUnicodeStringLength Unicode characters not including
529 the Null-terminator, then ASSERT().
531 @param String The pointer to a Null-terminated Unicode string.
533 @retval Value translated from String.
539 IN CONST CHAR16 *String
543 Convert a Null-terminated Unicode decimal string to a value of
546 This function returns a value of type UINT64 by interpreting the contents
547 of the Unicode string specified by String as a decimal number. The format
548 of the input Unicode string String is:
550 [spaces] [decimal digits].
552 The valid decimal digit character is in the range [0-9]. The
553 function will ignore the pad space, which includes spaces or
554 tab characters, before [decimal digits]. The running zero in the
555 beginning of [decimal digits] will be ignored. Then, the function
556 stops at the first character that is a not a valid decimal character
557 or a Null-terminator, whichever one comes first.
559 If String is NULL, then ASSERT().
560 If String is not aligned in a 16-bit boundary, then ASSERT().
561 If String has only pad spaces, then 0 is returned.
562 If String has no pad spaces or valid decimal digits,
564 If the number represented by String overflows according
565 to the range defined by UINT64, then ASSERT().
567 If PcdMaximumUnicodeStringLength is not zero, and String contains
568 more than PcdMaximumUnicodeStringLength Unicode characters not including
569 the Null-terminator, then ASSERT().
571 @param String The pointer to a Null-terminated Unicode string.
573 @retval Value translated from String.
579 IN CONST CHAR16 *String
584 Convert a Null-terminated Unicode hexadecimal string to a value of type UINTN.
586 This function returns a value of type UINTN by interpreting the contents
587 of the Unicode string specified by String as a hexadecimal number.
588 The format of the input Unicode string String is:
590 [spaces][zeros][x][hexadecimal digits].
592 The valid hexadecimal digit character is in the range [0-9], [a-f] and [A-F].
593 The prefix "0x" is optional. Both "x" and "X" is allowed in "0x" prefix.
594 If "x" appears in the input string, it must be prefixed with at least one 0.
595 The function will ignore the pad space, which includes spaces or tab characters,
596 before [zeros], [x] or [hexadecimal digit]. The running zero before [x] or
597 [hexadecimal digit] will be ignored. Then, the decoding starts after [x] or the
598 first valid hexadecimal digit. Then, the function stops at the first character
599 that is a not a valid hexadecimal character or NULL, whichever one comes first.
601 If String is NULL, then ASSERT().
602 If String is not aligned in a 16-bit boundary, then ASSERT().
603 If String has only pad spaces, then zero is returned.
604 If String has no leading pad spaces, leading zeros or valid hexadecimal digits,
605 then zero is returned.
606 If the number represented by String overflows according to the range defined by
607 UINTN, then ASSERT().
609 If PcdMaximumUnicodeStringLength is not zero, and String contains more than
610 PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator,
613 @param String The pointer to a Null-terminated Unicode string.
615 @retval Value translated from String.
621 IN CONST CHAR16 *String
626 Convert a Null-terminated Unicode hexadecimal string to a value of type UINT64.
628 This function returns a value of type UINT64 by interpreting the contents
629 of the Unicode string specified by String as a hexadecimal number.
630 The format of the input Unicode string String is
632 [spaces][zeros][x][hexadecimal digits].
634 The valid hexadecimal digit character is in the range [0-9], [a-f] and [A-F].
635 The prefix "0x" is optional. Both "x" and "X" is allowed in "0x" prefix.
636 If "x" appears in the input string, it must be prefixed with at least one 0.
637 The function will ignore the pad space, which includes spaces or tab characters,
638 before [zeros], [x] or [hexadecimal digit]. The running zero before [x] or
639 [hexadecimal digit] will be ignored. Then, the decoding starts after [x] or the
640 first valid hexadecimal digit. Then, the function stops at the first character that is
641 a not a valid hexadecimal character or NULL, whichever one comes first.
643 If String is NULL, then ASSERT().
644 If String is not aligned in a 16-bit boundary, then ASSERT().
645 If String has only pad spaces, then zero is returned.
646 If String has no leading pad spaces, leading zeros or valid hexadecimal digits,
647 then zero is returned.
648 If the number represented by String overflows according to the range defined by
649 UINT64, then ASSERT().
651 If PcdMaximumUnicodeStringLength is not zero, and String contains more than
652 PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator,
655 @param String The pointer to a Null-terminated Unicode string.
657 @retval Value translated from String.
663 IN CONST CHAR16 *String
667 Convert a Null-terminated Unicode string to a Null-terminated
668 ASCII string and returns the ASCII string.
670 This function converts the content of the Unicode string Source
671 to the ASCII string Destination by copying the lower 8 bits of
672 each Unicode character. It returns Destination.
674 The caller is responsible to make sure Destination points to a buffer with size
675 equal or greater than ((StrLen (Source) + 1) * sizeof (CHAR8)) in bytes.
677 If any Unicode characters in Source contain non-zero value in
678 the upper 8 bits, then ASSERT().
680 If Destination is NULL, then ASSERT().
681 If Source is NULL, then ASSERT().
682 If Source is not aligned on a 16-bit boundary, then ASSERT().
683 If Source and Destination overlap, then ASSERT().
685 If PcdMaximumUnicodeStringLength is not zero, and Source contains
686 more than PcdMaximumUnicodeStringLength Unicode characters not including
687 the Null-terminator, then ASSERT().
689 If PcdMaximumAsciiStringLength is not zero, and Source contains more
690 than PcdMaximumAsciiStringLength Unicode characters not including the
691 Null-terminator, then ASSERT().
693 @param Source The pointer to a Null-terminated Unicode string.
694 @param Destination The pointer to a Null-terminated ASCII string.
701 UnicodeStrToAsciiStr (
702 IN CONST CHAR16 *Source,
703 OUT CHAR8 *Destination
708 Copies one Null-terminated ASCII string to another Null-terminated ASCII
709 string and returns the new ASCII string.
711 This function copies the contents of the ASCII string Source to the ASCII
712 string Destination, and returns Destination. If Source and Destination
713 overlap, then the results are undefined.
715 If Destination is NULL, then ASSERT().
716 If Source is NULL, then ASSERT().
717 If Source and Destination overlap, then ASSERT().
718 If PcdMaximumAsciiStringLength is not zero and Source contains more than
719 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
722 @param Destination The pointer to a Null-terminated ASCII string.
723 @param Source The pointer to a Null-terminated ASCII string.
731 OUT CHAR8 *Destination,
732 IN CONST CHAR8 *Source
737 Copies up to a specified length one Null-terminated ASCII string to another
738 Null-terminated ASCII string and returns the new ASCII string.
740 This function copies the contents of the ASCII string Source to the ASCII
741 string Destination, and returns Destination. At most, Length ASCII characters
742 are copied from Source to Destination. If Length is 0, then Destination is
743 returned unmodified. If Length is greater that the number of ASCII characters
744 in Source, then Destination is padded with Null ASCII characters. If Source
745 and Destination overlap, then the results are undefined.
747 If Destination is NULL, then ASSERT().
748 If Source is NULL, then ASSERT().
749 If Source and Destination overlap, then ASSERT().
750 If PcdMaximumAsciiStringLength is not zero, and Length is greater than
751 PcdMaximumAsciiStringLength, then ASSERT().
752 If PcdMaximumAsciiStringLength is not zero, and Source contains more than
753 PcdMaximumAsciiStringLength ASCII characters, not including the Null-terminator,
756 @param Destination The pointer to a Null-terminated ASCII string.
757 @param Source The pointer to a Null-terminated ASCII string.
758 @param Length The maximum number of ASCII characters to copy.
766 OUT CHAR8 *Destination,
767 IN CONST CHAR8 *Source,
773 Returns the length of a Null-terminated ASCII string.
775 This function returns the number of ASCII characters in the Null-terminated
776 ASCII string specified by String.
778 If Length > 0 and Destination is NULL, then ASSERT().
779 If Length > 0 and Source is NULL, then ASSERT().
780 If PcdMaximumAsciiStringLength is not zero and String contains more than
781 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
784 @param String The pointer to a Null-terminated ASCII string.
786 @return The length of String.
792 IN CONST CHAR8 *String
797 Returns the size of a Null-terminated ASCII string in bytes, including the
800 This function returns the size, in bytes, of the Null-terminated ASCII string
803 If String is NULL, then ASSERT().
804 If PcdMaximumAsciiStringLength is not zero and String contains more than
805 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
808 @param String The pointer to a Null-terminated ASCII string.
810 @return The size of String.
816 IN CONST CHAR8 *String
821 Compares two Null-terminated ASCII strings, and returns the difference
822 between the first mismatched ASCII characters.
824 This function compares the Null-terminated ASCII string FirstString to the
825 Null-terminated ASCII string SecondString. If FirstString is identical to
826 SecondString, then 0 is returned. Otherwise, the value returned is the first
827 mismatched ASCII character in SecondString subtracted from the first
828 mismatched ASCII character in FirstString.
830 If FirstString is NULL, then ASSERT().
831 If SecondString is NULL, then ASSERT().
832 If PcdMaximumAsciiStringLength is not zero and FirstString contains more than
833 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
835 If PcdMaximumAsciiStringLength is not zero and SecondString contains more
836 than PcdMaximumAsciiStringLength ASCII characters not including the
837 Null-terminator, then ASSERT().
839 @param FirstString The pointer to a Null-terminated ASCII string.
840 @param SecondString The pointer to a Null-terminated ASCII string.
842 @retval ==0 FirstString is identical to SecondString.
843 @retval !=0 FirstString is not identical to SecondString.
849 IN CONST CHAR8 *FirstString,
850 IN CONST CHAR8 *SecondString
855 Performs a case insensitive comparison of two Null-terminated ASCII strings,
856 and returns the difference between the first mismatched ASCII characters.
858 This function performs a case insensitive comparison of the Null-terminated
859 ASCII string FirstString to the Null-terminated ASCII string SecondString. If
860 FirstString is identical to SecondString, then 0 is returned. Otherwise, the
861 value returned is the first mismatched lower case ASCII character in
862 SecondString subtracted from the first mismatched lower case ASCII character
865 If FirstString is NULL, then ASSERT().
866 If SecondString is NULL, then ASSERT().
867 If PcdMaximumAsciiStringLength is not zero and FirstString contains more than
868 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
870 If PcdMaximumAsciiStringLength is not zero and SecondString contains more
871 than PcdMaximumAsciiStringLength ASCII characters not including the
872 Null-terminator, then ASSERT().
874 @param FirstString The pointer to a Null-terminated ASCII string.
875 @param SecondString The pointer to a Null-terminated ASCII string.
877 @retval ==0 FirstString is identical to SecondString using case insensitive
879 @retval !=0 FirstString is not identical to SecondString using case
880 insensitive comparisons.
886 IN CONST CHAR8 *FirstString,
887 IN CONST CHAR8 *SecondString
892 Compares two Null-terminated ASCII strings with maximum lengths, and returns
893 the difference between the first mismatched ASCII characters.
895 This function compares the Null-terminated ASCII string FirstString to the
896 Null-terminated ASCII string SecondString. At most, Length ASCII characters
897 will be compared. If Length is 0, then 0 is returned. If FirstString is
898 identical to SecondString, then 0 is returned. Otherwise, the value returned
899 is the first mismatched ASCII character in SecondString subtracted from the
900 first mismatched ASCII character in FirstString.
902 If Length > 0 and FirstString is NULL, then ASSERT().
903 If Length > 0 and SecondString is NULL, then ASSERT().
904 If PcdMaximumAsciiStringLength is not zero, and Length is greater than
905 PcdMaximumAsciiStringLength, then ASSERT().
906 If PcdMaximumAsciiStringLength is not zero, and FirstString contains more than
907 PcdMaximumAsciiStringLength ASCII characters, not including the Null-terminator,
909 If PcdMaximumAsciiStringLength is not zero, and SecondString contains more than
910 PcdMaximumAsciiStringLength ASCII characters, not including the Null-terminator,
913 @param FirstString The pointer to a Null-terminated ASCII string.
914 @param SecondString The pointer to a Null-terminated ASCII string.
915 @param Length The maximum number of ASCII characters for compare.
917 @retval ==0 FirstString is identical to SecondString.
918 @retval !=0 FirstString is not identical to SecondString.
924 IN CONST CHAR8 *FirstString,
925 IN CONST CHAR8 *SecondString,
931 Concatenates one Null-terminated ASCII string to another Null-terminated
932 ASCII string, and returns the concatenated ASCII string.
934 This function concatenates two Null-terminated ASCII strings. The contents of
935 Null-terminated ASCII string Source are concatenated to the end of Null-
936 terminated ASCII string Destination. The Null-terminated concatenated ASCII
939 If Destination is NULL, then ASSERT().
940 If Source is NULL, then ASSERT().
941 If PcdMaximumAsciiStringLength is not zero and Destination contains more than
942 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
944 If PcdMaximumAsciiStringLength is not zero and Source contains more than
945 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
947 If PcdMaximumAsciiStringLength is not zero and concatenating Destination and
948 Source results in a ASCII string with more than PcdMaximumAsciiStringLength
949 ASCII characters, then ASSERT().
951 @param Destination The pointer to a Null-terminated ASCII string.
952 @param Source The pointer to a Null-terminated ASCII string.
960 IN OUT CHAR8 *Destination,
961 IN CONST CHAR8 *Source
966 Concatenates up to a specified length one Null-terminated ASCII string to
967 the end of another Null-terminated ASCII string, and returns the
968 concatenated ASCII string.
970 This function concatenates two Null-terminated ASCII strings. The contents
971 of Null-terminated ASCII string Source are concatenated to the end of Null-
972 terminated ASCII string Destination, and Destination is returned. At most,
973 Length ASCII characters are concatenated from Source to the end of
974 Destination, and Destination is always Null-terminated. If Length is 0, then
975 Destination is returned unmodified. If Source and Destination overlap, then
976 the results are undefined.
978 If Length > 0 and Destination is NULL, then ASSERT().
979 If Length > 0 and Source is NULL, then ASSERT().
980 If Source and Destination overlap, then ASSERT().
981 If PcdMaximumAsciiStringLength is not zero, and Length is greater than
982 PcdMaximumAsciiStringLength, then ASSERT().
983 If PcdMaximumAsciiStringLength is not zero, and Destination contains more than
984 PcdMaximumAsciiStringLength ASCII characters, not including the Null-terminator,
986 If PcdMaximumAsciiStringLength is not zero, and Source contains more than
987 PcdMaximumAsciiStringLength ASCII characters, not including the Null-terminator,
989 If PcdMaximumAsciiStringLength is not zero, and concatenating Destination and
990 Source results in a ASCII string with more than PcdMaximumAsciiStringLength
991 ASCII characters, not including the Null-terminator, then ASSERT().
993 @param Destination The pointer to a Null-terminated ASCII string.
994 @param Source The pointer to a Null-terminated ASCII string.
995 @param Length The maximum number of ASCII characters to concatenate from
1004 IN OUT CHAR8 *Destination,
1005 IN CONST CHAR8 *Source,
1011 Returns the first occurrence of a Null-terminated ASCII sub-string
1012 in a Null-terminated ASCII string.
1014 This function scans the contents of the ASCII string specified by String
1015 and returns the first occurrence of SearchString. If SearchString is not
1016 found in String, then NULL is returned. If the length of SearchString is zero,
1017 then String is returned.
1019 If String is NULL, then ASSERT().
1020 If SearchString is NULL, then ASSERT().
1022 If PcdMaximumAsciiStringLength is not zero, and SearchString or
1023 String contains more than PcdMaximumAsciiStringLength Unicode characters
1024 not including the Null-terminator, then ASSERT().
1026 @param String The pointer to a Null-terminated ASCII string.
1027 @param SearchString The pointer to a Null-terminated ASCII string to search for.
1029 @retval NULL If the SearchString does not appear in String.
1030 @retval others If there is a match return the first occurrence of SearchingString.
1031 If the length of SearchString is zero,return String.
1037 IN CONST CHAR8 *String,
1038 IN CONST CHAR8 *SearchString
1043 Convert a Null-terminated ASCII decimal string to a value of type
1046 This function returns a value of type UINTN by interpreting the contents
1047 of the ASCII string String as a decimal number. The format of the input
1048 ASCII string String is:
1050 [spaces] [decimal digits].
1052 The valid decimal digit character is in the range [0-9]. The function will
1053 ignore the pad space, which includes spaces or tab characters, before the digits.
1054 The running zero in the beginning of [decimal digits] will be ignored. Then, the
1055 function stops at the first character that is a not a valid decimal character or
1056 Null-terminator, whichever on comes first.
1058 If String has only pad spaces, then 0 is returned.
1059 If String has no pad spaces or valid decimal digits, then 0 is returned.
1060 If the number represented by String overflows according to the range defined by
1061 UINTN, then ASSERT().
1062 If String is NULL, then ASSERT().
1063 If PcdMaximumAsciiStringLength is not zero, and String contains more than
1064 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
1067 @param String The pointer to a Null-terminated ASCII string.
1069 @retval The value translated from String.
1074 AsciiStrDecimalToUintn (
1075 IN CONST CHAR8 *String
1080 Convert a Null-terminated ASCII decimal string to a value of type
1083 This function returns a value of type UINT64 by interpreting the contents
1084 of the ASCII string String as a decimal number. The format of the input
1085 ASCII string String is:
1087 [spaces] [decimal digits].
1089 The valid decimal digit character is in the range [0-9]. The function will
1090 ignore the pad space, which includes spaces or tab characters, before the digits.
1091 The running zero in the beginning of [decimal digits] will be ignored. Then, the
1092 function stops at the first character that is a not a valid decimal character or
1093 Null-terminator, whichever on comes first.
1095 If String has only pad spaces, then 0 is returned.
1096 If String has no pad spaces or valid decimal digits, then 0 is returned.
1097 If the number represented by String overflows according to the range defined by
1098 UINT64, then ASSERT().
1099 If String is NULL, then ASSERT().
1100 If PcdMaximumAsciiStringLength is not zero, and String contains more than
1101 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
1104 @param String The pointer to a Null-terminated ASCII string.
1106 @retval Value translated from String.
1111 AsciiStrDecimalToUint64 (
1112 IN CONST CHAR8 *String
1117 Convert a Null-terminated ASCII hexadecimal string to a value of type UINTN.
1119 This function returns a value of type UINTN by interpreting the contents of
1120 the ASCII string String as a hexadecimal number. The format of the input ASCII
1123 [spaces][zeros][x][hexadecimal digits].
1125 The valid hexadecimal digit character is in the range [0-9], [a-f] and [A-F].
1126 The prefix "0x" is optional. Both "x" and "X" is allowed in "0x" prefix. If "x"
1127 appears in the input string, it must be prefixed with at least one 0. The function
1128 will ignore the pad space, which includes spaces or tab characters, before [zeros],
1129 [x] or [hexadecimal digits]. The running zero before [x] or [hexadecimal digits]
1130 will be ignored. Then, the decoding starts after [x] or the first valid hexadecimal
1131 digit. Then, the function stops at the first character that is a not a valid
1132 hexadecimal character or Null-terminator, whichever on comes first.
1134 If String has only pad spaces, then 0 is returned.
1135 If String has no leading pad spaces, leading zeros or valid hexadecimal digits, then
1138 If the number represented by String overflows according to the range defined by UINTN,
1140 If String is NULL, then ASSERT().
1141 If PcdMaximumAsciiStringLength is not zero,
1142 and String contains more than PcdMaximumAsciiStringLength ASCII characters not including
1143 the Null-terminator, then ASSERT().
1145 @param String The pointer to a Null-terminated ASCII string.
1147 @retval Value translated from String.
1152 AsciiStrHexToUintn (
1153 IN CONST CHAR8 *String
1158 Convert a Null-terminated ASCII hexadecimal string to a value of type UINT64.
1160 This function returns a value of type UINT64 by interpreting the contents of
1161 the ASCII string String as a hexadecimal number. The format of the input ASCII
1164 [spaces][zeros][x][hexadecimal digits].
1166 The valid hexadecimal digit character is in the range [0-9], [a-f] and [A-F].
1167 The prefix "0x" is optional. Both "x" and "X" is allowed in "0x" prefix. If "x"
1168 appears in the input string, it must be prefixed with at least one 0. The function
1169 will ignore the pad space, which includes spaces or tab characters, before [zeros],
1170 [x] or [hexadecimal digits]. The running zero before [x] or [hexadecimal digits]
1171 will be ignored. Then, the decoding starts after [x] or the first valid hexadecimal
1172 digit. Then, the function stops at the first character that is a not a valid
1173 hexadecimal character or Null-terminator, whichever on comes first.
1175 If String has only pad spaces, then 0 is returned.
1176 If String has no leading pad spaces, leading zeros or valid hexadecimal digits, then
1179 If the number represented by String overflows according to the range defined by UINT64,
1181 If String is NULL, then ASSERT().
1182 If PcdMaximumAsciiStringLength is not zero,
1183 and String contains more than PcdMaximumAsciiStringLength ASCII characters not including
1184 the Null-terminator, then ASSERT().
1186 @param String The pointer to a Null-terminated ASCII string.
1188 @retval Value translated from String.
1193 AsciiStrHexToUint64 (
1194 IN CONST CHAR8 *String
1199 Convert one Null-terminated ASCII string to a Null-terminated
1200 Unicode string and returns the Unicode string.
1202 This function converts the contents of the ASCII string Source to the Unicode
1203 string Destination, and returns Destination. The function terminates the
1204 Unicode string Destination by appending a Null-terminator character at the end.
1205 The caller is responsible to make sure Destination points to a buffer with size
1206 equal or greater than ((AsciiStrLen (Source) + 1) * sizeof (CHAR16)) in bytes.
1208 If Destination is NULL, then ASSERT().
1209 If Destination is not aligned on a 16-bit boundary, then ASSERT().
1210 If Source is NULL, then ASSERT().
1211 If Source and Destination overlap, then ASSERT().
1212 If PcdMaximumAsciiStringLength is not zero, and Source contains more than
1213 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
1215 If PcdMaximumUnicodeStringLength is not zero, and Source contains more than
1216 PcdMaximumUnicodeStringLength ASCII characters not including the
1217 Null-terminator, then ASSERT().
1219 @param Source The pointer to a Null-terminated ASCII string.
1220 @param Destination The pointer to a Null-terminated Unicode string.
1222 @return Destination.
1227 AsciiStrToUnicodeStr (
1228 IN CONST CHAR8 *Source,
1229 OUT CHAR16 *Destination
1234 Converts an 8-bit value to an 8-bit BCD value.
1236 Converts the 8-bit value specified by Value to BCD. The BCD value is
1239 If Value >= 100, then ASSERT().
1241 @param Value The 8-bit value to convert to BCD. Range 0..99.
1243 @return The BCD value.
1254 Converts an 8-bit BCD value to an 8-bit value.
1256 Converts the 8-bit BCD value specified by Value to an 8-bit value. The 8-bit
1259 If Value >= 0xA0, then ASSERT().
1260 If (Value & 0x0F) >= 0x0A, then ASSERT().
1262 @param Value The 8-bit BCD value to convert to an 8-bit value.
1264 @return The 8-bit value is returned.
1275 // Linked List Functions and Macros
1279 Initializes the head node of a doubly linked list that is declared as a
1280 global variable in a module.
1282 Initializes the forward and backward links of a new linked list. After
1283 initializing a linked list with this macro, the other linked list functions
1284 may be used to add and remove nodes from the linked list. This macro results
1285 in smaller executables by initializing the linked list in the data section,
1286 instead if calling the InitializeListHead() function to perform the
1287 equivalent operation.
1289 @param ListHead The head note of a list to initialize.
1292 #define INITIALIZE_LIST_HEAD_VARIABLE(ListHead) {&(ListHead), &(ListHead)}
1296 Initializes the head node of a doubly linked list, and returns the pointer to
1297 the head node of the doubly linked list.
1299 Initializes the forward and backward links of a new linked list. After
1300 initializing a linked list with this function, the other linked list
1301 functions may be used to add and remove nodes from the linked list. It is up
1302 to the caller of this function to allocate the memory for ListHead.
1304 If ListHead is NULL, then ASSERT().
1306 @param ListHead A pointer to the head node of a new doubly linked list.
1313 InitializeListHead (
1314 IN OUT LIST_ENTRY *ListHead
1319 Adds a node to the beginning of a doubly linked list, and returns the pointer
1320 to the head node of the doubly linked list.
1322 Adds the node Entry at the beginning of the doubly linked list denoted by
1323 ListHead, and returns ListHead.
1325 If ListHead is NULL, then ASSERT().
1326 If Entry is NULL, then ASSERT().
1327 If ListHead was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or
1328 InitializeListHead(), then ASSERT().
1329 If PcdMaximumLinkedListLength is not zero, and prior to insertion the number
1330 of nodes in ListHead, including the ListHead node, is greater than or
1331 equal to PcdMaximumLinkedListLength, then ASSERT().
1333 @param ListHead A pointer to the head node of a doubly linked list.
1334 @param Entry A pointer to a node that is to be inserted at the beginning
1335 of a doubly linked list.
1343 IN OUT LIST_ENTRY *ListHead,
1344 IN OUT LIST_ENTRY *Entry
1349 Adds a node to the end of a doubly linked list, and returns the pointer to
1350 the head node of the doubly linked list.
1352 Adds the node Entry to the end of the doubly linked list denoted by ListHead,
1353 and returns ListHead.
1355 If ListHead is NULL, then ASSERT().
1356 If Entry is NULL, then ASSERT().
1357 If ListHead was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or
1358 InitializeListHead(), then ASSERT().
1359 If PcdMaximumLinkedListLength is not zero, and prior to insertion the number
1360 of nodes in ListHead, including the ListHead node, is greater than or
1361 equal to PcdMaximumLinkedListLength, then ASSERT().
1363 @param ListHead A pointer to the head node of a doubly linked list.
1364 @param Entry A pointer to a node that is to be added at the end of the
1373 IN OUT LIST_ENTRY *ListHead,
1374 IN OUT LIST_ENTRY *Entry
1379 Retrieves the first node of a doubly linked list.
1381 Returns the first node of a doubly linked list. List must have been
1382 initialized with INTIALIZE_LIST_HEAD_VARIABLE() or InitializeListHead().
1383 If List is empty, then List is returned.
1385 If List is NULL, then ASSERT().
1386 If List was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or
1387 InitializeListHead(), then ASSERT().
1388 If PcdMaximumLinkedListLength is not zero, and the number of nodes
1389 in List, including the List node, is greater than or equal to
1390 PcdMaximumLinkedListLength, then ASSERT().
1392 @param List A pointer to the head node of a doubly linked list.
1394 @return The first node of a doubly linked list.
1395 @retval List The list is empty.
1401 IN CONST LIST_ENTRY *List
1406 Retrieves the next node of a doubly linked list.
1408 Returns the node of a doubly linked list that follows Node.
1409 List must have been initialized with INTIALIZE_LIST_HEAD_VARIABLE()
1410 or InitializeListHead(). If List is empty, then List is returned.
1412 If List is NULL, then ASSERT().
1413 If Node is NULL, then ASSERT().
1414 If List was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or
1415 InitializeListHead(), then ASSERT().
1416 If PcdMaximumLinkedListLength is not zero, and List contains more than
1417 PcdMaximumLinkedListLength nodes, then ASSERT().
1418 If PcdVerifyNodeInList is TRUE and Node is not a node in List, then ASSERT().
1420 @param List A pointer to the head node of a doubly linked list.
1421 @param Node A pointer to a node in the doubly linked list.
1423 @return The pointer to the next node if one exists. Otherwise List is returned.
1429 IN CONST LIST_ENTRY *List,
1430 IN CONST LIST_ENTRY *Node
1435 Retrieves the previous node of a doubly linked list.
1437 Returns the node of a doubly linked list that precedes Node.
1438 List must have been initialized with INTIALIZE_LIST_HEAD_VARIABLE()
1439 or InitializeListHead(). If List is empty, then List is returned.
1441 If List is NULL, then ASSERT().
1442 If Node is NULL, then ASSERT().
1443 If List was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or
1444 InitializeListHead(), then ASSERT().
1445 If PcdMaximumLinkedListLength is not zero, and List contains more than
1446 PcdMaximumLinkedListLength nodes, then ASSERT().
1447 If PcdVerifyNodeInList is TRUE and Node is not a node in List, then ASSERT().
1449 @param List A pointer to the head node of a doubly linked list.
1450 @param Node A pointer to a node in the doubly linked list.
1452 @return The pointer to the previous node if one exists. Otherwise List is returned.
1458 IN CONST LIST_ENTRY *List,
1459 IN CONST LIST_ENTRY *Node
1464 Checks to see if a doubly linked list is empty or not.
1466 Checks to see if the doubly linked list is empty. If the linked list contains
1467 zero nodes, this function returns TRUE. Otherwise, it returns FALSE.
1469 If ListHead is NULL, then ASSERT().
1470 If ListHead was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or
1471 InitializeListHead(), then ASSERT().
1472 If PcdMaximumLinkedListLength is not zero, and the number of nodes
1473 in List, including the List node, is greater than or equal to
1474 PcdMaximumLinkedListLength, then ASSERT().
1476 @param ListHead A pointer to the head node of a doubly linked list.
1478 @retval TRUE The linked list is empty.
1479 @retval FALSE The linked list is not empty.
1485 IN CONST LIST_ENTRY *ListHead
1490 Determines if a node in a doubly linked list is the head node of a the same
1491 doubly linked list. This function is typically used to terminate a loop that
1492 traverses all the nodes in a doubly linked list starting with the head node.
1494 Returns TRUE if Node is equal to List. Returns FALSE if Node is one of the
1495 nodes in the doubly linked list specified by List. List must have been
1496 initialized with INTIALIZE_LIST_HEAD_VARIABLE() or InitializeListHead().
1498 If List is NULL, then ASSERT().
1499 If Node is NULL, then ASSERT().
1500 If List was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or InitializeListHead(),
1502 If PcdMaximumLinkedListLength is not zero, and the number of nodes
1503 in List, including the List node, is greater than or equal to
1504 PcdMaximumLinkedListLength, then ASSERT().
1505 If PcdVerifyNodeInList is TRUE and Node is not a node in List the and Node is not equal
1506 to List, then ASSERT().
1508 @param List A pointer to the head node of a doubly linked list.
1509 @param Node A pointer to a node in the doubly linked list.
1511 @retval TRUE Node is the head of the doubly-linked list pointed by List.
1512 @retval FALSE Node is not the head of the doubly-linked list pointed by List.
1518 IN CONST LIST_ENTRY *List,
1519 IN CONST LIST_ENTRY *Node
1524 Determines if a node the last node in a doubly linked list.
1526 Returns TRUE if Node is the last node in the doubly linked list specified by
1527 List. Otherwise, FALSE is returned. List must have been initialized with
1528 INTIALIZE_LIST_HEAD_VARIABLE() or InitializeListHead().
1530 If List is NULL, then ASSERT().
1531 If Node is NULL, then ASSERT().
1532 If List was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or
1533 InitializeListHead(), then ASSERT().
1534 If PcdMaximumLinkedListLength is not zero, and the number of nodes
1535 in List, including the List node, is greater than or equal to
1536 PcdMaximumLinkedListLength, then ASSERT().
1537 If PcdVerifyNodeInList is TRUE and Node is not a node in List, then ASSERT().
1539 @param List A pointer to the head node of a doubly linked list.
1540 @param Node A pointer to a node in the doubly linked list.
1542 @retval TRUE Node is the last node in the linked list.
1543 @retval FALSE Node is not the last node in the linked list.
1549 IN CONST LIST_ENTRY *List,
1550 IN CONST LIST_ENTRY *Node
1555 Swaps the location of two nodes in a doubly linked list, and returns the
1556 first node after the swap.
1558 If FirstEntry is identical to SecondEntry, then SecondEntry is returned.
1559 Otherwise, the location of the FirstEntry node is swapped with the location
1560 of the SecondEntry node in a doubly linked list. SecondEntry must be in the
1561 same double linked list as FirstEntry and that double linked list must have
1562 been initialized with INTIALIZE_LIST_HEAD_VARIABLE() or InitializeListHead().
1563 SecondEntry is returned after the nodes are swapped.
1565 If FirstEntry is NULL, then ASSERT().
1566 If SecondEntry is NULL, then ASSERT().
1567 If PcdVerifyNodeInList is TRUE and SecondEntry and FirstEntry are not in the
1568 same linked list, then ASSERT().
1569 If PcdMaximumLinkedListLength is not zero, and the number of nodes in the
1570 linked list containing the FirstEntry and SecondEntry nodes, including
1571 the FirstEntry and SecondEntry nodes, is greater than or equal to
1572 PcdMaximumLinkedListLength, then ASSERT().
1574 @param FirstEntry A pointer to a node in a linked list.
1575 @param SecondEntry A pointer to another node in the same linked list.
1577 @return SecondEntry.
1583 IN OUT LIST_ENTRY *FirstEntry,
1584 IN OUT LIST_ENTRY *SecondEntry
1589 Removes a node from a doubly linked list, and returns the node that follows
1592 Removes the node Entry from a doubly linked list. It is up to the caller of
1593 this function to release the memory used by this node if that is required. On
1594 exit, the node following Entry in the doubly linked list is returned. If
1595 Entry is the only node in the linked list, then the head node of the linked
1598 If Entry is NULL, then ASSERT().
1599 If Entry is the head node of an empty list, then ASSERT().
1600 If PcdMaximumLinkedListLength is not zero, and the number of nodes in the
1601 linked list containing Entry, including the Entry node, is greater than
1602 or equal to PcdMaximumLinkedListLength, then ASSERT().
1604 @param Entry A pointer to a node in a linked list.
1612 IN CONST LIST_ENTRY *Entry
1620 Shifts a 64-bit integer left between 0 and 63 bits. The low bits are filled
1621 with zeros. The shifted value is returned.
1623 This function shifts the 64-bit value Operand to the left by Count bits. The
1624 low Count bits are set to zero. The shifted value is returned.
1626 If Count is greater than 63, then ASSERT().
1628 @param Operand The 64-bit operand to shift left.
1629 @param Count The number of bits to shift left.
1631 @return Operand << Count.
1643 Shifts a 64-bit integer right between 0 and 63 bits. This high bits are
1644 filled with zeros. The shifted value is returned.
1646 This function shifts the 64-bit value Operand to the right by Count bits. The
1647 high Count bits are set to zero. The shifted value is returned.
1649 If Count is greater than 63, then ASSERT().
1651 @param Operand The 64-bit operand to shift right.
1652 @param Count The number of bits to shift right.
1654 @return Operand >> Count
1666 Shifts a 64-bit integer right between 0 and 63 bits. The high bits are filled
1667 with original integer's bit 63. The shifted value is returned.
1669 This function shifts the 64-bit value Operand to the right by Count bits. The
1670 high Count bits are set to bit 63 of Operand. The shifted value is returned.
1672 If Count is greater than 63, then ASSERT().
1674 @param Operand The 64-bit operand to shift right.
1675 @param Count The number of bits to shift right.
1677 @return Operand >> Count
1689 Rotates a 32-bit integer left between 0 and 31 bits, filling the low bits
1690 with the high bits that were rotated.
1692 This function rotates the 32-bit value Operand to the left by Count bits. The
1693 low Count bits are fill with the high Count bits of Operand. The rotated
1696 If Count is greater than 31, then ASSERT().
1698 @param Operand The 32-bit operand to rotate left.
1699 @param Count The number of bits to rotate left.
1701 @return Operand << Count
1713 Rotates a 32-bit integer right between 0 and 31 bits, filling the high bits
1714 with the low bits that were rotated.
1716 This function rotates the 32-bit value Operand to the right by Count bits.
1717 The high Count bits are fill with the low Count bits of Operand. The rotated
1720 If Count is greater than 31, then ASSERT().
1722 @param Operand The 32-bit operand to rotate right.
1723 @param Count The number of bits to rotate right.
1725 @return Operand >> Count
1737 Rotates a 64-bit integer left between 0 and 63 bits, filling the low bits
1738 with the high bits that were rotated.
1740 This function rotates the 64-bit value Operand to the left by Count bits. The
1741 low Count bits are fill with the high Count bits of Operand. The rotated
1744 If Count is greater than 63, then ASSERT().
1746 @param Operand The 64-bit operand to rotate left.
1747 @param Count The number of bits to rotate left.
1749 @return Operand << Count
1761 Rotates a 64-bit integer right between 0 and 63 bits, filling the high bits
1762 with the high low bits that were rotated.
1764 This function rotates the 64-bit value Operand to the right by Count bits.
1765 The high Count bits are fill with the low Count bits of Operand. The rotated
1768 If Count is greater than 63, then ASSERT().
1770 @param Operand The 64-bit operand to rotate right.
1771 @param Count The number of bits to rotate right.
1773 @return Operand >> Count
1785 Returns the bit position of the lowest bit set in a 32-bit value.
1787 This function computes the bit position of the lowest bit set in the 32-bit
1788 value specified by Operand. If Operand is zero, then -1 is returned.
1789 Otherwise, a value between 0 and 31 is returned.
1791 @param Operand The 32-bit operand to evaluate.
1793 @retval 0..31 The lowest bit set in Operand was found.
1794 @retval -1 Operand is zero.
1805 Returns the bit position of the lowest bit set in a 64-bit value.
1807 This function computes the bit position of the lowest bit set in the 64-bit
1808 value specified by Operand. If Operand is zero, then -1 is returned.
1809 Otherwise, a value between 0 and 63 is returned.
1811 @param Operand The 64-bit operand to evaluate.
1813 @retval 0..63 The lowest bit set in Operand was found.
1814 @retval -1 Operand is zero.
1826 Returns the bit position of the highest bit set in a 32-bit value. Equivalent
1829 This function computes the bit position of the highest bit set in the 32-bit
1830 value specified by Operand. If Operand is zero, then -1 is returned.
1831 Otherwise, a value between 0 and 31 is returned.
1833 @param Operand The 32-bit operand to evaluate.
1835 @retval 0..31 Position of the highest bit set in Operand if found.
1836 @retval -1 Operand is zero.
1847 Returns the bit position of the highest bit set in a 64-bit value. Equivalent
1850 This function computes the bit position of the highest bit set in the 64-bit
1851 value specified by Operand. If Operand is zero, then -1 is returned.
1852 Otherwise, a value between 0 and 63 is returned.
1854 @param Operand The 64-bit operand to evaluate.
1856 @retval 0..63 Position of the highest bit set in Operand if found.
1857 @retval -1 Operand is zero.
1868 Returns the value of the highest bit set in a 32-bit value. Equivalent to
1871 This function computes the value of the highest bit set in the 32-bit value
1872 specified by Operand. If Operand is zero, then zero is returned.
1874 @param Operand The 32-bit operand to evaluate.
1876 @return 1 << HighBitSet32(Operand)
1877 @retval 0 Operand is zero.
1888 Returns the value of the highest bit set in a 64-bit value. Equivalent to
1891 This function computes the value of the highest bit set in the 64-bit value
1892 specified by Operand. If Operand is zero, then zero is returned.
1894 @param Operand The 64-bit operand to evaluate.
1896 @return 1 << HighBitSet64(Operand)
1897 @retval 0 Operand is zero.
1908 Switches the endianness of a 16-bit integer.
1910 This function swaps the bytes in a 16-bit unsigned value to switch the value
1911 from little endian to big endian or vice versa. The byte swapped value is
1914 @param Value A 16-bit unsigned value.
1916 @return The byte swapped Value.
1927 Switches the endianness of a 32-bit integer.
1929 This function swaps the bytes in a 32-bit unsigned value to switch the value
1930 from little endian to big endian or vice versa. The byte swapped value is
1933 @param Value A 32-bit unsigned value.
1935 @return The byte swapped Value.
1946 Switches the endianness of a 64-bit integer.
1948 This function swaps the bytes in a 64-bit unsigned value to switch the value
1949 from little endian to big endian or vice versa. The byte swapped value is
1952 @param Value A 64-bit unsigned value.
1954 @return The byte swapped Value.
1965 Multiples a 64-bit unsigned integer by a 32-bit unsigned integer and
1966 generates a 64-bit unsigned result.
1968 This function multiples the 64-bit unsigned value Multiplicand by the 32-bit
1969 unsigned value Multiplier and generates a 64-bit unsigned result. This 64-
1970 bit unsigned result is returned.
1972 @param Multiplicand A 64-bit unsigned value.
1973 @param Multiplier A 32-bit unsigned value.
1975 @return Multiplicand * Multiplier
1981 IN UINT64 Multiplicand,
1982 IN UINT32 Multiplier
1987 Multiples a 64-bit unsigned integer by a 64-bit unsigned integer and
1988 generates a 64-bit unsigned result.
1990 This function multiples the 64-bit unsigned value Multiplicand by the 64-bit
1991 unsigned value Multiplier and generates a 64-bit unsigned result. This 64-
1992 bit unsigned result is returned.
1994 @param Multiplicand A 64-bit unsigned value.
1995 @param Multiplier A 64-bit unsigned value.
1997 @return Multiplicand * Multiplier.
2003 IN UINT64 Multiplicand,
2004 IN UINT64 Multiplier
2009 Multiples a 64-bit signed integer by a 64-bit signed integer and generates a
2010 64-bit signed result.
2012 This function multiples the 64-bit signed value Multiplicand by the 64-bit
2013 signed value Multiplier and generates a 64-bit signed result. This 64-bit
2014 signed result is returned.
2016 @param Multiplicand A 64-bit signed value.
2017 @param Multiplier A 64-bit signed value.
2019 @return Multiplicand * Multiplier
2025 IN INT64 Multiplicand,
2031 Divides a 64-bit unsigned integer by a 32-bit unsigned integer and generates
2032 a 64-bit unsigned result.
2034 This function divides the 64-bit unsigned value Dividend by the 32-bit
2035 unsigned value Divisor and generates a 64-bit unsigned quotient. This
2036 function returns the 64-bit unsigned quotient.
2038 If Divisor is 0, then ASSERT().
2040 @param Dividend A 64-bit unsigned value.
2041 @param Divisor A 32-bit unsigned value.
2043 @return Dividend / Divisor.
2055 Divides a 64-bit unsigned integer by a 32-bit unsigned integer and generates
2056 a 32-bit unsigned remainder.
2058 This function divides the 64-bit unsigned value Dividend by the 32-bit
2059 unsigned value Divisor and generates a 32-bit remainder. This function
2060 returns the 32-bit unsigned remainder.
2062 If Divisor is 0, then ASSERT().
2064 @param Dividend A 64-bit unsigned value.
2065 @param Divisor A 32-bit unsigned value.
2067 @return Dividend % Divisor.
2079 Divides a 64-bit unsigned integer by a 32-bit unsigned integer and generates
2080 a 64-bit unsigned result and an optional 32-bit unsigned remainder.
2082 This function divides the 64-bit unsigned value Dividend by the 32-bit
2083 unsigned value Divisor and generates a 64-bit unsigned quotient. If Remainder
2084 is not NULL, then the 32-bit unsigned remainder is returned in Remainder.
2085 This function returns the 64-bit unsigned quotient.
2087 If Divisor is 0, then ASSERT().
2089 @param Dividend A 64-bit unsigned value.
2090 @param Divisor A 32-bit unsigned value.
2091 @param Remainder A pointer to a 32-bit unsigned value. This parameter is
2092 optional and may be NULL.
2094 @return Dividend / Divisor.
2099 DivU64x32Remainder (
2102 OUT UINT32 *Remainder OPTIONAL
2107 Divides a 64-bit unsigned integer by a 64-bit unsigned integer and generates
2108 a 64-bit unsigned result and an optional 64-bit unsigned remainder.
2110 This function divides the 64-bit unsigned value Dividend by the 64-bit
2111 unsigned value Divisor and generates a 64-bit unsigned quotient. If Remainder
2112 is not NULL, then the 64-bit unsigned remainder is returned in Remainder.
2113 This function returns the 64-bit unsigned quotient.
2115 If Divisor is 0, then ASSERT().
2117 @param Dividend A 64-bit unsigned value.
2118 @param Divisor A 64-bit unsigned value.
2119 @param Remainder A pointer to a 64-bit unsigned value. This parameter is
2120 optional and may be NULL.
2122 @return Dividend / Divisor.
2127 DivU64x64Remainder (
2130 OUT UINT64 *Remainder OPTIONAL
2135 Divides a 64-bit signed integer by a 64-bit signed integer and generates a
2136 64-bit signed result and a optional 64-bit signed remainder.
2138 This function divides the 64-bit signed value Dividend by the 64-bit signed
2139 value Divisor and generates a 64-bit signed quotient. If Remainder is not
2140 NULL, then the 64-bit signed remainder is returned in Remainder. This
2141 function returns the 64-bit signed quotient.
2143 It is the caller's responsibility to not call this function with a Divisor of 0.
2144 If Divisor is 0, then the quotient and remainder should be assumed to be
2145 the largest negative integer.
2147 If Divisor is 0, then ASSERT().
2149 @param Dividend A 64-bit signed value.
2150 @param Divisor A 64-bit signed value.
2151 @param Remainder A pointer to a 64-bit signed value. This parameter is
2152 optional and may be NULL.
2154 @return Dividend / Divisor.
2159 DivS64x64Remainder (
2162 OUT INT64 *Remainder OPTIONAL
2167 Reads a 16-bit value from memory that may be unaligned.
2169 This function returns the 16-bit value pointed to by Buffer. The function
2170 guarantees that the read operation does not produce an alignment fault.
2172 If the Buffer is NULL, then ASSERT().
2174 @param Buffer The pointer to a 16-bit value that may be unaligned.
2176 @return The 16-bit value read from Buffer.
2182 IN CONST UINT16 *Buffer
2187 Writes a 16-bit value to memory that may be unaligned.
2189 This function writes the 16-bit value specified by Value to Buffer. Value is
2190 returned. The function guarantees that the write operation does not produce
2193 If the Buffer is NULL, then ASSERT().
2195 @param Buffer The pointer to a 16-bit value that may be unaligned.
2196 @param Value 16-bit value to write to Buffer.
2198 @return The 16-bit value to write to Buffer.
2210 Reads a 24-bit value from memory that may be unaligned.
2212 This function returns the 24-bit value pointed to by Buffer. The function
2213 guarantees that the read operation does not produce an alignment fault.
2215 If the Buffer is NULL, then ASSERT().
2217 @param Buffer The pointer to a 24-bit value that may be unaligned.
2219 @return The 24-bit value read from Buffer.
2225 IN CONST UINT32 *Buffer
2230 Writes a 24-bit value to memory that may be unaligned.
2232 This function writes the 24-bit value specified by Value to Buffer. Value is
2233 returned. The function guarantees that the write operation does not produce
2236 If the Buffer is NULL, then ASSERT().
2238 @param Buffer The pointer to a 24-bit value that may be unaligned.
2239 @param Value 24-bit value to write to Buffer.
2241 @return The 24-bit value to write to Buffer.
2253 Reads a 32-bit value from memory that may be unaligned.
2255 This function returns the 32-bit value pointed to by Buffer. The function
2256 guarantees that the read operation does not produce an alignment fault.
2258 If the Buffer is NULL, then ASSERT().
2260 @param Buffer The pointer to a 32-bit value that may be unaligned.
2262 @return The 32-bit value read from Buffer.
2268 IN CONST UINT32 *Buffer
2273 Writes a 32-bit value to memory that may be unaligned.
2275 This function writes the 32-bit value specified by Value to Buffer. Value is
2276 returned. The function guarantees that the write operation does not produce
2279 If the Buffer is NULL, then ASSERT().
2281 @param Buffer The pointer to a 32-bit value that may be unaligned.
2282 @param Value 32-bit value to write to Buffer.
2284 @return The 32-bit value to write to Buffer.
2296 Reads a 64-bit value from memory that may be unaligned.
2298 This function returns the 64-bit value pointed to by Buffer. The function
2299 guarantees that the read operation does not produce an alignment fault.
2301 If the Buffer is NULL, then ASSERT().
2303 @param Buffer The pointer to a 64-bit value that may be unaligned.
2305 @return The 64-bit value read from Buffer.
2311 IN CONST UINT64 *Buffer
2316 Writes a 64-bit value to memory that may be unaligned.
2318 This function writes the 64-bit value specified by Value to Buffer. Value is
2319 returned. The function guarantees that the write operation does not produce
2322 If the Buffer is NULL, then ASSERT().
2324 @param Buffer The pointer to a 64-bit value that may be unaligned.
2325 @param Value 64-bit value to write to Buffer.
2327 @return The 64-bit value to write to Buffer.
2339 // Bit Field Functions
2343 Returns a bit field from an 8-bit value.
2345 Returns the bitfield specified by the StartBit and the EndBit from Operand.
2347 If 8-bit operations are not supported, then ASSERT().
2348 If StartBit is greater than 7, then ASSERT().
2349 If EndBit is greater than 7, then ASSERT().
2350 If EndBit is less than StartBit, then ASSERT().
2352 @param Operand Operand on which to perform the bitfield operation.
2353 @param StartBit The ordinal of the least significant bit in the bit field.
2355 @param EndBit The ordinal of the most significant bit in the bit field.
2358 @return The bit field read.
2371 Writes a bit field to an 8-bit value, and returns the result.
2373 Writes Value to the bit field specified by the StartBit and the EndBit in
2374 Operand. All other bits in Operand are preserved. The new 8-bit value is
2377 If 8-bit operations are not supported, then ASSERT().
2378 If StartBit is greater than 7, then ASSERT().
2379 If EndBit is greater than 7, then ASSERT().
2380 If EndBit is less than StartBit, then ASSERT().
2381 If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
2383 @param Operand Operand on which to perform the bitfield operation.
2384 @param StartBit The ordinal of the least significant bit in the bit field.
2386 @param EndBit The ordinal of the most significant bit in the bit field.
2388 @param Value New value of the bit field.
2390 @return The new 8-bit value.
2404 Reads a bit field from an 8-bit value, performs a bitwise OR, and returns the
2407 Performs a bitwise OR between the bit field specified by StartBit
2408 and EndBit in Operand and the value specified by OrData. All other bits in
2409 Operand are preserved. The new 8-bit value is returned.
2411 If 8-bit operations are not supported, then ASSERT().
2412 If StartBit is greater than 7, then ASSERT().
2413 If EndBit is greater than 7, then ASSERT().
2414 If EndBit is less than StartBit, then ASSERT().
2415 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
2417 @param Operand Operand on which to perform the bitfield operation.
2418 @param StartBit The ordinal of the least significant bit in the bit field.
2420 @param EndBit The ordinal of the most significant bit in the bit field.
2422 @param OrData The value to OR with the read value from the value
2424 @return The new 8-bit value.
2438 Reads a bit field from an 8-bit value, performs a bitwise AND, and returns
2441 Performs a bitwise AND between the bit field specified by StartBit and EndBit
2442 in Operand and the value specified by AndData. All other bits in Operand are
2443 preserved. The new 8-bit value is returned.
2445 If 8-bit operations are not supported, then ASSERT().
2446 If StartBit is greater than 7, then ASSERT().
2447 If EndBit is greater than 7, then ASSERT().
2448 If EndBit is less than StartBit, then ASSERT().
2449 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
2451 @param Operand Operand on which to perform the bitfield operation.
2452 @param StartBit The ordinal of the least significant bit in the bit field.
2454 @param EndBit The ordinal of the most significant bit in the bit field.
2456 @param AndData The value to AND with the read value from the value.
2458 @return The new 8-bit value.
2472 Reads a bit field from an 8-bit value, performs a bitwise AND followed by a
2473 bitwise OR, and returns the result.
2475 Performs a bitwise AND between the bit field specified by StartBit and EndBit
2476 in Operand and the value specified by AndData, followed by a bitwise
2477 OR with value specified by OrData. All other bits in Operand are
2478 preserved. The new 8-bit value is returned.
2480 If 8-bit operations are not supported, then ASSERT().
2481 If StartBit is greater than 7, then ASSERT().
2482 If EndBit is greater than 7, then ASSERT().
2483 If EndBit is less than StartBit, then ASSERT().
2484 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
2485 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
2487 @param Operand Operand on which to perform the bitfield operation.
2488 @param StartBit The ordinal of the least significant bit in the bit field.
2490 @param EndBit The ordinal of the most significant bit in the bit field.
2492 @param AndData The value to AND with the read value from the value.
2493 @param OrData The value to OR with the result of the AND operation.
2495 @return The new 8-bit value.
2500 BitFieldAndThenOr8 (
2510 Returns a bit field from a 16-bit value.
2512 Returns the bitfield specified by the StartBit and the EndBit from Operand.
2514 If 16-bit operations are not supported, then ASSERT().
2515 If StartBit is greater than 15, then ASSERT().
2516 If EndBit is greater than 15, then ASSERT().
2517 If EndBit is less than StartBit, then ASSERT().
2519 @param Operand Operand on which to perform the bitfield operation.
2520 @param StartBit The ordinal of the least significant bit in the bit field.
2522 @param EndBit The ordinal of the most significant bit in the bit field.
2525 @return The bit field read.
2538 Writes a bit field to a 16-bit value, and returns the result.
2540 Writes Value to the bit field specified by the StartBit and the EndBit in
2541 Operand. All other bits in Operand are preserved. The new 16-bit value is
2544 If 16-bit operations are not supported, then ASSERT().
2545 If StartBit is greater than 15, then ASSERT().
2546 If EndBit is greater than 15, then ASSERT().
2547 If EndBit is less than StartBit, then ASSERT().
2548 If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
2550 @param Operand Operand on which to perform the bitfield operation.
2551 @param StartBit The ordinal of the least significant bit in the bit field.
2553 @param EndBit The ordinal of the most significant bit in the bit field.
2555 @param Value New value of the bit field.
2557 @return The new 16-bit value.
2571 Reads a bit field from a 16-bit value, performs a bitwise OR, and returns the
2574 Performs a bitwise OR between the bit field specified by StartBit
2575 and EndBit in Operand and the value specified by OrData. All other bits in
2576 Operand are preserved. The new 16-bit value is returned.
2578 If 16-bit operations are not supported, then ASSERT().
2579 If StartBit is greater than 15, then ASSERT().
2580 If EndBit is greater than 15, then ASSERT().
2581 If EndBit is less than StartBit, then ASSERT().
2582 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
2584 @param Operand Operand on which to perform the bitfield operation.
2585 @param StartBit The ordinal of the least significant bit in the bit field.
2587 @param EndBit The ordinal of the most significant bit in the bit field.
2589 @param OrData The value to OR with the read value from the value
2591 @return The new 16-bit value.
2605 Reads a bit field from a 16-bit value, performs a bitwise AND, and returns
2608 Performs a bitwise AND between the bit field specified by StartBit and EndBit
2609 in Operand and the value specified by AndData. All other bits in Operand are
2610 preserved. The new 16-bit value is returned.
2612 If 16-bit operations are not supported, then ASSERT().
2613 If StartBit is greater than 15, then ASSERT().
2614 If EndBit is greater than 15, then ASSERT().
2615 If EndBit is less than StartBit, then ASSERT().
2616 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
2618 @param Operand Operand on which to perform the bitfield operation.
2619 @param StartBit The ordinal of the least significant bit in the bit field.
2621 @param EndBit The ordinal of the most significant bit in the bit field.
2623 @param AndData The value to AND with the read value from the value
2625 @return The new 16-bit value.
2639 Reads a bit field from a 16-bit value, performs a bitwise AND followed by a
2640 bitwise OR, and returns the result.
2642 Performs a bitwise AND between the bit field specified by StartBit and EndBit
2643 in Operand and the value specified by AndData, followed by a bitwise
2644 OR with value specified by OrData. All other bits in Operand are
2645 preserved. The new 16-bit value is returned.
2647 If 16-bit operations are not supported, then ASSERT().
2648 If StartBit is greater than 15, then ASSERT().
2649 If EndBit is greater than 15, then ASSERT().
2650 If EndBit is less than StartBit, then ASSERT().
2651 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
2652 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
2654 @param Operand Operand on which to perform the bitfield operation.
2655 @param StartBit The ordinal of the least significant bit in the bit field.
2657 @param EndBit The ordinal of the most significant bit in the bit field.
2659 @param AndData The value to AND with the read value from the value.
2660 @param OrData The value to OR with the result of the AND operation.
2662 @return The new 16-bit value.
2667 BitFieldAndThenOr16 (
2677 Returns a bit field from a 32-bit value.
2679 Returns the bitfield specified by the StartBit and the EndBit from Operand.
2681 If 32-bit operations are not supported, then ASSERT().
2682 If StartBit is greater than 31, then ASSERT().
2683 If EndBit is greater than 31, then ASSERT().
2684 If EndBit is less than StartBit, then ASSERT().
2686 @param Operand Operand on which to perform the bitfield operation.
2687 @param StartBit The ordinal of the least significant bit in the bit field.
2689 @param EndBit The ordinal of the most significant bit in the bit field.
2692 @return The bit field read.
2705 Writes a bit field to a 32-bit value, and returns the result.
2707 Writes Value to the bit field specified by the StartBit and the EndBit in
2708 Operand. All other bits in Operand are preserved. The new 32-bit value is
2711 If 32-bit operations are not supported, then ASSERT().
2712 If StartBit is greater than 31, then ASSERT().
2713 If EndBit is greater than 31, then ASSERT().
2714 If EndBit is less than StartBit, then ASSERT().
2715 If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
2717 @param Operand Operand on which to perform the bitfield operation.
2718 @param StartBit The ordinal of the least significant bit in the bit field.
2720 @param EndBit The ordinal of the most significant bit in the bit field.
2722 @param Value New value of the bit field.
2724 @return The new 32-bit value.
2738 Reads a bit field from a 32-bit value, performs a bitwise OR, and returns the
2741 Performs a bitwise OR between the bit field specified by StartBit
2742 and EndBit in Operand and the value specified by OrData. All other bits in
2743 Operand are preserved. The new 32-bit value is returned.
2745 If 32-bit operations are not supported, then ASSERT().
2746 If StartBit is greater than 31, then ASSERT().
2747 If EndBit is greater than 31, then ASSERT().
2748 If EndBit is less than StartBit, then ASSERT().
2749 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
2751 @param Operand Operand on which to perform the bitfield operation.
2752 @param StartBit The ordinal of the least significant bit in the bit field.
2754 @param EndBit The ordinal of the most significant bit in the bit field.
2756 @param OrData The value to OR with the read value from the value.
2758 @return The new 32-bit value.
2772 Reads a bit field from a 32-bit value, performs a bitwise AND, and returns
2775 Performs a bitwise AND between the bit field specified by StartBit and EndBit
2776 in Operand and the value specified by AndData. All other bits in Operand are
2777 preserved. The new 32-bit value is returned.
2779 If 32-bit operations are not supported, then ASSERT().
2780 If StartBit is greater than 31, then ASSERT().
2781 If EndBit is greater than 31, then ASSERT().
2782 If EndBit is less than StartBit, then ASSERT().
2783 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
2785 @param Operand Operand on which to perform the bitfield operation.
2786 @param StartBit The ordinal of the least significant bit in the bit field.
2788 @param EndBit The ordinal of the most significant bit in the bit field.
2790 @param AndData The value to AND with the read value from the value
2792 @return The new 32-bit value.
2806 Reads a bit field from a 32-bit value, performs a bitwise AND followed by a
2807 bitwise OR, and returns the result.
2809 Performs a bitwise AND between the bit field specified by StartBit and EndBit
2810 in Operand and the value specified by AndData, followed by a bitwise
2811 OR with value specified by OrData. All other bits in Operand are
2812 preserved. The new 32-bit value is returned.
2814 If 32-bit operations are not supported, then ASSERT().
2815 If StartBit is greater than 31, then ASSERT().
2816 If EndBit is greater than 31, then ASSERT().
2817 If EndBit is less than StartBit, then ASSERT().
2818 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
2819 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
2821 @param Operand Operand on which to perform the bitfield operation.
2822 @param StartBit The ordinal of the least significant bit in the bit field.
2824 @param EndBit The ordinal of the most significant bit in the bit field.
2826 @param AndData The value to AND with the read value from the value.
2827 @param OrData The value to OR with the result of the AND operation.
2829 @return The new 32-bit value.
2834 BitFieldAndThenOr32 (
2844 Returns a bit field from a 64-bit value.
2846 Returns the bitfield specified by the StartBit and the EndBit from Operand.
2848 If 64-bit operations are not supported, then ASSERT().
2849 If StartBit is greater than 63, then ASSERT().
2850 If EndBit is greater than 63, then ASSERT().
2851 If EndBit is less than StartBit, then ASSERT().
2853 @param Operand Operand on which to perform the bitfield operation.
2854 @param StartBit The ordinal of the least significant bit in the bit field.
2856 @param EndBit The ordinal of the most significant bit in the bit field.
2859 @return The bit field read.
2872 Writes a bit field to a 64-bit value, and returns the result.
2874 Writes Value to the bit field specified by the StartBit and the EndBit in
2875 Operand. All other bits in Operand are preserved. The new 64-bit value is
2878 If 64-bit operations are not supported, then ASSERT().
2879 If StartBit is greater than 63, then ASSERT().
2880 If EndBit is greater than 63, then ASSERT().
2881 If EndBit is less than StartBit, then ASSERT().
2882 If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
2884 @param Operand Operand on which to perform the bitfield operation.
2885 @param StartBit The ordinal of the least significant bit in the bit field.
2887 @param EndBit The ordinal of the most significant bit in the bit field.
2889 @param Value New value of the bit field.
2891 @return The new 64-bit value.
2905 Reads a bit field from a 64-bit value, performs a bitwise OR, and returns the
2908 Performs a bitwise OR between the bit field specified by StartBit
2909 and EndBit in Operand and the value specified by OrData. All other bits in
2910 Operand are preserved. The new 64-bit value is returned.
2912 If 64-bit operations are not supported, then ASSERT().
2913 If StartBit is greater than 63, then ASSERT().
2914 If EndBit is greater than 63, then ASSERT().
2915 If EndBit is less than StartBit, then ASSERT().
2916 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
2918 @param Operand Operand on which to perform the bitfield operation.
2919 @param StartBit The ordinal of the least significant bit in the bit field.
2921 @param EndBit The ordinal of the most significant bit in the bit field.
2923 @param OrData The value to OR with the read value from the value
2925 @return The new 64-bit value.
2939 Reads a bit field from a 64-bit value, performs a bitwise AND, and returns
2942 Performs a bitwise AND between the bit field specified by StartBit and EndBit
2943 in Operand and the value specified by AndData. All other bits in Operand are
2944 preserved. The new 64-bit value is returned.
2946 If 64-bit operations are not supported, then ASSERT().
2947 If StartBit is greater than 63, then ASSERT().
2948 If EndBit is greater than 63, then ASSERT().
2949 If EndBit is less than StartBit, then ASSERT().
2950 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
2952 @param Operand Operand on which to perform the bitfield operation.
2953 @param StartBit The ordinal of the least significant bit in the bit field.
2955 @param EndBit The ordinal of the most significant bit in the bit field.
2957 @param AndData The value to AND with the read value from the value
2959 @return The new 64-bit value.
2973 Reads a bit field from a 64-bit value, performs a bitwise AND followed by a
2974 bitwise OR, and returns the result.
2976 Performs a bitwise AND between the bit field specified by StartBit and EndBit
2977 in Operand and the value specified by AndData, followed by a bitwise
2978 OR with value specified by OrData. All other bits in Operand are
2979 preserved. The new 64-bit value is returned.
2981 If 64-bit operations are not supported, then ASSERT().
2982 If StartBit is greater than 63, then ASSERT().
2983 If EndBit is greater than 63, then ASSERT().
2984 If EndBit is less than StartBit, then ASSERT().
2985 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
2986 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
2988 @param Operand Operand on which to perform the bitfield operation.
2989 @param StartBit The ordinal of the least significant bit in the bit field.
2991 @param EndBit The ordinal of the most significant bit in the bit field.
2993 @param AndData The value to AND with the read value from the value.
2994 @param OrData The value to OR with the result of the AND operation.
2996 @return The new 64-bit value.
3001 BitFieldAndThenOr64 (
3010 // Base Library Checksum Functions
3014 Returns the sum of all elements in a buffer in unit of UINT8.
3015 During calculation, the carry bits are dropped.
3017 This function calculates the sum of all elements in a buffer
3018 in unit of UINT8. The carry bits in result of addition are dropped.
3019 The result is returned as UINT8. If Length is Zero, then Zero is
3022 If Buffer is NULL, then ASSERT().
3023 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
3025 @param Buffer The pointer to the buffer to carry out the sum operation.
3026 @param Length The size, in bytes, of Buffer.
3028 @return Sum The sum of Buffer with carry bits dropped during additions.
3034 IN CONST UINT8 *Buffer,
3040 Returns the two's complement checksum of all elements in a buffer
3043 This function first calculates the sum of the 8-bit values in the
3044 buffer specified by Buffer and Length. The carry bits in the result
3045 of addition are dropped. Then, the two's complement of the sum is
3046 returned. If Length is 0, then 0 is returned.
3048 If Buffer is NULL, then ASSERT().
3049 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
3051 @param Buffer The pointer to the buffer to carry out the checksum operation.
3052 @param Length The size, in bytes, of Buffer.
3054 @return Checksum The two's complement checksum of Buffer.
3059 CalculateCheckSum8 (
3060 IN CONST UINT8 *Buffer,
3066 Returns the sum of all elements in a buffer of 16-bit values. During
3067 calculation, the carry bits are dropped.
3069 This function calculates the sum of the 16-bit values in the buffer
3070 specified by Buffer and Length. The carry bits in result of addition are dropped.
3071 The 16-bit result is returned. If Length is 0, then 0 is returned.
3073 If Buffer is NULL, then ASSERT().
3074 If Buffer is not aligned on a 16-bit boundary, then ASSERT().
3075 If Length is not aligned on a 16-bit boundary, then ASSERT().
3076 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
3078 @param Buffer The pointer to the buffer to carry out the sum operation.
3079 @param Length The size, in bytes, of Buffer.
3081 @return Sum The sum of Buffer with carry bits dropped during additions.
3087 IN CONST UINT16 *Buffer,
3093 Returns the two's complement checksum of all elements in a buffer of
3096 This function first calculates the sum of the 16-bit values in the buffer
3097 specified by Buffer and Length. The carry bits in the result of addition
3098 are dropped. Then, the two's complement of the sum is returned. If Length
3099 is 0, then 0 is returned.
3101 If Buffer is NULL, then ASSERT().
3102 If Buffer is not aligned on a 16-bit boundary, then ASSERT().
3103 If Length is not aligned on a 16-bit boundary, then ASSERT().
3104 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
3106 @param Buffer The pointer to the buffer to carry out the checksum operation.
3107 @param Length The size, in bytes, of Buffer.
3109 @return Checksum The two's complement checksum of Buffer.
3114 CalculateCheckSum16 (
3115 IN CONST UINT16 *Buffer,
3121 Returns the sum of all elements in a buffer of 32-bit values. During
3122 calculation, the carry bits are dropped.
3124 This function calculates the sum of the 32-bit values in the buffer
3125 specified by Buffer and Length. The carry bits in result of addition are dropped.
3126 The 32-bit result is returned. If Length is 0, then 0 is returned.
3128 If Buffer is NULL, then ASSERT().
3129 If Buffer is not aligned on a 32-bit boundary, then ASSERT().
3130 If Length is not aligned on a 32-bit boundary, then ASSERT().
3131 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
3133 @param Buffer The pointer to the buffer to carry out the sum operation.
3134 @param Length The size, in bytes, of Buffer.
3136 @return Sum The sum of Buffer with carry bits dropped during additions.
3142 IN CONST UINT32 *Buffer,
3148 Returns the two's complement checksum of all elements in a buffer of
3151 This function first calculates the sum of the 32-bit values in the buffer
3152 specified by Buffer and Length. The carry bits in the result of addition
3153 are dropped. Then, the two's complement of the sum is returned. If Length
3154 is 0, then 0 is returned.
3156 If Buffer is NULL, then ASSERT().
3157 If Buffer is not aligned on a 32-bit boundary, then ASSERT().
3158 If Length is not aligned on a 32-bit boundary, then ASSERT().
3159 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
3161 @param Buffer The pointer to the buffer to carry out the checksum operation.
3162 @param Length The size, in bytes, of Buffer.
3164 @return Checksum The two's complement checksum of Buffer.
3169 CalculateCheckSum32 (
3170 IN CONST UINT32 *Buffer,
3176 Returns the sum of all elements in a buffer of 64-bit values. During
3177 calculation, the carry bits are dropped.
3179 This function calculates the sum of the 64-bit values in the buffer
3180 specified by Buffer and Length. The carry bits in result of addition are dropped.
3181 The 64-bit result is returned. If Length is 0, then 0 is returned.
3183 If Buffer is NULL, then ASSERT().
3184 If Buffer is not aligned on a 64-bit boundary, then ASSERT().
3185 If Length is not aligned on a 64-bit boundary, then ASSERT().
3186 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
3188 @param Buffer The pointer to the buffer to carry out the sum operation.
3189 @param Length The size, in bytes, of Buffer.
3191 @return Sum The sum of Buffer with carry bits dropped during additions.
3197 IN CONST UINT64 *Buffer,
3203 Returns the two's complement checksum of all elements in a buffer of
3206 This function first calculates the sum of the 64-bit values in the buffer
3207 specified by Buffer and Length. The carry bits in the result of addition
3208 are dropped. Then, the two's complement of the sum is returned. If Length
3209 is 0, then 0 is returned.
3211 If Buffer is NULL, then ASSERT().
3212 If Buffer is not aligned on a 64-bit boundary, then ASSERT().
3213 If Length is not aligned on a 64-bit boundary, then ASSERT().
3214 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
3216 @param Buffer The pointer to the buffer to carry out the checksum operation.
3217 @param Length The size, in bytes, of Buffer.
3219 @return Checksum The two's complement checksum of Buffer.
3224 CalculateCheckSum64 (
3225 IN CONST UINT64 *Buffer,
3231 // Base Library CPU Functions
3235 Function entry point used when a stack switch is requested with SwitchStack()
3237 @param Context1 Context1 parameter passed into SwitchStack().
3238 @param Context2 Context2 parameter passed into SwitchStack().
3243 (EFIAPI *SWITCH_STACK_ENTRY_POINT)(
3244 IN VOID *Context1, OPTIONAL
3245 IN VOID *Context2 OPTIONAL
3250 Used to serialize load and store operations.
3252 All loads and stores that proceed calls to this function are guaranteed to be
3253 globally visible when this function returns.
3264 Saves the current CPU context that can be restored with a call to LongJump()
3267 Saves the current CPU context in the buffer specified by JumpBuffer and
3268 returns 0. The initial call to SetJump() must always return 0. Subsequent
3269 calls to LongJump() cause a non-zero value to be returned by SetJump().
3271 If JumpBuffer is NULL, then ASSERT().
3272 For Itanium processors, if JumpBuffer is not aligned on a 16-byte boundary, then ASSERT().
3274 NOTE: The structure BASE_LIBRARY_JUMP_BUFFER is CPU architecture specific.
3275 The same structure must never be used for more than one CPU architecture context.
3276 For example, a BASE_LIBRARY_JUMP_BUFFER allocated by an IA-32 module must never be used from an x64 module.
3277 SetJump()/LongJump() is not currently supported for the EBC processor type.
3279 @param JumpBuffer A pointer to CPU context buffer.
3281 @retval 0 Indicates a return from SetJump().
3287 OUT BASE_LIBRARY_JUMP_BUFFER *JumpBuffer
3292 Restores the CPU context that was saved with SetJump().
3294 Restores the CPU context from the buffer specified by JumpBuffer. This
3295 function never returns to the caller. Instead is resumes execution based on
3296 the state of JumpBuffer.
3298 If JumpBuffer is NULL, then ASSERT().
3299 For Itanium processors, if JumpBuffer is not aligned on a 16-byte boundary, then ASSERT().
3300 If Value is 0, then ASSERT().
3302 @param JumpBuffer A pointer to CPU context buffer.
3303 @param Value The value to return when the SetJump() context is
3304 restored and must be non-zero.
3310 IN BASE_LIBRARY_JUMP_BUFFER *JumpBuffer,
3316 Enables CPU interrupts.
3327 Disables CPU interrupts.
3338 Disables CPU interrupts and returns the interrupt state prior to the disable
3341 @retval TRUE CPU interrupts were enabled on entry to this call.
3342 @retval FALSE CPU interrupts were disabled on entry to this call.
3347 SaveAndDisableInterrupts (
3353 Enables CPU interrupts for the smallest window required to capture any
3359 EnableDisableInterrupts (
3365 Retrieves the current CPU interrupt state.
3367 Returns TRUE if interrupts are currently enabled. Otherwise
3370 @retval TRUE CPU interrupts are enabled.
3371 @retval FALSE CPU interrupts are disabled.
3382 Set the current CPU interrupt state.
3384 Sets the current CPU interrupt state to the state specified by
3385 InterruptState. If InterruptState is TRUE, then interrupts are enabled. If
3386 InterruptState is FALSE, then interrupts are disabled. InterruptState is
3389 @param InterruptState TRUE if interrupts should enabled. FALSE if
3390 interrupts should be disabled.
3392 @return InterruptState
3398 IN BOOLEAN InterruptState
3403 Requests CPU to pause for a short period of time.
3405 Requests CPU to pause for a short period of time. Typically used in MP
3406 systems to prevent memory starvation while waiting for a spin lock.
3417 Transfers control to a function starting with a new stack.
3419 Transfers control to the function specified by EntryPoint using the
3420 new stack specified by NewStack and passing in the parameters specified
3421 by Context1 and Context2. Context1 and Context2 are optional and may
3422 be NULL. The function EntryPoint must never return. This function
3423 supports a variable number of arguments following the NewStack parameter.
3424 These additional arguments are ignored on IA-32, x64, and EBC architectures.
3425 Itanium processors expect one additional parameter of type VOID * that specifies
3426 the new backing store pointer.
3428 If EntryPoint is NULL, then ASSERT().
3429 If NewStack is NULL, then ASSERT().
3431 @param EntryPoint A pointer to function to call with the new stack.
3432 @param Context1 A pointer to the context to pass into the EntryPoint
3434 @param Context2 A pointer to the context to pass into the EntryPoint
3436 @param NewStack A pointer to the new stack to use for the EntryPoint
3438 @param ... This variable argument list is ignored for IA-32, x64, and
3439 EBC architectures. For Itanium processors, this variable
3440 argument list is expected to contain a single parameter of
3441 type VOID * that specifies the new backing store pointer.
3448 IN SWITCH_STACK_ENTRY_POINT EntryPoint,
3449 IN VOID *Context1, OPTIONAL
3450 IN VOID *Context2, OPTIONAL
3457 Generates a breakpoint on the CPU.
3459 Generates a breakpoint on the CPU. The breakpoint must be implemented such
3460 that code can resume normal execution after the breakpoint.
3471 Executes an infinite loop.
3473 Forces the CPU to execute an infinite loop. A debugger may be used to skip
3474 past the loop and the code that follows the loop must execute properly. This
3475 implies that the infinite loop must not cause the code that follow it to be
3485 #if defined (MDE_CPU_IPF)
3488 Flush a range of cache lines in the cache coherency domain of the calling
3491 Flushes the cache lines specified by Address and Length. If Address is not aligned
3492 on a cache line boundary, then entire cache line containing Address is flushed.
3493 If Address + Length is not aligned on a cache line boundary, then the entire cache
3494 line containing Address + Length - 1 is flushed. This function may choose to flush
3495 the entire cache if that is more efficient than flushing the specified range. If
3496 Length is 0, the no cache lines are flushed. Address is returned.
3497 This function is only available on Itanium processors.
3499 If Length is greater than (MAX_ADDRESS - Address + 1), then ASSERT().
3501 @param Address The base address of the instruction lines to invalidate. If
3502 the CPU is in a physical addressing mode, then Address is a
3503 physical address. If the CPU is in a virtual addressing mode,
3504 then Address is a virtual address.
3506 @param Length The number of bytes to invalidate from the instruction cache.
3513 AsmFlushCacheRange (
3520 Executes an FC instruction.
3521 Executes an FC instruction on the cache line specified by Address.
3522 The cache line size affected is at least 32-bytes (aligned on a 32-byte boundary).
3523 An implementation may flush a larger region. This function is only available on Itanium processors.
3525 @param Address The Address of cache line to be flushed.
3527 @return The address of FC instruction executed.
3538 Executes an FC.I instruction.
3539 Executes an FC.I instruction on the cache line specified by Address.
3540 The cache line size affected is at least 32-bytes (aligned on a 32-byte boundary).
3541 An implementation may flush a larger region. This function is only available on Itanium processors.
3543 @param Address The Address of cache line to be flushed.
3545 @return The address of the FC.I instruction executed.
3556 Reads the current value of a Processor Identifier Register (CPUID).
3558 Reads and returns the current value of Processor Identifier Register specified by Index.
3559 The Index of largest implemented CPUID (One less than the number of implemented CPUID
3560 registers) is determined by CPUID [3] bits {7:0}.
3561 No parameter checking is performed on Index. If the Index value is beyond the
3562 implemented CPUID register range, a Reserved Register/Field fault may occur. The caller
3563 must either guarantee that Index is valid, or the caller must set up fault handlers to
3564 catch the faults. This function is only available on Itanium processors.
3566 @param Index The 8-bit Processor Identifier Register index to read.
3568 @return The current value of Processor Identifier Register specified by Index.
3579 Reads the current value of 64-bit Processor Status Register (PSR).
3580 This function is only available on Itanium processors.
3582 @return The current value of PSR.
3593 Writes the current value of 64-bit Processor Status Register (PSR).
3595 No parameter checking is performed on Value. All bits of Value corresponding to
3596 reserved fields of PSR must be 0 or a Reserved Register/Field fault may occur.
3597 The caller must either guarantee that Value is valid, or the caller must set up
3598 fault handlers to catch the faults. This function is only available on Itanium processors.
3600 @param Value The 64-bit value to write to PSR.
3602 @return The 64-bit value written to the PSR.
3613 Reads the current value of 64-bit Kernel Register #0 (KR0).
3615 Reads and returns the current value of KR0.
3616 This function is only available on Itanium processors.
3618 @return The current value of KR0.
3629 Reads the current value of 64-bit Kernel Register #1 (KR1).
3631 Reads and returns the current value of KR1.
3632 This function is only available on Itanium processors.
3634 @return The current value of KR1.
3645 Reads the current value of 64-bit Kernel Register #2 (KR2).
3647 Reads and returns the current value of KR2.
3648 This function is only available on Itanium processors.
3650 @return The current value of KR2.
3661 Reads the current value of 64-bit Kernel Register #3 (KR3).
3663 Reads and returns the current value of KR3.
3664 This function is only available on Itanium processors.
3666 @return The current value of KR3.
3677 Reads the current value of 64-bit Kernel Register #4 (KR4).
3679 Reads and returns the current value of KR4.
3680 This function is only available on Itanium processors.
3682 @return The current value of KR4.
3693 Reads the current value of 64-bit Kernel Register #5 (KR5).
3695 Reads and returns the current value of KR5.
3696 This function is only available on Itanium processors.
3698 @return The current value of KR5.
3709 Reads the current value of 64-bit Kernel Register #6 (KR6).
3711 Reads and returns the current value of KR6.
3712 This function is only available on Itanium processors.
3714 @return The current value of KR6.
3725 Reads the current value of 64-bit Kernel Register #7 (KR7).
3727 Reads and returns the current value of KR7.
3728 This function is only available on Itanium processors.
3730 @return The current value of KR7.
3741 Write the current value of 64-bit Kernel Register #0 (KR0).
3743 Writes the current value of KR0. The 64-bit value written to
3744 the KR0 is returned. This function is only available on Itanium processors.
3746 @param Value The 64-bit value to write to KR0.
3748 @return The 64-bit value written to the KR0.
3759 Write the current value of 64-bit Kernel Register #1 (KR1).
3761 Writes the current value of KR1. The 64-bit value written to
3762 the KR1 is returned. This function is only available on Itanium processors.
3764 @param Value The 64-bit value to write to KR1.
3766 @return The 64-bit value written to the KR1.
3777 Write the current value of 64-bit Kernel Register #2 (KR2).
3779 Writes the current value of KR2. The 64-bit value written to
3780 the KR2 is returned. This function is only available on Itanium processors.
3782 @param Value The 64-bit value to write to KR2.
3784 @return The 64-bit value written to the KR2.
3795 Write the current value of 64-bit Kernel Register #3 (KR3).
3797 Writes the current value of KR3. The 64-bit value written to
3798 the KR3 is returned. This function is only available on Itanium processors.
3800 @param Value The 64-bit value to write to KR3.
3802 @return The 64-bit value written to the KR3.
3813 Write the current value of 64-bit Kernel Register #4 (KR4).
3815 Writes the current value of KR4. The 64-bit value written to
3816 the KR4 is returned. This function is only available on Itanium processors.
3818 @param Value The 64-bit value to write to KR4.
3820 @return The 64-bit value written to the KR4.
3831 Write the current value of 64-bit Kernel Register #5 (KR5).
3833 Writes the current value of KR5. The 64-bit value written to
3834 the KR5 is returned. This function is only available on Itanium processors.
3836 @param Value The 64-bit value to write to KR5.
3838 @return The 64-bit value written to the KR5.
3849 Write the current value of 64-bit Kernel Register #6 (KR6).
3851 Writes the current value of KR6. The 64-bit value written to
3852 the KR6 is returned. This function is only available on Itanium processors.
3854 @param Value The 64-bit value to write to KR6.
3856 @return The 64-bit value written to the KR6.
3867 Write the current value of 64-bit Kernel Register #7 (KR7).
3869 Writes the current value of KR7. The 64-bit value written to
3870 the KR7 is returned. This function is only available on Itanium processors.
3872 @param Value The 64-bit value to write to KR7.
3874 @return The 64-bit value written to the KR7.
3885 Reads the current value of Interval Timer Counter Register (ITC).
3887 Reads and returns the current value of ITC.
3888 This function is only available on Itanium processors.
3890 @return The current value of ITC.
3901 Reads the current value of Interval Timer Vector Register (ITV).
3903 Reads and returns the current value of ITV.
3904 This function is only available on Itanium processors.
3906 @return The current value of ITV.
3917 Reads the current value of Interval Timer Match Register (ITM).
3919 Reads and returns the current value of ITM.
3920 This function is only available on Itanium processors.
3922 @return The current value of ITM.
3932 Writes the current value of 64-bit Interval Timer Counter Register (ITC).
3934 Writes the current value of ITC. The 64-bit value written to the ITC is returned.
3935 This function is only available on Itanium processors.
3937 @param Value The 64-bit value to write to ITC.
3939 @return The 64-bit value written to the ITC.
3950 Writes the current value of 64-bit Interval Timer Match Register (ITM).
3952 Writes the current value of ITM. The 64-bit value written to the ITM is returned.
3953 This function is only available on Itanium processors.
3955 @param Value The 64-bit value to write to ITM.
3957 @return The 64-bit value written to the ITM.
3968 Writes the current value of 64-bit Interval Timer Vector Register (ITV).
3970 Writes the current value of ITV. The 64-bit value written to the ITV is returned.
3971 No parameter checking is performed on Value. All bits of Value corresponding to
3972 reserved fields of ITV must be 0 or a Reserved Register/Field fault may occur.
3973 The caller must either guarantee that Value is valid, or the caller must set up
3974 fault handlers to catch the faults.
3975 This function is only available on Itanium processors.
3977 @param Value The 64-bit value to write to ITV.
3979 @return The 64-bit value written to the ITV.
3990 Reads the current value of Default Control Register (DCR).
3992 Reads and returns the current value of DCR. This function is only available on Itanium processors.
3994 @return The current value of DCR.
4005 Reads the current value of Interruption Vector Address Register (IVA).
4007 Reads and returns the current value of IVA. This function is only available on Itanium processors.
4009 @return The current value of IVA.
4019 Reads the current value of Page Table Address Register (PTA).
4021 Reads and returns the current value of PTA. This function is only available on Itanium processors.
4023 @return The current value of PTA.
4034 Writes the current value of 64-bit Default Control Register (DCR).
4036 Writes the current value of DCR. The 64-bit value written to the DCR is returned.
4037 No parameter checking is performed on Value. All bits of Value corresponding to
4038 reserved fields of DCR must be 0 or a Reserved Register/Field fault may occur.
4039 The caller must either guarantee that Value is valid, or the caller must set up
4040 fault handlers to catch the faults.
4041 This function is only available on Itanium processors.
4043 @param Value The 64-bit value to write to DCR.
4045 @return The 64-bit value written to the DCR.
4056 Writes the current value of 64-bit Interruption Vector Address Register (IVA).
4058 Writes the current value of IVA. The 64-bit value written to the IVA is returned.
4059 The size of vector table is 32 K bytes and is 32 K bytes aligned
4060 the low 15 bits of Value is ignored when written.
4061 This function is only available on Itanium processors.
4063 @param Value The 64-bit value to write to IVA.
4065 @return The 64-bit value written to the IVA.
4076 Writes the current value of 64-bit Page Table Address Register (PTA).
4078 Writes the current value of PTA. The 64-bit value written to the PTA is returned.
4079 No parameter checking is performed on Value. All bits of Value corresponding to
4080 reserved fields of DCR must be 0 or a Reserved Register/Field fault may occur.
4081 The caller must either guarantee that Value is valid, or the caller must set up
4082 fault handlers to catch the faults.
4083 This function is only available on Itanium processors.
4085 @param Value The 64-bit value to write to PTA.
4087 @return The 64-bit value written to the PTA.
4097 Reads the current value of Local Interrupt ID Register (LID).
4099 Reads and returns the current value of LID. This function is only available on Itanium processors.
4101 @return The current value of LID.
4112 Reads the current value of External Interrupt Vector Register (IVR).
4114 Reads and returns the current value of IVR. This function is only available on Itanium processors.
4116 @return The current value of IVR.
4127 Reads the current value of Task Priority Register (TPR).
4129 Reads and returns the current value of TPR. This function is only available on Itanium processors.
4131 @return The current value of TPR.
4142 Reads the current value of External Interrupt Request Register #0 (IRR0).
4144 Reads and returns the current value of IRR0. This function is only available on Itanium processors.
4146 @return The current value of IRR0.
4157 Reads the current value of External Interrupt Request Register #1 (IRR1).
4159 Reads and returns the current value of IRR1. This function is only available on Itanium processors.
4161 @return The current value of IRR1.
4172 Reads the current value of External Interrupt Request Register #2 (IRR2).
4174 Reads and returns the current value of IRR2. This function is only available on Itanium processors.
4176 @return The current value of IRR2.
4187 Reads the current value of External Interrupt Request Register #3 (IRR3).
4189 Reads and returns the current value of IRR3. This function is only available on Itanium processors.
4191 @return The current value of IRR3.
4202 Reads the current value of Performance Monitor Vector Register (PMV).
4204 Reads and returns the current value of PMV. This function is only available on Itanium processors.
4206 @return The current value of PMV.
4217 Reads the current value of Corrected Machine Check Vector Register (CMCV).
4219 Reads and returns the current value of CMCV. This function is only available on Itanium processors.
4221 @return The current value of CMCV.
4232 Reads the current value of Local Redirection Register #0 (LRR0).
4234 Reads and returns the current value of LRR0. This function is only available on Itanium processors.
4236 @return The current value of LRR0.
4247 Reads the current value of Local Redirection Register #1 (LRR1).
4249 Reads and returns the current value of LRR1. This function is only available on Itanium processors.
4251 @return The current value of LRR1.
4262 Writes the current value of 64-bit Page Local Interrupt ID Register (LID).
4264 Writes the current value of LID. The 64-bit value written to the LID is returned.
4265 No parameter checking is performed on Value. All bits of Value corresponding to
4266 reserved fields of LID must be 0 or a Reserved Register/Field fault may occur.
4267 The caller must either guarantee that Value is valid, or the caller must set up
4268 fault handlers to catch the faults.
4269 This function is only available on Itanium processors.
4271 @param Value The 64-bit value to write to LID.
4273 @return The 64-bit value written to the LID.
4284 Writes the current value of 64-bit Task Priority Register (TPR).
4286 Writes the current value of TPR. The 64-bit value written to the TPR is returned.
4287 No parameter checking is performed on Value. All bits of Value corresponding to
4288 reserved fields of TPR must be 0 or a Reserved Register/Field fault may occur.
4289 The caller must either guarantee that Value is valid, or the caller must set up
4290 fault handlers to catch the faults.
4291 This function is only available on Itanium processors.
4293 @param Value The 64-bit value to write to TPR.
4295 @return The 64-bit value written to the TPR.
4306 Performs a write operation on End OF External Interrupt Register (EOI).
4308 Writes a value of 0 to the EOI Register. This function is only available on Itanium processors.
4319 Writes the current value of 64-bit Performance Monitor Vector Register (PMV).
4321 Writes the current value of PMV. The 64-bit value written to the PMV is returned.
4322 No parameter checking is performed on Value. All bits of Value corresponding
4323 to reserved fields of PMV must be 0 or a Reserved Register/Field fault may occur.
4324 The caller must either guarantee that Value is valid, or the caller must set up
4325 fault handlers to catch the faults.
4326 This function is only available on Itanium processors.
4328 @param Value The 64-bit value to write to PMV.
4330 @return The 64-bit value written to the PMV.
4341 Writes the current value of 64-bit Corrected Machine Check Vector Register (CMCV).
4343 Writes the current value of CMCV. The 64-bit value written to the CMCV is returned.
4344 No parameter checking is performed on Value. All bits of Value corresponding
4345 to reserved fields of CMCV must be 0 or a Reserved Register/Field fault may occur.
4346 The caller must either guarantee that Value is valid, or the caller must set up
4347 fault handlers to catch the faults.
4348 This function is only available on Itanium processors.
4350 @param Value The 64-bit value to write to CMCV.
4352 @return The 64-bit value written to the CMCV.
4363 Writes the current value of 64-bit Local Redirection Register #0 (LRR0).
4365 Writes the current value of LRR0. The 64-bit value written to the LRR0 is returned.
4366 No parameter checking is performed on Value. All bits of Value corresponding
4367 to reserved fields of LRR0 must be 0 or a Reserved Register/Field fault may occur.
4368 The caller must either guarantee that Value is valid, or the caller must set up
4369 fault handlers to catch the faults.
4370 This function is only available on Itanium processors.
4372 @param Value The 64-bit value to write to LRR0.
4374 @return The 64-bit value written to the LRR0.
4385 Writes the current value of 64-bit Local Redirection Register #1 (LRR1).
4387 Writes the current value of LRR1. The 64-bit value written to the LRR1 is returned.
4388 No parameter checking is performed on Value. All bits of Value corresponding
4389 to reserved fields of LRR1 must be 0 or a Reserved Register/Field fault may occur.
4390 The caller must either guarantee that Value is valid, or the caller must
4391 set up fault handlers to catch the faults.
4392 This function is only available on Itanium processors.
4394 @param Value The 64-bit value to write to LRR1.
4396 @return The 64-bit value written to the LRR1.
4407 Reads the current value of Instruction Breakpoint Register (IBR).
4409 The Instruction Breakpoint Registers are used in pairs. The even numbered
4410 registers contain breakpoint addresses, and the odd numbered registers contain
4411 breakpoint mask conditions. At least four instruction registers pairs are implemented
4412 on all processor models. Implemented registers are contiguous starting with
4413 register 0. No parameter checking is performed on Index, and if the Index value
4414 is beyond the implemented IBR register range, a Reserved Register/Field fault may
4415 occur. The caller must either guarantee that Index is valid, or the caller must
4416 set up fault handlers to catch the faults.
4417 This function is only available on Itanium processors.
4419 @param Index The 8-bit Instruction Breakpoint Register index to read.
4421 @return The current value of Instruction Breakpoint Register specified by Index.
4432 Reads the current value of Data Breakpoint Register (DBR).
4434 The Data Breakpoint Registers are used in pairs. The even numbered registers
4435 contain breakpoint addresses, and odd numbered registers contain breakpoint
4436 mask conditions. At least four data registers pairs are implemented on all processor
4437 models. Implemented registers are contiguous starting with register 0.
4438 No parameter checking is performed on Index. If the Index value is beyond
4439 the implemented DBR register range, a Reserved Register/Field fault may occur.
4440 The caller must either guarantee that Index is valid, or the caller must set up
4441 fault handlers to catch the faults.
4442 This function is only available on Itanium processors.
4444 @param Index The 8-bit Data Breakpoint Register index to read.
4446 @return The current value of Data Breakpoint Register specified by Index.
4457 Reads the current value of Performance Monitor Configuration Register (PMC).
4459 All processor implementations provide at least four performance counters
4460 (PMC/PMD [4]...PMC/PMD [7] pairs), and four performance monitor counter overflow
4461 status registers (PMC [0]... PMC [3]). Processor implementations may provide
4462 additional implementation-dependent PMC and PMD to increase the number of
4463 'generic' performance counters (PMC/PMD pairs). The remainder of PMC and PMD
4464 register set is implementation dependent. No parameter checking is performed
4465 on Index. If the Index value is beyond the implemented PMC register range,
4466 zero value will be returned.
4467 This function is only available on Itanium processors.
4469 @param Index The 8-bit Performance Monitor Configuration Register index to read.
4471 @return The current value of Performance Monitor Configuration Register
4483 Reads the current value of Performance Monitor Data Register (PMD).
4485 All processor implementations provide at least 4 performance counters
4486 (PMC/PMD [4]...PMC/PMD [7] pairs), and 4 performance monitor counter
4487 overflow status registers (PMC [0]... PMC [3]). Processor implementations may
4488 provide additional implementation-dependent PMC and PMD to increase the number
4489 of 'generic' performance counters (PMC/PMD pairs). The remainder of PMC and PMD
4490 register set is implementation dependent. No parameter checking is performed
4491 on Index. If the Index value is beyond the implemented PMD register range,
4492 zero value will be returned.
4493 This function is only available on Itanium processors.
4495 @param Index The 8-bit Performance Monitor Data Register index to read.
4497 @return The current value of Performance Monitor Data Register specified by Index.
4508 Writes the current value of 64-bit Instruction Breakpoint Register (IBR).
4510 Writes current value of Instruction Breakpoint Register specified by Index.
4511 The Instruction Breakpoint Registers are used in pairs. The even numbered
4512 registers contain breakpoint addresses, and odd numbered registers contain
4513 breakpoint mask conditions. At least four instruction registers pairs are implemented
4514 on all processor models. Implemented registers are contiguous starting with
4515 register 0. No parameter checking is performed on Index. If the Index value
4516 is beyond the implemented IBR register range, a Reserved Register/Field fault may
4517 occur. The caller must either guarantee that Index is valid, or the caller must
4518 set up fault handlers to catch the faults.
4519 This function is only available on Itanium processors.
4521 @param Index The 8-bit Instruction Breakpoint Register index to write.
4522 @param Value The 64-bit value to write to IBR.
4524 @return The 64-bit value written to the IBR.
4536 Writes the current value of 64-bit Data Breakpoint Register (DBR).
4538 Writes current value of Data Breakpoint Register specified by Index.
4539 The Data Breakpoint Registers are used in pairs. The even numbered registers
4540 contain breakpoint addresses, and odd numbered registers contain breakpoint
4541 mask conditions. At least four data registers pairs are implemented on all processor
4542 models. Implemented registers are contiguous starting with register 0. No parameter
4543 checking is performed on Index. If the Index value is beyond the implemented
4544 DBR register range, a Reserved Register/Field fault may occur. The caller must
4545 either guarantee that Index is valid, or the caller must set up fault handlers to
4547 This function is only available on Itanium processors.
4549 @param Index The 8-bit Data Breakpoint Register index to write.
4550 @param Value The 64-bit value to write to DBR.
4552 @return The 64-bit value written to the DBR.
4564 Writes the current value of 64-bit Performance Monitor Configuration Register (PMC).
4566 Writes current value of Performance Monitor Configuration Register specified by Index.
4567 All processor implementations provide at least four performance counters
4568 (PMC/PMD [4]...PMC/PMD [7] pairs), and four performance monitor counter overflow status
4569 registers (PMC [0]... PMC [3]). Processor implementations may provide additional
4570 implementation-dependent PMC and PMD to increase the number of 'generic' performance
4571 counters (PMC/PMD pairs). The remainder of PMC and PMD register set is implementation
4572 dependent. No parameter checking is performed on Index. If the Index value is
4573 beyond the implemented PMC register range, the write is ignored.
4574 This function is only available on Itanium processors.
4576 @param Index The 8-bit Performance Monitor Configuration Register index to write.
4577 @param Value The 64-bit value to write to PMC.
4579 @return The 64-bit value written to the PMC.
4591 Writes the current value of 64-bit Performance Monitor Data Register (PMD).
4593 Writes current value of Performance Monitor Data Register specified by Index.
4594 All processor implementations provide at least four performance counters
4595 (PMC/PMD [4]...PMC/PMD [7] pairs), and four performance monitor counter overflow
4596 status registers (PMC [0]... PMC [3]). Processor implementations may provide
4597 additional implementation-dependent PMC and PMD to increase the number of 'generic'
4598 performance counters (PMC/PMD pairs). The remainder of PMC and PMD register set
4599 is implementation dependent. No parameter checking is performed on Index. If the
4600 Index value is beyond the implemented PMD register range, the write is ignored.
4601 This function is only available on Itanium processors.
4603 @param Index The 8-bit Performance Monitor Data Register index to write.
4604 @param Value The 64-bit value to write to PMD.
4606 @return The 64-bit value written to the PMD.
4618 Reads the current value of 64-bit Global Pointer (GP).
4620 Reads and returns the current value of GP.
4621 This function is only available on Itanium processors.
4623 @return The current value of GP.
4634 Write the current value of 64-bit Global Pointer (GP).
4636 Writes the current value of GP. The 64-bit value written to the GP is returned.
4637 No parameter checking is performed on Value.
4638 This function is only available on Itanium processors.
4640 @param Value The 64-bit value to write to GP.
4642 @return The 64-bit value written to the GP.
4653 Reads the current value of 64-bit Stack Pointer (SP).
4655 Reads and returns the current value of SP.
4656 This function is only available on Itanium processors.
4658 @return The current value of SP.
4669 /// Valid Index value for AsmReadControlRegister().
4671 #define IPF_CONTROL_REGISTER_DCR 0
4672 #define IPF_CONTROL_REGISTER_ITM 1
4673 #define IPF_CONTROL_REGISTER_IVA 2
4674 #define IPF_CONTROL_REGISTER_PTA 8
4675 #define IPF_CONTROL_REGISTER_IPSR 16
4676 #define IPF_CONTROL_REGISTER_ISR 17
4677 #define IPF_CONTROL_REGISTER_IIP 19
4678 #define IPF_CONTROL_REGISTER_IFA 20
4679 #define IPF_CONTROL_REGISTER_ITIR 21
4680 #define IPF_CONTROL_REGISTER_IIPA 22
4681 #define IPF_CONTROL_REGISTER_IFS 23
4682 #define IPF_CONTROL_REGISTER_IIM 24
4683 #define IPF_CONTROL_REGISTER_IHA 25
4684 #define IPF_CONTROL_REGISTER_LID 64
4685 #define IPF_CONTROL_REGISTER_IVR 65
4686 #define IPF_CONTROL_REGISTER_TPR 66
4687 #define IPF_CONTROL_REGISTER_EOI 67
4688 #define IPF_CONTROL_REGISTER_IRR0 68
4689 #define IPF_CONTROL_REGISTER_IRR1 69
4690 #define IPF_CONTROL_REGISTER_IRR2 70
4691 #define IPF_CONTROL_REGISTER_IRR3 71
4692 #define IPF_CONTROL_REGISTER_ITV 72
4693 #define IPF_CONTROL_REGISTER_PMV 73
4694 #define IPF_CONTROL_REGISTER_CMCV 74
4695 #define IPF_CONTROL_REGISTER_LRR0 80
4696 #define IPF_CONTROL_REGISTER_LRR1 81
4699 Reads a 64-bit control register.
4701 Reads and returns the control register specified by Index. The valid Index valued
4702 are defined above in "Related Definitions".
4703 If Index is invalid then 0xFFFFFFFFFFFFFFFF is returned. This function is only
4704 available on Itanium processors.
4706 @param Index The index of the control register to read.
4708 @return The control register specified by Index.
4713 AsmReadControlRegister (
4719 /// Valid Index value for AsmReadApplicationRegister().
4721 #define IPF_APPLICATION_REGISTER_K0 0
4722 #define IPF_APPLICATION_REGISTER_K1 1
4723 #define IPF_APPLICATION_REGISTER_K2 2
4724 #define IPF_APPLICATION_REGISTER_K3 3
4725 #define IPF_APPLICATION_REGISTER_K4 4
4726 #define IPF_APPLICATION_REGISTER_K5 5
4727 #define IPF_APPLICATION_REGISTER_K6 6
4728 #define IPF_APPLICATION_REGISTER_K7 7
4729 #define IPF_APPLICATION_REGISTER_RSC 16
4730 #define IPF_APPLICATION_REGISTER_BSP 17
4731 #define IPF_APPLICATION_REGISTER_BSPSTORE 18
4732 #define IPF_APPLICATION_REGISTER_RNAT 19
4733 #define IPF_APPLICATION_REGISTER_FCR 21
4734 #define IPF_APPLICATION_REGISTER_EFLAG 24
4735 #define IPF_APPLICATION_REGISTER_CSD 25
4736 #define IPF_APPLICATION_REGISTER_SSD 26
4737 #define IPF_APPLICATION_REGISTER_CFLG 27
4738 #define IPF_APPLICATION_REGISTER_FSR 28
4739 #define IPF_APPLICATION_REGISTER_FIR 29
4740 #define IPF_APPLICATION_REGISTER_FDR 30
4741 #define IPF_APPLICATION_REGISTER_CCV 32
4742 #define IPF_APPLICATION_REGISTER_UNAT 36
4743 #define IPF_APPLICATION_REGISTER_FPSR 40
4744 #define IPF_APPLICATION_REGISTER_ITC 44
4745 #define IPF_APPLICATION_REGISTER_PFS 64
4746 #define IPF_APPLICATION_REGISTER_LC 65
4747 #define IPF_APPLICATION_REGISTER_EC 66
4750 Reads a 64-bit application register.
4752 Reads and returns the application register specified by Index. The valid Index
4753 valued are defined above in "Related Definitions".
4754 If Index is invalid then 0xFFFFFFFFFFFFFFFF is returned. This function is only
4755 available on Itanium processors.
4757 @param Index The index of the application register to read.
4759 @return The application register specified by Index.
4764 AsmReadApplicationRegister (
4770 Reads the current value of a Machine Specific Register (MSR).
4772 Reads and returns the current value of the Machine Specific Register specified by Index. No
4773 parameter checking is performed on Index, and if the Index value is beyond the implemented MSR
4774 register range, a Reserved Register/Field fault may occur. The caller must either guarantee that
4775 Index is valid, or the caller must set up fault handlers to catch the faults. This function is
4776 only available on Itanium processors.
4778 @param Index The 8-bit Machine Specific Register index to read.
4780 @return The current value of the Machine Specific Register specified by Index.
4791 Writes the current value of a Machine Specific Register (MSR).
4793 Writes Value to the Machine Specific Register specified by Index. Value is returned. No
4794 parameter checking is performed on Index, and if the Index value is beyond the implemented MSR
4795 register range, a Reserved Register/Field fault may occur. The caller must either guarantee that
4796 Index is valid, or the caller must set up fault handlers to catch the faults. This function is
4797 only available on Itanium processors.
4799 @param Index The 8-bit Machine Specific Register index to write.
4800 @param Value The 64-bit value to write to the Machine Specific Register.
4802 @return The 64-bit value to write to the Machine Specific Register.
4814 Determines if the CPU is currently executing in virtual, physical, or mixed mode.
4816 Determines the current execution mode of the CPU.
4817 If the CPU is in virtual mode(PSR.RT=1, PSR.DT=1, PSR.IT=1), then 1 is returned.
4818 If the CPU is in physical mode(PSR.RT=0, PSR.DT=0, PSR.IT=0), then 0 is returned.
4819 If the CPU is not in physical mode or virtual mode, then it is in mixed mode,
4821 This function is only available on Itanium processors.
4823 @retval 1 The CPU is in virtual mode.
4824 @retval 0 The CPU is in physical mode.
4825 @retval -1 The CPU is in mixed mode.
4836 Makes a PAL procedure call.
4838 This is a wrapper function to make a PAL procedure call. Based on the Index
4839 value this API will make static or stacked PAL call. The following table
4840 describes the usage of PAL Procedure Index Assignment. Architected procedures
4841 may be designated as required or optional. If a PAL procedure is specified
4842 as optional, a unique return code of 0xFFFFFFFFFFFFFFFF is returned in the
4843 Status field of the PAL_CALL_RETURN structure.
4844 This indicates that the procedure is not present in this PAL implementation.
4845 It is the caller's responsibility to check for this return code after calling
4846 any optional PAL procedure.
4847 No parameter checking is performed on the 5 input parameters, but there are
4848 some common rules that the caller should follow when making a PAL call. Any
4849 address passed to PAL as buffers for return parameters must be 8-byte aligned.
4850 Unaligned addresses may cause undefined results. For those parameters defined
4851 as reserved or some fields defined as reserved must be zero filled or the invalid
4852 argument return value may be returned or undefined result may occur during the
4853 execution of the procedure. If the PalEntryPoint does not point to a valid
4854 PAL entry point then the system behavior is undefined. This function is only
4855 available on Itanium processors.
4857 @param PalEntryPoint The PAL procedure calls entry point.
4858 @param Index The PAL procedure Index number.
4859 @param Arg2 The 2nd parameter for PAL procedure calls.
4860 @param Arg3 The 3rd parameter for PAL procedure calls.
4861 @param Arg4 The 4th parameter for PAL procedure calls.
4863 @return structure returned from the PAL Call procedure, including the status and return value.
4869 IN UINT64 PalEntryPoint,
4877 #if defined (MDE_CPU_IA32) || defined (MDE_CPU_X64)
4879 /// IA32 and x64 Specific Functions.
4880 /// Byte packed structure for 16-bit Real Mode EFLAGS.
4884 UINT32 CF:1; ///< Carry Flag.
4885 UINT32 Reserved_0:1; ///< Reserved.
4886 UINT32 PF:1; ///< Parity Flag.
4887 UINT32 Reserved_1:1; ///< Reserved.
4888 UINT32 AF:1; ///< Auxiliary Carry Flag.
4889 UINT32 Reserved_2:1; ///< Reserved.
4890 UINT32 ZF:1; ///< Zero Flag.
4891 UINT32 SF:1; ///< Sign Flag.
4892 UINT32 TF:1; ///< Trap Flag.
4893 UINT32 IF:1; ///< Interrupt Enable Flag.
4894 UINT32 DF:1; ///< Direction Flag.
4895 UINT32 OF:1; ///< Overflow Flag.
4896 UINT32 IOPL:2; ///< I/O Privilege Level.
4897 UINT32 NT:1; ///< Nested Task.
4898 UINT32 Reserved_3:1; ///< Reserved.
4904 /// Byte packed structure for EFLAGS/RFLAGS.
4905 /// 32-bits on IA-32.
4906 /// 64-bits on x64. The upper 32-bits on x64 are reserved.
4910 UINT32 CF:1; ///< Carry Flag.
4911 UINT32 Reserved_0:1; ///< Reserved.
4912 UINT32 PF:1; ///< Parity Flag.
4913 UINT32 Reserved_1:1; ///< Reserved.
4914 UINT32 AF:1; ///< Auxiliary Carry Flag.
4915 UINT32 Reserved_2:1; ///< Reserved.
4916 UINT32 ZF:1; ///< Zero Flag.
4917 UINT32 SF:1; ///< Sign Flag.
4918 UINT32 TF:1; ///< Trap Flag.
4919 UINT32 IF:1; ///< Interrupt Enable Flag.
4920 UINT32 DF:1; ///< Direction Flag.
4921 UINT32 OF:1; ///< Overflow Flag.
4922 UINT32 IOPL:2; ///< I/O Privilege Level.
4923 UINT32 NT:1; ///< Nested Task.
4924 UINT32 Reserved_3:1; ///< Reserved.
4925 UINT32 RF:1; ///< Resume Flag.
4926 UINT32 VM:1; ///< Virtual 8086 Mode.
4927 UINT32 AC:1; ///< Alignment Check.
4928 UINT32 VIF:1; ///< Virtual Interrupt Flag.
4929 UINT32 VIP:1; ///< Virtual Interrupt Pending.
4930 UINT32 ID:1; ///< ID Flag.
4931 UINT32 Reserved_4:10; ///< Reserved.
4937 /// Byte packed structure for Control Register 0 (CR0).
4938 /// 32-bits on IA-32.
4939 /// 64-bits on x64. The upper 32-bits on x64 are reserved.
4943 UINT32 PE:1; ///< Protection Enable.
4944 UINT32 MP:1; ///< Monitor Coprocessor.
4945 UINT32 EM:1; ///< Emulation.
4946 UINT32 TS:1; ///< Task Switched.
4947 UINT32 ET:1; ///< Extension Type.
4948 UINT32 NE:1; ///< Numeric Error.
4949 UINT32 Reserved_0:10; ///< Reserved.
4950 UINT32 WP:1; ///< Write Protect.
4951 UINT32 Reserved_1:1; ///< Reserved.
4952 UINT32 AM:1; ///< Alignment Mask.
4953 UINT32 Reserved_2:10; ///< Reserved.
4954 UINT32 NW:1; ///< Mot Write-through.
4955 UINT32 CD:1; ///< Cache Disable.
4956 UINT32 PG:1; ///< Paging.
4962 /// Byte packed structure for Control Register 4 (CR4).
4963 /// 32-bits on IA-32.
4964 /// 64-bits on x64. The upper 32-bits on x64 are reserved.
4968 UINT32 VME:1; ///< Virtual-8086 Mode Extensions.
4969 UINT32 PVI:1; ///< Protected-Mode Virtual Interrupts.
4970 UINT32 TSD:1; ///< Time Stamp Disable.
4971 UINT32 DE:1; ///< Debugging Extensions.
4972 UINT32 PSE:1; ///< Page Size Extensions.
4973 UINT32 PAE:1; ///< Physical Address Extension.
4974 UINT32 MCE:1; ///< Machine Check Enable.
4975 UINT32 PGE:1; ///< Page Global Enable.
4976 UINT32 PCE:1; ///< Performance Monitoring Counter
4978 UINT32 OSFXSR:1; ///< Operating System Support for
4979 ///< FXSAVE and FXRSTOR instructions
4980 UINT32 OSXMMEXCPT:1; ///< Operating System Support for
4981 ///< Unmasked SIMD Floating Point
4983 UINT32 Reserved_0:2; ///< Reserved.
4984 UINT32 VMXE:1; ///< VMX Enable
4985 UINT32 Reserved_1:18; ///< Reserved.
4991 /// Byte packed structure for a segment descriptor in a GDT/LDT.
5010 } IA32_SEGMENT_DESCRIPTOR;
5013 /// Byte packed structure for an IDTR, GDTR, LDTR descriptor.
5022 #define IA32_IDT_GATE_TYPE_TASK 0x85
5023 #define IA32_IDT_GATE_TYPE_INTERRUPT_16 0x86
5024 #define IA32_IDT_GATE_TYPE_TRAP_16 0x87
5025 #define IA32_IDT_GATE_TYPE_INTERRUPT_32 0x8E
5026 #define IA32_IDT_GATE_TYPE_TRAP_32 0x8F
5029 #if defined (MDE_CPU_IA32)
5031 /// Byte packed structure for an IA-32 Interrupt Gate Descriptor.
5035 UINT32 OffsetLow:16; ///< Offset bits 15..0.
5036 UINT32 Selector:16; ///< Selector.
5037 UINT32 Reserved_0:8; ///< Reserved.
5038 UINT32 GateType:8; ///< Gate Type. See #defines above.
5039 UINT32 OffsetHigh:16; ///< Offset bits 31..16.
5042 } IA32_IDT_GATE_DESCRIPTOR;
5046 #if defined (MDE_CPU_X64)
5048 /// Byte packed structure for an x64 Interrupt Gate Descriptor.
5052 UINT32 OffsetLow:16; ///< Offset bits 15..0.
5053 UINT32 Selector:16; ///< Selector.
5054 UINT32 Reserved_0:8; ///< Reserved.
5055 UINT32 GateType:8; ///< Gate Type. See #defines above.
5056 UINT32 OffsetHigh:16; ///< Offset bits 31..16.
5057 UINT32 OffsetUpper:32; ///< Offset bits 63..32.
5058 UINT32 Reserved_1:32; ///< Reserved.
5064 } IA32_IDT_GATE_DESCRIPTOR;
5069 /// Byte packed structure for an FP/SSE/SSE2 context.
5076 /// Structures for the 16-bit real mode thunks.
5129 IA32_EFLAGS32 EFLAGS;
5139 } IA32_REGISTER_SET;
5142 /// Byte packed structure for an 16-bit real mode thunks.
5145 IA32_REGISTER_SET *RealModeState;
5146 VOID *RealModeBuffer;
5147 UINT32 RealModeBufferSize;
5148 UINT32 ThunkAttributes;
5151 #define THUNK_ATTRIBUTE_BIG_REAL_MODE 0x00000001
5152 #define THUNK_ATTRIBUTE_DISABLE_A20_MASK_INT_15 0x00000002
5153 #define THUNK_ATTRIBUTE_DISABLE_A20_MASK_KBD_CTRL 0x00000004
5156 Retrieves CPUID information.
5158 Executes the CPUID instruction with EAX set to the value specified by Index.
5159 This function always returns Index.
5160 If Eax is not NULL, then the value of EAX after CPUID is returned in Eax.
5161 If Ebx is not NULL, then the value of EBX after CPUID is returned in Ebx.
5162 If Ecx is not NULL, then the value of ECX after CPUID is returned in Ecx.
5163 If Edx is not NULL, then the value of EDX after CPUID is returned in Edx.
5164 This function is only available on IA-32 and x64.
5166 @param Index The 32-bit value to load into EAX prior to invoking the CPUID
5168 @param Eax The pointer to the 32-bit EAX value returned by the CPUID
5169 instruction. This is an optional parameter that may be NULL.
5170 @param Ebx The pointer to the 32-bit EBX value returned by the CPUID
5171 instruction. This is an optional parameter that may be NULL.
5172 @param Ecx The pointer to the 32-bit ECX value returned by the CPUID
5173 instruction. This is an optional parameter that may be NULL.
5174 @param Edx The pointer to the 32-bit EDX value returned by the CPUID
5175 instruction. This is an optional parameter that may be NULL.
5184 OUT UINT32 *Eax, OPTIONAL
5185 OUT UINT32 *Ebx, OPTIONAL
5186 OUT UINT32 *Ecx, OPTIONAL
5187 OUT UINT32 *Edx OPTIONAL
5192 Retrieves CPUID information using an extended leaf identifier.
5194 Executes the CPUID instruction with EAX set to the value specified by Index
5195 and ECX set to the value specified by SubIndex. This function always returns
5196 Index. This function is only available on IA-32 and x64.
5198 If Eax is not NULL, then the value of EAX after CPUID is returned in Eax.
5199 If Ebx is not NULL, then the value of EBX after CPUID is returned in Ebx.
5200 If Ecx is not NULL, then the value of ECX after CPUID is returned in Ecx.
5201 If Edx is not NULL, then the value of EDX after CPUID is returned in Edx.
5203 @param Index The 32-bit value to load into EAX prior to invoking the
5205 @param SubIndex The 32-bit value to load into ECX prior to invoking the
5207 @param Eax The pointer to the 32-bit EAX value returned by the CPUID
5208 instruction. This is an optional parameter that may be
5210 @param Ebx The pointer to the 32-bit EBX value returned by the CPUID
5211 instruction. This is an optional parameter that may be
5213 @param Ecx The pointer to the 32-bit ECX value returned by the CPUID
5214 instruction. This is an optional parameter that may be
5216 @param Edx The pointer to the 32-bit EDX value returned by the CPUID
5217 instruction. This is an optional parameter that may be
5228 OUT UINT32 *Eax, OPTIONAL
5229 OUT UINT32 *Ebx, OPTIONAL
5230 OUT UINT32 *Ecx, OPTIONAL
5231 OUT UINT32 *Edx OPTIONAL
5236 Set CD bit and clear NW bit of CR0 followed by a WBINVD.
5238 Disables the caches by setting the CD bit of CR0 to 1, clearing the NW bit of CR0 to 0,
5239 and executing a WBINVD instruction. This function is only available on IA-32 and x64.
5250 Perform a WBINVD and clear both the CD and NW bits of CR0.
5252 Enables the caches by executing a WBINVD instruction and then clear both the CD and NW
5253 bits of CR0 to 0. This function is only available on IA-32 and x64.
5264 Returns the lower 32-bits of a Machine Specific Register(MSR).
5266 Reads and returns the lower 32-bits of the MSR specified by Index.
5267 No parameter checking is performed on Index, and some Index values may cause
5268 CPU exceptions. The caller must either guarantee that Index is valid, or the
5269 caller must set up exception handlers to catch the exceptions. This function
5270 is only available on IA-32 and x64.
5272 @param Index The 32-bit MSR index to read.
5274 @return The lower 32 bits of the MSR identified by Index.
5285 Writes a 32-bit value to a Machine Specific Register(MSR), and returns the value.
5286 The upper 32-bits of the MSR are set to zero.
5288 Writes the 32-bit value specified by Value to the MSR specified by Index. The
5289 upper 32-bits of the MSR write are set to zero. The 32-bit value written to
5290 the MSR is returned. No parameter checking is performed on Index or Value,
5291 and some of these may cause CPU exceptions. The caller must either guarantee
5292 that Index and Value are valid, or the caller must establish proper exception
5293 handlers. This function is only available on IA-32 and x64.
5295 @param Index The 32-bit MSR index to write.
5296 @param Value The 32-bit value to write to the MSR.
5310 Reads a 64-bit MSR, performs a bitwise OR on the lower 32-bits, and
5311 writes the result back to the 64-bit MSR.
5313 Reads the 64-bit MSR specified by Index, performs a bitwise OR
5314 between the lower 32-bits of the read result and the value specified by
5315 OrData, and writes the result to the 64-bit MSR specified by Index. The lower
5316 32-bits of the value written to the MSR is returned. No parameter checking is
5317 performed on Index or OrData, and some of these may cause CPU exceptions. The
5318 caller must either guarantee that Index and OrData are valid, or the caller
5319 must establish proper exception handlers. This function is only available on
5322 @param Index The 32-bit MSR index to write.
5323 @param OrData The value to OR with the read value from the MSR.
5325 @return The lower 32-bit value written to the MSR.
5337 Reads a 64-bit MSR, performs a bitwise AND on the lower 32-bits, and writes
5338 the result back to the 64-bit MSR.
5340 Reads the 64-bit MSR specified by Index, performs a bitwise AND between the
5341 lower 32-bits of the read result and the value specified by AndData, and
5342 writes the result to the 64-bit MSR specified by Index. The lower 32-bits of
5343 the value written to the MSR is returned. No parameter checking is performed
5344 on Index or AndData, and some of these may cause CPU exceptions. The caller
5345 must either guarantee that Index and AndData are valid, or the caller must
5346 establish proper exception handlers. This function is only available on IA-32
5349 @param Index The 32-bit MSR index to write.
5350 @param AndData The value to AND with the read value from the MSR.
5352 @return The lower 32-bit value written to the MSR.
5364 Reads a 64-bit MSR, performs a bitwise AND followed by a bitwise OR
5365 on the lower 32-bits, and writes the result back to the 64-bit MSR.
5367 Reads the 64-bit MSR specified by Index, performs a bitwise AND between the
5368 lower 32-bits of the read result and the value specified by AndData
5369 preserving the upper 32-bits, performs a bitwise OR between the
5370 result of the AND operation and the value specified by OrData, and writes the
5371 result to the 64-bit MSR specified by Address. The lower 32-bits of the value
5372 written to the MSR is returned. No parameter checking is performed on Index,
5373 AndData, or OrData, and some of these may cause CPU exceptions. The caller
5374 must either guarantee that Index, AndData, and OrData are valid, or the
5375 caller must establish proper exception handlers. This function is only
5376 available on IA-32 and x64.
5378 @param Index The 32-bit MSR index to write.
5379 @param AndData The value to AND with the read value from the MSR.
5380 @param OrData The value to OR with the result of the AND operation.
5382 @return The lower 32-bit value written to the MSR.
5395 Reads a bit field of an MSR.
5397 Reads the bit field in the lower 32-bits of a 64-bit MSR. The bit field is
5398 specified by the StartBit and the EndBit. The value of the bit field is
5399 returned. The caller must either guarantee that Index is valid, or the caller
5400 must set up exception handlers to catch the exceptions. This function is only
5401 available on IA-32 and x64.
5403 If StartBit is greater than 31, then ASSERT().
5404 If EndBit is greater than 31, then ASSERT().
5405 If EndBit is less than StartBit, then ASSERT().
5407 @param Index The 32-bit MSR index to read.
5408 @param StartBit The ordinal of the least significant bit in the bit field.
5410 @param EndBit The ordinal of the most significant bit in the bit field.
5413 @return The bit field read from the MSR.
5418 AsmMsrBitFieldRead32 (
5426 Writes a bit field to an MSR.
5428 Writes Value to a bit field in the lower 32-bits of a 64-bit MSR. The bit
5429 field is specified by the StartBit and the EndBit. All other bits in the
5430 destination MSR are preserved. The lower 32-bits of the MSR written is
5431 returned. The caller must either guarantee that Index and the data written
5432 is valid, or the caller must set up exception handlers to catch the exceptions.
5433 This function is only available on IA-32 and x64.
5435 If StartBit is greater than 31, then ASSERT().
5436 If EndBit is greater than 31, then ASSERT().
5437 If EndBit is less than StartBit, then ASSERT().
5438 If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
5440 @param Index The 32-bit MSR index to write.
5441 @param StartBit The ordinal of the least significant bit in the bit field.
5443 @param EndBit The ordinal of the most significant bit in the bit field.
5445 @param Value New value of the bit field.
5447 @return The lower 32-bit of the value written to the MSR.
5452 AsmMsrBitFieldWrite32 (
5461 Reads a bit field in a 64-bit MSR, performs a bitwise OR, and writes the
5462 result back to the bit field in the 64-bit MSR.
5464 Reads the 64-bit MSR specified by Index, performs a bitwise OR
5465 between the read result and the value specified by OrData, and writes the
5466 result to the 64-bit MSR specified by Index. The lower 32-bits of the value
5467 written to the MSR are returned. Extra left bits in OrData are stripped. The
5468 caller must either guarantee that Index and the data written is valid, or
5469 the caller must set up exception handlers to catch the exceptions. This
5470 function is only available on IA-32 and x64.
5472 If StartBit is greater than 31, then ASSERT().
5473 If EndBit is greater than 31, then ASSERT().
5474 If EndBit is less than StartBit, then ASSERT().
5475 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
5477 @param Index The 32-bit MSR index to write.
5478 @param StartBit The ordinal of the least significant bit in the bit field.
5480 @param EndBit The ordinal of the most significant bit in the bit field.
5482 @param OrData The value to OR with the read value from the MSR.
5484 @return The lower 32-bit of the value written to the MSR.
5489 AsmMsrBitFieldOr32 (
5498 Reads a bit field in a 64-bit MSR, performs a bitwise AND, and writes the
5499 result back to the bit field in the 64-bit MSR.
5501 Reads the 64-bit MSR specified by Index, performs a bitwise AND between the
5502 read result and the value specified by AndData, and writes the result to the
5503 64-bit MSR specified by Index. The lower 32-bits of the value written to the
5504 MSR are returned. Extra left bits in AndData are stripped. The caller must
5505 either guarantee that Index and the data written is valid, or the caller must
5506 set up exception handlers to catch the exceptions. This function is only
5507 available on IA-32 and x64.
5509 If StartBit is greater than 31, then ASSERT().
5510 If EndBit is greater than 31, then ASSERT().
5511 If EndBit is less than StartBit, then ASSERT().
5512 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
5514 @param Index The 32-bit MSR index to write.
5515 @param StartBit The ordinal of the least significant bit in the bit field.
5517 @param EndBit The ordinal of the most significant bit in the bit field.
5519 @param AndData The value to AND with the read value from the MSR.
5521 @return The lower 32-bit of the value written to the MSR.
5526 AsmMsrBitFieldAnd32 (
5535 Reads a bit field in a 64-bit MSR, performs a bitwise AND followed by a
5536 bitwise OR, and writes the result back to the bit field in the
5539 Reads the 64-bit MSR specified by Index, performs a bitwise AND followed by a
5540 bitwise OR between the read result and the value specified by
5541 AndData, and writes the result to the 64-bit MSR specified by Index. The
5542 lower 32-bits of the value written to the MSR are returned. Extra left bits
5543 in both AndData and OrData are stripped. The caller must either guarantee
5544 that Index and the data written is valid, or the caller must set up exception
5545 handlers to catch the exceptions. This function is only available on IA-32
5548 If StartBit is greater than 31, then ASSERT().
5549 If EndBit is greater than 31, then ASSERT().
5550 If EndBit is less than StartBit, then ASSERT().
5551 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
5552 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
5554 @param Index The 32-bit MSR index to write.
5555 @param StartBit The ordinal of the least significant bit in the bit field.
5557 @param EndBit The ordinal of the most significant bit in the bit field.
5559 @param AndData The value to AND with the read value from the MSR.
5560 @param OrData The value to OR with the result of the AND operation.
5562 @return The lower 32-bit of the value written to the MSR.
5567 AsmMsrBitFieldAndThenOr32 (
5577 Returns a 64-bit Machine Specific Register(MSR).
5579 Reads and returns the 64-bit MSR specified by Index. No parameter checking is
5580 performed on Index, and some Index values may cause CPU exceptions. The
5581 caller must either guarantee that Index is valid, or the caller must set up
5582 exception handlers to catch the exceptions. This function is only available
5585 @param Index The 32-bit MSR index to read.
5587 @return The value of the MSR identified by Index.
5598 Writes a 64-bit value to a Machine Specific Register(MSR), and returns the
5601 Writes the 64-bit value specified by Value to the MSR specified by Index. The
5602 64-bit value written to the MSR is returned. No parameter checking is
5603 performed on Index or Value, and some of these may cause CPU exceptions. The
5604 caller must either guarantee that Index and Value are valid, or the caller
5605 must establish proper exception handlers. This function is only available on
5608 @param Index The 32-bit MSR index to write.
5609 @param Value The 64-bit value to write to the MSR.
5623 Reads a 64-bit MSR, performs a bitwise OR, and writes the result
5624 back to the 64-bit MSR.
5626 Reads the 64-bit MSR specified by Index, performs a bitwise OR
5627 between the read result and the value specified by OrData, and writes the
5628 result to the 64-bit MSR specified by Index. The value written to the MSR is
5629 returned. No parameter checking is performed on Index or OrData, and some of
5630 these may cause CPU exceptions. The caller must either guarantee that Index
5631 and OrData are valid, or the caller must establish proper exception handlers.
5632 This function is only available on IA-32 and x64.
5634 @param Index The 32-bit MSR index to write.
5635 @param OrData The value to OR with the read value from the MSR.
5637 @return The value written back to the MSR.
5649 Reads a 64-bit MSR, performs a bitwise AND, and writes the result back to the
5652 Reads the 64-bit MSR specified by Index, performs a bitwise AND between the
5653 read result and the value specified by OrData, and writes the result to the
5654 64-bit MSR specified by Index. The value written to the MSR is returned. No
5655 parameter checking is performed on Index or OrData, and some of these may
5656 cause CPU exceptions. The caller must either guarantee that Index and OrData
5657 are valid, or the caller must establish proper exception handlers. This
5658 function is only available on IA-32 and x64.
5660 @param Index The 32-bit MSR index to write.
5661 @param AndData The value to AND with the read value from the MSR.
5663 @return The value written back to the MSR.
5675 Reads a 64-bit MSR, performs a bitwise AND followed by a bitwise
5676 OR, and writes the result back to the 64-bit MSR.
5678 Reads the 64-bit MSR specified by Index, performs a bitwise AND between read
5679 result and the value specified by AndData, performs a bitwise OR
5680 between the result of the AND operation and the value specified by OrData,
5681 and writes the result to the 64-bit MSR specified by Index. The value written
5682 to the MSR is returned. No parameter checking is performed on Index, AndData,
5683 or OrData, and some of these may cause CPU exceptions. The caller must either
5684 guarantee that Index, AndData, and OrData are valid, or the caller must
5685 establish proper exception handlers. This function is only available on IA-32
5688 @param Index The 32-bit MSR index to write.
5689 @param AndData The value to AND with the read value from the MSR.
5690 @param OrData The value to OR with the result of the AND operation.
5692 @return The value written back to the MSR.
5705 Reads a bit field of an MSR.
5707 Reads the bit field in the 64-bit MSR. The bit field is specified by the
5708 StartBit and the EndBit. The value of the bit field is returned. The caller
5709 must either guarantee that Index is valid, or the caller must set up
5710 exception handlers to catch the exceptions. This function is only available
5713 If StartBit is greater than 63, then ASSERT().
5714 If EndBit is greater than 63, then ASSERT().
5715 If EndBit is less than StartBit, then ASSERT().
5717 @param Index The 32-bit MSR index to read.
5718 @param StartBit The ordinal of the least significant bit in the bit field.
5720 @param EndBit The ordinal of the most significant bit in the bit field.
5723 @return The value read from the MSR.
5728 AsmMsrBitFieldRead64 (
5736 Writes a bit field to an MSR.
5738 Writes Value to a bit field in a 64-bit MSR. The bit field is specified by
5739 the StartBit and the EndBit. All other bits in the destination MSR are
5740 preserved. The MSR written is returned. The caller must either guarantee
5741 that Index and the data written is valid, or the caller must set up exception
5742 handlers to catch the exceptions. This function is only available on IA-32 and x64.
5744 If StartBit is greater than 63, then ASSERT().
5745 If EndBit is greater than 63, then ASSERT().
5746 If EndBit is less than StartBit, then ASSERT().
5747 If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
5749 @param Index The 32-bit MSR index to write.
5750 @param StartBit The ordinal of the least significant bit in the bit field.
5752 @param EndBit The ordinal of the most significant bit in the bit field.
5754 @param Value New value of the bit field.
5756 @return The value written back to the MSR.
5761 AsmMsrBitFieldWrite64 (
5770 Reads a bit field in a 64-bit MSR, performs a bitwise OR, and
5771 writes the result back to the bit field in the 64-bit MSR.
5773 Reads the 64-bit MSR specified by Index, performs a bitwise OR
5774 between the read result and the value specified by OrData, and writes the
5775 result to the 64-bit MSR specified by Index. The value written to the MSR is
5776 returned. Extra left bits in OrData are stripped. The caller must either
5777 guarantee that Index and the data written is valid, or the caller must set up
5778 exception handlers to catch the exceptions. This function is only available
5781 If StartBit is greater than 63, then ASSERT().
5782 If EndBit is greater than 63, then ASSERT().
5783 If EndBit is less than StartBit, then ASSERT().
5784 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
5786 @param Index The 32-bit MSR index to write.
5787 @param StartBit The ordinal of the least significant bit in the bit field.
5789 @param EndBit The ordinal of the most significant bit in the bit field.
5791 @param OrData The value to OR with the read value from the bit field.
5793 @return The value written back to the MSR.
5798 AsmMsrBitFieldOr64 (
5807 Reads a bit field in a 64-bit MSR, performs a bitwise AND, and writes the
5808 result back to the bit field in the 64-bit MSR.
5810 Reads the 64-bit MSR specified by Index, performs a bitwise AND between the
5811 read result and the value specified by AndData, and writes the result to the
5812 64-bit MSR specified by Index. The value written to the MSR is returned.
5813 Extra left bits in AndData are stripped. The caller must either guarantee
5814 that Index and the data written is valid, or the caller must set up exception
5815 handlers to catch the exceptions. This function is only available on IA-32
5818 If StartBit is greater than 63, then ASSERT().
5819 If EndBit is greater than 63, then ASSERT().
5820 If EndBit is less than StartBit, then ASSERT().
5821 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
5823 @param Index The 32-bit MSR index to write.
5824 @param StartBit The ordinal of the least significant bit in the bit field.
5826 @param EndBit The ordinal of the most significant bit in the bit field.
5828 @param AndData The value to AND with the read value from the bit field.
5830 @return The value written back to the MSR.
5835 AsmMsrBitFieldAnd64 (
5844 Reads a bit field in a 64-bit MSR, performs a bitwise AND followed by a
5845 bitwise OR, and writes the result back to the bit field in the
5848 Reads the 64-bit MSR specified by Index, performs a bitwise AND followed by
5849 a bitwise OR between the read result and the value specified by
5850 AndData, and writes the result to the 64-bit MSR specified by Index. The
5851 value written to the MSR is returned. Extra left bits in both AndData and
5852 OrData are stripped. The caller must either guarantee that Index and the data
5853 written is valid, or the caller must set up exception handlers to catch the
5854 exceptions. This function is only available on IA-32 and x64.
5856 If StartBit is greater than 63, then ASSERT().
5857 If EndBit is greater than 63, then ASSERT().
5858 If EndBit is less than StartBit, then ASSERT().
5859 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
5860 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
5862 @param Index The 32-bit MSR index to write.
5863 @param StartBit The ordinal of the least significant bit in the bit field.
5865 @param EndBit The ordinal of the most significant bit in the bit field.
5867 @param AndData The value to AND with the read value from the bit field.
5868 @param OrData The value to OR with the result of the AND operation.
5870 @return The value written back to the MSR.
5875 AsmMsrBitFieldAndThenOr64 (
5885 Reads the current value of the EFLAGS register.
5887 Reads and returns the current value of the EFLAGS register. This function is
5888 only available on IA-32 and x64. This returns a 32-bit value on IA-32 and a
5889 64-bit value on x64.
5891 @return EFLAGS on IA-32 or RFLAGS on x64.
5902 Reads the current value of the Control Register 0 (CR0).
5904 Reads and returns the current value of CR0. This function is only available
5905 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
5908 @return The value of the Control Register 0 (CR0).
5919 Reads the current value of the Control Register 2 (CR2).
5921 Reads and returns the current value of CR2. This function is only available
5922 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
5925 @return The value of the Control Register 2 (CR2).
5936 Reads the current value of the Control Register 3 (CR3).
5938 Reads and returns the current value of CR3. This function is only available
5939 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
5942 @return The value of the Control Register 3 (CR3).
5953 Reads the current value of the Control Register 4 (CR4).
5955 Reads and returns the current value of CR4. This function is only available
5956 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
5959 @return The value of the Control Register 4 (CR4).
5970 Writes a value to Control Register 0 (CR0).
5972 Writes and returns a new value to CR0. This function is only available on
5973 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
5975 @param Cr0 The value to write to CR0.
5977 @return The value written to CR0.
5988 Writes a value to Control Register 2 (CR2).
5990 Writes and returns a new value to CR2. This function is only available on
5991 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
5993 @param Cr2 The value to write to CR2.
5995 @return The value written to CR2.
6006 Writes a value to Control Register 3 (CR3).
6008 Writes and returns a new value to CR3. This function is only available on
6009 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
6011 @param Cr3 The value to write to CR3.
6013 @return The value written to CR3.
6024 Writes a value to Control Register 4 (CR4).
6026 Writes and returns a new value to CR4. This function is only available on
6027 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
6029 @param Cr4 The value to write to CR4.
6031 @return The value written to CR4.
6042 Reads the current value of Debug Register 0 (DR0).
6044 Reads and returns the current value of DR0. This function is only available
6045 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
6048 @return The value of Debug Register 0 (DR0).
6059 Reads the current value of Debug Register 1 (DR1).
6061 Reads and returns the current value of DR1. This function is only available
6062 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
6065 @return The value of Debug Register 1 (DR1).
6076 Reads the current value of Debug Register 2 (DR2).
6078 Reads and returns the current value of DR2. This function is only available
6079 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
6082 @return The value of Debug Register 2 (DR2).
6093 Reads the current value of Debug Register 3 (DR3).
6095 Reads and returns the current value of DR3. This function is only available
6096 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
6099 @return The value of Debug Register 3 (DR3).
6110 Reads the current value of Debug Register 4 (DR4).
6112 Reads and returns the current value of DR4. This function is only available
6113 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
6116 @return The value of Debug Register 4 (DR4).
6127 Reads the current value of Debug Register 5 (DR5).
6129 Reads and returns the current value of DR5. This function is only available
6130 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
6133 @return The value of Debug Register 5 (DR5).
6144 Reads the current value of Debug Register 6 (DR6).
6146 Reads and returns the current value of DR6. This function is only available
6147 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
6150 @return The value of Debug Register 6 (DR6).
6161 Reads the current value of Debug Register 7 (DR7).
6163 Reads and returns the current value of DR7. This function is only available
6164 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
6167 @return The value of Debug Register 7 (DR7).
6178 Writes a value to Debug Register 0 (DR0).
6180 Writes and returns a new value to DR0. This function is only available on
6181 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
6183 @param Dr0 The value to write to Dr0.
6185 @return The value written to Debug Register 0 (DR0).
6196 Writes a value to Debug Register 1 (DR1).
6198 Writes and returns a new value to DR1. This function is only available on
6199 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
6201 @param Dr1 The value to write to Dr1.
6203 @return The value written to Debug Register 1 (DR1).
6214 Writes a value to Debug Register 2 (DR2).
6216 Writes and returns a new value to DR2. This function is only available on
6217 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
6219 @param Dr2 The value to write to Dr2.
6221 @return The value written to Debug Register 2 (DR2).
6232 Writes a value to Debug Register 3 (DR3).
6234 Writes and returns a new value to DR3. This function is only available on
6235 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
6237 @param Dr3 The value to write to Dr3.
6239 @return The value written to Debug Register 3 (DR3).
6250 Writes a value to Debug Register 4 (DR4).
6252 Writes and returns a new value to DR4. This function is only available on
6253 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
6255 @param Dr4 The value to write to Dr4.
6257 @return The value written to Debug Register 4 (DR4).
6268 Writes a value to Debug Register 5 (DR5).
6270 Writes and returns a new value to DR5. This function is only available on
6271 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
6273 @param Dr5 The value to write to Dr5.
6275 @return The value written to Debug Register 5 (DR5).
6286 Writes a value to Debug Register 6 (DR6).
6288 Writes and returns a new value to DR6. This function is only available on
6289 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
6291 @param Dr6 The value to write to Dr6.
6293 @return The value written to Debug Register 6 (DR6).
6304 Writes a value to Debug Register 7 (DR7).
6306 Writes and returns a new value to DR7. This function is only available on
6307 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
6309 @param Dr7 The value to write to Dr7.
6311 @return The value written to Debug Register 7 (DR7).
6322 Reads the current value of Code Segment Register (CS).
6324 Reads and returns the current value of CS. This function is only available on
6327 @return The current value of CS.
6338 Reads the current value of Data Segment Register (DS).
6340 Reads and returns the current value of DS. This function is only available on
6343 @return The current value of DS.
6354 Reads the current value of Extra Segment Register (ES).
6356 Reads and returns the current value of ES. This function is only available on
6359 @return The current value of ES.
6370 Reads the current value of FS Data Segment Register (FS).
6372 Reads and returns the current value of FS. This function is only available on
6375 @return The current value of FS.
6386 Reads the current value of GS Data Segment Register (GS).
6388 Reads and returns the current value of GS. This function is only available on
6391 @return The current value of GS.
6402 Reads the current value of Stack Segment Register (SS).
6404 Reads and returns the current value of SS. This function is only available on
6407 @return The current value of SS.
6418 Reads the current value of Task Register (TR).
6420 Reads and returns the current value of TR. This function is only available on
6423 @return The current value of TR.
6434 Reads the current Global Descriptor Table Register(GDTR) descriptor.
6436 Reads and returns the current GDTR descriptor and returns it in Gdtr. This
6437 function is only available on IA-32 and x64.
6439 If Gdtr is NULL, then ASSERT().
6441 @param Gdtr The pointer to a GDTR descriptor.
6447 OUT IA32_DESCRIPTOR *Gdtr
6452 Writes the current Global Descriptor Table Register (GDTR) descriptor.
6454 Writes and the current GDTR descriptor specified by Gdtr. This function is
6455 only available on IA-32 and x64.
6457 If Gdtr is NULL, then ASSERT().
6459 @param Gdtr The pointer to a GDTR descriptor.
6465 IN CONST IA32_DESCRIPTOR *Gdtr
6470 Reads the current Interrupt Descriptor Table Register(IDTR) descriptor.
6472 Reads and returns the current IDTR descriptor and returns it in Idtr. This
6473 function is only available on IA-32 and x64.
6475 If Idtr is NULL, then ASSERT().
6477 @param Idtr The pointer to a IDTR descriptor.
6483 OUT IA32_DESCRIPTOR *Idtr
6488 Writes the current Interrupt Descriptor Table Register(IDTR) descriptor.
6490 Writes the current IDTR descriptor and returns it in Idtr. This function is
6491 only available on IA-32 and x64.
6493 If Idtr is NULL, then ASSERT().
6495 @param Idtr The pointer to a IDTR descriptor.
6501 IN CONST IA32_DESCRIPTOR *Idtr
6506 Reads the current Local Descriptor Table Register(LDTR) selector.
6508 Reads and returns the current 16-bit LDTR descriptor value. This function is
6509 only available on IA-32 and x64.
6511 @return The current selector of LDT.
6522 Writes the current Local Descriptor Table Register (LDTR) selector.
6524 Writes and the current LDTR descriptor specified by Ldtr. This function is
6525 only available on IA-32 and x64.
6527 @param Ldtr 16-bit LDTR selector value.
6538 Save the current floating point/SSE/SSE2 context to a buffer.
6540 Saves the current floating point/SSE/SSE2 state to the buffer specified by
6541 Buffer. Buffer must be aligned on a 16-byte boundary. This function is only
6542 available on IA-32 and x64.
6544 If Buffer is NULL, then ASSERT().
6545 If Buffer is not aligned on a 16-byte boundary, then ASSERT().
6547 @param Buffer The pointer to a buffer to save the floating point/SSE/SSE2 context.
6553 OUT IA32_FX_BUFFER *Buffer
6558 Restores the current floating point/SSE/SSE2 context from a buffer.
6560 Restores the current floating point/SSE/SSE2 state from the buffer specified
6561 by Buffer. Buffer must be aligned on a 16-byte boundary. This function is
6562 only available on IA-32 and x64.
6564 If Buffer is NULL, then ASSERT().
6565 If Buffer is not aligned on a 16-byte boundary, then ASSERT().
6566 If Buffer was not saved with AsmFxSave(), then ASSERT().
6568 @param Buffer The pointer to a buffer to save the floating point/SSE/SSE2 context.
6574 IN CONST IA32_FX_BUFFER *Buffer
6579 Reads the current value of 64-bit MMX Register #0 (MM0).
6581 Reads and returns the current value of MM0. This function is only available
6584 @return The current value of MM0.
6595 Reads the current value of 64-bit MMX Register #1 (MM1).
6597 Reads and returns the current value of MM1. This function is only available
6600 @return The current value of MM1.
6611 Reads the current value of 64-bit MMX Register #2 (MM2).
6613 Reads and returns the current value of MM2. This function is only available
6616 @return The current value of MM2.
6627 Reads the current value of 64-bit MMX Register #3 (MM3).
6629 Reads and returns the current value of MM3. This function is only available
6632 @return The current value of MM3.
6643 Reads the current value of 64-bit MMX Register #4 (MM4).
6645 Reads and returns the current value of MM4. This function is only available
6648 @return The current value of MM4.
6659 Reads the current value of 64-bit MMX Register #5 (MM5).
6661 Reads and returns the current value of MM5. This function is only available
6664 @return The current value of MM5.
6675 Reads the current value of 64-bit MMX Register #6 (MM6).
6677 Reads and returns the current value of MM6. This function is only available
6680 @return The current value of MM6.
6691 Reads the current value of 64-bit MMX Register #7 (MM7).
6693 Reads and returns the current value of MM7. This function is only available
6696 @return The current value of MM7.
6707 Writes the current value of 64-bit MMX Register #0 (MM0).
6709 Writes the current value of MM0. This function is only available on IA32 and
6712 @param Value The 64-bit value to write to MM0.
6723 Writes the current value of 64-bit MMX Register #1 (MM1).
6725 Writes the current value of MM1. This function is only available on IA32 and
6728 @param Value The 64-bit value to write to MM1.
6739 Writes the current value of 64-bit MMX Register #2 (MM2).
6741 Writes the current value of MM2. This function is only available on IA32 and
6744 @param Value The 64-bit value to write to MM2.
6755 Writes the current value of 64-bit MMX Register #3 (MM3).
6757 Writes the current value of MM3. This function is only available on IA32 and
6760 @param Value The 64-bit value to write to MM3.
6771 Writes the current value of 64-bit MMX Register #4 (MM4).
6773 Writes the current value of MM4. This function is only available on IA32 and
6776 @param Value The 64-bit value to write to MM4.
6787 Writes the current value of 64-bit MMX Register #5 (MM5).
6789 Writes the current value of MM5. This function is only available on IA32 and
6792 @param Value The 64-bit value to write to MM5.
6803 Writes the current value of 64-bit MMX Register #6 (MM6).
6805 Writes the current value of MM6. This function is only available on IA32 and
6808 @param Value The 64-bit value to write to MM6.
6819 Writes the current value of 64-bit MMX Register #7 (MM7).
6821 Writes the current value of MM7. This function is only available on IA32 and
6824 @param Value The 64-bit value to write to MM7.
6835 Reads the current value of Time Stamp Counter (TSC).
6837 Reads and returns the current value of TSC. This function is only available
6840 @return The current value of TSC
6851 Reads the current value of a Performance Counter (PMC).
6853 Reads and returns the current value of performance counter specified by
6854 Index. This function is only available on IA-32 and x64.
6856 @param Index The 32-bit Performance Counter index to read.
6858 @return The value of the PMC specified by Index.
6869 Sets up a monitor buffer that is used by AsmMwait().
6871 Executes a MONITOR instruction with the register state specified by Eax, Ecx
6872 and Edx. Returns Eax. This function is only available on IA-32 and x64.
6874 @param Eax The value to load into EAX or RAX before executing the MONITOR
6876 @param Ecx The value to load into ECX or RCX before executing the MONITOR
6878 @param Edx The value to load into EDX or RDX before executing the MONITOR
6894 Executes an MWAIT instruction.
6896 Executes an MWAIT instruction with the register state specified by Eax and
6897 Ecx. Returns Eax. This function is only available on IA-32 and x64.
6899 @param Eax The value to load into EAX or RAX before executing the MONITOR
6901 @param Ecx The value to load into ECX or RCX before executing the MONITOR
6916 Executes a WBINVD instruction.
6918 Executes a WBINVD instruction. This function is only available on IA-32 and
6930 Executes a INVD instruction.
6932 Executes a INVD instruction. This function is only available on IA-32 and
6944 Flushes a cache line from all the instruction and data caches within the
6945 coherency domain of the CPU.
6947 Flushed the cache line specified by LinearAddress, and returns LinearAddress.
6948 This function is only available on IA-32 and x64.
6950 @param LinearAddress The address of the cache line to flush. If the CPU is
6951 in a physical addressing mode, then LinearAddress is a
6952 physical address. If the CPU is in a virtual
6953 addressing mode, then LinearAddress is a virtual
6956 @return LinearAddress.
6961 IN VOID *LinearAddress
6966 Enables the 32-bit paging mode on the CPU.
6968 Enables the 32-bit paging mode on the CPU. CR0, CR3, CR4, and the page tables
6969 must be properly initialized prior to calling this service. This function
6970 assumes the current execution mode is 32-bit protected mode. This function is
6971 only available on IA-32. After the 32-bit paging mode is enabled, control is
6972 transferred to the function specified by EntryPoint using the new stack
6973 specified by NewStack and passing in the parameters specified by Context1 and
6974 Context2. Context1 and Context2 are optional and may be NULL. The function
6975 EntryPoint must never return.
6977 If the current execution mode is not 32-bit protected mode, then ASSERT().
6978 If EntryPoint is NULL, then ASSERT().
6979 If NewStack is NULL, then ASSERT().
6981 There are a number of constraints that must be followed before calling this
6983 1) Interrupts must be disabled.
6984 2) The caller must be in 32-bit protected mode with flat descriptors. This
6985 means all descriptors must have a base of 0 and a limit of 4GB.
6986 3) CR0 and CR4 must be compatible with 32-bit protected mode with flat
6988 4) CR3 must point to valid page tables that will be used once the transition
6989 is complete, and those page tables must guarantee that the pages for this
6990 function and the stack are identity mapped.
6992 @param EntryPoint A pointer to function to call with the new stack after
6994 @param Context1 A pointer to the context to pass into the EntryPoint
6995 function as the first parameter after paging is enabled.
6996 @param Context2 A pointer to the context to pass into the EntryPoint
6997 function as the second parameter after paging is enabled.
6998 @param NewStack A pointer to the new stack to use for the EntryPoint
6999 function after paging is enabled.
7005 IN SWITCH_STACK_ENTRY_POINT EntryPoint,
7006 IN VOID *Context1, OPTIONAL
7007 IN VOID *Context2, OPTIONAL
7013 Disables the 32-bit paging mode on the CPU.
7015 Disables the 32-bit paging mode on the CPU and returns to 32-bit protected
7016 mode. This function assumes the current execution mode is 32-paged protected
7017 mode. This function is only available on IA-32. After the 32-bit paging mode
7018 is disabled, control is transferred to the function specified by EntryPoint
7019 using the new stack specified by NewStack and passing in the parameters
7020 specified by Context1 and Context2. Context1 and Context2 are optional and
7021 may be NULL. The function EntryPoint must never return.
7023 If the current execution mode is not 32-bit paged mode, then ASSERT().
7024 If EntryPoint is NULL, then ASSERT().
7025 If NewStack is NULL, then ASSERT().
7027 There are a number of constraints that must be followed before calling this
7029 1) Interrupts must be disabled.
7030 2) The caller must be in 32-bit paged mode.
7031 3) CR0, CR3, and CR4 must be compatible with 32-bit paged mode.
7032 4) CR3 must point to valid page tables that guarantee that the pages for
7033 this function and the stack are identity mapped.
7035 @param EntryPoint A pointer to function to call with the new stack after
7037 @param Context1 A pointer to the context to pass into the EntryPoint
7038 function as the first parameter after paging is disabled.
7039 @param Context2 A pointer to the context to pass into the EntryPoint
7040 function as the second parameter after paging is
7042 @param NewStack A pointer to the new stack to use for the EntryPoint
7043 function after paging is disabled.
7048 AsmDisablePaging32 (
7049 IN SWITCH_STACK_ENTRY_POINT EntryPoint,
7050 IN VOID *Context1, OPTIONAL
7051 IN VOID *Context2, OPTIONAL
7057 Enables the 64-bit paging mode on the CPU.
7059 Enables the 64-bit paging mode on the CPU. CR0, CR3, CR4, and the page tables
7060 must be properly initialized prior to calling this service. This function
7061 assumes the current execution mode is 32-bit protected mode with flat
7062 descriptors. This function is only available on IA-32. After the 64-bit
7063 paging mode is enabled, control is transferred to the function specified by
7064 EntryPoint using the new stack specified by NewStack and passing in the
7065 parameters specified by Context1 and Context2. Context1 and Context2 are
7066 optional and may be 0. The function EntryPoint must never return.
7068 If the current execution mode is not 32-bit protected mode with flat
7069 descriptors, then ASSERT().
7070 If EntryPoint is 0, then ASSERT().
7071 If NewStack is 0, then ASSERT().
7073 @param Cs The 16-bit selector to load in the CS before EntryPoint
7074 is called. The descriptor in the GDT that this selector
7075 references must be setup for long mode.
7076 @param EntryPoint The 64-bit virtual address of the function to call with
7077 the new stack after paging is enabled.
7078 @param Context1 The 64-bit virtual address of the context to pass into
7079 the EntryPoint function as the first parameter after
7081 @param Context2 The 64-bit virtual address of the context to pass into
7082 the EntryPoint function as the second parameter after
7084 @param NewStack The 64-bit virtual address of the new stack to use for
7085 the EntryPoint function after paging is enabled.
7092 IN UINT64 EntryPoint,
7093 IN UINT64 Context1, OPTIONAL
7094 IN UINT64 Context2, OPTIONAL
7100 Disables the 64-bit paging mode on the CPU.
7102 Disables the 64-bit paging mode on the CPU and returns to 32-bit protected
7103 mode. This function assumes the current execution mode is 64-paging mode.
7104 This function is only available on x64. After the 64-bit paging mode is
7105 disabled, control is transferred to the function specified by EntryPoint
7106 using the new stack specified by NewStack and passing in the parameters
7107 specified by Context1 and Context2. Context1 and Context2 are optional and
7108 may be 0. The function EntryPoint must never return.
7110 If the current execution mode is not 64-bit paged mode, then ASSERT().
7111 If EntryPoint is 0, then ASSERT().
7112 If NewStack is 0, then ASSERT().
7114 @param Cs The 16-bit selector to load in the CS before EntryPoint
7115 is called. The descriptor in the GDT that this selector
7116 references must be setup for 32-bit protected mode.
7117 @param EntryPoint The 64-bit virtual address of the function to call with
7118 the new stack after paging is disabled.
7119 @param Context1 The 64-bit virtual address of the context to pass into
7120 the EntryPoint function as the first parameter after
7122 @param Context2 The 64-bit virtual address of the context to pass into
7123 the EntryPoint function as the second parameter after
7125 @param NewStack The 64-bit virtual address of the new stack to use for
7126 the EntryPoint function after paging is disabled.
7131 AsmDisablePaging64 (
7133 IN UINT32 EntryPoint,
7134 IN UINT32 Context1, OPTIONAL
7135 IN UINT32 Context2, OPTIONAL
7141 // 16-bit thunking services
7145 Retrieves the properties for 16-bit thunk functions.
7147 Computes the size of the buffer and stack below 1MB required to use the
7148 AsmPrepareThunk16(), AsmThunk16() and AsmPrepareAndThunk16() functions. This
7149 buffer size is returned in RealModeBufferSize, and the stack size is returned
7150 in ExtraStackSize. If parameters are passed to the 16-bit real mode code,
7151 then the actual minimum stack size is ExtraStackSize plus the maximum number
7152 of bytes that need to be passed to the 16-bit real mode code.
7154 If RealModeBufferSize is NULL, then ASSERT().
7155 If ExtraStackSize is NULL, then ASSERT().
7157 @param RealModeBufferSize A pointer to the size of the buffer below 1MB
7158 required to use the 16-bit thunk functions.
7159 @param ExtraStackSize A pointer to the extra size of stack below 1MB
7160 that the 16-bit thunk functions require for
7161 temporary storage in the transition to and from
7167 AsmGetThunk16Properties (
7168 OUT UINT32 *RealModeBufferSize,
7169 OUT UINT32 *ExtraStackSize
7174 Prepares all structures a code required to use AsmThunk16().
7176 Prepares all structures and code required to use AsmThunk16().
7178 This interface is limited to be used in either physical mode or virtual modes with paging enabled where the
7179 virtual to physical mappings for ThunkContext.RealModeBuffer is mapped 1:1.
7181 If ThunkContext is NULL, then ASSERT().
7183 @param ThunkContext A pointer to the context structure that describes the
7184 16-bit real mode code to call.
7190 IN OUT THUNK_CONTEXT *ThunkContext
7195 Transfers control to a 16-bit real mode entry point and returns the results.
7197 Transfers control to a 16-bit real mode entry point and returns the results.
7198 AsmPrepareThunk16() must be called with ThunkContext before this function is used.
7199 This function must be called with interrupts disabled.
7201 The register state from the RealModeState field of ThunkContext is restored just prior
7202 to calling the 16-bit real mode entry point. This includes the EFLAGS field of RealModeState,
7203 which is used to set the interrupt state when a 16-bit real mode entry point is called.
7204 Control is transferred to the 16-bit real mode entry point specified by the CS and Eip fields of RealModeState.
7205 The stack is initialized to the SS and ESP fields of RealModeState. Any parameters passed to
7206 the 16-bit real mode code must be populated by the caller at SS:ESP prior to calling this function.
7207 The 16-bit real mode entry point is invoked with a 16-bit CALL FAR instruction,
7208 so when accessing stack contents, the 16-bit real mode code must account for the 16-bit segment
7209 and 16-bit offset of the return address that were pushed onto the stack. The 16-bit real mode entry
7210 point must exit with a RETF instruction. The register state is captured into RealModeState immediately
7211 after the RETF instruction is executed.
7213 If EFLAGS specifies interrupts enabled, or any of the 16-bit real mode code enables interrupts,
7214 or any of the 16-bit real mode code makes a SW interrupt, then the caller is responsible for making sure
7215 the IDT at address 0 is initialized to handle any HW or SW interrupts that may occur while in 16-bit real mode.
7217 If EFLAGS specifies interrupts enabled, or any of the 16-bit real mode code enables interrupts,
7218 then the caller is responsible for making sure the 8259 PIC is in a state compatible with 16-bit real mode.
7219 This includes the base vectors, the interrupt masks, and the edge/level trigger mode.
7221 If THUNK_ATTRIBUTE_BIG_REAL_MODE is set in the ThunkAttributes field of ThunkContext, then the user code
7222 is invoked in big real mode. Otherwise, the user code is invoked in 16-bit real mode with 64KB segment limits.
7224 If neither THUNK_ATTRIBUTE_DISABLE_A20_MASK_INT_15 nor THUNK_ATTRIBUTE_DISABLE_A20_MASK_KBD_CTRL are set in
7225 ThunkAttributes, then it is assumed that the user code did not enable the A20 mask, and no attempt is made to
7226 disable the A20 mask.
7228 If THUNK_ATTRIBUTE_DISABLE_A20_MASK_INT_15 is set and THUNK_ATTRIBUTE_DISABLE_A20_MASK_KBD_CTRL is clear in
7229 ThunkAttributes, then attempt to use the INT 15 service to disable the A20 mask. If this INT 15 call fails,
7230 then attempt to disable the A20 mask by directly accessing the 8042 keyboard controller I/O ports.
7232 If THUNK_ATTRIBUTE_DISABLE_A20_MASK_INT_15 is clear and THUNK_ATTRIBUTE_DISABLE_A20_MASK_KBD_CTRL is set in
7233 ThunkAttributes, then attempt to disable the A20 mask by directly accessing the 8042 keyboard controller I/O ports.
7235 If ThunkContext is NULL, then ASSERT().
7236 If AsmPrepareThunk16() was not previously called with ThunkContext, then ASSERT().
7237 If both THUNK_ATTRIBUTE_DISABLE_A20_MASK_INT_15 and THUNK_ATTRIBUTE_DISABLE_A20_MASK_KBD_CTRL are set in
7238 ThunkAttributes, then ASSERT().
7240 This interface is limited to be used in either physical mode or virtual modes with paging enabled where the
7241 virtual to physical mappings for ThunkContext.RealModeBuffer are mapped 1:1.
7243 @param ThunkContext A pointer to the context structure that describes the
7244 16-bit real mode code to call.
7250 IN OUT THUNK_CONTEXT *ThunkContext
7255 Prepares all structures and code for a 16-bit real mode thunk, transfers
7256 control to a 16-bit real mode entry point, and returns the results.
7258 Prepares all structures and code for a 16-bit real mode thunk, transfers
7259 control to a 16-bit real mode entry point, and returns the results. If the
7260 caller only need to perform a single 16-bit real mode thunk, then this
7261 service should be used. If the caller intends to make more than one 16-bit
7262 real mode thunk, then it is more efficient if AsmPrepareThunk16() is called
7263 once and AsmThunk16() can be called for each 16-bit real mode thunk.
7265 This interface is limited to be used in either physical mode or virtual modes with paging enabled where the
7266 virtual to physical mappings for ThunkContext.RealModeBuffer is mapped 1:1.
7268 See AsmPrepareThunk16() and AsmThunk16() for the detailed description and ASSERT() conditions.
7270 @param ThunkContext A pointer to the context structure that describes the
7271 16-bit real mode code to call.
7276 AsmPrepareAndThunk16 (
7277 IN OUT THUNK_CONTEXT *ThunkContext