2 Provides string functions, linked list functions, math functions, synchronization
3 functions, file path functions, and CPU architecture-specific functions.
5 Copyright (c) 2006 - 2017, 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 This function is similar as strlen_s defined in C11.
192 If String is not aligned on a 16-bit boundary, then ASSERT().
194 @param String A pointer to a Null-terminated Unicode string.
195 @param MaxSize The maximum number of Destination Unicode
196 char, including terminating null char.
198 @retval 0 If String is NULL.
199 @retval MaxSize If there is no null character in the first MaxSize characters of String.
200 @return The number of characters that percede the terminating null character.
206 IN CONST CHAR16
*String
,
211 Returns the size of a Null-terminated Unicode string in bytes, including the
214 This function returns the size of the Null-terminated Unicode string
215 specified by String in bytes, including the Null terminator.
217 If String is not aligned on a 16-bit boundary, then ASSERT().
219 @param String A pointer to a Null-terminated Unicode string.
220 @param MaxSize The maximum number of Destination Unicode
221 char, including the Null terminator.
223 @retval 0 If String is NULL.
224 @retval (sizeof (CHAR16) * (MaxSize + 1))
225 If there is no Null terminator in the first MaxSize characters of
227 @return The size of the Null-terminated Unicode string in bytes, including
234 IN CONST CHAR16
*String
,
239 Copies the string pointed to by Source (including the terminating null char)
240 to the array pointed to by Destination.
242 This function is similar as strcpy_s defined in C11.
244 If Destination is not aligned on a 16-bit boundary, then ASSERT().
245 If Source is not aligned on a 16-bit boundary, then ASSERT().
246 If an error would be returned, then the function will also ASSERT().
248 If an error is returned, then the Destination is unmodified.
250 @param Destination A pointer to a Null-terminated Unicode string.
251 @param DestMax The maximum number of Destination Unicode
252 char, including terminating null char.
253 @param Source A pointer to a Null-terminated Unicode string.
255 @retval RETURN_SUCCESS String is copied.
256 @retval RETURN_BUFFER_TOO_SMALL If DestMax is NOT greater than StrLen(Source).
257 @retval RETURN_INVALID_PARAMETER If Destination is NULL.
259 If PcdMaximumUnicodeStringLength is not zero,
260 and DestMax is greater than
261 PcdMaximumUnicodeStringLength.
263 @retval RETURN_ACCESS_DENIED If Source and Destination overlap.
268 OUT CHAR16
*Destination
,
270 IN CONST CHAR16
*Source
274 Copies not more than Length successive char from the string pointed to by
275 Source to the array pointed to by Destination. If no null char is copied from
276 Source, then Destination[Length] is always set to null.
278 This function is similar as strncpy_s defined in C11.
280 If Length > 0 and Destination is not aligned on a 16-bit boundary, then ASSERT().
281 If Length > 0 and Source is not aligned on a 16-bit boundary, then ASSERT().
282 If an error would be returned, then the function will also ASSERT().
284 If an error is returned, then the Destination is unmodified.
286 @param Destination A pointer to a Null-terminated Unicode string.
287 @param DestMax The maximum number of Destination Unicode
288 char, including terminating null char.
289 @param Source A pointer to a Null-terminated Unicode string.
290 @param Length The maximum number of Unicode characters to copy.
292 @retval RETURN_SUCCESS String is copied.
293 @retval RETURN_BUFFER_TOO_SMALL If DestMax is NOT greater than
294 MIN(StrLen(Source), Length).
295 @retval RETURN_INVALID_PARAMETER If Destination is NULL.
297 If PcdMaximumUnicodeStringLength is not zero,
298 and DestMax is greater than
299 PcdMaximumUnicodeStringLength.
301 @retval RETURN_ACCESS_DENIED If Source and Destination overlap.
306 OUT CHAR16
*Destination
,
308 IN CONST CHAR16
*Source
,
313 Appends a copy of the string pointed to by Source (including the terminating
314 null char) to the end of the string pointed to by Destination.
316 This function is similar as strcat_s defined in C11.
318 If Destination is not aligned on a 16-bit boundary, then ASSERT().
319 If Source is not aligned on a 16-bit boundary, then ASSERT().
320 If an error would be returned, then the function will also ASSERT().
322 If an error is returned, then the Destination is unmodified.
324 @param Destination A pointer to a Null-terminated Unicode string.
325 @param DestMax The maximum number of Destination Unicode
326 char, including terminating null char.
327 @param Source A pointer to a Null-terminated Unicode string.
329 @retval RETURN_SUCCESS String is appended.
330 @retval RETURN_BAD_BUFFER_SIZE If DestMax is NOT greater than
332 @retval RETURN_BUFFER_TOO_SMALL If (DestMax - StrLen(Destination)) is NOT
333 greater than StrLen(Source).
334 @retval RETURN_INVALID_PARAMETER If Destination is NULL.
336 If PcdMaximumUnicodeStringLength is not zero,
337 and DestMax is greater than
338 PcdMaximumUnicodeStringLength.
340 @retval RETURN_ACCESS_DENIED If Source and Destination overlap.
345 IN OUT CHAR16
*Destination
,
347 IN CONST CHAR16
*Source
351 Appends not more than Length successive char from the string pointed to by
352 Source to the end of the string pointed to by Destination. If no null char is
353 copied from Source, then Destination[StrLen(Destination) + Length] is always
356 This function is similar as strncat_s defined in C11.
358 If Destination is not aligned on a 16-bit boundary, then ASSERT().
359 If Source is not aligned on a 16-bit boundary, then ASSERT().
360 If an error would be returned, then the function will also ASSERT().
362 If an error is returned, then the Destination is unmodified.
364 @param Destination A pointer to a Null-terminated Unicode string.
365 @param DestMax The maximum number of Destination Unicode
366 char, including terminating null char.
367 @param Source A pointer to a Null-terminated Unicode string.
368 @param Length The maximum number of Unicode characters to copy.
370 @retval RETURN_SUCCESS String is appended.
371 @retval RETURN_BAD_BUFFER_SIZE If DestMax is NOT greater than
373 @retval RETURN_BUFFER_TOO_SMALL If (DestMax - StrLen(Destination)) is NOT
374 greater than MIN(StrLen(Source), Length).
375 @retval RETURN_INVALID_PARAMETER If Destination is NULL.
377 If PcdMaximumUnicodeStringLength is not zero,
378 and DestMax is greater than
379 PcdMaximumUnicodeStringLength.
381 @retval RETURN_ACCESS_DENIED If Source and Destination overlap.
386 IN OUT CHAR16
*Destination
,
388 IN CONST CHAR16
*Source
,
393 Returns the length of a Null-terminated Ascii string.
395 This function is similar as strlen_s defined in C11.
397 @param String A pointer to a Null-terminated Ascii string.
398 @param MaxSize The maximum number of Destination Ascii
399 char, including terminating null char.
401 @retval 0 If String is NULL.
402 @retval MaxSize If there is no null character in the first MaxSize characters of String.
403 @return The number of characters that percede the terminating null character.
409 IN CONST CHAR8
*String
,
414 Returns the size of a Null-terminated Ascii string in bytes, including the
417 This function returns the size of the Null-terminated Ascii string specified
418 by String in bytes, including the Null terminator.
420 @param String A pointer to a Null-terminated Ascii string.
421 @param MaxSize The maximum number of Destination Ascii
422 char, including the Null terminator.
424 @retval 0 If String is NULL.
425 @retval (sizeof (CHAR8) * (MaxSize + 1))
426 If there is no Null terminator in the first MaxSize characters of
428 @return The size of the Null-terminated Ascii string in bytes, including the
435 IN CONST CHAR8
*String
,
440 Copies the string pointed to by Source (including the terminating null char)
441 to the array pointed to by Destination.
443 This function is similar as strcpy_s defined in C11.
445 If an error would be returned, then the function will also ASSERT().
447 If an error is returned, then the Destination is unmodified.
449 @param Destination A pointer to a Null-terminated Ascii string.
450 @param DestMax The maximum number of Destination Ascii
451 char, including terminating null char.
452 @param Source A pointer to a Null-terminated Ascii string.
454 @retval RETURN_SUCCESS String is copied.
455 @retval RETURN_BUFFER_TOO_SMALL If DestMax is NOT greater than StrLen(Source).
456 @retval RETURN_INVALID_PARAMETER If Destination is NULL.
458 If PcdMaximumAsciiStringLength is not zero,
459 and DestMax is greater than
460 PcdMaximumAsciiStringLength.
462 @retval RETURN_ACCESS_DENIED If Source and Destination overlap.
467 OUT CHAR8
*Destination
,
469 IN CONST CHAR8
*Source
473 Copies not more than Length successive char from the string pointed to by
474 Source to the array pointed to by Destination. If no null char is copied from
475 Source, then Destination[Length] is always set to null.
477 This function is similar as strncpy_s defined in C11.
479 If an error would be returned, then the function will also ASSERT().
481 If an error is returned, then the Destination is unmodified.
483 @param Destination A pointer to a Null-terminated Ascii string.
484 @param DestMax The maximum number of Destination Ascii
485 char, including terminating null char.
486 @param Source A pointer to a Null-terminated Ascii string.
487 @param Length The maximum number of Ascii characters to copy.
489 @retval RETURN_SUCCESS String is copied.
490 @retval RETURN_BUFFER_TOO_SMALL If DestMax is NOT greater than
491 MIN(StrLen(Source), Length).
492 @retval RETURN_INVALID_PARAMETER If Destination is NULL.
494 If PcdMaximumAsciiStringLength is not zero,
495 and DestMax is greater than
496 PcdMaximumAsciiStringLength.
498 @retval RETURN_ACCESS_DENIED If Source and Destination overlap.
503 OUT CHAR8
*Destination
,
505 IN CONST CHAR8
*Source
,
510 Appends a copy of the string pointed to by Source (including the terminating
511 null char) to the end of the string pointed to by Destination.
513 This function is similar as strcat_s defined in C11.
515 If an error would be returned, then the function will also ASSERT().
517 If an error is returned, then the Destination is unmodified.
519 @param Destination A pointer to a Null-terminated Ascii string.
520 @param DestMax The maximum number of Destination Ascii
521 char, including terminating null char.
522 @param Source A pointer to a Null-terminated Ascii string.
524 @retval RETURN_SUCCESS String is appended.
525 @retval RETURN_BAD_BUFFER_SIZE If DestMax is NOT greater than
527 @retval RETURN_BUFFER_TOO_SMALL If (DestMax - StrLen(Destination)) is NOT
528 greater than StrLen(Source).
529 @retval RETURN_INVALID_PARAMETER If Destination is NULL.
531 If PcdMaximumAsciiStringLength is not zero,
532 and DestMax is greater than
533 PcdMaximumAsciiStringLength.
535 @retval RETURN_ACCESS_DENIED If Source and Destination overlap.
540 IN OUT CHAR8
*Destination
,
542 IN CONST CHAR8
*Source
546 Appends not more than Length successive char from the string pointed to by
547 Source to the end of the string pointed to by Destination. If no null char is
548 copied from Source, then Destination[StrLen(Destination) + Length] is always
551 This function is similar as strncat_s defined in C11.
553 If an error would be returned, then the function will also ASSERT().
555 If an error is returned, then the Destination is unmodified.
557 @param Destination A pointer to a Null-terminated Ascii string.
558 @param DestMax The maximum number of Destination Ascii
559 char, including terminating null char.
560 @param Source A pointer to a Null-terminated Ascii string.
561 @param Length The maximum number of Ascii characters to copy.
563 @retval RETURN_SUCCESS String is appended.
564 @retval RETURN_BAD_BUFFER_SIZE If DestMax is NOT greater than
566 @retval RETURN_BUFFER_TOO_SMALL If (DestMax - StrLen(Destination)) is NOT
567 greater than MIN(StrLen(Source), Length).
568 @retval RETURN_INVALID_PARAMETER If Destination is NULL.
570 If PcdMaximumAsciiStringLength is not zero,
571 and DestMax is greater than
572 PcdMaximumAsciiStringLength.
574 @retval RETURN_ACCESS_DENIED If Source and Destination overlap.
579 IN OUT CHAR8
*Destination
,
581 IN CONST CHAR8
*Source
,
586 #ifndef DISABLE_NEW_DEPRECATED_INTERFACES
589 [ATTENTION] This function is deprecated for security reason.
591 Copies one Null-terminated Unicode string to another Null-terminated Unicode
592 string and returns the new Unicode string.
594 This function copies the contents of the Unicode string Source to the Unicode
595 string Destination, and returns Destination. If Source and Destination
596 overlap, then the results are undefined.
598 If Destination is NULL, then ASSERT().
599 If Destination is not aligned on a 16-bit boundary, then ASSERT().
600 If Source is NULL, then ASSERT().
601 If Source is not aligned on a 16-bit boundary, then ASSERT().
602 If Source and Destination overlap, then ASSERT().
603 If PcdMaximumUnicodeStringLength is not zero, and Source contains more than
604 PcdMaximumUnicodeStringLength Unicode characters not including the
605 Null-terminator, then ASSERT().
607 @param Destination The pointer to a Null-terminated Unicode string.
608 @param Source The pointer to a Null-terminated Unicode string.
616 OUT CHAR16
*Destination
,
617 IN CONST CHAR16
*Source
622 [ATTENTION] This function is deprecated for security reason.
624 Copies up to a specified length from one Null-terminated Unicode string to
625 another Null-terminated Unicode string and returns the new Unicode string.
627 This function copies the contents of the Unicode string Source to the Unicode
628 string Destination, and returns Destination. At most, Length Unicode
629 characters are copied from Source to Destination. If Length is 0, then
630 Destination is returned unmodified. If Length is greater that the number of
631 Unicode characters in Source, then Destination is padded with Null Unicode
632 characters. If Source and Destination overlap, then the results are
635 If Length > 0 and Destination is NULL, then ASSERT().
636 If Length > 0 and Destination is not aligned on a 16-bit boundary, then ASSERT().
637 If Length > 0 and Source is NULL, then ASSERT().
638 If Length > 0 and Source is not aligned on a 16-bit boundary, then ASSERT().
639 If Source and Destination overlap, then ASSERT().
640 If PcdMaximumUnicodeStringLength is not zero, and Length is greater than
641 PcdMaximumUnicodeStringLength, then ASSERT().
642 If PcdMaximumUnicodeStringLength is not zero, and Source contains more than
643 PcdMaximumUnicodeStringLength Unicode characters, not including the Null-terminator,
646 @param Destination The pointer to a Null-terminated Unicode string.
647 @param Source The pointer to a Null-terminated Unicode string.
648 @param Length The maximum number of Unicode characters to copy.
656 OUT CHAR16
*Destination
,
657 IN CONST CHAR16
*Source
,
663 Returns the length of a Null-terminated Unicode string.
665 This function returns the number of Unicode characters in the Null-terminated
666 Unicode string specified by String.
668 If String is NULL, then ASSERT().
669 If String is not aligned on a 16-bit boundary, then ASSERT().
670 If PcdMaximumUnicodeStringLength is not zero, and String contains more than
671 PcdMaximumUnicodeStringLength Unicode characters not including the
672 Null-terminator, then ASSERT().
674 @param String Pointer to a Null-terminated Unicode string.
676 @return The length of String.
682 IN CONST CHAR16
*String
687 Returns the size of a Null-terminated Unicode string in bytes, including the
690 This function returns the size, in bytes, of the Null-terminated Unicode string
693 If String is NULL, then ASSERT().
694 If String is not aligned on a 16-bit boundary, then ASSERT().
695 If PcdMaximumUnicodeStringLength is not zero, and String contains more than
696 PcdMaximumUnicodeStringLength Unicode characters not including the
697 Null-terminator, then ASSERT().
699 @param String The pointer to a Null-terminated Unicode string.
701 @return The size of String.
707 IN CONST CHAR16
*String
712 Compares two Null-terminated Unicode strings, and returns the difference
713 between the first mismatched Unicode characters.
715 This function compares the Null-terminated Unicode string FirstString to the
716 Null-terminated Unicode string SecondString. If FirstString is identical to
717 SecondString, then 0 is returned. Otherwise, the value returned is the first
718 mismatched Unicode character in SecondString subtracted from the first
719 mismatched Unicode character in FirstString.
721 If FirstString is NULL, then ASSERT().
722 If FirstString is not aligned on a 16-bit boundary, then ASSERT().
723 If SecondString is NULL, then ASSERT().
724 If SecondString is not aligned on a 16-bit boundary, then ASSERT().
725 If PcdMaximumUnicodeStringLength is not zero, and FirstString contains more
726 than PcdMaximumUnicodeStringLength Unicode characters not including the
727 Null-terminator, then ASSERT().
728 If PcdMaximumUnicodeStringLength is not zero, and SecondString contains more
729 than PcdMaximumUnicodeStringLength Unicode characters, not including the
730 Null-terminator, then ASSERT().
732 @param FirstString The pointer to a Null-terminated Unicode string.
733 @param SecondString The pointer to a Null-terminated Unicode string.
735 @retval 0 FirstString is identical to SecondString.
736 @return others FirstString is not identical to SecondString.
742 IN CONST CHAR16
*FirstString
,
743 IN CONST CHAR16
*SecondString
748 Compares up to a specified length the contents of two Null-terminated Unicode strings,
749 and returns the difference between the first mismatched Unicode characters.
751 This function compares the Null-terminated Unicode string FirstString to the
752 Null-terminated Unicode string SecondString. At most, Length Unicode
753 characters will be compared. If Length is 0, then 0 is returned. If
754 FirstString is identical to SecondString, then 0 is returned. Otherwise, the
755 value returned is the first mismatched Unicode character in SecondString
756 subtracted from the first mismatched Unicode character in FirstString.
758 If Length > 0 and FirstString is NULL, then ASSERT().
759 If Length > 0 and FirstString is not aligned on a 16-bit boundary, then ASSERT().
760 If Length > 0 and SecondString is NULL, then ASSERT().
761 If Length > 0 and SecondString is not aligned on a 16-bit boundary, then ASSERT().
762 If PcdMaximumUnicodeStringLength is not zero, and Length is greater than
763 PcdMaximumUnicodeStringLength, then ASSERT().
764 If PcdMaximumUnicodeStringLength is not zero, and FirstString contains more than
765 PcdMaximumUnicodeStringLength Unicode characters, not including the Null-terminator,
767 If PcdMaximumUnicodeStringLength is not zero, and SecondString contains more than
768 PcdMaximumUnicodeStringLength Unicode characters, not including the Null-terminator,
771 @param FirstString The pointer to a Null-terminated Unicode string.
772 @param SecondString The pointer to a Null-terminated Unicode string.
773 @param Length The maximum number of Unicode characters to compare.
775 @retval 0 FirstString is identical to SecondString.
776 @return others FirstString is not identical to SecondString.
782 IN CONST CHAR16
*FirstString
,
783 IN CONST CHAR16
*SecondString
,
788 #ifndef DISABLE_NEW_DEPRECATED_INTERFACES
791 [ATTENTION] This function is deprecated for security reason.
793 Concatenates one Null-terminated Unicode string to another Null-terminated
794 Unicode string, and returns the concatenated Unicode string.
796 This function concatenates two Null-terminated Unicode strings. The contents
797 of Null-terminated Unicode string Source are concatenated to the end of
798 Null-terminated Unicode string Destination. The Null-terminated concatenated
799 Unicode String is returned. If Source and Destination overlap, then the
800 results are undefined.
802 If Destination is NULL, then ASSERT().
803 If Destination is not aligned on a 16-bit boundary, then ASSERT().
804 If Source is NULL, then ASSERT().
805 If Source is not aligned on a 16-bit boundary, then ASSERT().
806 If Source and Destination overlap, then ASSERT().
807 If PcdMaximumUnicodeStringLength is not zero, and Destination contains more
808 than PcdMaximumUnicodeStringLength Unicode characters, not including the
809 Null-terminator, then ASSERT().
810 If PcdMaximumUnicodeStringLength is not zero, and Source contains more than
811 PcdMaximumUnicodeStringLength Unicode characters, not including the
812 Null-terminator, then ASSERT().
813 If PcdMaximumUnicodeStringLength is not zero, and concatenating Destination
814 and Source results in a Unicode string with more than
815 PcdMaximumUnicodeStringLength Unicode characters, not including the
816 Null-terminator, then ASSERT().
818 @param Destination The pointer to a Null-terminated Unicode string.
819 @param Source The pointer to a Null-terminated Unicode string.
827 IN OUT CHAR16
*Destination
,
828 IN CONST CHAR16
*Source
833 [ATTENTION] This function is deprecated for security reason.
835 Concatenates up to a specified length one Null-terminated Unicode to the end
836 of another Null-terminated Unicode string, and returns the concatenated
839 This function concatenates two Null-terminated Unicode strings. The contents
840 of Null-terminated Unicode string Source are concatenated to the end of
841 Null-terminated Unicode string Destination, and Destination is returned. At
842 most, Length Unicode characters are concatenated from Source to the end of
843 Destination, and Destination is always Null-terminated. If Length is 0, then
844 Destination is returned unmodified. If Source and Destination overlap, then
845 the results are undefined.
847 If Destination is NULL, then ASSERT().
848 If Length > 0 and Destination is not aligned on a 16-bit boundary, then ASSERT().
849 If Length > 0 and Source is NULL, then ASSERT().
850 If Length > 0 and Source is not aligned on a 16-bit boundary, then ASSERT().
851 If Source and Destination overlap, then ASSERT().
852 If PcdMaximumUnicodeStringLength is not zero, and Length is greater than
853 PcdMaximumUnicodeStringLength, then ASSERT().
854 If PcdMaximumUnicodeStringLength is not zero, and Destination contains more
855 than PcdMaximumUnicodeStringLength Unicode characters, not including the
856 Null-terminator, then ASSERT().
857 If PcdMaximumUnicodeStringLength is not zero, and Source contains more than
858 PcdMaximumUnicodeStringLength Unicode characters, not including the
859 Null-terminator, then ASSERT().
860 If PcdMaximumUnicodeStringLength is not zero, and concatenating Destination
861 and Source results in a Unicode string with more than PcdMaximumUnicodeStringLength
862 Unicode characters, not including the Null-terminator, then ASSERT().
864 @param Destination The pointer to a Null-terminated Unicode string.
865 @param Source The pointer to a Null-terminated Unicode string.
866 @param Length The maximum number of Unicode characters to concatenate from
875 IN OUT CHAR16
*Destination
,
876 IN CONST CHAR16
*Source
,
882 Returns the first occurrence of a Null-terminated Unicode sub-string
883 in a Null-terminated Unicode string.
885 This function scans the contents of the Null-terminated Unicode string
886 specified by String and returns the first occurrence of SearchString.
887 If SearchString is not found in String, then NULL is returned. If
888 the length of SearchString is zero, then String is returned.
890 If String is NULL, then ASSERT().
891 If String is not aligned on a 16-bit boundary, then ASSERT().
892 If SearchString is NULL, then ASSERT().
893 If SearchString is not aligned on a 16-bit boundary, then ASSERT().
895 If PcdMaximumUnicodeStringLength is not zero, and SearchString
896 or String contains more than PcdMaximumUnicodeStringLength Unicode
897 characters, not including the Null-terminator, then ASSERT().
899 @param String The pointer to a Null-terminated Unicode string.
900 @param SearchString The pointer to a Null-terminated Unicode string to search for.
902 @retval NULL If the SearchString does not appear in String.
903 @return others If there is a match.
909 IN CONST CHAR16
*String
,
910 IN CONST CHAR16
*SearchString
914 Convert a Null-terminated Unicode decimal string to a value of
917 This function returns a value of type UINTN by interpreting the contents
918 of the Unicode string specified by String as a decimal number. The format
919 of the input Unicode string String is:
921 [spaces] [decimal digits].
923 The valid decimal digit character is in the range [0-9]. The
924 function will ignore the pad space, which includes spaces or
925 tab characters, before [decimal digits]. The running zero in the
926 beginning of [decimal digits] will be ignored. Then, the function
927 stops at the first character that is a not a valid decimal character
928 or a Null-terminator, whichever one comes first.
930 If String is NULL, then ASSERT().
931 If String is not aligned in a 16-bit boundary, then ASSERT().
932 If String has only pad spaces, then 0 is returned.
933 If String has no pad spaces or valid decimal digits,
935 If the number represented by String overflows according
936 to the range defined by UINTN, then ASSERT().
938 If PcdMaximumUnicodeStringLength is not zero, and String contains
939 more than PcdMaximumUnicodeStringLength Unicode characters not including
940 the Null-terminator, then ASSERT().
942 @param String The pointer to a Null-terminated Unicode string.
944 @retval Value translated from String.
950 IN CONST CHAR16
*String
954 Convert a Null-terminated Unicode decimal string to a value of
957 This function returns a value of type UINT64 by interpreting the contents
958 of the Unicode string specified by String as a decimal number. The format
959 of the input Unicode string String is:
961 [spaces] [decimal digits].
963 The valid decimal digit character is in the range [0-9]. The
964 function will ignore the pad space, which includes spaces or
965 tab characters, before [decimal digits]. The running zero in the
966 beginning of [decimal digits] will be ignored. Then, the function
967 stops at the first character that is a not a valid decimal character
968 or a Null-terminator, whichever one comes first.
970 If String is NULL, then ASSERT().
971 If String is not aligned in a 16-bit boundary, then ASSERT().
972 If String has only pad spaces, then 0 is returned.
973 If String has no pad spaces or valid decimal digits,
975 If the number represented by String overflows according
976 to the range defined by UINT64, then ASSERT().
978 If PcdMaximumUnicodeStringLength is not zero, and String contains
979 more than PcdMaximumUnicodeStringLength Unicode characters not including
980 the Null-terminator, then ASSERT().
982 @param String The pointer to a Null-terminated Unicode string.
984 @retval Value translated from String.
990 IN CONST CHAR16
*String
995 Convert a Null-terminated Unicode hexadecimal string to a value of type UINTN.
997 This function returns a value of type UINTN by interpreting the contents
998 of the Unicode string specified by String as a hexadecimal number.
999 The format of the input Unicode string String is:
1001 [spaces][zeros][x][hexadecimal digits].
1003 The valid hexadecimal digit character is in the range [0-9], [a-f] and [A-F].
1004 The prefix "0x" is optional. Both "x" and "X" is allowed in "0x" prefix.
1005 If "x" appears in the input string, it must be prefixed with at least one 0.
1006 The function will ignore the pad space, which includes spaces or tab characters,
1007 before [zeros], [x] or [hexadecimal digit]. The running zero before [x] or
1008 [hexadecimal digit] will be ignored. Then, the decoding starts after [x] or the
1009 first valid hexadecimal digit. Then, the function stops at the first character
1010 that is a not a valid hexadecimal character or NULL, whichever one comes first.
1012 If String is NULL, then ASSERT().
1013 If String is not aligned in a 16-bit boundary, then ASSERT().
1014 If String has only pad spaces, then zero is returned.
1015 If String has no leading pad spaces, leading zeros or valid hexadecimal digits,
1016 then zero is returned.
1017 If the number represented by String overflows according to the range defined by
1018 UINTN, then ASSERT().
1020 If PcdMaximumUnicodeStringLength is not zero, and String contains more than
1021 PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator,
1024 @param String The pointer to a Null-terminated Unicode string.
1026 @retval Value translated from String.
1032 IN CONST CHAR16
*String
1037 Convert a Null-terminated Unicode hexadecimal string to a value of type UINT64.
1039 This function returns a value of type UINT64 by interpreting the contents
1040 of the Unicode string specified by String as a hexadecimal number.
1041 The format of the input Unicode string String is
1043 [spaces][zeros][x][hexadecimal digits].
1045 The valid hexadecimal digit character is in the range [0-9], [a-f] and [A-F].
1046 The prefix "0x" is optional. Both "x" and "X" is allowed in "0x" prefix.
1047 If "x" appears in the input string, it must be prefixed with at least one 0.
1048 The function will ignore the pad space, which includes spaces or tab characters,
1049 before [zeros], [x] or [hexadecimal digit]. The running zero before [x] or
1050 [hexadecimal digit] will be ignored. Then, the decoding starts after [x] or the
1051 first valid hexadecimal digit. Then, the function stops at the first character that is
1052 a not a valid hexadecimal character or NULL, whichever one comes first.
1054 If String is NULL, then ASSERT().
1055 If String is not aligned in a 16-bit boundary, then ASSERT().
1056 If String has only pad spaces, then zero is returned.
1057 If String has no leading pad spaces, leading zeros or valid hexadecimal digits,
1058 then zero is returned.
1059 If the number represented by String overflows according to the range defined by
1060 UINT64, then ASSERT().
1062 If PcdMaximumUnicodeStringLength is not zero, and String contains more than
1063 PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator,
1066 @param String The pointer to a Null-terminated Unicode string.
1068 @retval Value translated from String.
1074 IN CONST CHAR16
*String
1077 #ifndef DISABLE_NEW_DEPRECATED_INTERFACES
1080 [ATTENTION] This function is deprecated for security reason.
1082 Convert a Null-terminated Unicode string to a Null-terminated
1083 ASCII string and returns the ASCII string.
1085 This function converts the content of the Unicode string Source
1086 to the ASCII string Destination by copying the lower 8 bits of
1087 each Unicode character. It returns Destination.
1089 The caller is responsible to make sure Destination points to a buffer with size
1090 equal or greater than ((StrLen (Source) + 1) * sizeof (CHAR8)) in bytes.
1092 If any Unicode characters in Source contain non-zero value in
1093 the upper 8 bits, then ASSERT().
1095 If Destination is NULL, then ASSERT().
1096 If Source is NULL, then ASSERT().
1097 If Source is not aligned on a 16-bit boundary, then ASSERT().
1098 If Source and Destination overlap, then ASSERT().
1100 If PcdMaximumUnicodeStringLength is not zero, and Source contains
1101 more than PcdMaximumUnicodeStringLength Unicode characters not including
1102 the Null-terminator, then ASSERT().
1104 If PcdMaximumAsciiStringLength is not zero, and Source contains more
1105 than PcdMaximumAsciiStringLength Unicode characters not including the
1106 Null-terminator, then ASSERT().
1108 @param Source The pointer to a Null-terminated Unicode string.
1109 @param Destination The pointer to a Null-terminated ASCII string.
1111 @return Destination.
1116 UnicodeStrToAsciiStr (
1117 IN CONST CHAR16
*Source
,
1118 OUT CHAR8
*Destination
1124 Convert a Null-terminated Unicode string to a Null-terminated
1127 This function is similar to AsciiStrCpyS.
1129 This function converts the content of the Unicode string Source
1130 to the ASCII string Destination by copying the lower 8 bits of
1131 each Unicode character. The function terminates the ASCII string
1132 Destination by appending a Null-terminator character at the end.
1134 The caller is responsible to make sure Destination points to a buffer with size
1135 equal or greater than ((StrLen (Source) + 1) * sizeof (CHAR8)) in bytes.
1137 If any Unicode characters in Source contain non-zero value in
1138 the upper 8 bits, then ASSERT().
1140 If Source is not aligned on a 16-bit boundary, then ASSERT().
1141 If an error would be returned, then the function will also ASSERT().
1143 If an error is returned, then the Destination is unmodified.
1145 @param Source The pointer to a Null-terminated Unicode string.
1146 @param Destination The pointer to a Null-terminated ASCII string.
1147 @param DestMax The maximum number of Destination Ascii
1148 char, including terminating null char.
1150 @retval RETURN_SUCCESS String is converted.
1151 @retval RETURN_BUFFER_TOO_SMALL If DestMax is NOT greater than StrLen(Source).
1152 @retval RETURN_INVALID_PARAMETER If Destination is NULL.
1154 If PcdMaximumAsciiStringLength is not zero,
1155 and DestMax is greater than
1156 PcdMaximumAsciiStringLength.
1157 If PcdMaximumUnicodeStringLength is not zero,
1158 and DestMax is greater than
1159 PcdMaximumUnicodeStringLength.
1161 @retval RETURN_ACCESS_DENIED If Source and Destination overlap.
1166 UnicodeStrToAsciiStrS (
1167 IN CONST CHAR16
*Source
,
1168 OUT CHAR8
*Destination
,
1172 #ifndef DISABLE_NEW_DEPRECATED_INTERFACES
1175 [ATTENTION] This function is deprecated for security reason.
1177 Copies one Null-terminated ASCII string to another Null-terminated ASCII
1178 string and returns the new ASCII string.
1180 This function copies the contents of the ASCII string Source to the ASCII
1181 string Destination, and returns Destination. If Source and Destination
1182 overlap, then the results are undefined.
1184 If Destination is NULL, then ASSERT().
1185 If Source is NULL, then ASSERT().
1186 If Source and Destination overlap, then ASSERT().
1187 If PcdMaximumAsciiStringLength is not zero and Source contains more than
1188 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
1191 @param Destination The pointer to a Null-terminated ASCII string.
1192 @param Source The pointer to a Null-terminated ASCII string.
1200 OUT CHAR8
*Destination
,
1201 IN CONST CHAR8
*Source
1206 [ATTENTION] This function is deprecated for security reason.
1208 Copies up to a specified length one Null-terminated ASCII string to another
1209 Null-terminated ASCII string and returns the new ASCII string.
1211 This function copies the contents of the ASCII string Source to the ASCII
1212 string Destination, and returns Destination. At most, Length ASCII characters
1213 are copied from Source to Destination. If Length is 0, then Destination is
1214 returned unmodified. If Length is greater that the number of ASCII characters
1215 in Source, then Destination is padded with Null ASCII characters. If Source
1216 and Destination overlap, then the results are undefined.
1218 If Destination is NULL, then ASSERT().
1219 If Source is NULL, then ASSERT().
1220 If Source and Destination overlap, then ASSERT().
1221 If PcdMaximumAsciiStringLength is not zero, and Length is greater than
1222 PcdMaximumAsciiStringLength, then ASSERT().
1223 If PcdMaximumAsciiStringLength is not zero, and Source contains more than
1224 PcdMaximumAsciiStringLength ASCII characters, not including the Null-terminator,
1227 @param Destination The pointer to a Null-terminated ASCII string.
1228 @param Source The pointer to a Null-terminated ASCII string.
1229 @param Length The maximum number of ASCII characters to copy.
1237 OUT CHAR8
*Destination
,
1238 IN CONST CHAR8
*Source
,
1244 Returns the length of a Null-terminated ASCII string.
1246 This function returns the number of ASCII characters in the Null-terminated
1247 ASCII string specified by String.
1249 If Length > 0 and Destination is NULL, then ASSERT().
1250 If Length > 0 and Source is NULL, then ASSERT().
1251 If PcdMaximumAsciiStringLength is not zero and String contains more than
1252 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
1255 @param String The pointer to a Null-terminated ASCII string.
1257 @return The length of String.
1263 IN CONST CHAR8
*String
1268 Returns the size of a Null-terminated ASCII string in bytes, including the
1271 This function returns the size, in bytes, of the Null-terminated ASCII string
1272 specified by String.
1274 If String is NULL, then ASSERT().
1275 If PcdMaximumAsciiStringLength is not zero and String contains more than
1276 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
1279 @param String The pointer to a Null-terminated ASCII string.
1281 @return The size of String.
1287 IN CONST CHAR8
*String
1292 Compares two Null-terminated ASCII strings, and returns the difference
1293 between the first mismatched ASCII characters.
1295 This function compares the Null-terminated ASCII string FirstString to the
1296 Null-terminated ASCII string SecondString. If FirstString is identical to
1297 SecondString, then 0 is returned. Otherwise, the value returned is the first
1298 mismatched ASCII character in SecondString subtracted from the first
1299 mismatched ASCII character in FirstString.
1301 If FirstString is NULL, then ASSERT().
1302 If SecondString is NULL, then ASSERT().
1303 If PcdMaximumAsciiStringLength is not zero and FirstString contains more than
1304 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
1306 If PcdMaximumAsciiStringLength is not zero and SecondString contains more
1307 than PcdMaximumAsciiStringLength ASCII characters not including the
1308 Null-terminator, then ASSERT().
1310 @param FirstString The pointer to a Null-terminated ASCII string.
1311 @param SecondString The pointer to a Null-terminated ASCII string.
1313 @retval ==0 FirstString is identical to SecondString.
1314 @retval !=0 FirstString is not identical to SecondString.
1320 IN CONST CHAR8
*FirstString
,
1321 IN CONST CHAR8
*SecondString
1326 Performs a case insensitive comparison of two Null-terminated ASCII strings,
1327 and returns the difference between the first mismatched ASCII characters.
1329 This function performs a case insensitive comparison of the Null-terminated
1330 ASCII string FirstString to the Null-terminated ASCII string SecondString. If
1331 FirstString is identical to SecondString, then 0 is returned. Otherwise, the
1332 value returned is the first mismatched lower case ASCII character in
1333 SecondString subtracted from the first mismatched lower case ASCII character
1336 If FirstString is NULL, then ASSERT().
1337 If SecondString is NULL, then ASSERT().
1338 If PcdMaximumAsciiStringLength is not zero and FirstString contains more than
1339 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
1341 If PcdMaximumAsciiStringLength is not zero and SecondString contains more
1342 than PcdMaximumAsciiStringLength ASCII characters not including the
1343 Null-terminator, then ASSERT().
1345 @param FirstString The pointer to a Null-terminated ASCII string.
1346 @param SecondString The pointer to a Null-terminated ASCII string.
1348 @retval ==0 FirstString is identical to SecondString using case insensitive
1350 @retval !=0 FirstString is not identical to SecondString using case
1351 insensitive comparisons.
1357 IN CONST CHAR8
*FirstString
,
1358 IN CONST CHAR8
*SecondString
1363 Compares two Null-terminated ASCII strings with maximum lengths, and returns
1364 the difference between the first mismatched ASCII characters.
1366 This function compares the Null-terminated ASCII string FirstString to the
1367 Null-terminated ASCII string SecondString. At most, Length ASCII characters
1368 will be compared. If Length is 0, then 0 is returned. If FirstString is
1369 identical to SecondString, then 0 is returned. Otherwise, the value returned
1370 is the first mismatched ASCII character in SecondString subtracted from the
1371 first mismatched ASCII character in FirstString.
1373 If Length > 0 and FirstString is NULL, then ASSERT().
1374 If Length > 0 and SecondString is NULL, then ASSERT().
1375 If PcdMaximumAsciiStringLength is not zero, and Length is greater than
1376 PcdMaximumAsciiStringLength, then ASSERT().
1377 If PcdMaximumAsciiStringLength is not zero, and FirstString contains more than
1378 PcdMaximumAsciiStringLength ASCII characters, not including the Null-terminator,
1380 If PcdMaximumAsciiStringLength is not zero, and SecondString contains more than
1381 PcdMaximumAsciiStringLength ASCII characters, not including the Null-terminator,
1384 @param FirstString The pointer to a Null-terminated ASCII string.
1385 @param SecondString The pointer to a Null-terminated ASCII string.
1386 @param Length The maximum number of ASCII characters for compare.
1388 @retval ==0 FirstString is identical to SecondString.
1389 @retval !=0 FirstString is not identical to SecondString.
1395 IN CONST CHAR8
*FirstString
,
1396 IN CONST CHAR8
*SecondString
,
1401 #ifndef DISABLE_NEW_DEPRECATED_INTERFACES
1404 [ATTENTION] This function is deprecated for security reason.
1406 Concatenates one Null-terminated ASCII string to another Null-terminated
1407 ASCII string, and returns the concatenated ASCII string.
1409 This function concatenates two Null-terminated ASCII strings. The contents of
1410 Null-terminated ASCII string Source are concatenated to the end of Null-
1411 terminated ASCII string Destination. The Null-terminated concatenated ASCII
1414 If Destination is NULL, then ASSERT().
1415 If Source is NULL, then ASSERT().
1416 If PcdMaximumAsciiStringLength is not zero and Destination contains more than
1417 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
1419 If PcdMaximumAsciiStringLength is not zero and Source contains more than
1420 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
1422 If PcdMaximumAsciiStringLength is not zero and concatenating Destination and
1423 Source results in a ASCII string with more than PcdMaximumAsciiStringLength
1424 ASCII characters, then ASSERT().
1426 @param Destination The pointer to a Null-terminated ASCII string.
1427 @param Source The pointer to a Null-terminated ASCII string.
1435 IN OUT CHAR8
*Destination
,
1436 IN CONST CHAR8
*Source
1441 [ATTENTION] This function is deprecated for security reason.
1443 Concatenates up to a specified length one Null-terminated ASCII string to
1444 the end of another Null-terminated ASCII string, and returns the
1445 concatenated ASCII string.
1447 This function concatenates two Null-terminated ASCII strings. The contents
1448 of Null-terminated ASCII string Source are concatenated to the end of Null-
1449 terminated ASCII string Destination, and Destination is returned. At most,
1450 Length ASCII characters are concatenated from Source to the end of
1451 Destination, and Destination is always Null-terminated. If Length is 0, then
1452 Destination is returned unmodified. If Source and Destination overlap, then
1453 the results are undefined.
1455 If Length > 0 and Destination is NULL, then ASSERT().
1456 If Length > 0 and Source is NULL, then ASSERT().
1457 If Source and Destination overlap, then ASSERT().
1458 If PcdMaximumAsciiStringLength is not zero, and Length is greater than
1459 PcdMaximumAsciiStringLength, then ASSERT().
1460 If PcdMaximumAsciiStringLength is not zero, and Destination contains more than
1461 PcdMaximumAsciiStringLength ASCII characters, not including the Null-terminator,
1463 If PcdMaximumAsciiStringLength is not zero, and Source contains more than
1464 PcdMaximumAsciiStringLength ASCII characters, not including the Null-terminator,
1466 If PcdMaximumAsciiStringLength is not zero, and concatenating Destination and
1467 Source results in a ASCII string with more than PcdMaximumAsciiStringLength
1468 ASCII characters, not including the Null-terminator, then ASSERT().
1470 @param Destination The pointer to a Null-terminated ASCII string.
1471 @param Source The pointer to a Null-terminated ASCII string.
1472 @param Length The maximum number of ASCII characters to concatenate from
1481 IN OUT CHAR8
*Destination
,
1482 IN CONST CHAR8
*Source
,
1488 Returns the first occurrence of a Null-terminated ASCII sub-string
1489 in a Null-terminated ASCII string.
1491 This function scans the contents of the ASCII string specified by String
1492 and returns the first occurrence of SearchString. If SearchString is not
1493 found in String, then NULL is returned. If the length of SearchString is zero,
1494 then String is returned.
1496 If String is NULL, then ASSERT().
1497 If SearchString is NULL, then ASSERT().
1499 If PcdMaximumAsciiStringLength is not zero, and SearchString or
1500 String contains more than PcdMaximumAsciiStringLength Unicode characters
1501 not including the Null-terminator, then ASSERT().
1503 @param String The pointer to a Null-terminated ASCII string.
1504 @param SearchString The pointer to a Null-terminated ASCII string to search for.
1506 @retval NULL If the SearchString does not appear in String.
1507 @retval others If there is a match return the first occurrence of SearchingString.
1508 If the length of SearchString is zero,return String.
1514 IN CONST CHAR8
*String
,
1515 IN CONST CHAR8
*SearchString
1520 Convert a Null-terminated ASCII decimal string to a value of type
1523 This function returns a value of type UINTN by interpreting the contents
1524 of the ASCII string String as a decimal number. The format of the input
1525 ASCII string String is:
1527 [spaces] [decimal digits].
1529 The valid decimal digit character is in the range [0-9]. The function will
1530 ignore the pad space, which includes spaces or tab characters, before the digits.
1531 The running zero in the beginning of [decimal digits] will be ignored. Then, the
1532 function stops at the first character that is a not a valid decimal character or
1533 Null-terminator, whichever on comes first.
1535 If String has only pad spaces, then 0 is returned.
1536 If String has no pad spaces or valid decimal digits, then 0 is returned.
1537 If the number represented by String overflows according to the range defined by
1538 UINTN, then ASSERT().
1539 If String is NULL, then ASSERT().
1540 If PcdMaximumAsciiStringLength is not zero, and String contains more than
1541 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
1544 @param String The pointer to a Null-terminated ASCII string.
1546 @retval The value translated from String.
1551 AsciiStrDecimalToUintn (
1552 IN CONST CHAR8
*String
1557 Convert a Null-terminated ASCII decimal string to a value of type
1560 This function returns a value of type UINT64 by interpreting the contents
1561 of the ASCII string String as a decimal number. The format of the input
1562 ASCII string String is:
1564 [spaces] [decimal digits].
1566 The valid decimal digit character is in the range [0-9]. The function will
1567 ignore the pad space, which includes spaces or tab characters, before the digits.
1568 The running zero in the beginning of [decimal digits] will be ignored. Then, the
1569 function stops at the first character that is a not a valid decimal character or
1570 Null-terminator, whichever on comes first.
1572 If String has only pad spaces, then 0 is returned.
1573 If String has no pad spaces or valid decimal digits, then 0 is returned.
1574 If the number represented by String overflows according to the range defined by
1575 UINT64, then ASSERT().
1576 If String is NULL, then ASSERT().
1577 If PcdMaximumAsciiStringLength is not zero, and String contains more than
1578 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
1581 @param String The pointer to a Null-terminated ASCII string.
1583 @retval Value translated from String.
1588 AsciiStrDecimalToUint64 (
1589 IN CONST CHAR8
*String
1594 Convert a Null-terminated ASCII hexadecimal string to a value of type UINTN.
1596 This function returns a value of type UINTN by interpreting the contents of
1597 the ASCII string String as a hexadecimal number. The format of the input ASCII
1600 [spaces][zeros][x][hexadecimal digits].
1602 The valid hexadecimal digit character is in the range [0-9], [a-f] and [A-F].
1603 The prefix "0x" is optional. Both "x" and "X" is allowed in "0x" prefix. If "x"
1604 appears in the input string, it must be prefixed with at least one 0. The function
1605 will ignore the pad space, which includes spaces or tab characters, before [zeros],
1606 [x] or [hexadecimal digits]. The running zero before [x] or [hexadecimal digits]
1607 will be ignored. Then, the decoding starts after [x] or the first valid hexadecimal
1608 digit. Then, the function stops at the first character that is a not a valid
1609 hexadecimal character or Null-terminator, whichever on comes first.
1611 If String has only pad spaces, then 0 is returned.
1612 If String has no leading pad spaces, leading zeros or valid hexadecimal digits, then
1615 If the number represented by String overflows according to the range defined by UINTN,
1617 If String is NULL, then ASSERT().
1618 If PcdMaximumAsciiStringLength is not zero,
1619 and String contains more than PcdMaximumAsciiStringLength ASCII characters not including
1620 the Null-terminator, then ASSERT().
1622 @param String The pointer to a Null-terminated ASCII string.
1624 @retval Value translated from String.
1629 AsciiStrHexToUintn (
1630 IN CONST CHAR8
*String
1635 Convert a Null-terminated ASCII hexadecimal string to a value of type UINT64.
1637 This function returns a value of type UINT64 by interpreting the contents of
1638 the ASCII string String as a hexadecimal number. The format of the input ASCII
1641 [spaces][zeros][x][hexadecimal digits].
1643 The valid hexadecimal digit character is in the range [0-9], [a-f] and [A-F].
1644 The prefix "0x" is optional. Both "x" and "X" is allowed in "0x" prefix. If "x"
1645 appears in the input string, it must be prefixed with at least one 0. The function
1646 will ignore the pad space, which includes spaces or tab characters, before [zeros],
1647 [x] or [hexadecimal digits]. The running zero before [x] or [hexadecimal digits]
1648 will be ignored. Then, the decoding starts after [x] or the first valid hexadecimal
1649 digit. Then, the function stops at the first character that is a not a valid
1650 hexadecimal character or Null-terminator, whichever on comes first.
1652 If String has only pad spaces, then 0 is returned.
1653 If String has no leading pad spaces, leading zeros or valid hexadecimal digits, then
1656 If the number represented by String overflows according to the range defined by UINT64,
1658 If String is NULL, then ASSERT().
1659 If PcdMaximumAsciiStringLength is not zero,
1660 and String contains more than PcdMaximumAsciiStringLength ASCII characters not including
1661 the Null-terminator, then ASSERT().
1663 @param String The pointer to a Null-terminated ASCII string.
1665 @retval Value translated from String.
1670 AsciiStrHexToUint64 (
1671 IN CONST CHAR8
*String
1674 #ifndef DISABLE_NEW_DEPRECATED_INTERFACES
1677 [ATTENTION] This function is deprecated for security reason.
1679 Convert one Null-terminated ASCII string to a Null-terminated
1680 Unicode string and returns the Unicode string.
1682 This function converts the contents of the ASCII string Source to the Unicode
1683 string Destination, and returns Destination. The function terminates the
1684 Unicode string Destination by appending a Null-terminator character at the end.
1685 The caller is responsible to make sure Destination points to a buffer with size
1686 equal or greater than ((AsciiStrLen (Source) + 1) * sizeof (CHAR16)) in bytes.
1688 If Destination is NULL, then ASSERT().
1689 If Destination is not aligned on a 16-bit boundary, then ASSERT().
1690 If Source is NULL, then ASSERT().
1691 If Source and Destination overlap, then ASSERT().
1692 If PcdMaximumAsciiStringLength is not zero, and Source contains more than
1693 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
1695 If PcdMaximumUnicodeStringLength is not zero, and Source contains more than
1696 PcdMaximumUnicodeStringLength ASCII characters not including the
1697 Null-terminator, then ASSERT().
1699 @param Source The pointer to a Null-terminated ASCII string.
1700 @param Destination The pointer to a Null-terminated Unicode string.
1702 @return Destination.
1707 AsciiStrToUnicodeStr (
1708 IN CONST CHAR8
*Source
,
1709 OUT CHAR16
*Destination
1715 Convert one Null-terminated ASCII string to a Null-terminated
1718 This function is similar to StrCpyS.
1720 This function converts the contents of the ASCII string Source to the Unicode
1721 string Destination. The function terminates the Unicode string Destination by
1722 appending a Null-terminator character at the end.
1724 The caller is responsible to make sure Destination points to a buffer with size
1725 equal or greater than ((AsciiStrLen (Source) + 1) * sizeof (CHAR16)) in bytes.
1727 If Destination is not aligned on a 16-bit boundary, then ASSERT().
1728 If an error would be returned, then the function will also ASSERT().
1730 If an error is returned, then the Destination is unmodified.
1732 @param Source The pointer to a Null-terminated ASCII string.
1733 @param Destination The pointer to a Null-terminated Unicode string.
1734 @param DestMax The maximum number of Destination Unicode
1735 char, including terminating null char.
1737 @retval RETURN_SUCCESS String is converted.
1738 @retval RETURN_BUFFER_TOO_SMALL If DestMax is NOT greater than StrLen(Source).
1739 @retval RETURN_INVALID_PARAMETER If Destination is NULL.
1741 If PcdMaximumUnicodeStringLength is not zero,
1742 and DestMax is greater than
1743 PcdMaximumUnicodeStringLength.
1744 If PcdMaximumAsciiStringLength is not zero,
1745 and DestMax is greater than
1746 PcdMaximumAsciiStringLength.
1748 @retval RETURN_ACCESS_DENIED If Source and Destination overlap.
1753 AsciiStrToUnicodeStrS (
1754 IN CONST CHAR8
*Source
,
1755 OUT CHAR16
*Destination
,
1760 Converts an 8-bit value to an 8-bit BCD value.
1762 Converts the 8-bit value specified by Value to BCD. The BCD value is
1765 If Value >= 100, then ASSERT().
1767 @param Value The 8-bit value to convert to BCD. Range 0..99.
1769 @return The BCD value.
1780 Converts an 8-bit BCD value to an 8-bit value.
1782 Converts the 8-bit BCD value specified by Value to an 8-bit value. The 8-bit
1785 If Value >= 0xA0, then ASSERT().
1786 If (Value & 0x0F) >= 0x0A, then ASSERT().
1788 @param Value The 8-bit BCD value to convert to an 8-bit value.
1790 @return The 8-bit value is returned.
1800 // File Path Manipulation Functions
1804 Removes the last directory or file entry in a path.
1806 @param[in, out] Path The pointer to the path to modify.
1808 @retval FALSE Nothing was found to remove.
1809 @retval TRUE A directory or file was removed.
1818 Function to clean up paths.
1819 - Single periods in the path are removed.
1820 - Double periods in the path are removed along with a single parent directory.
1821 - Forward slashes L'/' are converted to backward slashes L'\'.
1823 This will be done inline and the existing buffer may be larger than required
1826 @param[in] Path The pointer to the string containing the path.
1828 @return Returns Path, otherwise returns NULL to indicate that an error has occurred.
1832 PathCleanUpDirectories(
1837 // Linked List Functions and Macros
1841 Initializes the head node of a doubly linked list that is declared as a
1842 global variable in a module.
1844 Initializes the forward and backward links of a new linked list. After
1845 initializing a linked list with this macro, the other linked list functions
1846 may be used to add and remove nodes from the linked list. This macro results
1847 in smaller executables by initializing the linked list in the data section,
1848 instead if calling the InitializeListHead() function to perform the
1849 equivalent operation.
1851 @param ListHead The head note of a list to initialize.
1854 #define INITIALIZE_LIST_HEAD_VARIABLE(ListHead) {&(ListHead), &(ListHead)}
1858 Initializes the head node of a doubly linked list, and returns the pointer to
1859 the head node of the doubly linked list.
1861 Initializes the forward and backward links of a new linked list. After
1862 initializing a linked list with this function, the other linked list
1863 functions may be used to add and remove nodes from the linked list. It is up
1864 to the caller of this function to allocate the memory for ListHead.
1866 If ListHead is NULL, then ASSERT().
1868 @param ListHead A pointer to the head node of a new doubly linked list.
1875 InitializeListHead (
1876 IN OUT LIST_ENTRY
*ListHead
1881 Adds a node to the beginning of a doubly linked list, and returns the pointer
1882 to the head node of the doubly linked list.
1884 Adds the node Entry at the beginning of the doubly linked list denoted by
1885 ListHead, and returns ListHead.
1887 If ListHead is NULL, then ASSERT().
1888 If Entry is NULL, then ASSERT().
1889 If ListHead was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or
1890 InitializeListHead(), then ASSERT().
1891 If PcdMaximumLinkedListLength is not zero, and prior to insertion the number
1892 of nodes in ListHead, including the ListHead node, is greater than or
1893 equal to PcdMaximumLinkedListLength, then ASSERT().
1895 @param ListHead A pointer to the head node of a doubly linked list.
1896 @param Entry A pointer to a node that is to be inserted at the beginning
1897 of a doubly linked list.
1905 IN OUT LIST_ENTRY
*ListHead
,
1906 IN OUT LIST_ENTRY
*Entry
1911 Adds a node to the end of a doubly linked list, and returns the pointer to
1912 the head node of the doubly linked list.
1914 Adds the node Entry to the end of the doubly linked list denoted by ListHead,
1915 and returns ListHead.
1917 If ListHead is NULL, then ASSERT().
1918 If Entry is NULL, then ASSERT().
1919 If ListHead was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or
1920 InitializeListHead(), then ASSERT().
1921 If PcdMaximumLinkedListLength is not zero, and prior to insertion the number
1922 of nodes in ListHead, including the ListHead node, is greater than or
1923 equal to PcdMaximumLinkedListLength, then ASSERT().
1925 @param ListHead A pointer to the head node of a doubly linked list.
1926 @param Entry A pointer to a node that is to be added at the end of the
1935 IN OUT LIST_ENTRY
*ListHead
,
1936 IN OUT LIST_ENTRY
*Entry
1941 Retrieves the first node of a doubly linked list.
1943 Returns the first node of a doubly linked list. List must have been
1944 initialized with INTIALIZE_LIST_HEAD_VARIABLE() or InitializeListHead().
1945 If List is empty, then List is returned.
1947 If List is NULL, then ASSERT().
1948 If List was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or
1949 InitializeListHead(), then ASSERT().
1950 If PcdMaximumLinkedListLength is not zero, and the number of nodes
1951 in List, including the List node, is greater than or equal to
1952 PcdMaximumLinkedListLength, then ASSERT().
1954 @param List A pointer to the head node of a doubly linked list.
1956 @return The first node of a doubly linked list.
1957 @retval List The list is empty.
1963 IN CONST LIST_ENTRY
*List
1968 Retrieves the next node of a doubly linked list.
1970 Returns the node of a doubly linked list that follows Node.
1971 List must have been initialized with INTIALIZE_LIST_HEAD_VARIABLE()
1972 or InitializeListHead(). If List is empty, then List is returned.
1974 If List is NULL, then ASSERT().
1975 If Node is NULL, then ASSERT().
1976 If List was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or
1977 InitializeListHead(), then ASSERT().
1978 If PcdMaximumLinkedListLength is not zero, and List contains more than
1979 PcdMaximumLinkedListLength nodes, then ASSERT().
1980 If PcdVerifyNodeInList is TRUE and Node is not a node in List, then ASSERT().
1982 @param List A pointer to the head node of a doubly linked list.
1983 @param Node A pointer to a node in the doubly linked list.
1985 @return The pointer to the next node if one exists. Otherwise List is returned.
1991 IN CONST LIST_ENTRY
*List
,
1992 IN CONST LIST_ENTRY
*Node
1997 Retrieves the previous node of a doubly linked list.
1999 Returns the node of a doubly linked list that precedes Node.
2000 List must have been initialized with INTIALIZE_LIST_HEAD_VARIABLE()
2001 or InitializeListHead(). If List is empty, then List is returned.
2003 If List is NULL, then ASSERT().
2004 If Node is NULL, then ASSERT().
2005 If List was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or
2006 InitializeListHead(), then ASSERT().
2007 If PcdMaximumLinkedListLength is not zero, and List contains more than
2008 PcdMaximumLinkedListLength nodes, then ASSERT().
2009 If PcdVerifyNodeInList is TRUE and Node is not a node in List, then ASSERT().
2011 @param List A pointer to the head node of a doubly linked list.
2012 @param Node A pointer to a node in the doubly linked list.
2014 @return The pointer to the previous node if one exists. Otherwise List is returned.
2020 IN CONST LIST_ENTRY
*List
,
2021 IN CONST LIST_ENTRY
*Node
2026 Checks to see if a doubly linked list is empty or not.
2028 Checks to see if the doubly linked list is empty. If the linked list contains
2029 zero nodes, this function returns TRUE. Otherwise, it returns FALSE.
2031 If ListHead is NULL, then ASSERT().
2032 If ListHead was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or
2033 InitializeListHead(), then ASSERT().
2034 If PcdMaximumLinkedListLength is not zero, and the number of nodes
2035 in List, including the List node, is greater than or equal to
2036 PcdMaximumLinkedListLength, then ASSERT().
2038 @param ListHead A pointer to the head node of a doubly linked list.
2040 @retval TRUE The linked list is empty.
2041 @retval FALSE The linked list is not empty.
2047 IN CONST LIST_ENTRY
*ListHead
2052 Determines if a node in a doubly linked list is the head node of a the same
2053 doubly linked list. This function is typically used to terminate a loop that
2054 traverses all the nodes in a doubly linked list starting with the head node.
2056 Returns TRUE if Node is equal to List. Returns FALSE if Node is one of the
2057 nodes in the doubly linked list specified by List. List must have been
2058 initialized with INTIALIZE_LIST_HEAD_VARIABLE() or InitializeListHead().
2060 If List is NULL, then ASSERT().
2061 If Node is NULL, then ASSERT().
2062 If List was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or InitializeListHead(),
2064 If PcdMaximumLinkedListLength is not zero, and the number of nodes
2065 in List, including the List node, is greater than or equal to
2066 PcdMaximumLinkedListLength, then ASSERT().
2067 If PcdVerifyNodeInList is TRUE and Node is not a node in List the and Node is not equal
2068 to List, then ASSERT().
2070 @param List A pointer to the head node of a doubly linked list.
2071 @param Node A pointer to a node in the doubly linked list.
2073 @retval TRUE Node is the head of the doubly-linked list pointed by List.
2074 @retval FALSE Node is not the head of the doubly-linked list pointed by List.
2080 IN CONST LIST_ENTRY
*List
,
2081 IN CONST LIST_ENTRY
*Node
2086 Determines if a node the last node in a doubly linked list.
2088 Returns TRUE if Node is the last node in the doubly linked list specified by
2089 List. Otherwise, FALSE is returned. List must have been initialized with
2090 INTIALIZE_LIST_HEAD_VARIABLE() or InitializeListHead().
2092 If List is NULL, then ASSERT().
2093 If Node is NULL, then ASSERT().
2094 If List was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or
2095 InitializeListHead(), then ASSERT().
2096 If PcdMaximumLinkedListLength is not zero, and the number of nodes
2097 in List, including the List node, is greater than or equal to
2098 PcdMaximumLinkedListLength, then ASSERT().
2099 If PcdVerifyNodeInList is TRUE and Node is not a node in List, then ASSERT().
2101 @param List A pointer to the head node of a doubly linked list.
2102 @param Node A pointer to a node in the doubly linked list.
2104 @retval TRUE Node is the last node in the linked list.
2105 @retval FALSE Node is not the last node in the linked list.
2111 IN CONST LIST_ENTRY
*List
,
2112 IN CONST LIST_ENTRY
*Node
2117 Swaps the location of two nodes in a doubly linked list, and returns the
2118 first node after the swap.
2120 If FirstEntry is identical to SecondEntry, then SecondEntry is returned.
2121 Otherwise, the location of the FirstEntry node is swapped with the location
2122 of the SecondEntry node in a doubly linked list. SecondEntry must be in the
2123 same double linked list as FirstEntry and that double linked list must have
2124 been initialized with INTIALIZE_LIST_HEAD_VARIABLE() or InitializeListHead().
2125 SecondEntry is returned after the nodes are swapped.
2127 If FirstEntry is NULL, then ASSERT().
2128 If SecondEntry is NULL, then ASSERT().
2129 If PcdVerifyNodeInList is TRUE and SecondEntry and FirstEntry are not in the
2130 same linked list, then ASSERT().
2131 If PcdMaximumLinkedListLength is not zero, and the number of nodes in the
2132 linked list containing the FirstEntry and SecondEntry nodes, including
2133 the FirstEntry and SecondEntry nodes, is greater than or equal to
2134 PcdMaximumLinkedListLength, then ASSERT().
2136 @param FirstEntry A pointer to a node in a linked list.
2137 @param SecondEntry A pointer to another node in the same linked list.
2139 @return SecondEntry.
2145 IN OUT LIST_ENTRY
*FirstEntry
,
2146 IN OUT LIST_ENTRY
*SecondEntry
2151 Removes a node from a doubly linked list, and returns the node that follows
2154 Removes the node Entry from a doubly linked list. It is up to the caller of
2155 this function to release the memory used by this node if that is required. On
2156 exit, the node following Entry in the doubly linked list is returned. If
2157 Entry is the only node in the linked list, then the head node of the linked
2160 If Entry is NULL, then ASSERT().
2161 If Entry is the head node of an empty list, then ASSERT().
2162 If PcdMaximumLinkedListLength is not zero, and the number of nodes in the
2163 linked list containing Entry, including the Entry node, is greater than
2164 or equal to PcdMaximumLinkedListLength, then ASSERT().
2166 @param Entry A pointer to a node in a linked list.
2174 IN CONST LIST_ENTRY
*Entry
2182 Shifts a 64-bit integer left between 0 and 63 bits. The low bits are filled
2183 with zeros. The shifted value is returned.
2185 This function shifts the 64-bit value Operand to the left by Count bits. The
2186 low Count bits are set to zero. The shifted value is returned.
2188 If Count is greater than 63, then ASSERT().
2190 @param Operand The 64-bit operand to shift left.
2191 @param Count The number of bits to shift left.
2193 @return Operand << Count.
2205 Shifts a 64-bit integer right between 0 and 63 bits. This high bits are
2206 filled with zeros. The shifted value is returned.
2208 This function shifts the 64-bit value Operand to the right by Count bits. The
2209 high Count bits are set to zero. The shifted value is returned.
2211 If Count is greater than 63, then ASSERT().
2213 @param Operand The 64-bit operand to shift right.
2214 @param Count The number of bits to shift right.
2216 @return Operand >> Count
2228 Shifts a 64-bit integer right between 0 and 63 bits. The high bits are filled
2229 with original integer's bit 63. The shifted value is returned.
2231 This function shifts the 64-bit value Operand to the right by Count bits. The
2232 high Count bits are set to bit 63 of Operand. The shifted value is returned.
2234 If Count is greater than 63, then ASSERT().
2236 @param Operand The 64-bit operand to shift right.
2237 @param Count The number of bits to shift right.
2239 @return Operand >> Count
2251 Rotates a 32-bit integer left between 0 and 31 bits, filling the low bits
2252 with the high bits that were rotated.
2254 This function rotates the 32-bit value Operand to the left by Count bits. The
2255 low Count bits are fill with the high Count bits of Operand. The rotated
2258 If Count is greater than 31, then ASSERT().
2260 @param Operand The 32-bit operand to rotate left.
2261 @param Count The number of bits to rotate left.
2263 @return Operand << Count
2275 Rotates a 32-bit integer right between 0 and 31 bits, filling the high bits
2276 with the low bits that were rotated.
2278 This function rotates the 32-bit value Operand to the right by Count bits.
2279 The high Count bits are fill with the low Count bits of Operand. The rotated
2282 If Count is greater than 31, then ASSERT().
2284 @param Operand The 32-bit operand to rotate right.
2285 @param Count The number of bits to rotate right.
2287 @return Operand >> Count
2299 Rotates a 64-bit integer left between 0 and 63 bits, filling the low bits
2300 with the high bits that were rotated.
2302 This function rotates the 64-bit value Operand to the left by Count bits. The
2303 low Count bits are fill with the high Count bits of Operand. The rotated
2306 If Count is greater than 63, then ASSERT().
2308 @param Operand The 64-bit operand to rotate left.
2309 @param Count The number of bits to rotate left.
2311 @return Operand << Count
2323 Rotates a 64-bit integer right between 0 and 63 bits, filling the high bits
2324 with the high low bits that were rotated.
2326 This function rotates the 64-bit value Operand to the right by Count bits.
2327 The high Count bits are fill with the low Count bits of Operand. The rotated
2330 If Count is greater than 63, then ASSERT().
2332 @param Operand The 64-bit operand to rotate right.
2333 @param Count The number of bits to rotate right.
2335 @return Operand >> Count
2347 Returns the bit position of the lowest bit set in a 32-bit value.
2349 This function computes the bit position of the lowest bit set in the 32-bit
2350 value specified by Operand. If Operand is zero, then -1 is returned.
2351 Otherwise, a value between 0 and 31 is returned.
2353 @param Operand The 32-bit operand to evaluate.
2355 @retval 0..31 The lowest bit set in Operand was found.
2356 @retval -1 Operand is zero.
2367 Returns the bit position of the lowest bit set in a 64-bit value.
2369 This function computes the bit position of the lowest bit set in the 64-bit
2370 value specified by Operand. If Operand is zero, then -1 is returned.
2371 Otherwise, a value between 0 and 63 is returned.
2373 @param Operand The 64-bit operand to evaluate.
2375 @retval 0..63 The lowest bit set in Operand was found.
2376 @retval -1 Operand is zero.
2388 Returns the bit position of the highest bit set in a 32-bit value. Equivalent
2391 This function computes the bit position of the highest bit set in the 32-bit
2392 value specified by Operand. If Operand is zero, then -1 is returned.
2393 Otherwise, a value between 0 and 31 is returned.
2395 @param Operand The 32-bit operand to evaluate.
2397 @retval 0..31 Position of the highest bit set in Operand if found.
2398 @retval -1 Operand is zero.
2409 Returns the bit position of the highest bit set in a 64-bit value. Equivalent
2412 This function computes the bit position of the highest bit set in the 64-bit
2413 value specified by Operand. If Operand is zero, then -1 is returned.
2414 Otherwise, a value between 0 and 63 is returned.
2416 @param Operand The 64-bit operand to evaluate.
2418 @retval 0..63 Position of the highest bit set in Operand if found.
2419 @retval -1 Operand is zero.
2430 Returns the value of the highest bit set in a 32-bit value. Equivalent to
2433 This function computes the value of the highest bit set in the 32-bit value
2434 specified by Operand. If Operand is zero, then zero is returned.
2436 @param Operand The 32-bit operand to evaluate.
2438 @return 1 << HighBitSet32(Operand)
2439 @retval 0 Operand is zero.
2450 Returns the value of the highest bit set in a 64-bit value. Equivalent to
2453 This function computes the value of the highest bit set in the 64-bit value
2454 specified by Operand. If Operand is zero, then zero is returned.
2456 @param Operand The 64-bit operand to evaluate.
2458 @return 1 << HighBitSet64(Operand)
2459 @retval 0 Operand is zero.
2470 Switches the endianness of a 16-bit integer.
2472 This function swaps the bytes in a 16-bit unsigned value to switch the value
2473 from little endian to big endian or vice versa. The byte swapped value is
2476 @param Value A 16-bit unsigned value.
2478 @return The byte swapped Value.
2489 Switches the endianness of a 32-bit integer.
2491 This function swaps the bytes in a 32-bit unsigned value to switch the value
2492 from little endian to big endian or vice versa. The byte swapped value is
2495 @param Value A 32-bit unsigned value.
2497 @return The byte swapped Value.
2508 Switches the endianness of a 64-bit integer.
2510 This function swaps the bytes in a 64-bit unsigned value to switch the value
2511 from little endian to big endian or vice versa. The byte swapped value is
2514 @param Value A 64-bit unsigned value.
2516 @return The byte swapped Value.
2527 Multiples a 64-bit unsigned integer by a 32-bit unsigned integer and
2528 generates a 64-bit unsigned result.
2530 This function multiples the 64-bit unsigned value Multiplicand by the 32-bit
2531 unsigned value Multiplier and generates a 64-bit unsigned result. This 64-
2532 bit unsigned result is returned.
2534 @param Multiplicand A 64-bit unsigned value.
2535 @param Multiplier A 32-bit unsigned value.
2537 @return Multiplicand * Multiplier
2543 IN UINT64 Multiplicand
,
2544 IN UINT32 Multiplier
2549 Multiples a 64-bit unsigned integer by a 64-bit unsigned integer and
2550 generates a 64-bit unsigned result.
2552 This function multiples the 64-bit unsigned value Multiplicand by the 64-bit
2553 unsigned value Multiplier and generates a 64-bit unsigned result. This 64-
2554 bit unsigned result is returned.
2556 @param Multiplicand A 64-bit unsigned value.
2557 @param Multiplier A 64-bit unsigned value.
2559 @return Multiplicand * Multiplier.
2565 IN UINT64 Multiplicand
,
2566 IN UINT64 Multiplier
2571 Multiples a 64-bit signed integer by a 64-bit signed integer and generates a
2572 64-bit signed result.
2574 This function multiples the 64-bit signed value Multiplicand by the 64-bit
2575 signed value Multiplier and generates a 64-bit signed result. This 64-bit
2576 signed result is returned.
2578 @param Multiplicand A 64-bit signed value.
2579 @param Multiplier A 64-bit signed value.
2581 @return Multiplicand * Multiplier
2587 IN INT64 Multiplicand
,
2593 Divides a 64-bit unsigned integer by a 32-bit unsigned integer and generates
2594 a 64-bit unsigned result.
2596 This function divides the 64-bit unsigned value Dividend by the 32-bit
2597 unsigned value Divisor and generates a 64-bit unsigned quotient. This
2598 function returns the 64-bit unsigned quotient.
2600 If Divisor is 0, then ASSERT().
2602 @param Dividend A 64-bit unsigned value.
2603 @param Divisor A 32-bit unsigned value.
2605 @return Dividend / Divisor.
2617 Divides a 64-bit unsigned integer by a 32-bit unsigned integer and generates
2618 a 32-bit unsigned remainder.
2620 This function divides the 64-bit unsigned value Dividend by the 32-bit
2621 unsigned value Divisor and generates a 32-bit remainder. This function
2622 returns the 32-bit unsigned remainder.
2624 If Divisor is 0, then ASSERT().
2626 @param Dividend A 64-bit unsigned value.
2627 @param Divisor A 32-bit unsigned value.
2629 @return Dividend % Divisor.
2641 Divides a 64-bit unsigned integer by a 32-bit unsigned integer and generates
2642 a 64-bit unsigned result and an optional 32-bit unsigned remainder.
2644 This function divides the 64-bit unsigned value Dividend by the 32-bit
2645 unsigned value Divisor and generates a 64-bit unsigned quotient. If Remainder
2646 is not NULL, then the 32-bit unsigned remainder is returned in Remainder.
2647 This function returns the 64-bit unsigned quotient.
2649 If Divisor is 0, then ASSERT().
2651 @param Dividend A 64-bit unsigned value.
2652 @param Divisor A 32-bit unsigned value.
2653 @param Remainder A pointer to a 32-bit unsigned value. This parameter is
2654 optional and may be NULL.
2656 @return Dividend / Divisor.
2661 DivU64x32Remainder (
2664 OUT UINT32
*Remainder OPTIONAL
2669 Divides a 64-bit unsigned integer by a 64-bit unsigned integer and generates
2670 a 64-bit unsigned result and an optional 64-bit unsigned remainder.
2672 This function divides the 64-bit unsigned value Dividend by the 64-bit
2673 unsigned value Divisor and generates a 64-bit unsigned quotient. If Remainder
2674 is not NULL, then the 64-bit unsigned remainder is returned in Remainder.
2675 This function returns the 64-bit unsigned quotient.
2677 If Divisor is 0, then ASSERT().
2679 @param Dividend A 64-bit unsigned value.
2680 @param Divisor A 64-bit unsigned value.
2681 @param Remainder A pointer to a 64-bit unsigned value. This parameter is
2682 optional and may be NULL.
2684 @return Dividend / Divisor.
2689 DivU64x64Remainder (
2692 OUT UINT64
*Remainder OPTIONAL
2697 Divides a 64-bit signed integer by a 64-bit signed integer and generates a
2698 64-bit signed result and a optional 64-bit signed remainder.
2700 This function divides the 64-bit signed value Dividend by the 64-bit signed
2701 value Divisor and generates a 64-bit signed quotient. If Remainder is not
2702 NULL, then the 64-bit signed remainder is returned in Remainder. This
2703 function returns the 64-bit signed quotient.
2705 It is the caller's responsibility to not call this function with a Divisor of 0.
2706 If Divisor is 0, then the quotient and remainder should be assumed to be
2707 the largest negative integer.
2709 If Divisor is 0, then ASSERT().
2711 @param Dividend A 64-bit signed value.
2712 @param Divisor A 64-bit signed value.
2713 @param Remainder A pointer to a 64-bit signed value. This parameter is
2714 optional and may be NULL.
2716 @return Dividend / Divisor.
2721 DivS64x64Remainder (
2724 OUT INT64
*Remainder OPTIONAL
2729 Reads a 16-bit value from memory that may be unaligned.
2731 This function returns the 16-bit value pointed to by Buffer. The function
2732 guarantees that the read operation does not produce an alignment fault.
2734 If the Buffer is NULL, then ASSERT().
2736 @param Buffer The pointer to a 16-bit value that may be unaligned.
2738 @return The 16-bit value read from Buffer.
2744 IN CONST UINT16
*Buffer
2749 Writes a 16-bit value to memory that may be unaligned.
2751 This function writes the 16-bit value specified by Value to Buffer. Value is
2752 returned. The function guarantees that the write operation does not produce
2755 If the Buffer is NULL, then ASSERT().
2757 @param Buffer The pointer to a 16-bit value that may be unaligned.
2758 @param Value 16-bit value to write to Buffer.
2760 @return The 16-bit value to write to Buffer.
2772 Reads a 24-bit value from memory that may be unaligned.
2774 This function returns the 24-bit value pointed to by Buffer. The function
2775 guarantees that the read operation does not produce an alignment fault.
2777 If the Buffer is NULL, then ASSERT().
2779 @param Buffer The pointer to a 24-bit value that may be unaligned.
2781 @return The 24-bit value read from Buffer.
2787 IN CONST UINT32
*Buffer
2792 Writes a 24-bit value to memory that may be unaligned.
2794 This function writes the 24-bit value specified by Value to Buffer. Value is
2795 returned. The function guarantees that the write operation does not produce
2798 If the Buffer is NULL, then ASSERT().
2800 @param Buffer The pointer to a 24-bit value that may be unaligned.
2801 @param Value 24-bit value to write to Buffer.
2803 @return The 24-bit value to write to Buffer.
2815 Reads a 32-bit value from memory that may be unaligned.
2817 This function returns the 32-bit value pointed to by Buffer. The function
2818 guarantees that the read operation does not produce an alignment fault.
2820 If the Buffer is NULL, then ASSERT().
2822 @param Buffer The pointer to a 32-bit value that may be unaligned.
2824 @return The 32-bit value read from Buffer.
2830 IN CONST UINT32
*Buffer
2835 Writes a 32-bit value to memory that may be unaligned.
2837 This function writes the 32-bit value specified by Value to Buffer. Value is
2838 returned. The function guarantees that the write operation does not produce
2841 If the Buffer is NULL, then ASSERT().
2843 @param Buffer The pointer to a 32-bit value that may be unaligned.
2844 @param Value 32-bit value to write to Buffer.
2846 @return The 32-bit value to write to Buffer.
2858 Reads a 64-bit value from memory that may be unaligned.
2860 This function returns the 64-bit value pointed to by Buffer. The function
2861 guarantees that the read operation does not produce an alignment fault.
2863 If the Buffer is NULL, then ASSERT().
2865 @param Buffer The pointer to a 64-bit value that may be unaligned.
2867 @return The 64-bit value read from Buffer.
2873 IN CONST UINT64
*Buffer
2878 Writes a 64-bit value to memory that may be unaligned.
2880 This function writes the 64-bit value specified by Value to Buffer. Value is
2881 returned. The function guarantees that the write operation does not produce
2884 If the Buffer is NULL, then ASSERT().
2886 @param Buffer The pointer to a 64-bit value that may be unaligned.
2887 @param Value 64-bit value to write to Buffer.
2889 @return The 64-bit value to write to Buffer.
2901 // Bit Field Functions
2905 Returns a bit field from an 8-bit value.
2907 Returns the bitfield specified by the StartBit and the EndBit from Operand.
2909 If 8-bit operations are not supported, then ASSERT().
2910 If StartBit is greater than 7, then ASSERT().
2911 If EndBit is greater than 7, then ASSERT().
2912 If EndBit is less than StartBit, 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.
2920 @return The bit field read.
2933 Writes a bit field to an 8-bit value, and returns the result.
2935 Writes Value to the bit field specified by the StartBit and the EndBit in
2936 Operand. All other bits in Operand are preserved. The new 8-bit value is
2939 If 8-bit operations are not supported, then ASSERT().
2940 If StartBit is greater than 7, then ASSERT().
2941 If EndBit is greater than 7, then ASSERT().
2942 If EndBit is less than StartBit, then ASSERT().
2943 If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
2945 @param Operand Operand on which to perform the bitfield operation.
2946 @param StartBit The ordinal of the least significant bit in the bit field.
2948 @param EndBit The ordinal of the most significant bit in the bit field.
2950 @param Value New value of the bit field.
2952 @return The new 8-bit value.
2966 Reads a bit field from an 8-bit value, performs a bitwise OR, and returns the
2969 Performs a bitwise OR between the bit field specified by StartBit
2970 and EndBit in Operand and the value specified by OrData. All other bits in
2971 Operand are preserved. The new 8-bit value is returned.
2973 If 8-bit operations are not supported, then ASSERT().
2974 If StartBit is greater than 7, then ASSERT().
2975 If EndBit is greater than 7, then ASSERT().
2976 If EndBit is less than StartBit, then ASSERT().
2977 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
2979 @param Operand Operand on which to perform the bitfield operation.
2980 @param StartBit The ordinal of the least significant bit in the bit field.
2982 @param EndBit The ordinal of the most significant bit in the bit field.
2984 @param OrData The value to OR with the read value from the value
2986 @return The new 8-bit value.
3000 Reads a bit field from an 8-bit value, performs a bitwise AND, and returns
3003 Performs a bitwise AND between the bit field specified by StartBit and EndBit
3004 in Operand and the value specified by AndData. All other bits in Operand are
3005 preserved. The new 8-bit value is returned.
3007 If 8-bit operations are not supported, then ASSERT().
3008 If StartBit is greater than 7, then ASSERT().
3009 If EndBit is greater than 7, then ASSERT().
3010 If EndBit is less than StartBit, then ASSERT().
3011 If AndData 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 AndData The value to AND with the read value from the value.
3020 @return The new 8-bit value.
3034 Reads a bit field from an 8-bit value, performs a bitwise AND followed by a
3035 bitwise OR, and returns the result.
3037 Performs a bitwise AND between the bit field specified by StartBit and EndBit
3038 in Operand and the value specified by AndData, followed by a bitwise
3039 OR with value specified by OrData. All other bits in Operand are
3040 preserved. The new 8-bit value is returned.
3042 If 8-bit operations are not supported, then ASSERT().
3043 If StartBit is greater than 7, then ASSERT().
3044 If EndBit is greater than 7, then ASSERT().
3045 If EndBit is less than StartBit, then ASSERT().
3046 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
3047 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
3049 @param Operand Operand on which to perform the bitfield operation.
3050 @param StartBit The ordinal of the least significant bit in the bit field.
3052 @param EndBit The ordinal of the most significant bit in the bit field.
3054 @param AndData The value to AND with the read value from the value.
3055 @param OrData The value to OR with the result of the AND operation.
3057 @return The new 8-bit value.
3062 BitFieldAndThenOr8 (
3072 Returns a bit field from a 16-bit value.
3074 Returns the bitfield specified by the StartBit and the EndBit from Operand.
3076 If 16-bit operations are not supported, then ASSERT().
3077 If StartBit is greater than 15, then ASSERT().
3078 If EndBit is greater than 15, then ASSERT().
3079 If EndBit is less than StartBit, 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.
3087 @return The bit field read.
3100 Writes a bit field to a 16-bit value, and returns the result.
3102 Writes Value to the bit field specified by the StartBit and the EndBit in
3103 Operand. All other bits in Operand are preserved. The new 16-bit value is
3106 If 16-bit operations are not supported, then ASSERT().
3107 If StartBit is greater than 15, then ASSERT().
3108 If EndBit is greater than 15, then ASSERT().
3109 If EndBit is less than StartBit, then ASSERT().
3110 If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
3112 @param Operand Operand on which to perform the bitfield operation.
3113 @param StartBit The ordinal of the least significant bit in the bit field.
3115 @param EndBit The ordinal of the most significant bit in the bit field.
3117 @param Value New value of the bit field.
3119 @return The new 16-bit value.
3133 Reads a bit field from a 16-bit value, performs a bitwise OR, and returns the
3136 Performs a bitwise OR between the bit field specified by StartBit
3137 and EndBit in Operand and the value specified by OrData. All other bits in
3138 Operand are preserved. The new 16-bit value is returned.
3140 If 16-bit operations are not supported, then ASSERT().
3141 If StartBit is greater than 15, then ASSERT().
3142 If EndBit is greater than 15, then ASSERT().
3143 If EndBit is less than StartBit, then ASSERT().
3144 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
3146 @param Operand Operand on which to perform the bitfield operation.
3147 @param StartBit The ordinal of the least significant bit in the bit field.
3149 @param EndBit The ordinal of the most significant bit in the bit field.
3151 @param OrData The value to OR with the read value from the value
3153 @return The new 16-bit value.
3167 Reads a bit field from a 16-bit value, performs a bitwise AND, and returns
3170 Performs a bitwise AND between the bit field specified by StartBit and EndBit
3171 in Operand and the value specified by AndData. All other bits in Operand are
3172 preserved. The new 16-bit value is returned.
3174 If 16-bit operations are not supported, then ASSERT().
3175 If StartBit is greater than 15, then ASSERT().
3176 If EndBit is greater than 15, then ASSERT().
3177 If EndBit is less than StartBit, then ASSERT().
3178 If AndData 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 AndData The value to AND with the read value from the value
3187 @return The new 16-bit value.
3201 Reads a bit field from a 16-bit value, performs a bitwise AND followed by a
3202 bitwise OR, and returns the result.
3204 Performs a bitwise AND between the bit field specified by StartBit and EndBit
3205 in Operand and the value specified by AndData, followed by a bitwise
3206 OR with value specified by OrData. All other bits in Operand are
3207 preserved. The new 16-bit value is returned.
3209 If 16-bit operations are not supported, then ASSERT().
3210 If StartBit is greater than 15, then ASSERT().
3211 If EndBit is greater than 15, then ASSERT().
3212 If EndBit is less than StartBit, then ASSERT().
3213 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
3214 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
3216 @param Operand Operand on which to perform the bitfield operation.
3217 @param StartBit The ordinal of the least significant bit in the bit field.
3219 @param EndBit The ordinal of the most significant bit in the bit field.
3221 @param AndData The value to AND with the read value from the value.
3222 @param OrData The value to OR with the result of the AND operation.
3224 @return The new 16-bit value.
3229 BitFieldAndThenOr16 (
3239 Returns a bit field from a 32-bit value.
3241 Returns the bitfield specified by the StartBit and the EndBit from Operand.
3243 If 32-bit operations are not supported, then ASSERT().
3244 If StartBit is greater than 31, then ASSERT().
3245 If EndBit is greater than 31, then ASSERT().
3246 If EndBit is less than StartBit, 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.
3254 @return The bit field read.
3267 Writes a bit field to a 32-bit value, and returns the result.
3269 Writes Value to the bit field specified by the StartBit and the EndBit in
3270 Operand. All other bits in Operand are preserved. The new 32-bit value is
3273 If 32-bit operations are not supported, then ASSERT().
3274 If StartBit is greater than 31, then ASSERT().
3275 If EndBit is greater than 31, then ASSERT().
3276 If EndBit is less than StartBit, then ASSERT().
3277 If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
3279 @param Operand Operand on which to perform the bitfield operation.
3280 @param StartBit The ordinal of the least significant bit in the bit field.
3282 @param EndBit The ordinal of the most significant bit in the bit field.
3284 @param Value New value of the bit field.
3286 @return The new 32-bit value.
3300 Reads a bit field from a 32-bit value, performs a bitwise OR, and returns the
3303 Performs a bitwise OR between the bit field specified by StartBit
3304 and EndBit in Operand and the value specified by OrData. All other bits in
3305 Operand are preserved. The new 32-bit value is returned.
3307 If 32-bit operations are not supported, then ASSERT().
3308 If StartBit is greater than 31, then ASSERT().
3309 If EndBit is greater than 31, then ASSERT().
3310 If EndBit is less than StartBit, then ASSERT().
3311 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
3313 @param Operand Operand on which to perform the bitfield operation.
3314 @param StartBit The ordinal of the least significant bit in the bit field.
3316 @param EndBit The ordinal of the most significant bit in the bit field.
3318 @param OrData The value to OR with the read value from the value.
3320 @return The new 32-bit value.
3334 Reads a bit field from a 32-bit value, performs a bitwise AND, and returns
3337 Performs a bitwise AND between the bit field specified by StartBit and EndBit
3338 in Operand and the value specified by AndData. All other bits in Operand are
3339 preserved. The new 32-bit value is returned.
3341 If 32-bit operations are not supported, then ASSERT().
3342 If StartBit is greater than 31, then ASSERT().
3343 If EndBit is greater than 31, then ASSERT().
3344 If EndBit is less than StartBit, then ASSERT().
3345 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
3347 @param Operand Operand on which to perform the bitfield operation.
3348 @param StartBit The ordinal of the least significant bit in the bit field.
3350 @param EndBit The ordinal of the most significant bit in the bit field.
3352 @param AndData The value to AND with the read value from the value
3354 @return The new 32-bit value.
3368 Reads a bit field from a 32-bit value, performs a bitwise AND followed by a
3369 bitwise OR, and returns the result.
3371 Performs a bitwise AND between the bit field specified by StartBit and EndBit
3372 in Operand and the value specified by AndData, followed by a bitwise
3373 OR with value specified by OrData. All other bits in Operand are
3374 preserved. The new 32-bit value is returned.
3376 If 32-bit operations are not supported, then ASSERT().
3377 If StartBit is greater than 31, then ASSERT().
3378 If EndBit is greater than 31, then ASSERT().
3379 If EndBit is less than StartBit, then ASSERT().
3380 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
3381 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
3383 @param Operand Operand on which to perform the bitfield operation.
3384 @param StartBit The ordinal of the least significant bit in the bit field.
3386 @param EndBit The ordinal of the most significant bit in the bit field.
3388 @param AndData The value to AND with the read value from the value.
3389 @param OrData The value to OR with the result of the AND operation.
3391 @return The new 32-bit value.
3396 BitFieldAndThenOr32 (
3406 Returns a bit field from a 64-bit value.
3408 Returns the bitfield specified by the StartBit and the EndBit from Operand.
3410 If 64-bit operations are not supported, then ASSERT().
3411 If StartBit is greater than 63, then ASSERT().
3412 If EndBit is greater than 63, then ASSERT().
3413 If EndBit is less than StartBit, then ASSERT().
3415 @param Operand Operand on which to perform the bitfield operation.
3416 @param StartBit The ordinal of the least significant bit in the bit field.
3418 @param EndBit The ordinal of the most significant bit in the bit field.
3421 @return The bit field read.
3434 Writes a bit field to a 64-bit value, and returns the result.
3436 Writes Value to the bit field specified by the StartBit and the EndBit in
3437 Operand. All other bits in Operand are preserved. The new 64-bit value is
3440 If 64-bit operations are not supported, then ASSERT().
3441 If StartBit is greater than 63, then ASSERT().
3442 If EndBit is greater than 63, then ASSERT().
3443 If EndBit is less than StartBit, then ASSERT().
3444 If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
3446 @param Operand Operand on which to perform the bitfield operation.
3447 @param StartBit The ordinal of the least significant bit in the bit field.
3449 @param EndBit The ordinal of the most significant bit in the bit field.
3451 @param Value New value of the bit field.
3453 @return The new 64-bit value.
3467 Reads a bit field from a 64-bit value, performs a bitwise OR, and returns the
3470 Performs a bitwise OR between the bit field specified by StartBit
3471 and EndBit in Operand and the value specified by OrData. All other bits in
3472 Operand are preserved. The new 64-bit value is returned.
3474 If 64-bit operations are not supported, then ASSERT().
3475 If StartBit is greater than 63, then ASSERT().
3476 If EndBit is greater than 63, then ASSERT().
3477 If EndBit is less than StartBit, then ASSERT().
3478 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
3480 @param Operand Operand on which to perform the bitfield operation.
3481 @param StartBit The ordinal of the least significant bit in the bit field.
3483 @param EndBit The ordinal of the most significant bit in the bit field.
3485 @param OrData The value to OR with the read value from the value
3487 @return The new 64-bit value.
3501 Reads a bit field from a 64-bit value, performs a bitwise AND, and returns
3504 Performs a bitwise AND between the bit field specified by StartBit and EndBit
3505 in Operand and the value specified by AndData. All other bits in Operand are
3506 preserved. The new 64-bit value is returned.
3508 If 64-bit operations are not supported, then ASSERT().
3509 If StartBit is greater than 63, then ASSERT().
3510 If EndBit is greater than 63, then ASSERT().
3511 If EndBit is less than StartBit, then ASSERT().
3512 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
3514 @param Operand Operand on which to perform the bitfield operation.
3515 @param StartBit The ordinal of the least significant bit in the bit field.
3517 @param EndBit The ordinal of the most significant bit in the bit field.
3519 @param AndData The value to AND with the read value from the value
3521 @return The new 64-bit value.
3535 Reads a bit field from a 64-bit value, performs a bitwise AND followed by a
3536 bitwise OR, and returns the result.
3538 Performs a bitwise AND between the bit field specified by StartBit and EndBit
3539 in Operand and the value specified by AndData, followed by a bitwise
3540 OR with value specified by OrData. All other bits in Operand are
3541 preserved. The new 64-bit value is returned.
3543 If 64-bit operations are not supported, then ASSERT().
3544 If StartBit is greater than 63, then ASSERT().
3545 If EndBit is greater than 63, then ASSERT().
3546 If EndBit is less than StartBit, then ASSERT().
3547 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
3548 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
3550 @param Operand Operand on which to perform the bitfield operation.
3551 @param StartBit The ordinal of the least significant bit in the bit field.
3553 @param EndBit The ordinal of the most significant bit in the bit field.
3555 @param AndData The value to AND with the read value from the value.
3556 @param OrData The value to OR with the result of the AND operation.
3558 @return The new 64-bit value.
3563 BitFieldAndThenOr64 (
3572 // Base Library Checksum Functions
3576 Returns the sum of all elements in a buffer in unit of UINT8.
3577 During calculation, the carry bits are dropped.
3579 This function calculates the sum of all elements in a buffer
3580 in unit of UINT8. The carry bits in result of addition are dropped.
3581 The result is returned as UINT8. If Length is Zero, then Zero is
3584 If Buffer is NULL, then ASSERT().
3585 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
3587 @param Buffer The pointer to the buffer to carry out the sum operation.
3588 @param Length The size, in bytes, of Buffer.
3590 @return Sum The sum of Buffer with carry bits dropped during additions.
3596 IN CONST UINT8
*Buffer
,
3602 Returns the two's complement checksum of all elements in a buffer
3605 This function first calculates the sum of the 8-bit values in the
3606 buffer specified by Buffer and Length. The carry bits in the result
3607 of addition are dropped. Then, the two's complement of the sum is
3608 returned. If Length is 0, then 0 is returned.
3610 If Buffer is NULL, then ASSERT().
3611 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
3613 @param Buffer The pointer to the buffer to carry out the checksum operation.
3614 @param Length The size, in bytes, of Buffer.
3616 @return Checksum The two's complement checksum of Buffer.
3621 CalculateCheckSum8 (
3622 IN CONST UINT8
*Buffer
,
3628 Returns the sum of all elements in a buffer of 16-bit values. During
3629 calculation, the carry bits are dropped.
3631 This function calculates the sum of the 16-bit values in the buffer
3632 specified by Buffer and Length. The carry bits in result of addition are dropped.
3633 The 16-bit result is returned. If Length is 0, then 0 is returned.
3635 If Buffer is NULL, then ASSERT().
3636 If Buffer is not aligned on a 16-bit boundary, then ASSERT().
3637 If Length is not aligned on a 16-bit boundary, then ASSERT().
3638 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
3640 @param Buffer The pointer to the buffer to carry out the sum operation.
3641 @param Length The size, in bytes, of Buffer.
3643 @return Sum The sum of Buffer with carry bits dropped during additions.
3649 IN CONST UINT16
*Buffer
,
3655 Returns the two's complement checksum of all elements in a buffer of
3658 This function first calculates the sum of the 16-bit values in the buffer
3659 specified by Buffer and Length. The carry bits in the result of addition
3660 are dropped. Then, the two's complement of the sum is returned. If Length
3661 is 0, then 0 is returned.
3663 If Buffer is NULL, then ASSERT().
3664 If Buffer is not aligned on a 16-bit boundary, then ASSERT().
3665 If Length is not aligned on a 16-bit boundary, then ASSERT().
3666 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
3668 @param Buffer The pointer to the buffer to carry out the checksum operation.
3669 @param Length The size, in bytes, of Buffer.
3671 @return Checksum The two's complement checksum of Buffer.
3676 CalculateCheckSum16 (
3677 IN CONST UINT16
*Buffer
,
3683 Returns the sum of all elements in a buffer of 32-bit values. During
3684 calculation, the carry bits are dropped.
3686 This function calculates the sum of the 32-bit values in the buffer
3687 specified by Buffer and Length. The carry bits in result of addition are dropped.
3688 The 32-bit result is returned. If Length is 0, then 0 is returned.
3690 If Buffer is NULL, then ASSERT().
3691 If Buffer is not aligned on a 32-bit boundary, then ASSERT().
3692 If Length is not aligned on a 32-bit boundary, then ASSERT().
3693 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
3695 @param Buffer The pointer to the buffer to carry out the sum operation.
3696 @param Length The size, in bytes, of Buffer.
3698 @return Sum The sum of Buffer with carry bits dropped during additions.
3704 IN CONST UINT32
*Buffer
,
3710 Returns the two's complement checksum of all elements in a buffer of
3713 This function first calculates the sum of the 32-bit values in the buffer
3714 specified by Buffer and Length. The carry bits in the result of addition
3715 are dropped. Then, the two's complement of the sum is returned. If Length
3716 is 0, then 0 is returned.
3718 If Buffer is NULL, then ASSERT().
3719 If Buffer is not aligned on a 32-bit boundary, then ASSERT().
3720 If Length is not aligned on a 32-bit boundary, then ASSERT().
3721 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
3723 @param Buffer The pointer to the buffer to carry out the checksum operation.
3724 @param Length The size, in bytes, of Buffer.
3726 @return Checksum The two's complement checksum of Buffer.
3731 CalculateCheckSum32 (
3732 IN CONST UINT32
*Buffer
,
3738 Returns the sum of all elements in a buffer of 64-bit values. During
3739 calculation, the carry bits are dropped.
3741 This function calculates the sum of the 64-bit values in the buffer
3742 specified by Buffer and Length. The carry bits in result of addition are dropped.
3743 The 64-bit result is returned. If Length is 0, then 0 is returned.
3745 If Buffer is NULL, then ASSERT().
3746 If Buffer is not aligned on a 64-bit boundary, then ASSERT().
3747 If Length is not aligned on a 64-bit boundary, then ASSERT().
3748 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
3750 @param Buffer The pointer to the buffer to carry out the sum operation.
3751 @param Length The size, in bytes, of Buffer.
3753 @return Sum The sum of Buffer with carry bits dropped during additions.
3759 IN CONST UINT64
*Buffer
,
3765 Returns the two's complement checksum of all elements in a buffer of
3768 This function first calculates the sum of the 64-bit values in the buffer
3769 specified by Buffer and Length. The carry bits in the result of addition
3770 are dropped. Then, the two's complement of the sum is returned. If Length
3771 is 0, then 0 is returned.
3773 If Buffer is NULL, then ASSERT().
3774 If Buffer is not aligned on a 64-bit boundary, then ASSERT().
3775 If Length is not aligned on a 64-bit boundary, then ASSERT().
3776 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
3778 @param Buffer The pointer to the buffer to carry out the checksum operation.
3779 @param Length The size, in bytes, of Buffer.
3781 @return Checksum The two's complement checksum of Buffer.
3786 CalculateCheckSum64 (
3787 IN CONST UINT64
*Buffer
,
3793 // Base Library CPU Functions
3797 Function entry point used when a stack switch is requested with SwitchStack()
3799 @param Context1 Context1 parameter passed into SwitchStack().
3800 @param Context2 Context2 parameter passed into SwitchStack().
3805 (EFIAPI
*SWITCH_STACK_ENTRY_POINT
)(
3806 IN VOID
*Context1
, OPTIONAL
3807 IN VOID
*Context2 OPTIONAL
3812 Used to serialize load and store operations.
3814 All loads and stores that proceed calls to this function are guaranteed to be
3815 globally visible when this function returns.
3826 Saves the current CPU context that can be restored with a call to LongJump()
3829 Saves the current CPU context in the buffer specified by JumpBuffer and
3830 returns 0. The initial call to SetJump() must always return 0. Subsequent
3831 calls to LongJump() cause a non-zero value to be returned by SetJump().
3833 If JumpBuffer is NULL, then ASSERT().
3834 For Itanium processors, if JumpBuffer is not aligned on a 16-byte boundary, then ASSERT().
3836 NOTE: The structure BASE_LIBRARY_JUMP_BUFFER is CPU architecture specific.
3837 The same structure must never be used for more than one CPU architecture context.
3838 For example, a BASE_LIBRARY_JUMP_BUFFER allocated by an IA-32 module must never be used from an x64 module.
3839 SetJump()/LongJump() is not currently supported for the EBC processor type.
3841 @param JumpBuffer A pointer to CPU context buffer.
3843 @retval 0 Indicates a return from SetJump().
3849 OUT BASE_LIBRARY_JUMP_BUFFER
*JumpBuffer
3854 Restores the CPU context that was saved with SetJump().
3856 Restores the CPU context from the buffer specified by JumpBuffer. This
3857 function never returns to the caller. Instead is resumes execution based on
3858 the state of JumpBuffer.
3860 If JumpBuffer is NULL, then ASSERT().
3861 For Itanium processors, if JumpBuffer is not aligned on a 16-byte boundary, then ASSERT().
3862 If Value is 0, then ASSERT().
3864 @param JumpBuffer A pointer to CPU context buffer.
3865 @param Value The value to return when the SetJump() context is
3866 restored and must be non-zero.
3872 IN BASE_LIBRARY_JUMP_BUFFER
*JumpBuffer
,
3878 Enables CPU interrupts.
3889 Disables CPU interrupts.
3900 Disables CPU interrupts and returns the interrupt state prior to the disable
3903 @retval TRUE CPU interrupts were enabled on entry to this call.
3904 @retval FALSE CPU interrupts were disabled on entry to this call.
3909 SaveAndDisableInterrupts (
3915 Enables CPU interrupts for the smallest window required to capture any
3921 EnableDisableInterrupts (
3927 Retrieves the current CPU interrupt state.
3929 Returns TRUE if interrupts are currently enabled. Otherwise
3932 @retval TRUE CPU interrupts are enabled.
3933 @retval FALSE CPU interrupts are disabled.
3944 Set the current CPU interrupt state.
3946 Sets the current CPU interrupt state to the state specified by
3947 InterruptState. If InterruptState is TRUE, then interrupts are enabled. If
3948 InterruptState is FALSE, then interrupts are disabled. InterruptState is
3951 @param InterruptState TRUE if interrupts should enabled. FALSE if
3952 interrupts should be disabled.
3954 @return InterruptState
3960 IN BOOLEAN InterruptState
3965 Requests CPU to pause for a short period of time.
3967 Requests CPU to pause for a short period of time. Typically used in MP
3968 systems to prevent memory starvation while waiting for a spin lock.
3979 Transfers control to a function starting with a new stack.
3981 Transfers control to the function specified by EntryPoint using the
3982 new stack specified by NewStack and passing in the parameters specified
3983 by Context1 and Context2. Context1 and Context2 are optional and may
3984 be NULL. The function EntryPoint must never return. This function
3985 supports a variable number of arguments following the NewStack parameter.
3986 These additional arguments are ignored on IA-32, x64, and EBC architectures.
3987 Itanium processors expect one additional parameter of type VOID * that specifies
3988 the new backing store pointer.
3990 If EntryPoint is NULL, then ASSERT().
3991 If NewStack is NULL, then ASSERT().
3993 @param EntryPoint A pointer to function to call with the new stack.
3994 @param Context1 A pointer to the context to pass into the EntryPoint
3996 @param Context2 A pointer to the context to pass into the EntryPoint
3998 @param NewStack A pointer to the new stack to use for the EntryPoint
4000 @param ... This variable argument list is ignored for IA-32, x64, and
4001 EBC architectures. For Itanium processors, this variable
4002 argument list is expected to contain a single parameter of
4003 type VOID * that specifies the new backing store pointer.
4010 IN SWITCH_STACK_ENTRY_POINT EntryPoint
,
4011 IN VOID
*Context1
, OPTIONAL
4012 IN VOID
*Context2
, OPTIONAL
4019 Generates a breakpoint on the CPU.
4021 Generates a breakpoint on the CPU. The breakpoint must be implemented such
4022 that code can resume normal execution after the breakpoint.
4033 Executes an infinite loop.
4035 Forces the CPU to execute an infinite loop. A debugger may be used to skip
4036 past the loop and the code that follows the loop must execute properly. This
4037 implies that the infinite loop must not cause the code that follow it to be
4047 #if defined (MDE_CPU_IPF)
4050 Flush a range of cache lines in the cache coherency domain of the calling
4053 Flushes the cache lines specified by Address and Length. If Address is not aligned
4054 on a cache line boundary, then entire cache line containing Address is flushed.
4055 If Address + Length is not aligned on a cache line boundary, then the entire cache
4056 line containing Address + Length - 1 is flushed. This function may choose to flush
4057 the entire cache if that is more efficient than flushing the specified range. If
4058 Length is 0, the no cache lines are flushed. Address is returned.
4059 This function is only available on Itanium processors.
4061 If Length is greater than (MAX_ADDRESS - Address + 1), then ASSERT().
4063 @param Address The base address of the instruction lines to invalidate. If
4064 the CPU is in a physical addressing mode, then Address is a
4065 physical address. If the CPU is in a virtual addressing mode,
4066 then Address is a virtual address.
4068 @param Length The number of bytes to invalidate from the instruction cache.
4075 AsmFlushCacheRange (
4082 Executes an FC instruction.
4083 Executes an FC instruction on the cache line specified by Address.
4084 The cache line size affected is at least 32-bytes (aligned on a 32-byte boundary).
4085 An implementation may flush a larger region. This function is only available on Itanium processors.
4087 @param Address The Address of cache line to be flushed.
4089 @return The address of FC instruction executed.
4100 Executes an FC.I instruction.
4101 Executes an FC.I instruction on the cache line specified by Address.
4102 The cache line size affected is at least 32-bytes (aligned on a 32-byte boundary).
4103 An implementation may flush a larger region. This function is only available on Itanium processors.
4105 @param Address The Address of cache line to be flushed.
4107 @return The address of the FC.I instruction executed.
4118 Reads the current value of a Processor Identifier Register (CPUID).
4120 Reads and returns the current value of Processor Identifier Register specified by Index.
4121 The Index of largest implemented CPUID (One less than the number of implemented CPUID
4122 registers) is determined by CPUID [3] bits {7:0}.
4123 No parameter checking is performed on Index. If the Index value is beyond the
4124 implemented CPUID register range, a Reserved Register/Field fault may occur. The caller
4125 must either guarantee that Index is valid, or the caller must set up fault handlers to
4126 catch the faults. This function is only available on Itanium processors.
4128 @param Index The 8-bit Processor Identifier Register index to read.
4130 @return The current value of Processor Identifier Register specified by Index.
4141 Reads the current value of 64-bit Processor Status Register (PSR).
4142 This function is only available on Itanium processors.
4144 @return The current value of PSR.
4155 Writes the current value of 64-bit Processor Status Register (PSR).
4157 No parameter checking is performed on Value. All bits of Value corresponding to
4158 reserved fields of PSR must be 0 or a Reserved Register/Field fault may occur.
4159 The caller must either guarantee that Value is valid, or the caller must set up
4160 fault handlers to catch the faults. This function is only available on Itanium processors.
4162 @param Value The 64-bit value to write to PSR.
4164 @return The 64-bit value written to the PSR.
4175 Reads the current value of 64-bit Kernel Register #0 (KR0).
4177 Reads and returns the current value of KR0.
4178 This function is only available on Itanium processors.
4180 @return The current value of KR0.
4191 Reads the current value of 64-bit Kernel Register #1 (KR1).
4193 Reads and returns the current value of KR1.
4194 This function is only available on Itanium processors.
4196 @return The current value of KR1.
4207 Reads the current value of 64-bit Kernel Register #2 (KR2).
4209 Reads and returns the current value of KR2.
4210 This function is only available on Itanium processors.
4212 @return The current value of KR2.
4223 Reads the current value of 64-bit Kernel Register #3 (KR3).
4225 Reads and returns the current value of KR3.
4226 This function is only available on Itanium processors.
4228 @return The current value of KR3.
4239 Reads the current value of 64-bit Kernel Register #4 (KR4).
4241 Reads and returns the current value of KR4.
4242 This function is only available on Itanium processors.
4244 @return The current value of KR4.
4255 Reads the current value of 64-bit Kernel Register #5 (KR5).
4257 Reads and returns the current value of KR5.
4258 This function is only available on Itanium processors.
4260 @return The current value of KR5.
4271 Reads the current value of 64-bit Kernel Register #6 (KR6).
4273 Reads and returns the current value of KR6.
4274 This function is only available on Itanium processors.
4276 @return The current value of KR6.
4287 Reads the current value of 64-bit Kernel Register #7 (KR7).
4289 Reads and returns the current value of KR7.
4290 This function is only available on Itanium processors.
4292 @return The current value of KR7.
4303 Write the current value of 64-bit Kernel Register #0 (KR0).
4305 Writes the current value of KR0. The 64-bit value written to
4306 the KR0 is returned. This function is only available on Itanium processors.
4308 @param Value The 64-bit value to write to KR0.
4310 @return The 64-bit value written to the KR0.
4321 Write the current value of 64-bit Kernel Register #1 (KR1).
4323 Writes the current value of KR1. The 64-bit value written to
4324 the KR1 is returned. This function is only available on Itanium processors.
4326 @param Value The 64-bit value to write to KR1.
4328 @return The 64-bit value written to the KR1.
4339 Write the current value of 64-bit Kernel Register #2 (KR2).
4341 Writes the current value of KR2. The 64-bit value written to
4342 the KR2 is returned. This function is only available on Itanium processors.
4344 @param Value The 64-bit value to write to KR2.
4346 @return The 64-bit value written to the KR2.
4357 Write the current value of 64-bit Kernel Register #3 (KR3).
4359 Writes the current value of KR3. The 64-bit value written to
4360 the KR3 is returned. This function is only available on Itanium processors.
4362 @param Value The 64-bit value to write to KR3.
4364 @return The 64-bit value written to the KR3.
4375 Write the current value of 64-bit Kernel Register #4 (KR4).
4377 Writes the current value of KR4. The 64-bit value written to
4378 the KR4 is returned. This function is only available on Itanium processors.
4380 @param Value The 64-bit value to write to KR4.
4382 @return The 64-bit value written to the KR4.
4393 Write the current value of 64-bit Kernel Register #5 (KR5).
4395 Writes the current value of KR5. The 64-bit value written to
4396 the KR5 is returned. This function is only available on Itanium processors.
4398 @param Value The 64-bit value to write to KR5.
4400 @return The 64-bit value written to the KR5.
4411 Write the current value of 64-bit Kernel Register #6 (KR6).
4413 Writes the current value of KR6. The 64-bit value written to
4414 the KR6 is returned. This function is only available on Itanium processors.
4416 @param Value The 64-bit value to write to KR6.
4418 @return The 64-bit value written to the KR6.
4429 Write the current value of 64-bit Kernel Register #7 (KR7).
4431 Writes the current value of KR7. The 64-bit value written to
4432 the KR7 is returned. This function is only available on Itanium processors.
4434 @param Value The 64-bit value to write to KR7.
4436 @return The 64-bit value written to the KR7.
4447 Reads the current value of Interval Timer Counter Register (ITC).
4449 Reads and returns the current value of ITC.
4450 This function is only available on Itanium processors.
4452 @return The current value of ITC.
4463 Reads the current value of Interval Timer Vector Register (ITV).
4465 Reads and returns the current value of ITV.
4466 This function is only available on Itanium processors.
4468 @return The current value of ITV.
4479 Reads the current value of Interval Timer Match Register (ITM).
4481 Reads and returns the current value of ITM.
4482 This function is only available on Itanium processors.
4484 @return The current value of ITM.
4494 Writes the current value of 64-bit Interval Timer Counter Register (ITC).
4496 Writes the current value of ITC. The 64-bit value written to the ITC is returned.
4497 This function is only available on Itanium processors.
4499 @param Value The 64-bit value to write to ITC.
4501 @return The 64-bit value written to the ITC.
4512 Writes the current value of 64-bit Interval Timer Match Register (ITM).
4514 Writes the current value of ITM. The 64-bit value written to the ITM is returned.
4515 This function is only available on Itanium processors.
4517 @param Value The 64-bit value to write to ITM.
4519 @return The 64-bit value written to the ITM.
4530 Writes the current value of 64-bit Interval Timer Vector Register (ITV).
4532 Writes the current value of ITV. The 64-bit value written to the ITV is returned.
4533 No parameter checking is performed on Value. All bits of Value corresponding to
4534 reserved fields of ITV must be 0 or a Reserved Register/Field fault may occur.
4535 The caller must either guarantee that Value is valid, or the caller must set up
4536 fault handlers to catch the faults.
4537 This function is only available on Itanium processors.
4539 @param Value The 64-bit value to write to ITV.
4541 @return The 64-bit value written to the ITV.
4552 Reads the current value of Default Control Register (DCR).
4554 Reads and returns the current value of DCR. This function is only available on Itanium processors.
4556 @return The current value of DCR.
4567 Reads the current value of Interruption Vector Address Register (IVA).
4569 Reads and returns the current value of IVA. This function is only available on Itanium processors.
4571 @return The current value of IVA.
4581 Reads the current value of Page Table Address Register (PTA).
4583 Reads and returns the current value of PTA. This function is only available on Itanium processors.
4585 @return The current value of PTA.
4596 Writes the current value of 64-bit Default Control Register (DCR).
4598 Writes the current value of DCR. The 64-bit value written to the DCR is returned.
4599 No parameter checking is performed on Value. All bits of Value corresponding to
4600 reserved fields of DCR must be 0 or a Reserved Register/Field fault may occur.
4601 The caller must either guarantee that Value is valid, or the caller must set up
4602 fault handlers to catch the faults.
4603 This function is only available on Itanium processors.
4605 @param Value The 64-bit value to write to DCR.
4607 @return The 64-bit value written to the DCR.
4618 Writes the current value of 64-bit Interruption Vector Address Register (IVA).
4620 Writes the current value of IVA. The 64-bit value written to the IVA is returned.
4621 The size of vector table is 32 K bytes and is 32 K bytes aligned
4622 the low 15 bits of Value is ignored when written.
4623 This function is only available on Itanium processors.
4625 @param Value The 64-bit value to write to IVA.
4627 @return The 64-bit value written to the IVA.
4638 Writes the current value of 64-bit Page Table Address Register (PTA).
4640 Writes the current value of PTA. The 64-bit value written to the PTA is returned.
4641 No parameter checking is performed on Value. All bits of Value corresponding to
4642 reserved fields of DCR must be 0 or a Reserved Register/Field fault may occur.
4643 The caller must either guarantee that Value is valid, or the caller must set up
4644 fault handlers to catch the faults.
4645 This function is only available on Itanium processors.
4647 @param Value The 64-bit value to write to PTA.
4649 @return The 64-bit value written to the PTA.
4659 Reads the current value of Local Interrupt ID Register (LID).
4661 Reads and returns the current value of LID. This function is only available on Itanium processors.
4663 @return The current value of LID.
4674 Reads the current value of External Interrupt Vector Register (IVR).
4676 Reads and returns the current value of IVR. This function is only available on Itanium processors.
4678 @return The current value of IVR.
4689 Reads the current value of Task Priority Register (TPR).
4691 Reads and returns the current value of TPR. This function is only available on Itanium processors.
4693 @return The current value of TPR.
4704 Reads the current value of External Interrupt Request Register #0 (IRR0).
4706 Reads and returns the current value of IRR0. This function is only available on Itanium processors.
4708 @return The current value of IRR0.
4719 Reads the current value of External Interrupt Request Register #1 (IRR1).
4721 Reads and returns the current value of IRR1. This function is only available on Itanium processors.
4723 @return The current value of IRR1.
4734 Reads the current value of External Interrupt Request Register #2 (IRR2).
4736 Reads and returns the current value of IRR2. This function is only available on Itanium processors.
4738 @return The current value of IRR2.
4749 Reads the current value of External Interrupt Request Register #3 (IRR3).
4751 Reads and returns the current value of IRR3. This function is only available on Itanium processors.
4753 @return The current value of IRR3.
4764 Reads the current value of Performance Monitor Vector Register (PMV).
4766 Reads and returns the current value of PMV. This function is only available on Itanium processors.
4768 @return The current value of PMV.
4779 Reads the current value of Corrected Machine Check Vector Register (CMCV).
4781 Reads and returns the current value of CMCV. This function is only available on Itanium processors.
4783 @return The current value of CMCV.
4794 Reads the current value of Local Redirection Register #0 (LRR0).
4796 Reads and returns the current value of LRR0. This function is only available on Itanium processors.
4798 @return The current value of LRR0.
4809 Reads the current value of Local Redirection Register #1 (LRR1).
4811 Reads and returns the current value of LRR1. This function is only available on Itanium processors.
4813 @return The current value of LRR1.
4824 Writes the current value of 64-bit Page Local Interrupt ID Register (LID).
4826 Writes the current value of LID. The 64-bit value written to the LID is returned.
4827 No parameter checking is performed on Value. All bits of Value corresponding to
4828 reserved fields of LID must be 0 or a Reserved Register/Field fault may occur.
4829 The caller must either guarantee that Value is valid, or the caller must set up
4830 fault handlers to catch the faults.
4831 This function is only available on Itanium processors.
4833 @param Value The 64-bit value to write to LID.
4835 @return The 64-bit value written to the LID.
4846 Writes the current value of 64-bit Task Priority Register (TPR).
4848 Writes the current value of TPR. The 64-bit value written to the TPR is returned.
4849 No parameter checking is performed on Value. All bits of Value corresponding to
4850 reserved fields of TPR must be 0 or a Reserved Register/Field fault may occur.
4851 The caller must either guarantee that Value is valid, or the caller must set up
4852 fault handlers to catch the faults.
4853 This function is only available on Itanium processors.
4855 @param Value The 64-bit value to write to TPR.
4857 @return The 64-bit value written to the TPR.
4868 Performs a write operation on End OF External Interrupt Register (EOI).
4870 Writes a value of 0 to the EOI Register. This function is only available on Itanium processors.
4881 Writes the current value of 64-bit Performance Monitor Vector Register (PMV).
4883 Writes the current value of PMV. The 64-bit value written to the PMV is returned.
4884 No parameter checking is performed on Value. All bits of Value corresponding
4885 to reserved fields of PMV must be 0 or a Reserved Register/Field fault may occur.
4886 The caller must either guarantee that Value is valid, or the caller must set up
4887 fault handlers to catch the faults.
4888 This function is only available on Itanium processors.
4890 @param Value The 64-bit value to write to PMV.
4892 @return The 64-bit value written to the PMV.
4903 Writes the current value of 64-bit Corrected Machine Check Vector Register (CMCV).
4905 Writes the current value of CMCV. The 64-bit value written to the CMCV is returned.
4906 No parameter checking is performed on Value. All bits of Value corresponding
4907 to reserved fields of CMCV must be 0 or a Reserved Register/Field fault may occur.
4908 The caller must either guarantee that Value is valid, or the caller must set up
4909 fault handlers to catch the faults.
4910 This function is only available on Itanium processors.
4912 @param Value The 64-bit value to write to CMCV.
4914 @return The 64-bit value written to the CMCV.
4925 Writes the current value of 64-bit Local Redirection Register #0 (LRR0).
4927 Writes the current value of LRR0. The 64-bit value written to the LRR0 is returned.
4928 No parameter checking is performed on Value. All bits of Value corresponding
4929 to reserved fields of LRR0 must be 0 or a Reserved Register/Field fault may occur.
4930 The caller must either guarantee that Value is valid, or the caller must set up
4931 fault handlers to catch the faults.
4932 This function is only available on Itanium processors.
4934 @param Value The 64-bit value to write to LRR0.
4936 @return The 64-bit value written to the LRR0.
4947 Writes the current value of 64-bit Local Redirection Register #1 (LRR1).
4949 Writes the current value of LRR1. The 64-bit value written to the LRR1 is returned.
4950 No parameter checking is performed on Value. All bits of Value corresponding
4951 to reserved fields of LRR1 must be 0 or a Reserved Register/Field fault may occur.
4952 The caller must either guarantee that Value is valid, or the caller must
4953 set up fault handlers to catch the faults.
4954 This function is only available on Itanium processors.
4956 @param Value The 64-bit value to write to LRR1.
4958 @return The 64-bit value written to the LRR1.
4969 Reads the current value of Instruction Breakpoint Register (IBR).
4971 The Instruction Breakpoint Registers are used in pairs. The even numbered
4972 registers contain breakpoint addresses, and the odd numbered registers contain
4973 breakpoint mask conditions. At least four instruction registers pairs are implemented
4974 on all processor models. Implemented registers are contiguous starting with
4975 register 0. No parameter checking is performed on Index, and if the Index value
4976 is beyond the implemented IBR register range, a Reserved Register/Field fault may
4977 occur. The caller must either guarantee that Index is valid, or the caller must
4978 set up fault handlers to catch the faults.
4979 This function is only available on Itanium processors.
4981 @param Index The 8-bit Instruction Breakpoint Register index to read.
4983 @return The current value of Instruction Breakpoint Register specified by Index.
4994 Reads the current value of Data Breakpoint Register (DBR).
4996 The Data Breakpoint Registers are used in pairs. The even numbered registers
4997 contain breakpoint addresses, and odd numbered registers contain breakpoint
4998 mask conditions. At least four data registers pairs are implemented on all processor
4999 models. Implemented registers are contiguous starting with register 0.
5000 No parameter checking is performed on Index. If the Index value is beyond
5001 the implemented DBR register range, a Reserved Register/Field fault may occur.
5002 The caller must either guarantee that Index is valid, or the caller must set up
5003 fault handlers to catch the faults.
5004 This function is only available on Itanium processors.
5006 @param Index The 8-bit Data Breakpoint Register index to read.
5008 @return The current value of Data Breakpoint Register specified by Index.
5019 Reads the current value of Performance Monitor Configuration Register (PMC).
5021 All processor implementations provide at least four performance counters
5022 (PMC/PMD [4]...PMC/PMD [7] pairs), and four performance monitor counter overflow
5023 status registers (PMC [0]... PMC [3]). Processor implementations may provide
5024 additional implementation-dependent PMC and PMD to increase the number of
5025 'generic' performance counters (PMC/PMD pairs). The remainder of PMC and PMD
5026 register set is implementation dependent. No parameter checking is performed
5027 on Index. If the Index value is beyond the implemented PMC register range,
5028 zero value will be returned.
5029 This function is only available on Itanium processors.
5031 @param Index The 8-bit Performance Monitor Configuration Register index to read.
5033 @return The current value of Performance Monitor Configuration Register
5045 Reads the current value of Performance Monitor Data Register (PMD).
5047 All processor implementations provide at least 4 performance counters
5048 (PMC/PMD [4]...PMC/PMD [7] pairs), and 4 performance monitor counter
5049 overflow status registers (PMC [0]... PMC [3]). Processor implementations may
5050 provide additional implementation-dependent PMC and PMD to increase the number
5051 of 'generic' performance counters (PMC/PMD pairs). The remainder of PMC and PMD
5052 register set is implementation dependent. No parameter checking is performed
5053 on Index. If the Index value is beyond the implemented PMD register range,
5054 zero value will be returned.
5055 This function is only available on Itanium processors.
5057 @param Index The 8-bit Performance Monitor Data Register index to read.
5059 @return The current value of Performance Monitor Data Register specified by Index.
5070 Writes the current value of 64-bit Instruction Breakpoint Register (IBR).
5072 Writes current value of Instruction Breakpoint Register specified by Index.
5073 The Instruction Breakpoint Registers are used in pairs. The even numbered
5074 registers contain breakpoint addresses, and odd numbered registers contain
5075 breakpoint mask conditions. At least four instruction registers pairs are implemented
5076 on all processor models. Implemented registers are contiguous starting with
5077 register 0. No parameter checking is performed on Index. If the Index value
5078 is beyond the implemented IBR register range, a Reserved Register/Field fault may
5079 occur. The caller must either guarantee that Index is valid, or the caller must
5080 set up fault handlers to catch the faults.
5081 This function is only available on Itanium processors.
5083 @param Index The 8-bit Instruction Breakpoint Register index to write.
5084 @param Value The 64-bit value to write to IBR.
5086 @return The 64-bit value written to the IBR.
5098 Writes the current value of 64-bit Data Breakpoint Register (DBR).
5100 Writes current value of Data Breakpoint Register specified by Index.
5101 The Data Breakpoint Registers are used in pairs. The even numbered registers
5102 contain breakpoint addresses, and odd numbered registers contain breakpoint
5103 mask conditions. At least four data registers pairs are implemented on all processor
5104 models. Implemented registers are contiguous starting with register 0. No parameter
5105 checking is performed on Index. If the Index value is beyond the implemented
5106 DBR register range, a Reserved Register/Field fault may occur. The caller must
5107 either guarantee that Index is valid, or the caller must set up fault handlers to
5109 This function is only available on Itanium processors.
5111 @param Index The 8-bit Data Breakpoint Register index to write.
5112 @param Value The 64-bit value to write to DBR.
5114 @return The 64-bit value written to the DBR.
5126 Writes the current value of 64-bit Performance Monitor Configuration Register (PMC).
5128 Writes current value of Performance Monitor Configuration Register specified by Index.
5129 All processor implementations provide at least four performance counters
5130 (PMC/PMD [4]...PMC/PMD [7] pairs), and four performance monitor counter overflow status
5131 registers (PMC [0]... PMC [3]). Processor implementations may provide additional
5132 implementation-dependent PMC and PMD to increase the number of 'generic' performance
5133 counters (PMC/PMD pairs). The remainder of PMC and PMD register set is implementation
5134 dependent. No parameter checking is performed on Index. If the Index value is
5135 beyond the implemented PMC register range, the write is ignored.
5136 This function is only available on Itanium processors.
5138 @param Index The 8-bit Performance Monitor Configuration Register index to write.
5139 @param Value The 64-bit value to write to PMC.
5141 @return The 64-bit value written to the PMC.
5153 Writes the current value of 64-bit Performance Monitor Data Register (PMD).
5155 Writes current value of Performance Monitor Data Register specified by Index.
5156 All processor implementations provide at least four performance counters
5157 (PMC/PMD [4]...PMC/PMD [7] pairs), and four performance monitor counter overflow
5158 status registers (PMC [0]... PMC [3]). Processor implementations may provide
5159 additional implementation-dependent PMC and PMD to increase the number of 'generic'
5160 performance counters (PMC/PMD pairs). The remainder of PMC and PMD register set
5161 is implementation dependent. No parameter checking is performed on Index. If the
5162 Index value is beyond the implemented PMD register range, the write is ignored.
5163 This function is only available on Itanium processors.
5165 @param Index The 8-bit Performance Monitor Data Register index to write.
5166 @param Value The 64-bit value to write to PMD.
5168 @return The 64-bit value written to the PMD.
5180 Reads the current value of 64-bit Global Pointer (GP).
5182 Reads and returns the current value of GP.
5183 This function is only available on Itanium processors.
5185 @return The current value of GP.
5196 Write the current value of 64-bit Global Pointer (GP).
5198 Writes the current value of GP. The 64-bit value written to the GP is returned.
5199 No parameter checking is performed on Value.
5200 This function is only available on Itanium processors.
5202 @param Value The 64-bit value to write to GP.
5204 @return The 64-bit value written to the GP.
5215 Reads the current value of 64-bit Stack Pointer (SP).
5217 Reads and returns the current value of SP.
5218 This function is only available on Itanium processors.
5220 @return The current value of SP.
5231 /// Valid Index value for AsmReadControlRegister().
5233 #define IPF_CONTROL_REGISTER_DCR 0
5234 #define IPF_CONTROL_REGISTER_ITM 1
5235 #define IPF_CONTROL_REGISTER_IVA 2
5236 #define IPF_CONTROL_REGISTER_PTA 8
5237 #define IPF_CONTROL_REGISTER_IPSR 16
5238 #define IPF_CONTROL_REGISTER_ISR 17
5239 #define IPF_CONTROL_REGISTER_IIP 19
5240 #define IPF_CONTROL_REGISTER_IFA 20
5241 #define IPF_CONTROL_REGISTER_ITIR 21
5242 #define IPF_CONTROL_REGISTER_IIPA 22
5243 #define IPF_CONTROL_REGISTER_IFS 23
5244 #define IPF_CONTROL_REGISTER_IIM 24
5245 #define IPF_CONTROL_REGISTER_IHA 25
5246 #define IPF_CONTROL_REGISTER_LID 64
5247 #define IPF_CONTROL_REGISTER_IVR 65
5248 #define IPF_CONTROL_REGISTER_TPR 66
5249 #define IPF_CONTROL_REGISTER_EOI 67
5250 #define IPF_CONTROL_REGISTER_IRR0 68
5251 #define IPF_CONTROL_REGISTER_IRR1 69
5252 #define IPF_CONTROL_REGISTER_IRR2 70
5253 #define IPF_CONTROL_REGISTER_IRR3 71
5254 #define IPF_CONTROL_REGISTER_ITV 72
5255 #define IPF_CONTROL_REGISTER_PMV 73
5256 #define IPF_CONTROL_REGISTER_CMCV 74
5257 #define IPF_CONTROL_REGISTER_LRR0 80
5258 #define IPF_CONTROL_REGISTER_LRR1 81
5261 Reads a 64-bit control register.
5263 Reads and returns the control register specified by Index. The valid Index valued
5264 are defined above in "Related Definitions".
5265 If Index is invalid then 0xFFFFFFFFFFFFFFFF is returned. This function is only
5266 available on Itanium processors.
5268 @param Index The index of the control register to read.
5270 @return The control register specified by Index.
5275 AsmReadControlRegister (
5281 /// Valid Index value for AsmReadApplicationRegister().
5283 #define IPF_APPLICATION_REGISTER_K0 0
5284 #define IPF_APPLICATION_REGISTER_K1 1
5285 #define IPF_APPLICATION_REGISTER_K2 2
5286 #define IPF_APPLICATION_REGISTER_K3 3
5287 #define IPF_APPLICATION_REGISTER_K4 4
5288 #define IPF_APPLICATION_REGISTER_K5 5
5289 #define IPF_APPLICATION_REGISTER_K6 6
5290 #define IPF_APPLICATION_REGISTER_K7 7
5291 #define IPF_APPLICATION_REGISTER_RSC 16
5292 #define IPF_APPLICATION_REGISTER_BSP 17
5293 #define IPF_APPLICATION_REGISTER_BSPSTORE 18
5294 #define IPF_APPLICATION_REGISTER_RNAT 19
5295 #define IPF_APPLICATION_REGISTER_FCR 21
5296 #define IPF_APPLICATION_REGISTER_EFLAG 24
5297 #define IPF_APPLICATION_REGISTER_CSD 25
5298 #define IPF_APPLICATION_REGISTER_SSD 26
5299 #define IPF_APPLICATION_REGISTER_CFLG 27
5300 #define IPF_APPLICATION_REGISTER_FSR 28
5301 #define IPF_APPLICATION_REGISTER_FIR 29
5302 #define IPF_APPLICATION_REGISTER_FDR 30
5303 #define IPF_APPLICATION_REGISTER_CCV 32
5304 #define IPF_APPLICATION_REGISTER_UNAT 36
5305 #define IPF_APPLICATION_REGISTER_FPSR 40
5306 #define IPF_APPLICATION_REGISTER_ITC 44
5307 #define IPF_APPLICATION_REGISTER_PFS 64
5308 #define IPF_APPLICATION_REGISTER_LC 65
5309 #define IPF_APPLICATION_REGISTER_EC 66
5312 Reads a 64-bit application register.
5314 Reads and returns the application register specified by Index. The valid Index
5315 valued are defined above in "Related Definitions".
5316 If Index is invalid then 0xFFFFFFFFFFFFFFFF is returned. This function is only
5317 available on Itanium processors.
5319 @param Index The index of the application register to read.
5321 @return The application register specified by Index.
5326 AsmReadApplicationRegister (
5332 Reads the current value of a Machine Specific Register (MSR).
5334 Reads and returns the current value of the Machine Specific Register specified by Index. No
5335 parameter checking is performed on Index, and if the Index value is beyond the implemented MSR
5336 register range, a Reserved Register/Field fault may occur. The caller must either guarantee that
5337 Index is valid, or the caller must set up fault handlers to catch the faults. This function is
5338 only available on Itanium processors.
5340 @param Index The 8-bit Machine Specific Register index to read.
5342 @return The current value of the Machine Specific Register specified by Index.
5353 Writes the current value of a Machine Specific Register (MSR).
5355 Writes Value to the Machine Specific Register specified by Index. Value is returned. No
5356 parameter checking is performed on Index, and if the Index value is beyond the implemented MSR
5357 register range, a Reserved Register/Field fault may occur. The caller must either guarantee that
5358 Index is valid, or the caller must set up fault handlers to catch the faults. This function is
5359 only available on Itanium processors.
5361 @param Index The 8-bit Machine Specific Register index to write.
5362 @param Value The 64-bit value to write to the Machine Specific Register.
5364 @return The 64-bit value to write to the Machine Specific Register.
5376 Determines if the CPU is currently executing in virtual, physical, or mixed mode.
5378 Determines the current execution mode of the CPU.
5379 If the CPU is in virtual mode(PSR.RT=1, PSR.DT=1, PSR.IT=1), then 1 is returned.
5380 If the CPU is in physical mode(PSR.RT=0, PSR.DT=0, PSR.IT=0), then 0 is returned.
5381 If the CPU is not in physical mode or virtual mode, then it is in mixed mode,
5383 This function is only available on Itanium processors.
5385 @retval 1 The CPU is in virtual mode.
5386 @retval 0 The CPU is in physical mode.
5387 @retval -1 The CPU is in mixed mode.
5398 Makes a PAL procedure call.
5400 This is a wrapper function to make a PAL procedure call. Based on the Index
5401 value this API will make static or stacked PAL call. The following table
5402 describes the usage of PAL Procedure Index Assignment. Architected procedures
5403 may be designated as required or optional. If a PAL procedure is specified
5404 as optional, a unique return code of 0xFFFFFFFFFFFFFFFF is returned in the
5405 Status field of the PAL_CALL_RETURN structure.
5406 This indicates that the procedure is not present in this PAL implementation.
5407 It is the caller's responsibility to check for this return code after calling
5408 any optional PAL procedure.
5409 No parameter checking is performed on the 5 input parameters, but there are
5410 some common rules that the caller should follow when making a PAL call. Any
5411 address passed to PAL as buffers for return parameters must be 8-byte aligned.
5412 Unaligned addresses may cause undefined results. For those parameters defined
5413 as reserved or some fields defined as reserved must be zero filled or the invalid
5414 argument return value may be returned or undefined result may occur during the
5415 execution of the procedure. If the PalEntryPoint does not point to a valid
5416 PAL entry point then the system behavior is undefined. This function is only
5417 available on Itanium processors.
5419 @param PalEntryPoint The PAL procedure calls entry point.
5420 @param Index The PAL procedure Index number.
5421 @param Arg2 The 2nd parameter for PAL procedure calls.
5422 @param Arg3 The 3rd parameter for PAL procedure calls.
5423 @param Arg4 The 4th parameter for PAL procedure calls.
5425 @return structure returned from the PAL Call procedure, including the status and return value.
5431 IN UINT64 PalEntryPoint
,
5439 #if defined (MDE_CPU_IA32) || defined (MDE_CPU_X64)
5441 /// IA32 and x64 Specific Functions.
5442 /// Byte packed structure for 16-bit Real Mode EFLAGS.
5446 UINT32 CF
:1; ///< Carry Flag.
5447 UINT32 Reserved_0
:1; ///< Reserved.
5448 UINT32 PF
:1; ///< Parity Flag.
5449 UINT32 Reserved_1
:1; ///< Reserved.
5450 UINT32 AF
:1; ///< Auxiliary Carry Flag.
5451 UINT32 Reserved_2
:1; ///< Reserved.
5452 UINT32 ZF
:1; ///< Zero Flag.
5453 UINT32 SF
:1; ///< Sign Flag.
5454 UINT32 TF
:1; ///< Trap Flag.
5455 UINT32 IF
:1; ///< Interrupt Enable Flag.
5456 UINT32 DF
:1; ///< Direction Flag.
5457 UINT32 OF
:1; ///< Overflow Flag.
5458 UINT32 IOPL
:2; ///< I/O Privilege Level.
5459 UINT32 NT
:1; ///< Nested Task.
5460 UINT32 Reserved_3
:1; ///< Reserved.
5466 /// Byte packed structure for EFLAGS/RFLAGS.
5467 /// 32-bits on IA-32.
5468 /// 64-bits on x64. The upper 32-bits on x64 are reserved.
5472 UINT32 CF
:1; ///< Carry Flag.
5473 UINT32 Reserved_0
:1; ///< Reserved.
5474 UINT32 PF
:1; ///< Parity Flag.
5475 UINT32 Reserved_1
:1; ///< Reserved.
5476 UINT32 AF
:1; ///< Auxiliary Carry Flag.
5477 UINT32 Reserved_2
:1; ///< Reserved.
5478 UINT32 ZF
:1; ///< Zero Flag.
5479 UINT32 SF
:1; ///< Sign Flag.
5480 UINT32 TF
:1; ///< Trap Flag.
5481 UINT32 IF
:1; ///< Interrupt Enable Flag.
5482 UINT32 DF
:1; ///< Direction Flag.
5483 UINT32 OF
:1; ///< Overflow Flag.
5484 UINT32 IOPL
:2; ///< I/O Privilege Level.
5485 UINT32 NT
:1; ///< Nested Task.
5486 UINT32 Reserved_3
:1; ///< Reserved.
5487 UINT32 RF
:1; ///< Resume Flag.
5488 UINT32 VM
:1; ///< Virtual 8086 Mode.
5489 UINT32 AC
:1; ///< Alignment Check.
5490 UINT32 VIF
:1; ///< Virtual Interrupt Flag.
5491 UINT32 VIP
:1; ///< Virtual Interrupt Pending.
5492 UINT32 ID
:1; ///< ID Flag.
5493 UINT32 Reserved_4
:10; ///< Reserved.
5499 /// Byte packed structure for Control Register 0 (CR0).
5500 /// 32-bits on IA-32.
5501 /// 64-bits on x64. The upper 32-bits on x64 are reserved.
5505 UINT32 PE
:1; ///< Protection Enable.
5506 UINT32 MP
:1; ///< Monitor Coprocessor.
5507 UINT32 EM
:1; ///< Emulation.
5508 UINT32 TS
:1; ///< Task Switched.
5509 UINT32 ET
:1; ///< Extension Type.
5510 UINT32 NE
:1; ///< Numeric Error.
5511 UINT32 Reserved_0
:10; ///< Reserved.
5512 UINT32 WP
:1; ///< Write Protect.
5513 UINT32 Reserved_1
:1; ///< Reserved.
5514 UINT32 AM
:1; ///< Alignment Mask.
5515 UINT32 Reserved_2
:10; ///< Reserved.
5516 UINT32 NW
:1; ///< Mot Write-through.
5517 UINT32 CD
:1; ///< Cache Disable.
5518 UINT32 PG
:1; ///< Paging.
5524 /// Byte packed structure for Control Register 4 (CR4).
5525 /// 32-bits on IA-32.
5526 /// 64-bits on x64. The upper 32-bits on x64 are reserved.
5530 UINT32 VME
:1; ///< Virtual-8086 Mode Extensions.
5531 UINT32 PVI
:1; ///< Protected-Mode Virtual Interrupts.
5532 UINT32 TSD
:1; ///< Time Stamp Disable.
5533 UINT32 DE
:1; ///< Debugging Extensions.
5534 UINT32 PSE
:1; ///< Page Size Extensions.
5535 UINT32 PAE
:1; ///< Physical Address Extension.
5536 UINT32 MCE
:1; ///< Machine Check Enable.
5537 UINT32 PGE
:1; ///< Page Global Enable.
5538 UINT32 PCE
:1; ///< Performance Monitoring Counter
5540 UINT32 OSFXSR
:1; ///< Operating System Support for
5541 ///< FXSAVE and FXRSTOR instructions
5542 UINT32 OSXMMEXCPT
:1; ///< Operating System Support for
5543 ///< Unmasked SIMD Floating Point
5545 UINT32 Reserved_0
:2; ///< Reserved.
5546 UINT32 VMXE
:1; ///< VMX Enable
5547 UINT32 Reserved_1
:18; ///< Reserved.
5553 /// Byte packed structure for a segment descriptor in a GDT/LDT.
5572 } IA32_SEGMENT_DESCRIPTOR
;
5575 /// Byte packed structure for an IDTR, GDTR, LDTR descriptor.
5584 #define IA32_IDT_GATE_TYPE_TASK 0x85
5585 #define IA32_IDT_GATE_TYPE_INTERRUPT_16 0x86
5586 #define IA32_IDT_GATE_TYPE_TRAP_16 0x87
5587 #define IA32_IDT_GATE_TYPE_INTERRUPT_32 0x8E
5588 #define IA32_IDT_GATE_TYPE_TRAP_32 0x8F
5591 #if defined (MDE_CPU_IA32)
5593 /// Byte packed structure for an IA-32 Interrupt Gate Descriptor.
5597 UINT32 OffsetLow
:16; ///< Offset bits 15..0.
5598 UINT32 Selector
:16; ///< Selector.
5599 UINT32 Reserved_0
:8; ///< Reserved.
5600 UINT32 GateType
:8; ///< Gate Type. See #defines above.
5601 UINT32 OffsetHigh
:16; ///< Offset bits 31..16.
5604 } IA32_IDT_GATE_DESCRIPTOR
;
5608 #if defined (MDE_CPU_X64)
5610 /// Byte packed structure for an x64 Interrupt Gate Descriptor.
5614 UINT32 OffsetLow
:16; ///< Offset bits 15..0.
5615 UINT32 Selector
:16; ///< Selector.
5616 UINT32 Reserved_0
:8; ///< Reserved.
5617 UINT32 GateType
:8; ///< Gate Type. See #defines above.
5618 UINT32 OffsetHigh
:16; ///< Offset bits 31..16.
5619 UINT32 OffsetUpper
:32; ///< Offset bits 63..32.
5620 UINT32 Reserved_1
:32; ///< Reserved.
5626 } IA32_IDT_GATE_DESCRIPTOR
;
5631 /// Byte packed structure for an FP/SSE/SSE2 context.
5638 /// Structures for the 16-bit real mode thunks.
5691 IA32_EFLAGS32 EFLAGS
;
5701 } IA32_REGISTER_SET
;
5704 /// Byte packed structure for an 16-bit real mode thunks.
5707 IA32_REGISTER_SET
*RealModeState
;
5708 VOID
*RealModeBuffer
;
5709 UINT32 RealModeBufferSize
;
5710 UINT32 ThunkAttributes
;
5713 #define THUNK_ATTRIBUTE_BIG_REAL_MODE 0x00000001
5714 #define THUNK_ATTRIBUTE_DISABLE_A20_MASK_INT_15 0x00000002
5715 #define THUNK_ATTRIBUTE_DISABLE_A20_MASK_KBD_CTRL 0x00000004
5718 Retrieves CPUID information.
5720 Executes the CPUID instruction with EAX set to the value specified by Index.
5721 This function always returns Index.
5722 If Eax is not NULL, then the value of EAX after CPUID is returned in Eax.
5723 If Ebx is not NULL, then the value of EBX after CPUID is returned in Ebx.
5724 If Ecx is not NULL, then the value of ECX after CPUID is returned in Ecx.
5725 If Edx is not NULL, then the value of EDX after CPUID is returned in Edx.
5726 This function is only available on IA-32 and x64.
5728 @param Index The 32-bit value to load into EAX prior to invoking the CPUID
5730 @param Eax The pointer to the 32-bit EAX value returned by the CPUID
5731 instruction. This is an optional parameter that may be NULL.
5732 @param Ebx The pointer to the 32-bit EBX value returned by the CPUID
5733 instruction. This is an optional parameter that may be NULL.
5734 @param Ecx The pointer to the 32-bit ECX value returned by the CPUID
5735 instruction. This is an optional parameter that may be NULL.
5736 @param Edx The pointer to the 32-bit EDX value returned by the CPUID
5737 instruction. This is an optional parameter that may be NULL.
5746 OUT UINT32
*Eax
, OPTIONAL
5747 OUT UINT32
*Ebx
, OPTIONAL
5748 OUT UINT32
*Ecx
, OPTIONAL
5749 OUT UINT32
*Edx OPTIONAL
5754 Retrieves CPUID information using an extended leaf identifier.
5756 Executes the CPUID instruction with EAX set to the value specified by Index
5757 and ECX set to the value specified by SubIndex. This function always returns
5758 Index. This function is only available on IA-32 and x64.
5760 If Eax is not NULL, then the value of EAX after CPUID is returned in Eax.
5761 If Ebx is not NULL, then the value of EBX after CPUID is returned in Ebx.
5762 If Ecx is not NULL, then the value of ECX after CPUID is returned in Ecx.
5763 If Edx is not NULL, then the value of EDX after CPUID is returned in Edx.
5765 @param Index The 32-bit value to load into EAX prior to invoking the
5767 @param SubIndex The 32-bit value to load into ECX prior to invoking the
5769 @param Eax The pointer to the 32-bit EAX value returned by the CPUID
5770 instruction. This is an optional parameter that may be
5772 @param Ebx The pointer to the 32-bit EBX value returned by the CPUID
5773 instruction. This is an optional parameter that may be
5775 @param Ecx The pointer to the 32-bit ECX value returned by the CPUID
5776 instruction. This is an optional parameter that may be
5778 @param Edx The pointer to the 32-bit EDX value returned by the CPUID
5779 instruction. This is an optional parameter that may be
5790 OUT UINT32
*Eax
, OPTIONAL
5791 OUT UINT32
*Ebx
, OPTIONAL
5792 OUT UINT32
*Ecx
, OPTIONAL
5793 OUT UINT32
*Edx OPTIONAL
5798 Set CD bit and clear NW bit of CR0 followed by a WBINVD.
5800 Disables the caches by setting the CD bit of CR0 to 1, clearing the NW bit of CR0 to 0,
5801 and executing a WBINVD instruction. This function is only available on IA-32 and x64.
5812 Perform a WBINVD and clear both the CD and NW bits of CR0.
5814 Enables the caches by executing a WBINVD instruction and then clear both the CD and NW
5815 bits of CR0 to 0. This function is only available on IA-32 and x64.
5826 Returns the lower 32-bits of a Machine Specific Register(MSR).
5828 Reads and returns the lower 32-bits of the MSR specified by Index.
5829 No parameter checking is performed on Index, and some Index values may cause
5830 CPU exceptions. The caller must either guarantee that Index is valid, or the
5831 caller must set up exception handlers to catch the exceptions. This function
5832 is only available on IA-32 and x64.
5834 @param Index The 32-bit MSR index to read.
5836 @return The lower 32 bits of the MSR identified by Index.
5847 Writes a 32-bit value to a Machine Specific Register(MSR), and returns the value.
5848 The upper 32-bits of the MSR are set to zero.
5850 Writes the 32-bit value specified by Value to the MSR specified by Index. The
5851 upper 32-bits of the MSR write are set to zero. The 32-bit value written to
5852 the MSR is returned. No parameter checking is performed on Index or Value,
5853 and some of these may cause CPU exceptions. The caller must either guarantee
5854 that Index and Value are valid, or the caller must establish proper exception
5855 handlers. This function is only available on IA-32 and x64.
5857 @param Index The 32-bit MSR index to write.
5858 @param Value The 32-bit value to write to the MSR.
5872 Reads a 64-bit MSR, performs a bitwise OR on the lower 32-bits, and
5873 writes the result back to the 64-bit MSR.
5875 Reads the 64-bit MSR specified by Index, performs a bitwise OR
5876 between the lower 32-bits of the read result and the value specified by
5877 OrData, and writes the result to the 64-bit MSR specified by Index. The lower
5878 32-bits of the value written to the MSR is returned. No parameter checking is
5879 performed on Index or OrData, and some of these may cause CPU exceptions. The
5880 caller must either guarantee that Index and OrData are valid, or the caller
5881 must establish proper exception handlers. This function is only available on
5884 @param Index The 32-bit MSR index to write.
5885 @param OrData The value to OR with the read value from the MSR.
5887 @return The lower 32-bit value written to the MSR.
5899 Reads a 64-bit MSR, performs a bitwise AND on the lower 32-bits, and writes
5900 the result back to the 64-bit MSR.
5902 Reads the 64-bit MSR specified by Index, performs a bitwise AND between the
5903 lower 32-bits of the read result and the value specified by AndData, and
5904 writes the result to the 64-bit MSR specified by Index. The lower 32-bits of
5905 the value written to the MSR is returned. No parameter checking is performed
5906 on Index or AndData, and some of these may cause CPU exceptions. The caller
5907 must either guarantee that Index and AndData are valid, or the caller must
5908 establish proper exception handlers. This function is only available on IA-32
5911 @param Index The 32-bit MSR index to write.
5912 @param AndData The value to AND with the read value from the MSR.
5914 @return The lower 32-bit value written to the MSR.
5926 Reads a 64-bit MSR, performs a bitwise AND followed by a bitwise OR
5927 on the lower 32-bits, and writes the result back to the 64-bit MSR.
5929 Reads the 64-bit MSR specified by Index, performs a bitwise AND between the
5930 lower 32-bits of the read result and the value specified by AndData
5931 preserving the upper 32-bits, performs a bitwise OR between the
5932 result of the AND operation and the value specified by OrData, and writes the
5933 result to the 64-bit MSR specified by Address. The lower 32-bits of the value
5934 written to the MSR is returned. No parameter checking is performed on Index,
5935 AndData, or OrData, and some of these may cause CPU exceptions. The caller
5936 must either guarantee that Index, AndData, and OrData are valid, or the
5937 caller must establish proper exception handlers. This function is only
5938 available on IA-32 and x64.
5940 @param Index The 32-bit MSR index to write.
5941 @param AndData The value to AND with the read value from the MSR.
5942 @param OrData The value to OR with the result of the AND operation.
5944 @return The lower 32-bit value written to the MSR.
5957 Reads a bit field of an MSR.
5959 Reads the bit field in the lower 32-bits of a 64-bit MSR. The bit field is
5960 specified by the StartBit and the EndBit. The value of the bit field is
5961 returned. The caller must either guarantee that Index is valid, or the caller
5962 must set up exception handlers to catch the exceptions. This function is only
5963 available on IA-32 and x64.
5965 If StartBit is greater than 31, then ASSERT().
5966 If EndBit is greater than 31, then ASSERT().
5967 If EndBit is less than StartBit, then ASSERT().
5969 @param Index The 32-bit MSR index to read.
5970 @param StartBit The ordinal of the least significant bit in the bit field.
5972 @param EndBit The ordinal of the most significant bit in the bit field.
5975 @return The bit field read from the MSR.
5980 AsmMsrBitFieldRead32 (
5988 Writes a bit field to an MSR.
5990 Writes Value to a bit field in the lower 32-bits of a 64-bit MSR. The bit
5991 field is specified by the StartBit and the EndBit. All other bits in the
5992 destination MSR are preserved. The lower 32-bits of the MSR written is
5993 returned. The caller must either guarantee that Index and the data written
5994 is valid, or the caller must set up exception handlers to catch the exceptions.
5995 This function is only available on IA-32 and x64.
5997 If StartBit is greater than 31, then ASSERT().
5998 If EndBit is greater than 31, then ASSERT().
5999 If EndBit is less than StartBit, then ASSERT().
6000 If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
6002 @param Index The 32-bit MSR index to write.
6003 @param StartBit The ordinal of the least significant bit in the bit field.
6005 @param EndBit The ordinal of the most significant bit in the bit field.
6007 @param Value New value of the bit field.
6009 @return The lower 32-bit of the value written to the MSR.
6014 AsmMsrBitFieldWrite32 (
6023 Reads a bit field in a 64-bit MSR, performs a bitwise OR, and writes the
6024 result back to the bit field in the 64-bit MSR.
6026 Reads the 64-bit MSR specified by Index, performs a bitwise OR
6027 between the read result and the value specified by OrData, and writes the
6028 result to the 64-bit MSR specified by Index. The lower 32-bits of the value
6029 written to the MSR are returned. Extra left bits in OrData are stripped. The
6030 caller must either guarantee that Index and the data written is valid, or
6031 the caller must set up exception handlers to catch the exceptions. This
6032 function is only available on IA-32 and x64.
6034 If StartBit is greater than 31, then ASSERT().
6035 If EndBit is greater than 31, then ASSERT().
6036 If EndBit is less than StartBit, then ASSERT().
6037 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
6039 @param Index The 32-bit MSR index to write.
6040 @param StartBit The ordinal of the least significant bit in the bit field.
6042 @param EndBit The ordinal of the most significant bit in the bit field.
6044 @param OrData The value to OR with the read value from the MSR.
6046 @return The lower 32-bit of the value written to the MSR.
6051 AsmMsrBitFieldOr32 (
6060 Reads a bit field in a 64-bit MSR, performs a bitwise AND, and writes the
6061 result back to the bit field in the 64-bit MSR.
6063 Reads the 64-bit MSR specified by Index, performs a bitwise AND between the
6064 read result and the value specified by AndData, and writes the result to the
6065 64-bit MSR specified by Index. The lower 32-bits of the value written to the
6066 MSR are returned. Extra left bits in AndData are stripped. The caller must
6067 either guarantee that Index and the data written is valid, or the caller must
6068 set up exception handlers to catch the exceptions. This function is only
6069 available on IA-32 and x64.
6071 If StartBit is greater than 31, then ASSERT().
6072 If EndBit is greater than 31, then ASSERT().
6073 If EndBit is less than StartBit, then ASSERT().
6074 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
6076 @param Index The 32-bit MSR index to write.
6077 @param StartBit The ordinal of the least significant bit in the bit field.
6079 @param EndBit The ordinal of the most significant bit in the bit field.
6081 @param AndData The value to AND with the read value from the MSR.
6083 @return The lower 32-bit of the value written to the MSR.
6088 AsmMsrBitFieldAnd32 (
6097 Reads a bit field in a 64-bit MSR, performs a bitwise AND followed by a
6098 bitwise OR, and writes the result back to the bit field in the
6101 Reads the 64-bit MSR specified by Index, performs a bitwise AND followed by a
6102 bitwise OR between the read result and the value specified by
6103 AndData, and writes the result to the 64-bit MSR specified by Index. The
6104 lower 32-bits of the value written to the MSR are returned. Extra left bits
6105 in both AndData and OrData are stripped. The caller must either guarantee
6106 that Index and the data written is valid, or the caller must set up exception
6107 handlers to catch the exceptions. This function is only available on IA-32
6110 If StartBit is greater than 31, then ASSERT().
6111 If EndBit is greater than 31, then ASSERT().
6112 If EndBit is less than StartBit, then ASSERT().
6113 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
6114 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
6116 @param Index The 32-bit MSR index to write.
6117 @param StartBit The ordinal of the least significant bit in the bit field.
6119 @param EndBit The ordinal of the most significant bit in the bit field.
6121 @param AndData The value to AND with the read value from the MSR.
6122 @param OrData The value to OR with the result of the AND operation.
6124 @return The lower 32-bit of the value written to the MSR.
6129 AsmMsrBitFieldAndThenOr32 (
6139 Returns a 64-bit Machine Specific Register(MSR).
6141 Reads and returns the 64-bit MSR specified by Index. No parameter checking is
6142 performed on Index, and some Index values may cause CPU exceptions. The
6143 caller must either guarantee that Index is valid, or the caller must set up
6144 exception handlers to catch the exceptions. This function is only available
6147 @param Index The 32-bit MSR index to read.
6149 @return The value of the MSR identified by Index.
6160 Writes a 64-bit value to a Machine Specific Register(MSR), and returns the
6163 Writes the 64-bit value specified by Value to the MSR specified by Index. The
6164 64-bit value written to the MSR is returned. No parameter checking is
6165 performed on Index or Value, and some of these may cause CPU exceptions. The
6166 caller must either guarantee that Index and Value are valid, or the caller
6167 must establish proper exception handlers. This function is only available on
6170 @param Index The 32-bit MSR index to write.
6171 @param Value The 64-bit value to write to the MSR.
6185 Reads a 64-bit MSR, performs a bitwise OR, and writes the result
6186 back to the 64-bit MSR.
6188 Reads the 64-bit MSR specified by Index, performs a bitwise OR
6189 between the read result and the value specified by OrData, and writes the
6190 result to the 64-bit MSR specified by Index. The value written to the MSR is
6191 returned. No parameter checking is performed on Index or OrData, and some of
6192 these may cause CPU exceptions. The caller must either guarantee that Index
6193 and OrData are valid, or the caller must establish proper exception handlers.
6194 This function is only available on IA-32 and x64.
6196 @param Index The 32-bit MSR index to write.
6197 @param OrData The value to OR with the read value from the MSR.
6199 @return The value written back to the MSR.
6211 Reads a 64-bit MSR, performs a bitwise AND, and writes the result back to the
6214 Reads the 64-bit MSR specified by Index, performs a bitwise AND between the
6215 read result and the value specified by OrData, and writes the result to the
6216 64-bit MSR specified by Index. The value written to the MSR is returned. No
6217 parameter checking is performed on Index or OrData, and some of these may
6218 cause CPU exceptions. The caller must either guarantee that Index and OrData
6219 are valid, or the caller must establish proper exception handlers. This
6220 function is only available on IA-32 and x64.
6222 @param Index The 32-bit MSR index to write.
6223 @param AndData The value to AND with the read value from the MSR.
6225 @return The value written back to the MSR.
6237 Reads a 64-bit MSR, performs a bitwise AND followed by a bitwise
6238 OR, and writes the result back to the 64-bit MSR.
6240 Reads the 64-bit MSR specified by Index, performs a bitwise AND between read
6241 result and the value specified by AndData, performs a bitwise OR
6242 between the result of the AND operation and the value specified by OrData,
6243 and writes the result to the 64-bit MSR specified by Index. The value written
6244 to the MSR is returned. No parameter checking is performed on Index, AndData,
6245 or OrData, and some of these may cause CPU exceptions. The caller must either
6246 guarantee that Index, AndData, and OrData are valid, or the caller must
6247 establish proper exception handlers. This function is only available on IA-32
6250 @param Index The 32-bit MSR index to write.
6251 @param AndData The value to AND with the read value from the MSR.
6252 @param OrData The value to OR with the result of the AND operation.
6254 @return The value written back to the MSR.
6267 Reads a bit field of an MSR.
6269 Reads the bit field in the 64-bit MSR. The bit field is specified by the
6270 StartBit and the EndBit. The value of the bit field is returned. The caller
6271 must either guarantee that Index is valid, or the caller must set up
6272 exception handlers to catch the exceptions. This function is only available
6275 If StartBit is greater than 63, then ASSERT().
6276 If EndBit is greater than 63, then ASSERT().
6277 If EndBit is less than StartBit, then ASSERT().
6279 @param Index The 32-bit MSR index to read.
6280 @param StartBit The ordinal of the least significant bit in the bit field.
6282 @param EndBit The ordinal of the most significant bit in the bit field.
6285 @return The value read from the MSR.
6290 AsmMsrBitFieldRead64 (
6298 Writes a bit field to an MSR.
6300 Writes Value to a bit field in a 64-bit MSR. The bit field is specified by
6301 the StartBit and the EndBit. All other bits in the destination MSR are
6302 preserved. The MSR written is returned. The caller must either guarantee
6303 that Index and the data written is valid, or the caller must set up exception
6304 handlers to catch the exceptions. This function is only available on IA-32 and x64.
6306 If StartBit is greater than 63, then ASSERT().
6307 If EndBit is greater than 63, then ASSERT().
6308 If EndBit is less than StartBit, then ASSERT().
6309 If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
6311 @param Index The 32-bit MSR index to write.
6312 @param StartBit The ordinal of the least significant bit in the bit field.
6314 @param EndBit The ordinal of the most significant bit in the bit field.
6316 @param Value New value of the bit field.
6318 @return The value written back to the MSR.
6323 AsmMsrBitFieldWrite64 (
6332 Reads a bit field in a 64-bit MSR, performs a bitwise OR, and
6333 writes the result back to the bit field in the 64-bit MSR.
6335 Reads the 64-bit MSR specified by Index, performs a bitwise OR
6336 between the read result and the value specified by OrData, and writes the
6337 result to the 64-bit MSR specified by Index. The value written to the MSR is
6338 returned. Extra left bits in OrData are stripped. The caller must either
6339 guarantee that Index and the data written is valid, or the caller must set up
6340 exception handlers to catch the exceptions. This function is only available
6343 If StartBit is greater than 63, then ASSERT().
6344 If EndBit is greater than 63, then ASSERT().
6345 If EndBit is less than StartBit, then ASSERT().
6346 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
6348 @param Index The 32-bit MSR index to write.
6349 @param StartBit The ordinal of the least significant bit in the bit field.
6351 @param EndBit The ordinal of the most significant bit in the bit field.
6353 @param OrData The value to OR with the read value from the bit field.
6355 @return The value written back to the MSR.
6360 AsmMsrBitFieldOr64 (
6369 Reads a bit field in a 64-bit MSR, performs a bitwise AND, and writes the
6370 result back to the bit field in the 64-bit MSR.
6372 Reads the 64-bit MSR specified by Index, performs a bitwise AND between the
6373 read result and the value specified by AndData, and writes the result to the
6374 64-bit MSR specified by Index. The value written to the MSR is returned.
6375 Extra left bits in AndData are stripped. The caller must either guarantee
6376 that Index and the data written is valid, or the caller must set up exception
6377 handlers to catch the exceptions. This function is only available on IA-32
6380 If StartBit is greater than 63, then ASSERT().
6381 If EndBit is greater than 63, then ASSERT().
6382 If EndBit is less than StartBit, then ASSERT().
6383 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
6385 @param Index The 32-bit MSR index to write.
6386 @param StartBit The ordinal of the least significant bit in the bit field.
6388 @param EndBit The ordinal of the most significant bit in the bit field.
6390 @param AndData The value to AND with the read value from the bit field.
6392 @return The value written back to the MSR.
6397 AsmMsrBitFieldAnd64 (
6406 Reads a bit field in a 64-bit MSR, performs a bitwise AND followed by a
6407 bitwise OR, and writes the result back to the bit field in the
6410 Reads the 64-bit MSR specified by Index, performs a bitwise AND followed by
6411 a bitwise OR between the read result and the value specified by
6412 AndData, and writes the result to the 64-bit MSR specified by Index. The
6413 value written to the MSR is returned. Extra left bits in both AndData and
6414 OrData are stripped. The caller must either guarantee that Index and the data
6415 written is valid, or the caller must set up exception handlers to catch the
6416 exceptions. This function is only available on IA-32 and x64.
6418 If StartBit is greater than 63, then ASSERT().
6419 If EndBit is greater than 63, then ASSERT().
6420 If EndBit is less than StartBit, then ASSERT().
6421 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
6422 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
6424 @param Index The 32-bit MSR index to write.
6425 @param StartBit The ordinal of the least significant bit in the bit field.
6427 @param EndBit The ordinal of the most significant bit in the bit field.
6429 @param AndData The value to AND with the read value from the bit field.
6430 @param OrData The value to OR with the result of the AND operation.
6432 @return The value written back to the MSR.
6437 AsmMsrBitFieldAndThenOr64 (
6447 Reads the current value of the EFLAGS register.
6449 Reads and returns the current value of the EFLAGS register. This function is
6450 only available on IA-32 and x64. This returns a 32-bit value on IA-32 and a
6451 64-bit value on x64.
6453 @return EFLAGS on IA-32 or RFLAGS on x64.
6464 Reads the current value of the Control Register 0 (CR0).
6466 Reads and returns the current value of CR0. This function is only available
6467 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
6470 @return The value of the Control Register 0 (CR0).
6481 Reads the current value of the Control Register 2 (CR2).
6483 Reads and returns the current value of CR2. This function is only available
6484 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
6487 @return The value of the Control Register 2 (CR2).
6498 Reads the current value of the Control Register 3 (CR3).
6500 Reads and returns the current value of CR3. This function is only available
6501 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
6504 @return The value of the Control Register 3 (CR3).
6515 Reads the current value of the Control Register 4 (CR4).
6517 Reads and returns the current value of CR4. This function is only available
6518 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
6521 @return The value of the Control Register 4 (CR4).
6532 Writes a value to Control Register 0 (CR0).
6534 Writes and returns a new value to CR0. This function is only available on
6535 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
6537 @param Cr0 The value to write to CR0.
6539 @return The value written to CR0.
6550 Writes a value to Control Register 2 (CR2).
6552 Writes and returns a new value to CR2. This function is only available on
6553 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
6555 @param Cr2 The value to write to CR2.
6557 @return The value written to CR2.
6568 Writes a value to Control Register 3 (CR3).
6570 Writes and returns a new value to CR3. This function is only available on
6571 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
6573 @param Cr3 The value to write to CR3.
6575 @return The value written to CR3.
6586 Writes a value to Control Register 4 (CR4).
6588 Writes and returns a new value to CR4. This function is only available on
6589 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
6591 @param Cr4 The value to write to CR4.
6593 @return The value written to CR4.
6604 Reads the current value of Debug Register 0 (DR0).
6606 Reads and returns the current value of DR0. This function is only available
6607 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
6610 @return The value of Debug Register 0 (DR0).
6621 Reads the current value of Debug Register 1 (DR1).
6623 Reads and returns the current value of DR1. This function is only available
6624 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
6627 @return The value of Debug Register 1 (DR1).
6638 Reads the current value of Debug Register 2 (DR2).
6640 Reads and returns the current value of DR2. This function is only available
6641 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
6644 @return The value of Debug Register 2 (DR2).
6655 Reads the current value of Debug Register 3 (DR3).
6657 Reads and returns the current value of DR3. This function is only available
6658 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
6661 @return The value of Debug Register 3 (DR3).
6672 Reads the current value of Debug Register 4 (DR4).
6674 Reads and returns the current value of DR4. This function is only available
6675 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
6678 @return The value of Debug Register 4 (DR4).
6689 Reads the current value of Debug Register 5 (DR5).
6691 Reads and returns the current value of DR5. This function is only available
6692 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
6695 @return The value of Debug Register 5 (DR5).
6706 Reads the current value of Debug Register 6 (DR6).
6708 Reads and returns the current value of DR6. This function is only available
6709 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
6712 @return The value of Debug Register 6 (DR6).
6723 Reads the current value of Debug Register 7 (DR7).
6725 Reads and returns the current value of DR7. This function is only available
6726 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
6729 @return The value of Debug Register 7 (DR7).
6740 Writes a value to Debug Register 0 (DR0).
6742 Writes and returns a new value to DR0. This function is only available on
6743 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
6745 @param Dr0 The value to write to Dr0.
6747 @return The value written to Debug Register 0 (DR0).
6758 Writes a value to Debug Register 1 (DR1).
6760 Writes and returns a new value to DR1. This function is only available on
6761 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
6763 @param Dr1 The value to write to Dr1.
6765 @return The value written to Debug Register 1 (DR1).
6776 Writes a value to Debug Register 2 (DR2).
6778 Writes and returns a new value to DR2. This function is only available on
6779 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
6781 @param Dr2 The value to write to Dr2.
6783 @return The value written to Debug Register 2 (DR2).
6794 Writes a value to Debug Register 3 (DR3).
6796 Writes and returns a new value to DR3. This function is only available on
6797 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
6799 @param Dr3 The value to write to Dr3.
6801 @return The value written to Debug Register 3 (DR3).
6812 Writes a value to Debug Register 4 (DR4).
6814 Writes and returns a new value to DR4. This function is only available on
6815 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
6817 @param Dr4 The value to write to Dr4.
6819 @return The value written to Debug Register 4 (DR4).
6830 Writes a value to Debug Register 5 (DR5).
6832 Writes and returns a new value to DR5. This function is only available on
6833 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
6835 @param Dr5 The value to write to Dr5.
6837 @return The value written to Debug Register 5 (DR5).
6848 Writes a value to Debug Register 6 (DR6).
6850 Writes and returns a new value to DR6. This function is only available on
6851 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
6853 @param Dr6 The value to write to Dr6.
6855 @return The value written to Debug Register 6 (DR6).
6866 Writes a value to Debug Register 7 (DR7).
6868 Writes and returns a new value to DR7. This function is only available on
6869 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
6871 @param Dr7 The value to write to Dr7.
6873 @return The value written to Debug Register 7 (DR7).
6884 Reads the current value of Code Segment Register (CS).
6886 Reads and returns the current value of CS. This function is only available on
6889 @return The current value of CS.
6900 Reads the current value of Data Segment Register (DS).
6902 Reads and returns the current value of DS. This function is only available on
6905 @return The current value of DS.
6916 Reads the current value of Extra Segment Register (ES).
6918 Reads and returns the current value of ES. This function is only available on
6921 @return The current value of ES.
6932 Reads the current value of FS Data Segment Register (FS).
6934 Reads and returns the current value of FS. This function is only available on
6937 @return The current value of FS.
6948 Reads the current value of GS Data Segment Register (GS).
6950 Reads and returns the current value of GS. This function is only available on
6953 @return The current value of GS.
6964 Reads the current value of Stack Segment Register (SS).
6966 Reads and returns the current value of SS. This function is only available on
6969 @return The current value of SS.
6980 Reads the current value of Task Register (TR).
6982 Reads and returns the current value of TR. This function is only available on
6985 @return The current value of TR.
6996 Reads the current Global Descriptor Table Register(GDTR) descriptor.
6998 Reads and returns the current GDTR descriptor and returns it in Gdtr. This
6999 function is only available on IA-32 and x64.
7001 If Gdtr is NULL, then ASSERT().
7003 @param Gdtr The pointer to a GDTR descriptor.
7009 OUT IA32_DESCRIPTOR
*Gdtr
7014 Writes the current Global Descriptor Table Register (GDTR) descriptor.
7016 Writes and the current GDTR descriptor specified by Gdtr. This function is
7017 only available on IA-32 and x64.
7019 If Gdtr is NULL, then ASSERT().
7021 @param Gdtr The pointer to a GDTR descriptor.
7027 IN CONST IA32_DESCRIPTOR
*Gdtr
7032 Reads the current Interrupt Descriptor Table Register(IDTR) descriptor.
7034 Reads and returns the current IDTR descriptor and returns it in Idtr. This
7035 function is only available on IA-32 and x64.
7037 If Idtr is NULL, then ASSERT().
7039 @param Idtr The pointer to a IDTR descriptor.
7045 OUT IA32_DESCRIPTOR
*Idtr
7050 Writes the current Interrupt Descriptor Table Register(IDTR) descriptor.
7052 Writes the current IDTR descriptor and returns it in Idtr. This function is
7053 only available on IA-32 and x64.
7055 If Idtr is NULL, then ASSERT().
7057 @param Idtr The pointer to a IDTR descriptor.
7063 IN CONST IA32_DESCRIPTOR
*Idtr
7068 Reads the current Local Descriptor Table Register(LDTR) selector.
7070 Reads and returns the current 16-bit LDTR descriptor value. This function is
7071 only available on IA-32 and x64.
7073 @return The current selector of LDT.
7084 Writes the current Local Descriptor Table Register (LDTR) selector.
7086 Writes and the current LDTR descriptor specified by Ldtr. This function is
7087 only available on IA-32 and x64.
7089 @param Ldtr 16-bit LDTR selector value.
7100 Save the current floating point/SSE/SSE2 context to a buffer.
7102 Saves the current floating point/SSE/SSE2 state to the buffer specified by
7103 Buffer. Buffer must be aligned on a 16-byte boundary. This function is only
7104 available on IA-32 and x64.
7106 If Buffer is NULL, then ASSERT().
7107 If Buffer is not aligned on a 16-byte boundary, then ASSERT().
7109 @param Buffer The pointer to a buffer to save the floating point/SSE/SSE2 context.
7115 OUT IA32_FX_BUFFER
*Buffer
7120 Restores the current floating point/SSE/SSE2 context from a buffer.
7122 Restores the current floating point/SSE/SSE2 state from the buffer specified
7123 by Buffer. Buffer must be aligned on a 16-byte boundary. This function is
7124 only available on IA-32 and x64.
7126 If Buffer is NULL, then ASSERT().
7127 If Buffer is not aligned on a 16-byte boundary, then ASSERT().
7128 If Buffer was not saved with AsmFxSave(), then ASSERT().
7130 @param Buffer The pointer to a buffer to save the floating point/SSE/SSE2 context.
7136 IN CONST IA32_FX_BUFFER
*Buffer
7141 Reads the current value of 64-bit MMX Register #0 (MM0).
7143 Reads and returns the current value of MM0. This function is only available
7146 @return The current value of MM0.
7157 Reads the current value of 64-bit MMX Register #1 (MM1).
7159 Reads and returns the current value of MM1. This function is only available
7162 @return The current value of MM1.
7173 Reads the current value of 64-bit MMX Register #2 (MM2).
7175 Reads and returns the current value of MM2. This function is only available
7178 @return The current value of MM2.
7189 Reads the current value of 64-bit MMX Register #3 (MM3).
7191 Reads and returns the current value of MM3. This function is only available
7194 @return The current value of MM3.
7205 Reads the current value of 64-bit MMX Register #4 (MM4).
7207 Reads and returns the current value of MM4. This function is only available
7210 @return The current value of MM4.
7221 Reads the current value of 64-bit MMX Register #5 (MM5).
7223 Reads and returns the current value of MM5. This function is only available
7226 @return The current value of MM5.
7237 Reads the current value of 64-bit MMX Register #6 (MM6).
7239 Reads and returns the current value of MM6. This function is only available
7242 @return The current value of MM6.
7253 Reads the current value of 64-bit MMX Register #7 (MM7).
7255 Reads and returns the current value of MM7. This function is only available
7258 @return The current value of MM7.
7269 Writes the current value of 64-bit MMX Register #0 (MM0).
7271 Writes the current value of MM0. This function is only available on IA32 and
7274 @param Value The 64-bit value to write to MM0.
7285 Writes the current value of 64-bit MMX Register #1 (MM1).
7287 Writes the current value of MM1. This function is only available on IA32 and
7290 @param Value The 64-bit value to write to MM1.
7301 Writes the current value of 64-bit MMX Register #2 (MM2).
7303 Writes the current value of MM2. This function is only available on IA32 and
7306 @param Value The 64-bit value to write to MM2.
7317 Writes the current value of 64-bit MMX Register #3 (MM3).
7319 Writes the current value of MM3. This function is only available on IA32 and
7322 @param Value The 64-bit value to write to MM3.
7333 Writes the current value of 64-bit MMX Register #4 (MM4).
7335 Writes the current value of MM4. This function is only available on IA32 and
7338 @param Value The 64-bit value to write to MM4.
7349 Writes the current value of 64-bit MMX Register #5 (MM5).
7351 Writes the current value of MM5. This function is only available on IA32 and
7354 @param Value The 64-bit value to write to MM5.
7365 Writes the current value of 64-bit MMX Register #6 (MM6).
7367 Writes the current value of MM6. This function is only available on IA32 and
7370 @param Value The 64-bit value to write to MM6.
7381 Writes the current value of 64-bit MMX Register #7 (MM7).
7383 Writes the current value of MM7. This function is only available on IA32 and
7386 @param Value The 64-bit value to write to MM7.
7397 Reads the current value of Time Stamp Counter (TSC).
7399 Reads and returns the current value of TSC. This function is only available
7402 @return The current value of TSC
7413 Reads the current value of a Performance Counter (PMC).
7415 Reads and returns the current value of performance counter specified by
7416 Index. This function is only available on IA-32 and x64.
7418 @param Index The 32-bit Performance Counter index to read.
7420 @return The value of the PMC specified by Index.
7431 Sets up a monitor buffer that is used by AsmMwait().
7433 Executes a MONITOR instruction with the register state specified by Eax, Ecx
7434 and Edx. Returns Eax. This function is only available on IA-32 and x64.
7436 @param Eax The value to load into EAX or RAX before executing the MONITOR
7438 @param Ecx The value to load into ECX or RCX before executing the MONITOR
7440 @param Edx The value to load into EDX or RDX before executing the MONITOR
7456 Executes an MWAIT instruction.
7458 Executes an MWAIT instruction with the register state specified by Eax and
7459 Ecx. Returns Eax. This function is only available on IA-32 and x64.
7461 @param Eax The value to load into EAX or RAX before executing the MONITOR
7463 @param Ecx The value to load into ECX or RCX before executing the MONITOR
7478 Executes a WBINVD instruction.
7480 Executes a WBINVD instruction. This function is only available on IA-32 and
7492 Executes a INVD instruction.
7494 Executes a INVD instruction. This function is only available on IA-32 and
7506 Flushes a cache line from all the instruction and data caches within the
7507 coherency domain of the CPU.
7509 Flushed the cache line specified by LinearAddress, and returns LinearAddress.
7510 This function is only available on IA-32 and x64.
7512 @param LinearAddress The address of the cache line to flush. If the CPU is
7513 in a physical addressing mode, then LinearAddress is a
7514 physical address. If the CPU is in a virtual
7515 addressing mode, then LinearAddress is a virtual
7518 @return LinearAddress.
7523 IN VOID
*LinearAddress
7528 Enables the 32-bit paging mode on the CPU.
7530 Enables the 32-bit paging mode on the CPU. CR0, CR3, CR4, and the page tables
7531 must be properly initialized prior to calling this service. This function
7532 assumes the current execution mode is 32-bit protected mode. This function is
7533 only available on IA-32. After the 32-bit paging mode is enabled, control is
7534 transferred to the function specified by EntryPoint using the new stack
7535 specified by NewStack and passing in the parameters specified by Context1 and
7536 Context2. Context1 and Context2 are optional and may be NULL. The function
7537 EntryPoint must never return.
7539 If the current execution mode is not 32-bit protected mode, then ASSERT().
7540 If EntryPoint is NULL, then ASSERT().
7541 If NewStack is NULL, then ASSERT().
7543 There are a number of constraints that must be followed before calling this
7545 1) Interrupts must be disabled.
7546 2) The caller must be in 32-bit protected mode with flat descriptors. This
7547 means all descriptors must have a base of 0 and a limit of 4GB.
7548 3) CR0 and CR4 must be compatible with 32-bit protected mode with flat
7550 4) CR3 must point to valid page tables that will be used once the transition
7551 is complete, and those page tables must guarantee that the pages for this
7552 function and the stack are identity mapped.
7554 @param EntryPoint A pointer to function to call with the new stack after
7556 @param Context1 A pointer to the context to pass into the EntryPoint
7557 function as the first parameter after paging is enabled.
7558 @param Context2 A pointer to the context to pass into the EntryPoint
7559 function as the second parameter after paging is enabled.
7560 @param NewStack A pointer to the new stack to use for the EntryPoint
7561 function after paging is enabled.
7567 IN SWITCH_STACK_ENTRY_POINT EntryPoint
,
7568 IN VOID
*Context1
, OPTIONAL
7569 IN VOID
*Context2
, OPTIONAL
7575 Disables the 32-bit paging mode on the CPU.
7577 Disables the 32-bit paging mode on the CPU and returns to 32-bit protected
7578 mode. This function assumes the current execution mode is 32-paged protected
7579 mode. This function is only available on IA-32. After the 32-bit paging mode
7580 is disabled, control is transferred to the function specified by EntryPoint
7581 using the new stack specified by NewStack and passing in the parameters
7582 specified by Context1 and Context2. Context1 and Context2 are optional and
7583 may be NULL. The function EntryPoint must never return.
7585 If the current execution mode is not 32-bit paged mode, then ASSERT().
7586 If EntryPoint is NULL, then ASSERT().
7587 If NewStack is NULL, then ASSERT().
7589 There are a number of constraints that must be followed before calling this
7591 1) Interrupts must be disabled.
7592 2) The caller must be in 32-bit paged mode.
7593 3) CR0, CR3, and CR4 must be compatible with 32-bit paged mode.
7594 4) CR3 must point to valid page tables that guarantee that the pages for
7595 this function and the stack are identity mapped.
7597 @param EntryPoint A pointer to function to call with the new stack after
7599 @param Context1 A pointer to the context to pass into the EntryPoint
7600 function as the first parameter after paging is disabled.
7601 @param Context2 A pointer to the context to pass into the EntryPoint
7602 function as the second parameter after paging is
7604 @param NewStack A pointer to the new stack to use for the EntryPoint
7605 function after paging is disabled.
7610 AsmDisablePaging32 (
7611 IN SWITCH_STACK_ENTRY_POINT EntryPoint
,
7612 IN VOID
*Context1
, OPTIONAL
7613 IN VOID
*Context2
, OPTIONAL
7619 Enables the 64-bit paging mode on the CPU.
7621 Enables the 64-bit paging mode on the CPU. CR0, CR3, CR4, and the page tables
7622 must be properly initialized prior to calling this service. This function
7623 assumes the current execution mode is 32-bit protected mode with flat
7624 descriptors. This function is only available on IA-32. After the 64-bit
7625 paging mode is enabled, control is transferred to the function specified by
7626 EntryPoint using the new stack specified by NewStack and passing in the
7627 parameters specified by Context1 and Context2. Context1 and Context2 are
7628 optional and may be 0. The function EntryPoint must never return.
7630 If the current execution mode is not 32-bit protected mode with flat
7631 descriptors, then ASSERT().
7632 If EntryPoint is 0, then ASSERT().
7633 If NewStack is 0, then ASSERT().
7635 @param Cs The 16-bit selector to load in the CS before EntryPoint
7636 is called. The descriptor in the GDT that this selector
7637 references must be setup for long mode.
7638 @param EntryPoint The 64-bit virtual address of the function to call with
7639 the new stack after paging is enabled.
7640 @param Context1 The 64-bit virtual address of the context to pass into
7641 the EntryPoint function as the first parameter after
7643 @param Context2 The 64-bit virtual address of the context to pass into
7644 the EntryPoint function as the second parameter after
7646 @param NewStack The 64-bit virtual address of the new stack to use for
7647 the EntryPoint function after paging is enabled.
7654 IN UINT64 EntryPoint
,
7655 IN UINT64 Context1
, OPTIONAL
7656 IN UINT64 Context2
, OPTIONAL
7662 Disables the 64-bit paging mode on the CPU.
7664 Disables the 64-bit paging mode on the CPU and returns to 32-bit protected
7665 mode. This function assumes the current execution mode is 64-paging mode.
7666 This function is only available on x64. After the 64-bit paging mode is
7667 disabled, control is transferred to the function specified by EntryPoint
7668 using the new stack specified by NewStack and passing in the parameters
7669 specified by Context1 and Context2. Context1 and Context2 are optional and
7670 may be 0. The function EntryPoint must never return.
7672 If the current execution mode is not 64-bit paged mode, then ASSERT().
7673 If EntryPoint is 0, then ASSERT().
7674 If NewStack is 0, then ASSERT().
7676 @param Cs The 16-bit selector to load in the CS before EntryPoint
7677 is called. The descriptor in the GDT that this selector
7678 references must be setup for 32-bit protected mode.
7679 @param EntryPoint The 64-bit virtual address of the function to call with
7680 the new stack after paging is disabled.
7681 @param Context1 The 64-bit virtual address of the context to pass into
7682 the EntryPoint function as the first parameter after
7684 @param Context2 The 64-bit virtual address of the context to pass into
7685 the EntryPoint function as the second parameter after
7687 @param NewStack The 64-bit virtual address of the new stack to use for
7688 the EntryPoint function after paging is disabled.
7693 AsmDisablePaging64 (
7695 IN UINT32 EntryPoint
,
7696 IN UINT32 Context1
, OPTIONAL
7697 IN UINT32 Context2
, OPTIONAL
7703 // 16-bit thunking services
7707 Retrieves the properties for 16-bit thunk functions.
7709 Computes the size of the buffer and stack below 1MB required to use the
7710 AsmPrepareThunk16(), AsmThunk16() and AsmPrepareAndThunk16() functions. This
7711 buffer size is returned in RealModeBufferSize, and the stack size is returned
7712 in ExtraStackSize. If parameters are passed to the 16-bit real mode code,
7713 then the actual minimum stack size is ExtraStackSize plus the maximum number
7714 of bytes that need to be passed to the 16-bit real mode code.
7716 If RealModeBufferSize is NULL, then ASSERT().
7717 If ExtraStackSize is NULL, then ASSERT().
7719 @param RealModeBufferSize A pointer to the size of the buffer below 1MB
7720 required to use the 16-bit thunk functions.
7721 @param ExtraStackSize A pointer to the extra size of stack below 1MB
7722 that the 16-bit thunk functions require for
7723 temporary storage in the transition to and from
7729 AsmGetThunk16Properties (
7730 OUT UINT32
*RealModeBufferSize
,
7731 OUT UINT32
*ExtraStackSize
7736 Prepares all structures a code required to use AsmThunk16().
7738 Prepares all structures and code required to use AsmThunk16().
7740 This interface is limited to be used in either physical mode or virtual modes with paging enabled where the
7741 virtual to physical mappings for ThunkContext.RealModeBuffer is mapped 1:1.
7743 If ThunkContext is NULL, then ASSERT().
7745 @param ThunkContext A pointer to the context structure that describes the
7746 16-bit real mode code to call.
7752 IN OUT THUNK_CONTEXT
*ThunkContext
7757 Transfers control to a 16-bit real mode entry point and returns the results.
7759 Transfers control to a 16-bit real mode entry point and returns the results.
7760 AsmPrepareThunk16() must be called with ThunkContext before this function is used.
7761 This function must be called with interrupts disabled.
7763 The register state from the RealModeState field of ThunkContext is restored just prior
7764 to calling the 16-bit real mode entry point. This includes the EFLAGS field of RealModeState,
7765 which is used to set the interrupt state when a 16-bit real mode entry point is called.
7766 Control is transferred to the 16-bit real mode entry point specified by the CS and Eip fields of RealModeState.
7767 The stack is initialized to the SS and ESP fields of RealModeState. Any parameters passed to
7768 the 16-bit real mode code must be populated by the caller at SS:ESP prior to calling this function.
7769 The 16-bit real mode entry point is invoked with a 16-bit CALL FAR instruction,
7770 so when accessing stack contents, the 16-bit real mode code must account for the 16-bit segment
7771 and 16-bit offset of the return address that were pushed onto the stack. The 16-bit real mode entry
7772 point must exit with a RETF instruction. The register state is captured into RealModeState immediately
7773 after the RETF instruction is executed.
7775 If EFLAGS specifies interrupts enabled, or any of the 16-bit real mode code enables interrupts,
7776 or any of the 16-bit real mode code makes a SW interrupt, then the caller is responsible for making sure
7777 the IDT at address 0 is initialized to handle any HW or SW interrupts that may occur while in 16-bit real mode.
7779 If EFLAGS specifies interrupts enabled, or any of the 16-bit real mode code enables interrupts,
7780 then the caller is responsible for making sure the 8259 PIC is in a state compatible with 16-bit real mode.
7781 This includes the base vectors, the interrupt masks, and the edge/level trigger mode.
7783 If THUNK_ATTRIBUTE_BIG_REAL_MODE is set in the ThunkAttributes field of ThunkContext, then the user code
7784 is invoked in big real mode. Otherwise, the user code is invoked in 16-bit real mode with 64KB segment limits.
7786 If neither THUNK_ATTRIBUTE_DISABLE_A20_MASK_INT_15 nor THUNK_ATTRIBUTE_DISABLE_A20_MASK_KBD_CTRL are set in
7787 ThunkAttributes, then it is assumed that the user code did not enable the A20 mask, and no attempt is made to
7788 disable the A20 mask.
7790 If THUNK_ATTRIBUTE_DISABLE_A20_MASK_INT_15 is set and THUNK_ATTRIBUTE_DISABLE_A20_MASK_KBD_CTRL is clear in
7791 ThunkAttributes, then attempt to use the INT 15 service to disable the A20 mask. If this INT 15 call fails,
7792 then attempt to disable the A20 mask by directly accessing the 8042 keyboard controller I/O ports.
7794 If THUNK_ATTRIBUTE_DISABLE_A20_MASK_INT_15 is clear and THUNK_ATTRIBUTE_DISABLE_A20_MASK_KBD_CTRL is set in
7795 ThunkAttributes, then attempt to disable the A20 mask by directly accessing the 8042 keyboard controller I/O ports.
7797 If ThunkContext is NULL, then ASSERT().
7798 If AsmPrepareThunk16() was not previously called with ThunkContext, then ASSERT().
7799 If both THUNK_ATTRIBUTE_DISABLE_A20_MASK_INT_15 and THUNK_ATTRIBUTE_DISABLE_A20_MASK_KBD_CTRL are set in
7800 ThunkAttributes, then ASSERT().
7802 This interface is limited to be used in either physical mode or virtual modes with paging enabled where the
7803 virtual to physical mappings for ThunkContext.RealModeBuffer are mapped 1:1.
7805 @param ThunkContext A pointer to the context structure that describes the
7806 16-bit real mode code to call.
7812 IN OUT THUNK_CONTEXT
*ThunkContext
7817 Prepares all structures and code for a 16-bit real mode thunk, transfers
7818 control to a 16-bit real mode entry point, and returns the results.
7820 Prepares all structures and code for a 16-bit real mode thunk, transfers
7821 control to a 16-bit real mode entry point, and returns the results. If the
7822 caller only need to perform a single 16-bit real mode thunk, then this
7823 service should be used. If the caller intends to make more than one 16-bit
7824 real mode thunk, then it is more efficient if AsmPrepareThunk16() is called
7825 once and AsmThunk16() can be called for each 16-bit real mode thunk.
7827 This interface is limited to be used in either physical mode or virtual modes with paging enabled where the
7828 virtual to physical mappings for ThunkContext.RealModeBuffer is mapped 1:1.
7830 See AsmPrepareThunk16() and AsmThunk16() for the detailed description and ASSERT() conditions.
7832 @param ThunkContext A pointer to the context structure that describes the
7833 16-bit real mode code to call.
7838 AsmPrepareAndThunk16 (
7839 IN OUT THUNK_CONTEXT
*ThunkContext
7843 Generates a 16-bit random number through RDRAND instruction.
7845 if Rand is NULL, then ASSERT().
7847 @param[out] Rand Buffer pointer to store the random result.
7849 @retval TRUE RDRAND call was successful.
7850 @retval FALSE Failed attempts to call RDRAND.
7860 Generates a 32-bit random number through RDRAND instruction.
7862 if Rand is NULL, then ASSERT().
7864 @param[out] Rand Buffer pointer to store the random result.
7866 @retval TRUE RDRAND call was successful.
7867 @retval FALSE Failed attempts to call RDRAND.
7877 Generates a 64-bit random number through RDRAND instruction.
7879 if Rand is NULL, then ASSERT().
7881 @param[out] Rand Buffer pointer to store the random result.
7883 @retval TRUE RDRAND call was successful.
7884 @retval FALSE Failed attempts to call RDRAND.