2 Provides string functions, linked list functions, math functions, synchronization
3 functions, file path functions, and CPU architecture-specific functions.
5 Copyright (c) 2006 - 2016, 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 Copies the string pointed to by Source (including the terminating null char)
212 to the array pointed to by Destination.
214 This function is similar as strcpy_s defined in C11.
216 If Destination is not aligned on a 16-bit boundary, then ASSERT().
217 If Source is not aligned on a 16-bit boundary, then ASSERT().
218 If an error would be returned, then the function will also ASSERT().
220 If an error is returned, then the Destination is unmodified.
222 @param Destination A pointer to a Null-terminated Unicode string.
223 @param DestMax The maximum number of Destination Unicode
224 char, including terminating null char.
225 @param Source A pointer to a Null-terminated Unicode string.
227 @retval RETURN_SUCCESS String is copied.
228 @retval RETURN_BUFFER_TOO_SMALL If DestMax is NOT greater than StrLen(Source).
229 @retval RETURN_INVALID_PARAMETER If Destination is NULL.
231 If PcdMaximumUnicodeStringLength is not zero,
232 and DestMax is greater than
233 PcdMaximumUnicodeStringLength.
235 @retval RETURN_ACCESS_DENIED If Source and Destination overlap.
240 OUT CHAR16
*Destination
,
242 IN CONST CHAR16
*Source
246 Copies not more than Length successive char from the string pointed to by
247 Source to the array pointed to by Destination. If no null char is copied from
248 Source, then Destination[Length] is always set to null.
250 This function is similar as strncpy_s defined in C11.
252 If Length > 0 and Destination is not aligned on a 16-bit boundary, then ASSERT().
253 If Length > 0 and Source is not aligned on a 16-bit boundary, then ASSERT().
254 If an error would be returned, then the function will also ASSERT().
256 If an error is returned, then the Destination is unmodified.
258 @param Destination A pointer to a Null-terminated Unicode string.
259 @param DestMax The maximum number of Destination Unicode
260 char, including terminating null char.
261 @param Source A pointer to a Null-terminated Unicode string.
262 @param Length The maximum number of Unicode characters to copy.
264 @retval RETURN_SUCCESS String is copied.
265 @retval RETURN_BUFFER_TOO_SMALL If DestMax is NOT greater than
266 MIN(StrLen(Source), Length).
267 @retval RETURN_INVALID_PARAMETER If Destination is NULL.
269 If PcdMaximumUnicodeStringLength is not zero,
270 and DestMax is greater than
271 PcdMaximumUnicodeStringLength.
273 @retval RETURN_ACCESS_DENIED If Source and Destination overlap.
278 OUT CHAR16
*Destination
,
280 IN CONST CHAR16
*Source
,
285 Appends a copy of the string pointed to by Source (including the terminating
286 null char) to the end of the string pointed to by Destination.
288 This function is similar as strcat_s defined in C11.
290 If Destination is not aligned on a 16-bit boundary, then ASSERT().
291 If Source is not aligned on a 16-bit boundary, then ASSERT().
292 If an error would be returned, then the function will also ASSERT().
294 If an error is returned, then the Destination is unmodified.
296 @param Destination A pointer to a Null-terminated Unicode string.
297 @param DestMax The maximum number of Destination Unicode
298 char, including terminating null char.
299 @param Source A pointer to a Null-terminated Unicode string.
301 @retval RETURN_SUCCESS String is appended.
302 @retval RETURN_BAD_BUFFER_SIZE If DestMax is NOT greater than
304 @retval RETURN_BUFFER_TOO_SMALL If (DestMax - StrLen(Destination)) is NOT
305 greater than StrLen(Source).
306 @retval RETURN_INVALID_PARAMETER If Destination is NULL.
308 If PcdMaximumUnicodeStringLength is not zero,
309 and DestMax is greater than
310 PcdMaximumUnicodeStringLength.
312 @retval RETURN_ACCESS_DENIED If Source and Destination overlap.
317 IN OUT CHAR16
*Destination
,
319 IN CONST CHAR16
*Source
323 Appends not more than Length successive char from the string pointed to by
324 Source to the end of the string pointed to by Destination. If no null char is
325 copied from Source, then Destination[StrLen(Destination) + Length] is always
328 This function is similar as strncat_s defined in C11.
330 If Destination is not aligned on a 16-bit boundary, then ASSERT().
331 If Source is not aligned on a 16-bit boundary, then ASSERT().
332 If an error would be returned, then the function will also ASSERT().
334 If an error is returned, then the Destination is unmodified.
336 @param Destination A pointer to a Null-terminated Unicode string.
337 @param DestMax The maximum number of Destination Unicode
338 char, including terminating null char.
339 @param Source A pointer to a Null-terminated Unicode string.
340 @param Length The maximum number of Unicode characters to copy.
342 @retval RETURN_SUCCESS String is appended.
343 @retval RETURN_BAD_BUFFER_SIZE If DestMax is NOT greater than
345 @retval RETURN_BUFFER_TOO_SMALL If (DestMax - StrLen(Destination)) is NOT
346 greater than MIN(StrLen(Source), Length).
347 @retval RETURN_INVALID_PARAMETER If Destination is NULL.
349 If PcdMaximumUnicodeStringLength is not zero,
350 and DestMax is greater than
351 PcdMaximumUnicodeStringLength.
353 @retval RETURN_ACCESS_DENIED If Source and Destination overlap.
358 IN OUT CHAR16
*Destination
,
360 IN CONST CHAR16
*Source
,
365 Returns the length of a Null-terminated Ascii string.
367 This function is similar as strlen_s defined in C11.
369 @param String A pointer to a Null-terminated Ascii string.
370 @param MaxSize The maximum number of Destination Ascii
371 char, including terminating null char.
373 @retval 0 If String is NULL.
374 @retval MaxSize If there is no null character in the first MaxSize characters of String.
375 @return The number of characters that percede the terminating null character.
381 IN CONST CHAR8
*String
,
386 Copies the string pointed to by Source (including the terminating null char)
387 to the array pointed to by Destination.
389 This function is similar as strcpy_s defined in C11.
391 If an error would be returned, then the function will also ASSERT().
393 If an error is returned, then the Destination is unmodified.
395 @param Destination A pointer to a Null-terminated Ascii string.
396 @param DestMax The maximum number of Destination Ascii
397 char, including terminating null char.
398 @param Source A pointer to a Null-terminated Ascii string.
400 @retval RETURN_SUCCESS String is copied.
401 @retval RETURN_BUFFER_TOO_SMALL If DestMax is NOT greater than StrLen(Source).
402 @retval RETURN_INVALID_PARAMETER If Destination is NULL.
404 If PcdMaximumAsciiStringLength is not zero,
405 and DestMax is greater than
406 PcdMaximumAsciiStringLength.
408 @retval RETURN_ACCESS_DENIED If Source and Destination overlap.
413 OUT CHAR8
*Destination
,
415 IN CONST CHAR8
*Source
419 Copies not more than Length successive char from the string pointed to by
420 Source to the array pointed to by Destination. If no null char is copied from
421 Source, then Destination[Length] is always set to null.
423 This function is similar as strncpy_s defined in C11.
425 If an error would be returned, then the function will also ASSERT().
427 If an error is returned, then the Destination is unmodified.
429 @param Destination A pointer to a Null-terminated Ascii string.
430 @param DestMax The maximum number of Destination Ascii
431 char, including terminating null char.
432 @param Source A pointer to a Null-terminated Ascii string.
433 @param Length The maximum number of Ascii characters to copy.
435 @retval RETURN_SUCCESS String is copied.
436 @retval RETURN_BUFFER_TOO_SMALL If DestMax is NOT greater than
437 MIN(StrLen(Source), Length).
438 @retval RETURN_INVALID_PARAMETER If Destination is NULL.
440 If PcdMaximumAsciiStringLength is not zero,
441 and DestMax is greater than
442 PcdMaximumAsciiStringLength.
444 @retval RETURN_ACCESS_DENIED If Source and Destination overlap.
449 OUT CHAR8
*Destination
,
451 IN CONST CHAR8
*Source
,
456 Appends a copy of the string pointed to by Source (including the terminating
457 null char) to the end of the string pointed to by Destination.
459 This function is similar as strcat_s defined in C11.
461 If an error would be returned, then the function will also ASSERT().
463 If an error is returned, then the Destination is unmodified.
465 @param Destination A pointer to a Null-terminated Ascii string.
466 @param DestMax The maximum number of Destination Ascii
467 char, including terminating null char.
468 @param Source A pointer to a Null-terminated Ascii string.
470 @retval RETURN_SUCCESS String is appended.
471 @retval RETURN_BAD_BUFFER_SIZE If DestMax is NOT greater than
473 @retval RETURN_BUFFER_TOO_SMALL If (DestMax - StrLen(Destination)) is NOT
474 greater than StrLen(Source).
475 @retval RETURN_INVALID_PARAMETER If Destination is NULL.
477 If PcdMaximumAsciiStringLength is not zero,
478 and DestMax is greater than
479 PcdMaximumAsciiStringLength.
481 @retval RETURN_ACCESS_DENIED If Source and Destination overlap.
486 IN OUT CHAR8
*Destination
,
488 IN CONST CHAR8
*Source
492 Appends not more than Length successive char from the string pointed to by
493 Source to the end of the string pointed to by Destination. If no null char is
494 copied from Source, then Destination[StrLen(Destination) + Length] is always
497 This function is similar as strncat_s defined in C11.
499 If an error would be returned, then the function will also ASSERT().
501 If an error is returned, then the Destination is unmodified.
503 @param Destination A pointer to a Null-terminated Ascii string.
504 @param DestMax The maximum number of Destination Ascii
505 char, including terminating null char.
506 @param Source A pointer to a Null-terminated Ascii string.
507 @param Length The maximum number of Ascii characters to copy.
509 @retval RETURN_SUCCESS String is appended.
510 @retval RETURN_BAD_BUFFER_SIZE If DestMax is NOT greater than
512 @retval RETURN_BUFFER_TOO_SMALL If (DestMax - StrLen(Destination)) is NOT
513 greater than MIN(StrLen(Source), Length).
514 @retval RETURN_INVALID_PARAMETER If Destination is NULL.
516 If PcdMaximumAsciiStringLength is not zero,
517 and DestMax is greater than
518 PcdMaximumAsciiStringLength.
520 @retval RETURN_ACCESS_DENIED If Source and Destination overlap.
525 IN OUT CHAR8
*Destination
,
527 IN CONST CHAR8
*Source
,
532 #ifndef DISABLE_NEW_DEPRECATED_INTERFACES
535 [ATTENTION] This function is deprecated for security reason.
537 Copies one Null-terminated Unicode string to another Null-terminated Unicode
538 string and returns the new Unicode string.
540 This function copies the contents of the Unicode string Source to the Unicode
541 string Destination, and returns Destination. If Source and Destination
542 overlap, then the results are undefined.
544 If Destination is NULL, then ASSERT().
545 If Destination is not aligned on a 16-bit boundary, then ASSERT().
546 If Source is NULL, then ASSERT().
547 If Source is not aligned on a 16-bit boundary, then ASSERT().
548 If Source and Destination overlap, then ASSERT().
549 If PcdMaximumUnicodeStringLength is not zero, and Source contains more than
550 PcdMaximumUnicodeStringLength Unicode characters not including the
551 Null-terminator, then ASSERT().
553 @param Destination The pointer to a Null-terminated Unicode string.
554 @param Source The pointer to a Null-terminated Unicode string.
562 OUT CHAR16
*Destination
,
563 IN CONST CHAR16
*Source
568 [ATTENTION] This function is deprecated for security reason.
570 Copies up to a specified length from one Null-terminated Unicode string to
571 another Null-terminated Unicode string and returns the new Unicode string.
573 This function copies the contents of the Unicode string Source to the Unicode
574 string Destination, and returns Destination. At most, Length Unicode
575 characters are copied from Source to Destination. If Length is 0, then
576 Destination is returned unmodified. If Length is greater that the number of
577 Unicode characters in Source, then Destination is padded with Null Unicode
578 characters. If Source and Destination overlap, then the results are
581 If Length > 0 and Destination is NULL, then ASSERT().
582 If Length > 0 and Destination is not aligned on a 16-bit boundary, then ASSERT().
583 If Length > 0 and Source is NULL, then ASSERT().
584 If Length > 0 and Source is not aligned on a 16-bit boundary, then ASSERT().
585 If Source and Destination overlap, then ASSERT().
586 If PcdMaximumUnicodeStringLength is not zero, and Length is greater than
587 PcdMaximumUnicodeStringLength, then ASSERT().
588 If PcdMaximumUnicodeStringLength is not zero, and Source contains more than
589 PcdMaximumUnicodeStringLength Unicode characters, not including the Null-terminator,
592 @param Destination The pointer to a Null-terminated Unicode string.
593 @param Source The pointer to a Null-terminated Unicode string.
594 @param Length The maximum number of Unicode characters to copy.
602 OUT CHAR16
*Destination
,
603 IN CONST CHAR16
*Source
,
609 Returns the length of a Null-terminated Unicode string.
611 This function returns the number of Unicode characters in the Null-terminated
612 Unicode string specified by String.
614 If String is NULL, then ASSERT().
615 If String is not aligned on a 16-bit boundary, then ASSERT().
616 If PcdMaximumUnicodeStringLength is not zero, and String contains more than
617 PcdMaximumUnicodeStringLength Unicode characters not including the
618 Null-terminator, then ASSERT().
620 @param String Pointer to a Null-terminated Unicode string.
622 @return The length of String.
628 IN CONST CHAR16
*String
633 Returns the size of a Null-terminated Unicode string in bytes, including the
636 This function returns the size, in bytes, of the Null-terminated Unicode string
639 If String is NULL, then ASSERT().
640 If String is not aligned on a 16-bit boundary, then ASSERT().
641 If PcdMaximumUnicodeStringLength is not zero, and String contains more than
642 PcdMaximumUnicodeStringLength Unicode characters not including the
643 Null-terminator, then ASSERT().
645 @param String The pointer to a Null-terminated Unicode string.
647 @return The size of String.
653 IN CONST CHAR16
*String
658 Compares two Null-terminated Unicode strings, and returns the difference
659 between the first mismatched Unicode characters.
661 This function compares the Null-terminated Unicode string FirstString to the
662 Null-terminated Unicode string SecondString. If FirstString is identical to
663 SecondString, then 0 is returned. Otherwise, the value returned is the first
664 mismatched Unicode character in SecondString subtracted from the first
665 mismatched Unicode character in FirstString.
667 If FirstString is NULL, then ASSERT().
668 If FirstString is not aligned on a 16-bit boundary, then ASSERT().
669 If SecondString is NULL, then ASSERT().
670 If SecondString is not aligned on a 16-bit boundary, then ASSERT().
671 If PcdMaximumUnicodeStringLength is not zero, and FirstString contains more
672 than PcdMaximumUnicodeStringLength Unicode characters not including the
673 Null-terminator, then ASSERT().
674 If PcdMaximumUnicodeStringLength is not zero, and SecondString contains more
675 than PcdMaximumUnicodeStringLength Unicode characters, not including the
676 Null-terminator, then ASSERT().
678 @param FirstString The pointer to a Null-terminated Unicode string.
679 @param SecondString The pointer to a Null-terminated Unicode string.
681 @retval 0 FirstString is identical to SecondString.
682 @return others FirstString is not identical to SecondString.
688 IN CONST CHAR16
*FirstString
,
689 IN CONST CHAR16
*SecondString
694 Compares up to a specified length the contents of two Null-terminated Unicode strings,
695 and returns the difference between the first mismatched Unicode characters.
697 This function compares the Null-terminated Unicode string FirstString to the
698 Null-terminated Unicode string SecondString. At most, Length Unicode
699 characters will be compared. If Length is 0, then 0 is returned. If
700 FirstString is identical to SecondString, then 0 is returned. Otherwise, the
701 value returned is the first mismatched Unicode character in SecondString
702 subtracted from the first mismatched Unicode character in FirstString.
704 If Length > 0 and FirstString is NULL, then ASSERT().
705 If Length > 0 and FirstString is not aligned on a 16-bit boundary, then ASSERT().
706 If Length > 0 and SecondString is NULL, then ASSERT().
707 If Length > 0 and SecondString is not aligned on a 16-bit boundary, then ASSERT().
708 If PcdMaximumUnicodeStringLength is not zero, and Length is greater than
709 PcdMaximumUnicodeStringLength, then ASSERT().
710 If PcdMaximumUnicodeStringLength is not zero, and FirstString contains more than
711 PcdMaximumUnicodeStringLength Unicode characters, not including the Null-terminator,
713 If PcdMaximumUnicodeStringLength is not zero, and SecondString contains more than
714 PcdMaximumUnicodeStringLength Unicode characters, not including the Null-terminator,
717 @param FirstString The pointer to a Null-terminated Unicode string.
718 @param SecondString The pointer to a Null-terminated Unicode string.
719 @param Length The maximum number of Unicode characters to compare.
721 @retval 0 FirstString is identical to SecondString.
722 @return others FirstString is not identical to SecondString.
728 IN CONST CHAR16
*FirstString
,
729 IN CONST CHAR16
*SecondString
,
734 #ifndef DISABLE_NEW_DEPRECATED_INTERFACES
737 [ATTENTION] This function is deprecated for security reason.
739 Concatenates one Null-terminated Unicode string to another Null-terminated
740 Unicode string, and returns the concatenated Unicode string.
742 This function concatenates two Null-terminated Unicode strings. The contents
743 of Null-terminated Unicode string Source are concatenated to the end of
744 Null-terminated Unicode string Destination. The Null-terminated concatenated
745 Unicode String is returned. If Source and Destination overlap, then the
746 results are undefined.
748 If Destination is NULL, then ASSERT().
749 If Destination is not aligned on a 16-bit boundary, then ASSERT().
750 If Source is NULL, then ASSERT().
751 If Source is not aligned on a 16-bit boundary, then ASSERT().
752 If Source and Destination overlap, then ASSERT().
753 If PcdMaximumUnicodeStringLength is not zero, and Destination contains more
754 than PcdMaximumUnicodeStringLength Unicode characters, not including the
755 Null-terminator, then ASSERT().
756 If PcdMaximumUnicodeStringLength is not zero, and Source contains more than
757 PcdMaximumUnicodeStringLength Unicode characters, not including the
758 Null-terminator, then ASSERT().
759 If PcdMaximumUnicodeStringLength is not zero, and concatenating Destination
760 and Source results in a Unicode string with more than
761 PcdMaximumUnicodeStringLength Unicode characters, not including the
762 Null-terminator, then ASSERT().
764 @param Destination The pointer to a Null-terminated Unicode string.
765 @param Source The pointer to a Null-terminated Unicode string.
773 IN OUT CHAR16
*Destination
,
774 IN CONST CHAR16
*Source
779 [ATTENTION] This function is deprecated for security reason.
781 Concatenates up to a specified length one Null-terminated Unicode to the end
782 of another Null-terminated Unicode string, and returns the concatenated
785 This function concatenates two Null-terminated Unicode strings. The contents
786 of Null-terminated Unicode string Source are concatenated to the end of
787 Null-terminated Unicode string Destination, and Destination is returned. At
788 most, Length Unicode characters are concatenated from Source to the end of
789 Destination, and Destination is always Null-terminated. If Length is 0, then
790 Destination is returned unmodified. If Source and Destination overlap, then
791 the results are undefined.
793 If Destination is NULL, then ASSERT().
794 If Length > 0 and Destination is not aligned on a 16-bit boundary, then ASSERT().
795 If Length > 0 and Source is NULL, then ASSERT().
796 If Length > 0 and Source is not aligned on a 16-bit boundary, then ASSERT().
797 If Source and Destination overlap, then ASSERT().
798 If PcdMaximumUnicodeStringLength is not zero, and Length is greater than
799 PcdMaximumUnicodeStringLength, then ASSERT().
800 If PcdMaximumUnicodeStringLength is not zero, and Destination contains more
801 than PcdMaximumUnicodeStringLength Unicode characters, not including the
802 Null-terminator, then ASSERT().
803 If PcdMaximumUnicodeStringLength is not zero, and Source contains more than
804 PcdMaximumUnicodeStringLength Unicode characters, not including the
805 Null-terminator, then ASSERT().
806 If PcdMaximumUnicodeStringLength is not zero, and concatenating Destination
807 and Source results in a Unicode string with more than PcdMaximumUnicodeStringLength
808 Unicode characters, not including the Null-terminator, then ASSERT().
810 @param Destination The pointer to a Null-terminated Unicode string.
811 @param Source The pointer to a Null-terminated Unicode string.
812 @param Length The maximum number of Unicode characters to concatenate from
821 IN OUT CHAR16
*Destination
,
822 IN CONST CHAR16
*Source
,
828 Returns the first occurrence of a Null-terminated Unicode sub-string
829 in a Null-terminated Unicode string.
831 This function scans the contents of the Null-terminated Unicode string
832 specified by String and returns the first occurrence of SearchString.
833 If SearchString is not found in String, then NULL is returned. If
834 the length of SearchString is zero, then String is returned.
836 If String is NULL, then ASSERT().
837 If String is not aligned on a 16-bit boundary, then ASSERT().
838 If SearchString is NULL, then ASSERT().
839 If SearchString is not aligned on a 16-bit boundary, then ASSERT().
841 If PcdMaximumUnicodeStringLength is not zero, and SearchString
842 or String contains more than PcdMaximumUnicodeStringLength Unicode
843 characters, not including the Null-terminator, then ASSERT().
845 @param String The pointer to a Null-terminated Unicode string.
846 @param SearchString The pointer to a Null-terminated Unicode string to search for.
848 @retval NULL If the SearchString does not appear in String.
849 @return others If there is a match.
855 IN CONST CHAR16
*String
,
856 IN CONST CHAR16
*SearchString
860 Convert a Null-terminated Unicode decimal string to a value of
863 This function returns a value of type UINTN by interpreting the contents
864 of the Unicode string specified by String as a decimal number. The format
865 of the input Unicode string String is:
867 [spaces] [decimal digits].
869 The valid decimal digit character is in the range [0-9]. The
870 function will ignore the pad space, which includes spaces or
871 tab characters, before [decimal digits]. The running zero in the
872 beginning of [decimal digits] will be ignored. Then, the function
873 stops at the first character that is a not a valid decimal character
874 or a Null-terminator, whichever one comes first.
876 If String is NULL, then ASSERT().
877 If String is not aligned in a 16-bit boundary, then ASSERT().
878 If String has only pad spaces, then 0 is returned.
879 If String has no pad spaces or valid decimal digits,
881 If the number represented by String overflows according
882 to the range defined by UINTN, then ASSERT().
884 If PcdMaximumUnicodeStringLength is not zero, and String contains
885 more than PcdMaximumUnicodeStringLength Unicode characters not including
886 the Null-terminator, then ASSERT().
888 @param String The pointer to a Null-terminated Unicode string.
890 @retval Value translated from String.
896 IN CONST CHAR16
*String
900 Convert a Null-terminated Unicode decimal string to a value of
903 This function returns a value of type UINT64 by interpreting the contents
904 of the Unicode string specified by String as a decimal number. The format
905 of the input Unicode string String is:
907 [spaces] [decimal digits].
909 The valid decimal digit character is in the range [0-9]. The
910 function will ignore the pad space, which includes spaces or
911 tab characters, before [decimal digits]. The running zero in the
912 beginning of [decimal digits] will be ignored. Then, the function
913 stops at the first character that is a not a valid decimal character
914 or a Null-terminator, whichever one comes first.
916 If String is NULL, then ASSERT().
917 If String is not aligned in a 16-bit boundary, then ASSERT().
918 If String has only pad spaces, then 0 is returned.
919 If String has no pad spaces or valid decimal digits,
921 If the number represented by String overflows according
922 to the range defined by UINT64, then ASSERT().
924 If PcdMaximumUnicodeStringLength is not zero, and String contains
925 more than PcdMaximumUnicodeStringLength Unicode characters not including
926 the Null-terminator, then ASSERT().
928 @param String The pointer to a Null-terminated Unicode string.
930 @retval Value translated from String.
936 IN CONST CHAR16
*String
941 Convert a Null-terminated Unicode hexadecimal string to a value of type UINTN.
943 This function returns a value of type UINTN by interpreting the contents
944 of the Unicode string specified by String as a hexadecimal number.
945 The format of the input Unicode string String is:
947 [spaces][zeros][x][hexadecimal digits].
949 The valid hexadecimal digit character is in the range [0-9], [a-f] and [A-F].
950 The prefix "0x" is optional. Both "x" and "X" is allowed in "0x" prefix.
951 If "x" appears in the input string, it must be prefixed with at least one 0.
952 The function will ignore the pad space, which includes spaces or tab characters,
953 before [zeros], [x] or [hexadecimal digit]. The running zero before [x] or
954 [hexadecimal digit] will be ignored. Then, the decoding starts after [x] or the
955 first valid hexadecimal digit. Then, the function stops at the first character
956 that is a not a valid hexadecimal character or NULL, whichever one comes first.
958 If String is NULL, then ASSERT().
959 If String is not aligned in a 16-bit boundary, then ASSERT().
960 If String has only pad spaces, then zero is returned.
961 If String has no leading pad spaces, leading zeros or valid hexadecimal digits,
962 then zero is returned.
963 If the number represented by String overflows according to the range defined by
964 UINTN, then ASSERT().
966 If PcdMaximumUnicodeStringLength is not zero, and String contains more than
967 PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator,
970 @param String The pointer to a Null-terminated Unicode string.
972 @retval Value translated from String.
978 IN CONST CHAR16
*String
983 Convert a Null-terminated Unicode hexadecimal string to a value of type UINT64.
985 This function returns a value of type UINT64 by interpreting the contents
986 of the Unicode string specified by String as a hexadecimal number.
987 The format of the input Unicode string String is
989 [spaces][zeros][x][hexadecimal digits].
991 The valid hexadecimal digit character is in the range [0-9], [a-f] and [A-F].
992 The prefix "0x" is optional. Both "x" and "X" is allowed in "0x" prefix.
993 If "x" appears in the input string, it must be prefixed with at least one 0.
994 The function will ignore the pad space, which includes spaces or tab characters,
995 before [zeros], [x] or [hexadecimal digit]. The running zero before [x] or
996 [hexadecimal digit] will be ignored. Then, the decoding starts after [x] or the
997 first valid hexadecimal digit. Then, the function stops at the first character that is
998 a not a valid hexadecimal character or NULL, whichever one comes first.
1000 If String is NULL, then ASSERT().
1001 If String is not aligned in a 16-bit boundary, then ASSERT().
1002 If String has only pad spaces, then zero is returned.
1003 If String has no leading pad spaces, leading zeros or valid hexadecimal digits,
1004 then zero is returned.
1005 If the number represented by String overflows according to the range defined by
1006 UINT64, then ASSERT().
1008 If PcdMaximumUnicodeStringLength is not zero, and String contains more than
1009 PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator,
1012 @param String The pointer to a Null-terminated Unicode string.
1014 @retval Value translated from String.
1020 IN CONST CHAR16
*String
1023 #ifndef DISABLE_NEW_DEPRECATED_INTERFACES
1026 [ATTENTION] This function is deprecated for security reason.
1028 Convert a Null-terminated Unicode string to a Null-terminated
1029 ASCII string and returns the ASCII string.
1031 This function converts the content of the Unicode string Source
1032 to the ASCII string Destination by copying the lower 8 bits of
1033 each Unicode character. It returns Destination.
1035 The caller is responsible to make sure Destination points to a buffer with size
1036 equal or greater than ((StrLen (Source) + 1) * sizeof (CHAR8)) in bytes.
1038 If any Unicode characters in Source contain non-zero value in
1039 the upper 8 bits, then ASSERT().
1041 If Destination is NULL, then ASSERT().
1042 If Source is NULL, then ASSERT().
1043 If Source is not aligned on a 16-bit boundary, then ASSERT().
1044 If Source and Destination overlap, then ASSERT().
1046 If PcdMaximumUnicodeStringLength is not zero, and Source contains
1047 more than PcdMaximumUnicodeStringLength Unicode characters not including
1048 the Null-terminator, then ASSERT().
1050 If PcdMaximumAsciiStringLength is not zero, and Source contains more
1051 than PcdMaximumAsciiStringLength Unicode characters not including the
1052 Null-terminator, then ASSERT().
1054 @param Source The pointer to a Null-terminated Unicode string.
1055 @param Destination The pointer to a Null-terminated ASCII string.
1057 @return Destination.
1062 UnicodeStrToAsciiStr (
1063 IN CONST CHAR16
*Source
,
1064 OUT CHAR8
*Destination
1070 Convert a Null-terminated Unicode string to a Null-terminated
1073 This function is similar to AsciiStrCpyS.
1075 This function converts the content of the Unicode string Source
1076 to the ASCII string Destination by copying the lower 8 bits of
1077 each Unicode character. The function terminates the ASCII string
1078 Destination by appending a Null-terminator character at the end.
1080 The caller is responsible to make sure Destination points to a buffer with size
1081 equal or greater than ((StrLen (Source) + 1) * sizeof (CHAR8)) in bytes.
1083 If any Unicode characters in Source contain non-zero value in
1084 the upper 8 bits, then ASSERT().
1086 If Source is not aligned on a 16-bit boundary, then ASSERT().
1087 If an error would be returned, then the function will also ASSERT().
1089 If an error is returned, then the Destination is unmodified.
1091 @param Source The pointer to a Null-terminated Unicode string.
1092 @param Destination The pointer to a Null-terminated ASCII string.
1093 @param DestMax The maximum number of Destination Ascii
1094 char, including terminating null char.
1096 @retval RETURN_SUCCESS String is converted.
1097 @retval RETURN_BUFFER_TOO_SMALL If DestMax is NOT greater than StrLen(Source).
1098 @retval RETURN_INVALID_PARAMETER If Destination is NULL.
1100 If PcdMaximumAsciiStringLength is not zero,
1101 and DestMax is greater than
1102 PcdMaximumAsciiStringLength.
1103 If PcdMaximumUnicodeStringLength is not zero,
1104 and DestMax is greater than
1105 PcdMaximumUnicodeStringLength.
1107 @retval RETURN_ACCESS_DENIED If Source and Destination overlap.
1112 UnicodeStrToAsciiStrS (
1113 IN CONST CHAR16
*Source
,
1114 OUT CHAR8
*Destination
,
1118 #ifndef DISABLE_NEW_DEPRECATED_INTERFACES
1121 [ATTENTION] This function is deprecated for security reason.
1123 Copies one Null-terminated ASCII string to another Null-terminated ASCII
1124 string and returns the new ASCII string.
1126 This function copies the contents of the ASCII string Source to the ASCII
1127 string Destination, and returns Destination. If Source and Destination
1128 overlap, then the results are undefined.
1130 If Destination is NULL, then ASSERT().
1131 If Source is NULL, then ASSERT().
1132 If Source and Destination overlap, then ASSERT().
1133 If PcdMaximumAsciiStringLength is not zero and Source contains more than
1134 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
1137 @param Destination The pointer to a Null-terminated ASCII string.
1138 @param Source The pointer to a Null-terminated ASCII string.
1146 OUT CHAR8
*Destination
,
1147 IN CONST CHAR8
*Source
1152 [ATTENTION] This function is deprecated for security reason.
1154 Copies up to a specified length one Null-terminated ASCII string to another
1155 Null-terminated ASCII string and returns the new ASCII string.
1157 This function copies the contents of the ASCII string Source to the ASCII
1158 string Destination, and returns Destination. At most, Length ASCII characters
1159 are copied from Source to Destination. If Length is 0, then Destination is
1160 returned unmodified. If Length is greater that the number of ASCII characters
1161 in Source, then Destination is padded with Null ASCII characters. If Source
1162 and Destination overlap, then the results are undefined.
1164 If Destination is NULL, then ASSERT().
1165 If Source is NULL, then ASSERT().
1166 If Source and Destination overlap, then ASSERT().
1167 If PcdMaximumAsciiStringLength is not zero, and Length is greater than
1168 PcdMaximumAsciiStringLength, then ASSERT().
1169 If PcdMaximumAsciiStringLength is not zero, and Source contains more than
1170 PcdMaximumAsciiStringLength ASCII characters, not including the Null-terminator,
1173 @param Destination The pointer to a Null-terminated ASCII string.
1174 @param Source The pointer to a Null-terminated ASCII string.
1175 @param Length The maximum number of ASCII characters to copy.
1183 OUT CHAR8
*Destination
,
1184 IN CONST CHAR8
*Source
,
1190 Returns the length of a Null-terminated ASCII string.
1192 This function returns the number of ASCII characters in the Null-terminated
1193 ASCII string specified by String.
1195 If Length > 0 and Destination is NULL, then ASSERT().
1196 If Length > 0 and Source is NULL, then ASSERT().
1197 If PcdMaximumAsciiStringLength is not zero and String contains more than
1198 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
1201 @param String The pointer to a Null-terminated ASCII string.
1203 @return The length of String.
1209 IN CONST CHAR8
*String
1214 Returns the size of a Null-terminated ASCII string in bytes, including the
1217 This function returns the size, in bytes, of the Null-terminated ASCII string
1218 specified by String.
1220 If String is NULL, then ASSERT().
1221 If PcdMaximumAsciiStringLength is not zero and String contains more than
1222 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
1225 @param String The pointer to a Null-terminated ASCII string.
1227 @return The size of String.
1233 IN CONST CHAR8
*String
1238 Compares two Null-terminated ASCII strings, and returns the difference
1239 between the first mismatched ASCII characters.
1241 This function compares the Null-terminated ASCII string FirstString to the
1242 Null-terminated ASCII string SecondString. If FirstString is identical to
1243 SecondString, then 0 is returned. Otherwise, the value returned is the first
1244 mismatched ASCII character in SecondString subtracted from the first
1245 mismatched ASCII character in FirstString.
1247 If FirstString is NULL, then ASSERT().
1248 If SecondString is NULL, then ASSERT().
1249 If PcdMaximumAsciiStringLength is not zero and FirstString contains more than
1250 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
1252 If PcdMaximumAsciiStringLength is not zero and SecondString contains more
1253 than PcdMaximumAsciiStringLength ASCII characters not including the
1254 Null-terminator, then ASSERT().
1256 @param FirstString The pointer to a Null-terminated ASCII string.
1257 @param SecondString The pointer to a Null-terminated ASCII string.
1259 @retval ==0 FirstString is identical to SecondString.
1260 @retval !=0 FirstString is not identical to SecondString.
1266 IN CONST CHAR8
*FirstString
,
1267 IN CONST CHAR8
*SecondString
1272 Performs a case insensitive comparison of two Null-terminated ASCII strings,
1273 and returns the difference between the first mismatched ASCII characters.
1275 This function performs a case insensitive comparison of the Null-terminated
1276 ASCII string FirstString to the Null-terminated ASCII string SecondString. If
1277 FirstString is identical to SecondString, then 0 is returned. Otherwise, the
1278 value returned is the first mismatched lower case ASCII character in
1279 SecondString subtracted from the first mismatched lower case ASCII character
1282 If FirstString is NULL, then ASSERT().
1283 If SecondString is NULL, then ASSERT().
1284 If PcdMaximumAsciiStringLength is not zero and FirstString contains more than
1285 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
1287 If PcdMaximumAsciiStringLength is not zero and SecondString contains more
1288 than PcdMaximumAsciiStringLength ASCII characters not including the
1289 Null-terminator, then ASSERT().
1291 @param FirstString The pointer to a Null-terminated ASCII string.
1292 @param SecondString The pointer to a Null-terminated ASCII string.
1294 @retval ==0 FirstString is identical to SecondString using case insensitive
1296 @retval !=0 FirstString is not identical to SecondString using case
1297 insensitive comparisons.
1303 IN CONST CHAR8
*FirstString
,
1304 IN CONST CHAR8
*SecondString
1309 Compares two Null-terminated ASCII strings with maximum lengths, and returns
1310 the difference between the first mismatched ASCII characters.
1312 This function compares the Null-terminated ASCII string FirstString to the
1313 Null-terminated ASCII string SecondString. At most, Length ASCII characters
1314 will be compared. If Length is 0, then 0 is returned. If FirstString is
1315 identical to SecondString, then 0 is returned. Otherwise, the value returned
1316 is the first mismatched ASCII character in SecondString subtracted from the
1317 first mismatched ASCII character in FirstString.
1319 If Length > 0 and FirstString is NULL, then ASSERT().
1320 If Length > 0 and SecondString is NULL, then ASSERT().
1321 If PcdMaximumAsciiStringLength is not zero, and Length is greater than
1322 PcdMaximumAsciiStringLength, then ASSERT().
1323 If PcdMaximumAsciiStringLength is not zero, and FirstString contains more than
1324 PcdMaximumAsciiStringLength ASCII characters, not including the Null-terminator,
1326 If PcdMaximumAsciiStringLength is not zero, and SecondString contains more than
1327 PcdMaximumAsciiStringLength ASCII characters, not including the Null-terminator,
1330 @param FirstString The pointer to a Null-terminated ASCII string.
1331 @param SecondString The pointer to a Null-terminated ASCII string.
1332 @param Length The maximum number of ASCII characters for compare.
1334 @retval ==0 FirstString is identical to SecondString.
1335 @retval !=0 FirstString is not identical to SecondString.
1341 IN CONST CHAR8
*FirstString
,
1342 IN CONST CHAR8
*SecondString
,
1347 #ifndef DISABLE_NEW_DEPRECATED_INTERFACES
1350 [ATTENTION] This function is deprecated for security reason.
1352 Concatenates one Null-terminated ASCII string to another Null-terminated
1353 ASCII string, and returns the concatenated ASCII string.
1355 This function concatenates two Null-terminated ASCII strings. The contents of
1356 Null-terminated ASCII string Source are concatenated to the end of Null-
1357 terminated ASCII string Destination. The Null-terminated concatenated ASCII
1360 If Destination is NULL, then ASSERT().
1361 If Source is NULL, then ASSERT().
1362 If PcdMaximumAsciiStringLength is not zero and Destination contains more than
1363 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
1365 If PcdMaximumAsciiStringLength is not zero and Source contains more than
1366 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
1368 If PcdMaximumAsciiStringLength is not zero and concatenating Destination and
1369 Source results in a ASCII string with more than PcdMaximumAsciiStringLength
1370 ASCII characters, then ASSERT().
1372 @param Destination The pointer to a Null-terminated ASCII string.
1373 @param Source The pointer to a Null-terminated ASCII string.
1381 IN OUT CHAR8
*Destination
,
1382 IN CONST CHAR8
*Source
1387 [ATTENTION] This function is deprecated for security reason.
1389 Concatenates up to a specified length one Null-terminated ASCII string to
1390 the end of another Null-terminated ASCII string, and returns the
1391 concatenated ASCII string.
1393 This function concatenates two Null-terminated ASCII strings. The contents
1394 of Null-terminated ASCII string Source are concatenated to the end of Null-
1395 terminated ASCII string Destination, and Destination is returned. At most,
1396 Length ASCII characters are concatenated from Source to the end of
1397 Destination, and Destination is always Null-terminated. If Length is 0, then
1398 Destination is returned unmodified. If Source and Destination overlap, then
1399 the results are undefined.
1401 If Length > 0 and Destination is NULL, then ASSERT().
1402 If Length > 0 and Source is NULL, then ASSERT().
1403 If Source and Destination overlap, then ASSERT().
1404 If PcdMaximumAsciiStringLength is not zero, and Length is greater than
1405 PcdMaximumAsciiStringLength, then ASSERT().
1406 If PcdMaximumAsciiStringLength is not zero, and Destination contains more than
1407 PcdMaximumAsciiStringLength ASCII characters, not including the Null-terminator,
1409 If PcdMaximumAsciiStringLength is not zero, and Source contains more than
1410 PcdMaximumAsciiStringLength ASCII characters, not including the Null-terminator,
1412 If PcdMaximumAsciiStringLength is not zero, and concatenating Destination and
1413 Source results in a ASCII string with more than PcdMaximumAsciiStringLength
1414 ASCII characters, not including the Null-terminator, then ASSERT().
1416 @param Destination The pointer to a Null-terminated ASCII string.
1417 @param Source The pointer to a Null-terminated ASCII string.
1418 @param Length The maximum number of ASCII characters to concatenate from
1427 IN OUT CHAR8
*Destination
,
1428 IN CONST CHAR8
*Source
,
1434 Returns the first occurrence of a Null-terminated ASCII sub-string
1435 in a Null-terminated ASCII string.
1437 This function scans the contents of the ASCII string specified by String
1438 and returns the first occurrence of SearchString. If SearchString is not
1439 found in String, then NULL is returned. If the length of SearchString is zero,
1440 then String is returned.
1442 If String is NULL, then ASSERT().
1443 If SearchString is NULL, then ASSERT().
1445 If PcdMaximumAsciiStringLength is not zero, and SearchString or
1446 String contains more than PcdMaximumAsciiStringLength Unicode characters
1447 not including the Null-terminator, then ASSERT().
1449 @param String The pointer to a Null-terminated ASCII string.
1450 @param SearchString The pointer to a Null-terminated ASCII string to search for.
1452 @retval NULL If the SearchString does not appear in String.
1453 @retval others If there is a match return the first occurrence of SearchingString.
1454 If the length of SearchString is zero,return String.
1460 IN CONST CHAR8
*String
,
1461 IN CONST CHAR8
*SearchString
1466 Convert a Null-terminated ASCII decimal string to a value of type
1469 This function returns a value of type UINTN by interpreting the contents
1470 of the ASCII string String as a decimal number. The format of the input
1471 ASCII string String is:
1473 [spaces] [decimal digits].
1475 The valid decimal digit character is in the range [0-9]. The function will
1476 ignore the pad space, which includes spaces or tab characters, before the digits.
1477 The running zero in the beginning of [decimal digits] will be ignored. Then, the
1478 function stops at the first character that is a not a valid decimal character or
1479 Null-terminator, whichever on comes first.
1481 If String has only pad spaces, then 0 is returned.
1482 If String has no pad spaces or valid decimal digits, then 0 is returned.
1483 If the number represented by String overflows according to the range defined by
1484 UINTN, then ASSERT().
1485 If String is NULL, then ASSERT().
1486 If PcdMaximumAsciiStringLength is not zero, and String contains more than
1487 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
1490 @param String The pointer to a Null-terminated ASCII string.
1492 @retval The value translated from String.
1497 AsciiStrDecimalToUintn (
1498 IN CONST CHAR8
*String
1503 Convert a Null-terminated ASCII decimal string to a value of type
1506 This function returns a value of type UINT64 by interpreting the contents
1507 of the ASCII string String as a decimal number. The format of the input
1508 ASCII string String is:
1510 [spaces] [decimal digits].
1512 The valid decimal digit character is in the range [0-9]. The function will
1513 ignore the pad space, which includes spaces or tab characters, before the digits.
1514 The running zero in the beginning of [decimal digits] will be ignored. Then, the
1515 function stops at the first character that is a not a valid decimal character or
1516 Null-terminator, whichever on comes first.
1518 If String has only pad spaces, then 0 is returned.
1519 If String has no pad spaces or valid decimal digits, then 0 is returned.
1520 If the number represented by String overflows according to the range defined by
1521 UINT64, then ASSERT().
1522 If String is NULL, then ASSERT().
1523 If PcdMaximumAsciiStringLength is not zero, and String contains more than
1524 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
1527 @param String The pointer to a Null-terminated ASCII string.
1529 @retval Value translated from String.
1534 AsciiStrDecimalToUint64 (
1535 IN CONST CHAR8
*String
1540 Convert a Null-terminated ASCII hexadecimal string to a value of type UINTN.
1542 This function returns a value of type UINTN by interpreting the contents of
1543 the ASCII string String as a hexadecimal number. The format of the input ASCII
1546 [spaces][zeros][x][hexadecimal digits].
1548 The valid hexadecimal digit character is in the range [0-9], [a-f] and [A-F].
1549 The prefix "0x" is optional. Both "x" and "X" is allowed in "0x" prefix. If "x"
1550 appears in the input string, it must be prefixed with at least one 0. The function
1551 will ignore the pad space, which includes spaces or tab characters, before [zeros],
1552 [x] or [hexadecimal digits]. The running zero before [x] or [hexadecimal digits]
1553 will be ignored. Then, the decoding starts after [x] or the first valid hexadecimal
1554 digit. Then, the function stops at the first character that is a not a valid
1555 hexadecimal character or Null-terminator, whichever on comes first.
1557 If String has only pad spaces, then 0 is returned.
1558 If String has no leading pad spaces, leading zeros or valid hexadecimal digits, then
1561 If the number represented by String overflows according to the range defined by UINTN,
1563 If String is NULL, then ASSERT().
1564 If PcdMaximumAsciiStringLength is not zero,
1565 and String contains more than PcdMaximumAsciiStringLength ASCII characters not including
1566 the Null-terminator, then ASSERT().
1568 @param String The pointer to a Null-terminated ASCII string.
1570 @retval Value translated from String.
1575 AsciiStrHexToUintn (
1576 IN CONST CHAR8
*String
1581 Convert a Null-terminated ASCII hexadecimal string to a value of type UINT64.
1583 This function returns a value of type UINT64 by interpreting the contents of
1584 the ASCII string String as a hexadecimal number. The format of the input ASCII
1587 [spaces][zeros][x][hexadecimal digits].
1589 The valid hexadecimal digit character is in the range [0-9], [a-f] and [A-F].
1590 The prefix "0x" is optional. Both "x" and "X" is allowed in "0x" prefix. If "x"
1591 appears in the input string, it must be prefixed with at least one 0. The function
1592 will ignore the pad space, which includes spaces or tab characters, before [zeros],
1593 [x] or [hexadecimal digits]. The running zero before [x] or [hexadecimal digits]
1594 will be ignored. Then, the decoding starts after [x] or the first valid hexadecimal
1595 digit. Then, the function stops at the first character that is a not a valid
1596 hexadecimal character or Null-terminator, whichever on comes first.
1598 If String has only pad spaces, then 0 is returned.
1599 If String has no leading pad spaces, leading zeros or valid hexadecimal digits, then
1602 If the number represented by String overflows according to the range defined by UINT64,
1604 If String is NULL, then ASSERT().
1605 If PcdMaximumAsciiStringLength is not zero,
1606 and String contains more than PcdMaximumAsciiStringLength ASCII characters not including
1607 the Null-terminator, then ASSERT().
1609 @param String The pointer to a Null-terminated ASCII string.
1611 @retval Value translated from String.
1616 AsciiStrHexToUint64 (
1617 IN CONST CHAR8
*String
1620 #ifndef DISABLE_NEW_DEPRECATED_INTERFACES
1623 [ATTENTION] This function is deprecated for security reason.
1625 Convert one Null-terminated ASCII string to a Null-terminated
1626 Unicode string and returns the Unicode string.
1628 This function converts the contents of the ASCII string Source to the Unicode
1629 string Destination, and returns Destination. The function terminates the
1630 Unicode string Destination by appending a Null-terminator character at the end.
1631 The caller is responsible to make sure Destination points to a buffer with size
1632 equal or greater than ((AsciiStrLen (Source) + 1) * sizeof (CHAR16)) in bytes.
1634 If Destination is NULL, then ASSERT().
1635 If Destination is not aligned on a 16-bit boundary, then ASSERT().
1636 If Source is NULL, then ASSERT().
1637 If Source and Destination overlap, then ASSERT().
1638 If PcdMaximumAsciiStringLength is not zero, and Source contains more than
1639 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
1641 If PcdMaximumUnicodeStringLength is not zero, and Source contains more than
1642 PcdMaximumUnicodeStringLength ASCII characters not including the
1643 Null-terminator, then ASSERT().
1645 @param Source The pointer to a Null-terminated ASCII string.
1646 @param Destination The pointer to a Null-terminated Unicode string.
1648 @return Destination.
1653 AsciiStrToUnicodeStr (
1654 IN CONST CHAR8
*Source
,
1655 OUT CHAR16
*Destination
1661 Convert one Null-terminated ASCII string to a Null-terminated
1664 This function is similar to StrCpyS.
1666 This function converts the contents of the ASCII string Source to the Unicode
1667 string Destination. The function terminates the Unicode string Destination by
1668 appending a Null-terminator character at the end.
1670 The caller is responsible to make sure Destination points to a buffer with size
1671 equal or greater than ((AsciiStrLen (Source) + 1) * sizeof (CHAR16)) in bytes.
1673 If Destination is not aligned on a 16-bit boundary, then ASSERT().
1674 If an error would be returned, then the function will also ASSERT().
1676 If an error is returned, then the Destination is unmodified.
1678 @param Source The pointer to a Null-terminated ASCII string.
1679 @param Destination The pointer to a Null-terminated Unicode string.
1680 @param DestMax The maximum number of Destination Unicode
1681 char, including terminating null char.
1683 @retval RETURN_SUCCESS String is converted.
1684 @retval RETURN_BUFFER_TOO_SMALL If DestMax is NOT greater than StrLen(Source).
1685 @retval RETURN_INVALID_PARAMETER If Destination is NULL.
1687 If PcdMaximumUnicodeStringLength is not zero,
1688 and DestMax is greater than
1689 PcdMaximumUnicodeStringLength.
1690 If PcdMaximumAsciiStringLength is not zero,
1691 and DestMax is greater than
1692 PcdMaximumAsciiStringLength.
1694 @retval RETURN_ACCESS_DENIED If Source and Destination overlap.
1699 AsciiStrToUnicodeStrS (
1700 IN CONST CHAR8
*Source
,
1701 OUT CHAR16
*Destination
,
1706 Converts an 8-bit value to an 8-bit BCD value.
1708 Converts the 8-bit value specified by Value to BCD. The BCD value is
1711 If Value >= 100, then ASSERT().
1713 @param Value The 8-bit value to convert to BCD. Range 0..99.
1715 @return The BCD value.
1726 Converts an 8-bit BCD value to an 8-bit value.
1728 Converts the 8-bit BCD value specified by Value to an 8-bit value. The 8-bit
1731 If Value >= 0xA0, then ASSERT().
1732 If (Value & 0x0F) >= 0x0A, then ASSERT().
1734 @param Value The 8-bit BCD value to convert to an 8-bit value.
1736 @return The 8-bit value is returned.
1746 // File Path Manipulation Functions
1750 Removes the last directory or file entry in a path by changing the last
1751 L'\' to a CHAR_NULL.
1753 @param[in, out] Path The pointer to the path to modify.
1755 @retval FALSE Nothing was found to remove.
1756 @retval TRUE A directory or file was removed.
1765 Function to clean up paths.
1766 - Single periods in the path are removed.
1767 - Double periods in the path are removed along with a single parent directory.
1768 - Forward slashes L'/' are converted to backward slashes L'\'.
1770 This will be done inline and the existing buffer may be larger than required
1773 @param[in] Path The pointer to the string containing the path.
1775 @return Returns Path, otherwise returns NULL to indicate that an error has occurred.
1779 PathCleanUpDirectories(
1784 // Linked List Functions and Macros
1788 Initializes the head node of a doubly linked list that is declared as a
1789 global variable in a module.
1791 Initializes the forward and backward links of a new linked list. After
1792 initializing a linked list with this macro, the other linked list functions
1793 may be used to add and remove nodes from the linked list. This macro results
1794 in smaller executables by initializing the linked list in the data section,
1795 instead if calling the InitializeListHead() function to perform the
1796 equivalent operation.
1798 @param ListHead The head note of a list to initialize.
1801 #define INITIALIZE_LIST_HEAD_VARIABLE(ListHead) {&(ListHead), &(ListHead)}
1805 Initializes the head node of a doubly linked list, and returns the pointer to
1806 the head node of the doubly linked list.
1808 Initializes the forward and backward links of a new linked list. After
1809 initializing a linked list with this function, the other linked list
1810 functions may be used to add and remove nodes from the linked list. It is up
1811 to the caller of this function to allocate the memory for ListHead.
1813 If ListHead is NULL, then ASSERT().
1815 @param ListHead A pointer to the head node of a new doubly linked list.
1822 InitializeListHead (
1823 IN OUT LIST_ENTRY
*ListHead
1828 Adds a node to the beginning of a doubly linked list, and returns the pointer
1829 to the head node of the doubly linked list.
1831 Adds the node Entry at the beginning of the doubly linked list denoted by
1832 ListHead, and returns ListHead.
1834 If ListHead is NULL, then ASSERT().
1835 If Entry is NULL, then ASSERT().
1836 If ListHead was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or
1837 InitializeListHead(), then ASSERT().
1838 If PcdMaximumLinkedListLength is not zero, and prior to insertion the number
1839 of nodes in ListHead, including the ListHead node, is greater than or
1840 equal to PcdMaximumLinkedListLength, then ASSERT().
1842 @param ListHead A pointer to the head node of a doubly linked list.
1843 @param Entry A pointer to a node that is to be inserted at the beginning
1844 of a doubly linked list.
1852 IN OUT LIST_ENTRY
*ListHead
,
1853 IN OUT LIST_ENTRY
*Entry
1858 Adds a node to the end of a doubly linked list, and returns the pointer to
1859 the head node of the doubly linked list.
1861 Adds the node Entry to the end of the doubly linked list denoted by ListHead,
1862 and returns ListHead.
1864 If ListHead is NULL, then ASSERT().
1865 If Entry is NULL, then ASSERT().
1866 If ListHead was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or
1867 InitializeListHead(), then ASSERT().
1868 If PcdMaximumLinkedListLength is not zero, and prior to insertion the number
1869 of nodes in ListHead, including the ListHead node, is greater than or
1870 equal to PcdMaximumLinkedListLength, then ASSERT().
1872 @param ListHead A pointer to the head node of a doubly linked list.
1873 @param Entry A pointer to a node that is to be added at the end of the
1882 IN OUT LIST_ENTRY
*ListHead
,
1883 IN OUT LIST_ENTRY
*Entry
1888 Retrieves the first node of a doubly linked list.
1890 Returns the first node of a doubly linked list. List must have been
1891 initialized with INTIALIZE_LIST_HEAD_VARIABLE() or InitializeListHead().
1892 If List is empty, then List is returned.
1894 If List is NULL, then ASSERT().
1895 If List was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or
1896 InitializeListHead(), then ASSERT().
1897 If PcdMaximumLinkedListLength is not zero, and the number of nodes
1898 in List, including the List node, is greater than or equal to
1899 PcdMaximumLinkedListLength, then ASSERT().
1901 @param List A pointer to the head node of a doubly linked list.
1903 @return The first node of a doubly linked list.
1904 @retval List The list is empty.
1910 IN CONST LIST_ENTRY
*List
1915 Retrieves the next node of a doubly linked list.
1917 Returns the node of a doubly linked list that follows Node.
1918 List must have been initialized with INTIALIZE_LIST_HEAD_VARIABLE()
1919 or InitializeListHead(). If List is empty, then List is returned.
1921 If List is NULL, then ASSERT().
1922 If Node is NULL, then ASSERT().
1923 If List was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or
1924 InitializeListHead(), then ASSERT().
1925 If PcdMaximumLinkedListLength is not zero, and List contains more than
1926 PcdMaximumLinkedListLength nodes, then ASSERT().
1927 If PcdVerifyNodeInList is TRUE and Node is not a node in List, then ASSERT().
1929 @param List A pointer to the head node of a doubly linked list.
1930 @param Node A pointer to a node in the doubly linked list.
1932 @return The pointer to the next node if one exists. Otherwise List is returned.
1938 IN CONST LIST_ENTRY
*List
,
1939 IN CONST LIST_ENTRY
*Node
1944 Retrieves the previous node of a doubly linked list.
1946 Returns the node of a doubly linked list that precedes Node.
1947 List must have been initialized with INTIALIZE_LIST_HEAD_VARIABLE()
1948 or InitializeListHead(). If List is empty, then List is returned.
1950 If List is NULL, then ASSERT().
1951 If Node is NULL, then ASSERT().
1952 If List was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or
1953 InitializeListHead(), then ASSERT().
1954 If PcdMaximumLinkedListLength is not zero, and List contains more than
1955 PcdMaximumLinkedListLength nodes, then ASSERT().
1956 If PcdVerifyNodeInList is TRUE and Node is not a node in List, then ASSERT().
1958 @param List A pointer to the head node of a doubly linked list.
1959 @param Node A pointer to a node in the doubly linked list.
1961 @return The pointer to the previous node if one exists. Otherwise List is returned.
1967 IN CONST LIST_ENTRY
*List
,
1968 IN CONST LIST_ENTRY
*Node
1973 Checks to see if a doubly linked list is empty or not.
1975 Checks to see if the doubly linked list is empty. If the linked list contains
1976 zero nodes, this function returns TRUE. Otherwise, it returns FALSE.
1978 If ListHead is NULL, then ASSERT().
1979 If ListHead was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or
1980 InitializeListHead(), then ASSERT().
1981 If PcdMaximumLinkedListLength is not zero, and the number of nodes
1982 in List, including the List node, is greater than or equal to
1983 PcdMaximumLinkedListLength, then ASSERT().
1985 @param ListHead A pointer to the head node of a doubly linked list.
1987 @retval TRUE The linked list is empty.
1988 @retval FALSE The linked list is not empty.
1994 IN CONST LIST_ENTRY
*ListHead
1999 Determines if a node in a doubly linked list is the head node of a the same
2000 doubly linked list. This function is typically used to terminate a loop that
2001 traverses all the nodes in a doubly linked list starting with the head node.
2003 Returns TRUE if Node is equal to List. Returns FALSE if Node is one of the
2004 nodes in the doubly linked list specified by List. List must have been
2005 initialized with INTIALIZE_LIST_HEAD_VARIABLE() or InitializeListHead().
2007 If List is NULL, then ASSERT().
2008 If Node is NULL, then ASSERT().
2009 If List was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or InitializeListHead(),
2011 If PcdMaximumLinkedListLength is not zero, and the number of nodes
2012 in List, including the List node, is greater than or equal to
2013 PcdMaximumLinkedListLength, then ASSERT().
2014 If PcdVerifyNodeInList is TRUE and Node is not a node in List the and Node is not equal
2015 to List, then ASSERT().
2017 @param List A pointer to the head node of a doubly linked list.
2018 @param Node A pointer to a node in the doubly linked list.
2020 @retval TRUE Node is the head of the doubly-linked list pointed by List.
2021 @retval FALSE Node is not the head of the doubly-linked list pointed by List.
2027 IN CONST LIST_ENTRY
*List
,
2028 IN CONST LIST_ENTRY
*Node
2033 Determines if a node the last node in a doubly linked list.
2035 Returns TRUE if Node is the last node in the doubly linked list specified by
2036 List. Otherwise, FALSE is returned. List must have been initialized with
2037 INTIALIZE_LIST_HEAD_VARIABLE() or InitializeListHead().
2039 If List is NULL, then ASSERT().
2040 If Node is NULL, then ASSERT().
2041 If List was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or
2042 InitializeListHead(), then ASSERT().
2043 If PcdMaximumLinkedListLength is not zero, and the number of nodes
2044 in List, including the List node, is greater than or equal to
2045 PcdMaximumLinkedListLength, then ASSERT().
2046 If PcdVerifyNodeInList is TRUE and Node is not a node in List, then ASSERT().
2048 @param List A pointer to the head node of a doubly linked list.
2049 @param Node A pointer to a node in the doubly linked list.
2051 @retval TRUE Node is the last node in the linked list.
2052 @retval FALSE Node is not the last node in the linked list.
2058 IN CONST LIST_ENTRY
*List
,
2059 IN CONST LIST_ENTRY
*Node
2064 Swaps the location of two nodes in a doubly linked list, and returns the
2065 first node after the swap.
2067 If FirstEntry is identical to SecondEntry, then SecondEntry is returned.
2068 Otherwise, the location of the FirstEntry node is swapped with the location
2069 of the SecondEntry node in a doubly linked list. SecondEntry must be in the
2070 same double linked list as FirstEntry and that double linked list must have
2071 been initialized with INTIALIZE_LIST_HEAD_VARIABLE() or InitializeListHead().
2072 SecondEntry is returned after the nodes are swapped.
2074 If FirstEntry is NULL, then ASSERT().
2075 If SecondEntry is NULL, then ASSERT().
2076 If PcdVerifyNodeInList is TRUE and SecondEntry and FirstEntry are not in the
2077 same linked list, then ASSERT().
2078 If PcdMaximumLinkedListLength is not zero, and the number of nodes in the
2079 linked list containing the FirstEntry and SecondEntry nodes, including
2080 the FirstEntry and SecondEntry nodes, is greater than or equal to
2081 PcdMaximumLinkedListLength, then ASSERT().
2083 @param FirstEntry A pointer to a node in a linked list.
2084 @param SecondEntry A pointer to another node in the same linked list.
2086 @return SecondEntry.
2092 IN OUT LIST_ENTRY
*FirstEntry
,
2093 IN OUT LIST_ENTRY
*SecondEntry
2098 Removes a node from a doubly linked list, and returns the node that follows
2101 Removes the node Entry from a doubly linked list. It is up to the caller of
2102 this function to release the memory used by this node if that is required. On
2103 exit, the node following Entry in the doubly linked list is returned. If
2104 Entry is the only node in the linked list, then the head node of the linked
2107 If Entry is NULL, then ASSERT().
2108 If Entry is the head node of an empty list, then ASSERT().
2109 If PcdMaximumLinkedListLength is not zero, and the number of nodes in the
2110 linked list containing Entry, including the Entry node, is greater than
2111 or equal to PcdMaximumLinkedListLength, then ASSERT().
2113 @param Entry A pointer to a node in a linked list.
2121 IN CONST LIST_ENTRY
*Entry
2129 Shifts a 64-bit integer left between 0 and 63 bits. The low bits are filled
2130 with zeros. The shifted value is returned.
2132 This function shifts the 64-bit value Operand to the left by Count bits. The
2133 low Count bits are set to zero. The shifted value is returned.
2135 If Count is greater than 63, then ASSERT().
2137 @param Operand The 64-bit operand to shift left.
2138 @param Count The number of bits to shift left.
2140 @return Operand << Count.
2152 Shifts a 64-bit integer right between 0 and 63 bits. This high bits are
2153 filled with zeros. The shifted value is returned.
2155 This function shifts the 64-bit value Operand to the right by Count bits. The
2156 high Count bits are set to zero. The shifted value is returned.
2158 If Count is greater than 63, then ASSERT().
2160 @param Operand The 64-bit operand to shift right.
2161 @param Count The number of bits to shift right.
2163 @return Operand >> Count
2175 Shifts a 64-bit integer right between 0 and 63 bits. The high bits are filled
2176 with original integer's bit 63. The shifted value is returned.
2178 This function shifts the 64-bit value Operand to the right by Count bits. The
2179 high Count bits are set to bit 63 of Operand. The shifted value is returned.
2181 If Count is greater than 63, then ASSERT().
2183 @param Operand The 64-bit operand to shift right.
2184 @param Count The number of bits to shift right.
2186 @return Operand >> Count
2198 Rotates a 32-bit integer left between 0 and 31 bits, filling the low bits
2199 with the high bits that were rotated.
2201 This function rotates the 32-bit value Operand to the left by Count bits. The
2202 low Count bits are fill with the high Count bits of Operand. The rotated
2205 If Count is greater than 31, then ASSERT().
2207 @param Operand The 32-bit operand to rotate left.
2208 @param Count The number of bits to rotate left.
2210 @return Operand << Count
2222 Rotates a 32-bit integer right between 0 and 31 bits, filling the high bits
2223 with the low bits that were rotated.
2225 This function rotates the 32-bit value Operand to the right by Count bits.
2226 The high Count bits are fill with the low Count bits of Operand. The rotated
2229 If Count is greater than 31, then ASSERT().
2231 @param Operand The 32-bit operand to rotate right.
2232 @param Count The number of bits to rotate right.
2234 @return Operand >> Count
2246 Rotates a 64-bit integer left between 0 and 63 bits, filling the low bits
2247 with the high bits that were rotated.
2249 This function rotates the 64-bit value Operand to the left by Count bits. The
2250 low Count bits are fill with the high Count bits of Operand. The rotated
2253 If Count is greater than 63, then ASSERT().
2255 @param Operand The 64-bit operand to rotate left.
2256 @param Count The number of bits to rotate left.
2258 @return Operand << Count
2270 Rotates a 64-bit integer right between 0 and 63 bits, filling the high bits
2271 with the high low bits that were rotated.
2273 This function rotates the 64-bit value Operand to the right by Count bits.
2274 The high Count bits are fill with the low Count bits of Operand. The rotated
2277 If Count is greater than 63, then ASSERT().
2279 @param Operand The 64-bit operand to rotate right.
2280 @param Count The number of bits to rotate right.
2282 @return Operand >> Count
2294 Returns the bit position of the lowest bit set in a 32-bit value.
2296 This function computes the bit position of the lowest bit set in the 32-bit
2297 value specified by Operand. If Operand is zero, then -1 is returned.
2298 Otherwise, a value between 0 and 31 is returned.
2300 @param Operand The 32-bit operand to evaluate.
2302 @retval 0..31 The lowest bit set in Operand was found.
2303 @retval -1 Operand is zero.
2314 Returns the bit position of the lowest bit set in a 64-bit value.
2316 This function computes the bit position of the lowest bit set in the 64-bit
2317 value specified by Operand. If Operand is zero, then -1 is returned.
2318 Otherwise, a value between 0 and 63 is returned.
2320 @param Operand The 64-bit operand to evaluate.
2322 @retval 0..63 The lowest bit set in Operand was found.
2323 @retval -1 Operand is zero.
2335 Returns the bit position of the highest bit set in a 32-bit value. Equivalent
2338 This function computes the bit position of the highest bit set in the 32-bit
2339 value specified by Operand. If Operand is zero, then -1 is returned.
2340 Otherwise, a value between 0 and 31 is returned.
2342 @param Operand The 32-bit operand to evaluate.
2344 @retval 0..31 Position of the highest bit set in Operand if found.
2345 @retval -1 Operand is zero.
2356 Returns the bit position of the highest bit set in a 64-bit value. Equivalent
2359 This function computes the bit position of the highest bit set in the 64-bit
2360 value specified by Operand. If Operand is zero, then -1 is returned.
2361 Otherwise, a value between 0 and 63 is returned.
2363 @param Operand The 64-bit operand to evaluate.
2365 @retval 0..63 Position of the highest bit set in Operand if found.
2366 @retval -1 Operand is zero.
2377 Returns the value of the highest bit set in a 32-bit value. Equivalent to
2380 This function computes the value of the highest bit set in the 32-bit value
2381 specified by Operand. If Operand is zero, then zero is returned.
2383 @param Operand The 32-bit operand to evaluate.
2385 @return 1 << HighBitSet32(Operand)
2386 @retval 0 Operand is zero.
2397 Returns the value of the highest bit set in a 64-bit value. Equivalent to
2400 This function computes the value of the highest bit set in the 64-bit value
2401 specified by Operand. If Operand is zero, then zero is returned.
2403 @param Operand The 64-bit operand to evaluate.
2405 @return 1 << HighBitSet64(Operand)
2406 @retval 0 Operand is zero.
2417 Switches the endianness of a 16-bit integer.
2419 This function swaps the bytes in a 16-bit unsigned value to switch the value
2420 from little endian to big endian or vice versa. The byte swapped value is
2423 @param Value A 16-bit unsigned value.
2425 @return The byte swapped Value.
2436 Switches the endianness of a 32-bit integer.
2438 This function swaps the bytes in a 32-bit unsigned value to switch the value
2439 from little endian to big endian or vice versa. The byte swapped value is
2442 @param Value A 32-bit unsigned value.
2444 @return The byte swapped Value.
2455 Switches the endianness of a 64-bit integer.
2457 This function swaps the bytes in a 64-bit unsigned value to switch the value
2458 from little endian to big endian or vice versa. The byte swapped value is
2461 @param Value A 64-bit unsigned value.
2463 @return The byte swapped Value.
2474 Multiples a 64-bit unsigned integer by a 32-bit unsigned integer and
2475 generates a 64-bit unsigned result.
2477 This function multiples the 64-bit unsigned value Multiplicand by the 32-bit
2478 unsigned value Multiplier and generates a 64-bit unsigned result. This 64-
2479 bit unsigned result is returned.
2481 @param Multiplicand A 64-bit unsigned value.
2482 @param Multiplier A 32-bit unsigned value.
2484 @return Multiplicand * Multiplier
2490 IN UINT64 Multiplicand
,
2491 IN UINT32 Multiplier
2496 Multiples a 64-bit unsigned integer by a 64-bit unsigned integer and
2497 generates a 64-bit unsigned result.
2499 This function multiples the 64-bit unsigned value Multiplicand by the 64-bit
2500 unsigned value Multiplier and generates a 64-bit unsigned result. This 64-
2501 bit unsigned result is returned.
2503 @param Multiplicand A 64-bit unsigned value.
2504 @param Multiplier A 64-bit unsigned value.
2506 @return Multiplicand * Multiplier.
2512 IN UINT64 Multiplicand
,
2513 IN UINT64 Multiplier
2518 Multiples a 64-bit signed integer by a 64-bit signed integer and generates a
2519 64-bit signed result.
2521 This function multiples the 64-bit signed value Multiplicand by the 64-bit
2522 signed value Multiplier and generates a 64-bit signed result. This 64-bit
2523 signed result is returned.
2525 @param Multiplicand A 64-bit signed value.
2526 @param Multiplier A 64-bit signed value.
2528 @return Multiplicand * Multiplier
2534 IN INT64 Multiplicand
,
2540 Divides a 64-bit unsigned integer by a 32-bit unsigned integer and generates
2541 a 64-bit unsigned result.
2543 This function divides the 64-bit unsigned value Dividend by the 32-bit
2544 unsigned value Divisor and generates a 64-bit unsigned quotient. This
2545 function returns the 64-bit unsigned quotient.
2547 If Divisor is 0, then ASSERT().
2549 @param Dividend A 64-bit unsigned value.
2550 @param Divisor A 32-bit unsigned value.
2552 @return Dividend / Divisor.
2564 Divides a 64-bit unsigned integer by a 32-bit unsigned integer and generates
2565 a 32-bit unsigned remainder.
2567 This function divides the 64-bit unsigned value Dividend by the 32-bit
2568 unsigned value Divisor and generates a 32-bit remainder. This function
2569 returns the 32-bit unsigned remainder.
2571 If Divisor is 0, then ASSERT().
2573 @param Dividend A 64-bit unsigned value.
2574 @param Divisor A 32-bit unsigned value.
2576 @return Dividend % Divisor.
2588 Divides a 64-bit unsigned integer by a 32-bit unsigned integer and generates
2589 a 64-bit unsigned result and an optional 32-bit unsigned remainder.
2591 This function divides the 64-bit unsigned value Dividend by the 32-bit
2592 unsigned value Divisor and generates a 64-bit unsigned quotient. If Remainder
2593 is not NULL, then the 32-bit unsigned remainder is returned in Remainder.
2594 This function returns the 64-bit unsigned quotient.
2596 If Divisor is 0, then ASSERT().
2598 @param Dividend A 64-bit unsigned value.
2599 @param Divisor A 32-bit unsigned value.
2600 @param Remainder A pointer to a 32-bit unsigned value. This parameter is
2601 optional and may be NULL.
2603 @return Dividend / Divisor.
2608 DivU64x32Remainder (
2611 OUT UINT32
*Remainder OPTIONAL
2616 Divides a 64-bit unsigned integer by a 64-bit unsigned integer and generates
2617 a 64-bit unsigned result and an optional 64-bit unsigned remainder.
2619 This function divides the 64-bit unsigned value Dividend by the 64-bit
2620 unsigned value Divisor and generates a 64-bit unsigned quotient. If Remainder
2621 is not NULL, then the 64-bit unsigned remainder is returned in Remainder.
2622 This function returns the 64-bit unsigned quotient.
2624 If Divisor is 0, then ASSERT().
2626 @param Dividend A 64-bit unsigned value.
2627 @param Divisor A 64-bit unsigned value.
2628 @param Remainder A pointer to a 64-bit unsigned value. This parameter is
2629 optional and may be NULL.
2631 @return Dividend / Divisor.
2636 DivU64x64Remainder (
2639 OUT UINT64
*Remainder OPTIONAL
2644 Divides a 64-bit signed integer by a 64-bit signed integer and generates a
2645 64-bit signed result and a optional 64-bit signed remainder.
2647 This function divides the 64-bit signed value Dividend by the 64-bit signed
2648 value Divisor and generates a 64-bit signed quotient. If Remainder is not
2649 NULL, then the 64-bit signed remainder is returned in Remainder. This
2650 function returns the 64-bit signed quotient.
2652 It is the caller's responsibility to not call this function with a Divisor of 0.
2653 If Divisor is 0, then the quotient and remainder should be assumed to be
2654 the largest negative integer.
2656 If Divisor is 0, then ASSERT().
2658 @param Dividend A 64-bit signed value.
2659 @param Divisor A 64-bit signed value.
2660 @param Remainder A pointer to a 64-bit signed value. This parameter is
2661 optional and may be NULL.
2663 @return Dividend / Divisor.
2668 DivS64x64Remainder (
2671 OUT INT64
*Remainder OPTIONAL
2676 Reads a 16-bit value from memory that may be unaligned.
2678 This function returns the 16-bit value pointed to by Buffer. The function
2679 guarantees that the read operation does not produce an alignment fault.
2681 If the Buffer is NULL, then ASSERT().
2683 @param Buffer The pointer to a 16-bit value that may be unaligned.
2685 @return The 16-bit value read from Buffer.
2691 IN CONST UINT16
*Buffer
2696 Writes a 16-bit value to memory that may be unaligned.
2698 This function writes the 16-bit value specified by Value to Buffer. Value is
2699 returned. The function guarantees that the write operation does not produce
2702 If the Buffer is NULL, then ASSERT().
2704 @param Buffer The pointer to a 16-bit value that may be unaligned.
2705 @param Value 16-bit value to write to Buffer.
2707 @return The 16-bit value to write to Buffer.
2719 Reads a 24-bit value from memory that may be unaligned.
2721 This function returns the 24-bit value pointed to by Buffer. The function
2722 guarantees that the read operation does not produce an alignment fault.
2724 If the Buffer is NULL, then ASSERT().
2726 @param Buffer The pointer to a 24-bit value that may be unaligned.
2728 @return The 24-bit value read from Buffer.
2734 IN CONST UINT32
*Buffer
2739 Writes a 24-bit value to memory that may be unaligned.
2741 This function writes the 24-bit value specified by Value to Buffer. Value is
2742 returned. The function guarantees that the write operation does not produce
2745 If the Buffer is NULL, then ASSERT().
2747 @param Buffer The pointer to a 24-bit value that may be unaligned.
2748 @param Value 24-bit value to write to Buffer.
2750 @return The 24-bit value to write to Buffer.
2762 Reads a 32-bit value from memory that may be unaligned.
2764 This function returns the 32-bit value pointed to by Buffer. The function
2765 guarantees that the read operation does not produce an alignment fault.
2767 If the Buffer is NULL, then ASSERT().
2769 @param Buffer The pointer to a 32-bit value that may be unaligned.
2771 @return The 32-bit value read from Buffer.
2777 IN CONST UINT32
*Buffer
2782 Writes a 32-bit value to memory that may be unaligned.
2784 This function writes the 32-bit value specified by Value to Buffer. Value is
2785 returned. The function guarantees that the write operation does not produce
2788 If the Buffer is NULL, then ASSERT().
2790 @param Buffer The pointer to a 32-bit value that may be unaligned.
2791 @param Value 32-bit value to write to Buffer.
2793 @return The 32-bit value to write to Buffer.
2805 Reads a 64-bit value from memory that may be unaligned.
2807 This function returns the 64-bit value pointed to by Buffer. The function
2808 guarantees that the read operation does not produce an alignment fault.
2810 If the Buffer is NULL, then ASSERT().
2812 @param Buffer The pointer to a 64-bit value that may be unaligned.
2814 @return The 64-bit value read from Buffer.
2820 IN CONST UINT64
*Buffer
2825 Writes a 64-bit value to memory that may be unaligned.
2827 This function writes the 64-bit value specified by Value to Buffer. Value is
2828 returned. The function guarantees that the write operation does not produce
2831 If the Buffer is NULL, then ASSERT().
2833 @param Buffer The pointer to a 64-bit value that may be unaligned.
2834 @param Value 64-bit value to write to Buffer.
2836 @return The 64-bit value to write to Buffer.
2848 // Bit Field Functions
2852 Returns a bit field from an 8-bit value.
2854 Returns the bitfield specified by the StartBit and the EndBit from Operand.
2856 If 8-bit operations are not supported, then ASSERT().
2857 If StartBit is greater than 7, then ASSERT().
2858 If EndBit is greater than 7, then ASSERT().
2859 If EndBit is less than StartBit, then ASSERT().
2861 @param Operand Operand on which to perform the bitfield operation.
2862 @param StartBit The ordinal of the least significant bit in the bit field.
2864 @param EndBit The ordinal of the most significant bit in the bit field.
2867 @return The bit field read.
2880 Writes a bit field to an 8-bit value, and returns the result.
2882 Writes Value to the bit field specified by the StartBit and the EndBit in
2883 Operand. All other bits in Operand are preserved. The new 8-bit value is
2886 If 8-bit operations are not supported, then ASSERT().
2887 If StartBit is greater than 7, then ASSERT().
2888 If EndBit is greater than 7, then ASSERT().
2889 If EndBit is less than StartBit, then ASSERT().
2890 If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
2892 @param Operand Operand on which to perform the bitfield operation.
2893 @param StartBit The ordinal of the least significant bit in the bit field.
2895 @param EndBit The ordinal of the most significant bit in the bit field.
2897 @param Value New value of the bit field.
2899 @return The new 8-bit value.
2913 Reads a bit field from an 8-bit value, performs a bitwise OR, and returns the
2916 Performs a bitwise OR between the bit field specified by StartBit
2917 and EndBit in Operand and the value specified by OrData. All other bits in
2918 Operand are preserved. The new 8-bit value is returned.
2920 If 8-bit operations are not supported, then ASSERT().
2921 If StartBit is greater than 7, then ASSERT().
2922 If EndBit is greater than 7, then ASSERT().
2923 If EndBit is less than StartBit, then ASSERT().
2924 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
2926 @param Operand Operand on which to perform the bitfield operation.
2927 @param StartBit The ordinal of the least significant bit in the bit field.
2929 @param EndBit The ordinal of the most significant bit in the bit field.
2931 @param OrData The value to OR with the read value from the value
2933 @return The new 8-bit value.
2947 Reads a bit field from an 8-bit value, performs a bitwise AND, and returns
2950 Performs a bitwise AND between the bit field specified by StartBit and EndBit
2951 in Operand and the value specified by AndData. All other bits in Operand are
2952 preserved. The new 8-bit value is returned.
2954 If 8-bit operations are not supported, then ASSERT().
2955 If StartBit is greater than 7, then ASSERT().
2956 If EndBit is greater than 7, then ASSERT().
2957 If EndBit is less than StartBit, then ASSERT().
2958 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
2960 @param Operand Operand on which to perform the bitfield operation.
2961 @param StartBit The ordinal of the least significant bit in the bit field.
2963 @param EndBit The ordinal of the most significant bit in the bit field.
2965 @param AndData The value to AND with the read value from the value.
2967 @return The new 8-bit value.
2981 Reads a bit field from an 8-bit value, performs a bitwise AND followed by a
2982 bitwise OR, and returns the result.
2984 Performs a bitwise AND between the bit field specified by StartBit and EndBit
2985 in Operand and the value specified by AndData, followed by a bitwise
2986 OR with value specified by OrData. All other bits in Operand are
2987 preserved. The new 8-bit value is returned.
2989 If 8-bit operations are not supported, then ASSERT().
2990 If StartBit is greater than 7, then ASSERT().
2991 If EndBit is greater than 7, then ASSERT().
2992 If EndBit is less than StartBit, then ASSERT().
2993 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
2994 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
2996 @param Operand Operand on which to perform the bitfield operation.
2997 @param StartBit The ordinal of the least significant bit in the bit field.
2999 @param EndBit The ordinal of the most significant bit in the bit field.
3001 @param AndData The value to AND with the read value from the value.
3002 @param OrData The value to OR with the result of the AND operation.
3004 @return The new 8-bit value.
3009 BitFieldAndThenOr8 (
3019 Returns a bit field from a 16-bit value.
3021 Returns the bitfield specified by the StartBit and the EndBit from Operand.
3023 If 16-bit operations are not supported, then ASSERT().
3024 If StartBit is greater than 15, then ASSERT().
3025 If EndBit is greater than 15, then ASSERT().
3026 If EndBit is less than StartBit, then ASSERT().
3028 @param Operand Operand on which to perform the bitfield operation.
3029 @param StartBit The ordinal of the least significant bit in the bit field.
3031 @param EndBit The ordinal of the most significant bit in the bit field.
3034 @return The bit field read.
3047 Writes a bit field to a 16-bit value, and returns the result.
3049 Writes Value to the bit field specified by the StartBit and the EndBit in
3050 Operand. All other bits in Operand are preserved. The new 16-bit value is
3053 If 16-bit operations are not supported, then ASSERT().
3054 If StartBit is greater than 15, then ASSERT().
3055 If EndBit is greater than 15, then ASSERT().
3056 If EndBit is less than StartBit, then ASSERT().
3057 If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
3059 @param Operand Operand on which to perform the bitfield operation.
3060 @param StartBit The ordinal of the least significant bit in the bit field.
3062 @param EndBit The ordinal of the most significant bit in the bit field.
3064 @param Value New value of the bit field.
3066 @return The new 16-bit value.
3080 Reads a bit field from a 16-bit value, performs a bitwise OR, and returns the
3083 Performs a bitwise OR between the bit field specified by StartBit
3084 and EndBit in Operand and the value specified by OrData. All other bits in
3085 Operand are preserved. The new 16-bit value is returned.
3087 If 16-bit operations are not supported, then ASSERT().
3088 If StartBit is greater than 15, then ASSERT().
3089 If EndBit is greater than 15, then ASSERT().
3090 If EndBit is less than StartBit, then ASSERT().
3091 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
3093 @param Operand Operand on which to perform the bitfield operation.
3094 @param StartBit The ordinal of the least significant bit in the bit field.
3096 @param EndBit The ordinal of the most significant bit in the bit field.
3098 @param OrData The value to OR with the read value from the value
3100 @return The new 16-bit value.
3114 Reads a bit field from a 16-bit value, performs a bitwise AND, and returns
3117 Performs a bitwise AND between the bit field specified by StartBit and EndBit
3118 in Operand and the value specified by AndData. All other bits in Operand are
3119 preserved. The new 16-bit value is returned.
3121 If 16-bit operations are not supported, then ASSERT().
3122 If StartBit is greater than 15, then ASSERT().
3123 If EndBit is greater than 15, then ASSERT().
3124 If EndBit is less than StartBit, then ASSERT().
3125 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
3127 @param Operand Operand on which to perform the bitfield operation.
3128 @param StartBit The ordinal of the least significant bit in the bit field.
3130 @param EndBit The ordinal of the most significant bit in the bit field.
3132 @param AndData The value to AND with the read value from the value
3134 @return The new 16-bit value.
3148 Reads a bit field from a 16-bit value, performs a bitwise AND followed by a
3149 bitwise OR, and returns the result.
3151 Performs a bitwise AND between the bit field specified by StartBit and EndBit
3152 in Operand and the value specified by AndData, followed by a bitwise
3153 OR with value specified by OrData. All other bits in Operand are
3154 preserved. The new 16-bit value is returned.
3156 If 16-bit operations are not supported, then ASSERT().
3157 If StartBit is greater than 15, then ASSERT().
3158 If EndBit is greater than 15, then ASSERT().
3159 If EndBit is less than StartBit, then ASSERT().
3160 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
3161 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
3163 @param Operand Operand on which to perform the bitfield operation.
3164 @param StartBit The ordinal of the least significant bit in the bit field.
3166 @param EndBit The ordinal of the most significant bit in the bit field.
3168 @param AndData The value to AND with the read value from the value.
3169 @param OrData The value to OR with the result of the AND operation.
3171 @return The new 16-bit value.
3176 BitFieldAndThenOr16 (
3186 Returns a bit field from a 32-bit value.
3188 Returns the bitfield specified by the StartBit and the EndBit from Operand.
3190 If 32-bit operations are not supported, then ASSERT().
3191 If StartBit is greater than 31, then ASSERT().
3192 If EndBit is greater than 31, then ASSERT().
3193 If EndBit is less than StartBit, then ASSERT().
3195 @param Operand Operand on which to perform the bitfield operation.
3196 @param StartBit The ordinal of the least significant bit in the bit field.
3198 @param EndBit The ordinal of the most significant bit in the bit field.
3201 @return The bit field read.
3214 Writes a bit field to a 32-bit value, and returns the result.
3216 Writes Value to the bit field specified by the StartBit and the EndBit in
3217 Operand. All other bits in Operand are preserved. The new 32-bit value is
3220 If 32-bit operations are not supported, then ASSERT().
3221 If StartBit is greater than 31, then ASSERT().
3222 If EndBit is greater than 31, then ASSERT().
3223 If EndBit is less than StartBit, then ASSERT().
3224 If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
3226 @param Operand Operand on which to perform the bitfield operation.
3227 @param StartBit The ordinal of the least significant bit in the bit field.
3229 @param EndBit The ordinal of the most significant bit in the bit field.
3231 @param Value New value of the bit field.
3233 @return The new 32-bit value.
3247 Reads a bit field from a 32-bit value, performs a bitwise OR, and returns the
3250 Performs a bitwise OR between the bit field specified by StartBit
3251 and EndBit in Operand and the value specified by OrData. All other bits in
3252 Operand are preserved. The new 32-bit value is returned.
3254 If 32-bit operations are not supported, then ASSERT().
3255 If StartBit is greater than 31, then ASSERT().
3256 If EndBit is greater than 31, then ASSERT().
3257 If EndBit is less than StartBit, then ASSERT().
3258 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
3260 @param Operand Operand on which to perform the bitfield operation.
3261 @param StartBit The ordinal of the least significant bit in the bit field.
3263 @param EndBit The ordinal of the most significant bit in the bit field.
3265 @param OrData The value to OR with the read value from the value.
3267 @return The new 32-bit value.
3281 Reads a bit field from a 32-bit value, performs a bitwise AND, and returns
3284 Performs a bitwise AND between the bit field specified by StartBit and EndBit
3285 in Operand and the value specified by AndData. All other bits in Operand are
3286 preserved. The new 32-bit value is returned.
3288 If 32-bit operations are not supported, then ASSERT().
3289 If StartBit is greater than 31, then ASSERT().
3290 If EndBit is greater than 31, then ASSERT().
3291 If EndBit is less than StartBit, then ASSERT().
3292 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
3294 @param Operand Operand on which to perform the bitfield operation.
3295 @param StartBit The ordinal of the least significant bit in the bit field.
3297 @param EndBit The ordinal of the most significant bit in the bit field.
3299 @param AndData The value to AND with the read value from the value
3301 @return The new 32-bit value.
3315 Reads a bit field from a 32-bit value, performs a bitwise AND followed by a
3316 bitwise OR, and returns the result.
3318 Performs a bitwise AND between the bit field specified by StartBit and EndBit
3319 in Operand and the value specified by AndData, followed by a bitwise
3320 OR with value specified by OrData. All other bits in Operand are
3321 preserved. The new 32-bit value is returned.
3323 If 32-bit operations are not supported, then ASSERT().
3324 If StartBit is greater than 31, then ASSERT().
3325 If EndBit is greater than 31, then ASSERT().
3326 If EndBit is less than StartBit, then ASSERT().
3327 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
3328 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
3330 @param Operand Operand on which to perform the bitfield operation.
3331 @param StartBit The ordinal of the least significant bit in the bit field.
3333 @param EndBit The ordinal of the most significant bit in the bit field.
3335 @param AndData The value to AND with the read value from the value.
3336 @param OrData The value to OR with the result of the AND operation.
3338 @return The new 32-bit value.
3343 BitFieldAndThenOr32 (
3353 Returns a bit field from a 64-bit value.
3355 Returns the bitfield specified by the StartBit and the EndBit from Operand.
3357 If 64-bit operations are not supported, then ASSERT().
3358 If StartBit is greater than 63, then ASSERT().
3359 If EndBit is greater than 63, then ASSERT().
3360 If EndBit is less than StartBit, then ASSERT().
3362 @param Operand Operand on which to perform the bitfield operation.
3363 @param StartBit The ordinal of the least significant bit in the bit field.
3365 @param EndBit The ordinal of the most significant bit in the bit field.
3368 @return The bit field read.
3381 Writes a bit field to a 64-bit value, and returns the result.
3383 Writes Value to the bit field specified by the StartBit and the EndBit in
3384 Operand. All other bits in Operand are preserved. The new 64-bit value is
3387 If 64-bit operations are not supported, then ASSERT().
3388 If StartBit is greater than 63, then ASSERT().
3389 If EndBit is greater than 63, then ASSERT().
3390 If EndBit is less than StartBit, then ASSERT().
3391 If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
3393 @param Operand Operand on which to perform the bitfield operation.
3394 @param StartBit The ordinal of the least significant bit in the bit field.
3396 @param EndBit The ordinal of the most significant bit in the bit field.
3398 @param Value New value of the bit field.
3400 @return The new 64-bit value.
3414 Reads a bit field from a 64-bit value, performs a bitwise OR, and returns the
3417 Performs a bitwise OR between the bit field specified by StartBit
3418 and EndBit in Operand and the value specified by OrData. All other bits in
3419 Operand are preserved. The new 64-bit value is returned.
3421 If 64-bit operations are not supported, then ASSERT().
3422 If StartBit is greater than 63, then ASSERT().
3423 If EndBit is greater than 63, then ASSERT().
3424 If EndBit is less than StartBit, then ASSERT().
3425 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
3427 @param Operand Operand on which to perform the bitfield operation.
3428 @param StartBit The ordinal of the least significant bit in the bit field.
3430 @param EndBit The ordinal of the most significant bit in the bit field.
3432 @param OrData The value to OR with the read value from the value
3434 @return The new 64-bit value.
3448 Reads a bit field from a 64-bit value, performs a bitwise AND, and returns
3451 Performs a bitwise AND between the bit field specified by StartBit and EndBit
3452 in Operand and the value specified by AndData. All other bits in Operand are
3453 preserved. The new 64-bit value is returned.
3455 If 64-bit operations are not supported, then ASSERT().
3456 If StartBit is greater than 63, then ASSERT().
3457 If EndBit is greater than 63, then ASSERT().
3458 If EndBit is less than StartBit, then ASSERT().
3459 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
3461 @param Operand Operand on which to perform the bitfield operation.
3462 @param StartBit The ordinal of the least significant bit in the bit field.
3464 @param EndBit The ordinal of the most significant bit in the bit field.
3466 @param AndData The value to AND with the read value from the value
3468 @return The new 64-bit value.
3482 Reads a bit field from a 64-bit value, performs a bitwise AND followed by a
3483 bitwise OR, and returns the result.
3485 Performs a bitwise AND between the bit field specified by StartBit and EndBit
3486 in Operand and the value specified by AndData, followed by a bitwise
3487 OR with value specified by OrData. All other bits in Operand are
3488 preserved. The new 64-bit value is returned.
3490 If 64-bit operations are not supported, then ASSERT().
3491 If StartBit is greater than 63, then ASSERT().
3492 If EndBit is greater than 63, then ASSERT().
3493 If EndBit is less than StartBit, then ASSERT().
3494 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
3495 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
3497 @param Operand Operand on which to perform the bitfield operation.
3498 @param StartBit The ordinal of the least significant bit in the bit field.
3500 @param EndBit The ordinal of the most significant bit in the bit field.
3502 @param AndData The value to AND with the read value from the value.
3503 @param OrData The value to OR with the result of the AND operation.
3505 @return The new 64-bit value.
3510 BitFieldAndThenOr64 (
3519 // Base Library Checksum Functions
3523 Returns the sum of all elements in a buffer in unit of UINT8.
3524 During calculation, the carry bits are dropped.
3526 This function calculates the sum of all elements in a buffer
3527 in unit of UINT8. The carry bits in result of addition are dropped.
3528 The result is returned as UINT8. If Length is Zero, then Zero is
3531 If Buffer is NULL, then ASSERT().
3532 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
3534 @param Buffer The pointer to the buffer to carry out the sum operation.
3535 @param Length The size, in bytes, of Buffer.
3537 @return Sum The sum of Buffer with carry bits dropped during additions.
3543 IN CONST UINT8
*Buffer
,
3549 Returns the two's complement checksum of all elements in a buffer
3552 This function first calculates the sum of the 8-bit values in the
3553 buffer specified by Buffer and Length. The carry bits in the result
3554 of addition are dropped. Then, the two's complement of the sum is
3555 returned. If Length is 0, then 0 is returned.
3557 If Buffer is NULL, then ASSERT().
3558 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
3560 @param Buffer The pointer to the buffer to carry out the checksum operation.
3561 @param Length The size, in bytes, of Buffer.
3563 @return Checksum The two's complement checksum of Buffer.
3568 CalculateCheckSum8 (
3569 IN CONST UINT8
*Buffer
,
3575 Returns the sum of all elements in a buffer of 16-bit values. During
3576 calculation, the carry bits are dropped.
3578 This function calculates the sum of the 16-bit values in the buffer
3579 specified by Buffer and Length. The carry bits in result of addition are dropped.
3580 The 16-bit result is returned. If Length is 0, then 0 is returned.
3582 If Buffer is NULL, then ASSERT().
3583 If Buffer is not aligned on a 16-bit boundary, then ASSERT().
3584 If Length is not aligned on a 16-bit boundary, 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 UINT16
*Buffer
,
3602 Returns the two's complement checksum of all elements in a buffer of
3605 This function first calculates the sum of the 16-bit values in the buffer
3606 specified by Buffer and Length. The carry bits in the result of addition
3607 are dropped. Then, the two's complement of the sum is returned. If Length
3608 is 0, then 0 is returned.
3610 If Buffer is NULL, then ASSERT().
3611 If Buffer is not aligned on a 16-bit boundary, then ASSERT().
3612 If Length is not aligned on a 16-bit boundary, then ASSERT().
3613 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
3615 @param Buffer The pointer to the buffer to carry out the checksum operation.
3616 @param Length The size, in bytes, of Buffer.
3618 @return Checksum The two's complement checksum of Buffer.
3623 CalculateCheckSum16 (
3624 IN CONST UINT16
*Buffer
,
3630 Returns the sum of all elements in a buffer of 32-bit values. During
3631 calculation, the carry bits are dropped.
3633 This function calculates the sum of the 32-bit values in the buffer
3634 specified by Buffer and Length. The carry bits in result of addition are dropped.
3635 The 32-bit result is returned. If Length is 0, then 0 is returned.
3637 If Buffer is NULL, then ASSERT().
3638 If Buffer is not aligned on a 32-bit boundary, then ASSERT().
3639 If Length is not aligned on a 32-bit boundary, then ASSERT().
3640 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
3642 @param Buffer The pointer to the buffer to carry out the sum operation.
3643 @param Length The size, in bytes, of Buffer.
3645 @return Sum The sum of Buffer with carry bits dropped during additions.
3651 IN CONST UINT32
*Buffer
,
3657 Returns the two's complement checksum of all elements in a buffer of
3660 This function first calculates the sum of the 32-bit values in the buffer
3661 specified by Buffer and Length. The carry bits in the result of addition
3662 are dropped. Then, the two's complement of the sum is returned. If Length
3663 is 0, then 0 is returned.
3665 If Buffer is NULL, then ASSERT().
3666 If Buffer is not aligned on a 32-bit boundary, then ASSERT().
3667 If Length is not aligned on a 32-bit boundary, then ASSERT().
3668 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
3670 @param Buffer The pointer to the buffer to carry out the checksum operation.
3671 @param Length The size, in bytes, of Buffer.
3673 @return Checksum The two's complement checksum of Buffer.
3678 CalculateCheckSum32 (
3679 IN CONST UINT32
*Buffer
,
3685 Returns the sum of all elements in a buffer of 64-bit values. During
3686 calculation, the carry bits are dropped.
3688 This function calculates the sum of the 64-bit values in the buffer
3689 specified by Buffer and Length. The carry bits in result of addition are dropped.
3690 The 64-bit result is returned. If Length is 0, then 0 is returned.
3692 If Buffer is NULL, then ASSERT().
3693 If Buffer is not aligned on a 64-bit boundary, then ASSERT().
3694 If Length is not aligned on a 64-bit boundary, then ASSERT().
3695 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
3697 @param Buffer The pointer to the buffer to carry out the sum operation.
3698 @param Length The size, in bytes, of Buffer.
3700 @return Sum The sum of Buffer with carry bits dropped during additions.
3706 IN CONST UINT64
*Buffer
,
3712 Returns the two's complement checksum of all elements in a buffer of
3715 This function first calculates the sum of the 64-bit values in the buffer
3716 specified by Buffer and Length. The carry bits in the result of addition
3717 are dropped. Then, the two's complement of the sum is returned. If Length
3718 is 0, then 0 is returned.
3720 If Buffer is NULL, then ASSERT().
3721 If Buffer is not aligned on a 64-bit boundary, then ASSERT().
3722 If Length is not aligned on a 64-bit boundary, then ASSERT().
3723 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
3725 @param Buffer The pointer to the buffer to carry out the checksum operation.
3726 @param Length The size, in bytes, of Buffer.
3728 @return Checksum The two's complement checksum of Buffer.
3733 CalculateCheckSum64 (
3734 IN CONST UINT64
*Buffer
,
3740 // Base Library CPU Functions
3744 Function entry point used when a stack switch is requested with SwitchStack()
3746 @param Context1 Context1 parameter passed into SwitchStack().
3747 @param Context2 Context2 parameter passed into SwitchStack().
3752 (EFIAPI
*SWITCH_STACK_ENTRY_POINT
)(
3753 IN VOID
*Context1
, OPTIONAL
3754 IN VOID
*Context2 OPTIONAL
3759 Used to serialize load and store operations.
3761 All loads and stores that proceed calls to this function are guaranteed to be
3762 globally visible when this function returns.
3773 Saves the current CPU context that can be restored with a call to LongJump()
3776 Saves the current CPU context in the buffer specified by JumpBuffer and
3777 returns 0. The initial call to SetJump() must always return 0. Subsequent
3778 calls to LongJump() cause a non-zero value to be returned by SetJump().
3780 If JumpBuffer is NULL, then ASSERT().
3781 For Itanium processors, if JumpBuffer is not aligned on a 16-byte boundary, then ASSERT().
3783 NOTE: The structure BASE_LIBRARY_JUMP_BUFFER is CPU architecture specific.
3784 The same structure must never be used for more than one CPU architecture context.
3785 For example, a BASE_LIBRARY_JUMP_BUFFER allocated by an IA-32 module must never be used from an x64 module.
3786 SetJump()/LongJump() is not currently supported for the EBC processor type.
3788 @param JumpBuffer A pointer to CPU context buffer.
3790 @retval 0 Indicates a return from SetJump().
3796 OUT BASE_LIBRARY_JUMP_BUFFER
*JumpBuffer
3801 Restores the CPU context that was saved with SetJump().
3803 Restores the CPU context from the buffer specified by JumpBuffer. This
3804 function never returns to the caller. Instead is resumes execution based on
3805 the state of JumpBuffer.
3807 If JumpBuffer is NULL, then ASSERT().
3808 For Itanium processors, if JumpBuffer is not aligned on a 16-byte boundary, then ASSERT().
3809 If Value is 0, then ASSERT().
3811 @param JumpBuffer A pointer to CPU context buffer.
3812 @param Value The value to return when the SetJump() context is
3813 restored and must be non-zero.
3819 IN BASE_LIBRARY_JUMP_BUFFER
*JumpBuffer
,
3825 Enables CPU interrupts.
3836 Disables CPU interrupts.
3847 Disables CPU interrupts and returns the interrupt state prior to the disable
3850 @retval TRUE CPU interrupts were enabled on entry to this call.
3851 @retval FALSE CPU interrupts were disabled on entry to this call.
3856 SaveAndDisableInterrupts (
3862 Enables CPU interrupts for the smallest window required to capture any
3868 EnableDisableInterrupts (
3874 Retrieves the current CPU interrupt state.
3876 Returns TRUE if interrupts are currently enabled. Otherwise
3879 @retval TRUE CPU interrupts are enabled.
3880 @retval FALSE CPU interrupts are disabled.
3891 Set the current CPU interrupt state.
3893 Sets the current CPU interrupt state to the state specified by
3894 InterruptState. If InterruptState is TRUE, then interrupts are enabled. If
3895 InterruptState is FALSE, then interrupts are disabled. InterruptState is
3898 @param InterruptState TRUE if interrupts should enabled. FALSE if
3899 interrupts should be disabled.
3901 @return InterruptState
3907 IN BOOLEAN InterruptState
3912 Requests CPU to pause for a short period of time.
3914 Requests CPU to pause for a short period of time. Typically used in MP
3915 systems to prevent memory starvation while waiting for a spin lock.
3926 Transfers control to a function starting with a new stack.
3928 Transfers control to the function specified by EntryPoint using the
3929 new stack specified by NewStack and passing in the parameters specified
3930 by Context1 and Context2. Context1 and Context2 are optional and may
3931 be NULL. The function EntryPoint must never return. This function
3932 supports a variable number of arguments following the NewStack parameter.
3933 These additional arguments are ignored on IA-32, x64, and EBC architectures.
3934 Itanium processors expect one additional parameter of type VOID * that specifies
3935 the new backing store pointer.
3937 If EntryPoint is NULL, then ASSERT().
3938 If NewStack is NULL, then ASSERT().
3940 @param EntryPoint A pointer to function to call with the new stack.
3941 @param Context1 A pointer to the context to pass into the EntryPoint
3943 @param Context2 A pointer to the context to pass into the EntryPoint
3945 @param NewStack A pointer to the new stack to use for the EntryPoint
3947 @param ... This variable argument list is ignored for IA-32, x64, and
3948 EBC architectures. For Itanium processors, this variable
3949 argument list is expected to contain a single parameter of
3950 type VOID * that specifies the new backing store pointer.
3957 IN SWITCH_STACK_ENTRY_POINT EntryPoint
,
3958 IN VOID
*Context1
, OPTIONAL
3959 IN VOID
*Context2
, OPTIONAL
3966 Generates a breakpoint on the CPU.
3968 Generates a breakpoint on the CPU. The breakpoint must be implemented such
3969 that code can resume normal execution after the breakpoint.
3980 Executes an infinite loop.
3982 Forces the CPU to execute an infinite loop. A debugger may be used to skip
3983 past the loop and the code that follows the loop must execute properly. This
3984 implies that the infinite loop must not cause the code that follow it to be
3994 #if defined (MDE_CPU_IPF)
3997 Flush a range of cache lines in the cache coherency domain of the calling
4000 Flushes the cache lines specified by Address and Length. If Address is not aligned
4001 on a cache line boundary, then entire cache line containing Address is flushed.
4002 If Address + Length is not aligned on a cache line boundary, then the entire cache
4003 line containing Address + Length - 1 is flushed. This function may choose to flush
4004 the entire cache if that is more efficient than flushing the specified range. If
4005 Length is 0, the no cache lines are flushed. Address is returned.
4006 This function is only available on Itanium processors.
4008 If Length is greater than (MAX_ADDRESS - Address + 1), then ASSERT().
4010 @param Address The base address of the instruction lines to invalidate. If
4011 the CPU is in a physical addressing mode, then Address is a
4012 physical address. If the CPU is in a virtual addressing mode,
4013 then Address is a virtual address.
4015 @param Length The number of bytes to invalidate from the instruction cache.
4022 AsmFlushCacheRange (
4029 Executes an FC instruction.
4030 Executes an FC instruction on the cache line specified by Address.
4031 The cache line size affected is at least 32-bytes (aligned on a 32-byte boundary).
4032 An implementation may flush a larger region. This function is only available on Itanium processors.
4034 @param Address The Address of cache line to be flushed.
4036 @return The address of FC instruction executed.
4047 Executes an FC.I instruction.
4048 Executes an FC.I instruction on the cache line specified by Address.
4049 The cache line size affected is at least 32-bytes (aligned on a 32-byte boundary).
4050 An implementation may flush a larger region. This function is only available on Itanium processors.
4052 @param Address The Address of cache line to be flushed.
4054 @return The address of the FC.I instruction executed.
4065 Reads the current value of a Processor Identifier Register (CPUID).
4067 Reads and returns the current value of Processor Identifier Register specified by Index.
4068 The Index of largest implemented CPUID (One less than the number of implemented CPUID
4069 registers) is determined by CPUID [3] bits {7:0}.
4070 No parameter checking is performed on Index. If the Index value is beyond the
4071 implemented CPUID register range, a Reserved Register/Field fault may occur. The caller
4072 must either guarantee that Index is valid, or the caller must set up fault handlers to
4073 catch the faults. This function is only available on Itanium processors.
4075 @param Index The 8-bit Processor Identifier Register index to read.
4077 @return The current value of Processor Identifier Register specified by Index.
4088 Reads the current value of 64-bit Processor Status Register (PSR).
4089 This function is only available on Itanium processors.
4091 @return The current value of PSR.
4102 Writes the current value of 64-bit Processor Status Register (PSR).
4104 No parameter checking is performed on Value. All bits of Value corresponding to
4105 reserved fields of PSR must be 0 or a Reserved Register/Field fault may occur.
4106 The caller must either guarantee that Value is valid, or the caller must set up
4107 fault handlers to catch the faults. This function is only available on Itanium processors.
4109 @param Value The 64-bit value to write to PSR.
4111 @return The 64-bit value written to the PSR.
4122 Reads the current value of 64-bit Kernel Register #0 (KR0).
4124 Reads and returns the current value of KR0.
4125 This function is only available on Itanium processors.
4127 @return The current value of KR0.
4138 Reads the current value of 64-bit Kernel Register #1 (KR1).
4140 Reads and returns the current value of KR1.
4141 This function is only available on Itanium processors.
4143 @return The current value of KR1.
4154 Reads the current value of 64-bit Kernel Register #2 (KR2).
4156 Reads and returns the current value of KR2.
4157 This function is only available on Itanium processors.
4159 @return The current value of KR2.
4170 Reads the current value of 64-bit Kernel Register #3 (KR3).
4172 Reads and returns the current value of KR3.
4173 This function is only available on Itanium processors.
4175 @return The current value of KR3.
4186 Reads the current value of 64-bit Kernel Register #4 (KR4).
4188 Reads and returns the current value of KR4.
4189 This function is only available on Itanium processors.
4191 @return The current value of KR4.
4202 Reads the current value of 64-bit Kernel Register #5 (KR5).
4204 Reads and returns the current value of KR5.
4205 This function is only available on Itanium processors.
4207 @return The current value of KR5.
4218 Reads the current value of 64-bit Kernel Register #6 (KR6).
4220 Reads and returns the current value of KR6.
4221 This function is only available on Itanium processors.
4223 @return The current value of KR6.
4234 Reads the current value of 64-bit Kernel Register #7 (KR7).
4236 Reads and returns the current value of KR7.
4237 This function is only available on Itanium processors.
4239 @return The current value of KR7.
4250 Write the current value of 64-bit Kernel Register #0 (KR0).
4252 Writes the current value of KR0. The 64-bit value written to
4253 the KR0 is returned. This function is only available on Itanium processors.
4255 @param Value The 64-bit value to write to KR0.
4257 @return The 64-bit value written to the KR0.
4268 Write the current value of 64-bit Kernel Register #1 (KR1).
4270 Writes the current value of KR1. The 64-bit value written to
4271 the KR1 is returned. This function is only available on Itanium processors.
4273 @param Value The 64-bit value to write to KR1.
4275 @return The 64-bit value written to the KR1.
4286 Write the current value of 64-bit Kernel Register #2 (KR2).
4288 Writes the current value of KR2. The 64-bit value written to
4289 the KR2 is returned. This function is only available on Itanium processors.
4291 @param Value The 64-bit value to write to KR2.
4293 @return The 64-bit value written to the KR2.
4304 Write the current value of 64-bit Kernel Register #3 (KR3).
4306 Writes the current value of KR3. The 64-bit value written to
4307 the KR3 is returned. This function is only available on Itanium processors.
4309 @param Value The 64-bit value to write to KR3.
4311 @return The 64-bit value written to the KR3.
4322 Write the current value of 64-bit Kernel Register #4 (KR4).
4324 Writes the current value of KR4. The 64-bit value written to
4325 the KR4 is returned. This function is only available on Itanium processors.
4327 @param Value The 64-bit value to write to KR4.
4329 @return The 64-bit value written to the KR4.
4340 Write the current value of 64-bit Kernel Register #5 (KR5).
4342 Writes the current value of KR5. The 64-bit value written to
4343 the KR5 is returned. This function is only available on Itanium processors.
4345 @param Value The 64-bit value to write to KR5.
4347 @return The 64-bit value written to the KR5.
4358 Write the current value of 64-bit Kernel Register #6 (KR6).
4360 Writes the current value of KR6. The 64-bit value written to
4361 the KR6 is returned. This function is only available on Itanium processors.
4363 @param Value The 64-bit value to write to KR6.
4365 @return The 64-bit value written to the KR6.
4376 Write the current value of 64-bit Kernel Register #7 (KR7).
4378 Writes the current value of KR7. The 64-bit value written to
4379 the KR7 is returned. This function is only available on Itanium processors.
4381 @param Value The 64-bit value to write to KR7.
4383 @return The 64-bit value written to the KR7.
4394 Reads the current value of Interval Timer Counter Register (ITC).
4396 Reads and returns the current value of ITC.
4397 This function is only available on Itanium processors.
4399 @return The current value of ITC.
4410 Reads the current value of Interval Timer Vector Register (ITV).
4412 Reads and returns the current value of ITV.
4413 This function is only available on Itanium processors.
4415 @return The current value of ITV.
4426 Reads the current value of Interval Timer Match Register (ITM).
4428 Reads and returns the current value of ITM.
4429 This function is only available on Itanium processors.
4431 @return The current value of ITM.
4441 Writes the current value of 64-bit Interval Timer Counter Register (ITC).
4443 Writes the current value of ITC. The 64-bit value written to the ITC is returned.
4444 This function is only available on Itanium processors.
4446 @param Value The 64-bit value to write to ITC.
4448 @return The 64-bit value written to the ITC.
4459 Writes the current value of 64-bit Interval Timer Match Register (ITM).
4461 Writes the current value of ITM. The 64-bit value written to the ITM is returned.
4462 This function is only available on Itanium processors.
4464 @param Value The 64-bit value to write to ITM.
4466 @return The 64-bit value written to the ITM.
4477 Writes the current value of 64-bit Interval Timer Vector Register (ITV).
4479 Writes the current value of ITV. The 64-bit value written to the ITV is returned.
4480 No parameter checking is performed on Value. All bits of Value corresponding to
4481 reserved fields of ITV must be 0 or a Reserved Register/Field fault may occur.
4482 The caller must either guarantee that Value is valid, or the caller must set up
4483 fault handlers to catch the faults.
4484 This function is only available on Itanium processors.
4486 @param Value The 64-bit value to write to ITV.
4488 @return The 64-bit value written to the ITV.
4499 Reads the current value of Default Control Register (DCR).
4501 Reads and returns the current value of DCR. This function is only available on Itanium processors.
4503 @return The current value of DCR.
4514 Reads the current value of Interruption Vector Address Register (IVA).
4516 Reads and returns the current value of IVA. This function is only available on Itanium processors.
4518 @return The current value of IVA.
4528 Reads the current value of Page Table Address Register (PTA).
4530 Reads and returns the current value of PTA. This function is only available on Itanium processors.
4532 @return The current value of PTA.
4543 Writes the current value of 64-bit Default Control Register (DCR).
4545 Writes the current value of DCR. The 64-bit value written to the DCR is returned.
4546 No parameter checking is performed on Value. All bits of Value corresponding to
4547 reserved fields of DCR must be 0 or a Reserved Register/Field fault may occur.
4548 The caller must either guarantee that Value is valid, or the caller must set up
4549 fault handlers to catch the faults.
4550 This function is only available on Itanium processors.
4552 @param Value The 64-bit value to write to DCR.
4554 @return The 64-bit value written to the DCR.
4565 Writes the current value of 64-bit Interruption Vector Address Register (IVA).
4567 Writes the current value of IVA. The 64-bit value written to the IVA is returned.
4568 The size of vector table is 32 K bytes and is 32 K bytes aligned
4569 the low 15 bits of Value is ignored when written.
4570 This function is only available on Itanium processors.
4572 @param Value The 64-bit value to write to IVA.
4574 @return The 64-bit value written to the IVA.
4585 Writes the current value of 64-bit Page Table Address Register (PTA).
4587 Writes the current value of PTA. The 64-bit value written to the PTA is returned.
4588 No parameter checking is performed on Value. All bits of Value corresponding to
4589 reserved fields of DCR must be 0 or a Reserved Register/Field fault may occur.
4590 The caller must either guarantee that Value is valid, or the caller must set up
4591 fault handlers to catch the faults.
4592 This function is only available on Itanium processors.
4594 @param Value The 64-bit value to write to PTA.
4596 @return The 64-bit value written to the PTA.
4606 Reads the current value of Local Interrupt ID Register (LID).
4608 Reads and returns the current value of LID. This function is only available on Itanium processors.
4610 @return The current value of LID.
4621 Reads the current value of External Interrupt Vector Register (IVR).
4623 Reads and returns the current value of IVR. This function is only available on Itanium processors.
4625 @return The current value of IVR.
4636 Reads the current value of Task Priority Register (TPR).
4638 Reads and returns the current value of TPR. This function is only available on Itanium processors.
4640 @return The current value of TPR.
4651 Reads the current value of External Interrupt Request Register #0 (IRR0).
4653 Reads and returns the current value of IRR0. This function is only available on Itanium processors.
4655 @return The current value of IRR0.
4666 Reads the current value of External Interrupt Request Register #1 (IRR1).
4668 Reads and returns the current value of IRR1. This function is only available on Itanium processors.
4670 @return The current value of IRR1.
4681 Reads the current value of External Interrupt Request Register #2 (IRR2).
4683 Reads and returns the current value of IRR2. This function is only available on Itanium processors.
4685 @return The current value of IRR2.
4696 Reads the current value of External Interrupt Request Register #3 (IRR3).
4698 Reads and returns the current value of IRR3. This function is only available on Itanium processors.
4700 @return The current value of IRR3.
4711 Reads the current value of Performance Monitor Vector Register (PMV).
4713 Reads and returns the current value of PMV. This function is only available on Itanium processors.
4715 @return The current value of PMV.
4726 Reads the current value of Corrected Machine Check Vector Register (CMCV).
4728 Reads and returns the current value of CMCV. This function is only available on Itanium processors.
4730 @return The current value of CMCV.
4741 Reads the current value of Local Redirection Register #0 (LRR0).
4743 Reads and returns the current value of LRR0. This function is only available on Itanium processors.
4745 @return The current value of LRR0.
4756 Reads the current value of Local Redirection Register #1 (LRR1).
4758 Reads and returns the current value of LRR1. This function is only available on Itanium processors.
4760 @return The current value of LRR1.
4771 Writes the current value of 64-bit Page Local Interrupt ID Register (LID).
4773 Writes the current value of LID. The 64-bit value written to the LID is returned.
4774 No parameter checking is performed on Value. All bits of Value corresponding to
4775 reserved fields of LID must be 0 or a Reserved Register/Field fault may occur.
4776 The caller must either guarantee that Value is valid, or the caller must set up
4777 fault handlers to catch the faults.
4778 This function is only available on Itanium processors.
4780 @param Value The 64-bit value to write to LID.
4782 @return The 64-bit value written to the LID.
4793 Writes the current value of 64-bit Task Priority Register (TPR).
4795 Writes the current value of TPR. The 64-bit value written to the TPR is returned.
4796 No parameter checking is performed on Value. All bits of Value corresponding to
4797 reserved fields of TPR must be 0 or a Reserved Register/Field fault may occur.
4798 The caller must either guarantee that Value is valid, or the caller must set up
4799 fault handlers to catch the faults.
4800 This function is only available on Itanium processors.
4802 @param Value The 64-bit value to write to TPR.
4804 @return The 64-bit value written to the TPR.
4815 Performs a write operation on End OF External Interrupt Register (EOI).
4817 Writes a value of 0 to the EOI Register. This function is only available on Itanium processors.
4828 Writes the current value of 64-bit Performance Monitor Vector Register (PMV).
4830 Writes the current value of PMV. The 64-bit value written to the PMV is returned.
4831 No parameter checking is performed on Value. All bits of Value corresponding
4832 to reserved fields of PMV must be 0 or a Reserved Register/Field fault may occur.
4833 The caller must either guarantee that Value is valid, or the caller must set up
4834 fault handlers to catch the faults.
4835 This function is only available on Itanium processors.
4837 @param Value The 64-bit value to write to PMV.
4839 @return The 64-bit value written to the PMV.
4850 Writes the current value of 64-bit Corrected Machine Check Vector Register (CMCV).
4852 Writes the current value of CMCV. The 64-bit value written to the CMCV is returned.
4853 No parameter checking is performed on Value. All bits of Value corresponding
4854 to reserved fields of CMCV must be 0 or a Reserved Register/Field fault may occur.
4855 The caller must either guarantee that Value is valid, or the caller must set up
4856 fault handlers to catch the faults.
4857 This function is only available on Itanium processors.
4859 @param Value The 64-bit value to write to CMCV.
4861 @return The 64-bit value written to the CMCV.
4872 Writes the current value of 64-bit Local Redirection Register #0 (LRR0).
4874 Writes the current value of LRR0. The 64-bit value written to the LRR0 is returned.
4875 No parameter checking is performed on Value. All bits of Value corresponding
4876 to reserved fields of LRR0 must be 0 or a Reserved Register/Field fault may occur.
4877 The caller must either guarantee that Value is valid, or the caller must set up
4878 fault handlers to catch the faults.
4879 This function is only available on Itanium processors.
4881 @param Value The 64-bit value to write to LRR0.
4883 @return The 64-bit value written to the LRR0.
4894 Writes the current value of 64-bit Local Redirection Register #1 (LRR1).
4896 Writes the current value of LRR1. The 64-bit value written to the LRR1 is returned.
4897 No parameter checking is performed on Value. All bits of Value corresponding
4898 to reserved fields of LRR1 must be 0 or a Reserved Register/Field fault may occur.
4899 The caller must either guarantee that Value is valid, or the caller must
4900 set up fault handlers to catch the faults.
4901 This function is only available on Itanium processors.
4903 @param Value The 64-bit value to write to LRR1.
4905 @return The 64-bit value written to the LRR1.
4916 Reads the current value of Instruction Breakpoint Register (IBR).
4918 The Instruction Breakpoint Registers are used in pairs. The even numbered
4919 registers contain breakpoint addresses, and the odd numbered registers contain
4920 breakpoint mask conditions. At least four instruction registers pairs are implemented
4921 on all processor models. Implemented registers are contiguous starting with
4922 register 0. No parameter checking is performed on Index, and if the Index value
4923 is beyond the implemented IBR register range, a Reserved Register/Field fault may
4924 occur. The caller must either guarantee that Index is valid, or the caller must
4925 set up fault handlers to catch the faults.
4926 This function is only available on Itanium processors.
4928 @param Index The 8-bit Instruction Breakpoint Register index to read.
4930 @return The current value of Instruction Breakpoint Register specified by Index.
4941 Reads the current value of Data Breakpoint Register (DBR).
4943 The Data Breakpoint Registers are used in pairs. The even numbered registers
4944 contain breakpoint addresses, and odd numbered registers contain breakpoint
4945 mask conditions. At least four data registers pairs are implemented on all processor
4946 models. Implemented registers are contiguous starting with register 0.
4947 No parameter checking is performed on Index. If the Index value is beyond
4948 the implemented DBR register range, a Reserved Register/Field fault may occur.
4949 The caller must either guarantee that Index is valid, or the caller must set up
4950 fault handlers to catch the faults.
4951 This function is only available on Itanium processors.
4953 @param Index The 8-bit Data Breakpoint Register index to read.
4955 @return The current value of Data Breakpoint Register specified by Index.
4966 Reads the current value of Performance Monitor Configuration Register (PMC).
4968 All processor implementations provide at least four performance counters
4969 (PMC/PMD [4]...PMC/PMD [7] pairs), and four performance monitor counter overflow
4970 status registers (PMC [0]... PMC [3]). Processor implementations may provide
4971 additional implementation-dependent PMC and PMD to increase the number of
4972 'generic' performance counters (PMC/PMD pairs). The remainder of PMC and PMD
4973 register set is implementation dependent. No parameter checking is performed
4974 on Index. If the Index value is beyond the implemented PMC register range,
4975 zero value will be returned.
4976 This function is only available on Itanium processors.
4978 @param Index The 8-bit Performance Monitor Configuration Register index to read.
4980 @return The current value of Performance Monitor Configuration Register
4992 Reads the current value of Performance Monitor Data Register (PMD).
4994 All processor implementations provide at least 4 performance counters
4995 (PMC/PMD [4]...PMC/PMD [7] pairs), and 4 performance monitor counter
4996 overflow status registers (PMC [0]... PMC [3]). Processor implementations may
4997 provide additional implementation-dependent PMC and PMD to increase the number
4998 of 'generic' performance counters (PMC/PMD pairs). The remainder of PMC and PMD
4999 register set is implementation dependent. No parameter checking is performed
5000 on Index. If the Index value is beyond the implemented PMD register range,
5001 zero value will be returned.
5002 This function is only available on Itanium processors.
5004 @param Index The 8-bit Performance Monitor Data Register index to read.
5006 @return The current value of Performance Monitor Data Register specified by Index.
5017 Writes the current value of 64-bit Instruction Breakpoint Register (IBR).
5019 Writes current value of Instruction Breakpoint Register specified by Index.
5020 The Instruction Breakpoint Registers are used in pairs. The even numbered
5021 registers contain breakpoint addresses, and odd numbered registers contain
5022 breakpoint mask conditions. At least four instruction registers pairs are implemented
5023 on all processor models. Implemented registers are contiguous starting with
5024 register 0. No parameter checking is performed on Index. If the Index value
5025 is beyond the implemented IBR register range, a Reserved Register/Field fault may
5026 occur. The caller must either guarantee that Index is valid, or the caller must
5027 set up fault handlers to catch the faults.
5028 This function is only available on Itanium processors.
5030 @param Index The 8-bit Instruction Breakpoint Register index to write.
5031 @param Value The 64-bit value to write to IBR.
5033 @return The 64-bit value written to the IBR.
5045 Writes the current value of 64-bit Data Breakpoint Register (DBR).
5047 Writes current value of Data Breakpoint Register specified by Index.
5048 The Data Breakpoint Registers are used in pairs. The even numbered registers
5049 contain breakpoint addresses, and odd numbered registers contain breakpoint
5050 mask conditions. At least four data registers pairs are implemented on all processor
5051 models. Implemented registers are contiguous starting with register 0. No parameter
5052 checking is performed on Index. If the Index value is beyond the implemented
5053 DBR register range, a Reserved Register/Field fault may occur. The caller must
5054 either guarantee that Index is valid, or the caller must set up fault handlers to
5056 This function is only available on Itanium processors.
5058 @param Index The 8-bit Data Breakpoint Register index to write.
5059 @param Value The 64-bit value to write to DBR.
5061 @return The 64-bit value written to the DBR.
5073 Writes the current value of 64-bit Performance Monitor Configuration Register (PMC).
5075 Writes current value of Performance Monitor Configuration Register specified by Index.
5076 All processor implementations provide at least four performance counters
5077 (PMC/PMD [4]...PMC/PMD [7] pairs), and four performance monitor counter overflow status
5078 registers (PMC [0]... PMC [3]). Processor implementations may provide additional
5079 implementation-dependent PMC and PMD to increase the number of 'generic' performance
5080 counters (PMC/PMD pairs). The remainder of PMC and PMD register set is implementation
5081 dependent. No parameter checking is performed on Index. If the Index value is
5082 beyond the implemented PMC register range, the write is ignored.
5083 This function is only available on Itanium processors.
5085 @param Index The 8-bit Performance Monitor Configuration Register index to write.
5086 @param Value The 64-bit value to write to PMC.
5088 @return The 64-bit value written to the PMC.
5100 Writes the current value of 64-bit Performance Monitor Data Register (PMD).
5102 Writes current value of Performance Monitor Data Register specified by Index.
5103 All processor implementations provide at least four performance counters
5104 (PMC/PMD [4]...PMC/PMD [7] pairs), and four performance monitor counter overflow
5105 status registers (PMC [0]... PMC [3]). Processor implementations may provide
5106 additional implementation-dependent PMC and PMD to increase the number of 'generic'
5107 performance counters (PMC/PMD pairs). The remainder of PMC and PMD register set
5108 is implementation dependent. No parameter checking is performed on Index. If the
5109 Index value is beyond the implemented PMD register range, the write is ignored.
5110 This function is only available on Itanium processors.
5112 @param Index The 8-bit Performance Monitor Data Register index to write.
5113 @param Value The 64-bit value to write to PMD.
5115 @return The 64-bit value written to the PMD.
5127 Reads the current value of 64-bit Global Pointer (GP).
5129 Reads and returns the current value of GP.
5130 This function is only available on Itanium processors.
5132 @return The current value of GP.
5143 Write the current value of 64-bit Global Pointer (GP).
5145 Writes the current value of GP. The 64-bit value written to the GP is returned.
5146 No parameter checking is performed on Value.
5147 This function is only available on Itanium processors.
5149 @param Value The 64-bit value to write to GP.
5151 @return The 64-bit value written to the GP.
5162 Reads the current value of 64-bit Stack Pointer (SP).
5164 Reads and returns the current value of SP.
5165 This function is only available on Itanium processors.
5167 @return The current value of SP.
5178 /// Valid Index value for AsmReadControlRegister().
5180 #define IPF_CONTROL_REGISTER_DCR 0
5181 #define IPF_CONTROL_REGISTER_ITM 1
5182 #define IPF_CONTROL_REGISTER_IVA 2
5183 #define IPF_CONTROL_REGISTER_PTA 8
5184 #define IPF_CONTROL_REGISTER_IPSR 16
5185 #define IPF_CONTROL_REGISTER_ISR 17
5186 #define IPF_CONTROL_REGISTER_IIP 19
5187 #define IPF_CONTROL_REGISTER_IFA 20
5188 #define IPF_CONTROL_REGISTER_ITIR 21
5189 #define IPF_CONTROL_REGISTER_IIPA 22
5190 #define IPF_CONTROL_REGISTER_IFS 23
5191 #define IPF_CONTROL_REGISTER_IIM 24
5192 #define IPF_CONTROL_REGISTER_IHA 25
5193 #define IPF_CONTROL_REGISTER_LID 64
5194 #define IPF_CONTROL_REGISTER_IVR 65
5195 #define IPF_CONTROL_REGISTER_TPR 66
5196 #define IPF_CONTROL_REGISTER_EOI 67
5197 #define IPF_CONTROL_REGISTER_IRR0 68
5198 #define IPF_CONTROL_REGISTER_IRR1 69
5199 #define IPF_CONTROL_REGISTER_IRR2 70
5200 #define IPF_CONTROL_REGISTER_IRR3 71
5201 #define IPF_CONTROL_REGISTER_ITV 72
5202 #define IPF_CONTROL_REGISTER_PMV 73
5203 #define IPF_CONTROL_REGISTER_CMCV 74
5204 #define IPF_CONTROL_REGISTER_LRR0 80
5205 #define IPF_CONTROL_REGISTER_LRR1 81
5208 Reads a 64-bit control register.
5210 Reads and returns the control register specified by Index. The valid Index valued
5211 are defined above in "Related Definitions".
5212 If Index is invalid then 0xFFFFFFFFFFFFFFFF is returned. This function is only
5213 available on Itanium processors.
5215 @param Index The index of the control register to read.
5217 @return The control register specified by Index.
5222 AsmReadControlRegister (
5228 /// Valid Index value for AsmReadApplicationRegister().
5230 #define IPF_APPLICATION_REGISTER_K0 0
5231 #define IPF_APPLICATION_REGISTER_K1 1
5232 #define IPF_APPLICATION_REGISTER_K2 2
5233 #define IPF_APPLICATION_REGISTER_K3 3
5234 #define IPF_APPLICATION_REGISTER_K4 4
5235 #define IPF_APPLICATION_REGISTER_K5 5
5236 #define IPF_APPLICATION_REGISTER_K6 6
5237 #define IPF_APPLICATION_REGISTER_K7 7
5238 #define IPF_APPLICATION_REGISTER_RSC 16
5239 #define IPF_APPLICATION_REGISTER_BSP 17
5240 #define IPF_APPLICATION_REGISTER_BSPSTORE 18
5241 #define IPF_APPLICATION_REGISTER_RNAT 19
5242 #define IPF_APPLICATION_REGISTER_FCR 21
5243 #define IPF_APPLICATION_REGISTER_EFLAG 24
5244 #define IPF_APPLICATION_REGISTER_CSD 25
5245 #define IPF_APPLICATION_REGISTER_SSD 26
5246 #define IPF_APPLICATION_REGISTER_CFLG 27
5247 #define IPF_APPLICATION_REGISTER_FSR 28
5248 #define IPF_APPLICATION_REGISTER_FIR 29
5249 #define IPF_APPLICATION_REGISTER_FDR 30
5250 #define IPF_APPLICATION_REGISTER_CCV 32
5251 #define IPF_APPLICATION_REGISTER_UNAT 36
5252 #define IPF_APPLICATION_REGISTER_FPSR 40
5253 #define IPF_APPLICATION_REGISTER_ITC 44
5254 #define IPF_APPLICATION_REGISTER_PFS 64
5255 #define IPF_APPLICATION_REGISTER_LC 65
5256 #define IPF_APPLICATION_REGISTER_EC 66
5259 Reads a 64-bit application register.
5261 Reads and returns the application register specified by Index. The valid Index
5262 valued are defined above in "Related Definitions".
5263 If Index is invalid then 0xFFFFFFFFFFFFFFFF is returned. This function is only
5264 available on Itanium processors.
5266 @param Index The index of the application register to read.
5268 @return The application register specified by Index.
5273 AsmReadApplicationRegister (
5279 Reads the current value of a Machine Specific Register (MSR).
5281 Reads and returns the current value of the Machine Specific Register specified by Index. No
5282 parameter checking is performed on Index, and if the Index value is beyond the implemented MSR
5283 register range, a Reserved Register/Field fault may occur. The caller must either guarantee that
5284 Index is valid, or the caller must set up fault handlers to catch the faults. This function is
5285 only available on Itanium processors.
5287 @param Index The 8-bit Machine Specific Register index to read.
5289 @return The current value of the Machine Specific Register specified by Index.
5300 Writes the current value of a Machine Specific Register (MSR).
5302 Writes Value to the Machine Specific Register specified by Index. Value is returned. No
5303 parameter checking is performed on Index, and if the Index value is beyond the implemented MSR
5304 register range, a Reserved Register/Field fault may occur. The caller must either guarantee that
5305 Index is valid, or the caller must set up fault handlers to catch the faults. This function is
5306 only available on Itanium processors.
5308 @param Index The 8-bit Machine Specific Register index to write.
5309 @param Value The 64-bit value to write to the Machine Specific Register.
5311 @return The 64-bit value to write to the Machine Specific Register.
5323 Determines if the CPU is currently executing in virtual, physical, or mixed mode.
5325 Determines the current execution mode of the CPU.
5326 If the CPU is in virtual mode(PSR.RT=1, PSR.DT=1, PSR.IT=1), then 1 is returned.
5327 If the CPU is in physical mode(PSR.RT=0, PSR.DT=0, PSR.IT=0), then 0 is returned.
5328 If the CPU is not in physical mode or virtual mode, then it is in mixed mode,
5330 This function is only available on Itanium processors.
5332 @retval 1 The CPU is in virtual mode.
5333 @retval 0 The CPU is in physical mode.
5334 @retval -1 The CPU is in mixed mode.
5345 Makes a PAL procedure call.
5347 This is a wrapper function to make a PAL procedure call. Based on the Index
5348 value this API will make static or stacked PAL call. The following table
5349 describes the usage of PAL Procedure Index Assignment. Architected procedures
5350 may be designated as required or optional. If a PAL procedure is specified
5351 as optional, a unique return code of 0xFFFFFFFFFFFFFFFF is returned in the
5352 Status field of the PAL_CALL_RETURN structure.
5353 This indicates that the procedure is not present in this PAL implementation.
5354 It is the caller's responsibility to check for this return code after calling
5355 any optional PAL procedure.
5356 No parameter checking is performed on the 5 input parameters, but there are
5357 some common rules that the caller should follow when making a PAL call. Any
5358 address passed to PAL as buffers for return parameters must be 8-byte aligned.
5359 Unaligned addresses may cause undefined results. For those parameters defined
5360 as reserved or some fields defined as reserved must be zero filled or the invalid
5361 argument return value may be returned or undefined result may occur during the
5362 execution of the procedure. If the PalEntryPoint does not point to a valid
5363 PAL entry point then the system behavior is undefined. This function is only
5364 available on Itanium processors.
5366 @param PalEntryPoint The PAL procedure calls entry point.
5367 @param Index The PAL procedure Index number.
5368 @param Arg2 The 2nd parameter for PAL procedure calls.
5369 @param Arg3 The 3rd parameter for PAL procedure calls.
5370 @param Arg4 The 4th parameter for PAL procedure calls.
5372 @return structure returned from the PAL Call procedure, including the status and return value.
5378 IN UINT64 PalEntryPoint
,
5386 #if defined (MDE_CPU_IA32) || defined (MDE_CPU_X64)
5388 /// IA32 and x64 Specific Functions.
5389 /// Byte packed structure for 16-bit Real Mode EFLAGS.
5393 UINT32 CF
:1; ///< Carry Flag.
5394 UINT32 Reserved_0
:1; ///< Reserved.
5395 UINT32 PF
:1; ///< Parity Flag.
5396 UINT32 Reserved_1
:1; ///< Reserved.
5397 UINT32 AF
:1; ///< Auxiliary Carry Flag.
5398 UINT32 Reserved_2
:1; ///< Reserved.
5399 UINT32 ZF
:1; ///< Zero Flag.
5400 UINT32 SF
:1; ///< Sign Flag.
5401 UINT32 TF
:1; ///< Trap Flag.
5402 UINT32 IF
:1; ///< Interrupt Enable Flag.
5403 UINT32 DF
:1; ///< Direction Flag.
5404 UINT32 OF
:1; ///< Overflow Flag.
5405 UINT32 IOPL
:2; ///< I/O Privilege Level.
5406 UINT32 NT
:1; ///< Nested Task.
5407 UINT32 Reserved_3
:1; ///< Reserved.
5413 /// Byte packed structure for EFLAGS/RFLAGS.
5414 /// 32-bits on IA-32.
5415 /// 64-bits on x64. The upper 32-bits on x64 are reserved.
5419 UINT32 CF
:1; ///< Carry Flag.
5420 UINT32 Reserved_0
:1; ///< Reserved.
5421 UINT32 PF
:1; ///< Parity Flag.
5422 UINT32 Reserved_1
:1; ///< Reserved.
5423 UINT32 AF
:1; ///< Auxiliary Carry Flag.
5424 UINT32 Reserved_2
:1; ///< Reserved.
5425 UINT32 ZF
:1; ///< Zero Flag.
5426 UINT32 SF
:1; ///< Sign Flag.
5427 UINT32 TF
:1; ///< Trap Flag.
5428 UINT32 IF
:1; ///< Interrupt Enable Flag.
5429 UINT32 DF
:1; ///< Direction Flag.
5430 UINT32 OF
:1; ///< Overflow Flag.
5431 UINT32 IOPL
:2; ///< I/O Privilege Level.
5432 UINT32 NT
:1; ///< Nested Task.
5433 UINT32 Reserved_3
:1; ///< Reserved.
5434 UINT32 RF
:1; ///< Resume Flag.
5435 UINT32 VM
:1; ///< Virtual 8086 Mode.
5436 UINT32 AC
:1; ///< Alignment Check.
5437 UINT32 VIF
:1; ///< Virtual Interrupt Flag.
5438 UINT32 VIP
:1; ///< Virtual Interrupt Pending.
5439 UINT32 ID
:1; ///< ID Flag.
5440 UINT32 Reserved_4
:10; ///< Reserved.
5446 /// Byte packed structure for Control Register 0 (CR0).
5447 /// 32-bits on IA-32.
5448 /// 64-bits on x64. The upper 32-bits on x64 are reserved.
5452 UINT32 PE
:1; ///< Protection Enable.
5453 UINT32 MP
:1; ///< Monitor Coprocessor.
5454 UINT32 EM
:1; ///< Emulation.
5455 UINT32 TS
:1; ///< Task Switched.
5456 UINT32 ET
:1; ///< Extension Type.
5457 UINT32 NE
:1; ///< Numeric Error.
5458 UINT32 Reserved_0
:10; ///< Reserved.
5459 UINT32 WP
:1; ///< Write Protect.
5460 UINT32 Reserved_1
:1; ///< Reserved.
5461 UINT32 AM
:1; ///< Alignment Mask.
5462 UINT32 Reserved_2
:10; ///< Reserved.
5463 UINT32 NW
:1; ///< Mot Write-through.
5464 UINT32 CD
:1; ///< Cache Disable.
5465 UINT32 PG
:1; ///< Paging.
5471 /// Byte packed structure for Control Register 4 (CR4).
5472 /// 32-bits on IA-32.
5473 /// 64-bits on x64. The upper 32-bits on x64 are reserved.
5477 UINT32 VME
:1; ///< Virtual-8086 Mode Extensions.
5478 UINT32 PVI
:1; ///< Protected-Mode Virtual Interrupts.
5479 UINT32 TSD
:1; ///< Time Stamp Disable.
5480 UINT32 DE
:1; ///< Debugging Extensions.
5481 UINT32 PSE
:1; ///< Page Size Extensions.
5482 UINT32 PAE
:1; ///< Physical Address Extension.
5483 UINT32 MCE
:1; ///< Machine Check Enable.
5484 UINT32 PGE
:1; ///< Page Global Enable.
5485 UINT32 PCE
:1; ///< Performance Monitoring Counter
5487 UINT32 OSFXSR
:1; ///< Operating System Support for
5488 ///< FXSAVE and FXRSTOR instructions
5489 UINT32 OSXMMEXCPT
:1; ///< Operating System Support for
5490 ///< Unmasked SIMD Floating Point
5492 UINT32 Reserved_0
:2; ///< Reserved.
5493 UINT32 VMXE
:1; ///< VMX Enable
5494 UINT32 Reserved_1
:18; ///< Reserved.
5500 /// Byte packed structure for a segment descriptor in a GDT/LDT.
5519 } IA32_SEGMENT_DESCRIPTOR
;
5522 /// Byte packed structure for an IDTR, GDTR, LDTR descriptor.
5531 #define IA32_IDT_GATE_TYPE_TASK 0x85
5532 #define IA32_IDT_GATE_TYPE_INTERRUPT_16 0x86
5533 #define IA32_IDT_GATE_TYPE_TRAP_16 0x87
5534 #define IA32_IDT_GATE_TYPE_INTERRUPT_32 0x8E
5535 #define IA32_IDT_GATE_TYPE_TRAP_32 0x8F
5538 #if defined (MDE_CPU_IA32)
5540 /// Byte packed structure for an IA-32 Interrupt Gate Descriptor.
5544 UINT32 OffsetLow
:16; ///< Offset bits 15..0.
5545 UINT32 Selector
:16; ///< Selector.
5546 UINT32 Reserved_0
:8; ///< Reserved.
5547 UINT32 GateType
:8; ///< Gate Type. See #defines above.
5548 UINT32 OffsetHigh
:16; ///< Offset bits 31..16.
5551 } IA32_IDT_GATE_DESCRIPTOR
;
5555 #if defined (MDE_CPU_X64)
5557 /// Byte packed structure for an x64 Interrupt Gate Descriptor.
5561 UINT32 OffsetLow
:16; ///< Offset bits 15..0.
5562 UINT32 Selector
:16; ///< Selector.
5563 UINT32 Reserved_0
:8; ///< Reserved.
5564 UINT32 GateType
:8; ///< Gate Type. See #defines above.
5565 UINT32 OffsetHigh
:16; ///< Offset bits 31..16.
5566 UINT32 OffsetUpper
:32; ///< Offset bits 63..32.
5567 UINT32 Reserved_1
:32; ///< Reserved.
5573 } IA32_IDT_GATE_DESCRIPTOR
;
5578 /// Byte packed structure for an FP/SSE/SSE2 context.
5585 /// Structures for the 16-bit real mode thunks.
5638 IA32_EFLAGS32 EFLAGS
;
5648 } IA32_REGISTER_SET
;
5651 /// Byte packed structure for an 16-bit real mode thunks.
5654 IA32_REGISTER_SET
*RealModeState
;
5655 VOID
*RealModeBuffer
;
5656 UINT32 RealModeBufferSize
;
5657 UINT32 ThunkAttributes
;
5660 #define THUNK_ATTRIBUTE_BIG_REAL_MODE 0x00000001
5661 #define THUNK_ATTRIBUTE_DISABLE_A20_MASK_INT_15 0x00000002
5662 #define THUNK_ATTRIBUTE_DISABLE_A20_MASK_KBD_CTRL 0x00000004
5665 Retrieves CPUID information.
5667 Executes the CPUID instruction with EAX set to the value specified by Index.
5668 This function always returns Index.
5669 If Eax is not NULL, then the value of EAX after CPUID is returned in Eax.
5670 If Ebx is not NULL, then the value of EBX after CPUID is returned in Ebx.
5671 If Ecx is not NULL, then the value of ECX after CPUID is returned in Ecx.
5672 If Edx is not NULL, then the value of EDX after CPUID is returned in Edx.
5673 This function is only available on IA-32 and x64.
5675 @param Index The 32-bit value to load into EAX prior to invoking the CPUID
5677 @param Eax The pointer to the 32-bit EAX value returned by the CPUID
5678 instruction. This is an optional parameter that may be NULL.
5679 @param Ebx The pointer to the 32-bit EBX value returned by the CPUID
5680 instruction. This is an optional parameter that may be NULL.
5681 @param Ecx The pointer to the 32-bit ECX value returned by the CPUID
5682 instruction. This is an optional parameter that may be NULL.
5683 @param Edx The pointer to the 32-bit EDX value returned by the CPUID
5684 instruction. This is an optional parameter that may be NULL.
5693 OUT UINT32
*Eax
, OPTIONAL
5694 OUT UINT32
*Ebx
, OPTIONAL
5695 OUT UINT32
*Ecx
, OPTIONAL
5696 OUT UINT32
*Edx OPTIONAL
5701 Retrieves CPUID information using an extended leaf identifier.
5703 Executes the CPUID instruction with EAX set to the value specified by Index
5704 and ECX set to the value specified by SubIndex. This function always returns
5705 Index. This function is only available on IA-32 and x64.
5707 If Eax is not NULL, then the value of EAX after CPUID is returned in Eax.
5708 If Ebx is not NULL, then the value of EBX after CPUID is returned in Ebx.
5709 If Ecx is not NULL, then the value of ECX after CPUID is returned in Ecx.
5710 If Edx is not NULL, then the value of EDX after CPUID is returned in Edx.
5712 @param Index The 32-bit value to load into EAX prior to invoking the
5714 @param SubIndex The 32-bit value to load into ECX prior to invoking the
5716 @param Eax The pointer to the 32-bit EAX value returned by the CPUID
5717 instruction. This is an optional parameter that may be
5719 @param Ebx The pointer to the 32-bit EBX value returned by the CPUID
5720 instruction. This is an optional parameter that may be
5722 @param Ecx The pointer to the 32-bit ECX value returned by the CPUID
5723 instruction. This is an optional parameter that may be
5725 @param Edx The pointer to the 32-bit EDX value returned by the CPUID
5726 instruction. This is an optional parameter that may be
5737 OUT UINT32
*Eax
, OPTIONAL
5738 OUT UINT32
*Ebx
, OPTIONAL
5739 OUT UINT32
*Ecx
, OPTIONAL
5740 OUT UINT32
*Edx OPTIONAL
5745 Set CD bit and clear NW bit of CR0 followed by a WBINVD.
5747 Disables the caches by setting the CD bit of CR0 to 1, clearing the NW bit of CR0 to 0,
5748 and executing a WBINVD instruction. This function is only available on IA-32 and x64.
5759 Perform a WBINVD and clear both the CD and NW bits of CR0.
5761 Enables the caches by executing a WBINVD instruction and then clear both the CD and NW
5762 bits of CR0 to 0. This function is only available on IA-32 and x64.
5773 Returns the lower 32-bits of a Machine Specific Register(MSR).
5775 Reads and returns the lower 32-bits of the MSR specified by Index.
5776 No parameter checking is performed on Index, and some Index values may cause
5777 CPU exceptions. The caller must either guarantee that Index is valid, or the
5778 caller must set up exception handlers to catch the exceptions. This function
5779 is only available on IA-32 and x64.
5781 @param Index The 32-bit MSR index to read.
5783 @return The lower 32 bits of the MSR identified by Index.
5794 Writes a 32-bit value to a Machine Specific Register(MSR), and returns the value.
5795 The upper 32-bits of the MSR are set to zero.
5797 Writes the 32-bit value specified by Value to the MSR specified by Index. The
5798 upper 32-bits of the MSR write are set to zero. The 32-bit value written to
5799 the MSR is returned. No parameter checking is performed on Index or Value,
5800 and some of these may cause CPU exceptions. The caller must either guarantee
5801 that Index and Value are valid, or the caller must establish proper exception
5802 handlers. This function is only available on IA-32 and x64.
5804 @param Index The 32-bit MSR index to write.
5805 @param Value The 32-bit value to write to the MSR.
5819 Reads a 64-bit MSR, performs a bitwise OR on the lower 32-bits, and
5820 writes the result back to the 64-bit MSR.
5822 Reads the 64-bit MSR specified by Index, performs a bitwise OR
5823 between the lower 32-bits of the read result and the value specified by
5824 OrData, and writes the result to the 64-bit MSR specified by Index. The lower
5825 32-bits of the value written to the MSR is returned. No parameter checking is
5826 performed on Index or OrData, and some of these may cause CPU exceptions. The
5827 caller must either guarantee that Index and OrData are valid, or the caller
5828 must establish proper exception handlers. This function is only available on
5831 @param Index The 32-bit MSR index to write.
5832 @param OrData The value to OR with the read value from the MSR.
5834 @return The lower 32-bit value written to the MSR.
5846 Reads a 64-bit MSR, performs a bitwise AND on the lower 32-bits, and writes
5847 the result back to the 64-bit MSR.
5849 Reads the 64-bit MSR specified by Index, performs a bitwise AND between the
5850 lower 32-bits of the read result and the value specified by AndData, and
5851 writes the result to the 64-bit MSR specified by Index. The lower 32-bits of
5852 the value written to the MSR is returned. No parameter checking is performed
5853 on Index or AndData, and some of these may cause CPU exceptions. The caller
5854 must either guarantee that Index and AndData are valid, or the caller must
5855 establish proper exception handlers. This function is only available on IA-32
5858 @param Index The 32-bit MSR index to write.
5859 @param AndData The value to AND with the read value from the MSR.
5861 @return The lower 32-bit value written to the MSR.
5873 Reads a 64-bit MSR, performs a bitwise AND followed by a bitwise OR
5874 on the lower 32-bits, and writes the result back to the 64-bit MSR.
5876 Reads the 64-bit MSR specified by Index, performs a bitwise AND between the
5877 lower 32-bits of the read result and the value specified by AndData
5878 preserving the upper 32-bits, performs a bitwise OR between the
5879 result of the AND operation and the value specified by OrData, and writes the
5880 result to the 64-bit MSR specified by Address. The lower 32-bits of the value
5881 written to the MSR is returned. No parameter checking is performed on Index,
5882 AndData, or OrData, and some of these may cause CPU exceptions. The caller
5883 must either guarantee that Index, AndData, and OrData are valid, or the
5884 caller must establish proper exception handlers. This function is only
5885 available on IA-32 and x64.
5887 @param Index The 32-bit MSR index to write.
5888 @param AndData The value to AND with the read value from the MSR.
5889 @param OrData The value to OR with the result of the AND operation.
5891 @return The lower 32-bit value written to the MSR.
5904 Reads a bit field of an MSR.
5906 Reads the bit field in the lower 32-bits of a 64-bit MSR. The bit field is
5907 specified by the StartBit and the EndBit. The value of the bit field is
5908 returned. The caller must either guarantee that Index is valid, or the caller
5909 must set up exception handlers to catch the exceptions. This function is only
5910 available on IA-32 and x64.
5912 If StartBit is greater than 31, then ASSERT().
5913 If EndBit is greater than 31, then ASSERT().
5914 If EndBit is less than StartBit, then ASSERT().
5916 @param Index The 32-bit MSR index to read.
5917 @param StartBit The ordinal of the least significant bit in the bit field.
5919 @param EndBit The ordinal of the most significant bit in the bit field.
5922 @return The bit field read from the MSR.
5927 AsmMsrBitFieldRead32 (
5935 Writes a bit field to an MSR.
5937 Writes Value to a bit field in the lower 32-bits of a 64-bit MSR. The bit
5938 field is specified by the StartBit and the EndBit. All other bits in the
5939 destination MSR are preserved. The lower 32-bits of the MSR written is
5940 returned. The caller must either guarantee that Index and the data written
5941 is valid, or the caller must set up exception handlers to catch the exceptions.
5942 This function is only available on IA-32 and x64.
5944 If StartBit is greater than 31, then ASSERT().
5945 If EndBit is greater than 31, then ASSERT().
5946 If EndBit is less than StartBit, then ASSERT().
5947 If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
5949 @param Index The 32-bit MSR index to write.
5950 @param StartBit The ordinal of the least significant bit in the bit field.
5952 @param EndBit The ordinal of the most significant bit in the bit field.
5954 @param Value New value of the bit field.
5956 @return The lower 32-bit of the value written to the MSR.
5961 AsmMsrBitFieldWrite32 (
5970 Reads a bit field in a 64-bit MSR, performs a bitwise OR, and writes the
5971 result back to the bit field in the 64-bit MSR.
5973 Reads the 64-bit MSR specified by Index, performs a bitwise OR
5974 between the read result and the value specified by OrData, and writes the
5975 result to the 64-bit MSR specified by Index. The lower 32-bits of the value
5976 written to the MSR are returned. Extra left bits in OrData are stripped. The
5977 caller must either guarantee that Index and the data written is valid, or
5978 the caller must set up exception handlers to catch the exceptions. This
5979 function is only available on IA-32 and x64.
5981 If StartBit is greater than 31, then ASSERT().
5982 If EndBit is greater than 31, then ASSERT().
5983 If EndBit is less than StartBit, then ASSERT().
5984 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
5986 @param Index The 32-bit MSR index to write.
5987 @param StartBit The ordinal of the least significant bit in the bit field.
5989 @param EndBit The ordinal of the most significant bit in the bit field.
5991 @param OrData The value to OR with the read value from the MSR.
5993 @return The lower 32-bit of the value written to the MSR.
5998 AsmMsrBitFieldOr32 (
6007 Reads a bit field in a 64-bit MSR, performs a bitwise AND, and writes the
6008 result back to the bit field in the 64-bit MSR.
6010 Reads the 64-bit MSR specified by Index, performs a bitwise AND between the
6011 read result and the value specified by AndData, and writes the result to the
6012 64-bit MSR specified by Index. The lower 32-bits of the value written to the
6013 MSR are returned. Extra left bits in AndData are stripped. The caller must
6014 either guarantee that Index and the data written is valid, or the caller must
6015 set up exception handlers to catch the exceptions. This function is only
6016 available on IA-32 and x64.
6018 If StartBit is greater than 31, then ASSERT().
6019 If EndBit is greater than 31, then ASSERT().
6020 If EndBit is less than StartBit, then ASSERT().
6021 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
6023 @param Index The 32-bit MSR index to write.
6024 @param StartBit The ordinal of the least significant bit in the bit field.
6026 @param EndBit The ordinal of the most significant bit in the bit field.
6028 @param AndData The value to AND with the read value from the MSR.
6030 @return The lower 32-bit of the value written to the MSR.
6035 AsmMsrBitFieldAnd32 (
6044 Reads a bit field in a 64-bit MSR, performs a bitwise AND followed by a
6045 bitwise OR, and writes the result back to the bit field in the
6048 Reads the 64-bit MSR specified by Index, performs a bitwise AND followed by a
6049 bitwise OR between the read result and the value specified by
6050 AndData, and writes the result to the 64-bit MSR specified by Index. The
6051 lower 32-bits of the value written to the MSR are returned. Extra left bits
6052 in both AndData and OrData are stripped. The caller must either guarantee
6053 that Index and the data written is valid, or the caller must set up exception
6054 handlers to catch the exceptions. This function is only available on IA-32
6057 If StartBit is greater than 31, then ASSERT().
6058 If EndBit is greater than 31, then ASSERT().
6059 If EndBit is less than StartBit, then ASSERT().
6060 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
6061 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
6063 @param Index The 32-bit MSR index to write.
6064 @param StartBit The ordinal of the least significant bit in the bit field.
6066 @param EndBit The ordinal of the most significant bit in the bit field.
6068 @param AndData The value to AND with the read value from the MSR.
6069 @param OrData The value to OR with the result of the AND operation.
6071 @return The lower 32-bit of the value written to the MSR.
6076 AsmMsrBitFieldAndThenOr32 (
6086 Returns a 64-bit Machine Specific Register(MSR).
6088 Reads and returns the 64-bit MSR specified by Index. No parameter checking is
6089 performed on Index, and some Index values may cause CPU exceptions. The
6090 caller must either guarantee that Index is valid, or the caller must set up
6091 exception handlers to catch the exceptions. This function is only available
6094 @param Index The 32-bit MSR index to read.
6096 @return The value of the MSR identified by Index.
6107 Writes a 64-bit value to a Machine Specific Register(MSR), and returns the
6110 Writes the 64-bit value specified by Value to the MSR specified by Index. The
6111 64-bit value written to the MSR is returned. No parameter checking is
6112 performed on Index or Value, and some of these may cause CPU exceptions. The
6113 caller must either guarantee that Index and Value are valid, or the caller
6114 must establish proper exception handlers. This function is only available on
6117 @param Index The 32-bit MSR index to write.
6118 @param Value The 64-bit value to write to the MSR.
6132 Reads a 64-bit MSR, performs a bitwise OR, and writes the result
6133 back to the 64-bit MSR.
6135 Reads the 64-bit MSR specified by Index, performs a bitwise OR
6136 between the read result and the value specified by OrData, and writes the
6137 result to the 64-bit MSR specified by Index. The value written to the MSR is
6138 returned. No parameter checking is performed on Index or OrData, and some of
6139 these may cause CPU exceptions. The caller must either guarantee that Index
6140 and OrData are valid, or the caller must establish proper exception handlers.
6141 This function is only available on IA-32 and x64.
6143 @param Index The 32-bit MSR index to write.
6144 @param OrData The value to OR with the read value from the MSR.
6146 @return The value written back to the MSR.
6158 Reads a 64-bit MSR, performs a bitwise AND, and writes the result back to the
6161 Reads the 64-bit MSR specified by Index, performs a bitwise AND between the
6162 read result and the value specified by OrData, and writes the result to the
6163 64-bit MSR specified by Index. The value written to the MSR is returned. No
6164 parameter checking is performed on Index or OrData, and some of these may
6165 cause CPU exceptions. The caller must either guarantee that Index and OrData
6166 are valid, or the caller must establish proper exception handlers. This
6167 function is only available on IA-32 and x64.
6169 @param Index The 32-bit MSR index to write.
6170 @param AndData The value to AND with the read value from the MSR.
6172 @return The value written back to the MSR.
6184 Reads a 64-bit MSR, performs a bitwise AND followed by a bitwise
6185 OR, and writes the result back to the 64-bit MSR.
6187 Reads the 64-bit MSR specified by Index, performs a bitwise AND between read
6188 result and the value specified by AndData, performs a bitwise OR
6189 between the result of the AND operation and the value specified by OrData,
6190 and writes the result to the 64-bit MSR specified by Index. The value written
6191 to the MSR is returned. No parameter checking is performed on Index, AndData,
6192 or OrData, and some of these may cause CPU exceptions. The caller must either
6193 guarantee that Index, AndData, and OrData are valid, or the caller must
6194 establish proper exception handlers. This function is only available on IA-32
6197 @param Index The 32-bit MSR index to write.
6198 @param AndData The value to AND with the read value from the MSR.
6199 @param OrData The value to OR with the result of the AND operation.
6201 @return The value written back to the MSR.
6214 Reads a bit field of an MSR.
6216 Reads the bit field in the 64-bit MSR. The bit field is specified by the
6217 StartBit and the EndBit. The value of the bit field is returned. The caller
6218 must either guarantee that Index is valid, or the caller must set up
6219 exception handlers to catch the exceptions. This function is only available
6222 If StartBit is greater than 63, then ASSERT().
6223 If EndBit is greater than 63, then ASSERT().
6224 If EndBit is less than StartBit, then ASSERT().
6226 @param Index The 32-bit MSR index to read.
6227 @param StartBit The ordinal of the least significant bit in the bit field.
6229 @param EndBit The ordinal of the most significant bit in the bit field.
6232 @return The value read from the MSR.
6237 AsmMsrBitFieldRead64 (
6245 Writes a bit field to an MSR.
6247 Writes Value to a bit field in a 64-bit MSR. The bit field is specified by
6248 the StartBit and the EndBit. All other bits in the destination MSR are
6249 preserved. The MSR written is returned. The caller must either guarantee
6250 that Index and the data written is valid, or the caller must set up exception
6251 handlers to catch the exceptions. This function is only available on IA-32 and x64.
6253 If StartBit is greater than 63, then ASSERT().
6254 If EndBit is greater than 63, then ASSERT().
6255 If EndBit is less than StartBit, then ASSERT().
6256 If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
6258 @param Index The 32-bit MSR index to write.
6259 @param StartBit The ordinal of the least significant bit in the bit field.
6261 @param EndBit The ordinal of the most significant bit in the bit field.
6263 @param Value New value of the bit field.
6265 @return The value written back to the MSR.
6270 AsmMsrBitFieldWrite64 (
6279 Reads a bit field in a 64-bit MSR, performs a bitwise OR, and
6280 writes the result back to the bit field in the 64-bit MSR.
6282 Reads the 64-bit MSR specified by Index, performs a bitwise OR
6283 between the read result and the value specified by OrData, and writes the
6284 result to the 64-bit MSR specified by Index. The value written to the MSR is
6285 returned. Extra left bits in OrData are stripped. The caller must either
6286 guarantee that Index and the data written is valid, or the caller must set up
6287 exception handlers to catch the exceptions. This function is only available
6290 If StartBit is greater than 63, then ASSERT().
6291 If EndBit is greater than 63, then ASSERT().
6292 If EndBit is less than StartBit, then ASSERT().
6293 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
6295 @param Index The 32-bit MSR index to write.
6296 @param StartBit The ordinal of the least significant bit in the bit field.
6298 @param EndBit The ordinal of the most significant bit in the bit field.
6300 @param OrData The value to OR with the read value from the bit field.
6302 @return The value written back to the MSR.
6307 AsmMsrBitFieldOr64 (
6316 Reads a bit field in a 64-bit MSR, performs a bitwise AND, and writes the
6317 result back to the bit field in the 64-bit MSR.
6319 Reads the 64-bit MSR specified by Index, performs a bitwise AND between the
6320 read result and the value specified by AndData, and writes the result to the
6321 64-bit MSR specified by Index. The value written to the MSR is returned.
6322 Extra left bits in AndData are stripped. The caller must either guarantee
6323 that Index and the data written is valid, or the caller must set up exception
6324 handlers to catch the exceptions. This function is only available on IA-32
6327 If StartBit is greater than 63, then ASSERT().
6328 If EndBit is greater than 63, then ASSERT().
6329 If EndBit is less than StartBit, then ASSERT().
6330 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
6332 @param Index The 32-bit MSR index to write.
6333 @param StartBit The ordinal of the least significant bit in the bit field.
6335 @param EndBit The ordinal of the most significant bit in the bit field.
6337 @param AndData The value to AND with the read value from the bit field.
6339 @return The value written back to the MSR.
6344 AsmMsrBitFieldAnd64 (
6353 Reads a bit field in a 64-bit MSR, performs a bitwise AND followed by a
6354 bitwise OR, and writes the result back to the bit field in the
6357 Reads the 64-bit MSR specified by Index, performs a bitwise AND followed by
6358 a bitwise OR between the read result and the value specified by
6359 AndData, and writes the result to the 64-bit MSR specified by Index. The
6360 value written to the MSR is returned. Extra left bits in both AndData and
6361 OrData are stripped. The caller must either guarantee that Index and the data
6362 written is valid, or the caller must set up exception handlers to catch the
6363 exceptions. This function is only available on IA-32 and x64.
6365 If StartBit is greater than 63, then ASSERT().
6366 If EndBit is greater than 63, then ASSERT().
6367 If EndBit is less than StartBit, then ASSERT().
6368 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
6369 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
6371 @param Index The 32-bit MSR index to write.
6372 @param StartBit The ordinal of the least significant bit in the bit field.
6374 @param EndBit The ordinal of the most significant bit in the bit field.
6376 @param AndData The value to AND with the read value from the bit field.
6377 @param OrData The value to OR with the result of the AND operation.
6379 @return The value written back to the MSR.
6384 AsmMsrBitFieldAndThenOr64 (
6394 Reads the current value of the EFLAGS register.
6396 Reads and returns the current value of the EFLAGS register. This function is
6397 only available on IA-32 and x64. This returns a 32-bit value on IA-32 and a
6398 64-bit value on x64.
6400 @return EFLAGS on IA-32 or RFLAGS on x64.
6411 Reads the current value of the Control Register 0 (CR0).
6413 Reads and returns the current value of CR0. This function is only available
6414 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
6417 @return The value of the Control Register 0 (CR0).
6428 Reads the current value of the Control Register 2 (CR2).
6430 Reads and returns the current value of CR2. This function is only available
6431 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
6434 @return The value of the Control Register 2 (CR2).
6445 Reads the current value of the Control Register 3 (CR3).
6447 Reads and returns the current value of CR3. This function is only available
6448 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
6451 @return The value of the Control Register 3 (CR3).
6462 Reads the current value of the Control Register 4 (CR4).
6464 Reads and returns the current value of CR4. This function is only available
6465 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
6468 @return The value of the Control Register 4 (CR4).
6479 Writes a value to Control Register 0 (CR0).
6481 Writes and returns a new value to CR0. This function is only available on
6482 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
6484 @param Cr0 The value to write to CR0.
6486 @return The value written to CR0.
6497 Writes a value to Control Register 2 (CR2).
6499 Writes and returns a new value to CR2. This function is only available on
6500 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
6502 @param Cr2 The value to write to CR2.
6504 @return The value written to CR2.
6515 Writes a value to Control Register 3 (CR3).
6517 Writes and returns a new value to CR3. This function is only available on
6518 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
6520 @param Cr3 The value to write to CR3.
6522 @return The value written to CR3.
6533 Writes a value to Control Register 4 (CR4).
6535 Writes and returns a new value to CR4. This function is only available on
6536 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
6538 @param Cr4 The value to write to CR4.
6540 @return The value written to CR4.
6551 Reads the current value of Debug Register 0 (DR0).
6553 Reads and returns the current value of DR0. This function is only available
6554 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
6557 @return The value of Debug Register 0 (DR0).
6568 Reads the current value of Debug Register 1 (DR1).
6570 Reads and returns the current value of DR1. This function is only available
6571 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
6574 @return The value of Debug Register 1 (DR1).
6585 Reads the current value of Debug Register 2 (DR2).
6587 Reads and returns the current value of DR2. This function is only available
6588 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
6591 @return The value of Debug Register 2 (DR2).
6602 Reads the current value of Debug Register 3 (DR3).
6604 Reads and returns the current value of DR3. This function is only available
6605 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
6608 @return The value of Debug Register 3 (DR3).
6619 Reads the current value of Debug Register 4 (DR4).
6621 Reads and returns the current value of DR4. This function is only available
6622 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
6625 @return The value of Debug Register 4 (DR4).
6636 Reads the current value of Debug Register 5 (DR5).
6638 Reads and returns the current value of DR5. This function is only available
6639 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
6642 @return The value of Debug Register 5 (DR5).
6653 Reads the current value of Debug Register 6 (DR6).
6655 Reads and returns the current value of DR6. This function is only available
6656 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
6659 @return The value of Debug Register 6 (DR6).
6670 Reads the current value of Debug Register 7 (DR7).
6672 Reads and returns the current value of DR7. This function is only available
6673 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
6676 @return The value of Debug Register 7 (DR7).
6687 Writes a value to Debug Register 0 (DR0).
6689 Writes and returns a new value to DR0. This function is only available on
6690 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
6692 @param Dr0 The value to write to Dr0.
6694 @return The value written to Debug Register 0 (DR0).
6705 Writes a value to Debug Register 1 (DR1).
6707 Writes and returns a new value to DR1. This function is only available on
6708 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
6710 @param Dr1 The value to write to Dr1.
6712 @return The value written to Debug Register 1 (DR1).
6723 Writes a value to Debug Register 2 (DR2).
6725 Writes and returns a new value to DR2. This function is only available on
6726 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
6728 @param Dr2 The value to write to Dr2.
6730 @return The value written to Debug Register 2 (DR2).
6741 Writes a value to Debug Register 3 (DR3).
6743 Writes and returns a new value to DR3. This function is only available on
6744 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
6746 @param Dr3 The value to write to Dr3.
6748 @return The value written to Debug Register 3 (DR3).
6759 Writes a value to Debug Register 4 (DR4).
6761 Writes and returns a new value to DR4. This function is only available on
6762 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
6764 @param Dr4 The value to write to Dr4.
6766 @return The value written to Debug Register 4 (DR4).
6777 Writes a value to Debug Register 5 (DR5).
6779 Writes and returns a new value to DR5. This function is only available on
6780 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
6782 @param Dr5 The value to write to Dr5.
6784 @return The value written to Debug Register 5 (DR5).
6795 Writes a value to Debug Register 6 (DR6).
6797 Writes and returns a new value to DR6. This function is only available on
6798 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
6800 @param Dr6 The value to write to Dr6.
6802 @return The value written to Debug Register 6 (DR6).
6813 Writes a value to Debug Register 7 (DR7).
6815 Writes and returns a new value to DR7. This function is only available on
6816 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
6818 @param Dr7 The value to write to Dr7.
6820 @return The value written to Debug Register 7 (DR7).
6831 Reads the current value of Code Segment Register (CS).
6833 Reads and returns the current value of CS. This function is only available on
6836 @return The current value of CS.
6847 Reads the current value of Data Segment Register (DS).
6849 Reads and returns the current value of DS. This function is only available on
6852 @return The current value of DS.
6863 Reads the current value of Extra Segment Register (ES).
6865 Reads and returns the current value of ES. This function is only available on
6868 @return The current value of ES.
6879 Reads the current value of FS Data Segment Register (FS).
6881 Reads and returns the current value of FS. This function is only available on
6884 @return The current value of FS.
6895 Reads the current value of GS Data Segment Register (GS).
6897 Reads and returns the current value of GS. This function is only available on
6900 @return The current value of GS.
6911 Reads the current value of Stack Segment Register (SS).
6913 Reads and returns the current value of SS. This function is only available on
6916 @return The current value of SS.
6927 Reads the current value of Task Register (TR).
6929 Reads and returns the current value of TR. This function is only available on
6932 @return The current value of TR.
6943 Reads the current Global Descriptor Table Register(GDTR) descriptor.
6945 Reads and returns the current GDTR descriptor and returns it in Gdtr. This
6946 function is only available on IA-32 and x64.
6948 If Gdtr is NULL, then ASSERT().
6950 @param Gdtr The pointer to a GDTR descriptor.
6956 OUT IA32_DESCRIPTOR
*Gdtr
6961 Writes the current Global Descriptor Table Register (GDTR) descriptor.
6963 Writes and the current GDTR descriptor specified by Gdtr. This function is
6964 only available on IA-32 and x64.
6966 If Gdtr is NULL, then ASSERT().
6968 @param Gdtr The pointer to a GDTR descriptor.
6974 IN CONST IA32_DESCRIPTOR
*Gdtr
6979 Reads the current Interrupt Descriptor Table Register(IDTR) descriptor.
6981 Reads and returns the current IDTR descriptor and returns it in Idtr. This
6982 function is only available on IA-32 and x64.
6984 If Idtr is NULL, then ASSERT().
6986 @param Idtr The pointer to a IDTR descriptor.
6992 OUT IA32_DESCRIPTOR
*Idtr
6997 Writes the current Interrupt Descriptor Table Register(IDTR) descriptor.
6999 Writes the current IDTR descriptor and returns it in Idtr. This function is
7000 only available on IA-32 and x64.
7002 If Idtr is NULL, then ASSERT().
7004 @param Idtr The pointer to a IDTR descriptor.
7010 IN CONST IA32_DESCRIPTOR
*Idtr
7015 Reads the current Local Descriptor Table Register(LDTR) selector.
7017 Reads and returns the current 16-bit LDTR descriptor value. This function is
7018 only available on IA-32 and x64.
7020 @return The current selector of LDT.
7031 Writes the current Local Descriptor Table Register (LDTR) selector.
7033 Writes and the current LDTR descriptor specified by Ldtr. This function is
7034 only available on IA-32 and x64.
7036 @param Ldtr 16-bit LDTR selector value.
7047 Save the current floating point/SSE/SSE2 context to a buffer.
7049 Saves the current floating point/SSE/SSE2 state to the buffer specified by
7050 Buffer. Buffer must be aligned on a 16-byte boundary. This function is only
7051 available on IA-32 and x64.
7053 If Buffer is NULL, then ASSERT().
7054 If Buffer is not aligned on a 16-byte boundary, then ASSERT().
7056 @param Buffer The pointer to a buffer to save the floating point/SSE/SSE2 context.
7062 OUT IA32_FX_BUFFER
*Buffer
7067 Restores the current floating point/SSE/SSE2 context from a buffer.
7069 Restores the current floating point/SSE/SSE2 state from the buffer specified
7070 by Buffer. Buffer must be aligned on a 16-byte boundary. This function is
7071 only available on IA-32 and x64.
7073 If Buffer is NULL, then ASSERT().
7074 If Buffer is not aligned on a 16-byte boundary, then ASSERT().
7075 If Buffer was not saved with AsmFxSave(), then ASSERT().
7077 @param Buffer The pointer to a buffer to save the floating point/SSE/SSE2 context.
7083 IN CONST IA32_FX_BUFFER
*Buffer
7088 Reads the current value of 64-bit MMX Register #0 (MM0).
7090 Reads and returns the current value of MM0. This function is only available
7093 @return The current value of MM0.
7104 Reads the current value of 64-bit MMX Register #1 (MM1).
7106 Reads and returns the current value of MM1. This function is only available
7109 @return The current value of MM1.
7120 Reads the current value of 64-bit MMX Register #2 (MM2).
7122 Reads and returns the current value of MM2. This function is only available
7125 @return The current value of MM2.
7136 Reads the current value of 64-bit MMX Register #3 (MM3).
7138 Reads and returns the current value of MM3. This function is only available
7141 @return The current value of MM3.
7152 Reads the current value of 64-bit MMX Register #4 (MM4).
7154 Reads and returns the current value of MM4. This function is only available
7157 @return The current value of MM4.
7168 Reads the current value of 64-bit MMX Register #5 (MM5).
7170 Reads and returns the current value of MM5. This function is only available
7173 @return The current value of MM5.
7184 Reads the current value of 64-bit MMX Register #6 (MM6).
7186 Reads and returns the current value of MM6. This function is only available
7189 @return The current value of MM6.
7200 Reads the current value of 64-bit MMX Register #7 (MM7).
7202 Reads and returns the current value of MM7. This function is only available
7205 @return The current value of MM7.
7216 Writes the current value of 64-bit MMX Register #0 (MM0).
7218 Writes the current value of MM0. This function is only available on IA32 and
7221 @param Value The 64-bit value to write to MM0.
7232 Writes the current value of 64-bit MMX Register #1 (MM1).
7234 Writes the current value of MM1. This function is only available on IA32 and
7237 @param Value The 64-bit value to write to MM1.
7248 Writes the current value of 64-bit MMX Register #2 (MM2).
7250 Writes the current value of MM2. This function is only available on IA32 and
7253 @param Value The 64-bit value to write to MM2.
7264 Writes the current value of 64-bit MMX Register #3 (MM3).
7266 Writes the current value of MM3. This function is only available on IA32 and
7269 @param Value The 64-bit value to write to MM3.
7280 Writes the current value of 64-bit MMX Register #4 (MM4).
7282 Writes the current value of MM4. This function is only available on IA32 and
7285 @param Value The 64-bit value to write to MM4.
7296 Writes the current value of 64-bit MMX Register #5 (MM5).
7298 Writes the current value of MM5. This function is only available on IA32 and
7301 @param Value The 64-bit value to write to MM5.
7312 Writes the current value of 64-bit MMX Register #6 (MM6).
7314 Writes the current value of MM6. This function is only available on IA32 and
7317 @param Value The 64-bit value to write to MM6.
7328 Writes the current value of 64-bit MMX Register #7 (MM7).
7330 Writes the current value of MM7. This function is only available on IA32 and
7333 @param Value The 64-bit value to write to MM7.
7344 Reads the current value of Time Stamp Counter (TSC).
7346 Reads and returns the current value of TSC. This function is only available
7349 @return The current value of TSC
7360 Reads the current value of a Performance Counter (PMC).
7362 Reads and returns the current value of performance counter specified by
7363 Index. This function is only available on IA-32 and x64.
7365 @param Index The 32-bit Performance Counter index to read.
7367 @return The value of the PMC specified by Index.
7378 Sets up a monitor buffer that is used by AsmMwait().
7380 Executes a MONITOR instruction with the register state specified by Eax, Ecx
7381 and Edx. Returns Eax. This function is only available on IA-32 and x64.
7383 @param Eax The value to load into EAX or RAX before executing the MONITOR
7385 @param Ecx The value to load into ECX or RCX before executing the MONITOR
7387 @param Edx The value to load into EDX or RDX before executing the MONITOR
7403 Executes an MWAIT instruction.
7405 Executes an MWAIT instruction with the register state specified by Eax and
7406 Ecx. Returns Eax. This function is only available on IA-32 and x64.
7408 @param Eax The value to load into EAX or RAX before executing the MONITOR
7410 @param Ecx The value to load into ECX or RCX before executing the MONITOR
7425 Executes a WBINVD instruction.
7427 Executes a WBINVD instruction. This function is only available on IA-32 and
7439 Executes a INVD instruction.
7441 Executes a INVD instruction. This function is only available on IA-32 and
7453 Flushes a cache line from all the instruction and data caches within the
7454 coherency domain of the CPU.
7456 Flushed the cache line specified by LinearAddress, and returns LinearAddress.
7457 This function is only available on IA-32 and x64.
7459 @param LinearAddress The address of the cache line to flush. If the CPU is
7460 in a physical addressing mode, then LinearAddress is a
7461 physical address. If the CPU is in a virtual
7462 addressing mode, then LinearAddress is a virtual
7465 @return LinearAddress.
7470 IN VOID
*LinearAddress
7475 Enables the 32-bit paging mode on the CPU.
7477 Enables the 32-bit paging mode on the CPU. CR0, CR3, CR4, and the page tables
7478 must be properly initialized prior to calling this service. This function
7479 assumes the current execution mode is 32-bit protected mode. This function is
7480 only available on IA-32. After the 32-bit paging mode is enabled, control is
7481 transferred to the function specified by EntryPoint using the new stack
7482 specified by NewStack and passing in the parameters specified by Context1 and
7483 Context2. Context1 and Context2 are optional and may be NULL. The function
7484 EntryPoint must never return.
7486 If the current execution mode is not 32-bit protected mode, then ASSERT().
7487 If EntryPoint is NULL, then ASSERT().
7488 If NewStack is NULL, then ASSERT().
7490 There are a number of constraints that must be followed before calling this
7492 1) Interrupts must be disabled.
7493 2) The caller must be in 32-bit protected mode with flat descriptors. This
7494 means all descriptors must have a base of 0 and a limit of 4GB.
7495 3) CR0 and CR4 must be compatible with 32-bit protected mode with flat
7497 4) CR3 must point to valid page tables that will be used once the transition
7498 is complete, and those page tables must guarantee that the pages for this
7499 function and the stack are identity mapped.
7501 @param EntryPoint A pointer to function to call with the new stack after
7503 @param Context1 A pointer to the context to pass into the EntryPoint
7504 function as the first parameter after paging is enabled.
7505 @param Context2 A pointer to the context to pass into the EntryPoint
7506 function as the second parameter after paging is enabled.
7507 @param NewStack A pointer to the new stack to use for the EntryPoint
7508 function after paging is enabled.
7514 IN SWITCH_STACK_ENTRY_POINT EntryPoint
,
7515 IN VOID
*Context1
, OPTIONAL
7516 IN VOID
*Context2
, OPTIONAL
7522 Disables the 32-bit paging mode on the CPU.
7524 Disables the 32-bit paging mode on the CPU and returns to 32-bit protected
7525 mode. This function assumes the current execution mode is 32-paged protected
7526 mode. This function is only available on IA-32. After the 32-bit paging mode
7527 is disabled, control is transferred to the function specified by EntryPoint
7528 using the new stack specified by NewStack and passing in the parameters
7529 specified by Context1 and Context2. Context1 and Context2 are optional and
7530 may be NULL. The function EntryPoint must never return.
7532 If the current execution mode is not 32-bit paged mode, then ASSERT().
7533 If EntryPoint is NULL, then ASSERT().
7534 If NewStack is NULL, then ASSERT().
7536 There are a number of constraints that must be followed before calling this
7538 1) Interrupts must be disabled.
7539 2) The caller must be in 32-bit paged mode.
7540 3) CR0, CR3, and CR4 must be compatible with 32-bit paged mode.
7541 4) CR3 must point to valid page tables that guarantee that the pages for
7542 this function and the stack are identity mapped.
7544 @param EntryPoint A pointer to function to call with the new stack after
7546 @param Context1 A pointer to the context to pass into the EntryPoint
7547 function as the first parameter after paging is disabled.
7548 @param Context2 A pointer to the context to pass into the EntryPoint
7549 function as the second parameter after paging is
7551 @param NewStack A pointer to the new stack to use for the EntryPoint
7552 function after paging is disabled.
7557 AsmDisablePaging32 (
7558 IN SWITCH_STACK_ENTRY_POINT EntryPoint
,
7559 IN VOID
*Context1
, OPTIONAL
7560 IN VOID
*Context2
, OPTIONAL
7566 Enables the 64-bit paging mode on the CPU.
7568 Enables the 64-bit paging mode on the CPU. CR0, CR3, CR4, and the page tables
7569 must be properly initialized prior to calling this service. This function
7570 assumes the current execution mode is 32-bit protected mode with flat
7571 descriptors. This function is only available on IA-32. After the 64-bit
7572 paging mode is enabled, control is transferred to the function specified by
7573 EntryPoint using the new stack specified by NewStack and passing in the
7574 parameters specified by Context1 and Context2. Context1 and Context2 are
7575 optional and may be 0. The function EntryPoint must never return.
7577 If the current execution mode is not 32-bit protected mode with flat
7578 descriptors, then ASSERT().
7579 If EntryPoint is 0, then ASSERT().
7580 If NewStack is 0, then ASSERT().
7582 @param Cs The 16-bit selector to load in the CS before EntryPoint
7583 is called. The descriptor in the GDT that this selector
7584 references must be setup for long mode.
7585 @param EntryPoint The 64-bit virtual address of the function to call with
7586 the new stack after paging is enabled.
7587 @param Context1 The 64-bit virtual address of the context to pass into
7588 the EntryPoint function as the first parameter after
7590 @param Context2 The 64-bit virtual address of the context to pass into
7591 the EntryPoint function as the second parameter after
7593 @param NewStack The 64-bit virtual address of the new stack to use for
7594 the EntryPoint function after paging is enabled.
7601 IN UINT64 EntryPoint
,
7602 IN UINT64 Context1
, OPTIONAL
7603 IN UINT64 Context2
, OPTIONAL
7609 Disables the 64-bit paging mode on the CPU.
7611 Disables the 64-bit paging mode on the CPU and returns to 32-bit protected
7612 mode. This function assumes the current execution mode is 64-paging mode.
7613 This function is only available on x64. After the 64-bit paging mode is
7614 disabled, control is transferred to the function specified by EntryPoint
7615 using the new stack specified by NewStack and passing in the parameters
7616 specified by Context1 and Context2. Context1 and Context2 are optional and
7617 may be 0. The function EntryPoint must never return.
7619 If the current execution mode is not 64-bit paged mode, then ASSERT().
7620 If EntryPoint is 0, then ASSERT().
7621 If NewStack is 0, then ASSERT().
7623 @param Cs The 16-bit selector to load in the CS before EntryPoint
7624 is called. The descriptor in the GDT that this selector
7625 references must be setup for 32-bit protected mode.
7626 @param EntryPoint The 64-bit virtual address of the function to call with
7627 the new stack after paging is disabled.
7628 @param Context1 The 64-bit virtual address of the context to pass into
7629 the EntryPoint function as the first parameter after
7631 @param Context2 The 64-bit virtual address of the context to pass into
7632 the EntryPoint function as the second parameter after
7634 @param NewStack The 64-bit virtual address of the new stack to use for
7635 the EntryPoint function after paging is disabled.
7640 AsmDisablePaging64 (
7642 IN UINT32 EntryPoint
,
7643 IN UINT32 Context1
, OPTIONAL
7644 IN UINT32 Context2
, OPTIONAL
7650 // 16-bit thunking services
7654 Retrieves the properties for 16-bit thunk functions.
7656 Computes the size of the buffer and stack below 1MB required to use the
7657 AsmPrepareThunk16(), AsmThunk16() and AsmPrepareAndThunk16() functions. This
7658 buffer size is returned in RealModeBufferSize, and the stack size is returned
7659 in ExtraStackSize. If parameters are passed to the 16-bit real mode code,
7660 then the actual minimum stack size is ExtraStackSize plus the maximum number
7661 of bytes that need to be passed to the 16-bit real mode code.
7663 If RealModeBufferSize is NULL, then ASSERT().
7664 If ExtraStackSize is NULL, then ASSERT().
7666 @param RealModeBufferSize A pointer to the size of the buffer below 1MB
7667 required to use the 16-bit thunk functions.
7668 @param ExtraStackSize A pointer to the extra size of stack below 1MB
7669 that the 16-bit thunk functions require for
7670 temporary storage in the transition to and from
7676 AsmGetThunk16Properties (
7677 OUT UINT32
*RealModeBufferSize
,
7678 OUT UINT32
*ExtraStackSize
7683 Prepares all structures a code required to use AsmThunk16().
7685 Prepares all structures and code required to use AsmThunk16().
7687 This interface is limited to be used in either physical mode or virtual modes with paging enabled where the
7688 virtual to physical mappings for ThunkContext.RealModeBuffer is mapped 1:1.
7690 If ThunkContext is NULL, then ASSERT().
7692 @param ThunkContext A pointer to the context structure that describes the
7693 16-bit real mode code to call.
7699 IN OUT THUNK_CONTEXT
*ThunkContext
7704 Transfers control to a 16-bit real mode entry point and returns the results.
7706 Transfers control to a 16-bit real mode entry point and returns the results.
7707 AsmPrepareThunk16() must be called with ThunkContext before this function is used.
7708 This function must be called with interrupts disabled.
7710 The register state from the RealModeState field of ThunkContext is restored just prior
7711 to calling the 16-bit real mode entry point. This includes the EFLAGS field of RealModeState,
7712 which is used to set the interrupt state when a 16-bit real mode entry point is called.
7713 Control is transferred to the 16-bit real mode entry point specified by the CS and Eip fields of RealModeState.
7714 The stack is initialized to the SS and ESP fields of RealModeState. Any parameters passed to
7715 the 16-bit real mode code must be populated by the caller at SS:ESP prior to calling this function.
7716 The 16-bit real mode entry point is invoked with a 16-bit CALL FAR instruction,
7717 so when accessing stack contents, the 16-bit real mode code must account for the 16-bit segment
7718 and 16-bit offset of the return address that were pushed onto the stack. The 16-bit real mode entry
7719 point must exit with a RETF instruction. The register state is captured into RealModeState immediately
7720 after the RETF instruction is executed.
7722 If EFLAGS specifies interrupts enabled, or any of the 16-bit real mode code enables interrupts,
7723 or any of the 16-bit real mode code makes a SW interrupt, then the caller is responsible for making sure
7724 the IDT at address 0 is initialized to handle any HW or SW interrupts that may occur while in 16-bit real mode.
7726 If EFLAGS specifies interrupts enabled, or any of the 16-bit real mode code enables interrupts,
7727 then the caller is responsible for making sure the 8259 PIC is in a state compatible with 16-bit real mode.
7728 This includes the base vectors, the interrupt masks, and the edge/level trigger mode.
7730 If THUNK_ATTRIBUTE_BIG_REAL_MODE is set in the ThunkAttributes field of ThunkContext, then the user code
7731 is invoked in big real mode. Otherwise, the user code is invoked in 16-bit real mode with 64KB segment limits.
7733 If neither THUNK_ATTRIBUTE_DISABLE_A20_MASK_INT_15 nor THUNK_ATTRIBUTE_DISABLE_A20_MASK_KBD_CTRL are set in
7734 ThunkAttributes, then it is assumed that the user code did not enable the A20 mask, and no attempt is made to
7735 disable the A20 mask.
7737 If THUNK_ATTRIBUTE_DISABLE_A20_MASK_INT_15 is set and THUNK_ATTRIBUTE_DISABLE_A20_MASK_KBD_CTRL is clear in
7738 ThunkAttributes, then attempt to use the INT 15 service to disable the A20 mask. If this INT 15 call fails,
7739 then attempt to disable the A20 mask by directly accessing the 8042 keyboard controller I/O ports.
7741 If THUNK_ATTRIBUTE_DISABLE_A20_MASK_INT_15 is clear and THUNK_ATTRIBUTE_DISABLE_A20_MASK_KBD_CTRL is set in
7742 ThunkAttributes, then attempt to disable the A20 mask by directly accessing the 8042 keyboard controller I/O ports.
7744 If ThunkContext is NULL, then ASSERT().
7745 If AsmPrepareThunk16() was not previously called with ThunkContext, then ASSERT().
7746 If both THUNK_ATTRIBUTE_DISABLE_A20_MASK_INT_15 and THUNK_ATTRIBUTE_DISABLE_A20_MASK_KBD_CTRL are set in
7747 ThunkAttributes, then ASSERT().
7749 This interface is limited to be used in either physical mode or virtual modes with paging enabled where the
7750 virtual to physical mappings for ThunkContext.RealModeBuffer are mapped 1:1.
7752 @param ThunkContext A pointer to the context structure that describes the
7753 16-bit real mode code to call.
7759 IN OUT THUNK_CONTEXT
*ThunkContext
7764 Prepares all structures and code for a 16-bit real mode thunk, transfers
7765 control to a 16-bit real mode entry point, and returns the results.
7767 Prepares all structures and code for a 16-bit real mode thunk, transfers
7768 control to a 16-bit real mode entry point, and returns the results. If the
7769 caller only need to perform a single 16-bit real mode thunk, then this
7770 service should be used. If the caller intends to make more than one 16-bit
7771 real mode thunk, then it is more efficient if AsmPrepareThunk16() is called
7772 once and AsmThunk16() can be called for each 16-bit real mode thunk.
7774 This interface is limited to be used in either physical mode or virtual modes with paging enabled where the
7775 virtual to physical mappings for ThunkContext.RealModeBuffer is mapped 1:1.
7777 See AsmPrepareThunk16() and AsmThunk16() for the detailed description and ASSERT() conditions.
7779 @param ThunkContext A pointer to the context structure that describes the
7780 16-bit real mode code to call.
7785 AsmPrepareAndThunk16 (
7786 IN OUT THUNK_CONTEXT
*ThunkContext
7790 Generates a 16-bit random number through RDRAND instruction.
7792 if Rand is NULL, then ASSERT().
7794 @param[out] Rand Buffer pointer to store the random result.
7796 @retval TRUE RDRAND call was successful.
7797 @retval FALSE Failed attempts to call RDRAND.
7807 Generates a 32-bit random number through RDRAND instruction.
7809 if Rand is NULL, then ASSERT().
7811 @param[out] Rand Buffer pointer to store the random result.
7813 @retval TRUE RDRAND call was successful.
7814 @retval FALSE Failed attempts to call RDRAND.
7824 Generates a 64-bit random number through RDRAND instruction.
7826 if Rand is NULL, then ASSERT().
7828 @param[out] Rand Buffer pointer to store the random result.
7830 @retval TRUE RDRAND call was successful.
7831 @retval FALSE Failed attempts to call RDRAND.