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
1024 Convert a Null-terminated Unicode string to a Null-terminated
1025 ASCII string and returns the ASCII string.
1027 This function converts the content of the Unicode string Source
1028 to the ASCII string Destination by copying the lower 8 bits of
1029 each Unicode character. It returns Destination.
1031 The caller is responsible to make sure Destination points to a buffer with size
1032 equal or greater than ((StrLen (Source) + 1) * sizeof (CHAR8)) in bytes.
1034 If any Unicode characters in Source contain non-zero value in
1035 the upper 8 bits, then ASSERT().
1037 If Destination is NULL, then ASSERT().
1038 If Source is NULL, then ASSERT().
1039 If Source is not aligned on a 16-bit boundary, then ASSERT().
1040 If Source and Destination overlap, then ASSERT().
1042 If PcdMaximumUnicodeStringLength is not zero, and Source contains
1043 more than PcdMaximumUnicodeStringLength Unicode characters not including
1044 the Null-terminator, then ASSERT().
1046 If PcdMaximumAsciiStringLength is not zero, and Source contains more
1047 than PcdMaximumAsciiStringLength Unicode characters not including the
1048 Null-terminator, then ASSERT().
1050 @param Source The pointer to a Null-terminated Unicode string.
1051 @param Destination The pointer to a Null-terminated ASCII string.
1053 @return Destination.
1058 UnicodeStrToAsciiStr (
1059 IN CONST CHAR16
*Source
,
1060 OUT CHAR8
*Destination
1064 Convert a Null-terminated Unicode string to a Null-terminated
1067 This function is similar to AsciiStrCpyS.
1069 This function converts the content of the Unicode string Source
1070 to the ASCII string Destination by copying the lower 8 bits of
1071 each Unicode character. The function terminates the ASCII string
1072 Destination by appending a Null-terminator character at the end.
1074 The caller is responsible to make sure Destination points to a buffer with size
1075 equal or greater than ((StrLen (Source) + 1) * sizeof (CHAR8)) in bytes.
1077 If any Unicode characters in Source contain non-zero value in
1078 the upper 8 bits, then ASSERT().
1080 If Source is not aligned on a 16-bit boundary, then ASSERT().
1081 If an error would be returned, then the function will also ASSERT().
1083 If an error is returned, then the Destination is unmodified.
1085 @param Source The pointer to a Null-terminated Unicode string.
1086 @param Destination The pointer to a Null-terminated ASCII string.
1087 @param DestMax The maximum number of Destination Ascii
1088 char, including terminating null char.
1090 @retval RETURN_SUCCESS String is converted.
1091 @retval RETURN_BUFFER_TOO_SMALL If DestMax is NOT greater than StrLen(Source).
1092 @retval RETURN_INVALID_PARAMETER If Destination is NULL.
1094 If PcdMaximumAsciiStringLength is not zero,
1095 and DestMax is greater than
1096 PcdMaximumAsciiStringLength.
1097 If PcdMaximumUnicodeStringLength is not zero,
1098 and DestMax is greater than
1099 PcdMaximumUnicodeStringLength.
1101 @retval RETURN_ACCESS_DENIED If Source and Destination overlap.
1106 UnicodeStrToAsciiStrS (
1107 IN CONST CHAR16
*Source
,
1108 OUT CHAR8
*Destination
,
1112 #ifndef DISABLE_NEW_DEPRECATED_INTERFACES
1115 [ATTENTION] This function is deprecated for security reason.
1117 Copies one Null-terminated ASCII string to another Null-terminated ASCII
1118 string and returns the new ASCII string.
1120 This function copies the contents of the ASCII string Source to the ASCII
1121 string Destination, and returns Destination. If Source and Destination
1122 overlap, then the results are undefined.
1124 If Destination is NULL, then ASSERT().
1125 If Source is NULL, then ASSERT().
1126 If Source and Destination overlap, then ASSERT().
1127 If PcdMaximumAsciiStringLength is not zero and Source contains more than
1128 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
1131 @param Destination The pointer to a Null-terminated ASCII string.
1132 @param Source The pointer to a Null-terminated ASCII string.
1140 OUT CHAR8
*Destination
,
1141 IN CONST CHAR8
*Source
1146 [ATTENTION] This function is deprecated for security reason.
1148 Copies up to a specified length one Null-terminated ASCII string to another
1149 Null-terminated ASCII string and returns the new ASCII string.
1151 This function copies the contents of the ASCII string Source to the ASCII
1152 string Destination, and returns Destination. At most, Length ASCII characters
1153 are copied from Source to Destination. If Length is 0, then Destination is
1154 returned unmodified. If Length is greater that the number of ASCII characters
1155 in Source, then Destination is padded with Null ASCII characters. If Source
1156 and Destination overlap, then the results are undefined.
1158 If Destination is NULL, then ASSERT().
1159 If Source is NULL, then ASSERT().
1160 If Source and Destination overlap, then ASSERT().
1161 If PcdMaximumAsciiStringLength is not zero, and Length is greater than
1162 PcdMaximumAsciiStringLength, then ASSERT().
1163 If PcdMaximumAsciiStringLength is not zero, and Source contains more than
1164 PcdMaximumAsciiStringLength ASCII characters, not including the Null-terminator,
1167 @param Destination The pointer to a Null-terminated ASCII string.
1168 @param Source The pointer to a Null-terminated ASCII string.
1169 @param Length The maximum number of ASCII characters to copy.
1177 OUT CHAR8
*Destination
,
1178 IN CONST CHAR8
*Source
,
1184 Returns the length of a Null-terminated ASCII string.
1186 This function returns the number of ASCII characters in the Null-terminated
1187 ASCII string specified by String.
1189 If Length > 0 and Destination is NULL, then ASSERT().
1190 If Length > 0 and Source is NULL, then ASSERT().
1191 If PcdMaximumAsciiStringLength is not zero and String contains more than
1192 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
1195 @param String The pointer to a Null-terminated ASCII string.
1197 @return The length of String.
1203 IN CONST CHAR8
*String
1208 Returns the size of a Null-terminated ASCII string in bytes, including the
1211 This function returns the size, in bytes, of the Null-terminated ASCII string
1212 specified by String.
1214 If String is NULL, then ASSERT().
1215 If PcdMaximumAsciiStringLength is not zero and String contains more than
1216 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
1219 @param String The pointer to a Null-terminated ASCII string.
1221 @return The size of String.
1227 IN CONST CHAR8
*String
1232 Compares two Null-terminated ASCII strings, and returns the difference
1233 between the first mismatched ASCII characters.
1235 This function compares the Null-terminated ASCII string FirstString to the
1236 Null-terminated ASCII string SecondString. If FirstString is identical to
1237 SecondString, then 0 is returned. Otherwise, the value returned is the first
1238 mismatched ASCII character in SecondString subtracted from the first
1239 mismatched ASCII character in FirstString.
1241 If FirstString is NULL, then ASSERT().
1242 If SecondString is NULL, then ASSERT().
1243 If PcdMaximumAsciiStringLength is not zero and FirstString contains more than
1244 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
1246 If PcdMaximumAsciiStringLength is not zero and SecondString contains more
1247 than PcdMaximumAsciiStringLength ASCII characters not including the
1248 Null-terminator, then ASSERT().
1250 @param FirstString The pointer to a Null-terminated ASCII string.
1251 @param SecondString The pointer to a Null-terminated ASCII string.
1253 @retval ==0 FirstString is identical to SecondString.
1254 @retval !=0 FirstString is not identical to SecondString.
1260 IN CONST CHAR8
*FirstString
,
1261 IN CONST CHAR8
*SecondString
1266 Performs a case insensitive comparison of two Null-terminated ASCII strings,
1267 and returns the difference between the first mismatched ASCII characters.
1269 This function performs a case insensitive comparison of the Null-terminated
1270 ASCII string FirstString to the Null-terminated ASCII string SecondString. If
1271 FirstString is identical to SecondString, then 0 is returned. Otherwise, the
1272 value returned is the first mismatched lower case ASCII character in
1273 SecondString subtracted from the first mismatched lower case ASCII character
1276 If FirstString is NULL, then ASSERT().
1277 If SecondString is NULL, then ASSERT().
1278 If PcdMaximumAsciiStringLength is not zero and FirstString contains more than
1279 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
1281 If PcdMaximumAsciiStringLength is not zero and SecondString contains more
1282 than PcdMaximumAsciiStringLength ASCII characters not including the
1283 Null-terminator, then ASSERT().
1285 @param FirstString The pointer to a Null-terminated ASCII string.
1286 @param SecondString The pointer to a Null-terminated ASCII string.
1288 @retval ==0 FirstString is identical to SecondString using case insensitive
1290 @retval !=0 FirstString is not identical to SecondString using case
1291 insensitive comparisons.
1297 IN CONST CHAR8
*FirstString
,
1298 IN CONST CHAR8
*SecondString
1303 Compares two Null-terminated ASCII strings with maximum lengths, and returns
1304 the difference between the first mismatched ASCII characters.
1306 This function compares the Null-terminated ASCII string FirstString to the
1307 Null-terminated ASCII string SecondString. At most, Length ASCII characters
1308 will be compared. If Length is 0, then 0 is returned. If FirstString is
1309 identical to SecondString, then 0 is returned. Otherwise, the value returned
1310 is the first mismatched ASCII character in SecondString subtracted from the
1311 first mismatched ASCII character in FirstString.
1313 If Length > 0 and FirstString is NULL, then ASSERT().
1314 If Length > 0 and SecondString is NULL, then ASSERT().
1315 If PcdMaximumAsciiStringLength is not zero, and Length is greater than
1316 PcdMaximumAsciiStringLength, then ASSERT().
1317 If PcdMaximumAsciiStringLength is not zero, and FirstString contains more than
1318 PcdMaximumAsciiStringLength ASCII characters, not including the Null-terminator,
1320 If PcdMaximumAsciiStringLength is not zero, and SecondString contains more than
1321 PcdMaximumAsciiStringLength ASCII characters, not including the Null-terminator,
1324 @param FirstString The pointer to a Null-terminated ASCII string.
1325 @param SecondString The pointer to a Null-terminated ASCII string.
1326 @param Length The maximum number of ASCII characters for compare.
1328 @retval ==0 FirstString is identical to SecondString.
1329 @retval !=0 FirstString is not identical to SecondString.
1335 IN CONST CHAR8
*FirstString
,
1336 IN CONST CHAR8
*SecondString
,
1341 #ifndef DISABLE_NEW_DEPRECATED_INTERFACES
1344 [ATTENTION] This function is deprecated for security reason.
1346 Concatenates one Null-terminated ASCII string to another Null-terminated
1347 ASCII string, and returns the concatenated ASCII string.
1349 This function concatenates two Null-terminated ASCII strings. The contents of
1350 Null-terminated ASCII string Source are concatenated to the end of Null-
1351 terminated ASCII string Destination. The Null-terminated concatenated ASCII
1354 If Destination is NULL, then ASSERT().
1355 If Source is NULL, then ASSERT().
1356 If PcdMaximumAsciiStringLength is not zero and Destination contains more than
1357 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
1359 If PcdMaximumAsciiStringLength is not zero and Source contains more than
1360 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
1362 If PcdMaximumAsciiStringLength is not zero and concatenating Destination and
1363 Source results in a ASCII string with more than PcdMaximumAsciiStringLength
1364 ASCII characters, then ASSERT().
1366 @param Destination The pointer to a Null-terminated ASCII string.
1367 @param Source The pointer to a Null-terminated ASCII string.
1375 IN OUT CHAR8
*Destination
,
1376 IN CONST CHAR8
*Source
1381 [ATTENTION] This function is deprecated for security reason.
1383 Concatenates up to a specified length one Null-terminated ASCII string to
1384 the end of another Null-terminated ASCII string, and returns the
1385 concatenated ASCII string.
1387 This function concatenates two Null-terminated ASCII strings. The contents
1388 of Null-terminated ASCII string Source are concatenated to the end of Null-
1389 terminated ASCII string Destination, and Destination is returned. At most,
1390 Length ASCII characters are concatenated from Source to the end of
1391 Destination, and Destination is always Null-terminated. If Length is 0, then
1392 Destination is returned unmodified. If Source and Destination overlap, then
1393 the results are undefined.
1395 If Length > 0 and Destination is NULL, then ASSERT().
1396 If Length > 0 and Source is NULL, then ASSERT().
1397 If Source and Destination overlap, then ASSERT().
1398 If PcdMaximumAsciiStringLength is not zero, and Length is greater than
1399 PcdMaximumAsciiStringLength, then ASSERT().
1400 If PcdMaximumAsciiStringLength is not zero, and Destination contains more than
1401 PcdMaximumAsciiStringLength ASCII characters, not including the Null-terminator,
1403 If PcdMaximumAsciiStringLength is not zero, and Source contains more than
1404 PcdMaximumAsciiStringLength ASCII characters, not including the Null-terminator,
1406 If PcdMaximumAsciiStringLength is not zero, and concatenating Destination and
1407 Source results in a ASCII string with more than PcdMaximumAsciiStringLength
1408 ASCII characters, not including the Null-terminator, then ASSERT().
1410 @param Destination The pointer to a Null-terminated ASCII string.
1411 @param Source The pointer to a Null-terminated ASCII string.
1412 @param Length The maximum number of ASCII characters to concatenate from
1421 IN OUT CHAR8
*Destination
,
1422 IN CONST CHAR8
*Source
,
1428 Returns the first occurrence of a Null-terminated ASCII sub-string
1429 in a Null-terminated ASCII string.
1431 This function scans the contents of the ASCII string specified by String
1432 and returns the first occurrence of SearchString. If SearchString is not
1433 found in String, then NULL is returned. If the length of SearchString is zero,
1434 then String is returned.
1436 If String is NULL, then ASSERT().
1437 If SearchString is NULL, then ASSERT().
1439 If PcdMaximumAsciiStringLength is not zero, and SearchString or
1440 String contains more than PcdMaximumAsciiStringLength Unicode characters
1441 not including the Null-terminator, then ASSERT().
1443 @param String The pointer to a Null-terminated ASCII string.
1444 @param SearchString The pointer to a Null-terminated ASCII string to search for.
1446 @retval NULL If the SearchString does not appear in String.
1447 @retval others If there is a match return the first occurrence of SearchingString.
1448 If the length of SearchString is zero,return String.
1454 IN CONST CHAR8
*String
,
1455 IN CONST CHAR8
*SearchString
1460 Convert a Null-terminated ASCII decimal string to a value of type
1463 This function returns a value of type UINTN by interpreting the contents
1464 of the ASCII string String as a decimal number. The format of the input
1465 ASCII string String is:
1467 [spaces] [decimal digits].
1469 The valid decimal digit character is in the range [0-9]. The function will
1470 ignore the pad space, which includes spaces or tab characters, before the digits.
1471 The running zero in the beginning of [decimal digits] will be ignored. Then, the
1472 function stops at the first character that is a not a valid decimal character or
1473 Null-terminator, whichever on comes first.
1475 If String has only pad spaces, then 0 is returned.
1476 If String has no pad spaces or valid decimal digits, then 0 is returned.
1477 If the number represented by String overflows according to the range defined by
1478 UINTN, then ASSERT().
1479 If String is NULL, then ASSERT().
1480 If PcdMaximumAsciiStringLength is not zero, and String contains more than
1481 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
1484 @param String The pointer to a Null-terminated ASCII string.
1486 @retval The value translated from String.
1491 AsciiStrDecimalToUintn (
1492 IN CONST CHAR8
*String
1497 Convert a Null-terminated ASCII decimal string to a value of type
1500 This function returns a value of type UINT64 by interpreting the contents
1501 of the ASCII string String as a decimal number. The format of the input
1502 ASCII string String is:
1504 [spaces] [decimal digits].
1506 The valid decimal digit character is in the range [0-9]. The function will
1507 ignore the pad space, which includes spaces or tab characters, before the digits.
1508 The running zero in the beginning of [decimal digits] will be ignored. Then, the
1509 function stops at the first character that is a not a valid decimal character or
1510 Null-terminator, whichever on comes first.
1512 If String has only pad spaces, then 0 is returned.
1513 If String has no pad spaces or valid decimal digits, then 0 is returned.
1514 If the number represented by String overflows according to the range defined by
1515 UINT64, then ASSERT().
1516 If String is NULL, then ASSERT().
1517 If PcdMaximumAsciiStringLength is not zero, and String contains more than
1518 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
1521 @param String The pointer to a Null-terminated ASCII string.
1523 @retval Value translated from String.
1528 AsciiStrDecimalToUint64 (
1529 IN CONST CHAR8
*String
1534 Convert a Null-terminated ASCII hexadecimal string to a value of type UINTN.
1536 This function returns a value of type UINTN by interpreting the contents of
1537 the ASCII string String as a hexadecimal number. The format of the input ASCII
1540 [spaces][zeros][x][hexadecimal digits].
1542 The valid hexadecimal digit character is in the range [0-9], [a-f] and [A-F].
1543 The prefix "0x" is optional. Both "x" and "X" is allowed in "0x" prefix. If "x"
1544 appears in the input string, it must be prefixed with at least one 0. The function
1545 will ignore the pad space, which includes spaces or tab characters, before [zeros],
1546 [x] or [hexadecimal digits]. The running zero before [x] or [hexadecimal digits]
1547 will be ignored. Then, the decoding starts after [x] or the first valid hexadecimal
1548 digit. Then, the function stops at the first character that is a not a valid
1549 hexadecimal character or Null-terminator, whichever on comes first.
1551 If String has only pad spaces, then 0 is returned.
1552 If String has no leading pad spaces, leading zeros or valid hexadecimal digits, then
1555 If the number represented by String overflows according to the range defined by UINTN,
1557 If String is NULL, then ASSERT().
1558 If PcdMaximumAsciiStringLength is not zero,
1559 and String contains more than PcdMaximumAsciiStringLength ASCII characters not including
1560 the Null-terminator, then ASSERT().
1562 @param String The pointer to a Null-terminated ASCII string.
1564 @retval Value translated from String.
1569 AsciiStrHexToUintn (
1570 IN CONST CHAR8
*String
1575 Convert a Null-terminated ASCII hexadecimal string to a value of type UINT64.
1577 This function returns a value of type UINT64 by interpreting the contents of
1578 the ASCII string String as a hexadecimal number. The format of the input ASCII
1581 [spaces][zeros][x][hexadecimal digits].
1583 The valid hexadecimal digit character is in the range [0-9], [a-f] and [A-F].
1584 The prefix "0x" is optional. Both "x" and "X" is allowed in "0x" prefix. If "x"
1585 appears in the input string, it must be prefixed with at least one 0. The function
1586 will ignore the pad space, which includes spaces or tab characters, before [zeros],
1587 [x] or [hexadecimal digits]. The running zero before [x] or [hexadecimal digits]
1588 will be ignored. Then, the decoding starts after [x] or the first valid hexadecimal
1589 digit. Then, the function stops at the first character that is a not a valid
1590 hexadecimal character or Null-terminator, whichever on comes first.
1592 If String has only pad spaces, then 0 is returned.
1593 If String has no leading pad spaces, leading zeros or valid hexadecimal digits, then
1596 If the number represented by String overflows according to the range defined by UINT64,
1598 If String is NULL, then ASSERT().
1599 If PcdMaximumAsciiStringLength is not zero,
1600 and String contains more than PcdMaximumAsciiStringLength ASCII characters not including
1601 the Null-terminator, then ASSERT().
1603 @param String The pointer to a Null-terminated ASCII string.
1605 @retval Value translated from String.
1610 AsciiStrHexToUint64 (
1611 IN CONST CHAR8
*String
1616 Convert one Null-terminated ASCII string to a Null-terminated
1617 Unicode string and returns the Unicode string.
1619 This function converts the contents of the ASCII string Source to the Unicode
1620 string Destination, and returns Destination. The function terminates the
1621 Unicode string Destination by appending a Null-terminator character at the end.
1622 The caller is responsible to make sure Destination points to a buffer with size
1623 equal or greater than ((AsciiStrLen (Source) + 1) * sizeof (CHAR16)) in bytes.
1625 If Destination is NULL, then ASSERT().
1626 If Destination is not aligned on a 16-bit boundary, then ASSERT().
1627 If Source is NULL, then ASSERT().
1628 If Source and Destination overlap, then ASSERT().
1629 If PcdMaximumAsciiStringLength is not zero, and Source contains more than
1630 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
1632 If PcdMaximumUnicodeStringLength is not zero, and Source contains more than
1633 PcdMaximumUnicodeStringLength ASCII characters not including the
1634 Null-terminator, then ASSERT().
1636 @param Source The pointer to a Null-terminated ASCII string.
1637 @param Destination The pointer to a Null-terminated Unicode string.
1639 @return Destination.
1644 AsciiStrToUnicodeStr (
1645 IN CONST CHAR8
*Source
,
1646 OUT CHAR16
*Destination
1650 Convert one Null-terminated ASCII string to a Null-terminated
1653 This function is similar to StrCpyS.
1655 This function converts the contents of the ASCII string Source to the Unicode
1656 string Destination. The function terminates the Unicode string Destination by
1657 appending a Null-terminator character at the end.
1659 The caller is responsible to make sure Destination points to a buffer with size
1660 equal or greater than ((AsciiStrLen (Source) + 1) * sizeof (CHAR16)) in bytes.
1662 If Destination is not aligned on a 16-bit boundary, then ASSERT().
1663 If an error would be returned, then the function will also ASSERT().
1665 If an error is returned, then the Destination is unmodified.
1667 @param Source The pointer to a Null-terminated ASCII string.
1668 @param Destination The pointer to a Null-terminated Unicode string.
1669 @param DestMax The maximum number of Destination Unicode
1670 char, including terminating null char.
1672 @retval RETURN_SUCCESS String is converted.
1673 @retval RETURN_BUFFER_TOO_SMALL If DestMax is NOT greater than StrLen(Source).
1674 @retval RETURN_INVALID_PARAMETER If Destination is NULL.
1676 If PcdMaximumUnicodeStringLength is not zero,
1677 and DestMax is greater than
1678 PcdMaximumUnicodeStringLength.
1679 If PcdMaximumAsciiStringLength is not zero,
1680 and DestMax is greater than
1681 PcdMaximumAsciiStringLength.
1683 @retval RETURN_ACCESS_DENIED If Source and Destination overlap.
1688 AsciiStrToUnicodeStrS (
1689 IN CONST CHAR8
*Source
,
1690 OUT CHAR16
*Destination
,
1695 Converts an 8-bit value to an 8-bit BCD value.
1697 Converts the 8-bit value specified by Value to BCD. The BCD value is
1700 If Value >= 100, then ASSERT().
1702 @param Value The 8-bit value to convert to BCD. Range 0..99.
1704 @return The BCD value.
1715 Converts an 8-bit BCD value to an 8-bit value.
1717 Converts the 8-bit BCD value specified by Value to an 8-bit value. The 8-bit
1720 If Value >= 0xA0, then ASSERT().
1721 If (Value & 0x0F) >= 0x0A, then ASSERT().
1723 @param Value The 8-bit BCD value to convert to an 8-bit value.
1725 @return The 8-bit value is returned.
1735 // File Path Manipulation Functions
1739 Removes the last directory or file entry in a path by changing the last
1740 L'\' to a CHAR_NULL.
1742 @param[in, out] Path The pointer to the path to modify.
1744 @retval FALSE Nothing was found to remove.
1745 @retval TRUE A directory or file was removed.
1754 Function to clean up paths.
1755 - Single periods in the path are removed.
1756 - Double periods in the path are removed along with a single parent directory.
1757 - Forward slashes L'/' are converted to backward slashes L'\'.
1759 This will be done inline and the existing buffer may be larger than required
1762 @param[in] Path The pointer to the string containing the path.
1764 @return Returns Path, otherwise returns NULL to indicate that an error has occured.
1768 PathCleanUpDirectories(
1773 // Linked List Functions and Macros
1777 Initializes the head node of a doubly linked list that is declared as a
1778 global variable in a module.
1780 Initializes the forward and backward links of a new linked list. After
1781 initializing a linked list with this macro, the other linked list functions
1782 may be used to add and remove nodes from the linked list. This macro results
1783 in smaller executables by initializing the linked list in the data section,
1784 instead if calling the InitializeListHead() function to perform the
1785 equivalent operation.
1787 @param ListHead The head note of a list to initialize.
1790 #define INITIALIZE_LIST_HEAD_VARIABLE(ListHead) {&(ListHead), &(ListHead)}
1794 Initializes the head node of a doubly linked list, and returns the pointer to
1795 the head node of the doubly linked list.
1797 Initializes the forward and backward links of a new linked list. After
1798 initializing a linked list with this function, the other linked list
1799 functions may be used to add and remove nodes from the linked list. It is up
1800 to the caller of this function to allocate the memory for ListHead.
1802 If ListHead is NULL, then ASSERT().
1804 @param ListHead A pointer to the head node of a new doubly linked list.
1811 InitializeListHead (
1812 IN OUT LIST_ENTRY
*ListHead
1817 Adds a node to the beginning of a doubly linked list, and returns the pointer
1818 to the head node of the doubly linked list.
1820 Adds the node Entry at the beginning of the doubly linked list denoted by
1821 ListHead, and returns ListHead.
1823 If ListHead is NULL, then ASSERT().
1824 If Entry is NULL, then ASSERT().
1825 If ListHead was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or
1826 InitializeListHead(), then ASSERT().
1827 If PcdMaximumLinkedListLength is not zero, and prior to insertion the number
1828 of nodes in ListHead, including the ListHead node, is greater than or
1829 equal to PcdMaximumLinkedListLength, then ASSERT().
1831 @param ListHead A pointer to the head node of a doubly linked list.
1832 @param Entry A pointer to a node that is to be inserted at the beginning
1833 of a doubly linked list.
1841 IN OUT LIST_ENTRY
*ListHead
,
1842 IN OUT LIST_ENTRY
*Entry
1847 Adds a node to the end of a doubly linked list, and returns the pointer to
1848 the head node of the doubly linked list.
1850 Adds the node Entry to the end of the doubly linked list denoted by ListHead,
1851 and returns ListHead.
1853 If ListHead is NULL, then ASSERT().
1854 If Entry is NULL, then ASSERT().
1855 If ListHead was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or
1856 InitializeListHead(), then ASSERT().
1857 If PcdMaximumLinkedListLength is not zero, and prior to insertion the number
1858 of nodes in ListHead, including the ListHead node, is greater than or
1859 equal to PcdMaximumLinkedListLength, then ASSERT().
1861 @param ListHead A pointer to the head node of a doubly linked list.
1862 @param Entry A pointer to a node that is to be added at the end of the
1871 IN OUT LIST_ENTRY
*ListHead
,
1872 IN OUT LIST_ENTRY
*Entry
1877 Retrieves the first node of a doubly linked list.
1879 Returns the first node of a doubly linked list. List must have been
1880 initialized with INTIALIZE_LIST_HEAD_VARIABLE() or InitializeListHead().
1881 If List is empty, then List is returned.
1883 If List is NULL, then ASSERT().
1884 If List was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or
1885 InitializeListHead(), then ASSERT().
1886 If PcdMaximumLinkedListLength is not zero, and the number of nodes
1887 in List, including the List node, is greater than or equal to
1888 PcdMaximumLinkedListLength, then ASSERT().
1890 @param List A pointer to the head node of a doubly linked list.
1892 @return The first node of a doubly linked list.
1893 @retval List The list is empty.
1899 IN CONST LIST_ENTRY
*List
1904 Retrieves the next node of a doubly linked list.
1906 Returns the node of a doubly linked list that follows Node.
1907 List must have been initialized with INTIALIZE_LIST_HEAD_VARIABLE()
1908 or InitializeListHead(). If List is empty, then List is returned.
1910 If List is NULL, then ASSERT().
1911 If Node is NULL, then ASSERT().
1912 If List was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or
1913 InitializeListHead(), then ASSERT().
1914 If PcdMaximumLinkedListLength is not zero, and List contains more than
1915 PcdMaximumLinkedListLength nodes, then ASSERT().
1916 If PcdVerifyNodeInList is TRUE and Node is not a node in List, then ASSERT().
1918 @param List A pointer to the head node of a doubly linked list.
1919 @param Node A pointer to a node in the doubly linked list.
1921 @return The pointer to the next node if one exists. Otherwise List is returned.
1927 IN CONST LIST_ENTRY
*List
,
1928 IN CONST LIST_ENTRY
*Node
1933 Retrieves the previous node of a doubly linked list.
1935 Returns the node of a doubly linked list that precedes Node.
1936 List must have been initialized with INTIALIZE_LIST_HEAD_VARIABLE()
1937 or InitializeListHead(). If List is empty, then List is returned.
1939 If List is NULL, then ASSERT().
1940 If Node is NULL, then ASSERT().
1941 If List was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or
1942 InitializeListHead(), then ASSERT().
1943 If PcdMaximumLinkedListLength is not zero, and List contains more than
1944 PcdMaximumLinkedListLength nodes, then ASSERT().
1945 If PcdVerifyNodeInList is TRUE and Node is not a node in List, then ASSERT().
1947 @param List A pointer to the head node of a doubly linked list.
1948 @param Node A pointer to a node in the doubly linked list.
1950 @return The pointer to the previous node if one exists. Otherwise List is returned.
1956 IN CONST LIST_ENTRY
*List
,
1957 IN CONST LIST_ENTRY
*Node
1962 Checks to see if a doubly linked list is empty or not.
1964 Checks to see if the doubly linked list is empty. If the linked list contains
1965 zero nodes, this function returns TRUE. Otherwise, it returns FALSE.
1967 If ListHead is NULL, then ASSERT().
1968 If ListHead was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or
1969 InitializeListHead(), then ASSERT().
1970 If PcdMaximumLinkedListLength is not zero, and the number of nodes
1971 in List, including the List node, is greater than or equal to
1972 PcdMaximumLinkedListLength, then ASSERT().
1974 @param ListHead A pointer to the head node of a doubly linked list.
1976 @retval TRUE The linked list is empty.
1977 @retval FALSE The linked list is not empty.
1983 IN CONST LIST_ENTRY
*ListHead
1988 Determines if a node in a doubly linked list is the head node of a the same
1989 doubly linked list. This function is typically used to terminate a loop that
1990 traverses all the nodes in a doubly linked list starting with the head node.
1992 Returns TRUE if Node is equal to List. Returns FALSE if Node is one of the
1993 nodes in the doubly linked list specified by List. List must have been
1994 initialized with INTIALIZE_LIST_HEAD_VARIABLE() or InitializeListHead().
1996 If List is NULL, then ASSERT().
1997 If Node is NULL, then ASSERT().
1998 If List was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or InitializeListHead(),
2000 If PcdMaximumLinkedListLength is not zero, and the number of nodes
2001 in List, including the List node, is greater than or equal to
2002 PcdMaximumLinkedListLength, then ASSERT().
2003 If PcdVerifyNodeInList is TRUE and Node is not a node in List the and Node is not equal
2004 to List, then ASSERT().
2006 @param List A pointer to the head node of a doubly linked list.
2007 @param Node A pointer to a node in the doubly linked list.
2009 @retval TRUE Node is the head of the doubly-linked list pointed by List.
2010 @retval FALSE Node is not the head of the doubly-linked list pointed by List.
2016 IN CONST LIST_ENTRY
*List
,
2017 IN CONST LIST_ENTRY
*Node
2022 Determines if a node the last node in a doubly linked list.
2024 Returns TRUE if Node is the last node in the doubly linked list specified by
2025 List. Otherwise, FALSE is returned. List must have been initialized with
2026 INTIALIZE_LIST_HEAD_VARIABLE() or InitializeListHead().
2028 If List is NULL, then ASSERT().
2029 If Node is NULL, then ASSERT().
2030 If List was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or
2031 InitializeListHead(), then ASSERT().
2032 If PcdMaximumLinkedListLength is not zero, and the number of nodes
2033 in List, including the List node, is greater than or equal to
2034 PcdMaximumLinkedListLength, then ASSERT().
2035 If PcdVerifyNodeInList is TRUE and Node is not a node in List, then ASSERT().
2037 @param List A pointer to the head node of a doubly linked list.
2038 @param Node A pointer to a node in the doubly linked list.
2040 @retval TRUE Node is the last node in the linked list.
2041 @retval FALSE Node is not the last node in the linked list.
2047 IN CONST LIST_ENTRY
*List
,
2048 IN CONST LIST_ENTRY
*Node
2053 Swaps the location of two nodes in a doubly linked list, and returns the
2054 first node after the swap.
2056 If FirstEntry is identical to SecondEntry, then SecondEntry is returned.
2057 Otherwise, the location of the FirstEntry node is swapped with the location
2058 of the SecondEntry node in a doubly linked list. SecondEntry must be in the
2059 same double linked list as FirstEntry and that double linked list must have
2060 been initialized with INTIALIZE_LIST_HEAD_VARIABLE() or InitializeListHead().
2061 SecondEntry is returned after the nodes are swapped.
2063 If FirstEntry is NULL, then ASSERT().
2064 If SecondEntry is NULL, then ASSERT().
2065 If PcdVerifyNodeInList is TRUE and SecondEntry and FirstEntry are not in the
2066 same linked list, then ASSERT().
2067 If PcdMaximumLinkedListLength is not zero, and the number of nodes in the
2068 linked list containing the FirstEntry and SecondEntry nodes, including
2069 the FirstEntry and SecondEntry nodes, is greater than or equal to
2070 PcdMaximumLinkedListLength, then ASSERT().
2072 @param FirstEntry A pointer to a node in a linked list.
2073 @param SecondEntry A pointer to another node in the same linked list.
2075 @return SecondEntry.
2081 IN OUT LIST_ENTRY
*FirstEntry
,
2082 IN OUT LIST_ENTRY
*SecondEntry
2087 Removes a node from a doubly linked list, and returns the node that follows
2090 Removes the node Entry from a doubly linked list. It is up to the caller of
2091 this function to release the memory used by this node if that is required. On
2092 exit, the node following Entry in the doubly linked list is returned. If
2093 Entry is the only node in the linked list, then the head node of the linked
2096 If Entry is NULL, then ASSERT().
2097 If Entry is the head node of an empty list, then ASSERT().
2098 If PcdMaximumLinkedListLength is not zero, and the number of nodes in the
2099 linked list containing Entry, including the Entry node, is greater than
2100 or equal to PcdMaximumLinkedListLength, then ASSERT().
2102 @param Entry A pointer to a node in a linked list.
2110 IN CONST LIST_ENTRY
*Entry
2118 Shifts a 64-bit integer left between 0 and 63 bits. The low bits are filled
2119 with zeros. The shifted value is returned.
2121 This function shifts the 64-bit value Operand to the left by Count bits. The
2122 low Count bits are set to zero. The shifted value is returned.
2124 If Count is greater than 63, then ASSERT().
2126 @param Operand The 64-bit operand to shift left.
2127 @param Count The number of bits to shift left.
2129 @return Operand << Count.
2141 Shifts a 64-bit integer right between 0 and 63 bits. This high bits are
2142 filled with zeros. The shifted value is returned.
2144 This function shifts the 64-bit value Operand to the right by Count bits. The
2145 high Count bits are set to zero. The shifted value is returned.
2147 If Count is greater than 63, then ASSERT().
2149 @param Operand The 64-bit operand to shift right.
2150 @param Count The number of bits to shift right.
2152 @return Operand >> Count
2164 Shifts a 64-bit integer right between 0 and 63 bits. The high bits are filled
2165 with original integer's bit 63. The shifted value is returned.
2167 This function shifts the 64-bit value Operand to the right by Count bits. The
2168 high Count bits are set to bit 63 of Operand. The shifted value is returned.
2170 If Count is greater than 63, then ASSERT().
2172 @param Operand The 64-bit operand to shift right.
2173 @param Count The number of bits to shift right.
2175 @return Operand >> Count
2187 Rotates a 32-bit integer left between 0 and 31 bits, filling the low bits
2188 with the high bits that were rotated.
2190 This function rotates the 32-bit value Operand to the left by Count bits. The
2191 low Count bits are fill with the high Count bits of Operand. The rotated
2194 If Count is greater than 31, then ASSERT().
2196 @param Operand The 32-bit operand to rotate left.
2197 @param Count The number of bits to rotate left.
2199 @return Operand << Count
2211 Rotates a 32-bit integer right between 0 and 31 bits, filling the high bits
2212 with the low bits that were rotated.
2214 This function rotates the 32-bit value Operand to the right by Count bits.
2215 The high Count bits are fill with the low Count bits of Operand. The rotated
2218 If Count is greater than 31, then ASSERT().
2220 @param Operand The 32-bit operand to rotate right.
2221 @param Count The number of bits to rotate right.
2223 @return Operand >> Count
2235 Rotates a 64-bit integer left between 0 and 63 bits, filling the low bits
2236 with the high bits that were rotated.
2238 This function rotates the 64-bit value Operand to the left by Count bits. The
2239 low Count bits are fill with the high Count bits of Operand. The rotated
2242 If Count is greater than 63, then ASSERT().
2244 @param Operand The 64-bit operand to rotate left.
2245 @param Count The number of bits to rotate left.
2247 @return Operand << Count
2259 Rotates a 64-bit integer right between 0 and 63 bits, filling the high bits
2260 with the high low bits that were rotated.
2262 This function rotates the 64-bit value Operand to the right by Count bits.
2263 The high Count bits are fill with the low Count bits of Operand. The rotated
2266 If Count is greater than 63, then ASSERT().
2268 @param Operand The 64-bit operand to rotate right.
2269 @param Count The number of bits to rotate right.
2271 @return Operand >> Count
2283 Returns the bit position of the lowest bit set in a 32-bit value.
2285 This function computes the bit position of the lowest bit set in the 32-bit
2286 value specified by Operand. If Operand is zero, then -1 is returned.
2287 Otherwise, a value between 0 and 31 is returned.
2289 @param Operand The 32-bit operand to evaluate.
2291 @retval 0..31 The lowest bit set in Operand was found.
2292 @retval -1 Operand is zero.
2303 Returns the bit position of the lowest bit set in a 64-bit value.
2305 This function computes the bit position of the lowest bit set in the 64-bit
2306 value specified by Operand. If Operand is zero, then -1 is returned.
2307 Otherwise, a value between 0 and 63 is returned.
2309 @param Operand The 64-bit operand to evaluate.
2311 @retval 0..63 The lowest bit set in Operand was found.
2312 @retval -1 Operand is zero.
2324 Returns the bit position of the highest bit set in a 32-bit value. Equivalent
2327 This function computes the bit position of the highest bit set in the 32-bit
2328 value specified by Operand. If Operand is zero, then -1 is returned.
2329 Otherwise, a value between 0 and 31 is returned.
2331 @param Operand The 32-bit operand to evaluate.
2333 @retval 0..31 Position of the highest bit set in Operand if found.
2334 @retval -1 Operand is zero.
2345 Returns the bit position of the highest bit set in a 64-bit value. Equivalent
2348 This function computes the bit position of the highest bit set in the 64-bit
2349 value specified by Operand. If Operand is zero, then -1 is returned.
2350 Otherwise, a value between 0 and 63 is returned.
2352 @param Operand The 64-bit operand to evaluate.
2354 @retval 0..63 Position of the highest bit set in Operand if found.
2355 @retval -1 Operand is zero.
2366 Returns the value of the highest bit set in a 32-bit value. Equivalent to
2369 This function computes the value of the highest bit set in the 32-bit value
2370 specified by Operand. If Operand is zero, then zero is returned.
2372 @param Operand The 32-bit operand to evaluate.
2374 @return 1 << HighBitSet32(Operand)
2375 @retval 0 Operand is zero.
2386 Returns the value of the highest bit set in a 64-bit value. Equivalent to
2389 This function computes the value of the highest bit set in the 64-bit value
2390 specified by Operand. If Operand is zero, then zero is returned.
2392 @param Operand The 64-bit operand to evaluate.
2394 @return 1 << HighBitSet64(Operand)
2395 @retval 0 Operand is zero.
2406 Switches the endianness of a 16-bit integer.
2408 This function swaps the bytes in a 16-bit unsigned value to switch the value
2409 from little endian to big endian or vice versa. The byte swapped value is
2412 @param Value A 16-bit unsigned value.
2414 @return The byte swapped Value.
2425 Switches the endianness of a 32-bit integer.
2427 This function swaps the bytes in a 32-bit unsigned value to switch the value
2428 from little endian to big endian or vice versa. The byte swapped value is
2431 @param Value A 32-bit unsigned value.
2433 @return The byte swapped Value.
2444 Switches the endianness of a 64-bit integer.
2446 This function swaps the bytes in a 64-bit unsigned value to switch the value
2447 from little endian to big endian or vice versa. The byte swapped value is
2450 @param Value A 64-bit unsigned value.
2452 @return The byte swapped Value.
2463 Multiples a 64-bit unsigned integer by a 32-bit unsigned integer and
2464 generates a 64-bit unsigned result.
2466 This function multiples the 64-bit unsigned value Multiplicand by the 32-bit
2467 unsigned value Multiplier and generates a 64-bit unsigned result. This 64-
2468 bit unsigned result is returned.
2470 @param Multiplicand A 64-bit unsigned value.
2471 @param Multiplier A 32-bit unsigned value.
2473 @return Multiplicand * Multiplier
2479 IN UINT64 Multiplicand
,
2480 IN UINT32 Multiplier
2485 Multiples a 64-bit unsigned integer by a 64-bit unsigned integer and
2486 generates a 64-bit unsigned result.
2488 This function multiples the 64-bit unsigned value Multiplicand by the 64-bit
2489 unsigned value Multiplier and generates a 64-bit unsigned result. This 64-
2490 bit unsigned result is returned.
2492 @param Multiplicand A 64-bit unsigned value.
2493 @param Multiplier A 64-bit unsigned value.
2495 @return Multiplicand * Multiplier.
2501 IN UINT64 Multiplicand
,
2502 IN UINT64 Multiplier
2507 Multiples a 64-bit signed integer by a 64-bit signed integer and generates a
2508 64-bit signed result.
2510 This function multiples the 64-bit signed value Multiplicand by the 64-bit
2511 signed value Multiplier and generates a 64-bit signed result. This 64-bit
2512 signed result is returned.
2514 @param Multiplicand A 64-bit signed value.
2515 @param Multiplier A 64-bit signed value.
2517 @return Multiplicand * Multiplier
2523 IN INT64 Multiplicand
,
2529 Divides a 64-bit unsigned integer by a 32-bit unsigned integer and generates
2530 a 64-bit unsigned result.
2532 This function divides the 64-bit unsigned value Dividend by the 32-bit
2533 unsigned value Divisor and generates a 64-bit unsigned quotient. This
2534 function returns the 64-bit unsigned quotient.
2536 If Divisor is 0, then ASSERT().
2538 @param Dividend A 64-bit unsigned value.
2539 @param Divisor A 32-bit unsigned value.
2541 @return Dividend / Divisor.
2553 Divides a 64-bit unsigned integer by a 32-bit unsigned integer and generates
2554 a 32-bit unsigned remainder.
2556 This function divides the 64-bit unsigned value Dividend by the 32-bit
2557 unsigned value Divisor and generates a 32-bit remainder. This function
2558 returns the 32-bit unsigned remainder.
2560 If Divisor is 0, then ASSERT().
2562 @param Dividend A 64-bit unsigned value.
2563 @param Divisor A 32-bit unsigned value.
2565 @return Dividend % Divisor.
2577 Divides a 64-bit unsigned integer by a 32-bit unsigned integer and generates
2578 a 64-bit unsigned result and an optional 32-bit unsigned remainder.
2580 This function divides the 64-bit unsigned value Dividend by the 32-bit
2581 unsigned value Divisor and generates a 64-bit unsigned quotient. If Remainder
2582 is not NULL, then the 32-bit unsigned remainder is returned in Remainder.
2583 This function returns the 64-bit unsigned quotient.
2585 If Divisor is 0, then ASSERT().
2587 @param Dividend A 64-bit unsigned value.
2588 @param Divisor A 32-bit unsigned value.
2589 @param Remainder A pointer to a 32-bit unsigned value. This parameter is
2590 optional and may be NULL.
2592 @return Dividend / Divisor.
2597 DivU64x32Remainder (
2600 OUT UINT32
*Remainder OPTIONAL
2605 Divides a 64-bit unsigned integer by a 64-bit unsigned integer and generates
2606 a 64-bit unsigned result and an optional 64-bit unsigned remainder.
2608 This function divides the 64-bit unsigned value Dividend by the 64-bit
2609 unsigned value Divisor and generates a 64-bit unsigned quotient. If Remainder
2610 is not NULL, then the 64-bit unsigned remainder is returned in Remainder.
2611 This function returns the 64-bit unsigned quotient.
2613 If Divisor is 0, then ASSERT().
2615 @param Dividend A 64-bit unsigned value.
2616 @param Divisor A 64-bit unsigned value.
2617 @param Remainder A pointer to a 64-bit unsigned value. This parameter is
2618 optional and may be NULL.
2620 @return Dividend / Divisor.
2625 DivU64x64Remainder (
2628 OUT UINT64
*Remainder OPTIONAL
2633 Divides a 64-bit signed integer by a 64-bit signed integer and generates a
2634 64-bit signed result and a optional 64-bit signed remainder.
2636 This function divides the 64-bit signed value Dividend by the 64-bit signed
2637 value Divisor and generates a 64-bit signed quotient. If Remainder is not
2638 NULL, then the 64-bit signed remainder is returned in Remainder. This
2639 function returns the 64-bit signed quotient.
2641 It is the caller's responsibility to not call this function with a Divisor of 0.
2642 If Divisor is 0, then the quotient and remainder should be assumed to be
2643 the largest negative integer.
2645 If Divisor is 0, then ASSERT().
2647 @param Dividend A 64-bit signed value.
2648 @param Divisor A 64-bit signed value.
2649 @param Remainder A pointer to a 64-bit signed value. This parameter is
2650 optional and may be NULL.
2652 @return Dividend / Divisor.
2657 DivS64x64Remainder (
2660 OUT INT64
*Remainder OPTIONAL
2665 Reads a 16-bit value from memory that may be unaligned.
2667 This function returns the 16-bit value pointed to by Buffer. The function
2668 guarantees that the read operation does not produce an alignment fault.
2670 If the Buffer is NULL, then ASSERT().
2672 @param Buffer The pointer to a 16-bit value that may be unaligned.
2674 @return The 16-bit value read from Buffer.
2680 IN CONST UINT16
*Buffer
2685 Writes a 16-bit value to memory that may be unaligned.
2687 This function writes the 16-bit value specified by Value to Buffer. Value is
2688 returned. The function guarantees that the write operation does not produce
2691 If the Buffer is NULL, then ASSERT().
2693 @param Buffer The pointer to a 16-bit value that may be unaligned.
2694 @param Value 16-bit value to write to Buffer.
2696 @return The 16-bit value to write to Buffer.
2708 Reads a 24-bit value from memory that may be unaligned.
2710 This function returns the 24-bit value pointed to by Buffer. The function
2711 guarantees that the read operation does not produce an alignment fault.
2713 If the Buffer is NULL, then ASSERT().
2715 @param Buffer The pointer to a 24-bit value that may be unaligned.
2717 @return The 24-bit value read from Buffer.
2723 IN CONST UINT32
*Buffer
2728 Writes a 24-bit value to memory that may be unaligned.
2730 This function writes the 24-bit value specified by Value to Buffer. Value is
2731 returned. The function guarantees that the write operation does not produce
2734 If the Buffer is NULL, then ASSERT().
2736 @param Buffer The pointer to a 24-bit value that may be unaligned.
2737 @param Value 24-bit value to write to Buffer.
2739 @return The 24-bit value to write to Buffer.
2751 Reads a 32-bit value from memory that may be unaligned.
2753 This function returns the 32-bit value pointed to by Buffer. The function
2754 guarantees that the read operation does not produce an alignment fault.
2756 If the Buffer is NULL, then ASSERT().
2758 @param Buffer The pointer to a 32-bit value that may be unaligned.
2760 @return The 32-bit value read from Buffer.
2766 IN CONST UINT32
*Buffer
2771 Writes a 32-bit value to memory that may be unaligned.
2773 This function writes the 32-bit value specified by Value to Buffer. Value is
2774 returned. The function guarantees that the write operation does not produce
2777 If the Buffer is NULL, then ASSERT().
2779 @param Buffer The pointer to a 32-bit value that may be unaligned.
2780 @param Value 32-bit value to write to Buffer.
2782 @return The 32-bit value to write to Buffer.
2794 Reads a 64-bit value from memory that may be unaligned.
2796 This function returns the 64-bit value pointed to by Buffer. The function
2797 guarantees that the read operation does not produce an alignment fault.
2799 If the Buffer is NULL, then ASSERT().
2801 @param Buffer The pointer to a 64-bit value that may be unaligned.
2803 @return The 64-bit value read from Buffer.
2809 IN CONST UINT64
*Buffer
2814 Writes a 64-bit value to memory that may be unaligned.
2816 This function writes the 64-bit value specified by Value to Buffer. Value is
2817 returned. The function guarantees that the write operation does not produce
2820 If the Buffer is NULL, then ASSERT().
2822 @param Buffer The pointer to a 64-bit value that may be unaligned.
2823 @param Value 64-bit value to write to Buffer.
2825 @return The 64-bit value to write to Buffer.
2837 // Bit Field Functions
2841 Returns a bit field from an 8-bit value.
2843 Returns the bitfield specified by the StartBit and the EndBit from Operand.
2845 If 8-bit operations are not supported, then ASSERT().
2846 If StartBit is greater than 7, then ASSERT().
2847 If EndBit is greater than 7, then ASSERT().
2848 If EndBit is less than StartBit, then ASSERT().
2850 @param Operand Operand on which to perform the bitfield operation.
2851 @param StartBit The ordinal of the least significant bit in the bit field.
2853 @param EndBit The ordinal of the most significant bit in the bit field.
2856 @return The bit field read.
2869 Writes a bit field to an 8-bit value, and returns the result.
2871 Writes Value to the bit field specified by the StartBit and the EndBit in
2872 Operand. All other bits in Operand are preserved. The new 8-bit value is
2875 If 8-bit operations are not supported, then ASSERT().
2876 If StartBit is greater than 7, then ASSERT().
2877 If EndBit is greater than 7, then ASSERT().
2878 If EndBit is less than StartBit, then ASSERT().
2879 If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
2881 @param Operand Operand on which to perform the bitfield operation.
2882 @param StartBit The ordinal of the least significant bit in the bit field.
2884 @param EndBit The ordinal of the most significant bit in the bit field.
2886 @param Value New value of the bit field.
2888 @return The new 8-bit value.
2902 Reads a bit field from an 8-bit value, performs a bitwise OR, and returns the
2905 Performs a bitwise OR between the bit field specified by StartBit
2906 and EndBit in Operand and the value specified by OrData. All other bits in
2907 Operand are preserved. The new 8-bit value is returned.
2909 If 8-bit operations are not supported, then ASSERT().
2910 If StartBit is greater than 7, then ASSERT().
2911 If EndBit is greater than 7, then ASSERT().
2912 If EndBit is less than StartBit, then ASSERT().
2913 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
2915 @param Operand Operand on which to perform the bitfield operation.
2916 @param StartBit The ordinal of the least significant bit in the bit field.
2918 @param EndBit The ordinal of the most significant bit in the bit field.
2920 @param OrData The value to OR with the read value from the value
2922 @return The new 8-bit value.
2936 Reads a bit field from an 8-bit value, performs a bitwise AND, and returns
2939 Performs a bitwise AND between the bit field specified by StartBit and EndBit
2940 in Operand and the value specified by AndData. All other bits in Operand are
2941 preserved. The new 8-bit value is returned.
2943 If 8-bit operations are not supported, then ASSERT().
2944 If StartBit is greater than 7, then ASSERT().
2945 If EndBit is greater than 7, then ASSERT().
2946 If EndBit is less than StartBit, then ASSERT().
2947 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
2949 @param Operand Operand on which to perform the bitfield operation.
2950 @param StartBit The ordinal of the least significant bit in the bit field.
2952 @param EndBit The ordinal of the most significant bit in the bit field.
2954 @param AndData The value to AND with the read value from the value.
2956 @return The new 8-bit value.
2970 Reads a bit field from an 8-bit value, performs a bitwise AND followed by a
2971 bitwise OR, and returns the result.
2973 Performs a bitwise AND between the bit field specified by StartBit and EndBit
2974 in Operand and the value specified by AndData, followed by a bitwise
2975 OR with value specified by OrData. All other bits in Operand are
2976 preserved. The new 8-bit value is returned.
2978 If 8-bit operations are not supported, then ASSERT().
2979 If StartBit is greater than 7, then ASSERT().
2980 If EndBit is greater than 7, then ASSERT().
2981 If EndBit is less than StartBit, then ASSERT().
2982 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
2983 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
2985 @param Operand Operand on which to perform the bitfield operation.
2986 @param StartBit The ordinal of the least significant bit in the bit field.
2988 @param EndBit The ordinal of the most significant bit in the bit field.
2990 @param AndData The value to AND with the read value from the value.
2991 @param OrData The value to OR with the result of the AND operation.
2993 @return The new 8-bit value.
2998 BitFieldAndThenOr8 (
3008 Returns a bit field from a 16-bit value.
3010 Returns the bitfield specified by the StartBit and the EndBit from Operand.
3012 If 16-bit operations are not supported, then ASSERT().
3013 If StartBit is greater than 15, then ASSERT().
3014 If EndBit is greater than 15, then ASSERT().
3015 If EndBit is less than StartBit, then ASSERT().
3017 @param Operand Operand on which to perform the bitfield operation.
3018 @param StartBit The ordinal of the least significant bit in the bit field.
3020 @param EndBit The ordinal of the most significant bit in the bit field.
3023 @return The bit field read.
3036 Writes a bit field to a 16-bit value, and returns the result.
3038 Writes Value to the bit field specified by the StartBit and the EndBit in
3039 Operand. All other bits in Operand are preserved. The new 16-bit value is
3042 If 16-bit operations are not supported, then ASSERT().
3043 If StartBit is greater than 15, then ASSERT().
3044 If EndBit is greater than 15, then ASSERT().
3045 If EndBit is less than StartBit, then ASSERT().
3046 If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
3048 @param Operand Operand on which to perform the bitfield operation.
3049 @param StartBit The ordinal of the least significant bit in the bit field.
3051 @param EndBit The ordinal of the most significant bit in the bit field.
3053 @param Value New value of the bit field.
3055 @return The new 16-bit value.
3069 Reads a bit field from a 16-bit value, performs a bitwise OR, and returns the
3072 Performs a bitwise OR between the bit field specified by StartBit
3073 and EndBit in Operand and the value specified by OrData. All other bits in
3074 Operand are preserved. The new 16-bit value is returned.
3076 If 16-bit operations are not supported, then ASSERT().
3077 If StartBit is greater than 15, then ASSERT().
3078 If EndBit is greater than 15, then ASSERT().
3079 If EndBit is less than StartBit, then ASSERT().
3080 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
3082 @param Operand Operand on which to perform the bitfield operation.
3083 @param StartBit The ordinal of the least significant bit in the bit field.
3085 @param EndBit The ordinal of the most significant bit in the bit field.
3087 @param OrData The value to OR with the read value from the value
3089 @return The new 16-bit value.
3103 Reads a bit field from a 16-bit value, performs a bitwise AND, and returns
3106 Performs a bitwise AND between the bit field specified by StartBit and EndBit
3107 in Operand and the value specified by AndData. All other bits in Operand are
3108 preserved. The new 16-bit value is returned.
3110 If 16-bit operations are not supported, then ASSERT().
3111 If StartBit is greater than 15, then ASSERT().
3112 If EndBit is greater than 15, then ASSERT().
3113 If EndBit is less than StartBit, then ASSERT().
3114 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
3116 @param Operand Operand on which to perform the bitfield operation.
3117 @param StartBit The ordinal of the least significant bit in the bit field.
3119 @param EndBit The ordinal of the most significant bit in the bit field.
3121 @param AndData The value to AND with the read value from the value
3123 @return The new 16-bit value.
3137 Reads a bit field from a 16-bit value, performs a bitwise AND followed by a
3138 bitwise OR, and returns the result.
3140 Performs a bitwise AND between the bit field specified by StartBit and EndBit
3141 in Operand and the value specified by AndData, followed by a bitwise
3142 OR with value specified by OrData. All other bits in Operand are
3143 preserved. The new 16-bit value is returned.
3145 If 16-bit operations are not supported, then ASSERT().
3146 If StartBit is greater than 15, then ASSERT().
3147 If EndBit is greater than 15, then ASSERT().
3148 If EndBit is less than StartBit, then ASSERT().
3149 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
3150 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
3152 @param Operand Operand on which to perform the bitfield operation.
3153 @param StartBit The ordinal of the least significant bit in the bit field.
3155 @param EndBit The ordinal of the most significant bit in the bit field.
3157 @param AndData The value to AND with the read value from the value.
3158 @param OrData The value to OR with the result of the AND operation.
3160 @return The new 16-bit value.
3165 BitFieldAndThenOr16 (
3175 Returns a bit field from a 32-bit value.
3177 Returns the bitfield specified by the StartBit and the EndBit from Operand.
3179 If 32-bit operations are not supported, then ASSERT().
3180 If StartBit is greater than 31, then ASSERT().
3181 If EndBit is greater than 31, then ASSERT().
3182 If EndBit is less than StartBit, then ASSERT().
3184 @param Operand Operand on which to perform the bitfield operation.
3185 @param StartBit The ordinal of the least significant bit in the bit field.
3187 @param EndBit The ordinal of the most significant bit in the bit field.
3190 @return The bit field read.
3203 Writes a bit field to a 32-bit value, and returns the result.
3205 Writes Value to the bit field specified by the StartBit and the EndBit in
3206 Operand. All other bits in Operand are preserved. The new 32-bit value is
3209 If 32-bit operations are not supported, then ASSERT().
3210 If StartBit is greater than 31, then ASSERT().
3211 If EndBit is greater than 31, then ASSERT().
3212 If EndBit is less than StartBit, then ASSERT().
3213 If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
3215 @param Operand Operand on which to perform the bitfield operation.
3216 @param StartBit The ordinal of the least significant bit in the bit field.
3218 @param EndBit The ordinal of the most significant bit in the bit field.
3220 @param Value New value of the bit field.
3222 @return The new 32-bit value.
3236 Reads a bit field from a 32-bit value, performs a bitwise OR, and returns the
3239 Performs a bitwise OR between the bit field specified by StartBit
3240 and EndBit in Operand and the value specified by OrData. All other bits in
3241 Operand are preserved. The new 32-bit value is returned.
3243 If 32-bit operations are not supported, then ASSERT().
3244 If StartBit is greater than 31, then ASSERT().
3245 If EndBit is greater than 31, then ASSERT().
3246 If EndBit is less than StartBit, then ASSERT().
3247 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
3249 @param Operand Operand on which to perform the bitfield operation.
3250 @param StartBit The ordinal of the least significant bit in the bit field.
3252 @param EndBit The ordinal of the most significant bit in the bit field.
3254 @param OrData The value to OR with the read value from the value.
3256 @return The new 32-bit value.
3270 Reads a bit field from a 32-bit value, performs a bitwise AND, and returns
3273 Performs a bitwise AND between the bit field specified by StartBit and EndBit
3274 in Operand and the value specified by AndData. All other bits in Operand are
3275 preserved. The new 32-bit value is returned.
3277 If 32-bit operations are not supported, then ASSERT().
3278 If StartBit is greater than 31, then ASSERT().
3279 If EndBit is greater than 31, then ASSERT().
3280 If EndBit is less than StartBit, then ASSERT().
3281 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
3283 @param Operand Operand on which to perform the bitfield operation.
3284 @param StartBit The ordinal of the least significant bit in the bit field.
3286 @param EndBit The ordinal of the most significant bit in the bit field.
3288 @param AndData The value to AND with the read value from the value
3290 @return The new 32-bit value.
3304 Reads a bit field from a 32-bit value, performs a bitwise AND followed by a
3305 bitwise OR, and returns the result.
3307 Performs a bitwise AND between the bit field specified by StartBit and EndBit
3308 in Operand and the value specified by AndData, followed by a bitwise
3309 OR with value specified by OrData. All other bits in Operand are
3310 preserved. The new 32-bit value is returned.
3312 If 32-bit operations are not supported, then ASSERT().
3313 If StartBit is greater than 31, then ASSERT().
3314 If EndBit is greater than 31, then ASSERT().
3315 If EndBit is less than StartBit, then ASSERT().
3316 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
3317 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
3319 @param Operand Operand on which to perform the bitfield operation.
3320 @param StartBit The ordinal of the least significant bit in the bit field.
3322 @param EndBit The ordinal of the most significant bit in the bit field.
3324 @param AndData The value to AND with the read value from the value.
3325 @param OrData The value to OR with the result of the AND operation.
3327 @return The new 32-bit value.
3332 BitFieldAndThenOr32 (
3342 Returns a bit field from a 64-bit value.
3344 Returns the bitfield specified by the StartBit and the EndBit from Operand.
3346 If 64-bit operations are not supported, then ASSERT().
3347 If StartBit is greater than 63, then ASSERT().
3348 If EndBit is greater than 63, then ASSERT().
3349 If EndBit is less than StartBit, then ASSERT().
3351 @param Operand Operand on which to perform the bitfield operation.
3352 @param StartBit The ordinal of the least significant bit in the bit field.
3354 @param EndBit The ordinal of the most significant bit in the bit field.
3357 @return The bit field read.
3370 Writes a bit field to a 64-bit value, and returns the result.
3372 Writes Value to the bit field specified by the StartBit and the EndBit in
3373 Operand. All other bits in Operand are preserved. The new 64-bit value is
3376 If 64-bit operations are not supported, then ASSERT().
3377 If StartBit is greater than 63, then ASSERT().
3378 If EndBit is greater than 63, then ASSERT().
3379 If EndBit is less than StartBit, then ASSERT().
3380 If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
3382 @param Operand Operand on which to perform the bitfield operation.
3383 @param StartBit The ordinal of the least significant bit in the bit field.
3385 @param EndBit The ordinal of the most significant bit in the bit field.
3387 @param Value New value of the bit field.
3389 @return The new 64-bit value.
3403 Reads a bit field from a 64-bit value, performs a bitwise OR, and returns the
3406 Performs a bitwise OR between the bit field specified by StartBit
3407 and EndBit in Operand and the value specified by OrData. All other bits in
3408 Operand are preserved. The new 64-bit value is returned.
3410 If 64-bit operations are not supported, then ASSERT().
3411 If StartBit is greater than 63, then ASSERT().
3412 If EndBit is greater than 63, then ASSERT().
3413 If EndBit is less than StartBit, then ASSERT().
3414 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
3416 @param Operand Operand on which to perform the bitfield operation.
3417 @param StartBit The ordinal of the least significant bit in the bit field.
3419 @param EndBit The ordinal of the most significant bit in the bit field.
3421 @param OrData The value to OR with the read value from the value
3423 @return The new 64-bit value.
3437 Reads a bit field from a 64-bit value, performs a bitwise AND, and returns
3440 Performs a bitwise AND between the bit field specified by StartBit and EndBit
3441 in Operand and the value specified by AndData. All other bits in Operand are
3442 preserved. The new 64-bit value is returned.
3444 If 64-bit operations are not supported, then ASSERT().
3445 If StartBit is greater than 63, then ASSERT().
3446 If EndBit is greater than 63, then ASSERT().
3447 If EndBit is less than StartBit, then ASSERT().
3448 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
3450 @param Operand Operand on which to perform the bitfield operation.
3451 @param StartBit The ordinal of the least significant bit in the bit field.
3453 @param EndBit The ordinal of the most significant bit in the bit field.
3455 @param AndData The value to AND with the read value from the value
3457 @return The new 64-bit value.
3471 Reads a bit field from a 64-bit value, performs a bitwise AND followed by a
3472 bitwise OR, and returns the result.
3474 Performs a bitwise AND between the bit field specified by StartBit and EndBit
3475 in Operand and the value specified by AndData, followed by a bitwise
3476 OR with value specified by OrData. All other bits in Operand are
3477 preserved. The new 64-bit value is returned.
3479 If 64-bit operations are not supported, then ASSERT().
3480 If StartBit is greater than 63, then ASSERT().
3481 If EndBit is greater than 63, then ASSERT().
3482 If EndBit is less than StartBit, then ASSERT().
3483 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
3484 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
3486 @param Operand Operand on which to perform the bitfield operation.
3487 @param StartBit The ordinal of the least significant bit in the bit field.
3489 @param EndBit The ordinal of the most significant bit in the bit field.
3491 @param AndData The value to AND with the read value from the value.
3492 @param OrData The value to OR with the result of the AND operation.
3494 @return The new 64-bit value.
3499 BitFieldAndThenOr64 (
3508 // Base Library Checksum Functions
3512 Returns the sum of all elements in a buffer in unit of UINT8.
3513 During calculation, the carry bits are dropped.
3515 This function calculates the sum of all elements in a buffer
3516 in unit of UINT8. The carry bits in result of addition are dropped.
3517 The result is returned as UINT8. If Length is Zero, then Zero is
3520 If Buffer is NULL, then ASSERT().
3521 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
3523 @param Buffer The pointer to the buffer to carry out the sum operation.
3524 @param Length The size, in bytes, of Buffer.
3526 @return Sum The sum of Buffer with carry bits dropped during additions.
3532 IN CONST UINT8
*Buffer
,
3538 Returns the two's complement checksum of all elements in a buffer
3541 This function first calculates the sum of the 8-bit values in the
3542 buffer specified by Buffer and Length. The carry bits in the result
3543 of addition are dropped. Then, the two's complement of the sum is
3544 returned. If Length is 0, then 0 is returned.
3546 If Buffer is NULL, then ASSERT().
3547 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
3549 @param Buffer The pointer to the buffer to carry out the checksum operation.
3550 @param Length The size, in bytes, of Buffer.
3552 @return Checksum The two's complement checksum of Buffer.
3557 CalculateCheckSum8 (
3558 IN CONST UINT8
*Buffer
,
3564 Returns the sum of all elements in a buffer of 16-bit values. During
3565 calculation, the carry bits are dropped.
3567 This function calculates the sum of the 16-bit values in the buffer
3568 specified by Buffer and Length. The carry bits in result of addition are dropped.
3569 The 16-bit result is returned. If Length is 0, then 0 is returned.
3571 If Buffer is NULL, then ASSERT().
3572 If Buffer is not aligned on a 16-bit boundary, then ASSERT().
3573 If Length is not aligned on a 16-bit boundary, then ASSERT().
3574 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
3576 @param Buffer The pointer to the buffer to carry out the sum operation.
3577 @param Length The size, in bytes, of Buffer.
3579 @return Sum The sum of Buffer with carry bits dropped during additions.
3585 IN CONST UINT16
*Buffer
,
3591 Returns the two's complement checksum of all elements in a buffer of
3594 This function first calculates the sum of the 16-bit values in the buffer
3595 specified by Buffer and Length. The carry bits in the result of addition
3596 are dropped. Then, the two's complement of the sum is returned. If Length
3597 is 0, then 0 is returned.
3599 If Buffer is NULL, then ASSERT().
3600 If Buffer is not aligned on a 16-bit boundary, then ASSERT().
3601 If Length is not aligned on a 16-bit boundary, then ASSERT().
3602 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
3604 @param Buffer The pointer to the buffer to carry out the checksum operation.
3605 @param Length The size, in bytes, of Buffer.
3607 @return Checksum The two's complement checksum of Buffer.
3612 CalculateCheckSum16 (
3613 IN CONST UINT16
*Buffer
,
3619 Returns the sum of all elements in a buffer of 32-bit values. During
3620 calculation, the carry bits are dropped.
3622 This function calculates the sum of the 32-bit values in the buffer
3623 specified by Buffer and Length. The carry bits in result of addition are dropped.
3624 The 32-bit result is returned. If Length is 0, then 0 is returned.
3626 If Buffer is NULL, then ASSERT().
3627 If Buffer is not aligned on a 32-bit boundary, then ASSERT().
3628 If Length is not aligned on a 32-bit boundary, then ASSERT().
3629 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
3631 @param Buffer The pointer to the buffer to carry out the sum operation.
3632 @param Length The size, in bytes, of Buffer.
3634 @return Sum The sum of Buffer with carry bits dropped during additions.
3640 IN CONST UINT32
*Buffer
,
3646 Returns the two's complement checksum of all elements in a buffer of
3649 This function first calculates the sum of the 32-bit values in the buffer
3650 specified by Buffer and Length. The carry bits in the result of addition
3651 are dropped. Then, the two's complement of the sum is returned. If Length
3652 is 0, then 0 is returned.
3654 If Buffer is NULL, then ASSERT().
3655 If Buffer is not aligned on a 32-bit boundary, then ASSERT().
3656 If Length is not aligned on a 32-bit boundary, then ASSERT().
3657 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
3659 @param Buffer The pointer to the buffer to carry out the checksum operation.
3660 @param Length The size, in bytes, of Buffer.
3662 @return Checksum The two's complement checksum of Buffer.
3667 CalculateCheckSum32 (
3668 IN CONST UINT32
*Buffer
,
3674 Returns the sum of all elements in a buffer of 64-bit values. During
3675 calculation, the carry bits are dropped.
3677 This function calculates the sum of the 64-bit values in the buffer
3678 specified by Buffer and Length. The carry bits in result of addition are dropped.
3679 The 64-bit result is returned. If Length is 0, then 0 is returned.
3681 If Buffer is NULL, then ASSERT().
3682 If Buffer is not aligned on a 64-bit boundary, then ASSERT().
3683 If Length is not aligned on a 64-bit boundary, then ASSERT().
3684 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
3686 @param Buffer The pointer to the buffer to carry out the sum operation.
3687 @param Length The size, in bytes, of Buffer.
3689 @return Sum The sum of Buffer with carry bits dropped during additions.
3695 IN CONST UINT64
*Buffer
,
3701 Returns the two's complement checksum of all elements in a buffer of
3704 This function first calculates the sum of the 64-bit values in the buffer
3705 specified by Buffer and Length. The carry bits in the result of addition
3706 are dropped. Then, the two's complement of the sum is returned. If Length
3707 is 0, then 0 is returned.
3709 If Buffer is NULL, then ASSERT().
3710 If Buffer is not aligned on a 64-bit boundary, then ASSERT().
3711 If Length is not aligned on a 64-bit boundary, then ASSERT().
3712 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
3714 @param Buffer The pointer to the buffer to carry out the checksum operation.
3715 @param Length The size, in bytes, of Buffer.
3717 @return Checksum The two's complement checksum of Buffer.
3722 CalculateCheckSum64 (
3723 IN CONST UINT64
*Buffer
,
3729 // Base Library CPU Functions
3733 Function entry point used when a stack switch is requested with SwitchStack()
3735 @param Context1 Context1 parameter passed into SwitchStack().
3736 @param Context2 Context2 parameter passed into SwitchStack().
3741 (EFIAPI
*SWITCH_STACK_ENTRY_POINT
)(
3742 IN VOID
*Context1
, OPTIONAL
3743 IN VOID
*Context2 OPTIONAL
3748 Used to serialize load and store operations.
3750 All loads and stores that proceed calls to this function are guaranteed to be
3751 globally visible when this function returns.
3762 Saves the current CPU context that can be restored with a call to LongJump()
3765 Saves the current CPU context in the buffer specified by JumpBuffer and
3766 returns 0. The initial call to SetJump() must always return 0. Subsequent
3767 calls to LongJump() cause a non-zero value to be returned by SetJump().
3769 If JumpBuffer is NULL, then ASSERT().
3770 For Itanium processors, if JumpBuffer is not aligned on a 16-byte boundary, then ASSERT().
3772 NOTE: The structure BASE_LIBRARY_JUMP_BUFFER is CPU architecture specific.
3773 The same structure must never be used for more than one CPU architecture context.
3774 For example, a BASE_LIBRARY_JUMP_BUFFER allocated by an IA-32 module must never be used from an x64 module.
3775 SetJump()/LongJump() is not currently supported for the EBC processor type.
3777 @param JumpBuffer A pointer to CPU context buffer.
3779 @retval 0 Indicates a return from SetJump().
3785 OUT BASE_LIBRARY_JUMP_BUFFER
*JumpBuffer
3790 Restores the CPU context that was saved with SetJump().
3792 Restores the CPU context from the buffer specified by JumpBuffer. This
3793 function never returns to the caller. Instead is resumes execution based on
3794 the state of JumpBuffer.
3796 If JumpBuffer is NULL, then ASSERT().
3797 For Itanium processors, if JumpBuffer is not aligned on a 16-byte boundary, then ASSERT().
3798 If Value is 0, then ASSERT().
3800 @param JumpBuffer A pointer to CPU context buffer.
3801 @param Value The value to return when the SetJump() context is
3802 restored and must be non-zero.
3808 IN BASE_LIBRARY_JUMP_BUFFER
*JumpBuffer
,
3814 Enables CPU interrupts.
3825 Disables CPU interrupts.
3836 Disables CPU interrupts and returns the interrupt state prior to the disable
3839 @retval TRUE CPU interrupts were enabled on entry to this call.
3840 @retval FALSE CPU interrupts were disabled on entry to this call.
3845 SaveAndDisableInterrupts (
3851 Enables CPU interrupts for the smallest window required to capture any
3857 EnableDisableInterrupts (
3863 Retrieves the current CPU interrupt state.
3865 Returns TRUE if interrupts are currently enabled. Otherwise
3868 @retval TRUE CPU interrupts are enabled.
3869 @retval FALSE CPU interrupts are disabled.
3880 Set the current CPU interrupt state.
3882 Sets the current CPU interrupt state to the state specified by
3883 InterruptState. If InterruptState is TRUE, then interrupts are enabled. If
3884 InterruptState is FALSE, then interrupts are disabled. InterruptState is
3887 @param InterruptState TRUE if interrupts should enabled. FALSE if
3888 interrupts should be disabled.
3890 @return InterruptState
3896 IN BOOLEAN InterruptState
3901 Requests CPU to pause for a short period of time.
3903 Requests CPU to pause for a short period of time. Typically used in MP
3904 systems to prevent memory starvation while waiting for a spin lock.
3915 Transfers control to a function starting with a new stack.
3917 Transfers control to the function specified by EntryPoint using the
3918 new stack specified by NewStack and passing in the parameters specified
3919 by Context1 and Context2. Context1 and Context2 are optional and may
3920 be NULL. The function EntryPoint must never return. This function
3921 supports a variable number of arguments following the NewStack parameter.
3922 These additional arguments are ignored on IA-32, x64, and EBC architectures.
3923 Itanium processors expect one additional parameter of type VOID * that specifies
3924 the new backing store pointer.
3926 If EntryPoint is NULL, then ASSERT().
3927 If NewStack is NULL, then ASSERT().
3929 @param EntryPoint A pointer to function to call with the new stack.
3930 @param Context1 A pointer to the context to pass into the EntryPoint
3932 @param Context2 A pointer to the context to pass into the EntryPoint
3934 @param NewStack A pointer to the new stack to use for the EntryPoint
3936 @param ... This variable argument list is ignored for IA-32, x64, and
3937 EBC architectures. For Itanium processors, this variable
3938 argument list is expected to contain a single parameter of
3939 type VOID * that specifies the new backing store pointer.
3946 IN SWITCH_STACK_ENTRY_POINT EntryPoint
,
3947 IN VOID
*Context1
, OPTIONAL
3948 IN VOID
*Context2
, OPTIONAL
3955 Generates a breakpoint on the CPU.
3957 Generates a breakpoint on the CPU. The breakpoint must be implemented such
3958 that code can resume normal execution after the breakpoint.
3969 Executes an infinite loop.
3971 Forces the CPU to execute an infinite loop. A debugger may be used to skip
3972 past the loop and the code that follows the loop must execute properly. This
3973 implies that the infinite loop must not cause the code that follow it to be
3983 #if defined (MDE_CPU_IPF)
3986 Flush a range of cache lines in the cache coherency domain of the calling
3989 Flushes the cache lines specified by Address and Length. If Address is not aligned
3990 on a cache line boundary, then entire cache line containing Address is flushed.
3991 If Address + Length is not aligned on a cache line boundary, then the entire cache
3992 line containing Address + Length - 1 is flushed. This function may choose to flush
3993 the entire cache if that is more efficient than flushing the specified range. If
3994 Length is 0, the no cache lines are flushed. Address is returned.
3995 This function is only available on Itanium processors.
3997 If Length is greater than (MAX_ADDRESS - Address + 1), then ASSERT().
3999 @param Address The base address of the instruction lines to invalidate. If
4000 the CPU is in a physical addressing mode, then Address is a
4001 physical address. If the CPU is in a virtual addressing mode,
4002 then Address is a virtual address.
4004 @param Length The number of bytes to invalidate from the instruction cache.
4011 AsmFlushCacheRange (
4018 Executes an FC instruction.
4019 Executes an FC instruction on the cache line specified by Address.
4020 The cache line size affected is at least 32-bytes (aligned on a 32-byte boundary).
4021 An implementation may flush a larger region. This function is only available on Itanium processors.
4023 @param Address The Address of cache line to be flushed.
4025 @return The address of FC instruction executed.
4036 Executes an FC.I instruction.
4037 Executes an FC.I instruction on the cache line specified by Address.
4038 The cache line size affected is at least 32-bytes (aligned on a 32-byte boundary).
4039 An implementation may flush a larger region. This function is only available on Itanium processors.
4041 @param Address The Address of cache line to be flushed.
4043 @return The address of the FC.I instruction executed.
4054 Reads the current value of a Processor Identifier Register (CPUID).
4056 Reads and returns the current value of Processor Identifier Register specified by Index.
4057 The Index of largest implemented CPUID (One less than the number of implemented CPUID
4058 registers) is determined by CPUID [3] bits {7:0}.
4059 No parameter checking is performed on Index. If the Index value is beyond the
4060 implemented CPUID register range, a Reserved Register/Field fault may occur. The caller
4061 must either guarantee that Index is valid, or the caller must set up fault handlers to
4062 catch the faults. This function is only available on Itanium processors.
4064 @param Index The 8-bit Processor Identifier Register index to read.
4066 @return The current value of Processor Identifier Register specified by Index.
4077 Reads the current value of 64-bit Processor Status Register (PSR).
4078 This function is only available on Itanium processors.
4080 @return The current value of PSR.
4091 Writes the current value of 64-bit Processor Status Register (PSR).
4093 No parameter checking is performed on Value. All bits of Value corresponding to
4094 reserved fields of PSR must be 0 or a Reserved Register/Field fault may occur.
4095 The caller must either guarantee that Value is valid, or the caller must set up
4096 fault handlers to catch the faults. This function is only available on Itanium processors.
4098 @param Value The 64-bit value to write to PSR.
4100 @return The 64-bit value written to the PSR.
4111 Reads the current value of 64-bit Kernel Register #0 (KR0).
4113 Reads and returns the current value of KR0.
4114 This function is only available on Itanium processors.
4116 @return The current value of KR0.
4127 Reads the current value of 64-bit Kernel Register #1 (KR1).
4129 Reads and returns the current value of KR1.
4130 This function is only available on Itanium processors.
4132 @return The current value of KR1.
4143 Reads the current value of 64-bit Kernel Register #2 (KR2).
4145 Reads and returns the current value of KR2.
4146 This function is only available on Itanium processors.
4148 @return The current value of KR2.
4159 Reads the current value of 64-bit Kernel Register #3 (KR3).
4161 Reads and returns the current value of KR3.
4162 This function is only available on Itanium processors.
4164 @return The current value of KR3.
4175 Reads the current value of 64-bit Kernel Register #4 (KR4).
4177 Reads and returns the current value of KR4.
4178 This function is only available on Itanium processors.
4180 @return The current value of KR4.
4191 Reads the current value of 64-bit Kernel Register #5 (KR5).
4193 Reads and returns the current value of KR5.
4194 This function is only available on Itanium processors.
4196 @return The current value of KR5.
4207 Reads the current value of 64-bit Kernel Register #6 (KR6).
4209 Reads and returns the current value of KR6.
4210 This function is only available on Itanium processors.
4212 @return The current value of KR6.
4223 Reads the current value of 64-bit Kernel Register #7 (KR7).
4225 Reads and returns the current value of KR7.
4226 This function is only available on Itanium processors.
4228 @return The current value of KR7.
4239 Write the current value of 64-bit Kernel Register #0 (KR0).
4241 Writes the current value of KR0. The 64-bit value written to
4242 the KR0 is returned. This function is only available on Itanium processors.
4244 @param Value The 64-bit value to write to KR0.
4246 @return The 64-bit value written to the KR0.
4257 Write the current value of 64-bit Kernel Register #1 (KR1).
4259 Writes the current value of KR1. The 64-bit value written to
4260 the KR1 is returned. This function is only available on Itanium processors.
4262 @param Value The 64-bit value to write to KR1.
4264 @return The 64-bit value written to the KR1.
4275 Write the current value of 64-bit Kernel Register #2 (KR2).
4277 Writes the current value of KR2. The 64-bit value written to
4278 the KR2 is returned. This function is only available on Itanium processors.
4280 @param Value The 64-bit value to write to KR2.
4282 @return The 64-bit value written to the KR2.
4293 Write the current value of 64-bit Kernel Register #3 (KR3).
4295 Writes the current value of KR3. The 64-bit value written to
4296 the KR3 is returned. This function is only available on Itanium processors.
4298 @param Value The 64-bit value to write to KR3.
4300 @return The 64-bit value written to the KR3.
4311 Write the current value of 64-bit Kernel Register #4 (KR4).
4313 Writes the current value of KR4. The 64-bit value written to
4314 the KR4 is returned. This function is only available on Itanium processors.
4316 @param Value The 64-bit value to write to KR4.
4318 @return The 64-bit value written to the KR4.
4329 Write the current value of 64-bit Kernel Register #5 (KR5).
4331 Writes the current value of KR5. The 64-bit value written to
4332 the KR5 is returned. This function is only available on Itanium processors.
4334 @param Value The 64-bit value to write to KR5.
4336 @return The 64-bit value written to the KR5.
4347 Write the current value of 64-bit Kernel Register #6 (KR6).
4349 Writes the current value of KR6. The 64-bit value written to
4350 the KR6 is returned. This function is only available on Itanium processors.
4352 @param Value The 64-bit value to write to KR6.
4354 @return The 64-bit value written to the KR6.
4365 Write the current value of 64-bit Kernel Register #7 (KR7).
4367 Writes the current value of KR7. The 64-bit value written to
4368 the KR7 is returned. This function is only available on Itanium processors.
4370 @param Value The 64-bit value to write to KR7.
4372 @return The 64-bit value written to the KR7.
4383 Reads the current value of Interval Timer Counter Register (ITC).
4385 Reads and returns the current value of ITC.
4386 This function is only available on Itanium processors.
4388 @return The current value of ITC.
4399 Reads the current value of Interval Timer Vector Register (ITV).
4401 Reads and returns the current value of ITV.
4402 This function is only available on Itanium processors.
4404 @return The current value of ITV.
4415 Reads the current value of Interval Timer Match Register (ITM).
4417 Reads and returns the current value of ITM.
4418 This function is only available on Itanium processors.
4420 @return The current value of ITM.
4430 Writes the current value of 64-bit Interval Timer Counter Register (ITC).
4432 Writes the current value of ITC. The 64-bit value written to the ITC is returned.
4433 This function is only available on Itanium processors.
4435 @param Value The 64-bit value to write to ITC.
4437 @return The 64-bit value written to the ITC.
4448 Writes the current value of 64-bit Interval Timer Match Register (ITM).
4450 Writes the current value of ITM. The 64-bit value written to the ITM is returned.
4451 This function is only available on Itanium processors.
4453 @param Value The 64-bit value to write to ITM.
4455 @return The 64-bit value written to the ITM.
4466 Writes the current value of 64-bit Interval Timer Vector Register (ITV).
4468 Writes the current value of ITV. The 64-bit value written to the ITV is returned.
4469 No parameter checking is performed on Value. All bits of Value corresponding to
4470 reserved fields of ITV must be 0 or a Reserved Register/Field fault may occur.
4471 The caller must either guarantee that Value is valid, or the caller must set up
4472 fault handlers to catch the faults.
4473 This function is only available on Itanium processors.
4475 @param Value The 64-bit value to write to ITV.
4477 @return The 64-bit value written to the ITV.
4488 Reads the current value of Default Control Register (DCR).
4490 Reads and returns the current value of DCR. This function is only available on Itanium processors.
4492 @return The current value of DCR.
4503 Reads the current value of Interruption Vector Address Register (IVA).
4505 Reads and returns the current value of IVA. This function is only available on Itanium processors.
4507 @return The current value of IVA.
4517 Reads the current value of Page Table Address Register (PTA).
4519 Reads and returns the current value of PTA. This function is only available on Itanium processors.
4521 @return The current value of PTA.
4532 Writes the current value of 64-bit Default Control Register (DCR).
4534 Writes the current value of DCR. The 64-bit value written to the DCR is returned.
4535 No parameter checking is performed on Value. All bits of Value corresponding to
4536 reserved fields of DCR must be 0 or a Reserved Register/Field fault may occur.
4537 The caller must either guarantee that Value is valid, or the caller must set up
4538 fault handlers to catch the faults.
4539 This function is only available on Itanium processors.
4541 @param Value The 64-bit value to write to DCR.
4543 @return The 64-bit value written to the DCR.
4554 Writes the current value of 64-bit Interruption Vector Address Register (IVA).
4556 Writes the current value of IVA. The 64-bit value written to the IVA is returned.
4557 The size of vector table is 32 K bytes and is 32 K bytes aligned
4558 the low 15 bits of Value is ignored when written.
4559 This function is only available on Itanium processors.
4561 @param Value The 64-bit value to write to IVA.
4563 @return The 64-bit value written to the IVA.
4574 Writes the current value of 64-bit Page Table Address Register (PTA).
4576 Writes the current value of PTA. The 64-bit value written to the PTA is returned.
4577 No parameter checking is performed on Value. All bits of Value corresponding to
4578 reserved fields of DCR must be 0 or a Reserved Register/Field fault may occur.
4579 The caller must either guarantee that Value is valid, or the caller must set up
4580 fault handlers to catch the faults.
4581 This function is only available on Itanium processors.
4583 @param Value The 64-bit value to write to PTA.
4585 @return The 64-bit value written to the PTA.
4595 Reads the current value of Local Interrupt ID Register (LID).
4597 Reads and returns the current value of LID. This function is only available on Itanium processors.
4599 @return The current value of LID.
4610 Reads the current value of External Interrupt Vector Register (IVR).
4612 Reads and returns the current value of IVR. This function is only available on Itanium processors.
4614 @return The current value of IVR.
4625 Reads the current value of Task Priority Register (TPR).
4627 Reads and returns the current value of TPR. This function is only available on Itanium processors.
4629 @return The current value of TPR.
4640 Reads the current value of External Interrupt Request Register #0 (IRR0).
4642 Reads and returns the current value of IRR0. This function is only available on Itanium processors.
4644 @return The current value of IRR0.
4655 Reads the current value of External Interrupt Request Register #1 (IRR1).
4657 Reads and returns the current value of IRR1. This function is only available on Itanium processors.
4659 @return The current value of IRR1.
4670 Reads the current value of External Interrupt Request Register #2 (IRR2).
4672 Reads and returns the current value of IRR2. This function is only available on Itanium processors.
4674 @return The current value of IRR2.
4685 Reads the current value of External Interrupt Request Register #3 (IRR3).
4687 Reads and returns the current value of IRR3. This function is only available on Itanium processors.
4689 @return The current value of IRR3.
4700 Reads the current value of Performance Monitor Vector Register (PMV).
4702 Reads and returns the current value of PMV. This function is only available on Itanium processors.
4704 @return The current value of PMV.
4715 Reads the current value of Corrected Machine Check Vector Register (CMCV).
4717 Reads and returns the current value of CMCV. This function is only available on Itanium processors.
4719 @return The current value of CMCV.
4730 Reads the current value of Local Redirection Register #0 (LRR0).
4732 Reads and returns the current value of LRR0. This function is only available on Itanium processors.
4734 @return The current value of LRR0.
4745 Reads the current value of Local Redirection Register #1 (LRR1).
4747 Reads and returns the current value of LRR1. This function is only available on Itanium processors.
4749 @return The current value of LRR1.
4760 Writes the current value of 64-bit Page Local Interrupt ID Register (LID).
4762 Writes the current value of LID. The 64-bit value written to the LID is returned.
4763 No parameter checking is performed on Value. All bits of Value corresponding to
4764 reserved fields of LID must be 0 or a Reserved Register/Field fault may occur.
4765 The caller must either guarantee that Value is valid, or the caller must set up
4766 fault handlers to catch the faults.
4767 This function is only available on Itanium processors.
4769 @param Value The 64-bit value to write to LID.
4771 @return The 64-bit value written to the LID.
4782 Writes the current value of 64-bit Task Priority Register (TPR).
4784 Writes the current value of TPR. The 64-bit value written to the TPR is returned.
4785 No parameter checking is performed on Value. All bits of Value corresponding to
4786 reserved fields of TPR must be 0 or a Reserved Register/Field fault may occur.
4787 The caller must either guarantee that Value is valid, or the caller must set up
4788 fault handlers to catch the faults.
4789 This function is only available on Itanium processors.
4791 @param Value The 64-bit value to write to TPR.
4793 @return The 64-bit value written to the TPR.
4804 Performs a write operation on End OF External Interrupt Register (EOI).
4806 Writes a value of 0 to the EOI Register. This function is only available on Itanium processors.
4817 Writes the current value of 64-bit Performance Monitor Vector Register (PMV).
4819 Writes the current value of PMV. The 64-bit value written to the PMV is returned.
4820 No parameter checking is performed on Value. All bits of Value corresponding
4821 to reserved fields of PMV must be 0 or a Reserved Register/Field fault may occur.
4822 The caller must either guarantee that Value is valid, or the caller must set up
4823 fault handlers to catch the faults.
4824 This function is only available on Itanium processors.
4826 @param Value The 64-bit value to write to PMV.
4828 @return The 64-bit value written to the PMV.
4839 Writes the current value of 64-bit Corrected Machine Check Vector Register (CMCV).
4841 Writes the current value of CMCV. The 64-bit value written to the CMCV is returned.
4842 No parameter checking is performed on Value. All bits of Value corresponding
4843 to reserved fields of CMCV must be 0 or a Reserved Register/Field fault may occur.
4844 The caller must either guarantee that Value is valid, or the caller must set up
4845 fault handlers to catch the faults.
4846 This function is only available on Itanium processors.
4848 @param Value The 64-bit value to write to CMCV.
4850 @return The 64-bit value written to the CMCV.
4861 Writes the current value of 64-bit Local Redirection Register #0 (LRR0).
4863 Writes the current value of LRR0. The 64-bit value written to the LRR0 is returned.
4864 No parameter checking is performed on Value. All bits of Value corresponding
4865 to reserved fields of LRR0 must be 0 or a Reserved Register/Field fault may occur.
4866 The caller must either guarantee that Value is valid, or the caller must set up
4867 fault handlers to catch the faults.
4868 This function is only available on Itanium processors.
4870 @param Value The 64-bit value to write to LRR0.
4872 @return The 64-bit value written to the LRR0.
4883 Writes the current value of 64-bit Local Redirection Register #1 (LRR1).
4885 Writes the current value of LRR1. The 64-bit value written to the LRR1 is returned.
4886 No parameter checking is performed on Value. All bits of Value corresponding
4887 to reserved fields of LRR1 must be 0 or a Reserved Register/Field fault may occur.
4888 The caller must either guarantee that Value is valid, or the caller must
4889 set up fault handlers to catch the faults.
4890 This function is only available on Itanium processors.
4892 @param Value The 64-bit value to write to LRR1.
4894 @return The 64-bit value written to the LRR1.
4905 Reads the current value of Instruction Breakpoint Register (IBR).
4907 The Instruction Breakpoint Registers are used in pairs. The even numbered
4908 registers contain breakpoint addresses, and the odd numbered registers contain
4909 breakpoint mask conditions. At least four instruction registers pairs are implemented
4910 on all processor models. Implemented registers are contiguous starting with
4911 register 0. No parameter checking is performed on Index, and if the Index value
4912 is beyond the implemented IBR register range, a Reserved Register/Field fault may
4913 occur. The caller must either guarantee that Index is valid, or the caller must
4914 set up fault handlers to catch the faults.
4915 This function is only available on Itanium processors.
4917 @param Index The 8-bit Instruction Breakpoint Register index to read.
4919 @return The current value of Instruction Breakpoint Register specified by Index.
4930 Reads the current value of Data Breakpoint Register (DBR).
4932 The Data Breakpoint Registers are used in pairs. The even numbered registers
4933 contain breakpoint addresses, and odd numbered registers contain breakpoint
4934 mask conditions. At least four data registers pairs are implemented on all processor
4935 models. Implemented registers are contiguous starting with register 0.
4936 No parameter checking is performed on Index. If the Index value is beyond
4937 the implemented DBR register range, a Reserved Register/Field fault may occur.
4938 The caller must either guarantee that Index is valid, or the caller must set up
4939 fault handlers to catch the faults.
4940 This function is only available on Itanium processors.
4942 @param Index The 8-bit Data Breakpoint Register index to read.
4944 @return The current value of Data Breakpoint Register specified by Index.
4955 Reads the current value of Performance Monitor Configuration Register (PMC).
4957 All processor implementations provide at least four performance counters
4958 (PMC/PMD [4]...PMC/PMD [7] pairs), and four performance monitor counter overflow
4959 status registers (PMC [0]... PMC [3]). Processor implementations may provide
4960 additional implementation-dependent PMC and PMD to increase the number of
4961 'generic' performance counters (PMC/PMD pairs). The remainder of PMC and PMD
4962 register set is implementation dependent. No parameter checking is performed
4963 on Index. If the Index value is beyond the implemented PMC register range,
4964 zero value will be returned.
4965 This function is only available on Itanium processors.
4967 @param Index The 8-bit Performance Monitor Configuration Register index to read.
4969 @return The current value of Performance Monitor Configuration Register
4981 Reads the current value of Performance Monitor Data Register (PMD).
4983 All processor implementations provide at least 4 performance counters
4984 (PMC/PMD [4]...PMC/PMD [7] pairs), and 4 performance monitor counter
4985 overflow status registers (PMC [0]... PMC [3]). Processor implementations may
4986 provide additional implementation-dependent PMC and PMD to increase the number
4987 of 'generic' performance counters (PMC/PMD pairs). The remainder of PMC and PMD
4988 register set is implementation dependent. No parameter checking is performed
4989 on Index. If the Index value is beyond the implemented PMD register range,
4990 zero value will be returned.
4991 This function is only available on Itanium processors.
4993 @param Index The 8-bit Performance Monitor Data Register index to read.
4995 @return The current value of Performance Monitor Data Register specified by Index.
5006 Writes the current value of 64-bit Instruction Breakpoint Register (IBR).
5008 Writes current value of Instruction Breakpoint Register specified by Index.
5009 The Instruction Breakpoint Registers are used in pairs. The even numbered
5010 registers contain breakpoint addresses, and odd numbered registers contain
5011 breakpoint mask conditions. At least four instruction registers pairs are implemented
5012 on all processor models. Implemented registers are contiguous starting with
5013 register 0. No parameter checking is performed on Index. If the Index value
5014 is beyond the implemented IBR register range, a Reserved Register/Field fault may
5015 occur. The caller must either guarantee that Index is valid, or the caller must
5016 set up fault handlers to catch the faults.
5017 This function is only available on Itanium processors.
5019 @param Index The 8-bit Instruction Breakpoint Register index to write.
5020 @param Value The 64-bit value to write to IBR.
5022 @return The 64-bit value written to the IBR.
5034 Writes the current value of 64-bit Data Breakpoint Register (DBR).
5036 Writes current value of Data Breakpoint Register specified by Index.
5037 The Data Breakpoint Registers are used in pairs. The even numbered registers
5038 contain breakpoint addresses, and odd numbered registers contain breakpoint
5039 mask conditions. At least four data registers pairs are implemented on all processor
5040 models. Implemented registers are contiguous starting with register 0. No parameter
5041 checking is performed on Index. If the Index value is beyond the implemented
5042 DBR register range, a Reserved Register/Field fault may occur. The caller must
5043 either guarantee that Index is valid, or the caller must set up fault handlers to
5045 This function is only available on Itanium processors.
5047 @param Index The 8-bit Data Breakpoint Register index to write.
5048 @param Value The 64-bit value to write to DBR.
5050 @return The 64-bit value written to the DBR.
5062 Writes the current value of 64-bit Performance Monitor Configuration Register (PMC).
5064 Writes current value of Performance Monitor Configuration Register specified by Index.
5065 All processor implementations provide at least four performance counters
5066 (PMC/PMD [4]...PMC/PMD [7] pairs), and four performance monitor counter overflow status
5067 registers (PMC [0]... PMC [3]). Processor implementations may provide additional
5068 implementation-dependent PMC and PMD to increase the number of 'generic' performance
5069 counters (PMC/PMD pairs). The remainder of PMC and PMD register set is implementation
5070 dependent. No parameter checking is performed on Index. If the Index value is
5071 beyond the implemented PMC register range, the write is ignored.
5072 This function is only available on Itanium processors.
5074 @param Index The 8-bit Performance Monitor Configuration Register index to write.
5075 @param Value The 64-bit value to write to PMC.
5077 @return The 64-bit value written to the PMC.
5089 Writes the current value of 64-bit Performance Monitor Data Register (PMD).
5091 Writes current value of Performance Monitor Data Register specified by Index.
5092 All processor implementations provide at least four performance counters
5093 (PMC/PMD [4]...PMC/PMD [7] pairs), and four performance monitor counter overflow
5094 status registers (PMC [0]... PMC [3]). Processor implementations may provide
5095 additional implementation-dependent PMC and PMD to increase the number of 'generic'
5096 performance counters (PMC/PMD pairs). The remainder of PMC and PMD register set
5097 is implementation dependent. No parameter checking is performed on Index. If the
5098 Index value is beyond the implemented PMD register range, the write is ignored.
5099 This function is only available on Itanium processors.
5101 @param Index The 8-bit Performance Monitor Data Register index to write.
5102 @param Value The 64-bit value to write to PMD.
5104 @return The 64-bit value written to the PMD.
5116 Reads the current value of 64-bit Global Pointer (GP).
5118 Reads and returns the current value of GP.
5119 This function is only available on Itanium processors.
5121 @return The current value of GP.
5132 Write the current value of 64-bit Global Pointer (GP).
5134 Writes the current value of GP. The 64-bit value written to the GP is returned.
5135 No parameter checking is performed on Value.
5136 This function is only available on Itanium processors.
5138 @param Value The 64-bit value to write to GP.
5140 @return The 64-bit value written to the GP.
5151 Reads the current value of 64-bit Stack Pointer (SP).
5153 Reads and returns the current value of SP.
5154 This function is only available on Itanium processors.
5156 @return The current value of SP.
5167 /// Valid Index value for AsmReadControlRegister().
5169 #define IPF_CONTROL_REGISTER_DCR 0
5170 #define IPF_CONTROL_REGISTER_ITM 1
5171 #define IPF_CONTROL_REGISTER_IVA 2
5172 #define IPF_CONTROL_REGISTER_PTA 8
5173 #define IPF_CONTROL_REGISTER_IPSR 16
5174 #define IPF_CONTROL_REGISTER_ISR 17
5175 #define IPF_CONTROL_REGISTER_IIP 19
5176 #define IPF_CONTROL_REGISTER_IFA 20
5177 #define IPF_CONTROL_REGISTER_ITIR 21
5178 #define IPF_CONTROL_REGISTER_IIPA 22
5179 #define IPF_CONTROL_REGISTER_IFS 23
5180 #define IPF_CONTROL_REGISTER_IIM 24
5181 #define IPF_CONTROL_REGISTER_IHA 25
5182 #define IPF_CONTROL_REGISTER_LID 64
5183 #define IPF_CONTROL_REGISTER_IVR 65
5184 #define IPF_CONTROL_REGISTER_TPR 66
5185 #define IPF_CONTROL_REGISTER_EOI 67
5186 #define IPF_CONTROL_REGISTER_IRR0 68
5187 #define IPF_CONTROL_REGISTER_IRR1 69
5188 #define IPF_CONTROL_REGISTER_IRR2 70
5189 #define IPF_CONTROL_REGISTER_IRR3 71
5190 #define IPF_CONTROL_REGISTER_ITV 72
5191 #define IPF_CONTROL_REGISTER_PMV 73
5192 #define IPF_CONTROL_REGISTER_CMCV 74
5193 #define IPF_CONTROL_REGISTER_LRR0 80
5194 #define IPF_CONTROL_REGISTER_LRR1 81
5197 Reads a 64-bit control register.
5199 Reads and returns the control register specified by Index. The valid Index valued
5200 are defined above in "Related Definitions".
5201 If Index is invalid then 0xFFFFFFFFFFFFFFFF is returned. This function is only
5202 available on Itanium processors.
5204 @param Index The index of the control register to read.
5206 @return The control register specified by Index.
5211 AsmReadControlRegister (
5217 /// Valid Index value for AsmReadApplicationRegister().
5219 #define IPF_APPLICATION_REGISTER_K0 0
5220 #define IPF_APPLICATION_REGISTER_K1 1
5221 #define IPF_APPLICATION_REGISTER_K2 2
5222 #define IPF_APPLICATION_REGISTER_K3 3
5223 #define IPF_APPLICATION_REGISTER_K4 4
5224 #define IPF_APPLICATION_REGISTER_K5 5
5225 #define IPF_APPLICATION_REGISTER_K6 6
5226 #define IPF_APPLICATION_REGISTER_K7 7
5227 #define IPF_APPLICATION_REGISTER_RSC 16
5228 #define IPF_APPLICATION_REGISTER_BSP 17
5229 #define IPF_APPLICATION_REGISTER_BSPSTORE 18
5230 #define IPF_APPLICATION_REGISTER_RNAT 19
5231 #define IPF_APPLICATION_REGISTER_FCR 21
5232 #define IPF_APPLICATION_REGISTER_EFLAG 24
5233 #define IPF_APPLICATION_REGISTER_CSD 25
5234 #define IPF_APPLICATION_REGISTER_SSD 26
5235 #define IPF_APPLICATION_REGISTER_CFLG 27
5236 #define IPF_APPLICATION_REGISTER_FSR 28
5237 #define IPF_APPLICATION_REGISTER_FIR 29
5238 #define IPF_APPLICATION_REGISTER_FDR 30
5239 #define IPF_APPLICATION_REGISTER_CCV 32
5240 #define IPF_APPLICATION_REGISTER_UNAT 36
5241 #define IPF_APPLICATION_REGISTER_FPSR 40
5242 #define IPF_APPLICATION_REGISTER_ITC 44
5243 #define IPF_APPLICATION_REGISTER_PFS 64
5244 #define IPF_APPLICATION_REGISTER_LC 65
5245 #define IPF_APPLICATION_REGISTER_EC 66
5248 Reads a 64-bit application register.
5250 Reads and returns the application register specified by Index. The valid Index
5251 valued are defined above in "Related Definitions".
5252 If Index is invalid then 0xFFFFFFFFFFFFFFFF is returned. This function is only
5253 available on Itanium processors.
5255 @param Index The index of the application register to read.
5257 @return The application register specified by Index.
5262 AsmReadApplicationRegister (
5268 Reads the current value of a Machine Specific Register (MSR).
5270 Reads and returns the current value of the Machine Specific Register specified by Index. No
5271 parameter checking is performed on Index, and if the Index value is beyond the implemented MSR
5272 register range, a Reserved Register/Field fault may occur. The caller must either guarantee that
5273 Index is valid, or the caller must set up fault handlers to catch the faults. This function is
5274 only available on Itanium processors.
5276 @param Index The 8-bit Machine Specific Register index to read.
5278 @return The current value of the Machine Specific Register specified by Index.
5289 Writes the current value of a Machine Specific Register (MSR).
5291 Writes Value to the Machine Specific Register specified by Index. Value is returned. No
5292 parameter checking is performed on Index, and if the Index value is beyond the implemented MSR
5293 register range, a Reserved Register/Field fault may occur. The caller must either guarantee that
5294 Index is valid, or the caller must set up fault handlers to catch the faults. This function is
5295 only available on Itanium processors.
5297 @param Index The 8-bit Machine Specific Register index to write.
5298 @param Value The 64-bit value to write to the Machine Specific Register.
5300 @return The 64-bit value to write to the Machine Specific Register.
5312 Determines if the CPU is currently executing in virtual, physical, or mixed mode.
5314 Determines the current execution mode of the CPU.
5315 If the CPU is in virtual mode(PSR.RT=1, PSR.DT=1, PSR.IT=1), then 1 is returned.
5316 If the CPU is in physical mode(PSR.RT=0, PSR.DT=0, PSR.IT=0), then 0 is returned.
5317 If the CPU is not in physical mode or virtual mode, then it is in mixed mode,
5319 This function is only available on Itanium processors.
5321 @retval 1 The CPU is in virtual mode.
5322 @retval 0 The CPU is in physical mode.
5323 @retval -1 The CPU is in mixed mode.
5334 Makes a PAL procedure call.
5336 This is a wrapper function to make a PAL procedure call. Based on the Index
5337 value this API will make static or stacked PAL call. The following table
5338 describes the usage of PAL Procedure Index Assignment. Architected procedures
5339 may be designated as required or optional. If a PAL procedure is specified
5340 as optional, a unique return code of 0xFFFFFFFFFFFFFFFF is returned in the
5341 Status field of the PAL_CALL_RETURN structure.
5342 This indicates that the procedure is not present in this PAL implementation.
5343 It is the caller's responsibility to check for this return code after calling
5344 any optional PAL procedure.
5345 No parameter checking is performed on the 5 input parameters, but there are
5346 some common rules that the caller should follow when making a PAL call. Any
5347 address passed to PAL as buffers for return parameters must be 8-byte aligned.
5348 Unaligned addresses may cause undefined results. For those parameters defined
5349 as reserved or some fields defined as reserved must be zero filled or the invalid
5350 argument return value may be returned or undefined result may occur during the
5351 execution of the procedure. If the PalEntryPoint does not point to a valid
5352 PAL entry point then the system behavior is undefined. This function is only
5353 available on Itanium processors.
5355 @param PalEntryPoint The PAL procedure calls entry point.
5356 @param Index The PAL procedure Index number.
5357 @param Arg2 The 2nd parameter for PAL procedure calls.
5358 @param Arg3 The 3rd parameter for PAL procedure calls.
5359 @param Arg4 The 4th parameter for PAL procedure calls.
5361 @return structure returned from the PAL Call procedure, including the status and return value.
5367 IN UINT64 PalEntryPoint
,
5375 #if defined (MDE_CPU_IA32) || defined (MDE_CPU_X64)
5377 /// IA32 and x64 Specific Functions.
5378 /// Byte packed structure for 16-bit Real Mode EFLAGS.
5382 UINT32 CF
:1; ///< Carry Flag.
5383 UINT32 Reserved_0
:1; ///< Reserved.
5384 UINT32 PF
:1; ///< Parity Flag.
5385 UINT32 Reserved_1
:1; ///< Reserved.
5386 UINT32 AF
:1; ///< Auxiliary Carry Flag.
5387 UINT32 Reserved_2
:1; ///< Reserved.
5388 UINT32 ZF
:1; ///< Zero Flag.
5389 UINT32 SF
:1; ///< Sign Flag.
5390 UINT32 TF
:1; ///< Trap Flag.
5391 UINT32 IF
:1; ///< Interrupt Enable Flag.
5392 UINT32 DF
:1; ///< Direction Flag.
5393 UINT32 OF
:1; ///< Overflow Flag.
5394 UINT32 IOPL
:2; ///< I/O Privilege Level.
5395 UINT32 NT
:1; ///< Nested Task.
5396 UINT32 Reserved_3
:1; ///< Reserved.
5402 /// Byte packed structure for EFLAGS/RFLAGS.
5403 /// 32-bits on IA-32.
5404 /// 64-bits on x64. The upper 32-bits on x64 are reserved.
5408 UINT32 CF
:1; ///< Carry Flag.
5409 UINT32 Reserved_0
:1; ///< Reserved.
5410 UINT32 PF
:1; ///< Parity Flag.
5411 UINT32 Reserved_1
:1; ///< Reserved.
5412 UINT32 AF
:1; ///< Auxiliary Carry Flag.
5413 UINT32 Reserved_2
:1; ///< Reserved.
5414 UINT32 ZF
:1; ///< Zero Flag.
5415 UINT32 SF
:1; ///< Sign Flag.
5416 UINT32 TF
:1; ///< Trap Flag.
5417 UINT32 IF
:1; ///< Interrupt Enable Flag.
5418 UINT32 DF
:1; ///< Direction Flag.
5419 UINT32 OF
:1; ///< Overflow Flag.
5420 UINT32 IOPL
:2; ///< I/O Privilege Level.
5421 UINT32 NT
:1; ///< Nested Task.
5422 UINT32 Reserved_3
:1; ///< Reserved.
5423 UINT32 RF
:1; ///< Resume Flag.
5424 UINT32 VM
:1; ///< Virtual 8086 Mode.
5425 UINT32 AC
:1; ///< Alignment Check.
5426 UINT32 VIF
:1; ///< Virtual Interrupt Flag.
5427 UINT32 VIP
:1; ///< Virtual Interrupt Pending.
5428 UINT32 ID
:1; ///< ID Flag.
5429 UINT32 Reserved_4
:10; ///< Reserved.
5435 /// Byte packed structure for Control Register 0 (CR0).
5436 /// 32-bits on IA-32.
5437 /// 64-bits on x64. The upper 32-bits on x64 are reserved.
5441 UINT32 PE
:1; ///< Protection Enable.
5442 UINT32 MP
:1; ///< Monitor Coprocessor.
5443 UINT32 EM
:1; ///< Emulation.
5444 UINT32 TS
:1; ///< Task Switched.
5445 UINT32 ET
:1; ///< Extension Type.
5446 UINT32 NE
:1; ///< Numeric Error.
5447 UINT32 Reserved_0
:10; ///< Reserved.
5448 UINT32 WP
:1; ///< Write Protect.
5449 UINT32 Reserved_1
:1; ///< Reserved.
5450 UINT32 AM
:1; ///< Alignment Mask.
5451 UINT32 Reserved_2
:10; ///< Reserved.
5452 UINT32 NW
:1; ///< Mot Write-through.
5453 UINT32 CD
:1; ///< Cache Disable.
5454 UINT32 PG
:1; ///< Paging.
5460 /// Byte packed structure for Control Register 4 (CR4).
5461 /// 32-bits on IA-32.
5462 /// 64-bits on x64. The upper 32-bits on x64 are reserved.
5466 UINT32 VME
:1; ///< Virtual-8086 Mode Extensions.
5467 UINT32 PVI
:1; ///< Protected-Mode Virtual Interrupts.
5468 UINT32 TSD
:1; ///< Time Stamp Disable.
5469 UINT32 DE
:1; ///< Debugging Extensions.
5470 UINT32 PSE
:1; ///< Page Size Extensions.
5471 UINT32 PAE
:1; ///< Physical Address Extension.
5472 UINT32 MCE
:1; ///< Machine Check Enable.
5473 UINT32 PGE
:1; ///< Page Global Enable.
5474 UINT32 PCE
:1; ///< Performance Monitoring Counter
5476 UINT32 OSFXSR
:1; ///< Operating System Support for
5477 ///< FXSAVE and FXRSTOR instructions
5478 UINT32 OSXMMEXCPT
:1; ///< Operating System Support for
5479 ///< Unmasked SIMD Floating Point
5481 UINT32 Reserved_0
:2; ///< Reserved.
5482 UINT32 VMXE
:1; ///< VMX Enable
5483 UINT32 Reserved_1
:18; ///< Reserved.
5489 /// Byte packed structure for a segment descriptor in a GDT/LDT.
5508 } IA32_SEGMENT_DESCRIPTOR
;
5511 /// Byte packed structure for an IDTR, GDTR, LDTR descriptor.
5520 #define IA32_IDT_GATE_TYPE_TASK 0x85
5521 #define IA32_IDT_GATE_TYPE_INTERRUPT_16 0x86
5522 #define IA32_IDT_GATE_TYPE_TRAP_16 0x87
5523 #define IA32_IDT_GATE_TYPE_INTERRUPT_32 0x8E
5524 #define IA32_IDT_GATE_TYPE_TRAP_32 0x8F
5527 #if defined (MDE_CPU_IA32)
5529 /// Byte packed structure for an IA-32 Interrupt Gate Descriptor.
5533 UINT32 OffsetLow
:16; ///< Offset bits 15..0.
5534 UINT32 Selector
:16; ///< Selector.
5535 UINT32 Reserved_0
:8; ///< Reserved.
5536 UINT32 GateType
:8; ///< Gate Type. See #defines above.
5537 UINT32 OffsetHigh
:16; ///< Offset bits 31..16.
5540 } IA32_IDT_GATE_DESCRIPTOR
;
5544 #if defined (MDE_CPU_X64)
5546 /// Byte packed structure for an x64 Interrupt Gate Descriptor.
5550 UINT32 OffsetLow
:16; ///< Offset bits 15..0.
5551 UINT32 Selector
:16; ///< Selector.
5552 UINT32 Reserved_0
:8; ///< Reserved.
5553 UINT32 GateType
:8; ///< Gate Type. See #defines above.
5554 UINT32 OffsetHigh
:16; ///< Offset bits 31..16.
5555 UINT32 OffsetUpper
:32; ///< Offset bits 63..32.
5556 UINT32 Reserved_1
:32; ///< Reserved.
5562 } IA32_IDT_GATE_DESCRIPTOR
;
5567 /// Byte packed structure for an FP/SSE/SSE2 context.
5574 /// Structures for the 16-bit real mode thunks.
5627 IA32_EFLAGS32 EFLAGS
;
5637 } IA32_REGISTER_SET
;
5640 /// Byte packed structure for an 16-bit real mode thunks.
5643 IA32_REGISTER_SET
*RealModeState
;
5644 VOID
*RealModeBuffer
;
5645 UINT32 RealModeBufferSize
;
5646 UINT32 ThunkAttributes
;
5649 #define THUNK_ATTRIBUTE_BIG_REAL_MODE 0x00000001
5650 #define THUNK_ATTRIBUTE_DISABLE_A20_MASK_INT_15 0x00000002
5651 #define THUNK_ATTRIBUTE_DISABLE_A20_MASK_KBD_CTRL 0x00000004
5654 Retrieves CPUID information.
5656 Executes the CPUID instruction with EAX set to the value specified by Index.
5657 This function always returns Index.
5658 If Eax is not NULL, then the value of EAX after CPUID is returned in Eax.
5659 If Ebx is not NULL, then the value of EBX after CPUID is returned in Ebx.
5660 If Ecx is not NULL, then the value of ECX after CPUID is returned in Ecx.
5661 If Edx is not NULL, then the value of EDX after CPUID is returned in Edx.
5662 This function is only available on IA-32 and x64.
5664 @param Index The 32-bit value to load into EAX prior to invoking the CPUID
5666 @param Eax The pointer to the 32-bit EAX value returned by the CPUID
5667 instruction. This is an optional parameter that may be NULL.
5668 @param Ebx The pointer to the 32-bit EBX value returned by the CPUID
5669 instruction. This is an optional parameter that may be NULL.
5670 @param Ecx The pointer to the 32-bit ECX value returned by the CPUID
5671 instruction. This is an optional parameter that may be NULL.
5672 @param Edx The pointer to the 32-bit EDX value returned by the CPUID
5673 instruction. This is an optional parameter that may be NULL.
5682 OUT UINT32
*Eax
, OPTIONAL
5683 OUT UINT32
*Ebx
, OPTIONAL
5684 OUT UINT32
*Ecx
, OPTIONAL
5685 OUT UINT32
*Edx OPTIONAL
5690 Retrieves CPUID information using an extended leaf identifier.
5692 Executes the CPUID instruction with EAX set to the value specified by Index
5693 and ECX set to the value specified by SubIndex. This function always returns
5694 Index. This function is only available on IA-32 and x64.
5696 If Eax is not NULL, then the value of EAX after CPUID is returned in Eax.
5697 If Ebx is not NULL, then the value of EBX after CPUID is returned in Ebx.
5698 If Ecx is not NULL, then the value of ECX after CPUID is returned in Ecx.
5699 If Edx is not NULL, then the value of EDX after CPUID is returned in Edx.
5701 @param Index The 32-bit value to load into EAX prior to invoking the
5703 @param SubIndex The 32-bit value to load into ECX prior to invoking the
5705 @param Eax The pointer to the 32-bit EAX value returned by the CPUID
5706 instruction. This is an optional parameter that may be
5708 @param Ebx The pointer to the 32-bit EBX value returned by the CPUID
5709 instruction. This is an optional parameter that may be
5711 @param Ecx The pointer to the 32-bit ECX value returned by the CPUID
5712 instruction. This is an optional parameter that may be
5714 @param Edx The pointer to the 32-bit EDX value returned by the CPUID
5715 instruction. This is an optional parameter that may be
5726 OUT UINT32
*Eax
, OPTIONAL
5727 OUT UINT32
*Ebx
, OPTIONAL
5728 OUT UINT32
*Ecx
, OPTIONAL
5729 OUT UINT32
*Edx OPTIONAL
5734 Set CD bit and clear NW bit of CR0 followed by a WBINVD.
5736 Disables the caches by setting the CD bit of CR0 to 1, clearing the NW bit of CR0 to 0,
5737 and executing a WBINVD instruction. This function is only available on IA-32 and x64.
5748 Perform a WBINVD and clear both the CD and NW bits of CR0.
5750 Enables the caches by executing a WBINVD instruction and then clear both the CD and NW
5751 bits of CR0 to 0. This function is only available on IA-32 and x64.
5762 Returns the lower 32-bits of a Machine Specific Register(MSR).
5764 Reads and returns the lower 32-bits of the MSR specified by Index.
5765 No parameter checking is performed on Index, and some Index values may cause
5766 CPU exceptions. The caller must either guarantee that Index is valid, or the
5767 caller must set up exception handlers to catch the exceptions. This function
5768 is only available on IA-32 and x64.
5770 @param Index The 32-bit MSR index to read.
5772 @return The lower 32 bits of the MSR identified by Index.
5783 Writes a 32-bit value to a Machine Specific Register(MSR), and returns the value.
5784 The upper 32-bits of the MSR are set to zero.
5786 Writes the 32-bit value specified by Value to the MSR specified by Index. The
5787 upper 32-bits of the MSR write are set to zero. The 32-bit value written to
5788 the MSR is returned. No parameter checking is performed on Index or Value,
5789 and some of these may cause CPU exceptions. The caller must either guarantee
5790 that Index and Value are valid, or the caller must establish proper exception
5791 handlers. This function is only available on IA-32 and x64.
5793 @param Index The 32-bit MSR index to write.
5794 @param Value The 32-bit value to write to the MSR.
5808 Reads a 64-bit MSR, performs a bitwise OR on the lower 32-bits, and
5809 writes the result back to the 64-bit MSR.
5811 Reads the 64-bit MSR specified by Index, performs a bitwise OR
5812 between the lower 32-bits of the read result and the value specified by
5813 OrData, and writes the result to the 64-bit MSR specified by Index. The lower
5814 32-bits of the value written to the MSR is returned. No parameter checking is
5815 performed on Index or OrData, and some of these may cause CPU exceptions. The
5816 caller must either guarantee that Index and OrData are valid, or the caller
5817 must establish proper exception handlers. This function is only available on
5820 @param Index The 32-bit MSR index to write.
5821 @param OrData The value to OR with the read value from the MSR.
5823 @return The lower 32-bit value written to the MSR.
5835 Reads a 64-bit MSR, performs a bitwise AND on the lower 32-bits, and writes
5836 the result back to the 64-bit MSR.
5838 Reads the 64-bit MSR specified by Index, performs a bitwise AND between the
5839 lower 32-bits of the read result and the value specified by AndData, and
5840 writes the result to the 64-bit MSR specified by Index. The lower 32-bits of
5841 the value written to the MSR is returned. No parameter checking is performed
5842 on Index or AndData, and some of these may cause CPU exceptions. The caller
5843 must either guarantee that Index and AndData are valid, or the caller must
5844 establish proper exception handlers. This function is only available on IA-32
5847 @param Index The 32-bit MSR index to write.
5848 @param AndData The value to AND with the read value from the MSR.
5850 @return The lower 32-bit value written to the MSR.
5862 Reads a 64-bit MSR, performs a bitwise AND followed by a bitwise OR
5863 on the lower 32-bits, and writes the result back to the 64-bit MSR.
5865 Reads the 64-bit MSR specified by Index, performs a bitwise AND between the
5866 lower 32-bits of the read result and the value specified by AndData
5867 preserving the upper 32-bits, performs a bitwise OR between the
5868 result of the AND operation and the value specified by OrData, and writes the
5869 result to the 64-bit MSR specified by Address. The lower 32-bits of the value
5870 written to the MSR is returned. No parameter checking is performed on Index,
5871 AndData, or OrData, and some of these may cause CPU exceptions. The caller
5872 must either guarantee that Index, AndData, and OrData are valid, or the
5873 caller must establish proper exception handlers. This function is only
5874 available on IA-32 and x64.
5876 @param Index The 32-bit MSR index to write.
5877 @param AndData The value to AND with the read value from the MSR.
5878 @param OrData The value to OR with the result of the AND operation.
5880 @return The lower 32-bit value written to the MSR.
5893 Reads a bit field of an MSR.
5895 Reads the bit field in the lower 32-bits of a 64-bit MSR. The bit field is
5896 specified by the StartBit and the EndBit. The value of the bit field is
5897 returned. The caller must either guarantee that Index is valid, or the caller
5898 must set up exception handlers to catch the exceptions. This function is only
5899 available on IA-32 and x64.
5901 If StartBit is greater than 31, then ASSERT().
5902 If EndBit is greater than 31, then ASSERT().
5903 If EndBit is less than StartBit, then ASSERT().
5905 @param Index The 32-bit MSR index to read.
5906 @param StartBit The ordinal of the least significant bit in the bit field.
5908 @param EndBit The ordinal of the most significant bit in the bit field.
5911 @return The bit field read from the MSR.
5916 AsmMsrBitFieldRead32 (
5924 Writes a bit field to an MSR.
5926 Writes Value to a bit field in the lower 32-bits of a 64-bit MSR. The bit
5927 field is specified by the StartBit and the EndBit. All other bits in the
5928 destination MSR are preserved. The lower 32-bits of the MSR written is
5929 returned. The caller must either guarantee that Index and the data written
5930 is valid, or the caller must set up exception handlers to catch the exceptions.
5931 This function is only available on IA-32 and x64.
5933 If StartBit is greater than 31, then ASSERT().
5934 If EndBit is greater than 31, then ASSERT().
5935 If EndBit is less than StartBit, then ASSERT().
5936 If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
5938 @param Index The 32-bit MSR index to write.
5939 @param StartBit The ordinal of the least significant bit in the bit field.
5941 @param EndBit The ordinal of the most significant bit in the bit field.
5943 @param Value New value of the bit field.
5945 @return The lower 32-bit of the value written to the MSR.
5950 AsmMsrBitFieldWrite32 (
5959 Reads a bit field in a 64-bit MSR, performs a bitwise OR, and writes the
5960 result back to the bit field in the 64-bit MSR.
5962 Reads the 64-bit MSR specified by Index, performs a bitwise OR
5963 between the read result and the value specified by OrData, and writes the
5964 result to the 64-bit MSR specified by Index. The lower 32-bits of the value
5965 written to the MSR are returned. Extra left bits in OrData are stripped. The
5966 caller must either guarantee that Index and the data written is valid, or
5967 the caller must set up exception handlers to catch the exceptions. This
5968 function is only available on IA-32 and x64.
5970 If StartBit is greater than 31, then ASSERT().
5971 If EndBit is greater than 31, then ASSERT().
5972 If EndBit is less than StartBit, then ASSERT().
5973 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
5975 @param Index The 32-bit MSR index to write.
5976 @param StartBit The ordinal of the least significant bit in the bit field.
5978 @param EndBit The ordinal of the most significant bit in the bit field.
5980 @param OrData The value to OR with the read value from the MSR.
5982 @return The lower 32-bit of the value written to the MSR.
5987 AsmMsrBitFieldOr32 (
5996 Reads a bit field in a 64-bit MSR, performs a bitwise AND, and writes the
5997 result back to the bit field in the 64-bit MSR.
5999 Reads the 64-bit MSR specified by Index, performs a bitwise AND between the
6000 read result and the value specified by AndData, and writes the result to the
6001 64-bit MSR specified by Index. The lower 32-bits of the value written to the
6002 MSR are returned. Extra left bits in AndData are stripped. The caller must
6003 either guarantee that Index and the data written is valid, or the caller must
6004 set up exception handlers to catch the exceptions. This function is only
6005 available on IA-32 and x64.
6007 If StartBit is greater than 31, then ASSERT().
6008 If EndBit is greater than 31, then ASSERT().
6009 If EndBit is less than StartBit, then ASSERT().
6010 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
6012 @param Index The 32-bit MSR index to write.
6013 @param StartBit The ordinal of the least significant bit in the bit field.
6015 @param EndBit The ordinal of the most significant bit in the bit field.
6017 @param AndData The value to AND with the read value from the MSR.
6019 @return The lower 32-bit of the value written to the MSR.
6024 AsmMsrBitFieldAnd32 (
6033 Reads a bit field in a 64-bit MSR, performs a bitwise AND followed by a
6034 bitwise OR, and writes the result back to the bit field in the
6037 Reads the 64-bit MSR specified by Index, performs a bitwise AND followed by a
6038 bitwise OR between the read result and the value specified by
6039 AndData, and writes the result to the 64-bit MSR specified by Index. The
6040 lower 32-bits of the value written to the MSR are returned. Extra left bits
6041 in both AndData and OrData are stripped. The caller must either guarantee
6042 that Index and the data written is valid, or the caller must set up exception
6043 handlers to catch the exceptions. This function is only available on IA-32
6046 If StartBit is greater than 31, then ASSERT().
6047 If EndBit is greater than 31, then ASSERT().
6048 If EndBit is less than StartBit, then ASSERT().
6049 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
6050 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
6052 @param Index The 32-bit MSR index to write.
6053 @param StartBit The ordinal of the least significant bit in the bit field.
6055 @param EndBit The ordinal of the most significant bit in the bit field.
6057 @param AndData The value to AND with the read value from the MSR.
6058 @param OrData The value to OR with the result of the AND operation.
6060 @return The lower 32-bit of the value written to the MSR.
6065 AsmMsrBitFieldAndThenOr32 (
6075 Returns a 64-bit Machine Specific Register(MSR).
6077 Reads and returns the 64-bit MSR specified by Index. No parameter checking is
6078 performed on Index, and some Index values may cause CPU exceptions. The
6079 caller must either guarantee that Index is valid, or the caller must set up
6080 exception handlers to catch the exceptions. This function is only available
6083 @param Index The 32-bit MSR index to read.
6085 @return The value of the MSR identified by Index.
6096 Writes a 64-bit value to a Machine Specific Register(MSR), and returns the
6099 Writes the 64-bit value specified by Value to the MSR specified by Index. The
6100 64-bit value written to the MSR is returned. No parameter checking is
6101 performed on Index or Value, and some of these may cause CPU exceptions. The
6102 caller must either guarantee that Index and Value are valid, or the caller
6103 must establish proper exception handlers. This function is only available on
6106 @param Index The 32-bit MSR index to write.
6107 @param Value The 64-bit value to write to the MSR.
6121 Reads a 64-bit MSR, performs a bitwise OR, and writes the result
6122 back to the 64-bit MSR.
6124 Reads the 64-bit MSR specified by Index, performs a bitwise OR
6125 between the read result and the value specified by OrData, and writes the
6126 result to the 64-bit MSR specified by Index. The value written to the MSR is
6127 returned. No parameter checking is performed on Index or OrData, and some of
6128 these may cause CPU exceptions. The caller must either guarantee that Index
6129 and OrData are valid, or the caller must establish proper exception handlers.
6130 This function is only available on IA-32 and x64.
6132 @param Index The 32-bit MSR index to write.
6133 @param OrData The value to OR with the read value from the MSR.
6135 @return The value written back to the MSR.
6147 Reads a 64-bit MSR, performs a bitwise AND, and writes the result back to the
6150 Reads the 64-bit MSR specified by Index, performs a bitwise AND between the
6151 read result and the value specified by OrData, and writes the result to the
6152 64-bit MSR specified by Index. The value written to the MSR is returned. No
6153 parameter checking is performed on Index or OrData, and some of these may
6154 cause CPU exceptions. The caller must either guarantee that Index and OrData
6155 are valid, or the caller must establish proper exception handlers. This
6156 function is only available on IA-32 and x64.
6158 @param Index The 32-bit MSR index to write.
6159 @param AndData The value to AND with the read value from the MSR.
6161 @return The value written back to the MSR.
6173 Reads a 64-bit MSR, performs a bitwise AND followed by a bitwise
6174 OR, and writes the result back to the 64-bit MSR.
6176 Reads the 64-bit MSR specified by Index, performs a bitwise AND between read
6177 result and the value specified by AndData, performs a bitwise OR
6178 between the result of the AND operation and the value specified by OrData,
6179 and writes the result to the 64-bit MSR specified by Index. The value written
6180 to the MSR is returned. No parameter checking is performed on Index, AndData,
6181 or OrData, and some of these may cause CPU exceptions. The caller must either
6182 guarantee that Index, AndData, and OrData are valid, or the caller must
6183 establish proper exception handlers. This function is only available on IA-32
6186 @param Index The 32-bit MSR index to write.
6187 @param AndData The value to AND with the read value from the MSR.
6188 @param OrData The value to OR with the result of the AND operation.
6190 @return The value written back to the MSR.
6203 Reads a bit field of an MSR.
6205 Reads the bit field in the 64-bit MSR. The bit field is specified by the
6206 StartBit and the EndBit. The value of the bit field is returned. The caller
6207 must either guarantee that Index is valid, or the caller must set up
6208 exception handlers to catch the exceptions. This function is only available
6211 If StartBit is greater than 63, then ASSERT().
6212 If EndBit is greater than 63, then ASSERT().
6213 If EndBit is less than StartBit, then ASSERT().
6215 @param Index The 32-bit MSR index to read.
6216 @param StartBit The ordinal of the least significant bit in the bit field.
6218 @param EndBit The ordinal of the most significant bit in the bit field.
6221 @return The value read from the MSR.
6226 AsmMsrBitFieldRead64 (
6234 Writes a bit field to an MSR.
6236 Writes Value to a bit field in a 64-bit MSR. The bit field is specified by
6237 the StartBit and the EndBit. All other bits in the destination MSR are
6238 preserved. The MSR written is returned. The caller must either guarantee
6239 that Index and the data written is valid, or the caller must set up exception
6240 handlers to catch the exceptions. This function is only available on IA-32 and x64.
6242 If StartBit is greater than 63, then ASSERT().
6243 If EndBit is greater than 63, then ASSERT().
6244 If EndBit is less than StartBit, then ASSERT().
6245 If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
6247 @param Index The 32-bit MSR index to write.
6248 @param StartBit The ordinal of the least significant bit in the bit field.
6250 @param EndBit The ordinal of the most significant bit in the bit field.
6252 @param Value New value of the bit field.
6254 @return The value written back to the MSR.
6259 AsmMsrBitFieldWrite64 (
6268 Reads a bit field in a 64-bit MSR, performs a bitwise OR, and
6269 writes the result back to the bit field in the 64-bit MSR.
6271 Reads the 64-bit MSR specified by Index, performs a bitwise OR
6272 between the read result and the value specified by OrData, and writes the
6273 result to the 64-bit MSR specified by Index. The value written to the MSR is
6274 returned. Extra left bits in OrData are stripped. The caller must either
6275 guarantee that Index and the data written is valid, or the caller must set up
6276 exception handlers to catch the exceptions. This function is only available
6279 If StartBit is greater than 63, then ASSERT().
6280 If EndBit is greater than 63, then ASSERT().
6281 If EndBit is less than StartBit, then ASSERT().
6282 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
6284 @param Index The 32-bit MSR index to write.
6285 @param StartBit The ordinal of the least significant bit in the bit field.
6287 @param EndBit The ordinal of the most significant bit in the bit field.
6289 @param OrData The value to OR with the read value from the bit field.
6291 @return The value written back to the MSR.
6296 AsmMsrBitFieldOr64 (
6305 Reads a bit field in a 64-bit MSR, performs a bitwise AND, and writes the
6306 result back to the bit field in the 64-bit MSR.
6308 Reads the 64-bit MSR specified by Index, performs a bitwise AND between the
6309 read result and the value specified by AndData, and writes the result to the
6310 64-bit MSR specified by Index. The value written to the MSR is returned.
6311 Extra left bits in AndData are stripped. The caller must either guarantee
6312 that Index and the data written is valid, or the caller must set up exception
6313 handlers to catch the exceptions. This function is only available on IA-32
6316 If StartBit is greater than 63, then ASSERT().
6317 If EndBit is greater than 63, then ASSERT().
6318 If EndBit is less than StartBit, then ASSERT().
6319 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
6321 @param Index The 32-bit MSR index to write.
6322 @param StartBit The ordinal of the least significant bit in the bit field.
6324 @param EndBit The ordinal of the most significant bit in the bit field.
6326 @param AndData The value to AND with the read value from the bit field.
6328 @return The value written back to the MSR.
6333 AsmMsrBitFieldAnd64 (
6342 Reads a bit field in a 64-bit MSR, performs a bitwise AND followed by a
6343 bitwise OR, and writes the result back to the bit field in the
6346 Reads the 64-bit MSR specified by Index, performs a bitwise AND followed by
6347 a bitwise OR between the read result and the value specified by
6348 AndData, and writes the result to the 64-bit MSR specified by Index. The
6349 value written to the MSR is returned. Extra left bits in both AndData and
6350 OrData are stripped. The caller must either guarantee that Index and the data
6351 written is valid, or the caller must set up exception handlers to catch the
6352 exceptions. This function is only available on IA-32 and x64.
6354 If StartBit is greater than 63, then ASSERT().
6355 If EndBit is greater than 63, then ASSERT().
6356 If EndBit is less than StartBit, then ASSERT().
6357 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
6358 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
6360 @param Index The 32-bit MSR index to write.
6361 @param StartBit The ordinal of the least significant bit in the bit field.
6363 @param EndBit The ordinal of the most significant bit in the bit field.
6365 @param AndData The value to AND with the read value from the bit field.
6366 @param OrData The value to OR with the result of the AND operation.
6368 @return The value written back to the MSR.
6373 AsmMsrBitFieldAndThenOr64 (
6383 Reads the current value of the EFLAGS register.
6385 Reads and returns the current value of the EFLAGS register. This function is
6386 only available on IA-32 and x64. This returns a 32-bit value on IA-32 and a
6387 64-bit value on x64.
6389 @return EFLAGS on IA-32 or RFLAGS on x64.
6400 Reads the current value of the Control Register 0 (CR0).
6402 Reads and returns the current value of CR0. This function is only available
6403 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
6406 @return The value of the Control Register 0 (CR0).
6417 Reads the current value of the Control Register 2 (CR2).
6419 Reads and returns the current value of CR2. This function is only available
6420 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
6423 @return The value of the Control Register 2 (CR2).
6434 Reads the current value of the Control Register 3 (CR3).
6436 Reads and returns the current value of CR3. This function is only available
6437 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
6440 @return The value of the Control Register 3 (CR3).
6451 Reads the current value of the Control Register 4 (CR4).
6453 Reads and returns the current value of CR4. This function is only available
6454 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
6457 @return The value of the Control Register 4 (CR4).
6468 Writes a value to Control Register 0 (CR0).
6470 Writes and returns a new value to CR0. This function is only available on
6471 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
6473 @param Cr0 The value to write to CR0.
6475 @return The value written to CR0.
6486 Writes a value to Control Register 2 (CR2).
6488 Writes and returns a new value to CR2. This function is only available on
6489 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
6491 @param Cr2 The value to write to CR2.
6493 @return The value written to CR2.
6504 Writes a value to Control Register 3 (CR3).
6506 Writes and returns a new value to CR3. This function is only available on
6507 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
6509 @param Cr3 The value to write to CR3.
6511 @return The value written to CR3.
6522 Writes a value to Control Register 4 (CR4).
6524 Writes and returns a new value to CR4. This function is only available on
6525 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
6527 @param Cr4 The value to write to CR4.
6529 @return The value written to CR4.
6540 Reads the current value of Debug Register 0 (DR0).
6542 Reads and returns the current value of DR0. This function is only available
6543 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
6546 @return The value of Debug Register 0 (DR0).
6557 Reads the current value of Debug Register 1 (DR1).
6559 Reads and returns the current value of DR1. This function is only available
6560 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
6563 @return The value of Debug Register 1 (DR1).
6574 Reads the current value of Debug Register 2 (DR2).
6576 Reads and returns the current value of DR2. This function is only available
6577 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
6580 @return The value of Debug Register 2 (DR2).
6591 Reads the current value of Debug Register 3 (DR3).
6593 Reads and returns the current value of DR3. This function is only available
6594 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
6597 @return The value of Debug Register 3 (DR3).
6608 Reads the current value of Debug Register 4 (DR4).
6610 Reads and returns the current value of DR4. This function is only available
6611 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
6614 @return The value of Debug Register 4 (DR4).
6625 Reads the current value of Debug Register 5 (DR5).
6627 Reads and returns the current value of DR5. This function is only available
6628 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
6631 @return The value of Debug Register 5 (DR5).
6642 Reads the current value of Debug Register 6 (DR6).
6644 Reads and returns the current value of DR6. This function is only available
6645 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
6648 @return The value of Debug Register 6 (DR6).
6659 Reads the current value of Debug Register 7 (DR7).
6661 Reads and returns the current value of DR7. This function is only available
6662 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
6665 @return The value of Debug Register 7 (DR7).
6676 Writes a value to Debug Register 0 (DR0).
6678 Writes and returns a new value to DR0. This function is only available on
6679 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
6681 @param Dr0 The value to write to Dr0.
6683 @return The value written to Debug Register 0 (DR0).
6694 Writes a value to Debug Register 1 (DR1).
6696 Writes and returns a new value to DR1. This function is only available on
6697 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
6699 @param Dr1 The value to write to Dr1.
6701 @return The value written to Debug Register 1 (DR1).
6712 Writes a value to Debug Register 2 (DR2).
6714 Writes and returns a new value to DR2. This function is only available on
6715 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
6717 @param Dr2 The value to write to Dr2.
6719 @return The value written to Debug Register 2 (DR2).
6730 Writes a value to Debug Register 3 (DR3).
6732 Writes and returns a new value to DR3. This function is only available on
6733 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
6735 @param Dr3 The value to write to Dr3.
6737 @return The value written to Debug Register 3 (DR3).
6748 Writes a value to Debug Register 4 (DR4).
6750 Writes and returns a new value to DR4. This function is only available on
6751 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
6753 @param Dr4 The value to write to Dr4.
6755 @return The value written to Debug Register 4 (DR4).
6766 Writes a value to Debug Register 5 (DR5).
6768 Writes and returns a new value to DR5. This function is only available on
6769 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
6771 @param Dr5 The value to write to Dr5.
6773 @return The value written to Debug Register 5 (DR5).
6784 Writes a value to Debug Register 6 (DR6).
6786 Writes and returns a new value to DR6. This function is only available on
6787 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
6789 @param Dr6 The value to write to Dr6.
6791 @return The value written to Debug Register 6 (DR6).
6802 Writes a value to Debug Register 7 (DR7).
6804 Writes and returns a new value to DR7. This function is only available on
6805 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
6807 @param Dr7 The value to write to Dr7.
6809 @return The value written to Debug Register 7 (DR7).
6820 Reads the current value of Code Segment Register (CS).
6822 Reads and returns the current value of CS. This function is only available on
6825 @return The current value of CS.
6836 Reads the current value of Data Segment Register (DS).
6838 Reads and returns the current value of DS. This function is only available on
6841 @return The current value of DS.
6852 Reads the current value of Extra Segment Register (ES).
6854 Reads and returns the current value of ES. This function is only available on
6857 @return The current value of ES.
6868 Reads the current value of FS Data Segment Register (FS).
6870 Reads and returns the current value of FS. This function is only available on
6873 @return The current value of FS.
6884 Reads the current value of GS Data Segment Register (GS).
6886 Reads and returns the current value of GS. This function is only available on
6889 @return The current value of GS.
6900 Reads the current value of Stack Segment Register (SS).
6902 Reads and returns the current value of SS. This function is only available on
6905 @return The current value of SS.
6916 Reads the current value of Task Register (TR).
6918 Reads and returns the current value of TR. This function is only available on
6921 @return The current value of TR.
6932 Reads the current Global Descriptor Table Register(GDTR) descriptor.
6934 Reads and returns the current GDTR descriptor and returns it in Gdtr. This
6935 function is only available on IA-32 and x64.
6937 If Gdtr is NULL, then ASSERT().
6939 @param Gdtr The pointer to a GDTR descriptor.
6945 OUT IA32_DESCRIPTOR
*Gdtr
6950 Writes the current Global Descriptor Table Register (GDTR) descriptor.
6952 Writes and the current GDTR descriptor specified by Gdtr. This function is
6953 only available on IA-32 and x64.
6955 If Gdtr is NULL, then ASSERT().
6957 @param Gdtr The pointer to a GDTR descriptor.
6963 IN CONST IA32_DESCRIPTOR
*Gdtr
6968 Reads the current Interrupt Descriptor Table Register(IDTR) descriptor.
6970 Reads and returns the current IDTR descriptor and returns it in Idtr. This
6971 function is only available on IA-32 and x64.
6973 If Idtr is NULL, then ASSERT().
6975 @param Idtr The pointer to a IDTR descriptor.
6981 OUT IA32_DESCRIPTOR
*Idtr
6986 Writes the current Interrupt Descriptor Table Register(IDTR) descriptor.
6988 Writes the current IDTR descriptor and returns it in Idtr. This function is
6989 only available on IA-32 and x64.
6991 If Idtr is NULL, then ASSERT().
6993 @param Idtr The pointer to a IDTR descriptor.
6999 IN CONST IA32_DESCRIPTOR
*Idtr
7004 Reads the current Local Descriptor Table Register(LDTR) selector.
7006 Reads and returns the current 16-bit LDTR descriptor value. This function is
7007 only available on IA-32 and x64.
7009 @return The current selector of LDT.
7020 Writes the current Local Descriptor Table Register (LDTR) selector.
7022 Writes and the current LDTR descriptor specified by Ldtr. This function is
7023 only available on IA-32 and x64.
7025 @param Ldtr 16-bit LDTR selector value.
7036 Save the current floating point/SSE/SSE2 context to a buffer.
7038 Saves the current floating point/SSE/SSE2 state to the buffer specified by
7039 Buffer. Buffer must be aligned on a 16-byte boundary. This function is only
7040 available on IA-32 and x64.
7042 If Buffer is NULL, then ASSERT().
7043 If Buffer is not aligned on a 16-byte boundary, then ASSERT().
7045 @param Buffer The pointer to a buffer to save the floating point/SSE/SSE2 context.
7051 OUT IA32_FX_BUFFER
*Buffer
7056 Restores the current floating point/SSE/SSE2 context from a buffer.
7058 Restores the current floating point/SSE/SSE2 state from the buffer specified
7059 by Buffer. Buffer must be aligned on a 16-byte boundary. This function is
7060 only available on IA-32 and x64.
7062 If Buffer is NULL, then ASSERT().
7063 If Buffer is not aligned on a 16-byte boundary, then ASSERT().
7064 If Buffer was not saved with AsmFxSave(), then ASSERT().
7066 @param Buffer The pointer to a buffer to save the floating point/SSE/SSE2 context.
7072 IN CONST IA32_FX_BUFFER
*Buffer
7077 Reads the current value of 64-bit MMX Register #0 (MM0).
7079 Reads and returns the current value of MM0. This function is only available
7082 @return The current value of MM0.
7093 Reads the current value of 64-bit MMX Register #1 (MM1).
7095 Reads and returns the current value of MM1. This function is only available
7098 @return The current value of MM1.
7109 Reads the current value of 64-bit MMX Register #2 (MM2).
7111 Reads and returns the current value of MM2. This function is only available
7114 @return The current value of MM2.
7125 Reads the current value of 64-bit MMX Register #3 (MM3).
7127 Reads and returns the current value of MM3. This function is only available
7130 @return The current value of MM3.
7141 Reads the current value of 64-bit MMX Register #4 (MM4).
7143 Reads and returns the current value of MM4. This function is only available
7146 @return The current value of MM4.
7157 Reads the current value of 64-bit MMX Register #5 (MM5).
7159 Reads and returns the current value of MM5. This function is only available
7162 @return The current value of MM5.
7173 Reads the current value of 64-bit MMX Register #6 (MM6).
7175 Reads and returns the current value of MM6. This function is only available
7178 @return The current value of MM6.
7189 Reads the current value of 64-bit MMX Register #7 (MM7).
7191 Reads and returns the current value of MM7. This function is only available
7194 @return The current value of MM7.
7205 Writes the current value of 64-bit MMX Register #0 (MM0).
7207 Writes the current value of MM0. This function is only available on IA32 and
7210 @param Value The 64-bit value to write to MM0.
7221 Writes the current value of 64-bit MMX Register #1 (MM1).
7223 Writes the current value of MM1. This function is only available on IA32 and
7226 @param Value The 64-bit value to write to MM1.
7237 Writes the current value of 64-bit MMX Register #2 (MM2).
7239 Writes the current value of MM2. This function is only available on IA32 and
7242 @param Value The 64-bit value to write to MM2.
7253 Writes the current value of 64-bit MMX Register #3 (MM3).
7255 Writes the current value of MM3. This function is only available on IA32 and
7258 @param Value The 64-bit value to write to MM3.
7269 Writes the current value of 64-bit MMX Register #4 (MM4).
7271 Writes the current value of MM4. This function is only available on IA32 and
7274 @param Value The 64-bit value to write to MM4.
7285 Writes the current value of 64-bit MMX Register #5 (MM5).
7287 Writes the current value of MM5. This function is only available on IA32 and
7290 @param Value The 64-bit value to write to MM5.
7301 Writes the current value of 64-bit MMX Register #6 (MM6).
7303 Writes the current value of MM6. This function is only available on IA32 and
7306 @param Value The 64-bit value to write to MM6.
7317 Writes the current value of 64-bit MMX Register #7 (MM7).
7319 Writes the current value of MM7. This function is only available on IA32 and
7322 @param Value The 64-bit value to write to MM7.
7333 Reads the current value of Time Stamp Counter (TSC).
7335 Reads and returns the current value of TSC. This function is only available
7338 @return The current value of TSC
7349 Reads the current value of a Performance Counter (PMC).
7351 Reads and returns the current value of performance counter specified by
7352 Index. This function is only available on IA-32 and x64.
7354 @param Index The 32-bit Performance Counter index to read.
7356 @return The value of the PMC specified by Index.
7367 Sets up a monitor buffer that is used by AsmMwait().
7369 Executes a MONITOR instruction with the register state specified by Eax, Ecx
7370 and Edx. Returns Eax. This function is only available on IA-32 and x64.
7372 @param Eax The value to load into EAX or RAX before executing the MONITOR
7374 @param Ecx The value to load into ECX or RCX before executing the MONITOR
7376 @param Edx The value to load into EDX or RDX before executing the MONITOR
7392 Executes an MWAIT instruction.
7394 Executes an MWAIT instruction with the register state specified by Eax and
7395 Ecx. Returns Eax. This function is only available on IA-32 and x64.
7397 @param Eax The value to load into EAX or RAX before executing the MONITOR
7399 @param Ecx The value to load into ECX or RCX before executing the MONITOR
7414 Executes a WBINVD instruction.
7416 Executes a WBINVD instruction. This function is only available on IA-32 and
7428 Executes a INVD instruction.
7430 Executes a INVD instruction. This function is only available on IA-32 and
7442 Flushes a cache line from all the instruction and data caches within the
7443 coherency domain of the CPU.
7445 Flushed the cache line specified by LinearAddress, and returns LinearAddress.
7446 This function is only available on IA-32 and x64.
7448 @param LinearAddress The address of the cache line to flush. If the CPU is
7449 in a physical addressing mode, then LinearAddress is a
7450 physical address. If the CPU is in a virtual
7451 addressing mode, then LinearAddress is a virtual
7454 @return LinearAddress.
7459 IN VOID
*LinearAddress
7464 Enables the 32-bit paging mode on the CPU.
7466 Enables the 32-bit paging mode on the CPU. CR0, CR3, CR4, and the page tables
7467 must be properly initialized prior to calling this service. This function
7468 assumes the current execution mode is 32-bit protected mode. This function is
7469 only available on IA-32. After the 32-bit paging mode is enabled, control is
7470 transferred to the function specified by EntryPoint using the new stack
7471 specified by NewStack and passing in the parameters specified by Context1 and
7472 Context2. Context1 and Context2 are optional and may be NULL. The function
7473 EntryPoint must never return.
7475 If the current execution mode is not 32-bit protected mode, then ASSERT().
7476 If EntryPoint is NULL, then ASSERT().
7477 If NewStack is NULL, then ASSERT().
7479 There are a number of constraints that must be followed before calling this
7481 1) Interrupts must be disabled.
7482 2) The caller must be in 32-bit protected mode with flat descriptors. This
7483 means all descriptors must have a base of 0 and a limit of 4GB.
7484 3) CR0 and CR4 must be compatible with 32-bit protected mode with flat
7486 4) CR3 must point to valid page tables that will be used once the transition
7487 is complete, and those page tables must guarantee that the pages for this
7488 function and the stack are identity mapped.
7490 @param EntryPoint A pointer to function to call with the new stack after
7492 @param Context1 A pointer to the context to pass into the EntryPoint
7493 function as the first parameter after paging is enabled.
7494 @param Context2 A pointer to the context to pass into the EntryPoint
7495 function as the second parameter after paging is enabled.
7496 @param NewStack A pointer to the new stack to use for the EntryPoint
7497 function after paging is enabled.
7503 IN SWITCH_STACK_ENTRY_POINT EntryPoint
,
7504 IN VOID
*Context1
, OPTIONAL
7505 IN VOID
*Context2
, OPTIONAL
7511 Disables the 32-bit paging mode on the CPU.
7513 Disables the 32-bit paging mode on the CPU and returns to 32-bit protected
7514 mode. This function assumes the current execution mode is 32-paged protected
7515 mode. This function is only available on IA-32. After the 32-bit paging mode
7516 is disabled, control is transferred to the function specified by EntryPoint
7517 using the new stack specified by NewStack and passing in the parameters
7518 specified by Context1 and Context2. Context1 and Context2 are optional and
7519 may be NULL. The function EntryPoint must never return.
7521 If the current execution mode is not 32-bit paged mode, then ASSERT().
7522 If EntryPoint is NULL, then ASSERT().
7523 If NewStack is NULL, then ASSERT().
7525 There are a number of constraints that must be followed before calling this
7527 1) Interrupts must be disabled.
7528 2) The caller must be in 32-bit paged mode.
7529 3) CR0, CR3, and CR4 must be compatible with 32-bit paged mode.
7530 4) CR3 must point to valid page tables that guarantee that the pages for
7531 this function and the stack are identity mapped.
7533 @param EntryPoint A pointer to function to call with the new stack after
7535 @param Context1 A pointer to the context to pass into the EntryPoint
7536 function as the first parameter after paging is disabled.
7537 @param Context2 A pointer to the context to pass into the EntryPoint
7538 function as the second parameter after paging is
7540 @param NewStack A pointer to the new stack to use for the EntryPoint
7541 function after paging is disabled.
7546 AsmDisablePaging32 (
7547 IN SWITCH_STACK_ENTRY_POINT EntryPoint
,
7548 IN VOID
*Context1
, OPTIONAL
7549 IN VOID
*Context2
, OPTIONAL
7555 Enables the 64-bit paging mode on the CPU.
7557 Enables the 64-bit paging mode on the CPU. CR0, CR3, CR4, and the page tables
7558 must be properly initialized prior to calling this service. This function
7559 assumes the current execution mode is 32-bit protected mode with flat
7560 descriptors. This function is only available on IA-32. After the 64-bit
7561 paging mode is enabled, control is transferred to the function specified by
7562 EntryPoint using the new stack specified by NewStack and passing in the
7563 parameters specified by Context1 and Context2. Context1 and Context2 are
7564 optional and may be 0. The function EntryPoint must never return.
7566 If the current execution mode is not 32-bit protected mode with flat
7567 descriptors, then ASSERT().
7568 If EntryPoint is 0, then ASSERT().
7569 If NewStack is 0, then ASSERT().
7571 @param Cs The 16-bit selector to load in the CS before EntryPoint
7572 is called. The descriptor in the GDT that this selector
7573 references must be setup for long mode.
7574 @param EntryPoint The 64-bit virtual address of the function to call with
7575 the new stack after paging is enabled.
7576 @param Context1 The 64-bit virtual address of the context to pass into
7577 the EntryPoint function as the first parameter after
7579 @param Context2 The 64-bit virtual address of the context to pass into
7580 the EntryPoint function as the second parameter after
7582 @param NewStack The 64-bit virtual address of the new stack to use for
7583 the EntryPoint function after paging is enabled.
7590 IN UINT64 EntryPoint
,
7591 IN UINT64 Context1
, OPTIONAL
7592 IN UINT64 Context2
, OPTIONAL
7598 Disables the 64-bit paging mode on the CPU.
7600 Disables the 64-bit paging mode on the CPU and returns to 32-bit protected
7601 mode. This function assumes the current execution mode is 64-paging mode.
7602 This function is only available on x64. After the 64-bit paging mode is
7603 disabled, control is transferred to the function specified by EntryPoint
7604 using the new stack specified by NewStack and passing in the parameters
7605 specified by Context1 and Context2. Context1 and Context2 are optional and
7606 may be 0. The function EntryPoint must never return.
7608 If the current execution mode is not 64-bit paged mode, then ASSERT().
7609 If EntryPoint is 0, then ASSERT().
7610 If NewStack is 0, then ASSERT().
7612 @param Cs The 16-bit selector to load in the CS before EntryPoint
7613 is called. The descriptor in the GDT that this selector
7614 references must be setup for 32-bit protected mode.
7615 @param EntryPoint The 64-bit virtual address of the function to call with
7616 the new stack after paging is disabled.
7617 @param Context1 The 64-bit virtual address of the context to pass into
7618 the EntryPoint function as the first parameter after
7620 @param Context2 The 64-bit virtual address of the context to pass into
7621 the EntryPoint function as the second parameter after
7623 @param NewStack The 64-bit virtual address of the new stack to use for
7624 the EntryPoint function after paging is disabled.
7629 AsmDisablePaging64 (
7631 IN UINT32 EntryPoint
,
7632 IN UINT32 Context1
, OPTIONAL
7633 IN UINT32 Context2
, OPTIONAL
7639 // 16-bit thunking services
7643 Retrieves the properties for 16-bit thunk functions.
7645 Computes the size of the buffer and stack below 1MB required to use the
7646 AsmPrepareThunk16(), AsmThunk16() and AsmPrepareAndThunk16() functions. This
7647 buffer size is returned in RealModeBufferSize, and the stack size is returned
7648 in ExtraStackSize. If parameters are passed to the 16-bit real mode code,
7649 then the actual minimum stack size is ExtraStackSize plus the maximum number
7650 of bytes that need to be passed to the 16-bit real mode code.
7652 If RealModeBufferSize is NULL, then ASSERT().
7653 If ExtraStackSize is NULL, then ASSERT().
7655 @param RealModeBufferSize A pointer to the size of the buffer below 1MB
7656 required to use the 16-bit thunk functions.
7657 @param ExtraStackSize A pointer to the extra size of stack below 1MB
7658 that the 16-bit thunk functions require for
7659 temporary storage in the transition to and from
7665 AsmGetThunk16Properties (
7666 OUT UINT32
*RealModeBufferSize
,
7667 OUT UINT32
*ExtraStackSize
7672 Prepares all structures a code required to use AsmThunk16().
7674 Prepares all structures and code required to use AsmThunk16().
7676 This interface is limited to be used in either physical mode or virtual modes with paging enabled where the
7677 virtual to physical mappings for ThunkContext.RealModeBuffer is mapped 1:1.
7679 If ThunkContext is NULL, then ASSERT().
7681 @param ThunkContext A pointer to the context structure that describes the
7682 16-bit real mode code to call.
7688 IN OUT THUNK_CONTEXT
*ThunkContext
7693 Transfers control to a 16-bit real mode entry point and returns the results.
7695 Transfers control to a 16-bit real mode entry point and returns the results.
7696 AsmPrepareThunk16() must be called with ThunkContext before this function is used.
7697 This function must be called with interrupts disabled.
7699 The register state from the RealModeState field of ThunkContext is restored just prior
7700 to calling the 16-bit real mode entry point. This includes the EFLAGS field of RealModeState,
7701 which is used to set the interrupt state when a 16-bit real mode entry point is called.
7702 Control is transferred to the 16-bit real mode entry point specified by the CS and Eip fields of RealModeState.
7703 The stack is initialized to the SS and ESP fields of RealModeState. Any parameters passed to
7704 the 16-bit real mode code must be populated by the caller at SS:ESP prior to calling this function.
7705 The 16-bit real mode entry point is invoked with a 16-bit CALL FAR instruction,
7706 so when accessing stack contents, the 16-bit real mode code must account for the 16-bit segment
7707 and 16-bit offset of the return address that were pushed onto the stack. The 16-bit real mode entry
7708 point must exit with a RETF instruction. The register state is captured into RealModeState immediately
7709 after the RETF instruction is executed.
7711 If EFLAGS specifies interrupts enabled, or any of the 16-bit real mode code enables interrupts,
7712 or any of the 16-bit real mode code makes a SW interrupt, then the caller is responsible for making sure
7713 the IDT at address 0 is initialized to handle any HW or SW interrupts that may occur while in 16-bit real mode.
7715 If EFLAGS specifies interrupts enabled, or any of the 16-bit real mode code enables interrupts,
7716 then the caller is responsible for making sure the 8259 PIC is in a state compatible with 16-bit real mode.
7717 This includes the base vectors, the interrupt masks, and the edge/level trigger mode.
7719 If THUNK_ATTRIBUTE_BIG_REAL_MODE is set in the ThunkAttributes field of ThunkContext, then the user code
7720 is invoked in big real mode. Otherwise, the user code is invoked in 16-bit real mode with 64KB segment limits.
7722 If neither THUNK_ATTRIBUTE_DISABLE_A20_MASK_INT_15 nor THUNK_ATTRIBUTE_DISABLE_A20_MASK_KBD_CTRL are set in
7723 ThunkAttributes, then it is assumed that the user code did not enable the A20 mask, and no attempt is made to
7724 disable the A20 mask.
7726 If THUNK_ATTRIBUTE_DISABLE_A20_MASK_INT_15 is set and THUNK_ATTRIBUTE_DISABLE_A20_MASK_KBD_CTRL is clear in
7727 ThunkAttributes, then attempt to use the INT 15 service to disable the A20 mask. If this INT 15 call fails,
7728 then attempt to disable the A20 mask by directly accessing the 8042 keyboard controller I/O ports.
7730 If THUNK_ATTRIBUTE_DISABLE_A20_MASK_INT_15 is clear and THUNK_ATTRIBUTE_DISABLE_A20_MASK_KBD_CTRL is set in
7731 ThunkAttributes, then attempt to disable the A20 mask by directly accessing the 8042 keyboard controller I/O ports.
7733 If ThunkContext is NULL, then ASSERT().
7734 If AsmPrepareThunk16() was not previously called with ThunkContext, then ASSERT().
7735 If both THUNK_ATTRIBUTE_DISABLE_A20_MASK_INT_15 and THUNK_ATTRIBUTE_DISABLE_A20_MASK_KBD_CTRL are set in
7736 ThunkAttributes, then ASSERT().
7738 This interface is limited to be used in either physical mode or virtual modes with paging enabled where the
7739 virtual to physical mappings for ThunkContext.RealModeBuffer are mapped 1:1.
7741 @param ThunkContext A pointer to the context structure that describes the
7742 16-bit real mode code to call.
7748 IN OUT THUNK_CONTEXT
*ThunkContext
7753 Prepares all structures and code for a 16-bit real mode thunk, transfers
7754 control to a 16-bit real mode entry point, and returns the results.
7756 Prepares all structures and code for a 16-bit real mode thunk, transfers
7757 control to a 16-bit real mode entry point, and returns the results. If the
7758 caller only need to perform a single 16-bit real mode thunk, then this
7759 service should be used. If the caller intends to make more than one 16-bit
7760 real mode thunk, then it is more efficient if AsmPrepareThunk16() is called
7761 once and AsmThunk16() can be called for each 16-bit real mode thunk.
7763 This interface is limited to be used in either physical mode or virtual modes with paging enabled where the
7764 virtual to physical mappings for ThunkContext.RealModeBuffer is mapped 1:1.
7766 See AsmPrepareThunk16() and AsmThunk16() for the detailed description and ASSERT() conditions.
7768 @param ThunkContext A pointer to the context structure that describes the
7769 16-bit real mode code to call.
7774 AsmPrepareAndThunk16 (
7775 IN OUT THUNK_CONTEXT
*ThunkContext
7779 Generates a 16-bit random number through RDRAND instruction.
7781 if Rand is NULL, then ASSERT().
7783 @param[out] Rand Buffer pointer to store the random result.
7785 @retval TRUE RDRAND call was successful.
7786 @retval FALSE Failed attempts to call RDRAND.
7796 Generates a 32-bit random number through RDRAND instruction.
7798 if Rand is NULL, then ASSERT().
7800 @param[out] Rand Buffer pointer to store the random result.
7802 @retval TRUE RDRAND call was successful.
7803 @retval FALSE Failed attempts to call RDRAND.
7813 Generates a 64-bit random number through RDRAND instruction.
7815 if Rand is NULL, then ASSERT().
7817 @param[out] Rand Buffer pointer to store the random result.
7819 @retval TRUE RDRAND call was successful.
7820 @retval FALSE Failed attempts to call RDRAND.