2 Provides string functions, linked list functions, math functions, synchronization
3 functions, and CPU architecture-specific functions.
5 Copyright (c) 2006 - 2014, 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.
21 // Definitions for architecture-specific types
23 #if defined (MDE_CPU_IA32)
25 /// The IA-32 architecture context buffer used by SetJump() and LongJump().
34 } BASE_LIBRARY_JUMP_BUFFER
;
36 #define BASE_LIBRARY_JUMP_BUFFER_ALIGNMENT 4
38 #endif // defined (MDE_CPU_IA32)
40 #if defined (MDE_CPU_IPF)
43 /// The Itanium architecture context buffer used by SetJump() and LongJump().
78 UINT64 AfterSpillUNAT
;
84 } BASE_LIBRARY_JUMP_BUFFER
;
86 #define BASE_LIBRARY_JUMP_BUFFER_ALIGNMENT 0x10
88 #endif // defined (MDE_CPU_IPF)
90 #if defined (MDE_CPU_X64)
92 /// The x64 architecture context buffer used by SetJump() and LongJump().
106 UINT8 XmmBuffer
[160]; ///< XMM6-XMM15.
107 } BASE_LIBRARY_JUMP_BUFFER
;
109 #define BASE_LIBRARY_JUMP_BUFFER_ALIGNMENT 8
111 #endif // defined (MDE_CPU_X64)
113 #if defined (MDE_CPU_EBC)
115 /// The EBC context buffer used by SetJump() and LongJump().
123 } BASE_LIBRARY_JUMP_BUFFER
;
125 #define BASE_LIBRARY_JUMP_BUFFER_ALIGNMENT 8
127 #endif // defined (MDE_CPU_EBC)
129 #if defined (MDE_CPU_ARM)
132 UINT32 R3
; ///< A copy of R13.
143 } BASE_LIBRARY_JUMP_BUFFER
;
145 #define BASE_LIBRARY_JUMP_BUFFER_ALIGNMENT 4
147 #endif // defined (MDE_CPU_ARM)
149 #if defined (MDE_CPU_AARCH64)
175 } BASE_LIBRARY_JUMP_BUFFER
;
177 #define BASE_LIBRARY_JUMP_BUFFER_ALIGNMENT 8
179 #endif // defined (MDE_CPU_AARCH64)
188 Returns the length of a Null-terminated Unicode string.
190 If String is not aligned on a 16-bit boundary, then ASSERT().
192 @param String A pointer to a Null-terminated Unicode string.
193 @param MaxSize The maximum number of Destination Unicode
194 char, including terminating null char.
196 @retval 0 If String is NULL.
197 @retval MaxSize If there is no null character in the first MaxSize characters of String.
198 @return The number of characters that percede the terminating null character.
204 IN CONST CHAR16
*String
,
209 Copies the string pointed to by Source (including the terminating null char)
210 to the array pointed to by Destination.
212 If Destination is not aligned on a 16-bit boundary, then ASSERT().
213 If Source is not aligned on a 16-bit boundary, then ASSERT().
215 @param Destination A pointer to a Null-terminated Unicode string.
216 @param DestMax The maximum number of Destination Unicode
217 char, including terminating null char.
218 @param Source A pointer to a Null-terminated Unicode string.
220 @retval RETURN_SUCCESS String is copied.
221 @retval RETURN_BUFFER_TOO_SMALL If DestMax is NOT greater than StrLen(Source).
222 @retval RETURN_INVALID_PARAMETER If Destination is NULL.
224 If PcdMaximumUnicodeStringLength is not zero,
225 and DestMax is greater than
226 PcdMaximumUnicodeStringLength.
228 @retval RETURN_ACCESS_DENIED If Source and Destination overlap.
233 OUT CHAR16
*Destination
,
235 IN CONST CHAR16
*Source
239 Copies not more than Length successive char from the string pointed to by
240 Source to the array pointed to by Destination. If no null char is copied from
241 Source, then Destination[Length] is always set to null.
243 If Length > 0 and Destination is not aligned on a 16-bit boundary, then ASSERT().
244 If Length > 0 and Source is not aligned on a 16-bit boundary, then ASSERT().
246 @param Destination A pointer to a Null-terminated Unicode string.
247 @param DestMax The maximum number of Destination Unicode
248 char, including terminating null char.
249 @param Source A pointer to a Null-terminated Unicode string.
250 @param Length The maximum number of Unicode characters to copy.
252 @retval RETURN_SUCCESS String is copied.
253 @retval RETURN_BUFFER_TOO_SMALL If DestMax is NOT greater than
254 MIN(StrLen(Source), Length).
255 @retval RETURN_INVALID_PARAMETER If Destination is NULL.
257 If PcdMaximumUnicodeStringLength is not zero,
258 and DestMax is greater than
259 PcdMaximumUnicodeStringLength.
261 @retval RETURN_ACCESS_DENIED If Source and Destination overlap.
266 OUT CHAR16
*Destination
,
268 IN CONST CHAR16
*Source
,
273 Appends a copy of the string pointed to by Source (including the terminating
274 null char) to the end of the string pointed to by Destination.
276 If Destination is not aligned on a 16-bit boundary, then ASSERT().
277 If Source is not aligned on a 16-bit boundary, then ASSERT().
279 @param Destination A pointer to a Null-terminated Unicode string.
280 @param DestMax The maximum number of Destination Unicode
281 char, including terminating null char.
282 @param Source A pointer to a Null-terminated Unicode string.
284 @retval RETURN_SUCCESS String is appended.
285 @retval RETURN_BAD_BUFFER_SIZE If DestMax is NOT greater than
287 @retval RETURN_BUFFER_TOO_SMALL If (DestMax - StrLen(Destination)) is NOT
288 greater than StrLen(Source).
289 @retval RETURN_INVALID_PARAMETER If Destination is NULL.
291 If PcdMaximumUnicodeStringLength is not zero,
292 and DestMax is greater than
293 PcdMaximumUnicodeStringLength.
295 @retval RETURN_ACCESS_DENIED If Source and Destination overlap.
300 IN OUT CHAR16
*Destination
,
302 IN CONST CHAR16
*Source
306 Appends not more than Length successive char from the string pointed to by
307 Source to the end of the string pointed to by Destination. If no null char is
308 copied from Source, then Destination[StrLen(Destination) + Length] is always
311 If Destination is not aligned on a 16-bit boundary, then ASSERT().
312 If and Source is not aligned on a 16-bit boundary, then ASSERT().
314 @param Destination A pointer to a Null-terminated Unicode string.
315 @param DestMax The maximum number of Destination Unicode
316 char, including terminating null char.
317 @param Source A pointer to a Null-terminated Unicode string.
318 @param Length The maximum number of Unicode characters to copy.
320 @retval RETURN_SUCCESS String is appended.
321 @retval RETURN_BAD_BUFFER_SIZE If DestMax is NOT greater than
323 @retval RETURN_BUFFER_TOO_SMALL If (DestMax - StrLen(Destination)) is NOT
324 greater than MIN(StrLen(Source), Length).
325 @retval RETURN_INVALID_PARAMETER If Destination is NULL.
327 If PcdMaximumUnicodeStringLength is not zero,
328 and DestMax is greater than
329 PcdMaximumUnicodeStringLength.
331 @retval RETURN_ACCESS_DENIED If Source and Destination overlap.
336 IN OUT CHAR16
*Destination
,
338 IN CONST CHAR16
*Source
,
343 Returns the length of a Null-terminated Ascii string.
345 @param String A pointer to a Null-terminated Ascii string.
346 @param MaxSize The maximum number of Destination Ascii
347 char, including terminating null char.
349 @retval 0 If String is NULL.
350 @retval MaxSize If there is no null character in the first MaxSize characters of String.
351 @return The number of characters that percede the terminating null character.
357 IN CONST CHAR8
*String
,
362 Copies the string pointed to by Source (including the terminating null char)
363 to the array pointed to by Destination.
365 @param Destination A pointer to a Null-terminated Ascii string.
366 @param DestMax The maximum number of Destination Ascii
367 char, including terminating null char.
368 @param Source A pointer to a Null-terminated Ascii string.
370 @retval RETURN_SUCCESS String is copied.
371 @retval RETURN_BUFFER_TOO_SMALL If DestMax is NOT greater than StrLen(Source).
372 @retval RETURN_INVALID_PARAMETER If Destination is NULL.
374 If PcdMaximumAsciiStringLength is not zero,
375 and DestMax is greater than
376 PcdMaximumAsciiStringLength.
378 @retval RETURN_ACCESS_DENIED If Source and Destination overlap.
383 OUT CHAR8
*Destination
,
385 IN CONST CHAR8
*Source
389 Copies not more than Length successive char from the string pointed to by
390 Source to the array pointed to by Destination. If no null char is copied from
391 Source, then Destination[Length] is always set to null.
393 @param Destination A pointer to a Null-terminated Ascii string.
394 @param DestMax The maximum number of Destination Ascii
395 char, including terminating null char.
396 @param Source A pointer to a Null-terminated Ascii string.
397 @param Length The maximum number of Ascii characters to copy.
399 @retval RETURN_SUCCESS String is copied.
400 @retval RETURN_BUFFER_TOO_SMALL If DestMax is NOT greater than
401 MIN(StrLen(Source), Length).
402 @retval RETURN_INVALID_PARAMETER If Destination is NULL.
404 If PcdMaximumAsciiStringLength is not zero,
405 and DestMax is greater than
406 PcdMaximumAsciiStringLength.
408 @retval RETURN_ACCESS_DENIED If Source and Destination overlap.
413 OUT CHAR8
*Destination
,
415 IN CONST CHAR8
*Source
,
420 Appends a copy of the string pointed to by Source (including the terminating
421 null char) to the end of the string pointed to by Destination.
423 @param Destination A pointer to a Null-terminated Ascii string.
424 @param DestMax The maximum number of Destination Ascii
425 char, including terminating null char.
426 @param Source A pointer to a Null-terminated Ascii string.
428 @retval RETURN_SUCCESS String is appended.
429 @retval RETURN_BAD_BUFFER_SIZE If DestMax is NOT greater than
431 @retval RETURN_BUFFER_TOO_SMALL If (DestMax - StrLen(Destination)) is NOT
432 greater than StrLen(Source).
433 @retval RETURN_INVALID_PARAMETER If Destination is NULL.
435 If PcdMaximumAsciiStringLength is not zero,
436 and DestMax is greater than
437 PcdMaximumAsciiStringLength.
439 @retval RETURN_ACCESS_DENIED If Source and Destination overlap.
444 IN OUT CHAR8
*Destination
,
446 IN CONST CHAR8
*Source
450 Appends not more than Length successive char from the string pointed to by
451 Source to the end of the string pointed to by Destination. If no null char is
452 copied from Source, then Destination[StrLen(Destination) + Length] is always
455 @param Destination A pointer to a Null-terminated Ascii string.
456 @param DestMax The maximum number of Destination Ascii
457 char, including terminating null char.
458 @param Source A pointer to a Null-terminated Ascii string.
459 @param Length The maximum number of Ascii characters to copy.
461 @retval RETURN_SUCCESS String is appended.
462 @retval RETURN_BAD_BUFFER_SIZE If DestMax is NOT greater than
464 @retval RETURN_BUFFER_TOO_SMALL If (DestMax - StrLen(Destination)) is NOT
465 greater than MIN(StrLen(Source), Length).
466 @retval RETURN_INVALID_PARAMETER If Destination is NULL.
468 If PcdMaximumAsciiStringLength is not zero,
469 and DestMax is greater than
470 PcdMaximumAsciiStringLength.
472 @retval RETURN_ACCESS_DENIED If Source and Destination overlap.
477 IN OUT CHAR8
*Destination
,
479 IN CONST CHAR8
*Source
,
485 Copies one Null-terminated Unicode string to another Null-terminated Unicode
486 string and returns the new Unicode string.
488 This function copies the contents of the Unicode string Source to the Unicode
489 string Destination, and returns Destination. If Source and Destination
490 overlap, then the results are undefined.
492 If Destination is NULL, then ASSERT().
493 If Destination is not aligned on a 16-bit boundary, then ASSERT().
494 If Source is NULL, then ASSERT().
495 If Source is not aligned on a 16-bit boundary, then ASSERT().
496 If Source and Destination overlap, then ASSERT().
497 If PcdMaximumUnicodeStringLength is not zero, and Source contains more than
498 PcdMaximumUnicodeStringLength Unicode characters not including the
499 Null-terminator, then ASSERT().
501 @param Destination The pointer to a Null-terminated Unicode string.
502 @param Source The pointer to a Null-terminated Unicode string.
510 OUT CHAR16
*Destination
,
511 IN CONST CHAR16
*Source
516 Copies up to a specified length from one Null-terminated Unicode string to
517 another Null-terminated Unicode string and returns the new Unicode string.
519 This function copies the contents of the Unicode string Source to the Unicode
520 string Destination, and returns Destination. At most, Length Unicode
521 characters are copied from Source to Destination. If Length is 0, then
522 Destination is returned unmodified. If Length is greater that the number of
523 Unicode characters in Source, then Destination is padded with Null Unicode
524 characters. If Source and Destination overlap, then the results are
527 If Length > 0 and Destination is NULL, then ASSERT().
528 If Length > 0 and Destination is not aligned on a 16-bit boundary, then ASSERT().
529 If Length > 0 and Source is NULL, then ASSERT().
530 If Length > 0 and Source is not aligned on a 16-bit boundary, then ASSERT().
531 If Source and Destination overlap, then ASSERT().
532 If PcdMaximumUnicodeStringLength is not zero, and Length is greater than
533 PcdMaximumUnicodeStringLength, then ASSERT().
534 If PcdMaximumUnicodeStringLength is not zero, and Source contains more than
535 PcdMaximumUnicodeStringLength Unicode characters, not including the Null-terminator,
538 @param Destination The pointer to a Null-terminated Unicode string.
539 @param Source The pointer to a Null-terminated Unicode string.
540 @param Length The maximum number of Unicode characters to copy.
548 OUT CHAR16
*Destination
,
549 IN CONST CHAR16
*Source
,
555 Returns the length of a Null-terminated Unicode string.
557 This function returns the number of Unicode characters in the Null-terminated
558 Unicode string specified by String.
560 If String is NULL, then ASSERT().
561 If String is not aligned on a 16-bit boundary, then ASSERT().
562 If PcdMaximumUnicodeStringLength is not zero, and String contains more than
563 PcdMaximumUnicodeStringLength Unicode characters not including the
564 Null-terminator, then ASSERT().
566 @param String Pointer to a Null-terminated Unicode string.
568 @return The length of String.
574 IN CONST CHAR16
*String
579 Returns the size of a Null-terminated Unicode string in bytes, including the
582 This function returns the size, in bytes, of the Null-terminated Unicode string
585 If String is NULL, then ASSERT().
586 If String is not aligned on a 16-bit boundary, then ASSERT().
587 If PcdMaximumUnicodeStringLength is not zero, and String contains more than
588 PcdMaximumUnicodeStringLength Unicode characters not including the
589 Null-terminator, then ASSERT().
591 @param String The pointer to a Null-terminated Unicode string.
593 @return The size of String.
599 IN CONST CHAR16
*String
604 Compares two Null-terminated Unicode strings, and returns the difference
605 between the first mismatched Unicode characters.
607 This function compares the Null-terminated Unicode string FirstString to the
608 Null-terminated Unicode string SecondString. If FirstString is identical to
609 SecondString, then 0 is returned. Otherwise, the value returned is the first
610 mismatched Unicode character in SecondString subtracted from the first
611 mismatched Unicode character in FirstString.
613 If FirstString is NULL, then ASSERT().
614 If FirstString is not aligned on a 16-bit boundary, then ASSERT().
615 If SecondString is NULL, then ASSERT().
616 If SecondString is not aligned on a 16-bit boundary, then ASSERT().
617 If PcdMaximumUnicodeStringLength is not zero, and FirstString contains more
618 than PcdMaximumUnicodeStringLength Unicode characters not including the
619 Null-terminator, then ASSERT().
620 If PcdMaximumUnicodeStringLength is not zero, and SecondString contains more
621 than PcdMaximumUnicodeStringLength Unicode characters, not including the
622 Null-terminator, then ASSERT().
624 @param FirstString The pointer to a Null-terminated Unicode string.
625 @param SecondString The pointer to a Null-terminated Unicode string.
627 @retval 0 FirstString is identical to SecondString.
628 @return others FirstString is not identical to SecondString.
634 IN CONST CHAR16
*FirstString
,
635 IN CONST CHAR16
*SecondString
640 Compares up to a specified length the contents of two Null-terminated Unicode strings,
641 and returns the difference between the first mismatched Unicode characters.
643 This function compares the Null-terminated Unicode string FirstString to the
644 Null-terminated Unicode string SecondString. At most, Length Unicode
645 characters will be compared. If Length is 0, then 0 is returned. If
646 FirstString is identical to SecondString, then 0 is returned. Otherwise, the
647 value returned is the first mismatched Unicode character in SecondString
648 subtracted from the first mismatched Unicode character in FirstString.
650 If Length > 0 and FirstString is NULL, then ASSERT().
651 If Length > 0 and FirstString is not aligned on a 16-bit boundary, then ASSERT().
652 If Length > 0 and SecondString is NULL, then ASSERT().
653 If Length > 0 and SecondString is not aligned on a 16-bit boundary, then ASSERT().
654 If PcdMaximumUnicodeStringLength is not zero, and Length is greater than
655 PcdMaximumUnicodeStringLength, then ASSERT().
656 If PcdMaximumUnicodeStringLength is not zero, and FirstString contains more than
657 PcdMaximumUnicodeStringLength Unicode characters, not including the Null-terminator,
659 If PcdMaximumUnicodeStringLength is not zero, and SecondString contains more than
660 PcdMaximumUnicodeStringLength Unicode characters, not including the Null-terminator,
663 @param FirstString The pointer to a Null-terminated Unicode string.
664 @param SecondString The pointer to a Null-terminated Unicode string.
665 @param Length The maximum number of Unicode characters to compare.
667 @retval 0 FirstString is identical to SecondString.
668 @return others FirstString is not identical to SecondString.
674 IN CONST CHAR16
*FirstString
,
675 IN CONST CHAR16
*SecondString
,
681 Concatenates one Null-terminated Unicode string to another Null-terminated
682 Unicode string, and returns the concatenated Unicode string.
684 This function concatenates two Null-terminated Unicode strings. The contents
685 of Null-terminated Unicode string Source are concatenated to the end of
686 Null-terminated Unicode string Destination. The Null-terminated concatenated
687 Unicode String is returned. If Source and Destination overlap, then the
688 results are undefined.
690 If Destination is NULL, then ASSERT().
691 If Destination is not aligned on a 16-bit boundary, then ASSERT().
692 If Source is NULL, then ASSERT().
693 If Source is not aligned on a 16-bit boundary, then ASSERT().
694 If Source and Destination overlap, then ASSERT().
695 If PcdMaximumUnicodeStringLength is not zero, and Destination contains more
696 than PcdMaximumUnicodeStringLength Unicode characters, not including the
697 Null-terminator, then ASSERT().
698 If PcdMaximumUnicodeStringLength is not zero, and Source contains more than
699 PcdMaximumUnicodeStringLength Unicode characters, not including the
700 Null-terminator, then ASSERT().
701 If PcdMaximumUnicodeStringLength is not zero, and concatenating Destination
702 and Source results in a Unicode string with more than
703 PcdMaximumUnicodeStringLength Unicode characters, not including the
704 Null-terminator, then ASSERT().
706 @param Destination The pointer to a Null-terminated Unicode string.
707 @param Source The pointer to a Null-terminated Unicode string.
715 IN OUT CHAR16
*Destination
,
716 IN CONST CHAR16
*Source
721 Concatenates up to a specified length one Null-terminated Unicode to the end
722 of another Null-terminated Unicode string, and returns the concatenated
725 This function concatenates two Null-terminated Unicode strings. The contents
726 of Null-terminated Unicode string Source are concatenated to the end of
727 Null-terminated Unicode string Destination, and Destination is returned. At
728 most, Length Unicode characters are concatenated from Source to the end of
729 Destination, and Destination is always Null-terminated. If Length is 0, then
730 Destination is returned unmodified. If Source and Destination overlap, then
731 the results are undefined.
733 If Destination is NULL, then ASSERT().
734 If Length > 0 and Destination is not aligned on a 16-bit boundary, then ASSERT().
735 If Length > 0 and Source is NULL, then ASSERT().
736 If Length > 0 and Source is not aligned on a 16-bit boundary, then ASSERT().
737 If Source and Destination overlap, then ASSERT().
738 If PcdMaximumUnicodeStringLength is not zero, and Length is greater than
739 PcdMaximumUnicodeStringLength, then ASSERT().
740 If PcdMaximumUnicodeStringLength is not zero, and Destination contains more
741 than PcdMaximumUnicodeStringLength Unicode characters, not including the
742 Null-terminator, then ASSERT().
743 If PcdMaximumUnicodeStringLength is not zero, and Source contains more than
744 PcdMaximumUnicodeStringLength Unicode characters, not including the
745 Null-terminator, then ASSERT().
746 If PcdMaximumUnicodeStringLength is not zero, and concatenating Destination
747 and Source results in a Unicode string with more than PcdMaximumUnicodeStringLength
748 Unicode characters, not including the Null-terminator, then ASSERT().
750 @param Destination The pointer to a Null-terminated Unicode string.
751 @param Source The pointer to a Null-terminated Unicode string.
752 @param Length The maximum number of Unicode characters to concatenate from
761 IN OUT CHAR16
*Destination
,
762 IN CONST CHAR16
*Source
,
767 Returns the first occurrence of a Null-terminated Unicode sub-string
768 in a Null-terminated Unicode string.
770 This function scans the contents of the Null-terminated Unicode string
771 specified by String and returns the first occurrence of SearchString.
772 If SearchString is not found in String, then NULL is returned. If
773 the length of SearchString is zero, then String is returned.
775 If String is NULL, then ASSERT().
776 If String is not aligned on a 16-bit boundary, then ASSERT().
777 If SearchString is NULL, then ASSERT().
778 If SearchString is not aligned on a 16-bit boundary, then ASSERT().
780 If PcdMaximumUnicodeStringLength is not zero, and SearchString
781 or String contains more than PcdMaximumUnicodeStringLength Unicode
782 characters, not including the Null-terminator, then ASSERT().
784 @param String The pointer to a Null-terminated Unicode string.
785 @param SearchString The pointer to a Null-terminated Unicode string to search for.
787 @retval NULL If the SearchString does not appear in String.
788 @return others If there is a match.
794 IN CONST CHAR16
*String
,
795 IN CONST CHAR16
*SearchString
799 Convert a Null-terminated Unicode decimal string to a value of
802 This function returns a value of type UINTN by interpreting the contents
803 of the Unicode string specified by String as a decimal number. The format
804 of the input Unicode string String is:
806 [spaces] [decimal digits].
808 The valid decimal digit character is in the range [0-9]. The
809 function will ignore the pad space, which includes spaces or
810 tab characters, before [decimal digits]. The running zero in the
811 beginning of [decimal digits] will be ignored. Then, the function
812 stops at the first character that is a not a valid decimal character
813 or a Null-terminator, whichever one comes first.
815 If String is NULL, then ASSERT().
816 If String is not aligned in a 16-bit boundary, then ASSERT().
817 If String has only pad spaces, then 0 is returned.
818 If String has no pad spaces or valid decimal digits,
820 If the number represented by String overflows according
821 to the range defined by UINTN, then ASSERT().
823 If PcdMaximumUnicodeStringLength is not zero, and String contains
824 more than PcdMaximumUnicodeStringLength Unicode characters not including
825 the Null-terminator, then ASSERT().
827 @param String The pointer to a Null-terminated Unicode string.
829 @retval Value translated from String.
835 IN CONST CHAR16
*String
839 Convert a Null-terminated Unicode decimal string to a value of
842 This function returns a value of type UINT64 by interpreting the contents
843 of the Unicode string specified by String as a decimal number. The format
844 of the input Unicode string String is:
846 [spaces] [decimal digits].
848 The valid decimal digit character is in the range [0-9]. The
849 function will ignore the pad space, which includes spaces or
850 tab characters, before [decimal digits]. The running zero in the
851 beginning of [decimal digits] will be ignored. Then, the function
852 stops at the first character that is a not a valid decimal character
853 or a Null-terminator, whichever one comes first.
855 If String is NULL, then ASSERT().
856 If String is not aligned in a 16-bit boundary, then ASSERT().
857 If String has only pad spaces, then 0 is returned.
858 If String has no pad spaces or valid decimal digits,
860 If the number represented by String overflows according
861 to the range defined by UINT64, then ASSERT().
863 If PcdMaximumUnicodeStringLength is not zero, and String contains
864 more than PcdMaximumUnicodeStringLength Unicode characters not including
865 the Null-terminator, then ASSERT().
867 @param String The pointer to a Null-terminated Unicode string.
869 @retval Value translated from String.
875 IN CONST CHAR16
*String
880 Convert a Null-terminated Unicode hexadecimal string to a value of type UINTN.
882 This function returns a value of type UINTN by interpreting the contents
883 of the Unicode string specified by String as a hexadecimal number.
884 The format of the input Unicode string String is:
886 [spaces][zeros][x][hexadecimal digits].
888 The valid hexadecimal digit character is in the range [0-9], [a-f] and [A-F].
889 The prefix "0x" is optional. Both "x" and "X" is allowed in "0x" prefix.
890 If "x" appears in the input string, it must be prefixed with at least one 0.
891 The function will ignore the pad space, which includes spaces or tab characters,
892 before [zeros], [x] or [hexadecimal digit]. The running zero before [x] or
893 [hexadecimal digit] will be ignored. Then, the decoding starts after [x] or the
894 first valid hexadecimal digit. Then, the function stops at the first character
895 that is a not a valid hexadecimal character or NULL, whichever one comes first.
897 If String is NULL, then ASSERT().
898 If String is not aligned in a 16-bit boundary, then ASSERT().
899 If String has only pad spaces, then zero is returned.
900 If String has no leading pad spaces, leading zeros or valid hexadecimal digits,
901 then zero is returned.
902 If the number represented by String overflows according to the range defined by
903 UINTN, then ASSERT().
905 If PcdMaximumUnicodeStringLength is not zero, and String contains more than
906 PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator,
909 @param String The pointer to a Null-terminated Unicode string.
911 @retval Value translated from String.
917 IN CONST CHAR16
*String
922 Convert a Null-terminated Unicode hexadecimal string to a value of type UINT64.
924 This function returns a value of type UINT64 by interpreting the contents
925 of the Unicode string specified by String as a hexadecimal number.
926 The format of the input Unicode string String is
928 [spaces][zeros][x][hexadecimal digits].
930 The valid hexadecimal digit character is in the range [0-9], [a-f] and [A-F].
931 The prefix "0x" is optional. Both "x" and "X" is allowed in "0x" prefix.
932 If "x" appears in the input string, it must be prefixed with at least one 0.
933 The function will ignore the pad space, which includes spaces or tab characters,
934 before [zeros], [x] or [hexadecimal digit]. The running zero before [x] or
935 [hexadecimal digit] will be ignored. Then, the decoding starts after [x] or the
936 first valid hexadecimal digit. Then, the function stops at the first character that is
937 a not a valid hexadecimal character or NULL, whichever one comes first.
939 If String is NULL, then ASSERT().
940 If String is not aligned in a 16-bit boundary, then ASSERT().
941 If String has only pad spaces, then zero is returned.
942 If String has no leading pad spaces, leading zeros or valid hexadecimal digits,
943 then zero is returned.
944 If the number represented by String overflows according to the range defined by
945 UINT64, then ASSERT().
947 If PcdMaximumUnicodeStringLength is not zero, and String contains more than
948 PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator,
951 @param String The pointer to a Null-terminated Unicode string.
953 @retval Value translated from String.
959 IN CONST CHAR16
*String
963 Convert a Null-terminated Unicode string to a Null-terminated
964 ASCII string and returns the ASCII string.
966 This function converts the content of the Unicode string Source
967 to the ASCII string Destination by copying the lower 8 bits of
968 each Unicode character. It returns Destination.
970 The caller is responsible to make sure Destination points to a buffer with size
971 equal or greater than ((StrLen (Source) + 1) * sizeof (CHAR8)) in bytes.
973 If any Unicode characters in Source contain non-zero value in
974 the upper 8 bits, then ASSERT().
976 If Destination is NULL, then ASSERT().
977 If Source is NULL, then ASSERT().
978 If Source is not aligned on a 16-bit boundary, then ASSERT().
979 If Source and Destination overlap, then ASSERT().
981 If PcdMaximumUnicodeStringLength is not zero, and Source contains
982 more than PcdMaximumUnicodeStringLength Unicode characters not including
983 the Null-terminator, then ASSERT().
985 If PcdMaximumAsciiStringLength is not zero, and Source contains more
986 than PcdMaximumAsciiStringLength Unicode characters not including the
987 Null-terminator, then ASSERT().
989 @param Source The pointer to a Null-terminated Unicode string.
990 @param Destination The pointer to a Null-terminated ASCII string.
997 UnicodeStrToAsciiStr (
998 IN CONST CHAR16
*Source
,
999 OUT CHAR8
*Destination
1004 Copies one Null-terminated ASCII string to another Null-terminated ASCII
1005 string and returns the new ASCII string.
1007 This function copies the contents of the ASCII string Source to the ASCII
1008 string Destination, and returns Destination. If Source and Destination
1009 overlap, then the results are undefined.
1011 If Destination is NULL, then ASSERT().
1012 If Source is NULL, then ASSERT().
1013 If Source and Destination overlap, then ASSERT().
1014 If PcdMaximumAsciiStringLength is not zero and Source contains more than
1015 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
1018 @param Destination The pointer to a Null-terminated ASCII string.
1019 @param Source The pointer to a Null-terminated ASCII string.
1027 OUT CHAR8
*Destination
,
1028 IN CONST CHAR8
*Source
1033 Copies up to a specified length one Null-terminated ASCII string to another
1034 Null-terminated ASCII string and returns the new ASCII string.
1036 This function copies the contents of the ASCII string Source to the ASCII
1037 string Destination, and returns Destination. At most, Length ASCII characters
1038 are copied from Source to Destination. If Length is 0, then Destination is
1039 returned unmodified. If Length is greater that the number of ASCII characters
1040 in Source, then Destination is padded with Null ASCII characters. If Source
1041 and Destination overlap, then the results are undefined.
1043 If Destination is NULL, then ASSERT().
1044 If Source is NULL, then ASSERT().
1045 If Source and Destination overlap, then ASSERT().
1046 If PcdMaximumAsciiStringLength is not zero, and Length is greater than
1047 PcdMaximumAsciiStringLength, then ASSERT().
1048 If PcdMaximumAsciiStringLength is not zero, and Source contains more than
1049 PcdMaximumAsciiStringLength ASCII characters, not including the Null-terminator,
1052 @param Destination The pointer to a Null-terminated ASCII string.
1053 @param Source The pointer to a Null-terminated ASCII string.
1054 @param Length The maximum number of ASCII characters to copy.
1062 OUT CHAR8
*Destination
,
1063 IN CONST CHAR8
*Source
,
1069 Returns the length of a Null-terminated ASCII string.
1071 This function returns the number of ASCII characters in the Null-terminated
1072 ASCII string specified by String.
1074 If Length > 0 and Destination is NULL, then ASSERT().
1075 If Length > 0 and Source is NULL, then ASSERT().
1076 If PcdMaximumAsciiStringLength is not zero and String contains more than
1077 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
1080 @param String The pointer to a Null-terminated ASCII string.
1082 @return The length of String.
1088 IN CONST CHAR8
*String
1093 Returns the size of a Null-terminated ASCII string in bytes, including the
1096 This function returns the size, in bytes, of the Null-terminated ASCII string
1097 specified by String.
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 @return The size of String.
1112 IN CONST CHAR8
*String
1117 Compares two Null-terminated ASCII strings, and returns the difference
1118 between the first mismatched ASCII characters.
1120 This function compares the Null-terminated ASCII string FirstString to the
1121 Null-terminated ASCII string SecondString. If FirstString is identical to
1122 SecondString, then 0 is returned. Otherwise, the value returned is the first
1123 mismatched ASCII character in SecondString subtracted from the first
1124 mismatched ASCII character in FirstString.
1126 If FirstString is NULL, then ASSERT().
1127 If SecondString is NULL, then ASSERT().
1128 If PcdMaximumAsciiStringLength is not zero and FirstString contains more than
1129 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
1131 If PcdMaximumAsciiStringLength is not zero and SecondString contains more
1132 than PcdMaximumAsciiStringLength ASCII characters not including the
1133 Null-terminator, then ASSERT().
1135 @param FirstString The pointer to a Null-terminated ASCII string.
1136 @param SecondString The pointer to a Null-terminated ASCII string.
1138 @retval ==0 FirstString is identical to SecondString.
1139 @retval !=0 FirstString is not identical to SecondString.
1145 IN CONST CHAR8
*FirstString
,
1146 IN CONST CHAR8
*SecondString
1151 Performs a case insensitive comparison of two Null-terminated ASCII strings,
1152 and returns the difference between the first mismatched ASCII characters.
1154 This function performs a case insensitive comparison of the Null-terminated
1155 ASCII string FirstString to the Null-terminated ASCII string SecondString. If
1156 FirstString is identical to SecondString, then 0 is returned. Otherwise, the
1157 value returned is the first mismatched lower case ASCII character in
1158 SecondString subtracted from the first mismatched lower case ASCII character
1161 If FirstString is NULL, then ASSERT().
1162 If SecondString is NULL, then ASSERT().
1163 If PcdMaximumAsciiStringLength is not zero and FirstString contains more than
1164 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
1166 If PcdMaximumAsciiStringLength is not zero and SecondString contains more
1167 than PcdMaximumAsciiStringLength ASCII characters not including the
1168 Null-terminator, then ASSERT().
1170 @param FirstString The pointer to a Null-terminated ASCII string.
1171 @param SecondString The pointer to a Null-terminated ASCII string.
1173 @retval ==0 FirstString is identical to SecondString using case insensitive
1175 @retval !=0 FirstString is not identical to SecondString using case
1176 insensitive comparisons.
1182 IN CONST CHAR8
*FirstString
,
1183 IN CONST CHAR8
*SecondString
1188 Compares two Null-terminated ASCII strings with maximum lengths, and returns
1189 the difference between the first mismatched ASCII characters.
1191 This function compares the Null-terminated ASCII string FirstString to the
1192 Null-terminated ASCII string SecondString. At most, Length ASCII characters
1193 will be compared. If Length is 0, then 0 is returned. If FirstString is
1194 identical to SecondString, then 0 is returned. Otherwise, the value returned
1195 is the first mismatched ASCII character in SecondString subtracted from the
1196 first mismatched ASCII character in FirstString.
1198 If Length > 0 and FirstString is NULL, then ASSERT().
1199 If Length > 0 and SecondString is NULL, then ASSERT().
1200 If PcdMaximumAsciiStringLength is not zero, and Length is greater than
1201 PcdMaximumAsciiStringLength, then ASSERT().
1202 If PcdMaximumAsciiStringLength is not zero, and FirstString contains more than
1203 PcdMaximumAsciiStringLength ASCII characters, not including the Null-terminator,
1205 If PcdMaximumAsciiStringLength is not zero, and SecondString contains more than
1206 PcdMaximumAsciiStringLength ASCII characters, not including the Null-terminator,
1209 @param FirstString The pointer to a Null-terminated ASCII string.
1210 @param SecondString The pointer to a Null-terminated ASCII string.
1211 @param Length The maximum number of ASCII characters for compare.
1213 @retval ==0 FirstString is identical to SecondString.
1214 @retval !=0 FirstString is not identical to SecondString.
1220 IN CONST CHAR8
*FirstString
,
1221 IN CONST CHAR8
*SecondString
,
1227 Concatenates one Null-terminated ASCII string to another Null-terminated
1228 ASCII string, and returns the concatenated ASCII string.
1230 This function concatenates two Null-terminated ASCII strings. The contents of
1231 Null-terminated ASCII string Source are concatenated to the end of Null-
1232 terminated ASCII string Destination. The Null-terminated concatenated ASCII
1235 If Destination is NULL, then ASSERT().
1236 If Source is NULL, then ASSERT().
1237 If PcdMaximumAsciiStringLength is not zero and Destination contains more than
1238 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
1240 If PcdMaximumAsciiStringLength is not zero and Source contains more than
1241 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
1243 If PcdMaximumAsciiStringLength is not zero and concatenating Destination and
1244 Source results in a ASCII string with more than PcdMaximumAsciiStringLength
1245 ASCII characters, then ASSERT().
1247 @param Destination The pointer to a Null-terminated ASCII string.
1248 @param Source The pointer to a Null-terminated ASCII string.
1256 IN OUT CHAR8
*Destination
,
1257 IN CONST CHAR8
*Source
1262 Concatenates up to a specified length one Null-terminated ASCII string to
1263 the end of another Null-terminated ASCII string, and returns the
1264 concatenated ASCII string.
1266 This function concatenates two Null-terminated ASCII strings. The contents
1267 of Null-terminated ASCII string Source are concatenated to the end of Null-
1268 terminated ASCII string Destination, and Destination is returned. At most,
1269 Length ASCII characters are concatenated from Source to the end of
1270 Destination, and Destination is always Null-terminated. If Length is 0, then
1271 Destination is returned unmodified. If Source and Destination overlap, then
1272 the results are undefined.
1274 If Length > 0 and Destination is NULL, then ASSERT().
1275 If Length > 0 and Source is NULL, then ASSERT().
1276 If Source and Destination overlap, then ASSERT().
1277 If PcdMaximumAsciiStringLength is not zero, and Length is greater than
1278 PcdMaximumAsciiStringLength, then ASSERT().
1279 If PcdMaximumAsciiStringLength is not zero, and Destination contains more than
1280 PcdMaximumAsciiStringLength ASCII characters, not including the Null-terminator,
1282 If PcdMaximumAsciiStringLength is not zero, and Source contains more than
1283 PcdMaximumAsciiStringLength ASCII characters, not including the Null-terminator,
1285 If PcdMaximumAsciiStringLength is not zero, and concatenating Destination and
1286 Source results in a ASCII string with more than PcdMaximumAsciiStringLength
1287 ASCII characters, not including the Null-terminator, then ASSERT().
1289 @param Destination The pointer to a Null-terminated ASCII string.
1290 @param Source The pointer to a Null-terminated ASCII string.
1291 @param Length The maximum number of ASCII characters to concatenate from
1300 IN OUT CHAR8
*Destination
,
1301 IN CONST CHAR8
*Source
,
1307 Returns the first occurrence of a Null-terminated ASCII sub-string
1308 in a Null-terminated ASCII string.
1310 This function scans the contents of the ASCII string specified by String
1311 and returns the first occurrence of SearchString. If SearchString is not
1312 found in String, then NULL is returned. If the length of SearchString is zero,
1313 then String is returned.
1315 If String is NULL, then ASSERT().
1316 If SearchString is NULL, then ASSERT().
1318 If PcdMaximumAsciiStringLength is not zero, and SearchString or
1319 String contains more than PcdMaximumAsciiStringLength Unicode characters
1320 not including the Null-terminator, then ASSERT().
1322 @param String The pointer to a Null-terminated ASCII string.
1323 @param SearchString The pointer to a Null-terminated ASCII string to search for.
1325 @retval NULL If the SearchString does not appear in String.
1326 @retval others If there is a match return the first occurrence of SearchingString.
1327 If the length of SearchString is zero,return String.
1333 IN CONST CHAR8
*String
,
1334 IN CONST CHAR8
*SearchString
1339 Convert a Null-terminated ASCII decimal string to a value of type
1342 This function returns a value of type UINTN by interpreting the contents
1343 of the ASCII string String as a decimal number. The format of the input
1344 ASCII string String is:
1346 [spaces] [decimal digits].
1348 The valid decimal digit character is in the range [0-9]. The function will
1349 ignore the pad space, which includes spaces or tab characters, before the digits.
1350 The running zero in the beginning of [decimal digits] will be ignored. Then, the
1351 function stops at the first character that is a not a valid decimal character or
1352 Null-terminator, whichever on comes first.
1354 If String has only pad spaces, then 0 is returned.
1355 If String has no pad spaces or valid decimal digits, then 0 is returned.
1356 If the number represented by String overflows according to the range defined by
1357 UINTN, then ASSERT().
1358 If String is NULL, then ASSERT().
1359 If PcdMaximumAsciiStringLength is not zero, and String contains more than
1360 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
1363 @param String The pointer to a Null-terminated ASCII string.
1365 @retval The value translated from String.
1370 AsciiStrDecimalToUintn (
1371 IN CONST CHAR8
*String
1376 Convert a Null-terminated ASCII decimal string to a value of type
1379 This function returns a value of type UINT64 by interpreting the contents
1380 of the ASCII string String as a decimal number. The format of the input
1381 ASCII string String is:
1383 [spaces] [decimal digits].
1385 The valid decimal digit character is in the range [0-9]. The function will
1386 ignore the pad space, which includes spaces or tab characters, before the digits.
1387 The running zero in the beginning of [decimal digits] will be ignored. Then, the
1388 function stops at the first character that is a not a valid decimal character or
1389 Null-terminator, whichever on comes first.
1391 If String has only pad spaces, then 0 is returned.
1392 If String has no pad spaces or valid decimal digits, then 0 is returned.
1393 If the number represented by String overflows according to the range defined by
1394 UINT64, then ASSERT().
1395 If String is NULL, then ASSERT().
1396 If PcdMaximumAsciiStringLength is not zero, and String contains more than
1397 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
1400 @param String The pointer to a Null-terminated ASCII string.
1402 @retval Value translated from String.
1407 AsciiStrDecimalToUint64 (
1408 IN CONST CHAR8
*String
1413 Convert a Null-terminated ASCII hexadecimal string to a value of type UINTN.
1415 This function returns a value of type UINTN by interpreting the contents of
1416 the ASCII string String as a hexadecimal number. The format of the input ASCII
1419 [spaces][zeros][x][hexadecimal digits].
1421 The valid hexadecimal digit character is in the range [0-9], [a-f] and [A-F].
1422 The prefix "0x" is optional. Both "x" and "X" is allowed in "0x" prefix. If "x"
1423 appears in the input string, it must be prefixed with at least one 0. The function
1424 will ignore the pad space, which includes spaces or tab characters, before [zeros],
1425 [x] or [hexadecimal digits]. The running zero before [x] or [hexadecimal digits]
1426 will be ignored. Then, the decoding starts after [x] or the first valid hexadecimal
1427 digit. Then, the function stops at the first character that is a not a valid
1428 hexadecimal character or Null-terminator, whichever on comes first.
1430 If String has only pad spaces, then 0 is returned.
1431 If String has no leading pad spaces, leading zeros or valid hexadecimal digits, then
1434 If the number represented by String overflows according to the range defined by UINTN,
1436 If String is NULL, then ASSERT().
1437 If PcdMaximumAsciiStringLength is not zero,
1438 and String contains more than PcdMaximumAsciiStringLength ASCII characters not including
1439 the Null-terminator, then ASSERT().
1441 @param String The pointer to a Null-terminated ASCII string.
1443 @retval Value translated from String.
1448 AsciiStrHexToUintn (
1449 IN CONST CHAR8
*String
1454 Convert a Null-terminated ASCII hexadecimal string to a value of type UINT64.
1456 This function returns a value of type UINT64 by interpreting the contents of
1457 the ASCII string String as a hexadecimal number. The format of the input ASCII
1460 [spaces][zeros][x][hexadecimal digits].
1462 The valid hexadecimal digit character is in the range [0-9], [a-f] and [A-F].
1463 The prefix "0x" is optional. Both "x" and "X" is allowed in "0x" prefix. If "x"
1464 appears in the input string, it must be prefixed with at least one 0. The function
1465 will ignore the pad space, which includes spaces or tab characters, before [zeros],
1466 [x] or [hexadecimal digits]. The running zero before [x] or [hexadecimal digits]
1467 will be ignored. Then, the decoding starts after [x] or the first valid hexadecimal
1468 digit. Then, the function stops at the first character that is a not a valid
1469 hexadecimal character or Null-terminator, whichever on comes first.
1471 If String has only pad spaces, then 0 is returned.
1472 If String has no leading pad spaces, leading zeros or valid hexadecimal digits, then
1475 If the number represented by String overflows according to the range defined by UINT64,
1477 If String is NULL, then ASSERT().
1478 If PcdMaximumAsciiStringLength is not zero,
1479 and String contains more than PcdMaximumAsciiStringLength ASCII characters not including
1480 the Null-terminator, then ASSERT().
1482 @param String The pointer to a Null-terminated ASCII string.
1484 @retval Value translated from String.
1489 AsciiStrHexToUint64 (
1490 IN CONST CHAR8
*String
1495 Convert one Null-terminated ASCII string to a Null-terminated
1496 Unicode string and returns the Unicode string.
1498 This function converts the contents of the ASCII string Source to the Unicode
1499 string Destination, and returns Destination. The function terminates the
1500 Unicode string Destination by appending a Null-terminator character at the end.
1501 The caller is responsible to make sure Destination points to a buffer with size
1502 equal or greater than ((AsciiStrLen (Source) + 1) * sizeof (CHAR16)) in bytes.
1504 If Destination is NULL, then ASSERT().
1505 If Destination is not aligned on a 16-bit boundary, then ASSERT().
1506 If Source is NULL, then ASSERT().
1507 If Source and Destination overlap, then ASSERT().
1508 If PcdMaximumAsciiStringLength is not zero, and Source contains more than
1509 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
1511 If PcdMaximumUnicodeStringLength is not zero, and Source contains more than
1512 PcdMaximumUnicodeStringLength ASCII characters not including the
1513 Null-terminator, then ASSERT().
1515 @param Source The pointer to a Null-terminated ASCII string.
1516 @param Destination The pointer to a Null-terminated Unicode string.
1518 @return Destination.
1523 AsciiStrToUnicodeStr (
1524 IN CONST CHAR8
*Source
,
1525 OUT CHAR16
*Destination
1530 Converts an 8-bit value to an 8-bit BCD value.
1532 Converts the 8-bit value specified by Value to BCD. The BCD value is
1535 If Value >= 100, then ASSERT().
1537 @param Value The 8-bit value to convert to BCD. Range 0..99.
1539 @return The BCD value.
1550 Converts an 8-bit BCD value to an 8-bit value.
1552 Converts the 8-bit BCD value specified by Value to an 8-bit value. The 8-bit
1555 If Value >= 0xA0, then ASSERT().
1556 If (Value & 0x0F) >= 0x0A, then ASSERT().
1558 @param Value The 8-bit BCD value to convert to an 8-bit value.
1560 @return The 8-bit value is returned.
1571 // Linked List Functions and Macros
1575 Initializes the head node of a doubly linked list that is declared as a
1576 global variable in a module.
1578 Initializes the forward and backward links of a new linked list. After
1579 initializing a linked list with this macro, the other linked list functions
1580 may be used to add and remove nodes from the linked list. This macro results
1581 in smaller executables by initializing the linked list in the data section,
1582 instead if calling the InitializeListHead() function to perform the
1583 equivalent operation.
1585 @param ListHead The head note of a list to initialize.
1588 #define INITIALIZE_LIST_HEAD_VARIABLE(ListHead) {&(ListHead), &(ListHead)}
1592 Initializes the head node of a doubly linked list, and returns the pointer to
1593 the head node of the doubly linked list.
1595 Initializes the forward and backward links of a new linked list. After
1596 initializing a linked list with this function, the other linked list
1597 functions may be used to add and remove nodes from the linked list. It is up
1598 to the caller of this function to allocate the memory for ListHead.
1600 If ListHead is NULL, then ASSERT().
1602 @param ListHead A pointer to the head node of a new doubly linked list.
1609 InitializeListHead (
1610 IN OUT LIST_ENTRY
*ListHead
1615 Adds a node to the beginning of a doubly linked list, and returns the pointer
1616 to the head node of the doubly linked list.
1618 Adds the node Entry at the beginning of the doubly linked list denoted by
1619 ListHead, and returns ListHead.
1621 If ListHead is NULL, then ASSERT().
1622 If Entry is NULL, then ASSERT().
1623 If ListHead was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or
1624 InitializeListHead(), then ASSERT().
1625 If PcdMaximumLinkedListLength is not zero, and prior to insertion the number
1626 of nodes in ListHead, including the ListHead node, is greater than or
1627 equal to PcdMaximumLinkedListLength, then ASSERT().
1629 @param ListHead A pointer to the head node of a doubly linked list.
1630 @param Entry A pointer to a node that is to be inserted at the beginning
1631 of a doubly linked list.
1639 IN OUT LIST_ENTRY
*ListHead
,
1640 IN OUT LIST_ENTRY
*Entry
1645 Adds a node to the end of a doubly linked list, and returns the pointer to
1646 the head node of the doubly linked list.
1648 Adds the node Entry to the end of the doubly linked list denoted by ListHead,
1649 and returns ListHead.
1651 If ListHead is NULL, then ASSERT().
1652 If Entry is NULL, then ASSERT().
1653 If ListHead was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or
1654 InitializeListHead(), then ASSERT().
1655 If PcdMaximumLinkedListLength is not zero, and prior to insertion the number
1656 of nodes in ListHead, including the ListHead node, is greater than or
1657 equal to PcdMaximumLinkedListLength, then ASSERT().
1659 @param ListHead A pointer to the head node of a doubly linked list.
1660 @param Entry A pointer to a node that is to be added at the end of the
1669 IN OUT LIST_ENTRY
*ListHead
,
1670 IN OUT LIST_ENTRY
*Entry
1675 Retrieves the first node of a doubly linked list.
1677 Returns the first node of a doubly linked list. List must have been
1678 initialized with INTIALIZE_LIST_HEAD_VARIABLE() or InitializeListHead().
1679 If List is empty, then List is returned.
1681 If List is NULL, then ASSERT().
1682 If List was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or
1683 InitializeListHead(), then ASSERT().
1684 If PcdMaximumLinkedListLength is not zero, and the number of nodes
1685 in List, including the List node, is greater than or equal to
1686 PcdMaximumLinkedListLength, then ASSERT().
1688 @param List A pointer to the head node of a doubly linked list.
1690 @return The first node of a doubly linked list.
1691 @retval List The list is empty.
1697 IN CONST LIST_ENTRY
*List
1702 Retrieves the next node of a doubly linked list.
1704 Returns the node of a doubly linked list that follows Node.
1705 List must have been initialized with INTIALIZE_LIST_HEAD_VARIABLE()
1706 or InitializeListHead(). If List is empty, then List is returned.
1708 If List is NULL, then ASSERT().
1709 If Node is NULL, then ASSERT().
1710 If List was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or
1711 InitializeListHead(), then ASSERT().
1712 If PcdMaximumLinkedListLength is not zero, and List contains more than
1713 PcdMaximumLinkedListLength nodes, then ASSERT().
1714 If PcdVerifyNodeInList is TRUE and Node is not a node in List, then ASSERT().
1716 @param List A pointer to the head node of a doubly linked list.
1717 @param Node A pointer to a node in the doubly linked list.
1719 @return The pointer to the next node if one exists. Otherwise List is returned.
1725 IN CONST LIST_ENTRY
*List
,
1726 IN CONST LIST_ENTRY
*Node
1731 Retrieves the previous node of a doubly linked list.
1733 Returns the node of a doubly linked list that precedes Node.
1734 List must have been initialized with INTIALIZE_LIST_HEAD_VARIABLE()
1735 or InitializeListHead(). If List is empty, then List is returned.
1737 If List is NULL, then ASSERT().
1738 If Node is NULL, then ASSERT().
1739 If List was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or
1740 InitializeListHead(), then ASSERT().
1741 If PcdMaximumLinkedListLength is not zero, and List contains more than
1742 PcdMaximumLinkedListLength nodes, then ASSERT().
1743 If PcdVerifyNodeInList is TRUE and Node is not a node in List, then ASSERT().
1745 @param List A pointer to the head node of a doubly linked list.
1746 @param Node A pointer to a node in the doubly linked list.
1748 @return The pointer to the previous node if one exists. Otherwise List is returned.
1754 IN CONST LIST_ENTRY
*List
,
1755 IN CONST LIST_ENTRY
*Node
1760 Checks to see if a doubly linked list is empty or not.
1762 Checks to see if the doubly linked list is empty. If the linked list contains
1763 zero nodes, this function returns TRUE. Otherwise, it returns FALSE.
1765 If ListHead is NULL, then ASSERT().
1766 If ListHead was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or
1767 InitializeListHead(), then ASSERT().
1768 If PcdMaximumLinkedListLength is not zero, and the number of nodes
1769 in List, including the List node, is greater than or equal to
1770 PcdMaximumLinkedListLength, then ASSERT().
1772 @param ListHead A pointer to the head node of a doubly linked list.
1774 @retval TRUE The linked list is empty.
1775 @retval FALSE The linked list is not empty.
1781 IN CONST LIST_ENTRY
*ListHead
1786 Determines if a node in a doubly linked list is the head node of a the same
1787 doubly linked list. This function is typically used to terminate a loop that
1788 traverses all the nodes in a doubly linked list starting with the head node.
1790 Returns TRUE if Node is equal to List. Returns FALSE if Node is one of the
1791 nodes in the doubly linked list specified by List. List must have been
1792 initialized with INTIALIZE_LIST_HEAD_VARIABLE() or InitializeListHead().
1794 If List is NULL, then ASSERT().
1795 If Node is NULL, then ASSERT().
1796 If List was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or InitializeListHead(),
1798 If PcdMaximumLinkedListLength is not zero, and the number of nodes
1799 in List, including the List node, is greater than or equal to
1800 PcdMaximumLinkedListLength, then ASSERT().
1801 If PcdVerifyNodeInList is TRUE and Node is not a node in List the and Node is not equal
1802 to List, then ASSERT().
1804 @param List A pointer to the head node of a doubly linked list.
1805 @param Node A pointer to a node in the doubly linked list.
1807 @retval TRUE Node is the head of the doubly-linked list pointed by List.
1808 @retval FALSE Node is not the head of the doubly-linked list pointed by List.
1814 IN CONST LIST_ENTRY
*List
,
1815 IN CONST LIST_ENTRY
*Node
1820 Determines if a node the last node in a doubly linked list.
1822 Returns TRUE if Node is the last node in the doubly linked list specified by
1823 List. Otherwise, FALSE is returned. List must have been initialized with
1824 INTIALIZE_LIST_HEAD_VARIABLE() or InitializeListHead().
1826 If List is NULL, then ASSERT().
1827 If Node is NULL, then ASSERT().
1828 If List was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or
1829 InitializeListHead(), then ASSERT().
1830 If PcdMaximumLinkedListLength is not zero, and the number of nodes
1831 in List, including the List node, is greater than or equal to
1832 PcdMaximumLinkedListLength, then ASSERT().
1833 If PcdVerifyNodeInList is TRUE and Node is not a node in List, then ASSERT().
1835 @param List A pointer to the head node of a doubly linked list.
1836 @param Node A pointer to a node in the doubly linked list.
1838 @retval TRUE Node is the last node in the linked list.
1839 @retval FALSE Node is not the last node in the linked list.
1845 IN CONST LIST_ENTRY
*List
,
1846 IN CONST LIST_ENTRY
*Node
1851 Swaps the location of two nodes in a doubly linked list, and returns the
1852 first node after the swap.
1854 If FirstEntry is identical to SecondEntry, then SecondEntry is returned.
1855 Otherwise, the location of the FirstEntry node is swapped with the location
1856 of the SecondEntry node in a doubly linked list. SecondEntry must be in the
1857 same double linked list as FirstEntry and that double linked list must have
1858 been initialized with INTIALIZE_LIST_HEAD_VARIABLE() or InitializeListHead().
1859 SecondEntry is returned after the nodes are swapped.
1861 If FirstEntry is NULL, then ASSERT().
1862 If SecondEntry is NULL, then ASSERT().
1863 If PcdVerifyNodeInList is TRUE and SecondEntry and FirstEntry are not in the
1864 same linked list, then ASSERT().
1865 If PcdMaximumLinkedListLength is not zero, and the number of nodes in the
1866 linked list containing the FirstEntry and SecondEntry nodes, including
1867 the FirstEntry and SecondEntry nodes, is greater than or equal to
1868 PcdMaximumLinkedListLength, then ASSERT().
1870 @param FirstEntry A pointer to a node in a linked list.
1871 @param SecondEntry A pointer to another node in the same linked list.
1873 @return SecondEntry.
1879 IN OUT LIST_ENTRY
*FirstEntry
,
1880 IN OUT LIST_ENTRY
*SecondEntry
1885 Removes a node from a doubly linked list, and returns the node that follows
1888 Removes the node Entry from a doubly linked list. It is up to the caller of
1889 this function to release the memory used by this node if that is required. On
1890 exit, the node following Entry in the doubly linked list is returned. If
1891 Entry is the only node in the linked list, then the head node of the linked
1894 If Entry is NULL, then ASSERT().
1895 If Entry is the head node of an empty list, then ASSERT().
1896 If PcdMaximumLinkedListLength is not zero, and the number of nodes in the
1897 linked list containing Entry, including the Entry node, is greater than
1898 or equal to PcdMaximumLinkedListLength, then ASSERT().
1900 @param Entry A pointer to a node in a linked list.
1908 IN CONST LIST_ENTRY
*Entry
1916 Shifts a 64-bit integer left between 0 and 63 bits. The low bits are filled
1917 with zeros. The shifted value is returned.
1919 This function shifts the 64-bit value Operand to the left by Count bits. The
1920 low Count bits are set to zero. The shifted value is returned.
1922 If Count is greater than 63, then ASSERT().
1924 @param Operand The 64-bit operand to shift left.
1925 @param Count The number of bits to shift left.
1927 @return Operand << Count.
1939 Shifts a 64-bit integer right between 0 and 63 bits. This high bits are
1940 filled with zeros. The shifted value is returned.
1942 This function shifts the 64-bit value Operand to the right by Count bits. The
1943 high Count bits are set to zero. The shifted value is returned.
1945 If Count is greater than 63, then ASSERT().
1947 @param Operand The 64-bit operand to shift right.
1948 @param Count The number of bits to shift right.
1950 @return Operand >> Count
1962 Shifts a 64-bit integer right between 0 and 63 bits. The high bits are filled
1963 with original integer's bit 63. The shifted value is returned.
1965 This function shifts the 64-bit value Operand to the right by Count bits. The
1966 high Count bits are set to bit 63 of Operand. The shifted value is returned.
1968 If Count is greater than 63, then ASSERT().
1970 @param Operand The 64-bit operand to shift right.
1971 @param Count The number of bits to shift right.
1973 @return Operand >> Count
1985 Rotates a 32-bit integer left between 0 and 31 bits, filling the low bits
1986 with the high bits that were rotated.
1988 This function rotates the 32-bit value Operand to the left by Count bits. The
1989 low Count bits are fill with the high Count bits of Operand. The rotated
1992 If Count is greater than 31, then ASSERT().
1994 @param Operand The 32-bit operand to rotate left.
1995 @param Count The number of bits to rotate left.
1997 @return Operand << Count
2009 Rotates a 32-bit integer right between 0 and 31 bits, filling the high bits
2010 with the low bits that were rotated.
2012 This function rotates the 32-bit value Operand to the right by Count bits.
2013 The high Count bits are fill with the low Count bits of Operand. The rotated
2016 If Count is greater than 31, then ASSERT().
2018 @param Operand The 32-bit operand to rotate right.
2019 @param Count The number of bits to rotate right.
2021 @return Operand >> Count
2033 Rotates a 64-bit integer left between 0 and 63 bits, filling the low bits
2034 with the high bits that were rotated.
2036 This function rotates the 64-bit value Operand to the left by Count bits. The
2037 low Count bits are fill with the high Count bits of Operand. The rotated
2040 If Count is greater than 63, then ASSERT().
2042 @param Operand The 64-bit operand to rotate left.
2043 @param Count The number of bits to rotate left.
2045 @return Operand << Count
2057 Rotates a 64-bit integer right between 0 and 63 bits, filling the high bits
2058 with the high low bits that were rotated.
2060 This function rotates the 64-bit value Operand to the right by Count bits.
2061 The high Count bits are fill with the low Count bits of Operand. The rotated
2064 If Count is greater than 63, then ASSERT().
2066 @param Operand The 64-bit operand to rotate right.
2067 @param Count The number of bits to rotate right.
2069 @return Operand >> Count
2081 Returns the bit position of the lowest bit set in a 32-bit value.
2083 This function computes the bit position of the lowest bit set in the 32-bit
2084 value specified by Operand. If Operand is zero, then -1 is returned.
2085 Otherwise, a value between 0 and 31 is returned.
2087 @param Operand The 32-bit operand to evaluate.
2089 @retval 0..31 The lowest bit set in Operand was found.
2090 @retval -1 Operand is zero.
2101 Returns the bit position of the lowest bit set in a 64-bit value.
2103 This function computes the bit position of the lowest bit set in the 64-bit
2104 value specified by Operand. If Operand is zero, then -1 is returned.
2105 Otherwise, a value between 0 and 63 is returned.
2107 @param Operand The 64-bit operand to evaluate.
2109 @retval 0..63 The lowest bit set in Operand was found.
2110 @retval -1 Operand is zero.
2122 Returns the bit position of the highest bit set in a 32-bit value. Equivalent
2125 This function computes the bit position of the highest bit set in the 32-bit
2126 value specified by Operand. If Operand is zero, then -1 is returned.
2127 Otherwise, a value between 0 and 31 is returned.
2129 @param Operand The 32-bit operand to evaluate.
2131 @retval 0..31 Position of the highest bit set in Operand if found.
2132 @retval -1 Operand is zero.
2143 Returns the bit position of the highest bit set in a 64-bit value. Equivalent
2146 This function computes the bit position of the highest bit set in the 64-bit
2147 value specified by Operand. If Operand is zero, then -1 is returned.
2148 Otherwise, a value between 0 and 63 is returned.
2150 @param Operand The 64-bit operand to evaluate.
2152 @retval 0..63 Position of the highest bit set in Operand if found.
2153 @retval -1 Operand is zero.
2164 Returns the value of the highest bit set in a 32-bit value. Equivalent to
2167 This function computes the value of the highest bit set in the 32-bit value
2168 specified by Operand. If Operand is zero, then zero is returned.
2170 @param Operand The 32-bit operand to evaluate.
2172 @return 1 << HighBitSet32(Operand)
2173 @retval 0 Operand is zero.
2184 Returns the value of the highest bit set in a 64-bit value. Equivalent to
2187 This function computes the value of the highest bit set in the 64-bit value
2188 specified by Operand. If Operand is zero, then zero is returned.
2190 @param Operand The 64-bit operand to evaluate.
2192 @return 1 << HighBitSet64(Operand)
2193 @retval 0 Operand is zero.
2204 Switches the endianness of a 16-bit integer.
2206 This function swaps the bytes in a 16-bit unsigned value to switch the value
2207 from little endian to big endian or vice versa. The byte swapped value is
2210 @param Value A 16-bit unsigned value.
2212 @return The byte swapped Value.
2223 Switches the endianness of a 32-bit integer.
2225 This function swaps the bytes in a 32-bit unsigned value to switch the value
2226 from little endian to big endian or vice versa. The byte swapped value is
2229 @param Value A 32-bit unsigned value.
2231 @return The byte swapped Value.
2242 Switches the endianness of a 64-bit integer.
2244 This function swaps the bytes in a 64-bit unsigned value to switch the value
2245 from little endian to big endian or vice versa. The byte swapped value is
2248 @param Value A 64-bit unsigned value.
2250 @return The byte swapped Value.
2261 Multiples a 64-bit unsigned integer by a 32-bit unsigned integer and
2262 generates a 64-bit unsigned result.
2264 This function multiples the 64-bit unsigned value Multiplicand by the 32-bit
2265 unsigned value Multiplier and generates a 64-bit unsigned result. This 64-
2266 bit unsigned result is returned.
2268 @param Multiplicand A 64-bit unsigned value.
2269 @param Multiplier A 32-bit unsigned value.
2271 @return Multiplicand * Multiplier
2277 IN UINT64 Multiplicand
,
2278 IN UINT32 Multiplier
2283 Multiples a 64-bit unsigned integer by a 64-bit unsigned integer and
2284 generates a 64-bit unsigned result.
2286 This function multiples the 64-bit unsigned value Multiplicand by the 64-bit
2287 unsigned value Multiplier and generates a 64-bit unsigned result. This 64-
2288 bit unsigned result is returned.
2290 @param Multiplicand A 64-bit unsigned value.
2291 @param Multiplier A 64-bit unsigned value.
2293 @return Multiplicand * Multiplier.
2299 IN UINT64 Multiplicand
,
2300 IN UINT64 Multiplier
2305 Multiples a 64-bit signed integer by a 64-bit signed integer and generates a
2306 64-bit signed result.
2308 This function multiples the 64-bit signed value Multiplicand by the 64-bit
2309 signed value Multiplier and generates a 64-bit signed result. This 64-bit
2310 signed result is returned.
2312 @param Multiplicand A 64-bit signed value.
2313 @param Multiplier A 64-bit signed value.
2315 @return Multiplicand * Multiplier
2321 IN INT64 Multiplicand
,
2327 Divides a 64-bit unsigned integer by a 32-bit unsigned integer and generates
2328 a 64-bit unsigned result.
2330 This function divides the 64-bit unsigned value Dividend by the 32-bit
2331 unsigned value Divisor and generates a 64-bit unsigned quotient. This
2332 function returns the 64-bit unsigned quotient.
2334 If Divisor is 0, then ASSERT().
2336 @param Dividend A 64-bit unsigned value.
2337 @param Divisor A 32-bit unsigned value.
2339 @return Dividend / Divisor.
2351 Divides a 64-bit unsigned integer by a 32-bit unsigned integer and generates
2352 a 32-bit unsigned remainder.
2354 This function divides the 64-bit unsigned value Dividend by the 32-bit
2355 unsigned value Divisor and generates a 32-bit remainder. This function
2356 returns the 32-bit unsigned remainder.
2358 If Divisor is 0, then ASSERT().
2360 @param Dividend A 64-bit unsigned value.
2361 @param Divisor A 32-bit unsigned value.
2363 @return Dividend % Divisor.
2375 Divides a 64-bit unsigned integer by a 32-bit unsigned integer and generates
2376 a 64-bit unsigned result and an optional 32-bit unsigned remainder.
2378 This function divides the 64-bit unsigned value Dividend by the 32-bit
2379 unsigned value Divisor and generates a 64-bit unsigned quotient. If Remainder
2380 is not NULL, then the 32-bit unsigned remainder is returned in Remainder.
2381 This function returns the 64-bit unsigned quotient.
2383 If Divisor is 0, then ASSERT().
2385 @param Dividend A 64-bit unsigned value.
2386 @param Divisor A 32-bit unsigned value.
2387 @param Remainder A pointer to a 32-bit unsigned value. This parameter is
2388 optional and may be NULL.
2390 @return Dividend / Divisor.
2395 DivU64x32Remainder (
2398 OUT UINT32
*Remainder OPTIONAL
2403 Divides a 64-bit unsigned integer by a 64-bit unsigned integer and generates
2404 a 64-bit unsigned result and an optional 64-bit unsigned remainder.
2406 This function divides the 64-bit unsigned value Dividend by the 64-bit
2407 unsigned value Divisor and generates a 64-bit unsigned quotient. If Remainder
2408 is not NULL, then the 64-bit unsigned remainder is returned in Remainder.
2409 This function returns the 64-bit unsigned quotient.
2411 If Divisor is 0, then ASSERT().
2413 @param Dividend A 64-bit unsigned value.
2414 @param Divisor A 64-bit unsigned value.
2415 @param Remainder A pointer to a 64-bit unsigned value. This parameter is
2416 optional and may be NULL.
2418 @return Dividend / Divisor.
2423 DivU64x64Remainder (
2426 OUT UINT64
*Remainder OPTIONAL
2431 Divides a 64-bit signed integer by a 64-bit signed integer and generates a
2432 64-bit signed result and a optional 64-bit signed remainder.
2434 This function divides the 64-bit signed value Dividend by the 64-bit signed
2435 value Divisor and generates a 64-bit signed quotient. If Remainder is not
2436 NULL, then the 64-bit signed remainder is returned in Remainder. This
2437 function returns the 64-bit signed quotient.
2439 It is the caller's responsibility to not call this function with a Divisor of 0.
2440 If Divisor is 0, then the quotient and remainder should be assumed to be
2441 the largest negative integer.
2443 If Divisor is 0, then ASSERT().
2445 @param Dividend A 64-bit signed value.
2446 @param Divisor A 64-bit signed value.
2447 @param Remainder A pointer to a 64-bit signed value. This parameter is
2448 optional and may be NULL.
2450 @return Dividend / Divisor.
2455 DivS64x64Remainder (
2458 OUT INT64
*Remainder OPTIONAL
2463 Reads a 16-bit value from memory that may be unaligned.
2465 This function returns the 16-bit value pointed to by Buffer. The function
2466 guarantees that the read operation does not produce an alignment fault.
2468 If the Buffer is NULL, then ASSERT().
2470 @param Buffer The pointer to a 16-bit value that may be unaligned.
2472 @return The 16-bit value read from Buffer.
2478 IN CONST UINT16
*Buffer
2483 Writes a 16-bit value to memory that may be unaligned.
2485 This function writes the 16-bit value specified by Value to Buffer. Value is
2486 returned. The function guarantees that the write operation does not produce
2489 If the Buffer is NULL, then ASSERT().
2491 @param Buffer The pointer to a 16-bit value that may be unaligned.
2492 @param Value 16-bit value to write to Buffer.
2494 @return The 16-bit value to write to Buffer.
2506 Reads a 24-bit value from memory that may be unaligned.
2508 This function returns the 24-bit value pointed to by Buffer. The function
2509 guarantees that the read operation does not produce an alignment fault.
2511 If the Buffer is NULL, then ASSERT().
2513 @param Buffer The pointer to a 24-bit value that may be unaligned.
2515 @return The 24-bit value read from Buffer.
2521 IN CONST UINT32
*Buffer
2526 Writes a 24-bit value to memory that may be unaligned.
2528 This function writes the 24-bit value specified by Value to Buffer. Value is
2529 returned. The function guarantees that the write operation does not produce
2532 If the Buffer is NULL, then ASSERT().
2534 @param Buffer The pointer to a 24-bit value that may be unaligned.
2535 @param Value 24-bit value to write to Buffer.
2537 @return The 24-bit value to write to Buffer.
2549 Reads a 32-bit value from memory that may be unaligned.
2551 This function returns the 32-bit value pointed to by Buffer. The function
2552 guarantees that the read operation does not produce an alignment fault.
2554 If the Buffer is NULL, then ASSERT().
2556 @param Buffer The pointer to a 32-bit value that may be unaligned.
2558 @return The 32-bit value read from Buffer.
2564 IN CONST UINT32
*Buffer
2569 Writes a 32-bit value to memory that may be unaligned.
2571 This function writes the 32-bit value specified by Value to Buffer. Value is
2572 returned. The function guarantees that the write operation does not produce
2575 If the Buffer is NULL, then ASSERT().
2577 @param Buffer The pointer to a 32-bit value that may be unaligned.
2578 @param Value 32-bit value to write to Buffer.
2580 @return The 32-bit value to write to Buffer.
2592 Reads a 64-bit value from memory that may be unaligned.
2594 This function returns the 64-bit value pointed to by Buffer. The function
2595 guarantees that the read operation does not produce an alignment fault.
2597 If the Buffer is NULL, then ASSERT().
2599 @param Buffer The pointer to a 64-bit value that may be unaligned.
2601 @return The 64-bit value read from Buffer.
2607 IN CONST UINT64
*Buffer
2612 Writes a 64-bit value to memory that may be unaligned.
2614 This function writes the 64-bit value specified by Value to Buffer. Value is
2615 returned. The function guarantees that the write operation does not produce
2618 If the Buffer is NULL, then ASSERT().
2620 @param Buffer The pointer to a 64-bit value that may be unaligned.
2621 @param Value 64-bit value to write to Buffer.
2623 @return The 64-bit value to write to Buffer.
2635 // Bit Field Functions
2639 Returns a bit field from an 8-bit value.
2641 Returns the bitfield specified by the StartBit and the EndBit from Operand.
2643 If 8-bit operations are not supported, then ASSERT().
2644 If StartBit is greater than 7, then ASSERT().
2645 If EndBit is greater than 7, then ASSERT().
2646 If EndBit is less than StartBit, then ASSERT().
2648 @param Operand Operand on which to perform the bitfield operation.
2649 @param StartBit The ordinal of the least significant bit in the bit field.
2651 @param EndBit The ordinal of the most significant bit in the bit field.
2654 @return The bit field read.
2667 Writes a bit field to an 8-bit value, and returns the result.
2669 Writes Value to the bit field specified by the StartBit and the EndBit in
2670 Operand. All other bits in Operand are preserved. The new 8-bit value is
2673 If 8-bit operations are not supported, then ASSERT().
2674 If StartBit is greater than 7, then ASSERT().
2675 If EndBit is greater than 7, then ASSERT().
2676 If EndBit is less than StartBit, then ASSERT().
2677 If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
2679 @param Operand Operand on which to perform the bitfield operation.
2680 @param StartBit The ordinal of the least significant bit in the bit field.
2682 @param EndBit The ordinal of the most significant bit in the bit field.
2684 @param Value New value of the bit field.
2686 @return The new 8-bit value.
2700 Reads a bit field from an 8-bit value, performs a bitwise OR, and returns the
2703 Performs a bitwise OR between the bit field specified by StartBit
2704 and EndBit in Operand and the value specified by OrData. All other bits in
2705 Operand are preserved. The new 8-bit value is returned.
2707 If 8-bit operations are not supported, then ASSERT().
2708 If StartBit is greater than 7, then ASSERT().
2709 If EndBit is greater than 7, then ASSERT().
2710 If EndBit is less than StartBit, then ASSERT().
2711 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
2713 @param Operand Operand on which to perform the bitfield operation.
2714 @param StartBit The ordinal of the least significant bit in the bit field.
2716 @param EndBit The ordinal of the most significant bit in the bit field.
2718 @param OrData The value to OR with the read value from the value
2720 @return The new 8-bit value.
2734 Reads a bit field from an 8-bit value, performs a bitwise AND, and returns
2737 Performs a bitwise AND between the bit field specified by StartBit and EndBit
2738 in Operand and the value specified by AndData. All other bits in Operand are
2739 preserved. The new 8-bit value is returned.
2741 If 8-bit operations are not supported, then ASSERT().
2742 If StartBit is greater than 7, then ASSERT().
2743 If EndBit is greater than 7, then ASSERT().
2744 If EndBit is less than StartBit, then ASSERT().
2745 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
2747 @param Operand Operand on which to perform the bitfield operation.
2748 @param StartBit The ordinal of the least significant bit in the bit field.
2750 @param EndBit The ordinal of the most significant bit in the bit field.
2752 @param AndData The value to AND with the read value from the value.
2754 @return The new 8-bit value.
2768 Reads a bit field from an 8-bit value, performs a bitwise AND followed by a
2769 bitwise OR, and returns the result.
2771 Performs a bitwise AND between the bit field specified by StartBit and EndBit
2772 in Operand and the value specified by AndData, followed by a bitwise
2773 OR with value specified by OrData. All other bits in Operand are
2774 preserved. The new 8-bit value is returned.
2776 If 8-bit operations are not supported, then ASSERT().
2777 If StartBit is greater than 7, then ASSERT().
2778 If EndBit is greater than 7, then ASSERT().
2779 If EndBit is less than StartBit, then ASSERT().
2780 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
2781 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
2783 @param Operand Operand on which to perform the bitfield operation.
2784 @param StartBit The ordinal of the least significant bit in the bit field.
2786 @param EndBit The ordinal of the most significant bit in the bit field.
2788 @param AndData The value to AND with the read value from the value.
2789 @param OrData The value to OR with the result of the AND operation.
2791 @return The new 8-bit value.
2796 BitFieldAndThenOr8 (
2806 Returns a bit field from a 16-bit value.
2808 Returns the bitfield specified by the StartBit and the EndBit from Operand.
2810 If 16-bit operations are not supported, then ASSERT().
2811 If StartBit is greater than 15, then ASSERT().
2812 If EndBit is greater than 15, then ASSERT().
2813 If EndBit is less than StartBit, then ASSERT().
2815 @param Operand Operand on which to perform the bitfield operation.
2816 @param StartBit The ordinal of the least significant bit in the bit field.
2818 @param EndBit The ordinal of the most significant bit in the bit field.
2821 @return The bit field read.
2834 Writes a bit field to a 16-bit value, and returns the result.
2836 Writes Value to the bit field specified by the StartBit and the EndBit in
2837 Operand. All other bits in Operand are preserved. The new 16-bit value is
2840 If 16-bit operations are not supported, then ASSERT().
2841 If StartBit is greater than 15, then ASSERT().
2842 If EndBit is greater than 15, then ASSERT().
2843 If EndBit is less than StartBit, then ASSERT().
2844 If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
2846 @param Operand Operand on which to perform the bitfield operation.
2847 @param StartBit The ordinal of the least significant bit in the bit field.
2849 @param EndBit The ordinal of the most significant bit in the bit field.
2851 @param Value New value of the bit field.
2853 @return The new 16-bit value.
2867 Reads a bit field from a 16-bit value, performs a bitwise OR, and returns the
2870 Performs a bitwise OR between the bit field specified by StartBit
2871 and EndBit in Operand and the value specified by OrData. All other bits in
2872 Operand are preserved. The new 16-bit value is returned.
2874 If 16-bit operations are not supported, then ASSERT().
2875 If StartBit is greater than 15, then ASSERT().
2876 If EndBit is greater than 15, then ASSERT().
2877 If EndBit is less than StartBit, then ASSERT().
2878 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
2880 @param Operand Operand on which to perform the bitfield operation.
2881 @param StartBit The ordinal of the least significant bit in the bit field.
2883 @param EndBit The ordinal of the most significant bit in the bit field.
2885 @param OrData The value to OR with the read value from the value
2887 @return The new 16-bit value.
2901 Reads a bit field from a 16-bit value, performs a bitwise AND, and returns
2904 Performs a bitwise AND between the bit field specified by StartBit and EndBit
2905 in Operand and the value specified by AndData. All other bits in Operand are
2906 preserved. The new 16-bit value is returned.
2908 If 16-bit operations are not supported, then ASSERT().
2909 If StartBit is greater than 15, then ASSERT().
2910 If EndBit is greater than 15, then ASSERT().
2911 If EndBit is less than StartBit, then ASSERT().
2912 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
2914 @param Operand Operand on which to perform the bitfield operation.
2915 @param StartBit The ordinal of the least significant bit in the bit field.
2917 @param EndBit The ordinal of the most significant bit in the bit field.
2919 @param AndData The value to AND with the read value from the value
2921 @return The new 16-bit value.
2935 Reads a bit field from a 16-bit value, performs a bitwise AND followed by a
2936 bitwise OR, and returns the result.
2938 Performs a bitwise AND between the bit field specified by StartBit and EndBit
2939 in Operand and the value specified by AndData, followed by a bitwise
2940 OR with value specified by OrData. All other bits in Operand are
2941 preserved. The new 16-bit value is returned.
2943 If 16-bit operations are not supported, then ASSERT().
2944 If StartBit is greater than 15, then ASSERT().
2945 If EndBit is greater than 15, then ASSERT().
2946 If EndBit is less than StartBit, then ASSERT().
2947 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
2948 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
2950 @param Operand Operand on which to perform the bitfield operation.
2951 @param StartBit The ordinal of the least significant bit in the bit field.
2953 @param EndBit The ordinal of the most significant bit in the bit field.
2955 @param AndData The value to AND with the read value from the value.
2956 @param OrData The value to OR with the result of the AND operation.
2958 @return The new 16-bit value.
2963 BitFieldAndThenOr16 (
2973 Returns a bit field from a 32-bit value.
2975 Returns the bitfield specified by the StartBit and the EndBit from Operand.
2977 If 32-bit operations are not supported, then ASSERT().
2978 If StartBit is greater than 31, then ASSERT().
2979 If EndBit is greater than 31, then ASSERT().
2980 If EndBit is less than StartBit, then ASSERT().
2982 @param Operand Operand on which to perform the bitfield operation.
2983 @param StartBit The ordinal of the least significant bit in the bit field.
2985 @param EndBit The ordinal of the most significant bit in the bit field.
2988 @return The bit field read.
3001 Writes a bit field to a 32-bit value, and returns the result.
3003 Writes Value to the bit field specified by the StartBit and the EndBit in
3004 Operand. All other bits in Operand are preserved. The new 32-bit value is
3007 If 32-bit operations are not supported, then ASSERT().
3008 If StartBit is greater than 31, then ASSERT().
3009 If EndBit is greater than 31, then ASSERT().
3010 If EndBit is less than StartBit, then ASSERT().
3011 If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
3013 @param Operand Operand on which to perform the bitfield operation.
3014 @param StartBit The ordinal of the least significant bit in the bit field.
3016 @param EndBit The ordinal of the most significant bit in the bit field.
3018 @param Value New value of the bit field.
3020 @return The new 32-bit value.
3034 Reads a bit field from a 32-bit value, performs a bitwise OR, and returns the
3037 Performs a bitwise OR between the bit field specified by StartBit
3038 and EndBit in Operand and the value specified by OrData. All other bits in
3039 Operand are preserved. The new 32-bit value is returned.
3041 If 32-bit operations are not supported, then ASSERT().
3042 If StartBit is greater than 31, then ASSERT().
3043 If EndBit is greater than 31, then ASSERT().
3044 If EndBit is less than StartBit, then ASSERT().
3045 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
3047 @param Operand Operand on which to perform the bitfield operation.
3048 @param StartBit The ordinal of the least significant bit in the bit field.
3050 @param EndBit The ordinal of the most significant bit in the bit field.
3052 @param OrData The value to OR with the read value from the value.
3054 @return The new 32-bit value.
3068 Reads a bit field from a 32-bit value, performs a bitwise AND, and returns
3071 Performs a bitwise AND between the bit field specified by StartBit and EndBit
3072 in Operand and the value specified by AndData. All other bits in Operand are
3073 preserved. The new 32-bit value is returned.
3075 If 32-bit operations are not supported, then ASSERT().
3076 If StartBit is greater than 31, then ASSERT().
3077 If EndBit is greater than 31, then ASSERT().
3078 If EndBit is less than StartBit, then ASSERT().
3079 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
3081 @param Operand Operand on which to perform the bitfield operation.
3082 @param StartBit The ordinal of the least significant bit in the bit field.
3084 @param EndBit The ordinal of the most significant bit in the bit field.
3086 @param AndData The value to AND with the read value from the value
3088 @return The new 32-bit value.
3102 Reads a bit field from a 32-bit value, performs a bitwise AND followed by a
3103 bitwise OR, and returns the result.
3105 Performs a bitwise AND between the bit field specified by StartBit and EndBit
3106 in Operand and the value specified by AndData, followed by a bitwise
3107 OR with value specified by OrData. All other bits in Operand are
3108 preserved. The new 32-bit value is returned.
3110 If 32-bit operations are not supported, then ASSERT().
3111 If StartBit is greater than 31, then ASSERT().
3112 If EndBit is greater than 31, then ASSERT().
3113 If EndBit is less than StartBit, then ASSERT().
3114 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
3115 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
3117 @param Operand Operand on which to perform the bitfield operation.
3118 @param StartBit The ordinal of the least significant bit in the bit field.
3120 @param EndBit The ordinal of the most significant bit in the bit field.
3122 @param AndData The value to AND with the read value from the value.
3123 @param OrData The value to OR with the result of the AND operation.
3125 @return The new 32-bit value.
3130 BitFieldAndThenOr32 (
3140 Returns a bit field from a 64-bit value.
3142 Returns the bitfield specified by the StartBit and the EndBit from Operand.
3144 If 64-bit operations are not supported, then ASSERT().
3145 If StartBit is greater than 63, then ASSERT().
3146 If EndBit is greater than 63, then ASSERT().
3147 If EndBit is less than StartBit, then ASSERT().
3149 @param Operand Operand on which to perform the bitfield operation.
3150 @param StartBit The ordinal of the least significant bit in the bit field.
3152 @param EndBit The ordinal of the most significant bit in the bit field.
3155 @return The bit field read.
3168 Writes a bit field to a 64-bit value, and returns the result.
3170 Writes Value to the bit field specified by the StartBit and the EndBit in
3171 Operand. All other bits in Operand are preserved. The new 64-bit value is
3174 If 64-bit operations are not supported, then ASSERT().
3175 If StartBit is greater than 63, then ASSERT().
3176 If EndBit is greater than 63, then ASSERT().
3177 If EndBit is less than StartBit, then ASSERT().
3178 If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
3180 @param Operand Operand on which to perform the bitfield operation.
3181 @param StartBit The ordinal of the least significant bit in the bit field.
3183 @param EndBit The ordinal of the most significant bit in the bit field.
3185 @param Value New value of the bit field.
3187 @return The new 64-bit value.
3201 Reads a bit field from a 64-bit value, performs a bitwise OR, and returns the
3204 Performs a bitwise OR between the bit field specified by StartBit
3205 and EndBit in Operand and the value specified by OrData. All other bits in
3206 Operand are preserved. The new 64-bit value is returned.
3208 If 64-bit operations are not supported, then ASSERT().
3209 If StartBit is greater than 63, then ASSERT().
3210 If EndBit is greater than 63, then ASSERT().
3211 If EndBit is less than StartBit, then ASSERT().
3212 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
3214 @param Operand Operand on which to perform the bitfield operation.
3215 @param StartBit The ordinal of the least significant bit in the bit field.
3217 @param EndBit The ordinal of the most significant bit in the bit field.
3219 @param OrData The value to OR with the read value from the value
3221 @return The new 64-bit value.
3235 Reads a bit field from a 64-bit value, performs a bitwise AND, and returns
3238 Performs a bitwise AND between the bit field specified by StartBit and EndBit
3239 in Operand and the value specified by AndData. All other bits in Operand are
3240 preserved. The new 64-bit value is returned.
3242 If 64-bit operations are not supported, then ASSERT().
3243 If StartBit is greater than 63, then ASSERT().
3244 If EndBit is greater than 63, then ASSERT().
3245 If EndBit is less than StartBit, then ASSERT().
3246 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
3248 @param Operand Operand on which to perform the bitfield operation.
3249 @param StartBit The ordinal of the least significant bit in the bit field.
3251 @param EndBit The ordinal of the most significant bit in the bit field.
3253 @param AndData The value to AND with the read value from the value
3255 @return The new 64-bit value.
3269 Reads a bit field from a 64-bit value, performs a bitwise AND followed by a
3270 bitwise OR, and returns the result.
3272 Performs a bitwise AND between the bit field specified by StartBit and EndBit
3273 in Operand and the value specified by AndData, followed by a bitwise
3274 OR with value specified by OrData. All other bits in Operand are
3275 preserved. The new 64-bit value is returned.
3277 If 64-bit operations are not supported, then ASSERT().
3278 If StartBit is greater than 63, then ASSERT().
3279 If EndBit is greater than 63, then ASSERT().
3280 If EndBit is less than StartBit, then ASSERT().
3281 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
3282 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
3284 @param Operand Operand on which to perform the bitfield operation.
3285 @param StartBit The ordinal of the least significant bit in the bit field.
3287 @param EndBit The ordinal of the most significant bit in the bit field.
3289 @param AndData The value to AND with the read value from the value.
3290 @param OrData The value to OR with the result of the AND operation.
3292 @return The new 64-bit value.
3297 BitFieldAndThenOr64 (
3306 // Base Library Checksum Functions
3310 Returns the sum of all elements in a buffer in unit of UINT8.
3311 During calculation, the carry bits are dropped.
3313 This function calculates the sum of all elements in a buffer
3314 in unit of UINT8. The carry bits in result of addition are dropped.
3315 The result is returned as UINT8. If Length is Zero, then Zero is
3318 If Buffer is NULL, then ASSERT().
3319 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
3321 @param Buffer The pointer to the buffer to carry out the sum operation.
3322 @param Length The size, in bytes, of Buffer.
3324 @return Sum The sum of Buffer with carry bits dropped during additions.
3330 IN CONST UINT8
*Buffer
,
3336 Returns the two's complement checksum of all elements in a buffer
3339 This function first calculates the sum of the 8-bit values in the
3340 buffer specified by Buffer and Length. The carry bits in the result
3341 of addition are dropped. Then, the two's complement of the sum is
3342 returned. If Length is 0, then 0 is returned.
3344 If Buffer is NULL, then ASSERT().
3345 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
3347 @param Buffer The pointer to the buffer to carry out the checksum operation.
3348 @param Length The size, in bytes, of Buffer.
3350 @return Checksum The two's complement checksum of Buffer.
3355 CalculateCheckSum8 (
3356 IN CONST UINT8
*Buffer
,
3362 Returns the sum of all elements in a buffer of 16-bit values. During
3363 calculation, the carry bits are dropped.
3365 This function calculates the sum of the 16-bit values in the buffer
3366 specified by Buffer and Length. The carry bits in result of addition are dropped.
3367 The 16-bit result is returned. If Length is 0, then 0 is returned.
3369 If Buffer is NULL, then ASSERT().
3370 If Buffer is not aligned on a 16-bit boundary, then ASSERT().
3371 If Length is not aligned on a 16-bit boundary, then ASSERT().
3372 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
3374 @param Buffer The pointer to the buffer to carry out the sum operation.
3375 @param Length The size, in bytes, of Buffer.
3377 @return Sum The sum of Buffer with carry bits dropped during additions.
3383 IN CONST UINT16
*Buffer
,
3389 Returns the two's complement checksum of all elements in a buffer of
3392 This function first calculates the sum of the 16-bit values in the buffer
3393 specified by Buffer and Length. The carry bits in the result of addition
3394 are dropped. Then, the two's complement of the sum is returned. If Length
3395 is 0, then 0 is returned.
3397 If Buffer is NULL, then ASSERT().
3398 If Buffer is not aligned on a 16-bit boundary, then ASSERT().
3399 If Length is not aligned on a 16-bit boundary, then ASSERT().
3400 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
3402 @param Buffer The pointer to the buffer to carry out the checksum operation.
3403 @param Length The size, in bytes, of Buffer.
3405 @return Checksum The two's complement checksum of Buffer.
3410 CalculateCheckSum16 (
3411 IN CONST UINT16
*Buffer
,
3417 Returns the sum of all elements in a buffer of 32-bit values. During
3418 calculation, the carry bits are dropped.
3420 This function calculates the sum of the 32-bit values in the buffer
3421 specified by Buffer and Length. The carry bits in result of addition are dropped.
3422 The 32-bit result is returned. If Length is 0, then 0 is returned.
3424 If Buffer is NULL, then ASSERT().
3425 If Buffer is not aligned on a 32-bit boundary, then ASSERT().
3426 If Length is not aligned on a 32-bit boundary, then ASSERT().
3427 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
3429 @param Buffer The pointer to the buffer to carry out the sum operation.
3430 @param Length The size, in bytes, of Buffer.
3432 @return Sum The sum of Buffer with carry bits dropped during additions.
3438 IN CONST UINT32
*Buffer
,
3444 Returns the two's complement checksum of all elements in a buffer of
3447 This function first calculates the sum of the 32-bit values in the buffer
3448 specified by Buffer and Length. The carry bits in the result of addition
3449 are dropped. Then, the two's complement of the sum is returned. If Length
3450 is 0, then 0 is returned.
3452 If Buffer is NULL, then ASSERT().
3453 If Buffer is not aligned on a 32-bit boundary, then ASSERT().
3454 If Length is not aligned on a 32-bit boundary, then ASSERT().
3455 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
3457 @param Buffer The pointer to the buffer to carry out the checksum operation.
3458 @param Length The size, in bytes, of Buffer.
3460 @return Checksum The two's complement checksum of Buffer.
3465 CalculateCheckSum32 (
3466 IN CONST UINT32
*Buffer
,
3472 Returns the sum of all elements in a buffer of 64-bit values. During
3473 calculation, the carry bits are dropped.
3475 This function calculates the sum of the 64-bit values in the buffer
3476 specified by Buffer and Length. The carry bits in result of addition are dropped.
3477 The 64-bit result is returned. If Length is 0, then 0 is returned.
3479 If Buffer is NULL, then ASSERT().
3480 If Buffer is not aligned on a 64-bit boundary, then ASSERT().
3481 If Length is not aligned on a 64-bit boundary, then ASSERT().
3482 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
3484 @param Buffer The pointer to the buffer to carry out the sum operation.
3485 @param Length The size, in bytes, of Buffer.
3487 @return Sum The sum of Buffer with carry bits dropped during additions.
3493 IN CONST UINT64
*Buffer
,
3499 Returns the two's complement checksum of all elements in a buffer of
3502 This function first calculates the sum of the 64-bit values in the buffer
3503 specified by Buffer and Length. The carry bits in the result of addition
3504 are dropped. Then, the two's complement of the sum is returned. If Length
3505 is 0, then 0 is returned.
3507 If Buffer is NULL, then ASSERT().
3508 If Buffer is not aligned on a 64-bit boundary, then ASSERT().
3509 If Length is not aligned on a 64-bit boundary, then ASSERT().
3510 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
3512 @param Buffer The pointer to the buffer to carry out the checksum operation.
3513 @param Length The size, in bytes, of Buffer.
3515 @return Checksum The two's complement checksum of Buffer.
3520 CalculateCheckSum64 (
3521 IN CONST UINT64
*Buffer
,
3527 // Base Library CPU Functions
3531 Function entry point used when a stack switch is requested with SwitchStack()
3533 @param Context1 Context1 parameter passed into SwitchStack().
3534 @param Context2 Context2 parameter passed into SwitchStack().
3539 (EFIAPI
*SWITCH_STACK_ENTRY_POINT
)(
3540 IN VOID
*Context1
, OPTIONAL
3541 IN VOID
*Context2 OPTIONAL
3546 Used to serialize load and store operations.
3548 All loads and stores that proceed calls to this function are guaranteed to be
3549 globally visible when this function returns.
3560 Saves the current CPU context that can be restored with a call to LongJump()
3563 Saves the current CPU context in the buffer specified by JumpBuffer and
3564 returns 0. The initial call to SetJump() must always return 0. Subsequent
3565 calls to LongJump() cause a non-zero value to be returned by SetJump().
3567 If JumpBuffer is NULL, then ASSERT().
3568 For Itanium processors, if JumpBuffer is not aligned on a 16-byte boundary, then ASSERT().
3570 NOTE: The structure BASE_LIBRARY_JUMP_BUFFER is CPU architecture specific.
3571 The same structure must never be used for more than one CPU architecture context.
3572 For example, a BASE_LIBRARY_JUMP_BUFFER allocated by an IA-32 module must never be used from an x64 module.
3573 SetJump()/LongJump() is not currently supported for the EBC processor type.
3575 @param JumpBuffer A pointer to CPU context buffer.
3577 @retval 0 Indicates a return from SetJump().
3583 OUT BASE_LIBRARY_JUMP_BUFFER
*JumpBuffer
3588 Restores the CPU context that was saved with SetJump().
3590 Restores the CPU context from the buffer specified by JumpBuffer. This
3591 function never returns to the caller. Instead is resumes execution based on
3592 the state of JumpBuffer.
3594 If JumpBuffer is NULL, then ASSERT().
3595 For Itanium processors, if JumpBuffer is not aligned on a 16-byte boundary, then ASSERT().
3596 If Value is 0, then ASSERT().
3598 @param JumpBuffer A pointer to CPU context buffer.
3599 @param Value The value to return when the SetJump() context is
3600 restored and must be non-zero.
3606 IN BASE_LIBRARY_JUMP_BUFFER
*JumpBuffer
,
3612 Enables CPU interrupts.
3623 Disables CPU interrupts.
3634 Disables CPU interrupts and returns the interrupt state prior to the disable
3637 @retval TRUE CPU interrupts were enabled on entry to this call.
3638 @retval FALSE CPU interrupts were disabled on entry to this call.
3643 SaveAndDisableInterrupts (
3649 Enables CPU interrupts for the smallest window required to capture any
3655 EnableDisableInterrupts (
3661 Retrieves the current CPU interrupt state.
3663 Returns TRUE if interrupts are currently enabled. Otherwise
3666 @retval TRUE CPU interrupts are enabled.
3667 @retval FALSE CPU interrupts are disabled.
3678 Set the current CPU interrupt state.
3680 Sets the current CPU interrupt state to the state specified by
3681 InterruptState. If InterruptState is TRUE, then interrupts are enabled. If
3682 InterruptState is FALSE, then interrupts are disabled. InterruptState is
3685 @param InterruptState TRUE if interrupts should enabled. FALSE if
3686 interrupts should be disabled.
3688 @return InterruptState
3694 IN BOOLEAN InterruptState
3699 Requests CPU to pause for a short period of time.
3701 Requests CPU to pause for a short period of time. Typically used in MP
3702 systems to prevent memory starvation while waiting for a spin lock.
3713 Transfers control to a function starting with a new stack.
3715 Transfers control to the function specified by EntryPoint using the
3716 new stack specified by NewStack and passing in the parameters specified
3717 by Context1 and Context2. Context1 and Context2 are optional and may
3718 be NULL. The function EntryPoint must never return. This function
3719 supports a variable number of arguments following the NewStack parameter.
3720 These additional arguments are ignored on IA-32, x64, and EBC architectures.
3721 Itanium processors expect one additional parameter of type VOID * that specifies
3722 the new backing store pointer.
3724 If EntryPoint is NULL, then ASSERT().
3725 If NewStack is NULL, then ASSERT().
3727 @param EntryPoint A pointer to function to call with the new stack.
3728 @param Context1 A pointer to the context to pass into the EntryPoint
3730 @param Context2 A pointer to the context to pass into the EntryPoint
3732 @param NewStack A pointer to the new stack to use for the EntryPoint
3734 @param ... This variable argument list is ignored for IA-32, x64, and
3735 EBC architectures. For Itanium processors, this variable
3736 argument list is expected to contain a single parameter of
3737 type VOID * that specifies the new backing store pointer.
3744 IN SWITCH_STACK_ENTRY_POINT EntryPoint
,
3745 IN VOID
*Context1
, OPTIONAL
3746 IN VOID
*Context2
, OPTIONAL
3753 Generates a breakpoint on the CPU.
3755 Generates a breakpoint on the CPU. The breakpoint must be implemented such
3756 that code can resume normal execution after the breakpoint.
3767 Executes an infinite loop.
3769 Forces the CPU to execute an infinite loop. A debugger may be used to skip
3770 past the loop and the code that follows the loop must execute properly. This
3771 implies that the infinite loop must not cause the code that follow it to be
3781 #if defined (MDE_CPU_IPF)
3784 Flush a range of cache lines in the cache coherency domain of the calling
3787 Flushes the cache lines specified by Address and Length. If Address is not aligned
3788 on a cache line boundary, then entire cache line containing Address is flushed.
3789 If Address + Length is not aligned on a cache line boundary, then the entire cache
3790 line containing Address + Length - 1 is flushed. This function may choose to flush
3791 the entire cache if that is more efficient than flushing the specified range. If
3792 Length is 0, the no cache lines are flushed. Address is returned.
3793 This function is only available on Itanium processors.
3795 If Length is greater than (MAX_ADDRESS - Address + 1), then ASSERT().
3797 @param Address The base address of the instruction lines to invalidate. If
3798 the CPU is in a physical addressing mode, then Address is a
3799 physical address. If the CPU is in a virtual addressing mode,
3800 then Address is a virtual address.
3802 @param Length The number of bytes to invalidate from the instruction cache.
3809 AsmFlushCacheRange (
3816 Executes an FC instruction.
3817 Executes an FC instruction on the cache line specified by Address.
3818 The cache line size affected is at least 32-bytes (aligned on a 32-byte boundary).
3819 An implementation may flush a larger region. This function is only available on Itanium processors.
3821 @param Address The Address of cache line to be flushed.
3823 @return The address of FC instruction executed.
3834 Executes an FC.I instruction.
3835 Executes an FC.I instruction on the cache line specified by Address.
3836 The cache line size affected is at least 32-bytes (aligned on a 32-byte boundary).
3837 An implementation may flush a larger region. This function is only available on Itanium processors.
3839 @param Address The Address of cache line to be flushed.
3841 @return The address of the FC.I instruction executed.
3852 Reads the current value of a Processor Identifier Register (CPUID).
3854 Reads and returns the current value of Processor Identifier Register specified by Index.
3855 The Index of largest implemented CPUID (One less than the number of implemented CPUID
3856 registers) is determined by CPUID [3] bits {7:0}.
3857 No parameter checking is performed on Index. If the Index value is beyond the
3858 implemented CPUID register range, a Reserved Register/Field fault may occur. The caller
3859 must either guarantee that Index is valid, or the caller must set up fault handlers to
3860 catch the faults. This function is only available on Itanium processors.
3862 @param Index The 8-bit Processor Identifier Register index to read.
3864 @return The current value of Processor Identifier Register specified by Index.
3875 Reads the current value of 64-bit Processor Status Register (PSR).
3876 This function is only available on Itanium processors.
3878 @return The current value of PSR.
3889 Writes the current value of 64-bit Processor Status Register (PSR).
3891 No parameter checking is performed on Value. All bits of Value corresponding to
3892 reserved fields of PSR must be 0 or a Reserved Register/Field fault may occur.
3893 The caller must either guarantee that Value is valid, or the caller must set up
3894 fault handlers to catch the faults. This function is only available on Itanium processors.
3896 @param Value The 64-bit value to write to PSR.
3898 @return The 64-bit value written to the PSR.
3909 Reads the current value of 64-bit Kernel Register #0 (KR0).
3911 Reads and returns the current value of KR0.
3912 This function is only available on Itanium processors.
3914 @return The current value of KR0.
3925 Reads the current value of 64-bit Kernel Register #1 (KR1).
3927 Reads and returns the current value of KR1.
3928 This function is only available on Itanium processors.
3930 @return The current value of KR1.
3941 Reads the current value of 64-bit Kernel Register #2 (KR2).
3943 Reads and returns the current value of KR2.
3944 This function is only available on Itanium processors.
3946 @return The current value of KR2.
3957 Reads the current value of 64-bit Kernel Register #3 (KR3).
3959 Reads and returns the current value of KR3.
3960 This function is only available on Itanium processors.
3962 @return The current value of KR3.
3973 Reads the current value of 64-bit Kernel Register #4 (KR4).
3975 Reads and returns the current value of KR4.
3976 This function is only available on Itanium processors.
3978 @return The current value of KR4.
3989 Reads the current value of 64-bit Kernel Register #5 (KR5).
3991 Reads and returns the current value of KR5.
3992 This function is only available on Itanium processors.
3994 @return The current value of KR5.
4005 Reads the current value of 64-bit Kernel Register #6 (KR6).
4007 Reads and returns the current value of KR6.
4008 This function is only available on Itanium processors.
4010 @return The current value of KR6.
4021 Reads the current value of 64-bit Kernel Register #7 (KR7).
4023 Reads and returns the current value of KR7.
4024 This function is only available on Itanium processors.
4026 @return The current value of KR7.
4037 Write the current value of 64-bit Kernel Register #0 (KR0).
4039 Writes the current value of KR0. The 64-bit value written to
4040 the KR0 is returned. This function is only available on Itanium processors.
4042 @param Value The 64-bit value to write to KR0.
4044 @return The 64-bit value written to the KR0.
4055 Write the current value of 64-bit Kernel Register #1 (KR1).
4057 Writes the current value of KR1. The 64-bit value written to
4058 the KR1 is returned. This function is only available on Itanium processors.
4060 @param Value The 64-bit value to write to KR1.
4062 @return The 64-bit value written to the KR1.
4073 Write the current value of 64-bit Kernel Register #2 (KR2).
4075 Writes the current value of KR2. The 64-bit value written to
4076 the KR2 is returned. This function is only available on Itanium processors.
4078 @param Value The 64-bit value to write to KR2.
4080 @return The 64-bit value written to the KR2.
4091 Write the current value of 64-bit Kernel Register #3 (KR3).
4093 Writes the current value of KR3. The 64-bit value written to
4094 the KR3 is returned. This function is only available on Itanium processors.
4096 @param Value The 64-bit value to write to KR3.
4098 @return The 64-bit value written to the KR3.
4109 Write the current value of 64-bit Kernel Register #4 (KR4).
4111 Writes the current value of KR4. The 64-bit value written to
4112 the KR4 is returned. This function is only available on Itanium processors.
4114 @param Value The 64-bit value to write to KR4.
4116 @return The 64-bit value written to the KR4.
4127 Write the current value of 64-bit Kernel Register #5 (KR5).
4129 Writes the current value of KR5. The 64-bit value written to
4130 the KR5 is returned. This function is only available on Itanium processors.
4132 @param Value The 64-bit value to write to KR5.
4134 @return The 64-bit value written to the KR5.
4145 Write the current value of 64-bit Kernel Register #6 (KR6).
4147 Writes the current value of KR6. The 64-bit value written to
4148 the KR6 is returned. This function is only available on Itanium processors.
4150 @param Value The 64-bit value to write to KR6.
4152 @return The 64-bit value written to the KR6.
4163 Write the current value of 64-bit Kernel Register #7 (KR7).
4165 Writes the current value of KR7. The 64-bit value written to
4166 the KR7 is returned. This function is only available on Itanium processors.
4168 @param Value The 64-bit value to write to KR7.
4170 @return The 64-bit value written to the KR7.
4181 Reads the current value of Interval Timer Counter Register (ITC).
4183 Reads and returns the current value of ITC.
4184 This function is only available on Itanium processors.
4186 @return The current value of ITC.
4197 Reads the current value of Interval Timer Vector Register (ITV).
4199 Reads and returns the current value of ITV.
4200 This function is only available on Itanium processors.
4202 @return The current value of ITV.
4213 Reads the current value of Interval Timer Match Register (ITM).
4215 Reads and returns the current value of ITM.
4216 This function is only available on Itanium processors.
4218 @return The current value of ITM.
4228 Writes the current value of 64-bit Interval Timer Counter Register (ITC).
4230 Writes the current value of ITC. The 64-bit value written to the ITC is returned.
4231 This function is only available on Itanium processors.
4233 @param Value The 64-bit value to write to ITC.
4235 @return The 64-bit value written to the ITC.
4246 Writes the current value of 64-bit Interval Timer Match Register (ITM).
4248 Writes the current value of ITM. The 64-bit value written to the ITM is returned.
4249 This function is only available on Itanium processors.
4251 @param Value The 64-bit value to write to ITM.
4253 @return The 64-bit value written to the ITM.
4264 Writes the current value of 64-bit Interval Timer Vector Register (ITV).
4266 Writes the current value of ITV. The 64-bit value written to the ITV is returned.
4267 No parameter checking is performed on Value. All bits of Value corresponding to
4268 reserved fields of ITV must be 0 or a Reserved Register/Field fault may occur.
4269 The caller must either guarantee that Value is valid, or the caller must set up
4270 fault handlers to catch the faults.
4271 This function is only available on Itanium processors.
4273 @param Value The 64-bit value to write to ITV.
4275 @return The 64-bit value written to the ITV.
4286 Reads the current value of Default Control Register (DCR).
4288 Reads and returns the current value of DCR. This function is only available on Itanium processors.
4290 @return The current value of DCR.
4301 Reads the current value of Interruption Vector Address Register (IVA).
4303 Reads and returns the current value of IVA. This function is only available on Itanium processors.
4305 @return The current value of IVA.
4315 Reads the current value of Page Table Address Register (PTA).
4317 Reads and returns the current value of PTA. This function is only available on Itanium processors.
4319 @return The current value of PTA.
4330 Writes the current value of 64-bit Default Control Register (DCR).
4332 Writes the current value of DCR. The 64-bit value written to the DCR is returned.
4333 No parameter checking is performed on Value. All bits of Value corresponding to
4334 reserved fields of DCR must be 0 or a Reserved Register/Field fault may occur.
4335 The caller must either guarantee that Value is valid, or the caller must set up
4336 fault handlers to catch the faults.
4337 This function is only available on Itanium processors.
4339 @param Value The 64-bit value to write to DCR.
4341 @return The 64-bit value written to the DCR.
4352 Writes the current value of 64-bit Interruption Vector Address Register (IVA).
4354 Writes the current value of IVA. The 64-bit value written to the IVA is returned.
4355 The size of vector table is 32 K bytes and is 32 K bytes aligned
4356 the low 15 bits of Value is ignored when written.
4357 This function is only available on Itanium processors.
4359 @param Value The 64-bit value to write to IVA.
4361 @return The 64-bit value written to the IVA.
4372 Writes the current value of 64-bit Page Table Address Register (PTA).
4374 Writes the current value of PTA. The 64-bit value written to the PTA is returned.
4375 No parameter checking is performed on Value. All bits of Value corresponding to
4376 reserved fields of DCR must be 0 or a Reserved Register/Field fault may occur.
4377 The caller must either guarantee that Value is valid, or the caller must set up
4378 fault handlers to catch the faults.
4379 This function is only available on Itanium processors.
4381 @param Value The 64-bit value to write to PTA.
4383 @return The 64-bit value written to the PTA.
4393 Reads the current value of Local Interrupt ID Register (LID).
4395 Reads and returns the current value of LID. This function is only available on Itanium processors.
4397 @return The current value of LID.
4408 Reads the current value of External Interrupt Vector Register (IVR).
4410 Reads and returns the current value of IVR. This function is only available on Itanium processors.
4412 @return The current value of IVR.
4423 Reads the current value of Task Priority Register (TPR).
4425 Reads and returns the current value of TPR. This function is only available on Itanium processors.
4427 @return The current value of TPR.
4438 Reads the current value of External Interrupt Request Register #0 (IRR0).
4440 Reads and returns the current value of IRR0. This function is only available on Itanium processors.
4442 @return The current value of IRR0.
4453 Reads the current value of External Interrupt Request Register #1 (IRR1).
4455 Reads and returns the current value of IRR1. This function is only available on Itanium processors.
4457 @return The current value of IRR1.
4468 Reads the current value of External Interrupt Request Register #2 (IRR2).
4470 Reads and returns the current value of IRR2. This function is only available on Itanium processors.
4472 @return The current value of IRR2.
4483 Reads the current value of External Interrupt Request Register #3 (IRR3).
4485 Reads and returns the current value of IRR3. This function is only available on Itanium processors.
4487 @return The current value of IRR3.
4498 Reads the current value of Performance Monitor Vector Register (PMV).
4500 Reads and returns the current value of PMV. This function is only available on Itanium processors.
4502 @return The current value of PMV.
4513 Reads the current value of Corrected Machine Check Vector Register (CMCV).
4515 Reads and returns the current value of CMCV. This function is only available on Itanium processors.
4517 @return The current value of CMCV.
4528 Reads the current value of Local Redirection Register #0 (LRR0).
4530 Reads and returns the current value of LRR0. This function is only available on Itanium processors.
4532 @return The current value of LRR0.
4543 Reads the current value of Local Redirection Register #1 (LRR1).
4545 Reads and returns the current value of LRR1. This function is only available on Itanium processors.
4547 @return The current value of LRR1.
4558 Writes the current value of 64-bit Page Local Interrupt ID Register (LID).
4560 Writes the current value of LID. The 64-bit value written to the LID is returned.
4561 No parameter checking is performed on Value. All bits of Value corresponding to
4562 reserved fields of LID must be 0 or a Reserved Register/Field fault may occur.
4563 The caller must either guarantee that Value is valid, or the caller must set up
4564 fault handlers to catch the faults.
4565 This function is only available on Itanium processors.
4567 @param Value The 64-bit value to write to LID.
4569 @return The 64-bit value written to the LID.
4580 Writes the current value of 64-bit Task Priority Register (TPR).
4582 Writes the current value of TPR. The 64-bit value written to the TPR is returned.
4583 No parameter checking is performed on Value. All bits of Value corresponding to
4584 reserved fields of TPR must be 0 or a Reserved Register/Field fault may occur.
4585 The caller must either guarantee that Value is valid, or the caller must set up
4586 fault handlers to catch the faults.
4587 This function is only available on Itanium processors.
4589 @param Value The 64-bit value to write to TPR.
4591 @return The 64-bit value written to the TPR.
4602 Performs a write operation on End OF External Interrupt Register (EOI).
4604 Writes a value of 0 to the EOI Register. This function is only available on Itanium processors.
4615 Writes the current value of 64-bit Performance Monitor Vector Register (PMV).
4617 Writes the current value of PMV. The 64-bit value written to the PMV is returned.
4618 No parameter checking is performed on Value. All bits of Value corresponding
4619 to reserved fields of PMV must be 0 or a Reserved Register/Field fault may occur.
4620 The caller must either guarantee that Value is valid, or the caller must set up
4621 fault handlers to catch the faults.
4622 This function is only available on Itanium processors.
4624 @param Value The 64-bit value to write to PMV.
4626 @return The 64-bit value written to the PMV.
4637 Writes the current value of 64-bit Corrected Machine Check Vector Register (CMCV).
4639 Writes the current value of CMCV. The 64-bit value written to the CMCV is returned.
4640 No parameter checking is performed on Value. All bits of Value corresponding
4641 to reserved fields of CMCV must be 0 or a Reserved Register/Field fault may occur.
4642 The caller must either guarantee that Value is valid, or the caller must set up
4643 fault handlers to catch the faults.
4644 This function is only available on Itanium processors.
4646 @param Value The 64-bit value to write to CMCV.
4648 @return The 64-bit value written to the CMCV.
4659 Writes the current value of 64-bit Local Redirection Register #0 (LRR0).
4661 Writes the current value of LRR0. The 64-bit value written to the LRR0 is returned.
4662 No parameter checking is performed on Value. All bits of Value corresponding
4663 to reserved fields of LRR0 must be 0 or a Reserved Register/Field fault may occur.
4664 The caller must either guarantee that Value is valid, or the caller must set up
4665 fault handlers to catch the faults.
4666 This function is only available on Itanium processors.
4668 @param Value The 64-bit value to write to LRR0.
4670 @return The 64-bit value written to the LRR0.
4681 Writes the current value of 64-bit Local Redirection Register #1 (LRR1).
4683 Writes the current value of LRR1. The 64-bit value written to the LRR1 is returned.
4684 No parameter checking is performed on Value. All bits of Value corresponding
4685 to reserved fields of LRR1 must be 0 or a Reserved Register/Field fault may occur.
4686 The caller must either guarantee that Value is valid, or the caller must
4687 set up fault handlers to catch the faults.
4688 This function is only available on Itanium processors.
4690 @param Value The 64-bit value to write to LRR1.
4692 @return The 64-bit value written to the LRR1.
4703 Reads the current value of Instruction Breakpoint Register (IBR).
4705 The Instruction Breakpoint Registers are used in pairs. The even numbered
4706 registers contain breakpoint addresses, and the odd numbered registers contain
4707 breakpoint mask conditions. At least four instruction registers pairs are implemented
4708 on all processor models. Implemented registers are contiguous starting with
4709 register 0. No parameter checking is performed on Index, and if the Index value
4710 is beyond the implemented IBR register range, a Reserved Register/Field fault may
4711 occur. The caller must either guarantee that Index is valid, or the caller must
4712 set up fault handlers to catch the faults.
4713 This function is only available on Itanium processors.
4715 @param Index The 8-bit Instruction Breakpoint Register index to read.
4717 @return The current value of Instruction Breakpoint Register specified by Index.
4728 Reads the current value of Data Breakpoint Register (DBR).
4730 The Data Breakpoint Registers are used in pairs. The even numbered registers
4731 contain breakpoint addresses, and odd numbered registers contain breakpoint
4732 mask conditions. At least four data registers pairs are implemented on all processor
4733 models. Implemented registers are contiguous starting with register 0.
4734 No parameter checking is performed on Index. If the Index value is beyond
4735 the implemented DBR register range, a Reserved Register/Field fault may occur.
4736 The caller must either guarantee that Index is valid, or the caller must set up
4737 fault handlers to catch the faults.
4738 This function is only available on Itanium processors.
4740 @param Index The 8-bit Data Breakpoint Register index to read.
4742 @return The current value of Data Breakpoint Register specified by Index.
4753 Reads the current value of Performance Monitor Configuration Register (PMC).
4755 All processor implementations provide at least four performance counters
4756 (PMC/PMD [4]...PMC/PMD [7] pairs), and four performance monitor counter overflow
4757 status registers (PMC [0]... PMC [3]). Processor implementations may provide
4758 additional implementation-dependent PMC and PMD to increase the number of
4759 'generic' performance counters (PMC/PMD pairs). The remainder of PMC and PMD
4760 register set is implementation dependent. No parameter checking is performed
4761 on Index. If the Index value is beyond the implemented PMC register range,
4762 zero value will be returned.
4763 This function is only available on Itanium processors.
4765 @param Index The 8-bit Performance Monitor Configuration Register index to read.
4767 @return The current value of Performance Monitor Configuration Register
4779 Reads the current value of Performance Monitor Data Register (PMD).
4781 All processor implementations provide at least 4 performance counters
4782 (PMC/PMD [4]...PMC/PMD [7] pairs), and 4 performance monitor counter
4783 overflow status registers (PMC [0]... PMC [3]). Processor implementations may
4784 provide additional implementation-dependent PMC and PMD to increase the number
4785 of 'generic' performance counters (PMC/PMD pairs). The remainder of PMC and PMD
4786 register set is implementation dependent. No parameter checking is performed
4787 on Index. If the Index value is beyond the implemented PMD register range,
4788 zero value will be returned.
4789 This function is only available on Itanium processors.
4791 @param Index The 8-bit Performance Monitor Data Register index to read.
4793 @return The current value of Performance Monitor Data Register specified by Index.
4804 Writes the current value of 64-bit Instruction Breakpoint Register (IBR).
4806 Writes current value of Instruction Breakpoint Register specified by Index.
4807 The Instruction Breakpoint Registers are used in pairs. The even numbered
4808 registers contain breakpoint addresses, and odd numbered registers contain
4809 breakpoint mask conditions. At least four instruction registers pairs are implemented
4810 on all processor models. Implemented registers are contiguous starting with
4811 register 0. No parameter checking is performed on Index. If the Index value
4812 is beyond the implemented IBR register range, a Reserved Register/Field fault may
4813 occur. The caller must either guarantee that Index is valid, or the caller must
4814 set up fault handlers to catch the faults.
4815 This function is only available on Itanium processors.
4817 @param Index The 8-bit Instruction Breakpoint Register index to write.
4818 @param Value The 64-bit value to write to IBR.
4820 @return The 64-bit value written to the IBR.
4832 Writes the current value of 64-bit Data Breakpoint Register (DBR).
4834 Writes current value of Data Breakpoint Register specified by Index.
4835 The Data Breakpoint Registers are used in pairs. The even numbered registers
4836 contain breakpoint addresses, and odd numbered registers contain breakpoint
4837 mask conditions. At least four data registers pairs are implemented on all processor
4838 models. Implemented registers are contiguous starting with register 0. No parameter
4839 checking is performed on Index. If the Index value is beyond the implemented
4840 DBR register range, a Reserved Register/Field fault may occur. The caller must
4841 either guarantee that Index is valid, or the caller must set up fault handlers to
4843 This function is only available on Itanium processors.
4845 @param Index The 8-bit Data Breakpoint Register index to write.
4846 @param Value The 64-bit value to write to DBR.
4848 @return The 64-bit value written to the DBR.
4860 Writes the current value of 64-bit Performance Monitor Configuration Register (PMC).
4862 Writes current value of Performance Monitor Configuration Register specified by Index.
4863 All processor implementations provide at least four performance counters
4864 (PMC/PMD [4]...PMC/PMD [7] pairs), and four performance monitor counter overflow status
4865 registers (PMC [0]... PMC [3]). Processor implementations may provide additional
4866 implementation-dependent PMC and PMD to increase the number of 'generic' performance
4867 counters (PMC/PMD pairs). The remainder of PMC and PMD register set is implementation
4868 dependent. No parameter checking is performed on Index. If the Index value is
4869 beyond the implemented PMC register range, the write is ignored.
4870 This function is only available on Itanium processors.
4872 @param Index The 8-bit Performance Monitor Configuration Register index to write.
4873 @param Value The 64-bit value to write to PMC.
4875 @return The 64-bit value written to the PMC.
4887 Writes the current value of 64-bit Performance Monitor Data Register (PMD).
4889 Writes current value of Performance Monitor Data Register specified by Index.
4890 All processor implementations provide at least four performance counters
4891 (PMC/PMD [4]...PMC/PMD [7] pairs), and four performance monitor counter overflow
4892 status registers (PMC [0]... PMC [3]). Processor implementations may provide
4893 additional implementation-dependent PMC and PMD to increase the number of 'generic'
4894 performance counters (PMC/PMD pairs). The remainder of PMC and PMD register set
4895 is implementation dependent. No parameter checking is performed on Index. If the
4896 Index value is beyond the implemented PMD register range, the write is ignored.
4897 This function is only available on Itanium processors.
4899 @param Index The 8-bit Performance Monitor Data Register index to write.
4900 @param Value The 64-bit value to write to PMD.
4902 @return The 64-bit value written to the PMD.
4914 Reads the current value of 64-bit Global Pointer (GP).
4916 Reads and returns the current value of GP.
4917 This function is only available on Itanium processors.
4919 @return The current value of GP.
4930 Write the current value of 64-bit Global Pointer (GP).
4932 Writes the current value of GP. The 64-bit value written to the GP is returned.
4933 No parameter checking is performed on Value.
4934 This function is only available on Itanium processors.
4936 @param Value The 64-bit value to write to GP.
4938 @return The 64-bit value written to the GP.
4949 Reads the current value of 64-bit Stack Pointer (SP).
4951 Reads and returns the current value of SP.
4952 This function is only available on Itanium processors.
4954 @return The current value of SP.
4965 /// Valid Index value for AsmReadControlRegister().
4967 #define IPF_CONTROL_REGISTER_DCR 0
4968 #define IPF_CONTROL_REGISTER_ITM 1
4969 #define IPF_CONTROL_REGISTER_IVA 2
4970 #define IPF_CONTROL_REGISTER_PTA 8
4971 #define IPF_CONTROL_REGISTER_IPSR 16
4972 #define IPF_CONTROL_REGISTER_ISR 17
4973 #define IPF_CONTROL_REGISTER_IIP 19
4974 #define IPF_CONTROL_REGISTER_IFA 20
4975 #define IPF_CONTROL_REGISTER_ITIR 21
4976 #define IPF_CONTROL_REGISTER_IIPA 22
4977 #define IPF_CONTROL_REGISTER_IFS 23
4978 #define IPF_CONTROL_REGISTER_IIM 24
4979 #define IPF_CONTROL_REGISTER_IHA 25
4980 #define IPF_CONTROL_REGISTER_LID 64
4981 #define IPF_CONTROL_REGISTER_IVR 65
4982 #define IPF_CONTROL_REGISTER_TPR 66
4983 #define IPF_CONTROL_REGISTER_EOI 67
4984 #define IPF_CONTROL_REGISTER_IRR0 68
4985 #define IPF_CONTROL_REGISTER_IRR1 69
4986 #define IPF_CONTROL_REGISTER_IRR2 70
4987 #define IPF_CONTROL_REGISTER_IRR3 71
4988 #define IPF_CONTROL_REGISTER_ITV 72
4989 #define IPF_CONTROL_REGISTER_PMV 73
4990 #define IPF_CONTROL_REGISTER_CMCV 74
4991 #define IPF_CONTROL_REGISTER_LRR0 80
4992 #define IPF_CONTROL_REGISTER_LRR1 81
4995 Reads a 64-bit control register.
4997 Reads and returns the control register specified by Index. The valid Index valued
4998 are defined above in "Related Definitions".
4999 If Index is invalid then 0xFFFFFFFFFFFFFFFF is returned. This function is only
5000 available on Itanium processors.
5002 @param Index The index of the control register to read.
5004 @return The control register specified by Index.
5009 AsmReadControlRegister (
5015 /// Valid Index value for AsmReadApplicationRegister().
5017 #define IPF_APPLICATION_REGISTER_K0 0
5018 #define IPF_APPLICATION_REGISTER_K1 1
5019 #define IPF_APPLICATION_REGISTER_K2 2
5020 #define IPF_APPLICATION_REGISTER_K3 3
5021 #define IPF_APPLICATION_REGISTER_K4 4
5022 #define IPF_APPLICATION_REGISTER_K5 5
5023 #define IPF_APPLICATION_REGISTER_K6 6
5024 #define IPF_APPLICATION_REGISTER_K7 7
5025 #define IPF_APPLICATION_REGISTER_RSC 16
5026 #define IPF_APPLICATION_REGISTER_BSP 17
5027 #define IPF_APPLICATION_REGISTER_BSPSTORE 18
5028 #define IPF_APPLICATION_REGISTER_RNAT 19
5029 #define IPF_APPLICATION_REGISTER_FCR 21
5030 #define IPF_APPLICATION_REGISTER_EFLAG 24
5031 #define IPF_APPLICATION_REGISTER_CSD 25
5032 #define IPF_APPLICATION_REGISTER_SSD 26
5033 #define IPF_APPLICATION_REGISTER_CFLG 27
5034 #define IPF_APPLICATION_REGISTER_FSR 28
5035 #define IPF_APPLICATION_REGISTER_FIR 29
5036 #define IPF_APPLICATION_REGISTER_FDR 30
5037 #define IPF_APPLICATION_REGISTER_CCV 32
5038 #define IPF_APPLICATION_REGISTER_UNAT 36
5039 #define IPF_APPLICATION_REGISTER_FPSR 40
5040 #define IPF_APPLICATION_REGISTER_ITC 44
5041 #define IPF_APPLICATION_REGISTER_PFS 64
5042 #define IPF_APPLICATION_REGISTER_LC 65
5043 #define IPF_APPLICATION_REGISTER_EC 66
5046 Reads a 64-bit application register.
5048 Reads and returns the application register specified by Index. The valid Index
5049 valued are defined above in "Related Definitions".
5050 If Index is invalid then 0xFFFFFFFFFFFFFFFF is returned. This function is only
5051 available on Itanium processors.
5053 @param Index The index of the application register to read.
5055 @return The application register specified by Index.
5060 AsmReadApplicationRegister (
5066 Reads the current value of a Machine Specific Register (MSR).
5068 Reads and returns the current value of the Machine Specific Register specified by Index. No
5069 parameter checking is performed on Index, and if the Index value is beyond the implemented MSR
5070 register range, a Reserved Register/Field fault may occur. The caller must either guarantee that
5071 Index is valid, or the caller must set up fault handlers to catch the faults. This function is
5072 only available on Itanium processors.
5074 @param Index The 8-bit Machine Specific Register index to read.
5076 @return The current value of the Machine Specific Register specified by Index.
5087 Writes the current value of a Machine Specific Register (MSR).
5089 Writes Value to the Machine Specific Register specified by Index. Value is returned. No
5090 parameter checking is performed on Index, and if the Index value is beyond the implemented MSR
5091 register range, a Reserved Register/Field fault may occur. The caller must either guarantee that
5092 Index is valid, or the caller must set up fault handlers to catch the faults. This function is
5093 only available on Itanium processors.
5095 @param Index The 8-bit Machine Specific Register index to write.
5096 @param Value The 64-bit value to write to the Machine Specific Register.
5098 @return The 64-bit value to write to the Machine Specific Register.
5110 Determines if the CPU is currently executing in virtual, physical, or mixed mode.
5112 Determines the current execution mode of the CPU.
5113 If the CPU is in virtual mode(PSR.RT=1, PSR.DT=1, PSR.IT=1), then 1 is returned.
5114 If the CPU is in physical mode(PSR.RT=0, PSR.DT=0, PSR.IT=0), then 0 is returned.
5115 If the CPU is not in physical mode or virtual mode, then it is in mixed mode,
5117 This function is only available on Itanium processors.
5119 @retval 1 The CPU is in virtual mode.
5120 @retval 0 The CPU is in physical mode.
5121 @retval -1 The CPU is in mixed mode.
5132 Makes a PAL procedure call.
5134 This is a wrapper function to make a PAL procedure call. Based on the Index
5135 value this API will make static or stacked PAL call. The following table
5136 describes the usage of PAL Procedure Index Assignment. Architected procedures
5137 may be designated as required or optional. If a PAL procedure is specified
5138 as optional, a unique return code of 0xFFFFFFFFFFFFFFFF is returned in the
5139 Status field of the PAL_CALL_RETURN structure.
5140 This indicates that the procedure is not present in this PAL implementation.
5141 It is the caller's responsibility to check for this return code after calling
5142 any optional PAL procedure.
5143 No parameter checking is performed on the 5 input parameters, but there are
5144 some common rules that the caller should follow when making a PAL call. Any
5145 address passed to PAL as buffers for return parameters must be 8-byte aligned.
5146 Unaligned addresses may cause undefined results. For those parameters defined
5147 as reserved or some fields defined as reserved must be zero filled or the invalid
5148 argument return value may be returned or undefined result may occur during the
5149 execution of the procedure. If the PalEntryPoint does not point to a valid
5150 PAL entry point then the system behavior is undefined. This function is only
5151 available on Itanium processors.
5153 @param PalEntryPoint The PAL procedure calls entry point.
5154 @param Index The PAL procedure Index number.
5155 @param Arg2 The 2nd parameter for PAL procedure calls.
5156 @param Arg3 The 3rd parameter for PAL procedure calls.
5157 @param Arg4 The 4th parameter for PAL procedure calls.
5159 @return structure returned from the PAL Call procedure, including the status and return value.
5165 IN UINT64 PalEntryPoint
,
5173 #if defined (MDE_CPU_IA32) || defined (MDE_CPU_X64)
5175 /// IA32 and x64 Specific Functions.
5176 /// Byte packed structure for 16-bit Real Mode EFLAGS.
5180 UINT32 CF
:1; ///< Carry Flag.
5181 UINT32 Reserved_0
:1; ///< Reserved.
5182 UINT32 PF
:1; ///< Parity Flag.
5183 UINT32 Reserved_1
:1; ///< Reserved.
5184 UINT32 AF
:1; ///< Auxiliary Carry Flag.
5185 UINT32 Reserved_2
:1; ///< Reserved.
5186 UINT32 ZF
:1; ///< Zero Flag.
5187 UINT32 SF
:1; ///< Sign Flag.
5188 UINT32 TF
:1; ///< Trap Flag.
5189 UINT32 IF
:1; ///< Interrupt Enable Flag.
5190 UINT32 DF
:1; ///< Direction Flag.
5191 UINT32 OF
:1; ///< Overflow Flag.
5192 UINT32 IOPL
:2; ///< I/O Privilege Level.
5193 UINT32 NT
:1; ///< Nested Task.
5194 UINT32 Reserved_3
:1; ///< Reserved.
5200 /// Byte packed structure for EFLAGS/RFLAGS.
5201 /// 32-bits on IA-32.
5202 /// 64-bits on x64. The upper 32-bits on x64 are reserved.
5206 UINT32 CF
:1; ///< Carry Flag.
5207 UINT32 Reserved_0
:1; ///< Reserved.
5208 UINT32 PF
:1; ///< Parity Flag.
5209 UINT32 Reserved_1
:1; ///< Reserved.
5210 UINT32 AF
:1; ///< Auxiliary Carry Flag.
5211 UINT32 Reserved_2
:1; ///< Reserved.
5212 UINT32 ZF
:1; ///< Zero Flag.
5213 UINT32 SF
:1; ///< Sign Flag.
5214 UINT32 TF
:1; ///< Trap Flag.
5215 UINT32 IF
:1; ///< Interrupt Enable Flag.
5216 UINT32 DF
:1; ///< Direction Flag.
5217 UINT32 OF
:1; ///< Overflow Flag.
5218 UINT32 IOPL
:2; ///< I/O Privilege Level.
5219 UINT32 NT
:1; ///< Nested Task.
5220 UINT32 Reserved_3
:1; ///< Reserved.
5221 UINT32 RF
:1; ///< Resume Flag.
5222 UINT32 VM
:1; ///< Virtual 8086 Mode.
5223 UINT32 AC
:1; ///< Alignment Check.
5224 UINT32 VIF
:1; ///< Virtual Interrupt Flag.
5225 UINT32 VIP
:1; ///< Virtual Interrupt Pending.
5226 UINT32 ID
:1; ///< ID Flag.
5227 UINT32 Reserved_4
:10; ///< Reserved.
5233 /// Byte packed structure for Control Register 0 (CR0).
5234 /// 32-bits on IA-32.
5235 /// 64-bits on x64. The upper 32-bits on x64 are reserved.
5239 UINT32 PE
:1; ///< Protection Enable.
5240 UINT32 MP
:1; ///< Monitor Coprocessor.
5241 UINT32 EM
:1; ///< Emulation.
5242 UINT32 TS
:1; ///< Task Switched.
5243 UINT32 ET
:1; ///< Extension Type.
5244 UINT32 NE
:1; ///< Numeric Error.
5245 UINT32 Reserved_0
:10; ///< Reserved.
5246 UINT32 WP
:1; ///< Write Protect.
5247 UINT32 Reserved_1
:1; ///< Reserved.
5248 UINT32 AM
:1; ///< Alignment Mask.
5249 UINT32 Reserved_2
:10; ///< Reserved.
5250 UINT32 NW
:1; ///< Mot Write-through.
5251 UINT32 CD
:1; ///< Cache Disable.
5252 UINT32 PG
:1; ///< Paging.
5258 /// Byte packed structure for Control Register 4 (CR4).
5259 /// 32-bits on IA-32.
5260 /// 64-bits on x64. The upper 32-bits on x64 are reserved.
5264 UINT32 VME
:1; ///< Virtual-8086 Mode Extensions.
5265 UINT32 PVI
:1; ///< Protected-Mode Virtual Interrupts.
5266 UINT32 TSD
:1; ///< Time Stamp Disable.
5267 UINT32 DE
:1; ///< Debugging Extensions.
5268 UINT32 PSE
:1; ///< Page Size Extensions.
5269 UINT32 PAE
:1; ///< Physical Address Extension.
5270 UINT32 MCE
:1; ///< Machine Check Enable.
5271 UINT32 PGE
:1; ///< Page Global Enable.
5272 UINT32 PCE
:1; ///< Performance Monitoring Counter
5274 UINT32 OSFXSR
:1; ///< Operating System Support for
5275 ///< FXSAVE and FXRSTOR instructions
5276 UINT32 OSXMMEXCPT
:1; ///< Operating System Support for
5277 ///< Unmasked SIMD Floating Point
5279 UINT32 Reserved_0
:2; ///< Reserved.
5280 UINT32 VMXE
:1; ///< VMX Enable
5281 UINT32 Reserved_1
:18; ///< Reserved.
5287 /// Byte packed structure for a segment descriptor in a GDT/LDT.
5306 } IA32_SEGMENT_DESCRIPTOR
;
5309 /// Byte packed structure for an IDTR, GDTR, LDTR descriptor.
5318 #define IA32_IDT_GATE_TYPE_TASK 0x85
5319 #define IA32_IDT_GATE_TYPE_INTERRUPT_16 0x86
5320 #define IA32_IDT_GATE_TYPE_TRAP_16 0x87
5321 #define IA32_IDT_GATE_TYPE_INTERRUPT_32 0x8E
5322 #define IA32_IDT_GATE_TYPE_TRAP_32 0x8F
5325 #if defined (MDE_CPU_IA32)
5327 /// Byte packed structure for an IA-32 Interrupt Gate Descriptor.
5331 UINT32 OffsetLow
:16; ///< Offset bits 15..0.
5332 UINT32 Selector
:16; ///< Selector.
5333 UINT32 Reserved_0
:8; ///< Reserved.
5334 UINT32 GateType
:8; ///< Gate Type. See #defines above.
5335 UINT32 OffsetHigh
:16; ///< Offset bits 31..16.
5338 } IA32_IDT_GATE_DESCRIPTOR
;
5342 #if defined (MDE_CPU_X64)
5344 /// Byte packed structure for an x64 Interrupt Gate Descriptor.
5348 UINT32 OffsetLow
:16; ///< Offset bits 15..0.
5349 UINT32 Selector
:16; ///< Selector.
5350 UINT32 Reserved_0
:8; ///< Reserved.
5351 UINT32 GateType
:8; ///< Gate Type. See #defines above.
5352 UINT32 OffsetHigh
:16; ///< Offset bits 31..16.
5353 UINT32 OffsetUpper
:32; ///< Offset bits 63..32.
5354 UINT32 Reserved_1
:32; ///< Reserved.
5360 } IA32_IDT_GATE_DESCRIPTOR
;
5365 /// Byte packed structure for an FP/SSE/SSE2 context.
5372 /// Structures for the 16-bit real mode thunks.
5425 IA32_EFLAGS32 EFLAGS
;
5435 } IA32_REGISTER_SET
;
5438 /// Byte packed structure for an 16-bit real mode thunks.
5441 IA32_REGISTER_SET
*RealModeState
;
5442 VOID
*RealModeBuffer
;
5443 UINT32 RealModeBufferSize
;
5444 UINT32 ThunkAttributes
;
5447 #define THUNK_ATTRIBUTE_BIG_REAL_MODE 0x00000001
5448 #define THUNK_ATTRIBUTE_DISABLE_A20_MASK_INT_15 0x00000002
5449 #define THUNK_ATTRIBUTE_DISABLE_A20_MASK_KBD_CTRL 0x00000004
5452 Retrieves CPUID information.
5454 Executes the CPUID instruction with EAX set to the value specified by Index.
5455 This function always returns Index.
5456 If Eax is not NULL, then the value of EAX after CPUID is returned in Eax.
5457 If Ebx is not NULL, then the value of EBX after CPUID is returned in Ebx.
5458 If Ecx is not NULL, then the value of ECX after CPUID is returned in Ecx.
5459 If Edx is not NULL, then the value of EDX after CPUID is returned in Edx.
5460 This function is only available on IA-32 and x64.
5462 @param Index The 32-bit value to load into EAX prior to invoking the CPUID
5464 @param Eax The pointer to the 32-bit EAX value returned by the CPUID
5465 instruction. This is an optional parameter that may be NULL.
5466 @param Ebx The pointer to the 32-bit EBX value returned by the CPUID
5467 instruction. This is an optional parameter that may be NULL.
5468 @param Ecx The pointer to the 32-bit ECX value returned by the CPUID
5469 instruction. This is an optional parameter that may be NULL.
5470 @param Edx The pointer to the 32-bit EDX value returned by the CPUID
5471 instruction. This is an optional parameter that may be NULL.
5480 OUT UINT32
*Eax
, OPTIONAL
5481 OUT UINT32
*Ebx
, OPTIONAL
5482 OUT UINT32
*Ecx
, OPTIONAL
5483 OUT UINT32
*Edx OPTIONAL
5488 Retrieves CPUID information using an extended leaf identifier.
5490 Executes the CPUID instruction with EAX set to the value specified by Index
5491 and ECX set to the value specified by SubIndex. This function always returns
5492 Index. This function is only available on IA-32 and x64.
5494 If Eax is not NULL, then the value of EAX after CPUID is returned in Eax.
5495 If Ebx is not NULL, then the value of EBX after CPUID is returned in Ebx.
5496 If Ecx is not NULL, then the value of ECX after CPUID is returned in Ecx.
5497 If Edx is not NULL, then the value of EDX after CPUID is returned in Edx.
5499 @param Index The 32-bit value to load into EAX prior to invoking the
5501 @param SubIndex The 32-bit value to load into ECX prior to invoking the
5503 @param Eax The pointer to the 32-bit EAX value returned by the CPUID
5504 instruction. This is an optional parameter that may be
5506 @param Ebx The pointer to the 32-bit EBX value returned by the CPUID
5507 instruction. This is an optional parameter that may be
5509 @param Ecx The pointer to the 32-bit ECX value returned by the CPUID
5510 instruction. This is an optional parameter that may be
5512 @param Edx The pointer to the 32-bit EDX value returned by the CPUID
5513 instruction. This is an optional parameter that may be
5524 OUT UINT32
*Eax
, OPTIONAL
5525 OUT UINT32
*Ebx
, OPTIONAL
5526 OUT UINT32
*Ecx
, OPTIONAL
5527 OUT UINT32
*Edx OPTIONAL
5532 Set CD bit and clear NW bit of CR0 followed by a WBINVD.
5534 Disables the caches by setting the CD bit of CR0 to 1, clearing the NW bit of CR0 to 0,
5535 and executing a WBINVD instruction. This function is only available on IA-32 and x64.
5546 Perform a WBINVD and clear both the CD and NW bits of CR0.
5548 Enables the caches by executing a WBINVD instruction and then clear both the CD and NW
5549 bits of CR0 to 0. This function is only available on IA-32 and x64.
5560 Returns the lower 32-bits of a Machine Specific Register(MSR).
5562 Reads and returns the lower 32-bits of the MSR specified by Index.
5563 No parameter checking is performed on Index, and some Index values may cause
5564 CPU exceptions. The caller must either guarantee that Index is valid, or the
5565 caller must set up exception handlers to catch the exceptions. This function
5566 is only available on IA-32 and x64.
5568 @param Index The 32-bit MSR index to read.
5570 @return The lower 32 bits of the MSR identified by Index.
5581 Writes a 32-bit value to a Machine Specific Register(MSR), and returns the value.
5582 The upper 32-bits of the MSR are set to zero.
5584 Writes the 32-bit value specified by Value to the MSR specified by Index. The
5585 upper 32-bits of the MSR write are set to zero. The 32-bit value written to
5586 the MSR is returned. No parameter checking is performed on Index or Value,
5587 and some of these may cause CPU exceptions. The caller must either guarantee
5588 that Index and Value are valid, or the caller must establish proper exception
5589 handlers. This function is only available on IA-32 and x64.
5591 @param Index The 32-bit MSR index to write.
5592 @param Value The 32-bit value to write to the MSR.
5606 Reads a 64-bit MSR, performs a bitwise OR on the lower 32-bits, and
5607 writes the result back to the 64-bit MSR.
5609 Reads the 64-bit MSR specified by Index, performs a bitwise OR
5610 between the lower 32-bits of the read result and the value specified by
5611 OrData, and writes the result to the 64-bit MSR specified by Index. The lower
5612 32-bits of the value written to the MSR is returned. No parameter checking is
5613 performed on Index or OrData, and some of these may cause CPU exceptions. The
5614 caller must either guarantee that Index and OrData are valid, or the caller
5615 must establish proper exception handlers. This function is only available on
5618 @param Index The 32-bit MSR index to write.
5619 @param OrData The value to OR with the read value from the MSR.
5621 @return The lower 32-bit value written to the MSR.
5633 Reads a 64-bit MSR, performs a bitwise AND on the lower 32-bits, and writes
5634 the result back to the 64-bit MSR.
5636 Reads the 64-bit MSR specified by Index, performs a bitwise AND between the
5637 lower 32-bits of the read result and the value specified by AndData, and
5638 writes the result to the 64-bit MSR specified by Index. The lower 32-bits of
5639 the value written to the MSR is returned. No parameter checking is performed
5640 on Index or AndData, and some of these may cause CPU exceptions. The caller
5641 must either guarantee that Index and AndData are valid, or the caller must
5642 establish proper exception handlers. This function is only available on IA-32
5645 @param Index The 32-bit MSR index to write.
5646 @param AndData The value to AND with the read value from the MSR.
5648 @return The lower 32-bit value written to the MSR.
5660 Reads a 64-bit MSR, performs a bitwise AND followed by a bitwise OR
5661 on the lower 32-bits, and writes the result back to the 64-bit MSR.
5663 Reads the 64-bit MSR specified by Index, performs a bitwise AND between the
5664 lower 32-bits of the read result and the value specified by AndData
5665 preserving the upper 32-bits, performs a bitwise OR between the
5666 result of the AND operation and the value specified by OrData, and writes the
5667 result to the 64-bit MSR specified by Address. The lower 32-bits of the value
5668 written to the MSR is returned. No parameter checking is performed on Index,
5669 AndData, or OrData, and some of these may cause CPU exceptions. The caller
5670 must either guarantee that Index, AndData, and OrData are valid, or the
5671 caller must establish proper exception handlers. This function is only
5672 available on IA-32 and x64.
5674 @param Index The 32-bit MSR index to write.
5675 @param AndData The value to AND with the read value from the MSR.
5676 @param OrData The value to OR with the result of the AND operation.
5678 @return The lower 32-bit value written to the MSR.
5691 Reads a bit field of an MSR.
5693 Reads the bit field in the lower 32-bits of a 64-bit MSR. The bit field is
5694 specified by the StartBit and the EndBit. The value of the bit field is
5695 returned. The caller must either guarantee that Index is valid, or the caller
5696 must set up exception handlers to catch the exceptions. This function is only
5697 available on IA-32 and x64.
5699 If StartBit is greater than 31, then ASSERT().
5700 If EndBit is greater than 31, then ASSERT().
5701 If EndBit is less than StartBit, then ASSERT().
5703 @param Index The 32-bit MSR index to read.
5704 @param StartBit The ordinal of the least significant bit in the bit field.
5706 @param EndBit The ordinal of the most significant bit in the bit field.
5709 @return The bit field read from the MSR.
5714 AsmMsrBitFieldRead32 (
5722 Writes a bit field to an MSR.
5724 Writes Value to a bit field in the lower 32-bits of a 64-bit MSR. The bit
5725 field is specified by the StartBit and the EndBit. All other bits in the
5726 destination MSR are preserved. The lower 32-bits of the MSR written is
5727 returned. The caller must either guarantee that Index and the data written
5728 is valid, or the caller must set up exception handlers to catch the exceptions.
5729 This function is only available on IA-32 and x64.
5731 If StartBit is greater than 31, then ASSERT().
5732 If EndBit is greater than 31, then ASSERT().
5733 If EndBit is less than StartBit, then ASSERT().
5734 If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
5736 @param Index The 32-bit MSR index to write.
5737 @param StartBit The ordinal of the least significant bit in the bit field.
5739 @param EndBit The ordinal of the most significant bit in the bit field.
5741 @param Value New value of the bit field.
5743 @return The lower 32-bit of the value written to the MSR.
5748 AsmMsrBitFieldWrite32 (
5757 Reads a bit field in a 64-bit MSR, performs a bitwise OR, and writes the
5758 result back to the bit field in the 64-bit MSR.
5760 Reads the 64-bit MSR specified by Index, performs a bitwise OR
5761 between the read result and the value specified by OrData, and writes the
5762 result to the 64-bit MSR specified by Index. The lower 32-bits of the value
5763 written to the MSR are returned. Extra left bits in OrData are stripped. The
5764 caller must either guarantee that Index and the data written is valid, or
5765 the caller must set up exception handlers to catch the exceptions. This
5766 function is only available on IA-32 and x64.
5768 If StartBit is greater than 31, then ASSERT().
5769 If EndBit is greater than 31, then ASSERT().
5770 If EndBit is less than StartBit, then ASSERT().
5771 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
5773 @param Index The 32-bit MSR index to write.
5774 @param StartBit The ordinal of the least significant bit in the bit field.
5776 @param EndBit The ordinal of the most significant bit in the bit field.
5778 @param OrData The value to OR with the read value from the MSR.
5780 @return The lower 32-bit of the value written to the MSR.
5785 AsmMsrBitFieldOr32 (
5794 Reads a bit field in a 64-bit MSR, performs a bitwise AND, and writes the
5795 result back to the bit field in the 64-bit MSR.
5797 Reads the 64-bit MSR specified by Index, performs a bitwise AND between the
5798 read result and the value specified by AndData, and writes the result to the
5799 64-bit MSR specified by Index. The lower 32-bits of the value written to the
5800 MSR are returned. Extra left bits in AndData are stripped. The caller must
5801 either guarantee that Index and the data written is valid, or the caller must
5802 set up exception handlers to catch the exceptions. This function is only
5803 available on IA-32 and x64.
5805 If StartBit is greater than 31, then ASSERT().
5806 If EndBit is greater than 31, then ASSERT().
5807 If EndBit is less than StartBit, then ASSERT().
5808 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
5810 @param Index The 32-bit MSR index to write.
5811 @param StartBit The ordinal of the least significant bit in the bit field.
5813 @param EndBit The ordinal of the most significant bit in the bit field.
5815 @param AndData The value to AND with the read value from the MSR.
5817 @return The lower 32-bit of the value written to the MSR.
5822 AsmMsrBitFieldAnd32 (
5831 Reads a bit field in a 64-bit MSR, performs a bitwise AND followed by a
5832 bitwise OR, and writes the result back to the bit field in the
5835 Reads the 64-bit MSR specified by Index, performs a bitwise AND followed by a
5836 bitwise OR between the read result and the value specified by
5837 AndData, and writes the result to the 64-bit MSR specified by Index. The
5838 lower 32-bits of the value written to the MSR are returned. Extra left bits
5839 in both AndData and OrData are stripped. The caller must either guarantee
5840 that Index and the data written is valid, or the caller must set up exception
5841 handlers to catch the exceptions. This function is only available on IA-32
5844 If StartBit is greater than 31, then ASSERT().
5845 If EndBit is greater than 31, then ASSERT().
5846 If EndBit is less than StartBit, then ASSERT().
5847 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
5848 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
5850 @param Index The 32-bit MSR index to write.
5851 @param StartBit The ordinal of the least significant bit in the bit field.
5853 @param EndBit The ordinal of the most significant bit in the bit field.
5855 @param AndData The value to AND with the read value from the MSR.
5856 @param OrData The value to OR with the result of the AND operation.
5858 @return The lower 32-bit of the value written to the MSR.
5863 AsmMsrBitFieldAndThenOr32 (
5873 Returns a 64-bit Machine Specific Register(MSR).
5875 Reads and returns the 64-bit MSR specified by Index. No parameter checking is
5876 performed on Index, and some Index values may cause CPU exceptions. The
5877 caller must either guarantee that Index is valid, or the caller must set up
5878 exception handlers to catch the exceptions. This function is only available
5881 @param Index The 32-bit MSR index to read.
5883 @return The value of the MSR identified by Index.
5894 Writes a 64-bit value to a Machine Specific Register(MSR), and returns the
5897 Writes the 64-bit value specified by Value to the MSR specified by Index. The
5898 64-bit value written to the MSR is returned. No parameter checking is
5899 performed on Index or Value, and some of these may cause CPU exceptions. The
5900 caller must either guarantee that Index and Value are valid, or the caller
5901 must establish proper exception handlers. This function is only available on
5904 @param Index The 32-bit MSR index to write.
5905 @param Value The 64-bit value to write to the MSR.
5919 Reads a 64-bit MSR, performs a bitwise OR, and writes the result
5920 back to the 64-bit MSR.
5922 Reads the 64-bit MSR specified by Index, performs a bitwise OR
5923 between the read result and the value specified by OrData, and writes the
5924 result to the 64-bit MSR specified by Index. The value written to the MSR is
5925 returned. No parameter checking is performed on Index or OrData, and some of
5926 these may cause CPU exceptions. The caller must either guarantee that Index
5927 and OrData are valid, or the caller must establish proper exception handlers.
5928 This function is only available on IA-32 and x64.
5930 @param Index The 32-bit MSR index to write.
5931 @param OrData The value to OR with the read value from the MSR.
5933 @return The value written back to the MSR.
5945 Reads a 64-bit MSR, performs a bitwise AND, and writes the result back to the
5948 Reads the 64-bit MSR specified by Index, performs a bitwise AND between the
5949 read result and the value specified by OrData, and writes the result to the
5950 64-bit MSR specified by Index. The value written to the MSR is returned. No
5951 parameter checking is performed on Index or OrData, and some of these may
5952 cause CPU exceptions. The caller must either guarantee that Index and OrData
5953 are valid, or the caller must establish proper exception handlers. This
5954 function is only available on IA-32 and x64.
5956 @param Index The 32-bit MSR index to write.
5957 @param AndData The value to AND with the read value from the MSR.
5959 @return The value written back to the MSR.
5971 Reads a 64-bit MSR, performs a bitwise AND followed by a bitwise
5972 OR, and writes the result back to the 64-bit MSR.
5974 Reads the 64-bit MSR specified by Index, performs a bitwise AND between read
5975 result and the value specified by AndData, performs a bitwise OR
5976 between the result of the AND operation and the value specified by OrData,
5977 and writes the result to the 64-bit MSR specified by Index. The value written
5978 to the MSR is returned. No parameter checking is performed on Index, AndData,
5979 or OrData, and some of these may cause CPU exceptions. The caller must either
5980 guarantee that Index, AndData, and OrData are valid, or the caller must
5981 establish proper exception handlers. This function is only available on IA-32
5984 @param Index The 32-bit MSR index to write.
5985 @param AndData The value to AND with the read value from the MSR.
5986 @param OrData The value to OR with the result of the AND operation.
5988 @return The value written back to the MSR.
6001 Reads a bit field of an MSR.
6003 Reads the bit field in the 64-bit MSR. The bit field is specified by the
6004 StartBit and the EndBit. The value of the bit field is returned. The caller
6005 must either guarantee that Index is valid, or the caller must set up
6006 exception handlers to catch the exceptions. This function is only available
6009 If StartBit is greater than 63, then ASSERT().
6010 If EndBit is greater than 63, then ASSERT().
6011 If EndBit is less than StartBit, then ASSERT().
6013 @param Index The 32-bit MSR index to read.
6014 @param StartBit The ordinal of the least significant bit in the bit field.
6016 @param EndBit The ordinal of the most significant bit in the bit field.
6019 @return The value read from the MSR.
6024 AsmMsrBitFieldRead64 (
6032 Writes a bit field to an MSR.
6034 Writes Value to a bit field in a 64-bit MSR. The bit field is specified by
6035 the StartBit and the EndBit. All other bits in the destination MSR are
6036 preserved. The MSR written is returned. The caller must either guarantee
6037 that Index and the data written is valid, or the caller must set up exception
6038 handlers to catch the exceptions. This function is only available on IA-32 and x64.
6040 If StartBit is greater than 63, then ASSERT().
6041 If EndBit is greater than 63, then ASSERT().
6042 If EndBit is less than StartBit, then ASSERT().
6043 If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
6045 @param Index The 32-bit MSR index to write.
6046 @param StartBit The ordinal of the least significant bit in the bit field.
6048 @param EndBit The ordinal of the most significant bit in the bit field.
6050 @param Value New value of the bit field.
6052 @return The value written back to the MSR.
6057 AsmMsrBitFieldWrite64 (
6066 Reads a bit field in a 64-bit MSR, performs a bitwise OR, and
6067 writes the result back to the bit field in the 64-bit MSR.
6069 Reads the 64-bit MSR specified by Index, performs a bitwise OR
6070 between the read result and the value specified by OrData, and writes the
6071 result to the 64-bit MSR specified by Index. The value written to the MSR is
6072 returned. Extra left bits in OrData are stripped. The caller must either
6073 guarantee that Index and the data written is valid, or the caller must set up
6074 exception handlers to catch the exceptions. This function is only available
6077 If StartBit is greater than 63, then ASSERT().
6078 If EndBit is greater than 63, then ASSERT().
6079 If EndBit is less than StartBit, then ASSERT().
6080 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
6082 @param Index The 32-bit MSR index to write.
6083 @param StartBit The ordinal of the least significant bit in the bit field.
6085 @param EndBit The ordinal of the most significant bit in the bit field.
6087 @param OrData The value to OR with the read value from the bit field.
6089 @return The value written back to the MSR.
6094 AsmMsrBitFieldOr64 (
6103 Reads a bit field in a 64-bit MSR, performs a bitwise AND, and writes the
6104 result back to the bit field in the 64-bit MSR.
6106 Reads the 64-bit MSR specified by Index, performs a bitwise AND between the
6107 read result and the value specified by AndData, and writes the result to the
6108 64-bit MSR specified by Index. The value written to the MSR is returned.
6109 Extra left bits in AndData are stripped. The caller must either guarantee
6110 that Index and the data written is valid, or the caller must set up exception
6111 handlers to catch the exceptions. This function is only available on IA-32
6114 If StartBit is greater than 63, then ASSERT().
6115 If EndBit is greater than 63, then ASSERT().
6116 If EndBit is less than StartBit, then ASSERT().
6117 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
6119 @param Index The 32-bit MSR index to write.
6120 @param StartBit The ordinal of the least significant bit in the bit field.
6122 @param EndBit The ordinal of the most significant bit in the bit field.
6124 @param AndData The value to AND with the read value from the bit field.
6126 @return The value written back to the MSR.
6131 AsmMsrBitFieldAnd64 (
6140 Reads a bit field in a 64-bit MSR, performs a bitwise AND followed by a
6141 bitwise OR, and writes the result back to the bit field in the
6144 Reads the 64-bit MSR specified by Index, performs a bitwise AND followed by
6145 a bitwise OR between the read result and the value specified by
6146 AndData, and writes the result to the 64-bit MSR specified by Index. The
6147 value written to the MSR is returned. Extra left bits in both AndData and
6148 OrData are stripped. The caller must either guarantee that Index and the data
6149 written is valid, or the caller must set up exception handlers to catch the
6150 exceptions. This function is only available on IA-32 and x64.
6152 If StartBit is greater than 63, then ASSERT().
6153 If EndBit is greater than 63, then ASSERT().
6154 If EndBit is less than StartBit, then ASSERT().
6155 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
6156 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
6158 @param Index The 32-bit MSR index to write.
6159 @param StartBit The ordinal of the least significant bit in the bit field.
6161 @param EndBit The ordinal of the most significant bit in the bit field.
6163 @param AndData The value to AND with the read value from the bit field.
6164 @param OrData The value to OR with the result of the AND operation.
6166 @return The value written back to the MSR.
6171 AsmMsrBitFieldAndThenOr64 (
6181 Reads the current value of the EFLAGS register.
6183 Reads and returns the current value of the EFLAGS register. This function is
6184 only available on IA-32 and x64. This returns a 32-bit value on IA-32 and a
6185 64-bit value on x64.
6187 @return EFLAGS on IA-32 or RFLAGS on x64.
6198 Reads the current value of the Control Register 0 (CR0).
6200 Reads and returns the current value of CR0. This function is only available
6201 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
6204 @return The value of the Control Register 0 (CR0).
6215 Reads the current value of the Control Register 2 (CR2).
6217 Reads and returns the current value of CR2. This function is only available
6218 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
6221 @return The value of the Control Register 2 (CR2).
6232 Reads the current value of the Control Register 3 (CR3).
6234 Reads and returns the current value of CR3. This function is only available
6235 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
6238 @return The value of the Control Register 3 (CR3).
6249 Reads the current value of the Control Register 4 (CR4).
6251 Reads and returns the current value of CR4. This function is only available
6252 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
6255 @return The value of the Control Register 4 (CR4).
6266 Writes a value to Control Register 0 (CR0).
6268 Writes and returns a new value to CR0. This function is only available on
6269 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
6271 @param Cr0 The value to write to CR0.
6273 @return The value written to CR0.
6284 Writes a value to Control Register 2 (CR2).
6286 Writes and returns a new value to CR2. This function is only available on
6287 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
6289 @param Cr2 The value to write to CR2.
6291 @return The value written to CR2.
6302 Writes a value to Control Register 3 (CR3).
6304 Writes and returns a new value to CR3. This function is only available on
6305 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
6307 @param Cr3 The value to write to CR3.
6309 @return The value written to CR3.
6320 Writes a value to Control Register 4 (CR4).
6322 Writes and returns a new value to CR4. This function is only available on
6323 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
6325 @param Cr4 The value to write to CR4.
6327 @return The value written to CR4.
6338 Reads the current value of Debug Register 0 (DR0).
6340 Reads and returns the current value of DR0. This function is only available
6341 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
6344 @return The value of Debug Register 0 (DR0).
6355 Reads the current value of Debug Register 1 (DR1).
6357 Reads and returns the current value of DR1. This function is only available
6358 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
6361 @return The value of Debug Register 1 (DR1).
6372 Reads the current value of Debug Register 2 (DR2).
6374 Reads and returns the current value of DR2. This function is only available
6375 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
6378 @return The value of Debug Register 2 (DR2).
6389 Reads the current value of Debug Register 3 (DR3).
6391 Reads and returns the current value of DR3. This function is only available
6392 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
6395 @return The value of Debug Register 3 (DR3).
6406 Reads the current value of Debug Register 4 (DR4).
6408 Reads and returns the current value of DR4. This function is only available
6409 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
6412 @return The value of Debug Register 4 (DR4).
6423 Reads the current value of Debug Register 5 (DR5).
6425 Reads and returns the current value of DR5. This function is only available
6426 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
6429 @return The value of Debug Register 5 (DR5).
6440 Reads the current value of Debug Register 6 (DR6).
6442 Reads and returns the current value of DR6. This function is only available
6443 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
6446 @return The value of Debug Register 6 (DR6).
6457 Reads the current value of Debug Register 7 (DR7).
6459 Reads and returns the current value of DR7. This function is only available
6460 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
6463 @return The value of Debug Register 7 (DR7).
6474 Writes a value to Debug Register 0 (DR0).
6476 Writes and returns a new value to DR0. This function is only available on
6477 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
6479 @param Dr0 The value to write to Dr0.
6481 @return The value written to Debug Register 0 (DR0).
6492 Writes a value to Debug Register 1 (DR1).
6494 Writes and returns a new value to DR1. This function is only available on
6495 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
6497 @param Dr1 The value to write to Dr1.
6499 @return The value written to Debug Register 1 (DR1).
6510 Writes a value to Debug Register 2 (DR2).
6512 Writes and returns a new value to DR2. This function is only available on
6513 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
6515 @param Dr2 The value to write to Dr2.
6517 @return The value written to Debug Register 2 (DR2).
6528 Writes a value to Debug Register 3 (DR3).
6530 Writes and returns a new value to DR3. This function is only available on
6531 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
6533 @param Dr3 The value to write to Dr3.
6535 @return The value written to Debug Register 3 (DR3).
6546 Writes a value to Debug Register 4 (DR4).
6548 Writes and returns a new value to DR4. This function is only available on
6549 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
6551 @param Dr4 The value to write to Dr4.
6553 @return The value written to Debug Register 4 (DR4).
6564 Writes a value to Debug Register 5 (DR5).
6566 Writes and returns a new value to DR5. This function is only available on
6567 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
6569 @param Dr5 The value to write to Dr5.
6571 @return The value written to Debug Register 5 (DR5).
6582 Writes a value to Debug Register 6 (DR6).
6584 Writes and returns a new value to DR6. This function is only available on
6585 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
6587 @param Dr6 The value to write to Dr6.
6589 @return The value written to Debug Register 6 (DR6).
6600 Writes a value to Debug Register 7 (DR7).
6602 Writes and returns a new value to DR7. This function is only available on
6603 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
6605 @param Dr7 The value to write to Dr7.
6607 @return The value written to Debug Register 7 (DR7).
6618 Reads the current value of Code Segment Register (CS).
6620 Reads and returns the current value of CS. This function is only available on
6623 @return The current value of CS.
6634 Reads the current value of Data Segment Register (DS).
6636 Reads and returns the current value of DS. This function is only available on
6639 @return The current value of DS.
6650 Reads the current value of Extra Segment Register (ES).
6652 Reads and returns the current value of ES. This function is only available on
6655 @return The current value of ES.
6666 Reads the current value of FS Data Segment Register (FS).
6668 Reads and returns the current value of FS. This function is only available on
6671 @return The current value of FS.
6682 Reads the current value of GS Data Segment Register (GS).
6684 Reads and returns the current value of GS. This function is only available on
6687 @return The current value of GS.
6698 Reads the current value of Stack Segment Register (SS).
6700 Reads and returns the current value of SS. This function is only available on
6703 @return The current value of SS.
6714 Reads the current value of Task Register (TR).
6716 Reads and returns the current value of TR. This function is only available on
6719 @return The current value of TR.
6730 Reads the current Global Descriptor Table Register(GDTR) descriptor.
6732 Reads and returns the current GDTR descriptor and returns it in Gdtr. This
6733 function is only available on IA-32 and x64.
6735 If Gdtr is NULL, then ASSERT().
6737 @param Gdtr The pointer to a GDTR descriptor.
6743 OUT IA32_DESCRIPTOR
*Gdtr
6748 Writes the current Global Descriptor Table Register (GDTR) descriptor.
6750 Writes and the current GDTR descriptor specified by Gdtr. This function is
6751 only available on IA-32 and x64.
6753 If Gdtr is NULL, then ASSERT().
6755 @param Gdtr The pointer to a GDTR descriptor.
6761 IN CONST IA32_DESCRIPTOR
*Gdtr
6766 Reads the current Interrupt Descriptor Table Register(IDTR) descriptor.
6768 Reads and returns the current IDTR descriptor and returns it in Idtr. This
6769 function is only available on IA-32 and x64.
6771 If Idtr is NULL, then ASSERT().
6773 @param Idtr The pointer to a IDTR descriptor.
6779 OUT IA32_DESCRIPTOR
*Idtr
6784 Writes the current Interrupt Descriptor Table Register(IDTR) descriptor.
6786 Writes the current IDTR descriptor and returns it in Idtr. This function is
6787 only available on IA-32 and x64.
6789 If Idtr is NULL, then ASSERT().
6791 @param Idtr The pointer to a IDTR descriptor.
6797 IN CONST IA32_DESCRIPTOR
*Idtr
6802 Reads the current Local Descriptor Table Register(LDTR) selector.
6804 Reads and returns the current 16-bit LDTR descriptor value. This function is
6805 only available on IA-32 and x64.
6807 @return The current selector of LDT.
6818 Writes the current Local Descriptor Table Register (LDTR) selector.
6820 Writes and the current LDTR descriptor specified by Ldtr. This function is
6821 only available on IA-32 and x64.
6823 @param Ldtr 16-bit LDTR selector value.
6834 Save the current floating point/SSE/SSE2 context to a buffer.
6836 Saves the current floating point/SSE/SSE2 state to the buffer specified by
6837 Buffer. Buffer must be aligned on a 16-byte boundary. This function is only
6838 available on IA-32 and x64.
6840 If Buffer is NULL, then ASSERT().
6841 If Buffer is not aligned on a 16-byte boundary, then ASSERT().
6843 @param Buffer The pointer to a buffer to save the floating point/SSE/SSE2 context.
6849 OUT IA32_FX_BUFFER
*Buffer
6854 Restores the current floating point/SSE/SSE2 context from a buffer.
6856 Restores the current floating point/SSE/SSE2 state from the buffer specified
6857 by Buffer. Buffer must be aligned on a 16-byte boundary. This function is
6858 only available on IA-32 and x64.
6860 If Buffer is NULL, then ASSERT().
6861 If Buffer is not aligned on a 16-byte boundary, then ASSERT().
6862 If Buffer was not saved with AsmFxSave(), then ASSERT().
6864 @param Buffer The pointer to a buffer to save the floating point/SSE/SSE2 context.
6870 IN CONST IA32_FX_BUFFER
*Buffer
6875 Reads the current value of 64-bit MMX Register #0 (MM0).
6877 Reads and returns the current value of MM0. This function is only available
6880 @return The current value of MM0.
6891 Reads the current value of 64-bit MMX Register #1 (MM1).
6893 Reads and returns the current value of MM1. This function is only available
6896 @return The current value of MM1.
6907 Reads the current value of 64-bit MMX Register #2 (MM2).
6909 Reads and returns the current value of MM2. This function is only available
6912 @return The current value of MM2.
6923 Reads the current value of 64-bit MMX Register #3 (MM3).
6925 Reads and returns the current value of MM3. This function is only available
6928 @return The current value of MM3.
6939 Reads the current value of 64-bit MMX Register #4 (MM4).
6941 Reads and returns the current value of MM4. This function is only available
6944 @return The current value of MM4.
6955 Reads the current value of 64-bit MMX Register #5 (MM5).
6957 Reads and returns the current value of MM5. This function is only available
6960 @return The current value of MM5.
6971 Reads the current value of 64-bit MMX Register #6 (MM6).
6973 Reads and returns the current value of MM6. This function is only available
6976 @return The current value of MM6.
6987 Reads the current value of 64-bit MMX Register #7 (MM7).
6989 Reads and returns the current value of MM7. This function is only available
6992 @return The current value of MM7.
7003 Writes the current value of 64-bit MMX Register #0 (MM0).
7005 Writes the current value of MM0. This function is only available on IA32 and
7008 @param Value The 64-bit value to write to MM0.
7019 Writes the current value of 64-bit MMX Register #1 (MM1).
7021 Writes the current value of MM1. This function is only available on IA32 and
7024 @param Value The 64-bit value to write to MM1.
7035 Writes the current value of 64-bit MMX Register #2 (MM2).
7037 Writes the current value of MM2. This function is only available on IA32 and
7040 @param Value The 64-bit value to write to MM2.
7051 Writes the current value of 64-bit MMX Register #3 (MM3).
7053 Writes the current value of MM3. This function is only available on IA32 and
7056 @param Value The 64-bit value to write to MM3.
7067 Writes the current value of 64-bit MMX Register #4 (MM4).
7069 Writes the current value of MM4. This function is only available on IA32 and
7072 @param Value The 64-bit value to write to MM4.
7083 Writes the current value of 64-bit MMX Register #5 (MM5).
7085 Writes the current value of MM5. This function is only available on IA32 and
7088 @param Value The 64-bit value to write to MM5.
7099 Writes the current value of 64-bit MMX Register #6 (MM6).
7101 Writes the current value of MM6. This function is only available on IA32 and
7104 @param Value The 64-bit value to write to MM6.
7115 Writes the current value of 64-bit MMX Register #7 (MM7).
7117 Writes the current value of MM7. This function is only available on IA32 and
7120 @param Value The 64-bit value to write to MM7.
7131 Reads the current value of Time Stamp Counter (TSC).
7133 Reads and returns the current value of TSC. This function is only available
7136 @return The current value of TSC
7147 Reads the current value of a Performance Counter (PMC).
7149 Reads and returns the current value of performance counter specified by
7150 Index. This function is only available on IA-32 and x64.
7152 @param Index The 32-bit Performance Counter index to read.
7154 @return The value of the PMC specified by Index.
7165 Sets up a monitor buffer that is used by AsmMwait().
7167 Executes a MONITOR instruction with the register state specified by Eax, Ecx
7168 and Edx. Returns Eax. This function is only available on IA-32 and x64.
7170 @param Eax The value to load into EAX or RAX before executing the MONITOR
7172 @param Ecx The value to load into ECX or RCX before executing the MONITOR
7174 @param Edx The value to load into EDX or RDX before executing the MONITOR
7190 Executes an MWAIT instruction.
7192 Executes an MWAIT instruction with the register state specified by Eax and
7193 Ecx. Returns Eax. This function is only available on IA-32 and x64.
7195 @param Eax The value to load into EAX or RAX before executing the MONITOR
7197 @param Ecx The value to load into ECX or RCX before executing the MONITOR
7212 Executes a WBINVD instruction.
7214 Executes a WBINVD instruction. This function is only available on IA-32 and
7226 Executes a INVD instruction.
7228 Executes a INVD instruction. This function is only available on IA-32 and
7240 Flushes a cache line from all the instruction and data caches within the
7241 coherency domain of the CPU.
7243 Flushed the cache line specified by LinearAddress, and returns LinearAddress.
7244 This function is only available on IA-32 and x64.
7246 @param LinearAddress The address of the cache line to flush. If the CPU is
7247 in a physical addressing mode, then LinearAddress is a
7248 physical address. If the CPU is in a virtual
7249 addressing mode, then LinearAddress is a virtual
7252 @return LinearAddress.
7257 IN VOID
*LinearAddress
7262 Enables the 32-bit paging mode on the CPU.
7264 Enables the 32-bit paging mode on the CPU. CR0, CR3, CR4, and the page tables
7265 must be properly initialized prior to calling this service. This function
7266 assumes the current execution mode is 32-bit protected mode. This function is
7267 only available on IA-32. After the 32-bit paging mode is enabled, control is
7268 transferred to the function specified by EntryPoint using the new stack
7269 specified by NewStack and passing in the parameters specified by Context1 and
7270 Context2. Context1 and Context2 are optional and may be NULL. The function
7271 EntryPoint must never return.
7273 If the current execution mode is not 32-bit protected mode, then ASSERT().
7274 If EntryPoint is NULL, then ASSERT().
7275 If NewStack is NULL, then ASSERT().
7277 There are a number of constraints that must be followed before calling this
7279 1) Interrupts must be disabled.
7280 2) The caller must be in 32-bit protected mode with flat descriptors. This
7281 means all descriptors must have a base of 0 and a limit of 4GB.
7282 3) CR0 and CR4 must be compatible with 32-bit protected mode with flat
7284 4) CR3 must point to valid page tables that will be used once the transition
7285 is complete, and those page tables must guarantee that the pages for this
7286 function and the stack are identity mapped.
7288 @param EntryPoint A pointer to function to call with the new stack after
7290 @param Context1 A pointer to the context to pass into the EntryPoint
7291 function as the first parameter after paging is enabled.
7292 @param Context2 A pointer to the context to pass into the EntryPoint
7293 function as the second parameter after paging is enabled.
7294 @param NewStack A pointer to the new stack to use for the EntryPoint
7295 function after paging is enabled.
7301 IN SWITCH_STACK_ENTRY_POINT EntryPoint
,
7302 IN VOID
*Context1
, OPTIONAL
7303 IN VOID
*Context2
, OPTIONAL
7309 Disables the 32-bit paging mode on the CPU.
7311 Disables the 32-bit paging mode on the CPU and returns to 32-bit protected
7312 mode. This function assumes the current execution mode is 32-paged protected
7313 mode. This function is only available on IA-32. After the 32-bit paging mode
7314 is disabled, control is transferred to the function specified by EntryPoint
7315 using the new stack specified by NewStack and passing in the parameters
7316 specified by Context1 and Context2. Context1 and Context2 are optional and
7317 may be NULL. The function EntryPoint must never return.
7319 If the current execution mode is not 32-bit paged mode, then ASSERT().
7320 If EntryPoint is NULL, then ASSERT().
7321 If NewStack is NULL, then ASSERT().
7323 There are a number of constraints that must be followed before calling this
7325 1) Interrupts must be disabled.
7326 2) The caller must be in 32-bit paged mode.
7327 3) CR0, CR3, and CR4 must be compatible with 32-bit paged mode.
7328 4) CR3 must point to valid page tables that guarantee that the pages for
7329 this function and the stack are identity mapped.
7331 @param EntryPoint A pointer to function to call with the new stack after
7333 @param Context1 A pointer to the context to pass into the EntryPoint
7334 function as the first parameter after paging is disabled.
7335 @param Context2 A pointer to the context to pass into the EntryPoint
7336 function as the second parameter after paging is
7338 @param NewStack A pointer to the new stack to use for the EntryPoint
7339 function after paging is disabled.
7344 AsmDisablePaging32 (
7345 IN SWITCH_STACK_ENTRY_POINT EntryPoint
,
7346 IN VOID
*Context1
, OPTIONAL
7347 IN VOID
*Context2
, OPTIONAL
7353 Enables the 64-bit paging mode on the CPU.
7355 Enables the 64-bit paging mode on the CPU. CR0, CR3, CR4, and the page tables
7356 must be properly initialized prior to calling this service. This function
7357 assumes the current execution mode is 32-bit protected mode with flat
7358 descriptors. This function is only available on IA-32. After the 64-bit
7359 paging mode is enabled, control is transferred to the function specified by
7360 EntryPoint using the new stack specified by NewStack and passing in the
7361 parameters specified by Context1 and Context2. Context1 and Context2 are
7362 optional and may be 0. The function EntryPoint must never return.
7364 If the current execution mode is not 32-bit protected mode with flat
7365 descriptors, then ASSERT().
7366 If EntryPoint is 0, then ASSERT().
7367 If NewStack is 0, then ASSERT().
7369 @param Cs The 16-bit selector to load in the CS before EntryPoint
7370 is called. The descriptor in the GDT that this selector
7371 references must be setup for long mode.
7372 @param EntryPoint The 64-bit virtual address of the function to call with
7373 the new stack after paging is enabled.
7374 @param Context1 The 64-bit virtual address of the context to pass into
7375 the EntryPoint function as the first parameter after
7377 @param Context2 The 64-bit virtual address of the context to pass into
7378 the EntryPoint function as the second parameter after
7380 @param NewStack The 64-bit virtual address of the new stack to use for
7381 the EntryPoint function after paging is enabled.
7388 IN UINT64 EntryPoint
,
7389 IN UINT64 Context1
, OPTIONAL
7390 IN UINT64 Context2
, OPTIONAL
7396 Disables the 64-bit paging mode on the CPU.
7398 Disables the 64-bit paging mode on the CPU and returns to 32-bit protected
7399 mode. This function assumes the current execution mode is 64-paging mode.
7400 This function is only available on x64. After the 64-bit paging mode is
7401 disabled, control is transferred to the function specified by EntryPoint
7402 using the new stack specified by NewStack and passing in the parameters
7403 specified by Context1 and Context2. Context1 and Context2 are optional and
7404 may be 0. The function EntryPoint must never return.
7406 If the current execution mode is not 64-bit paged mode, then ASSERT().
7407 If EntryPoint is 0, then ASSERT().
7408 If NewStack is 0, then ASSERT().
7410 @param Cs The 16-bit selector to load in the CS before EntryPoint
7411 is called. The descriptor in the GDT that this selector
7412 references must be setup for 32-bit protected mode.
7413 @param EntryPoint The 64-bit virtual address of the function to call with
7414 the new stack after paging is disabled.
7415 @param Context1 The 64-bit virtual address of the context to pass into
7416 the EntryPoint function as the first parameter after
7418 @param Context2 The 64-bit virtual address of the context to pass into
7419 the EntryPoint function as the second parameter after
7421 @param NewStack The 64-bit virtual address of the new stack to use for
7422 the EntryPoint function after paging is disabled.
7427 AsmDisablePaging64 (
7429 IN UINT32 EntryPoint
,
7430 IN UINT32 Context1
, OPTIONAL
7431 IN UINT32 Context2
, OPTIONAL
7437 // 16-bit thunking services
7441 Retrieves the properties for 16-bit thunk functions.
7443 Computes the size of the buffer and stack below 1MB required to use the
7444 AsmPrepareThunk16(), AsmThunk16() and AsmPrepareAndThunk16() functions. This
7445 buffer size is returned in RealModeBufferSize, and the stack size is returned
7446 in ExtraStackSize. If parameters are passed to the 16-bit real mode code,
7447 then the actual minimum stack size is ExtraStackSize plus the maximum number
7448 of bytes that need to be passed to the 16-bit real mode code.
7450 If RealModeBufferSize is NULL, then ASSERT().
7451 If ExtraStackSize is NULL, then ASSERT().
7453 @param RealModeBufferSize A pointer to the size of the buffer below 1MB
7454 required to use the 16-bit thunk functions.
7455 @param ExtraStackSize A pointer to the extra size of stack below 1MB
7456 that the 16-bit thunk functions require for
7457 temporary storage in the transition to and from
7463 AsmGetThunk16Properties (
7464 OUT UINT32
*RealModeBufferSize
,
7465 OUT UINT32
*ExtraStackSize
7470 Prepares all structures a code required to use AsmThunk16().
7472 Prepares all structures and code required to use AsmThunk16().
7474 This interface is limited to be used in either physical mode or virtual modes with paging enabled where the
7475 virtual to physical mappings for ThunkContext.RealModeBuffer is mapped 1:1.
7477 If ThunkContext is NULL, then ASSERT().
7479 @param ThunkContext A pointer to the context structure that describes the
7480 16-bit real mode code to call.
7486 IN OUT THUNK_CONTEXT
*ThunkContext
7491 Transfers control to a 16-bit real mode entry point and returns the results.
7493 Transfers control to a 16-bit real mode entry point and returns the results.
7494 AsmPrepareThunk16() must be called with ThunkContext before this function is used.
7495 This function must be called with interrupts disabled.
7497 The register state from the RealModeState field of ThunkContext is restored just prior
7498 to calling the 16-bit real mode entry point. This includes the EFLAGS field of RealModeState,
7499 which is used to set the interrupt state when a 16-bit real mode entry point is called.
7500 Control is transferred to the 16-bit real mode entry point specified by the CS and Eip fields of RealModeState.
7501 The stack is initialized to the SS and ESP fields of RealModeState. Any parameters passed to
7502 the 16-bit real mode code must be populated by the caller at SS:ESP prior to calling this function.
7503 The 16-bit real mode entry point is invoked with a 16-bit CALL FAR instruction,
7504 so when accessing stack contents, the 16-bit real mode code must account for the 16-bit segment
7505 and 16-bit offset of the return address that were pushed onto the stack. The 16-bit real mode entry
7506 point must exit with a RETF instruction. The register state is captured into RealModeState immediately
7507 after the RETF instruction is executed.
7509 If EFLAGS specifies interrupts enabled, or any of the 16-bit real mode code enables interrupts,
7510 or any of the 16-bit real mode code makes a SW interrupt, then the caller is responsible for making sure
7511 the IDT at address 0 is initialized to handle any HW or SW interrupts that may occur while in 16-bit real mode.
7513 If EFLAGS specifies interrupts enabled, or any of the 16-bit real mode code enables interrupts,
7514 then the caller is responsible for making sure the 8259 PIC is in a state compatible with 16-bit real mode.
7515 This includes the base vectors, the interrupt masks, and the edge/level trigger mode.
7517 If THUNK_ATTRIBUTE_BIG_REAL_MODE is set in the ThunkAttributes field of ThunkContext, then the user code
7518 is invoked in big real mode. Otherwise, the user code is invoked in 16-bit real mode with 64KB segment limits.
7520 If neither THUNK_ATTRIBUTE_DISABLE_A20_MASK_INT_15 nor THUNK_ATTRIBUTE_DISABLE_A20_MASK_KBD_CTRL are set in
7521 ThunkAttributes, then it is assumed that the user code did not enable the A20 mask, and no attempt is made to
7522 disable the A20 mask.
7524 If THUNK_ATTRIBUTE_DISABLE_A20_MASK_INT_15 is set and THUNK_ATTRIBUTE_DISABLE_A20_MASK_KBD_CTRL is clear in
7525 ThunkAttributes, then attempt to use the INT 15 service to disable the A20 mask. If this INT 15 call fails,
7526 then attempt to disable the A20 mask by directly accessing the 8042 keyboard controller I/O ports.
7528 If THUNK_ATTRIBUTE_DISABLE_A20_MASK_INT_15 is clear and THUNK_ATTRIBUTE_DISABLE_A20_MASK_KBD_CTRL is set in
7529 ThunkAttributes, then attempt to disable the A20 mask by directly accessing the 8042 keyboard controller I/O ports.
7531 If ThunkContext is NULL, then ASSERT().
7532 If AsmPrepareThunk16() was not previously called with ThunkContext, then ASSERT().
7533 If both THUNK_ATTRIBUTE_DISABLE_A20_MASK_INT_15 and THUNK_ATTRIBUTE_DISABLE_A20_MASK_KBD_CTRL are set in
7534 ThunkAttributes, then ASSERT().
7536 This interface is limited to be used in either physical mode or virtual modes with paging enabled where the
7537 virtual to physical mappings for ThunkContext.RealModeBuffer are mapped 1:1.
7539 @param ThunkContext A pointer to the context structure that describes the
7540 16-bit real mode code to call.
7546 IN OUT THUNK_CONTEXT
*ThunkContext
7551 Prepares all structures and code for a 16-bit real mode thunk, transfers
7552 control to a 16-bit real mode entry point, and returns the results.
7554 Prepares all structures and code for a 16-bit real mode thunk, transfers
7555 control to a 16-bit real mode entry point, and returns the results. If the
7556 caller only need to perform a single 16-bit real mode thunk, then this
7557 service should be used. If the caller intends to make more than one 16-bit
7558 real mode thunk, then it is more efficient if AsmPrepareThunk16() is called
7559 once and AsmThunk16() can be called for each 16-bit real mode thunk.
7561 This interface is limited to be used in either physical mode or virtual modes with paging enabled where the
7562 virtual to physical mappings for ThunkContext.RealModeBuffer is mapped 1:1.
7564 See AsmPrepareThunk16() and AsmThunk16() for the detailed description and ASSERT() conditions.
7566 @param ThunkContext A pointer to the context structure that describes the
7567 16-bit real mode code to call.
7572 AsmPrepareAndThunk16 (
7573 IN OUT THUNK_CONTEXT
*ThunkContext