2 Provides string functions, linked list functions, math functions, synchronization
3 functions, file path functions, and CPU architecture-specific functions.
5 Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.<BR>
6 Portions copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>
7 This program and the accompanying materials
8 are licensed and made available under the terms and conditions of the BSD License
9 which accompanies this distribution. The full text of the license may be found at
10 http://opensource.org/licenses/bsd-license.php.
12 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
13 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
21 // Definitions for architecture-specific types
23 #if defined (MDE_CPU_IA32)
25 /// The IA-32 architecture context buffer used by SetJump() and LongJump().
34 } BASE_LIBRARY_JUMP_BUFFER
;
36 #define BASE_LIBRARY_JUMP_BUFFER_ALIGNMENT 4
38 #endif // defined (MDE_CPU_IA32)
40 #if defined (MDE_CPU_IPF)
43 /// The Itanium architecture context buffer used by SetJump() and LongJump().
78 UINT64 AfterSpillUNAT
;
84 } BASE_LIBRARY_JUMP_BUFFER
;
86 #define BASE_LIBRARY_JUMP_BUFFER_ALIGNMENT 0x10
88 #endif // defined (MDE_CPU_IPF)
90 #if defined (MDE_CPU_X64)
92 /// The x64 architecture context buffer used by SetJump() and LongJump().
106 UINT8 XmmBuffer
[160]; ///< XMM6-XMM15.
107 } BASE_LIBRARY_JUMP_BUFFER
;
109 #define BASE_LIBRARY_JUMP_BUFFER_ALIGNMENT 8
111 #endif // defined (MDE_CPU_X64)
113 #if defined (MDE_CPU_EBC)
115 /// The EBC context buffer used by SetJump() and LongJump().
123 } BASE_LIBRARY_JUMP_BUFFER
;
125 #define BASE_LIBRARY_JUMP_BUFFER_ALIGNMENT 8
127 #endif // defined (MDE_CPU_EBC)
129 #if defined (MDE_CPU_ARM)
132 UINT32 R3
; ///< A copy of R13.
143 } BASE_LIBRARY_JUMP_BUFFER
;
145 #define BASE_LIBRARY_JUMP_BUFFER_ALIGNMENT 4
147 #endif // defined (MDE_CPU_ARM)
149 #if defined (MDE_CPU_AARCH64)
175 } BASE_LIBRARY_JUMP_BUFFER
;
177 #define BASE_LIBRARY_JUMP_BUFFER_ALIGNMENT 8
179 #endif // defined (MDE_CPU_AARCH64)
188 Returns the length of a Null-terminated Unicode string.
190 This function is similar as strlen_s defined in C11.
192 If String is not aligned on a 16-bit boundary, then ASSERT().
194 @param String A pointer to a Null-terminated Unicode string.
195 @param MaxSize The maximum number of Destination Unicode
196 char, including terminating null char.
198 @retval 0 If String is NULL.
199 @retval MaxSize If there is no null character in the first MaxSize characters of String.
200 @return The number of characters that percede the terminating null character.
206 IN CONST CHAR16
*String
,
211 Copies the string pointed to by Source (including the terminating null char)
212 to the array pointed to by Destination.
214 This function is similar as strcpy_s defined in C11.
216 If Destination is not aligned on a 16-bit boundary, then ASSERT().
217 If Source is not aligned on a 16-bit boundary, then ASSERT().
218 If an error would be returned, then the function will also ASSERT().
220 If an error is returned, then the Destination is unmodified.
222 @param Destination A pointer to a Null-terminated Unicode string.
223 @param DestMax The maximum number of Destination Unicode
224 char, including terminating null char.
225 @param Source A pointer to a Null-terminated Unicode string.
227 @retval RETURN_SUCCESS String is copied.
228 @retval RETURN_BUFFER_TOO_SMALL If DestMax is NOT greater than StrLen(Source).
229 @retval RETURN_INVALID_PARAMETER If Destination is NULL.
231 If PcdMaximumUnicodeStringLength is not zero,
232 and DestMax is greater than
233 PcdMaximumUnicodeStringLength.
235 @retval RETURN_ACCESS_DENIED If Source and Destination overlap.
240 OUT CHAR16
*Destination
,
242 IN CONST CHAR16
*Source
246 Copies not more than Length successive char from the string pointed to by
247 Source to the array pointed to by Destination. If no null char is copied from
248 Source, then Destination[Length] is always set to null.
250 This function is similar as strncpy_s defined in C11.
252 If Length > 0 and Destination is not aligned on a 16-bit boundary, then ASSERT().
253 If Length > 0 and Source is not aligned on a 16-bit boundary, then ASSERT().
254 If an error would be returned, then the function will also ASSERT().
256 If an error is returned, then the Destination is unmodified.
258 @param Destination A pointer to a Null-terminated Unicode string.
259 @param DestMax The maximum number of Destination Unicode
260 char, including terminating null char.
261 @param Source A pointer to a Null-terminated Unicode string.
262 @param Length The maximum number of Unicode characters to copy.
264 @retval RETURN_SUCCESS String is copied.
265 @retval RETURN_BUFFER_TOO_SMALL If DestMax is NOT greater than
266 MIN(StrLen(Source), Length).
267 @retval RETURN_INVALID_PARAMETER If Destination is NULL.
269 If PcdMaximumUnicodeStringLength is not zero,
270 and DestMax is greater than
271 PcdMaximumUnicodeStringLength.
273 @retval RETURN_ACCESS_DENIED If Source and Destination overlap.
278 OUT CHAR16
*Destination
,
280 IN CONST CHAR16
*Source
,
285 Appends a copy of the string pointed to by Source (including the terminating
286 null char) to the end of the string pointed to by Destination.
288 This function is similar as strcat_s defined in C11.
290 If Destination is not aligned on a 16-bit boundary, then ASSERT().
291 If Source is not aligned on a 16-bit boundary, then ASSERT().
292 If an error would be returned, then the function will also ASSERT().
294 If an error is returned, then the Destination is unmodified.
296 @param Destination A pointer to a Null-terminated Unicode string.
297 @param DestMax The maximum number of Destination Unicode
298 char, including terminating null char.
299 @param Source A pointer to a Null-terminated Unicode string.
301 @retval RETURN_SUCCESS String is appended.
302 @retval RETURN_BAD_BUFFER_SIZE If DestMax is NOT greater than
304 @retval RETURN_BUFFER_TOO_SMALL If (DestMax - StrLen(Destination)) is NOT
305 greater than StrLen(Source).
306 @retval RETURN_INVALID_PARAMETER If Destination is NULL.
308 If PcdMaximumUnicodeStringLength is not zero,
309 and DestMax is greater than
310 PcdMaximumUnicodeStringLength.
312 @retval RETURN_ACCESS_DENIED If Source and Destination overlap.
317 IN OUT CHAR16
*Destination
,
319 IN CONST CHAR16
*Source
323 Appends not more than Length successive char from the string pointed to by
324 Source to the end of the string pointed to by Destination. If no null char is
325 copied from Source, then Destination[StrLen(Destination) + Length] is always
328 This function is similar as strncat_s defined in C11.
330 If Destination is not aligned on a 16-bit boundary, then ASSERT().
331 If Source is not aligned on a 16-bit boundary, then ASSERT().
332 If an error would be returned, then the function will also ASSERT().
334 If an error is returned, then the Destination is unmodified.
336 @param Destination A pointer to a Null-terminated Unicode string.
337 @param DestMax The maximum number of Destination Unicode
338 char, including terminating null char.
339 @param Source A pointer to a Null-terminated Unicode string.
340 @param Length The maximum number of Unicode characters to copy.
342 @retval RETURN_SUCCESS String is appended.
343 @retval RETURN_BAD_BUFFER_SIZE If DestMax is NOT greater than
345 @retval RETURN_BUFFER_TOO_SMALL If (DestMax - StrLen(Destination)) is NOT
346 greater than MIN(StrLen(Source), Length).
347 @retval RETURN_INVALID_PARAMETER If Destination is NULL.
349 If PcdMaximumUnicodeStringLength is not zero,
350 and DestMax is greater than
351 PcdMaximumUnicodeStringLength.
353 @retval RETURN_ACCESS_DENIED If Source and Destination overlap.
358 IN OUT CHAR16
*Destination
,
360 IN CONST CHAR16
*Source
,
365 Returns the length of a Null-terminated Ascii string.
367 This function is similar as strlen_s defined in C11.
369 @param String A pointer to a Null-terminated Ascii string.
370 @param MaxSize The maximum number of Destination Ascii
371 char, including terminating null char.
373 @retval 0 If String is NULL.
374 @retval MaxSize If there is no null character in the first MaxSize characters of String.
375 @return The number of characters that percede the terminating null character.
381 IN CONST CHAR8
*String
,
386 Copies the string pointed to by Source (including the terminating null char)
387 to the array pointed to by Destination.
389 This function is similar as strcpy_s defined in C11.
391 If an error would be returned, then the function will also ASSERT().
393 If an error is returned, then the Destination is unmodified.
395 @param Destination A pointer to a Null-terminated Ascii string.
396 @param DestMax The maximum number of Destination Ascii
397 char, including terminating null char.
398 @param Source A pointer to a Null-terminated Ascii string.
400 @retval RETURN_SUCCESS String is copied.
401 @retval RETURN_BUFFER_TOO_SMALL If DestMax is NOT greater than StrLen(Source).
402 @retval RETURN_INVALID_PARAMETER If Destination is NULL.
404 If PcdMaximumAsciiStringLength is not zero,
405 and DestMax is greater than
406 PcdMaximumAsciiStringLength.
408 @retval RETURN_ACCESS_DENIED If Source and Destination overlap.
413 OUT CHAR8
*Destination
,
415 IN CONST CHAR8
*Source
419 Copies not more than Length successive char from the string pointed to by
420 Source to the array pointed to by Destination. If no null char is copied from
421 Source, then Destination[Length] is always set to null.
423 This function is similar as strncpy_s defined in C11.
425 If an error would be returned, then the function will also ASSERT().
427 If an error is returned, then the Destination is unmodified.
429 @param Destination A pointer to a Null-terminated Ascii string.
430 @param DestMax The maximum number of Destination Ascii
431 char, including terminating null char.
432 @param Source A pointer to a Null-terminated Ascii string.
433 @param Length The maximum number of Ascii characters to copy.
435 @retval RETURN_SUCCESS String is copied.
436 @retval RETURN_BUFFER_TOO_SMALL If DestMax is NOT greater than
437 MIN(StrLen(Source), Length).
438 @retval RETURN_INVALID_PARAMETER If Destination is NULL.
440 If PcdMaximumAsciiStringLength is not zero,
441 and DestMax is greater than
442 PcdMaximumAsciiStringLength.
444 @retval RETURN_ACCESS_DENIED If Source and Destination overlap.
449 OUT CHAR8
*Destination
,
451 IN CONST CHAR8
*Source
,
456 Appends a copy of the string pointed to by Source (including the terminating
457 null char) to the end of the string pointed to by Destination.
459 This function is similar as strcat_s defined in C11.
461 If an error would be returned, then the function will also ASSERT().
463 If an error is returned, then the Destination is unmodified.
465 @param Destination A pointer to a Null-terminated Ascii string.
466 @param DestMax The maximum number of Destination Ascii
467 char, including terminating null char.
468 @param Source A pointer to a Null-terminated Ascii string.
470 @retval RETURN_SUCCESS String is appended.
471 @retval RETURN_BAD_BUFFER_SIZE If DestMax is NOT greater than
473 @retval RETURN_BUFFER_TOO_SMALL If (DestMax - StrLen(Destination)) is NOT
474 greater than StrLen(Source).
475 @retval RETURN_INVALID_PARAMETER If Destination is NULL.
477 If PcdMaximumAsciiStringLength is not zero,
478 and DestMax is greater than
479 PcdMaximumAsciiStringLength.
481 @retval RETURN_ACCESS_DENIED If Source and Destination overlap.
486 IN OUT CHAR8
*Destination
,
488 IN CONST CHAR8
*Source
492 Appends not more than Length successive char from the string pointed to by
493 Source to the end of the string pointed to by Destination. If no null char is
494 copied from Source, then Destination[StrLen(Destination) + Length] is always
497 This function is similar as strncat_s defined in C11.
499 If an error would be returned, then the function will also ASSERT().
501 If an error is returned, then the Destination is unmodified.
503 @param Destination A pointer to a Null-terminated Ascii string.
504 @param DestMax The maximum number of Destination Ascii
505 char, including terminating null char.
506 @param Source A pointer to a Null-terminated Ascii string.
507 @param Length The maximum number of Ascii characters to copy.
509 @retval RETURN_SUCCESS String is appended.
510 @retval RETURN_BAD_BUFFER_SIZE If DestMax is NOT greater than
512 @retval RETURN_BUFFER_TOO_SMALL If (DestMax - StrLen(Destination)) is NOT
513 greater than MIN(StrLen(Source), Length).
514 @retval RETURN_INVALID_PARAMETER If Destination is NULL.
516 If PcdMaximumAsciiStringLength is not zero,
517 and DestMax is greater than
518 PcdMaximumAsciiStringLength.
520 @retval RETURN_ACCESS_DENIED If Source and Destination overlap.
525 IN OUT CHAR8
*Destination
,
527 IN CONST CHAR8
*Source
,
532 #ifndef DISABLE_NEW_DEPRECATED_INTERFACES
535 [ATTENTION] This function is deprecated for security reason.
537 Copies one Null-terminated Unicode string to another Null-terminated Unicode
538 string and returns the new Unicode string.
540 This function copies the contents of the Unicode string Source to the Unicode
541 string Destination, and returns Destination. If Source and Destination
542 overlap, then the results are undefined.
544 If Destination is NULL, then ASSERT().
545 If Destination is not aligned on a 16-bit boundary, then ASSERT().
546 If Source is NULL, then ASSERT().
547 If Source is not aligned on a 16-bit boundary, then ASSERT().
548 If Source and Destination overlap, then ASSERT().
549 If PcdMaximumUnicodeStringLength is not zero, and Source contains more than
550 PcdMaximumUnicodeStringLength Unicode characters not including the
551 Null-terminator, then ASSERT().
553 @param Destination The pointer to a Null-terminated Unicode string.
554 @param Source The pointer to a Null-terminated Unicode string.
562 OUT CHAR16
*Destination
,
563 IN CONST CHAR16
*Source
568 [ATTENTION] This function is deprecated for security reason.
570 Copies up to a specified length from one Null-terminated Unicode string to
571 another Null-terminated Unicode string and returns the new Unicode string.
573 This function copies the contents of the Unicode string Source to the Unicode
574 string Destination, and returns Destination. At most, Length Unicode
575 characters are copied from Source to Destination. If Length is 0, then
576 Destination is returned unmodified. If Length is greater that the number of
577 Unicode characters in Source, then Destination is padded with Null Unicode
578 characters. If Source and Destination overlap, then the results are
581 If Length > 0 and Destination is NULL, then ASSERT().
582 If Length > 0 and Destination is not aligned on a 16-bit boundary, then ASSERT().
583 If Length > 0 and Source is NULL, then ASSERT().
584 If Length > 0 and Source is not aligned on a 16-bit boundary, then ASSERT().
585 If Source and Destination overlap, then ASSERT().
586 If PcdMaximumUnicodeStringLength is not zero, and Length is greater than
587 PcdMaximumUnicodeStringLength, then ASSERT().
588 If PcdMaximumUnicodeStringLength is not zero, and Source contains more than
589 PcdMaximumUnicodeStringLength Unicode characters, not including the Null-terminator,
592 @param Destination The pointer to a Null-terminated Unicode string.
593 @param Source The pointer to a Null-terminated Unicode string.
594 @param Length The maximum number of Unicode characters to copy.
602 OUT CHAR16
*Destination
,
603 IN CONST CHAR16
*Source
,
609 Returns the length of a Null-terminated Unicode string.
611 This function returns the number of Unicode characters in the Null-terminated
612 Unicode string specified by String.
614 If String is NULL, then ASSERT().
615 If String is not aligned on a 16-bit boundary, then ASSERT().
616 If PcdMaximumUnicodeStringLength is not zero, and String contains more than
617 PcdMaximumUnicodeStringLength Unicode characters not including the
618 Null-terminator, then ASSERT().
620 @param String Pointer to a Null-terminated Unicode string.
622 @return The length of String.
628 IN CONST CHAR16
*String
633 Returns the size of a Null-terminated Unicode string in bytes, including the
636 This function returns the size, in bytes, of the Null-terminated Unicode string
639 If String is NULL, then ASSERT().
640 If String is not aligned on a 16-bit boundary, then ASSERT().
641 If PcdMaximumUnicodeStringLength is not zero, and String contains more than
642 PcdMaximumUnicodeStringLength Unicode characters not including the
643 Null-terminator, then ASSERT().
645 @param String The pointer to a Null-terminated Unicode string.
647 @return The size of String.
653 IN CONST CHAR16
*String
658 Compares two Null-terminated Unicode strings, and returns the difference
659 between the first mismatched Unicode characters.
661 This function compares the Null-terminated Unicode string FirstString to the
662 Null-terminated Unicode string SecondString. If FirstString is identical to
663 SecondString, then 0 is returned. Otherwise, the value returned is the first
664 mismatched Unicode character in SecondString subtracted from the first
665 mismatched Unicode character in FirstString.
667 If FirstString is NULL, then ASSERT().
668 If FirstString is not aligned on a 16-bit boundary, then ASSERT().
669 If SecondString is NULL, then ASSERT().
670 If SecondString is not aligned on a 16-bit boundary, then ASSERT().
671 If PcdMaximumUnicodeStringLength is not zero, and FirstString contains more
672 than PcdMaximumUnicodeStringLength Unicode characters not including the
673 Null-terminator, then ASSERT().
674 If PcdMaximumUnicodeStringLength is not zero, and SecondString contains more
675 than PcdMaximumUnicodeStringLength Unicode characters, not including the
676 Null-terminator, then ASSERT().
678 @param FirstString The pointer to a Null-terminated Unicode string.
679 @param SecondString The pointer to a Null-terminated Unicode string.
681 @retval 0 FirstString is identical to SecondString.
682 @return others FirstString is not identical to SecondString.
688 IN CONST CHAR16
*FirstString
,
689 IN CONST CHAR16
*SecondString
694 Compares up to a specified length the contents of two Null-terminated Unicode strings,
695 and returns the difference between the first mismatched Unicode characters.
697 This function compares the Null-terminated Unicode string FirstString to the
698 Null-terminated Unicode string SecondString. At most, Length Unicode
699 characters will be compared. If Length is 0, then 0 is returned. If
700 FirstString is identical to SecondString, then 0 is returned. Otherwise, the
701 value returned is the first mismatched Unicode character in SecondString
702 subtracted from the first mismatched Unicode character in FirstString.
704 If Length > 0 and FirstString is NULL, then ASSERT().
705 If Length > 0 and FirstString is not aligned on a 16-bit boundary, then ASSERT().
706 If Length > 0 and SecondString is NULL, then ASSERT().
707 If Length > 0 and SecondString is not aligned on a 16-bit boundary, then ASSERT().
708 If PcdMaximumUnicodeStringLength is not zero, and Length is greater than
709 PcdMaximumUnicodeStringLength, then ASSERT().
710 If PcdMaximumUnicodeStringLength is not zero, and FirstString contains more than
711 PcdMaximumUnicodeStringLength Unicode characters, not including the Null-terminator,
713 If PcdMaximumUnicodeStringLength is not zero, and SecondString contains more than
714 PcdMaximumUnicodeStringLength Unicode characters, not including the Null-terminator,
717 @param FirstString The pointer to a Null-terminated Unicode string.
718 @param SecondString The pointer to a Null-terminated Unicode string.
719 @param Length The maximum number of Unicode characters to compare.
721 @retval 0 FirstString is identical to SecondString.
722 @return others FirstString is not identical to SecondString.
728 IN CONST CHAR16
*FirstString
,
729 IN CONST CHAR16
*SecondString
,
734 #ifndef DISABLE_NEW_DEPRECATED_INTERFACES
737 [ATTENTION] This function is deprecated for security reason.
739 Concatenates one Null-terminated Unicode string to another Null-terminated
740 Unicode string, and returns the concatenated Unicode string.
742 This function concatenates two Null-terminated Unicode strings. The contents
743 of Null-terminated Unicode string Source are concatenated to the end of
744 Null-terminated Unicode string Destination. The Null-terminated concatenated
745 Unicode String is returned. If Source and Destination overlap, then the
746 results are undefined.
748 If Destination is NULL, then ASSERT().
749 If Destination is not aligned on a 16-bit boundary, then ASSERT().
750 If Source is NULL, then ASSERT().
751 If Source is not aligned on a 16-bit boundary, then ASSERT().
752 If Source and Destination overlap, then ASSERT().
753 If PcdMaximumUnicodeStringLength is not zero, and Destination contains more
754 than PcdMaximumUnicodeStringLength Unicode characters, not including the
755 Null-terminator, then ASSERT().
756 If PcdMaximumUnicodeStringLength is not zero, and Source contains more than
757 PcdMaximumUnicodeStringLength Unicode characters, not including the
758 Null-terminator, then ASSERT().
759 If PcdMaximumUnicodeStringLength is not zero, and concatenating Destination
760 and Source results in a Unicode string with more than
761 PcdMaximumUnicodeStringLength Unicode characters, not including the
762 Null-terminator, then ASSERT().
764 @param Destination The pointer to a Null-terminated Unicode string.
765 @param Source The pointer to a Null-terminated Unicode string.
773 IN OUT CHAR16
*Destination
,
774 IN CONST CHAR16
*Source
779 [ATTENTION] This function is deprecated for security reason.
781 Concatenates up to a specified length one Null-terminated Unicode to the end
782 of another Null-terminated Unicode string, and returns the concatenated
785 This function concatenates two Null-terminated Unicode strings. The contents
786 of Null-terminated Unicode string Source are concatenated to the end of
787 Null-terminated Unicode string Destination, and Destination is returned. At
788 most, Length Unicode characters are concatenated from Source to the end of
789 Destination, and Destination is always Null-terminated. If Length is 0, then
790 Destination is returned unmodified. If Source and Destination overlap, then
791 the results are undefined.
793 If Destination is NULL, then ASSERT().
794 If Length > 0 and Destination is not aligned on a 16-bit boundary, then ASSERT().
795 If Length > 0 and Source is NULL, then ASSERT().
796 If Length > 0 and Source is not aligned on a 16-bit boundary, then ASSERT().
797 If Source and Destination overlap, then ASSERT().
798 If PcdMaximumUnicodeStringLength is not zero, and Length is greater than
799 PcdMaximumUnicodeStringLength, then ASSERT().
800 If PcdMaximumUnicodeStringLength is not zero, and Destination contains more
801 than PcdMaximumUnicodeStringLength Unicode characters, not including the
802 Null-terminator, then ASSERT().
803 If PcdMaximumUnicodeStringLength is not zero, and Source contains more than
804 PcdMaximumUnicodeStringLength Unicode characters, not including the
805 Null-terminator, then ASSERT().
806 If PcdMaximumUnicodeStringLength is not zero, and concatenating Destination
807 and Source results in a Unicode string with more than PcdMaximumUnicodeStringLength
808 Unicode characters, not including the Null-terminator, then ASSERT().
810 @param Destination The pointer to a Null-terminated Unicode string.
811 @param Source The pointer to a Null-terminated Unicode string.
812 @param Length The maximum number of Unicode characters to concatenate from
821 IN OUT CHAR16
*Destination
,
822 IN CONST CHAR16
*Source
,
828 Returns the first occurrence of a Null-terminated Unicode sub-string
829 in a Null-terminated Unicode string.
831 This function scans the contents of the Null-terminated Unicode string
832 specified by String and returns the first occurrence of SearchString.
833 If SearchString is not found in String, then NULL is returned. If
834 the length of SearchString is zero, then String is returned.
836 If String is NULL, then ASSERT().
837 If String is not aligned on a 16-bit boundary, then ASSERT().
838 If SearchString is NULL, then ASSERT().
839 If SearchString is not aligned on a 16-bit boundary, then ASSERT().
841 If PcdMaximumUnicodeStringLength is not zero, and SearchString
842 or String contains more than PcdMaximumUnicodeStringLength Unicode
843 characters, not including the Null-terminator, then ASSERT().
845 @param String The pointer to a Null-terminated Unicode string.
846 @param SearchString The pointer to a Null-terminated Unicode string to search for.
848 @retval NULL If the SearchString does not appear in String.
849 @return others If there is a match.
855 IN CONST CHAR16
*String
,
856 IN CONST CHAR16
*SearchString
860 Convert a Null-terminated Unicode decimal string to a value of
863 This function returns a value of type UINTN by interpreting the contents
864 of the Unicode string specified by String as a decimal number. The format
865 of the input Unicode string String is:
867 [spaces] [decimal digits].
869 The valid decimal digit character is in the range [0-9]. The
870 function will ignore the pad space, which includes spaces or
871 tab characters, before [decimal digits]. The running zero in the
872 beginning of [decimal digits] will be ignored. Then, the function
873 stops at the first character that is a not a valid decimal character
874 or a Null-terminator, whichever one comes first.
876 If String is NULL, then ASSERT().
877 If String is not aligned in a 16-bit boundary, then ASSERT().
878 If String has only pad spaces, then 0 is returned.
879 If String has no pad spaces or valid decimal digits,
881 If the number represented by String overflows according
882 to the range defined by UINTN, then ASSERT().
884 If PcdMaximumUnicodeStringLength is not zero, and String contains
885 more than PcdMaximumUnicodeStringLength Unicode characters not including
886 the Null-terminator, then ASSERT().
888 @param String The pointer to a Null-terminated Unicode string.
890 @retval Value translated from String.
896 IN CONST CHAR16
*String
900 Convert a Null-terminated Unicode decimal string to a value of
903 This function returns a value of type UINT64 by interpreting the contents
904 of the Unicode string specified by String as a decimal number. The format
905 of the input Unicode string String is:
907 [spaces] [decimal digits].
909 The valid decimal digit character is in the range [0-9]. The
910 function will ignore the pad space, which includes spaces or
911 tab characters, before [decimal digits]. The running zero in the
912 beginning of [decimal digits] will be ignored. Then, the function
913 stops at the first character that is a not a valid decimal character
914 or a Null-terminator, whichever one comes first.
916 If String is NULL, then ASSERT().
917 If String is not aligned in a 16-bit boundary, then ASSERT().
918 If String has only pad spaces, then 0 is returned.
919 If String has no pad spaces or valid decimal digits,
921 If the number represented by String overflows according
922 to the range defined by UINT64, then ASSERT().
924 If PcdMaximumUnicodeStringLength is not zero, and String contains
925 more than PcdMaximumUnicodeStringLength Unicode characters not including
926 the Null-terminator, then ASSERT().
928 @param String The pointer to a Null-terminated Unicode string.
930 @retval Value translated from String.
936 IN CONST CHAR16
*String
941 Convert a Null-terminated Unicode hexadecimal string to a value of type UINTN.
943 This function returns a value of type UINTN by interpreting the contents
944 of the Unicode string specified by String as a hexadecimal number.
945 The format of the input Unicode string String is:
947 [spaces][zeros][x][hexadecimal digits].
949 The valid hexadecimal digit character is in the range [0-9], [a-f] and [A-F].
950 The prefix "0x" is optional. Both "x" and "X" is allowed in "0x" prefix.
951 If "x" appears in the input string, it must be prefixed with at least one 0.
952 The function will ignore the pad space, which includes spaces or tab characters,
953 before [zeros], [x] or [hexadecimal digit]. The running zero before [x] or
954 [hexadecimal digit] will be ignored. Then, the decoding starts after [x] or the
955 first valid hexadecimal digit. Then, the function stops at the first character
956 that is a not a valid hexadecimal character or NULL, whichever one comes first.
958 If String is NULL, then ASSERT().
959 If String is not aligned in a 16-bit boundary, then ASSERT().
960 If String has only pad spaces, then zero is returned.
961 If String has no leading pad spaces, leading zeros or valid hexadecimal digits,
962 then zero is returned.
963 If the number represented by String overflows according to the range defined by
964 UINTN, then ASSERT().
966 If PcdMaximumUnicodeStringLength is not zero, and String contains more than
967 PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator,
970 @param String The pointer to a Null-terminated Unicode string.
972 @retval Value translated from String.
978 IN CONST CHAR16
*String
983 Convert a Null-terminated Unicode hexadecimal string to a value of type UINT64.
985 This function returns a value of type UINT64 by interpreting the contents
986 of the Unicode string specified by String as a hexadecimal number.
987 The format of the input Unicode string String is
989 [spaces][zeros][x][hexadecimal digits].
991 The valid hexadecimal digit character is in the range [0-9], [a-f] and [A-F].
992 The prefix "0x" is optional. Both "x" and "X" is allowed in "0x" prefix.
993 If "x" appears in the input string, it must be prefixed with at least one 0.
994 The function will ignore the pad space, which includes spaces or tab characters,
995 before [zeros], [x] or [hexadecimal digit]. The running zero before [x] or
996 [hexadecimal digit] will be ignored. Then, the decoding starts after [x] or the
997 first valid hexadecimal digit. Then, the function stops at the first character that is
998 a not a valid hexadecimal character or NULL, whichever one comes first.
1000 If String is NULL, then ASSERT().
1001 If String is not aligned in a 16-bit boundary, then ASSERT().
1002 If String has only pad spaces, then zero is returned.
1003 If String has no leading pad spaces, leading zeros or valid hexadecimal digits,
1004 then zero is returned.
1005 If the number represented by String overflows according to the range defined by
1006 UINT64, then ASSERT().
1008 If PcdMaximumUnicodeStringLength is not zero, and String contains more than
1009 PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator,
1012 @param String The pointer to a Null-terminated Unicode string.
1014 @retval Value translated from String.
1020 IN CONST CHAR16
*String
1023 #ifndef DISABLE_NEW_DEPRECATED_INTERFACES
1026 [ATTENTION] This function is deprecated for security reason.
1028 Convert a Null-terminated Unicode string to a Null-terminated
1029 ASCII string and returns the ASCII string.
1031 This function converts the content of the Unicode string Source
1032 to the ASCII string Destination by copying the lower 8 bits of
1033 each Unicode character. It returns Destination.
1035 The caller is responsible to make sure Destination points to a buffer with size
1036 equal or greater than ((StrLen (Source) + 1) * sizeof (CHAR8)) in bytes.
1038 If any Unicode characters in Source contain non-zero value in
1039 the upper 8 bits, then ASSERT().
1041 If Destination is NULL, then ASSERT().
1042 If Source is NULL, then ASSERT().
1043 If Source is not aligned on a 16-bit boundary, then ASSERT().
1044 If Source and Destination overlap, then ASSERT().
1046 If PcdMaximumUnicodeStringLength is not zero, and Source contains
1047 more than PcdMaximumUnicodeStringLength Unicode characters not including
1048 the Null-terminator, then ASSERT().
1050 If PcdMaximumAsciiStringLength is not zero, and Source contains more
1051 than PcdMaximumAsciiStringLength Unicode characters not including the
1052 Null-terminator, then ASSERT().
1054 @param Source The pointer to a Null-terminated Unicode string.
1055 @param Destination The pointer to a Null-terminated ASCII string.
1057 @return Destination.
1062 UnicodeStrToAsciiStr (
1063 IN CONST CHAR16
*Source
,
1064 OUT CHAR8
*Destination
1070 Convert a Null-terminated Unicode string to a Null-terminated
1073 This function is similar to AsciiStrCpyS.
1075 This function converts the content of the Unicode string Source
1076 to the ASCII string Destination by copying the lower 8 bits of
1077 each Unicode character. The function terminates the ASCII string
1078 Destination by appending a Null-terminator character at the end.
1080 The caller is responsible to make sure Destination points to a buffer with size
1081 equal or greater than ((StrLen (Source) + 1) * sizeof (CHAR8)) in bytes.
1083 If any Unicode characters in Source contain non-zero value in
1084 the upper 8 bits, then ASSERT().
1086 If Source is not aligned on a 16-bit boundary, then ASSERT().
1087 If an error would be returned, then the function will also ASSERT().
1089 If an error is returned, then the Destination is unmodified.
1091 @param Source The pointer to a Null-terminated Unicode string.
1092 @param Destination The pointer to a Null-terminated ASCII string.
1093 @param DestMax The maximum number of Destination Ascii
1094 char, including terminating null char.
1096 @retval RETURN_SUCCESS String is converted.
1097 @retval RETURN_BUFFER_TOO_SMALL If DestMax is NOT greater than StrLen(Source).
1098 @retval RETURN_INVALID_PARAMETER If Destination is NULL.
1100 If PcdMaximumAsciiStringLength is not zero,
1101 and DestMax is greater than
1102 PcdMaximumAsciiStringLength.
1103 If PcdMaximumUnicodeStringLength is not zero,
1104 and DestMax is greater than
1105 PcdMaximumUnicodeStringLength.
1107 @retval RETURN_ACCESS_DENIED If Source and Destination overlap.
1112 UnicodeStrToAsciiStrS (
1113 IN CONST CHAR16
*Source
,
1114 OUT CHAR8
*Destination
,
1118 #ifndef DISABLE_NEW_DEPRECATED_INTERFACES
1121 [ATTENTION] This function is deprecated for security reason.
1123 Copies one Null-terminated ASCII string to another Null-terminated ASCII
1124 string and returns the new ASCII string.
1126 This function copies the contents of the ASCII string Source to the ASCII
1127 string Destination, and returns Destination. If Source and Destination
1128 overlap, then the results are undefined.
1130 If Destination is NULL, then ASSERT().
1131 If Source is NULL, then ASSERT().
1132 If Source and Destination overlap, then ASSERT().
1133 If PcdMaximumAsciiStringLength is not zero and Source contains more than
1134 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
1137 @param Destination The pointer to a Null-terminated ASCII string.
1138 @param Source The pointer to a Null-terminated ASCII string.
1146 OUT CHAR8
*Destination
,
1147 IN CONST CHAR8
*Source
1152 [ATTENTION] This function is deprecated for security reason.
1154 Copies up to a specified length one Null-terminated ASCII string to another
1155 Null-terminated ASCII string and returns the new ASCII string.
1157 This function copies the contents of the ASCII string Source to the ASCII
1158 string Destination, and returns Destination. At most, Length ASCII characters
1159 are copied from Source to Destination. If Length is 0, then Destination is
1160 returned unmodified. If Length is greater that the number of ASCII characters
1161 in Source, then Destination is padded with Null ASCII characters. If Source
1162 and Destination overlap, then the results are undefined.
1164 If Destination is NULL, then ASSERT().
1165 If Source is NULL, then ASSERT().
1166 If Source and Destination overlap, then ASSERT().
1167 If PcdMaximumAsciiStringLength is not zero, and Length is greater than
1168 PcdMaximumAsciiStringLength, then ASSERT().
1169 If PcdMaximumAsciiStringLength is not zero, and Source contains more than
1170 PcdMaximumAsciiStringLength ASCII characters, not including the Null-terminator,
1173 @param Destination The pointer to a Null-terminated ASCII string.
1174 @param Source The pointer to a Null-terminated ASCII string.
1175 @param Length The maximum number of ASCII characters to copy.
1183 OUT CHAR8
*Destination
,
1184 IN CONST CHAR8
*Source
,
1190 Returns the length of a Null-terminated ASCII string.
1192 This function returns the number of ASCII characters in the Null-terminated
1193 ASCII string specified by String.
1195 If Length > 0 and Destination is NULL, then ASSERT().
1196 If Length > 0 and Source is NULL, then ASSERT().
1197 If PcdMaximumAsciiStringLength is not zero and String contains more than
1198 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
1201 @param String The pointer to a Null-terminated ASCII string.
1203 @return The length of String.
1209 IN CONST CHAR8
*String
1214 Returns the size of a Null-terminated ASCII string in bytes, including the
1217 This function returns the size, in bytes, of the Null-terminated ASCII string
1218 specified by String.
1220 If String is NULL, then ASSERT().
1221 If PcdMaximumAsciiStringLength is not zero and String contains more than
1222 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
1225 @param String The pointer to a Null-terminated ASCII string.
1227 @return The size of String.
1233 IN CONST CHAR8
*String
1238 Compares two Null-terminated ASCII strings, and returns the difference
1239 between the first mismatched ASCII characters.
1241 This function compares the Null-terminated ASCII string FirstString to the
1242 Null-terminated ASCII string SecondString. If FirstString is identical to
1243 SecondString, then 0 is returned. Otherwise, the value returned is the first
1244 mismatched ASCII character in SecondString subtracted from the first
1245 mismatched ASCII character in FirstString.
1247 If FirstString is NULL, then ASSERT().
1248 If SecondString is NULL, then ASSERT().
1249 If PcdMaximumAsciiStringLength is not zero and FirstString contains more than
1250 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
1252 If PcdMaximumAsciiStringLength is not zero and SecondString contains more
1253 than PcdMaximumAsciiStringLength ASCII characters not including the
1254 Null-terminator, then ASSERT().
1256 @param FirstString The pointer to a Null-terminated ASCII string.
1257 @param SecondString The pointer to a Null-terminated ASCII string.
1259 @retval ==0 FirstString is identical to SecondString.
1260 @retval !=0 FirstString is not identical to SecondString.
1266 IN CONST CHAR8
*FirstString
,
1267 IN CONST CHAR8
*SecondString
1272 Performs a case insensitive comparison of two Null-terminated ASCII strings,
1273 and returns the difference between the first mismatched ASCII characters.
1275 This function performs a case insensitive comparison of the Null-terminated
1276 ASCII string FirstString to the Null-terminated ASCII string SecondString. If
1277 FirstString is identical to SecondString, then 0 is returned. Otherwise, the
1278 value returned is the first mismatched lower case ASCII character in
1279 SecondString subtracted from the first mismatched lower case ASCII character
1282 If FirstString is NULL, then ASSERT().
1283 If SecondString is NULL, then ASSERT().
1284 If PcdMaximumAsciiStringLength is not zero and FirstString contains more than
1285 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
1287 If PcdMaximumAsciiStringLength is not zero and SecondString contains more
1288 than PcdMaximumAsciiStringLength ASCII characters not including the
1289 Null-terminator, then ASSERT().
1291 @param FirstString The pointer to a Null-terminated ASCII string.
1292 @param SecondString The pointer to a Null-terminated ASCII string.
1294 @retval ==0 FirstString is identical to SecondString using case insensitive
1296 @retval !=0 FirstString is not identical to SecondString using case
1297 insensitive comparisons.
1303 IN CONST CHAR8
*FirstString
,
1304 IN CONST CHAR8
*SecondString
1309 Compares two Null-terminated ASCII strings with maximum lengths, and returns
1310 the difference between the first mismatched ASCII characters.
1312 This function compares the Null-terminated ASCII string FirstString to the
1313 Null-terminated ASCII string SecondString. At most, Length ASCII characters
1314 will be compared. If Length is 0, then 0 is returned. If FirstString is
1315 identical to SecondString, then 0 is returned. Otherwise, the value returned
1316 is the first mismatched ASCII character in SecondString subtracted from the
1317 first mismatched ASCII character in FirstString.
1319 If Length > 0 and FirstString is NULL, then ASSERT().
1320 If Length > 0 and SecondString is NULL, then ASSERT().
1321 If PcdMaximumAsciiStringLength is not zero, and Length is greater than
1322 PcdMaximumAsciiStringLength, then ASSERT().
1323 If PcdMaximumAsciiStringLength is not zero, and FirstString contains more than
1324 PcdMaximumAsciiStringLength ASCII characters, not including the Null-terminator,
1326 If PcdMaximumAsciiStringLength is not zero, and SecondString contains more than
1327 PcdMaximumAsciiStringLength ASCII characters, not including the Null-terminator,
1330 @param FirstString The pointer to a Null-terminated ASCII string.
1331 @param SecondString The pointer to a Null-terminated ASCII string.
1332 @param Length The maximum number of ASCII characters for compare.
1334 @retval ==0 FirstString is identical to SecondString.
1335 @retval !=0 FirstString is not identical to SecondString.
1341 IN CONST CHAR8
*FirstString
,
1342 IN CONST CHAR8
*SecondString
,
1347 #ifndef DISABLE_NEW_DEPRECATED_INTERFACES
1350 [ATTENTION] This function is deprecated for security reason.
1352 Concatenates one Null-terminated ASCII string to another Null-terminated
1353 ASCII string, and returns the concatenated ASCII string.
1355 This function concatenates two Null-terminated ASCII strings. The contents of
1356 Null-terminated ASCII string Source are concatenated to the end of Null-
1357 terminated ASCII string Destination. The Null-terminated concatenated ASCII
1360 If Destination is NULL, then ASSERT().
1361 If Source is NULL, then ASSERT().
1362 If PcdMaximumAsciiStringLength is not zero and Destination contains more than
1363 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
1365 If PcdMaximumAsciiStringLength is not zero and Source contains more than
1366 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
1368 If PcdMaximumAsciiStringLength is not zero and concatenating Destination and
1369 Source results in a ASCII string with more than PcdMaximumAsciiStringLength
1370 ASCII characters, then ASSERT().
1372 @param Destination The pointer to a Null-terminated ASCII string.
1373 @param Source The pointer to a Null-terminated ASCII string.
1381 IN OUT CHAR8
*Destination
,
1382 IN CONST CHAR8
*Source
1387 [ATTENTION] This function is deprecated for security reason.
1389 Concatenates up to a specified length one Null-terminated ASCII string to
1390 the end of another Null-terminated ASCII string, and returns the
1391 concatenated ASCII string.
1393 This function concatenates two Null-terminated ASCII strings. The contents
1394 of Null-terminated ASCII string Source are concatenated to the end of Null-
1395 terminated ASCII string Destination, and Destination is returned. At most,
1396 Length ASCII characters are concatenated from Source to the end of
1397 Destination, and Destination is always Null-terminated. If Length is 0, then
1398 Destination is returned unmodified. If Source and Destination overlap, then
1399 the results are undefined.
1401 If Length > 0 and Destination is NULL, then ASSERT().
1402 If Length > 0 and Source is NULL, then ASSERT().
1403 If Source and Destination overlap, then ASSERT().
1404 If PcdMaximumAsciiStringLength is not zero, and Length is greater than
1405 PcdMaximumAsciiStringLength, then ASSERT().
1406 If PcdMaximumAsciiStringLength is not zero, and Destination contains more than
1407 PcdMaximumAsciiStringLength ASCII characters, not including the Null-terminator,
1409 If PcdMaximumAsciiStringLength is not zero, and Source contains more than
1410 PcdMaximumAsciiStringLength ASCII characters, not including the Null-terminator,
1412 If PcdMaximumAsciiStringLength is not zero, and concatenating Destination and
1413 Source results in a ASCII string with more than PcdMaximumAsciiStringLength
1414 ASCII characters, not including the Null-terminator, then ASSERT().
1416 @param Destination The pointer to a Null-terminated ASCII string.
1417 @param Source The pointer to a Null-terminated ASCII string.
1418 @param Length The maximum number of ASCII characters to concatenate from
1427 IN OUT CHAR8
*Destination
,
1428 IN CONST CHAR8
*Source
,
1434 Returns the first occurrence of a Null-terminated ASCII sub-string
1435 in a Null-terminated ASCII string.
1437 This function scans the contents of the ASCII string specified by String
1438 and returns the first occurrence of SearchString. If SearchString is not
1439 found in String, then NULL is returned. If the length of SearchString is zero,
1440 then String is returned.
1442 If String is NULL, then ASSERT().
1443 If SearchString is NULL, then ASSERT().
1445 If PcdMaximumAsciiStringLength is not zero, and SearchString or
1446 String contains more than PcdMaximumAsciiStringLength Unicode characters
1447 not including the Null-terminator, then ASSERT().
1449 @param String The pointer to a Null-terminated ASCII string.
1450 @param SearchString The pointer to a Null-terminated ASCII string to search for.
1452 @retval NULL If the SearchString does not appear in String.
1453 @retval others If there is a match return the first occurrence of SearchingString.
1454 If the length of SearchString is zero,return String.
1460 IN CONST CHAR8
*String
,
1461 IN CONST CHAR8
*SearchString
1466 Convert a Null-terminated ASCII decimal string to a value of type
1469 This function returns a value of type UINTN by interpreting the contents
1470 of the ASCII string String as a decimal number. The format of the input
1471 ASCII string String is:
1473 [spaces] [decimal digits].
1475 The valid decimal digit character is in the range [0-9]. The function will
1476 ignore the pad space, which includes spaces or tab characters, before the digits.
1477 The running zero in the beginning of [decimal digits] will be ignored. Then, the
1478 function stops at the first character that is a not a valid decimal character or
1479 Null-terminator, whichever on comes first.
1481 If String has only pad spaces, then 0 is returned.
1482 If String has no pad spaces or valid decimal digits, then 0 is returned.
1483 If the number represented by String overflows according to the range defined by
1484 UINTN, then ASSERT().
1485 If String is NULL, then ASSERT().
1486 If PcdMaximumAsciiStringLength is not zero, and String contains more than
1487 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
1490 @param String The pointer to a Null-terminated ASCII string.
1492 @retval The value translated from String.
1497 AsciiStrDecimalToUintn (
1498 IN CONST CHAR8
*String
1503 Convert a Null-terminated ASCII decimal string to a value of type
1506 This function returns a value of type UINT64 by interpreting the contents
1507 of the ASCII string String as a decimal number. The format of the input
1508 ASCII string String is:
1510 [spaces] [decimal digits].
1512 The valid decimal digit character is in the range [0-9]. The function will
1513 ignore the pad space, which includes spaces or tab characters, before the digits.
1514 The running zero in the beginning of [decimal digits] will be ignored. Then, the
1515 function stops at the first character that is a not a valid decimal character or
1516 Null-terminator, whichever on comes first.
1518 If String has only pad spaces, then 0 is returned.
1519 If String has no pad spaces or valid decimal digits, then 0 is returned.
1520 If the number represented by String overflows according to the range defined by
1521 UINT64, then ASSERT().
1522 If String is NULL, then ASSERT().
1523 If PcdMaximumAsciiStringLength is not zero, and String contains more than
1524 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
1527 @param String The pointer to a Null-terminated ASCII string.
1529 @retval Value translated from String.
1534 AsciiStrDecimalToUint64 (
1535 IN CONST CHAR8
*String
1540 Convert a Null-terminated ASCII hexadecimal string to a value of type UINTN.
1542 This function returns a value of type UINTN by interpreting the contents of
1543 the ASCII string String as a hexadecimal number. The format of the input ASCII
1546 [spaces][zeros][x][hexadecimal digits].
1548 The valid hexadecimal digit character is in the range [0-9], [a-f] and [A-F].
1549 The prefix "0x" is optional. Both "x" and "X" is allowed in "0x" prefix. If "x"
1550 appears in the input string, it must be prefixed with at least one 0. The function
1551 will ignore the pad space, which includes spaces or tab characters, before [zeros],
1552 [x] or [hexadecimal digits]. The running zero before [x] or [hexadecimal digits]
1553 will be ignored. Then, the decoding starts after [x] or the first valid hexadecimal
1554 digit. Then, the function stops at the first character that is a not a valid
1555 hexadecimal character or Null-terminator, whichever on comes first.
1557 If String has only pad spaces, then 0 is returned.
1558 If String has no leading pad spaces, leading zeros or valid hexadecimal digits, then
1561 If the number represented by String overflows according to the range defined by UINTN,
1563 If String is NULL, then ASSERT().
1564 If PcdMaximumAsciiStringLength is not zero,
1565 and String contains more than PcdMaximumAsciiStringLength ASCII characters not including
1566 the Null-terminator, then ASSERT().
1568 @param String The pointer to a Null-terminated ASCII string.
1570 @retval Value translated from String.
1575 AsciiStrHexToUintn (
1576 IN CONST CHAR8
*String
1581 Convert a Null-terminated ASCII hexadecimal string to a value of type UINT64.
1583 This function returns a value of type UINT64 by interpreting the contents of
1584 the ASCII string String as a hexadecimal number. The format of the input ASCII
1587 [spaces][zeros][x][hexadecimal digits].
1589 The valid hexadecimal digit character is in the range [0-9], [a-f] and [A-F].
1590 The prefix "0x" is optional. Both "x" and "X" is allowed in "0x" prefix. If "x"
1591 appears in the input string, it must be prefixed with at least one 0. The function
1592 will ignore the pad space, which includes spaces or tab characters, before [zeros],
1593 [x] or [hexadecimal digits]. The running zero before [x] or [hexadecimal digits]
1594 will be ignored. Then, the decoding starts after [x] or the first valid hexadecimal
1595 digit. Then, the function stops at the first character that is a not a valid
1596 hexadecimal character or Null-terminator, whichever on comes first.
1598 If String has only pad spaces, then 0 is returned.
1599 If String has no leading pad spaces, leading zeros or valid hexadecimal digits, then
1602 If the number represented by String overflows according to the range defined by UINT64,
1604 If String is NULL, then ASSERT().
1605 If PcdMaximumAsciiStringLength is not zero,
1606 and String contains more than PcdMaximumAsciiStringLength ASCII characters not including
1607 the Null-terminator, then ASSERT().
1609 @param String The pointer to a Null-terminated ASCII string.
1611 @retval Value translated from String.
1616 AsciiStrHexToUint64 (
1617 IN CONST CHAR8
*String
1620 #ifndef DISABLE_NEW_DEPRECATED_INTERFACES
1623 [ATTENTION] This function is deprecated for security reason.
1625 Convert one Null-terminated ASCII string to a Null-terminated
1626 Unicode string and returns the Unicode string.
1628 This function converts the contents of the ASCII string Source to the Unicode
1629 string Destination, and returns Destination. The function terminates the
1630 Unicode string Destination by appending a Null-terminator character at the end.
1631 The caller is responsible to make sure Destination points to a buffer with size
1632 equal or greater than ((AsciiStrLen (Source) + 1) * sizeof (CHAR16)) in bytes.
1634 If Destination is NULL, then ASSERT().
1635 If Destination is not aligned on a 16-bit boundary, then ASSERT().
1636 If Source is NULL, then ASSERT().
1637 If Source and Destination overlap, then ASSERT().
1638 If PcdMaximumAsciiStringLength is not zero, and Source contains more than
1639 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
1641 If PcdMaximumUnicodeStringLength is not zero, and Source contains more than
1642 PcdMaximumUnicodeStringLength ASCII characters not including the
1643 Null-terminator, then ASSERT().
1645 @param Source The pointer to a Null-terminated ASCII string.
1646 @param Destination The pointer to a Null-terminated Unicode string.
1648 @return Destination.
1653 AsciiStrToUnicodeStr (
1654 IN CONST CHAR8
*Source
,
1655 OUT CHAR16
*Destination
1661 Convert one Null-terminated ASCII string to a Null-terminated
1664 This function is similar to StrCpyS.
1666 This function converts the contents of the ASCII string Source to the Unicode
1667 string Destination. The function terminates the Unicode string Destination by
1668 appending a Null-terminator character at the end.
1670 The caller is responsible to make sure Destination points to a buffer with size
1671 equal or greater than ((AsciiStrLen (Source) + 1) * sizeof (CHAR16)) in bytes.
1673 If Destination is not aligned on a 16-bit boundary, then ASSERT().
1674 If an error would be returned, then the function will also ASSERT().
1676 If an error is returned, then the Destination is unmodified.
1678 @param Source The pointer to a Null-terminated ASCII string.
1679 @param Destination The pointer to a Null-terminated Unicode string.
1680 @param DestMax The maximum number of Destination Unicode
1681 char, including terminating null char.
1683 @retval RETURN_SUCCESS String is converted.
1684 @retval RETURN_BUFFER_TOO_SMALL If DestMax is NOT greater than StrLen(Source).
1685 @retval RETURN_INVALID_PARAMETER If Destination is NULL.
1687 If PcdMaximumUnicodeStringLength is not zero,
1688 and DestMax is greater than
1689 PcdMaximumUnicodeStringLength.
1690 If PcdMaximumAsciiStringLength is not zero,
1691 and DestMax is greater than
1692 PcdMaximumAsciiStringLength.
1694 @retval RETURN_ACCESS_DENIED If Source and Destination overlap.
1699 AsciiStrToUnicodeStrS (
1700 IN CONST CHAR8
*Source
,
1701 OUT CHAR16
*Destination
,
1706 Converts an 8-bit value to an 8-bit BCD value.
1708 Converts the 8-bit value specified by Value to BCD. The BCD value is
1711 If Value >= 100, then ASSERT().
1713 @param Value The 8-bit value to convert to BCD. Range 0..99.
1715 @return The BCD value.
1726 Converts an 8-bit BCD value to an 8-bit value.
1728 Converts the 8-bit BCD value specified by Value to an 8-bit value. The 8-bit
1731 If Value >= 0xA0, then ASSERT().
1732 If (Value & 0x0F) >= 0x0A, then ASSERT().
1734 @param Value The 8-bit BCD value to convert to an 8-bit value.
1736 @return The 8-bit value is returned.
1746 // File Path Manipulation Functions
1750 Removes the last directory or file entry in a path.
1752 @param[in, out] Path The pointer to the path to modify.
1754 @retval FALSE Nothing was found to remove.
1755 @retval TRUE A directory or file was removed.
1764 Function to clean up paths.
1765 - Single periods in the path are removed.
1766 - Double periods in the path are removed along with a single parent directory.
1767 - Forward slashes L'/' are converted to backward slashes L'\'.
1769 This will be done inline and the existing buffer may be larger than required
1772 @param[in] Path The pointer to the string containing the path.
1774 @return Returns Path, otherwise returns NULL to indicate that an error has occurred.
1778 PathCleanUpDirectories(
1783 // Linked List Functions and Macros
1787 Initializes the head node of a doubly linked list that is declared as a
1788 global variable in a module.
1790 Initializes the forward and backward links of a new linked list. After
1791 initializing a linked list with this macro, the other linked list functions
1792 may be used to add and remove nodes from the linked list. This macro results
1793 in smaller executables by initializing the linked list in the data section,
1794 instead if calling the InitializeListHead() function to perform the
1795 equivalent operation.
1797 @param ListHead The head note of a list to initialize.
1800 #define INITIALIZE_LIST_HEAD_VARIABLE(ListHead) {&(ListHead), &(ListHead)}
1804 Initializes the head node of a doubly linked list, and returns the pointer to
1805 the head node of the doubly linked list.
1807 Initializes the forward and backward links of a new linked list. After
1808 initializing a linked list with this function, the other linked list
1809 functions may be used to add and remove nodes from the linked list. It is up
1810 to the caller of this function to allocate the memory for ListHead.
1812 If ListHead is NULL, then ASSERT().
1814 @param ListHead A pointer to the head node of a new doubly linked list.
1821 InitializeListHead (
1822 IN OUT LIST_ENTRY
*ListHead
1827 Adds a node to the beginning of a doubly linked list, and returns the pointer
1828 to the head node of the doubly linked list.
1830 Adds the node Entry at the beginning of the doubly linked list denoted by
1831 ListHead, and returns ListHead.
1833 If ListHead is NULL, then ASSERT().
1834 If Entry is NULL, then ASSERT().
1835 If ListHead was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or
1836 InitializeListHead(), then ASSERT().
1837 If PcdMaximumLinkedListLength is not zero, and prior to insertion the number
1838 of nodes in ListHead, including the ListHead node, is greater than or
1839 equal to PcdMaximumLinkedListLength, then ASSERT().
1841 @param ListHead A pointer to the head node of a doubly linked list.
1842 @param Entry A pointer to a node that is to be inserted at the beginning
1843 of a doubly linked list.
1851 IN OUT LIST_ENTRY
*ListHead
,
1852 IN OUT LIST_ENTRY
*Entry
1857 Adds a node to the end of a doubly linked list, and returns the pointer to
1858 the head node of the doubly linked list.
1860 Adds the node Entry to the end of the doubly linked list denoted by ListHead,
1861 and returns ListHead.
1863 If ListHead is NULL, then ASSERT().
1864 If Entry is NULL, then ASSERT().
1865 If ListHead was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or
1866 InitializeListHead(), then ASSERT().
1867 If PcdMaximumLinkedListLength is not zero, and prior to insertion the number
1868 of nodes in ListHead, including the ListHead node, is greater than or
1869 equal to PcdMaximumLinkedListLength, then ASSERT().
1871 @param ListHead A pointer to the head node of a doubly linked list.
1872 @param Entry A pointer to a node that is to be added at the end of the
1881 IN OUT LIST_ENTRY
*ListHead
,
1882 IN OUT LIST_ENTRY
*Entry
1887 Retrieves the first node of a doubly linked list.
1889 Returns the first node of a doubly linked list. List must have been
1890 initialized with INTIALIZE_LIST_HEAD_VARIABLE() or InitializeListHead().
1891 If List is empty, then List is returned.
1893 If List is NULL, then ASSERT().
1894 If List was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or
1895 InitializeListHead(), then ASSERT().
1896 If PcdMaximumLinkedListLength is not zero, and the number of nodes
1897 in List, including the List node, is greater than or equal to
1898 PcdMaximumLinkedListLength, then ASSERT().
1900 @param List A pointer to the head node of a doubly linked list.
1902 @return The first node of a doubly linked list.
1903 @retval List The list is empty.
1909 IN CONST LIST_ENTRY
*List
1914 Retrieves the next node of a doubly linked list.
1916 Returns the node of a doubly linked list that follows Node.
1917 List must have been initialized with INTIALIZE_LIST_HEAD_VARIABLE()
1918 or InitializeListHead(). If List is empty, then List is returned.
1920 If List is NULL, then ASSERT().
1921 If Node is NULL, then ASSERT().
1922 If List was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or
1923 InitializeListHead(), then ASSERT().
1924 If PcdMaximumLinkedListLength is not zero, and List contains more than
1925 PcdMaximumLinkedListLength nodes, then ASSERT().
1926 If PcdVerifyNodeInList is TRUE and Node is not a node in List, then ASSERT().
1928 @param List A pointer to the head node of a doubly linked list.
1929 @param Node A pointer to a node in the doubly linked list.
1931 @return The pointer to the next node if one exists. Otherwise List is returned.
1937 IN CONST LIST_ENTRY
*List
,
1938 IN CONST LIST_ENTRY
*Node
1943 Retrieves the previous node of a doubly linked list.
1945 Returns the node of a doubly linked list that precedes Node.
1946 List must have been initialized with INTIALIZE_LIST_HEAD_VARIABLE()
1947 or InitializeListHead(). If List is empty, then List is returned.
1949 If List is NULL, then ASSERT().
1950 If Node is NULL, then ASSERT().
1951 If List was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or
1952 InitializeListHead(), then ASSERT().
1953 If PcdMaximumLinkedListLength is not zero, and List contains more than
1954 PcdMaximumLinkedListLength nodes, then ASSERT().
1955 If PcdVerifyNodeInList is TRUE and Node is not a node in List, then ASSERT().
1957 @param List A pointer to the head node of a doubly linked list.
1958 @param Node A pointer to a node in the doubly linked list.
1960 @return The pointer to the previous node if one exists. Otherwise List is returned.
1966 IN CONST LIST_ENTRY
*List
,
1967 IN CONST LIST_ENTRY
*Node
1972 Checks to see if a doubly linked list is empty or not.
1974 Checks to see if the doubly linked list is empty. If the linked list contains
1975 zero nodes, this function returns TRUE. Otherwise, it returns FALSE.
1977 If ListHead is NULL, then ASSERT().
1978 If ListHead was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or
1979 InitializeListHead(), then ASSERT().
1980 If PcdMaximumLinkedListLength is not zero, and the number of nodes
1981 in List, including the List node, is greater than or equal to
1982 PcdMaximumLinkedListLength, then ASSERT().
1984 @param ListHead A pointer to the head node of a doubly linked list.
1986 @retval TRUE The linked list is empty.
1987 @retval FALSE The linked list is not empty.
1993 IN CONST LIST_ENTRY
*ListHead
1998 Determines if a node in a doubly linked list is the head node of a the same
1999 doubly linked list. This function is typically used to terminate a loop that
2000 traverses all the nodes in a doubly linked list starting with the head node.
2002 Returns TRUE if Node is equal to List. Returns FALSE if Node is one of the
2003 nodes in the doubly linked list specified by List. List must have been
2004 initialized with INTIALIZE_LIST_HEAD_VARIABLE() or InitializeListHead().
2006 If List is NULL, then ASSERT().
2007 If Node is NULL, then ASSERT().
2008 If List was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or InitializeListHead(),
2010 If PcdMaximumLinkedListLength is not zero, and the number of nodes
2011 in List, including the List node, is greater than or equal to
2012 PcdMaximumLinkedListLength, then ASSERT().
2013 If PcdVerifyNodeInList is TRUE and Node is not a node in List the and Node is not equal
2014 to List, then ASSERT().
2016 @param List A pointer to the head node of a doubly linked list.
2017 @param Node A pointer to a node in the doubly linked list.
2019 @retval TRUE Node is the head of the doubly-linked list pointed by List.
2020 @retval FALSE Node is not the head of the doubly-linked list pointed by List.
2026 IN CONST LIST_ENTRY
*List
,
2027 IN CONST LIST_ENTRY
*Node
2032 Determines if a node the last node in a doubly linked list.
2034 Returns TRUE if Node is the last node in the doubly linked list specified by
2035 List. Otherwise, FALSE is returned. List must have been initialized with
2036 INTIALIZE_LIST_HEAD_VARIABLE() or InitializeListHead().
2038 If List is NULL, then ASSERT().
2039 If Node is NULL, then ASSERT().
2040 If List was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or
2041 InitializeListHead(), then ASSERT().
2042 If PcdMaximumLinkedListLength is not zero, and the number of nodes
2043 in List, including the List node, is greater than or equal to
2044 PcdMaximumLinkedListLength, then ASSERT().
2045 If PcdVerifyNodeInList is TRUE and Node is not a node in List, then ASSERT().
2047 @param List A pointer to the head node of a doubly linked list.
2048 @param Node A pointer to a node in the doubly linked list.
2050 @retval TRUE Node is the last node in the linked list.
2051 @retval FALSE Node is not the last node in the linked list.
2057 IN CONST LIST_ENTRY
*List
,
2058 IN CONST LIST_ENTRY
*Node
2063 Swaps the location of two nodes in a doubly linked list, and returns the
2064 first node after the swap.
2066 If FirstEntry is identical to SecondEntry, then SecondEntry is returned.
2067 Otherwise, the location of the FirstEntry node is swapped with the location
2068 of the SecondEntry node in a doubly linked list. SecondEntry must be in the
2069 same double linked list as FirstEntry and that double linked list must have
2070 been initialized with INTIALIZE_LIST_HEAD_VARIABLE() or InitializeListHead().
2071 SecondEntry is returned after the nodes are swapped.
2073 If FirstEntry is NULL, then ASSERT().
2074 If SecondEntry is NULL, then ASSERT().
2075 If PcdVerifyNodeInList is TRUE and SecondEntry and FirstEntry are not in the
2076 same linked list, then ASSERT().
2077 If PcdMaximumLinkedListLength is not zero, and the number of nodes in the
2078 linked list containing the FirstEntry and SecondEntry nodes, including
2079 the FirstEntry and SecondEntry nodes, is greater than or equal to
2080 PcdMaximumLinkedListLength, then ASSERT().
2082 @param FirstEntry A pointer to a node in a linked list.
2083 @param SecondEntry A pointer to another node in the same linked list.
2085 @return SecondEntry.
2091 IN OUT LIST_ENTRY
*FirstEntry
,
2092 IN OUT LIST_ENTRY
*SecondEntry
2097 Removes a node from a doubly linked list, and returns the node that follows
2100 Removes the node Entry from a doubly linked list. It is up to the caller of
2101 this function to release the memory used by this node if that is required. On
2102 exit, the node following Entry in the doubly linked list is returned. If
2103 Entry is the only node in the linked list, then the head node of the linked
2106 If Entry is NULL, then ASSERT().
2107 If Entry is the head node of an empty list, then ASSERT().
2108 If PcdMaximumLinkedListLength is not zero, and the number of nodes in the
2109 linked list containing Entry, including the Entry node, is greater than
2110 or equal to PcdMaximumLinkedListLength, then ASSERT().
2112 @param Entry A pointer to a node in a linked list.
2120 IN CONST LIST_ENTRY
*Entry
2128 Shifts a 64-bit integer left between 0 and 63 bits. The low bits are filled
2129 with zeros. The shifted value is returned.
2131 This function shifts the 64-bit value Operand to the left by Count bits. The
2132 low Count bits are set to zero. The shifted value is returned.
2134 If Count is greater than 63, then ASSERT().
2136 @param Operand The 64-bit operand to shift left.
2137 @param Count The number of bits to shift left.
2139 @return Operand << Count.
2151 Shifts a 64-bit integer right between 0 and 63 bits. This high bits are
2152 filled with zeros. The shifted value is returned.
2154 This function shifts the 64-bit value Operand to the right by Count bits. The
2155 high Count bits are set to zero. The shifted value is returned.
2157 If Count is greater than 63, then ASSERT().
2159 @param Operand The 64-bit operand to shift right.
2160 @param Count The number of bits to shift right.
2162 @return Operand >> Count
2174 Shifts a 64-bit integer right between 0 and 63 bits. The high bits are filled
2175 with original integer's bit 63. The shifted value is returned.
2177 This function shifts the 64-bit value Operand to the right by Count bits. The
2178 high Count bits are set to bit 63 of Operand. The shifted value is returned.
2180 If Count is greater than 63, then ASSERT().
2182 @param Operand The 64-bit operand to shift right.
2183 @param Count The number of bits to shift right.
2185 @return Operand >> Count
2197 Rotates a 32-bit integer left between 0 and 31 bits, filling the low bits
2198 with the high bits that were rotated.
2200 This function rotates the 32-bit value Operand to the left by Count bits. The
2201 low Count bits are fill with the high Count bits of Operand. The rotated
2204 If Count is greater than 31, then ASSERT().
2206 @param Operand The 32-bit operand to rotate left.
2207 @param Count The number of bits to rotate left.
2209 @return Operand << Count
2221 Rotates a 32-bit integer right between 0 and 31 bits, filling the high bits
2222 with the low bits that were rotated.
2224 This function rotates the 32-bit value Operand to the right by Count bits.
2225 The high Count bits are fill with the low Count bits of Operand. The rotated
2228 If Count is greater than 31, then ASSERT().
2230 @param Operand The 32-bit operand to rotate right.
2231 @param Count The number of bits to rotate right.
2233 @return Operand >> Count
2245 Rotates a 64-bit integer left between 0 and 63 bits, filling the low bits
2246 with the high bits that were rotated.
2248 This function rotates the 64-bit value Operand to the left by Count bits. The
2249 low Count bits are fill with the high Count bits of Operand. The rotated
2252 If Count is greater than 63, then ASSERT().
2254 @param Operand The 64-bit operand to rotate left.
2255 @param Count The number of bits to rotate left.
2257 @return Operand << Count
2269 Rotates a 64-bit integer right between 0 and 63 bits, filling the high bits
2270 with the high low bits that were rotated.
2272 This function rotates the 64-bit value Operand to the right by Count bits.
2273 The high Count bits are fill with the low Count bits of Operand. The rotated
2276 If Count is greater than 63, then ASSERT().
2278 @param Operand The 64-bit operand to rotate right.
2279 @param Count The number of bits to rotate right.
2281 @return Operand >> Count
2293 Returns the bit position of the lowest bit set in a 32-bit value.
2295 This function computes the bit position of the lowest bit set in the 32-bit
2296 value specified by Operand. If Operand is zero, then -1 is returned.
2297 Otherwise, a value between 0 and 31 is returned.
2299 @param Operand The 32-bit operand to evaluate.
2301 @retval 0..31 The lowest bit set in Operand was found.
2302 @retval -1 Operand is zero.
2313 Returns the bit position of the lowest bit set in a 64-bit value.
2315 This function computes the bit position of the lowest bit set in the 64-bit
2316 value specified by Operand. If Operand is zero, then -1 is returned.
2317 Otherwise, a value between 0 and 63 is returned.
2319 @param Operand The 64-bit operand to evaluate.
2321 @retval 0..63 The lowest bit set in Operand was found.
2322 @retval -1 Operand is zero.
2334 Returns the bit position of the highest bit set in a 32-bit value. Equivalent
2337 This function computes the bit position of the highest bit set in the 32-bit
2338 value specified by Operand. If Operand is zero, then -1 is returned.
2339 Otherwise, a value between 0 and 31 is returned.
2341 @param Operand The 32-bit operand to evaluate.
2343 @retval 0..31 Position of the highest bit set in Operand if found.
2344 @retval -1 Operand is zero.
2355 Returns the bit position of the highest bit set in a 64-bit value. Equivalent
2358 This function computes the bit position of the highest bit set in the 64-bit
2359 value specified by Operand. If Operand is zero, then -1 is returned.
2360 Otherwise, a value between 0 and 63 is returned.
2362 @param Operand The 64-bit operand to evaluate.
2364 @retval 0..63 Position of the highest bit set in Operand if found.
2365 @retval -1 Operand is zero.
2376 Returns the value of the highest bit set in a 32-bit value. Equivalent to
2379 This function computes the value of the highest bit set in the 32-bit value
2380 specified by Operand. If Operand is zero, then zero is returned.
2382 @param Operand The 32-bit operand to evaluate.
2384 @return 1 << HighBitSet32(Operand)
2385 @retval 0 Operand is zero.
2396 Returns the value of the highest bit set in a 64-bit value. Equivalent to
2399 This function computes the value of the highest bit set in the 64-bit value
2400 specified by Operand. If Operand is zero, then zero is returned.
2402 @param Operand The 64-bit operand to evaluate.
2404 @return 1 << HighBitSet64(Operand)
2405 @retval 0 Operand is zero.
2416 Switches the endianness of a 16-bit integer.
2418 This function swaps the bytes in a 16-bit unsigned value to switch the value
2419 from little endian to big endian or vice versa. The byte swapped value is
2422 @param Value A 16-bit unsigned value.
2424 @return The byte swapped Value.
2435 Switches the endianness of a 32-bit integer.
2437 This function swaps the bytes in a 32-bit unsigned value to switch the value
2438 from little endian to big endian or vice versa. The byte swapped value is
2441 @param Value A 32-bit unsigned value.
2443 @return The byte swapped Value.
2454 Switches the endianness of a 64-bit integer.
2456 This function swaps the bytes in a 64-bit unsigned value to switch the value
2457 from little endian to big endian or vice versa. The byte swapped value is
2460 @param Value A 64-bit unsigned value.
2462 @return The byte swapped Value.
2473 Multiples a 64-bit unsigned integer by a 32-bit unsigned integer and
2474 generates a 64-bit unsigned result.
2476 This function multiples the 64-bit unsigned value Multiplicand by the 32-bit
2477 unsigned value Multiplier and generates a 64-bit unsigned result. This 64-
2478 bit unsigned result is returned.
2480 @param Multiplicand A 64-bit unsigned value.
2481 @param Multiplier A 32-bit unsigned value.
2483 @return Multiplicand * Multiplier
2489 IN UINT64 Multiplicand
,
2490 IN UINT32 Multiplier
2495 Multiples a 64-bit unsigned integer by a 64-bit unsigned integer and
2496 generates a 64-bit unsigned result.
2498 This function multiples the 64-bit unsigned value Multiplicand by the 64-bit
2499 unsigned value Multiplier and generates a 64-bit unsigned result. This 64-
2500 bit unsigned result is returned.
2502 @param Multiplicand A 64-bit unsigned value.
2503 @param Multiplier A 64-bit unsigned value.
2505 @return Multiplicand * Multiplier.
2511 IN UINT64 Multiplicand
,
2512 IN UINT64 Multiplier
2517 Multiples a 64-bit signed integer by a 64-bit signed integer and generates a
2518 64-bit signed result.
2520 This function multiples the 64-bit signed value Multiplicand by the 64-bit
2521 signed value Multiplier and generates a 64-bit signed result. This 64-bit
2522 signed result is returned.
2524 @param Multiplicand A 64-bit signed value.
2525 @param Multiplier A 64-bit signed value.
2527 @return Multiplicand * Multiplier
2533 IN INT64 Multiplicand
,
2539 Divides a 64-bit unsigned integer by a 32-bit unsigned integer and generates
2540 a 64-bit unsigned result.
2542 This function divides the 64-bit unsigned value Dividend by the 32-bit
2543 unsigned value Divisor and generates a 64-bit unsigned quotient. This
2544 function returns the 64-bit unsigned quotient.
2546 If Divisor is 0, then ASSERT().
2548 @param Dividend A 64-bit unsigned value.
2549 @param Divisor A 32-bit unsigned value.
2551 @return Dividend / Divisor.
2563 Divides a 64-bit unsigned integer by a 32-bit unsigned integer and generates
2564 a 32-bit unsigned remainder.
2566 This function divides the 64-bit unsigned value Dividend by the 32-bit
2567 unsigned value Divisor and generates a 32-bit remainder. This function
2568 returns the 32-bit unsigned remainder.
2570 If Divisor is 0, then ASSERT().
2572 @param Dividend A 64-bit unsigned value.
2573 @param Divisor A 32-bit unsigned value.
2575 @return Dividend % Divisor.
2587 Divides a 64-bit unsigned integer by a 32-bit unsigned integer and generates
2588 a 64-bit unsigned result and an optional 32-bit unsigned remainder.
2590 This function divides the 64-bit unsigned value Dividend by the 32-bit
2591 unsigned value Divisor and generates a 64-bit unsigned quotient. If Remainder
2592 is not NULL, then the 32-bit unsigned remainder is returned in Remainder.
2593 This function returns the 64-bit unsigned quotient.
2595 If Divisor is 0, then ASSERT().
2597 @param Dividend A 64-bit unsigned value.
2598 @param Divisor A 32-bit unsigned value.
2599 @param Remainder A pointer to a 32-bit unsigned value. This parameter is
2600 optional and may be NULL.
2602 @return Dividend / Divisor.
2607 DivU64x32Remainder (
2610 OUT UINT32
*Remainder OPTIONAL
2615 Divides a 64-bit unsigned integer by a 64-bit unsigned integer and generates
2616 a 64-bit unsigned result and an optional 64-bit unsigned remainder.
2618 This function divides the 64-bit unsigned value Dividend by the 64-bit
2619 unsigned value Divisor and generates a 64-bit unsigned quotient. If Remainder
2620 is not NULL, then the 64-bit unsigned remainder is returned in Remainder.
2621 This function returns the 64-bit unsigned quotient.
2623 If Divisor is 0, then ASSERT().
2625 @param Dividend A 64-bit unsigned value.
2626 @param Divisor A 64-bit unsigned value.
2627 @param Remainder A pointer to a 64-bit unsigned value. This parameter is
2628 optional and may be NULL.
2630 @return Dividend / Divisor.
2635 DivU64x64Remainder (
2638 OUT UINT64
*Remainder OPTIONAL
2643 Divides a 64-bit signed integer by a 64-bit signed integer and generates a
2644 64-bit signed result and a optional 64-bit signed remainder.
2646 This function divides the 64-bit signed value Dividend by the 64-bit signed
2647 value Divisor and generates a 64-bit signed quotient. If Remainder is not
2648 NULL, then the 64-bit signed remainder is returned in Remainder. This
2649 function returns the 64-bit signed quotient.
2651 It is the caller's responsibility to not call this function with a Divisor of 0.
2652 If Divisor is 0, then the quotient and remainder should be assumed to be
2653 the largest negative integer.
2655 If Divisor is 0, then ASSERT().
2657 @param Dividend A 64-bit signed value.
2658 @param Divisor A 64-bit signed value.
2659 @param Remainder A pointer to a 64-bit signed value. This parameter is
2660 optional and may be NULL.
2662 @return Dividend / Divisor.
2667 DivS64x64Remainder (
2670 OUT INT64
*Remainder OPTIONAL
2675 Reads a 16-bit value from memory that may be unaligned.
2677 This function returns the 16-bit value pointed to by Buffer. The function
2678 guarantees that the read operation does not produce an alignment fault.
2680 If the Buffer is NULL, then ASSERT().
2682 @param Buffer The pointer to a 16-bit value that may be unaligned.
2684 @return The 16-bit value read from Buffer.
2690 IN CONST UINT16
*Buffer
2695 Writes a 16-bit value to memory that may be unaligned.
2697 This function writes the 16-bit value specified by Value to Buffer. Value is
2698 returned. The function guarantees that the write operation does not produce
2701 If the Buffer is NULL, then ASSERT().
2703 @param Buffer The pointer to a 16-bit value that may be unaligned.
2704 @param Value 16-bit value to write to Buffer.
2706 @return The 16-bit value to write to Buffer.
2718 Reads a 24-bit value from memory that may be unaligned.
2720 This function returns the 24-bit value pointed to by Buffer. The function
2721 guarantees that the read operation does not produce an alignment fault.
2723 If the Buffer is NULL, then ASSERT().
2725 @param Buffer The pointer to a 24-bit value that may be unaligned.
2727 @return The 24-bit value read from Buffer.
2733 IN CONST UINT32
*Buffer
2738 Writes a 24-bit value to memory that may be unaligned.
2740 This function writes the 24-bit value specified by Value to Buffer. Value is
2741 returned. The function guarantees that the write operation does not produce
2744 If the Buffer is NULL, then ASSERT().
2746 @param Buffer The pointer to a 24-bit value that may be unaligned.
2747 @param Value 24-bit value to write to Buffer.
2749 @return The 24-bit value to write to Buffer.
2761 Reads a 32-bit value from memory that may be unaligned.
2763 This function returns the 32-bit value pointed to by Buffer. The function
2764 guarantees that the read operation does not produce an alignment fault.
2766 If the Buffer is NULL, then ASSERT().
2768 @param Buffer The pointer to a 32-bit value that may be unaligned.
2770 @return The 32-bit value read from Buffer.
2776 IN CONST UINT32
*Buffer
2781 Writes a 32-bit value to memory that may be unaligned.
2783 This function writes the 32-bit value specified by Value to Buffer. Value is
2784 returned. The function guarantees that the write operation does not produce
2787 If the Buffer is NULL, then ASSERT().
2789 @param Buffer The pointer to a 32-bit value that may be unaligned.
2790 @param Value 32-bit value to write to Buffer.
2792 @return The 32-bit value to write to Buffer.
2804 Reads a 64-bit value from memory that may be unaligned.
2806 This function returns the 64-bit value pointed to by Buffer. The function
2807 guarantees that the read operation does not produce an alignment fault.
2809 If the Buffer is NULL, then ASSERT().
2811 @param Buffer The pointer to a 64-bit value that may be unaligned.
2813 @return The 64-bit value read from Buffer.
2819 IN CONST UINT64
*Buffer
2824 Writes a 64-bit value to memory that may be unaligned.
2826 This function writes the 64-bit value specified by Value to Buffer. Value is
2827 returned. The function guarantees that the write operation does not produce
2830 If the Buffer is NULL, then ASSERT().
2832 @param Buffer The pointer to a 64-bit value that may be unaligned.
2833 @param Value 64-bit value to write to Buffer.
2835 @return The 64-bit value to write to Buffer.
2847 // Bit Field Functions
2851 Returns a bit field from an 8-bit value.
2853 Returns the bitfield specified by the StartBit and the EndBit from Operand.
2855 If 8-bit operations are not supported, then ASSERT().
2856 If StartBit is greater than 7, then ASSERT().
2857 If EndBit is greater than 7, then ASSERT().
2858 If EndBit is less than StartBit, then ASSERT().
2860 @param Operand Operand on which to perform the bitfield operation.
2861 @param StartBit The ordinal of the least significant bit in the bit field.
2863 @param EndBit The ordinal of the most significant bit in the bit field.
2866 @return The bit field read.
2879 Writes a bit field to an 8-bit value, and returns the result.
2881 Writes Value to the bit field specified by the StartBit and the EndBit in
2882 Operand. All other bits in Operand are preserved. The new 8-bit value is
2885 If 8-bit operations are not supported, then ASSERT().
2886 If StartBit is greater than 7, then ASSERT().
2887 If EndBit is greater than 7, then ASSERT().
2888 If EndBit is less than StartBit, then ASSERT().
2889 If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
2891 @param Operand Operand on which to perform the bitfield operation.
2892 @param StartBit The ordinal of the least significant bit in the bit field.
2894 @param EndBit The ordinal of the most significant bit in the bit field.
2896 @param Value New value of the bit field.
2898 @return The new 8-bit value.
2912 Reads a bit field from an 8-bit value, performs a bitwise OR, and returns the
2915 Performs a bitwise OR between the bit field specified by StartBit
2916 and EndBit in Operand and the value specified by OrData. All other bits in
2917 Operand are preserved. The new 8-bit value is returned.
2919 If 8-bit operations are not supported, then ASSERT().
2920 If StartBit is greater than 7, then ASSERT().
2921 If EndBit is greater than 7, then ASSERT().
2922 If EndBit is less than StartBit, then ASSERT().
2923 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
2925 @param Operand Operand on which to perform the bitfield operation.
2926 @param StartBit The ordinal of the least significant bit in the bit field.
2928 @param EndBit The ordinal of the most significant bit in the bit field.
2930 @param OrData The value to OR with the read value from the value
2932 @return The new 8-bit value.
2946 Reads a bit field from an 8-bit value, performs a bitwise AND, and returns
2949 Performs a bitwise AND between the bit field specified by StartBit and EndBit
2950 in Operand and the value specified by AndData. All other bits in Operand are
2951 preserved. The new 8-bit value is returned.
2953 If 8-bit operations are not supported, then ASSERT().
2954 If StartBit is greater than 7, then ASSERT().
2955 If EndBit is greater than 7, then ASSERT().
2956 If EndBit is less than StartBit, then ASSERT().
2957 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
2959 @param Operand Operand on which to perform the bitfield operation.
2960 @param StartBit The ordinal of the least significant bit in the bit field.
2962 @param EndBit The ordinal of the most significant bit in the bit field.
2964 @param AndData The value to AND with the read value from the value.
2966 @return The new 8-bit value.
2980 Reads a bit field from an 8-bit value, performs a bitwise AND followed by a
2981 bitwise OR, and returns the result.
2983 Performs a bitwise AND between the bit field specified by StartBit and EndBit
2984 in Operand and the value specified by AndData, followed by a bitwise
2985 OR with value specified by OrData. All other bits in Operand are
2986 preserved. The new 8-bit value is returned.
2988 If 8-bit operations are not supported, then ASSERT().
2989 If StartBit is greater than 7, then ASSERT().
2990 If EndBit is greater than 7, then ASSERT().
2991 If EndBit is less than StartBit, then ASSERT().
2992 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
2993 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
2995 @param Operand Operand on which to perform the bitfield operation.
2996 @param StartBit The ordinal of the least significant bit in the bit field.
2998 @param EndBit The ordinal of the most significant bit in the bit field.
3000 @param AndData The value to AND with the read value from the value.
3001 @param OrData The value to OR with the result of the AND operation.
3003 @return The new 8-bit value.
3008 BitFieldAndThenOr8 (
3018 Returns a bit field from a 16-bit value.
3020 Returns the bitfield specified by the StartBit and the EndBit from Operand.
3022 If 16-bit operations are not supported, then ASSERT().
3023 If StartBit is greater than 15, then ASSERT().
3024 If EndBit is greater than 15, then ASSERT().
3025 If EndBit is less than StartBit, then ASSERT().
3027 @param Operand Operand on which to perform the bitfield operation.
3028 @param StartBit The ordinal of the least significant bit in the bit field.
3030 @param EndBit The ordinal of the most significant bit in the bit field.
3033 @return The bit field read.
3046 Writes a bit field to a 16-bit value, and returns the result.
3048 Writes Value to the bit field specified by the StartBit and the EndBit in
3049 Operand. All other bits in Operand are preserved. The new 16-bit value is
3052 If 16-bit operations are not supported, then ASSERT().
3053 If StartBit is greater than 15, then ASSERT().
3054 If EndBit is greater than 15, then ASSERT().
3055 If EndBit is less than StartBit, then ASSERT().
3056 If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
3058 @param Operand Operand on which to perform the bitfield operation.
3059 @param StartBit The ordinal of the least significant bit in the bit field.
3061 @param EndBit The ordinal of the most significant bit in the bit field.
3063 @param Value New value of the bit field.
3065 @return The new 16-bit value.
3079 Reads a bit field from a 16-bit value, performs a bitwise OR, and returns the
3082 Performs a bitwise OR between the bit field specified by StartBit
3083 and EndBit in Operand and the value specified by OrData. All other bits in
3084 Operand are preserved. The new 16-bit value is returned.
3086 If 16-bit operations are not supported, then ASSERT().
3087 If StartBit is greater than 15, then ASSERT().
3088 If EndBit is greater than 15, then ASSERT().
3089 If EndBit is less than StartBit, then ASSERT().
3090 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
3092 @param Operand Operand on which to perform the bitfield operation.
3093 @param StartBit The ordinal of the least significant bit in the bit field.
3095 @param EndBit The ordinal of the most significant bit in the bit field.
3097 @param OrData The value to OR with the read value from the value
3099 @return The new 16-bit value.
3113 Reads a bit field from a 16-bit value, performs a bitwise AND, and returns
3116 Performs a bitwise AND between the bit field specified by StartBit and EndBit
3117 in Operand and the value specified by AndData. All other bits in Operand are
3118 preserved. The new 16-bit value is returned.
3120 If 16-bit operations are not supported, then ASSERT().
3121 If StartBit is greater than 15, then ASSERT().
3122 If EndBit is greater than 15, then ASSERT().
3123 If EndBit is less than StartBit, then ASSERT().
3124 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
3126 @param Operand Operand on which to perform the bitfield operation.
3127 @param StartBit The ordinal of the least significant bit in the bit field.
3129 @param EndBit The ordinal of the most significant bit in the bit field.
3131 @param AndData The value to AND with the read value from the value
3133 @return The new 16-bit value.
3147 Reads a bit field from a 16-bit value, performs a bitwise AND followed by a
3148 bitwise OR, and returns the result.
3150 Performs a bitwise AND between the bit field specified by StartBit and EndBit
3151 in Operand and the value specified by AndData, followed by a bitwise
3152 OR with value specified by OrData. All other bits in Operand are
3153 preserved. The new 16-bit value is returned.
3155 If 16-bit operations are not supported, then ASSERT().
3156 If StartBit is greater than 15, then ASSERT().
3157 If EndBit is greater than 15, then ASSERT().
3158 If EndBit is less than StartBit, then ASSERT().
3159 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
3160 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
3162 @param Operand Operand on which to perform the bitfield operation.
3163 @param StartBit The ordinal of the least significant bit in the bit field.
3165 @param EndBit The ordinal of the most significant bit in the bit field.
3167 @param AndData The value to AND with the read value from the value.
3168 @param OrData The value to OR with the result of the AND operation.
3170 @return The new 16-bit value.
3175 BitFieldAndThenOr16 (
3185 Returns a bit field from a 32-bit value.
3187 Returns the bitfield specified by the StartBit and the EndBit from Operand.
3189 If 32-bit operations are not supported, then ASSERT().
3190 If StartBit is greater than 31, then ASSERT().
3191 If EndBit is greater than 31, then ASSERT().
3192 If EndBit is less than StartBit, then ASSERT().
3194 @param Operand Operand on which to perform the bitfield operation.
3195 @param StartBit The ordinal of the least significant bit in the bit field.
3197 @param EndBit The ordinal of the most significant bit in the bit field.
3200 @return The bit field read.
3213 Writes a bit field to a 32-bit value, and returns the result.
3215 Writes Value to the bit field specified by the StartBit and the EndBit in
3216 Operand. All other bits in Operand are preserved. The new 32-bit value is
3219 If 32-bit operations are not supported, then ASSERT().
3220 If StartBit is greater than 31, then ASSERT().
3221 If EndBit is greater than 31, then ASSERT().
3222 If EndBit is less than StartBit, then ASSERT().
3223 If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
3225 @param Operand Operand on which to perform the bitfield operation.
3226 @param StartBit The ordinal of the least significant bit in the bit field.
3228 @param EndBit The ordinal of the most significant bit in the bit field.
3230 @param Value New value of the bit field.
3232 @return The new 32-bit value.
3246 Reads a bit field from a 32-bit value, performs a bitwise OR, and returns the
3249 Performs a bitwise OR between the bit field specified by StartBit
3250 and EndBit in Operand and the value specified by OrData. All other bits in
3251 Operand are preserved. The new 32-bit value is returned.
3253 If 32-bit operations are not supported, then ASSERT().
3254 If StartBit is greater than 31, then ASSERT().
3255 If EndBit is greater than 31, then ASSERT().
3256 If EndBit is less than StartBit, then ASSERT().
3257 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
3259 @param Operand Operand on which to perform the bitfield operation.
3260 @param StartBit The ordinal of the least significant bit in the bit field.
3262 @param EndBit The ordinal of the most significant bit in the bit field.
3264 @param OrData The value to OR with the read value from the value.
3266 @return The new 32-bit value.
3280 Reads a bit field from a 32-bit value, performs a bitwise AND, and returns
3283 Performs a bitwise AND between the bit field specified by StartBit and EndBit
3284 in Operand and the value specified by AndData. All other bits in Operand are
3285 preserved. The new 32-bit value is returned.
3287 If 32-bit operations are not supported, then ASSERT().
3288 If StartBit is greater than 31, then ASSERT().
3289 If EndBit is greater than 31, then ASSERT().
3290 If EndBit is less than StartBit, then ASSERT().
3291 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
3293 @param Operand Operand on which to perform the bitfield operation.
3294 @param StartBit The ordinal of the least significant bit in the bit field.
3296 @param EndBit The ordinal of the most significant bit in the bit field.
3298 @param AndData The value to AND with the read value from the value
3300 @return The new 32-bit value.
3314 Reads a bit field from a 32-bit value, performs a bitwise AND followed by a
3315 bitwise OR, and returns the result.
3317 Performs a bitwise AND between the bit field specified by StartBit and EndBit
3318 in Operand and the value specified by AndData, followed by a bitwise
3319 OR with value specified by OrData. All other bits in Operand are
3320 preserved. The new 32-bit value is returned.
3322 If 32-bit operations are not supported, then ASSERT().
3323 If StartBit is greater than 31, then ASSERT().
3324 If EndBit is greater than 31, then ASSERT().
3325 If EndBit is less than StartBit, then ASSERT().
3326 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
3327 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
3329 @param Operand Operand on which to perform the bitfield operation.
3330 @param StartBit The ordinal of the least significant bit in the bit field.
3332 @param EndBit The ordinal of the most significant bit in the bit field.
3334 @param AndData The value to AND with the read value from the value.
3335 @param OrData The value to OR with the result of the AND operation.
3337 @return The new 32-bit value.
3342 BitFieldAndThenOr32 (
3352 Returns a bit field from a 64-bit value.
3354 Returns the bitfield specified by the StartBit and the EndBit from Operand.
3356 If 64-bit operations are not supported, then ASSERT().
3357 If StartBit is greater than 63, then ASSERT().
3358 If EndBit is greater than 63, then ASSERT().
3359 If EndBit is less than StartBit, then ASSERT().
3361 @param Operand Operand on which to perform the bitfield operation.
3362 @param StartBit The ordinal of the least significant bit in the bit field.
3364 @param EndBit The ordinal of the most significant bit in the bit field.
3367 @return The bit field read.
3380 Writes a bit field to a 64-bit value, and returns the result.
3382 Writes Value to the bit field specified by the StartBit and the EndBit in
3383 Operand. All other bits in Operand are preserved. The new 64-bit value is
3386 If 64-bit operations are not supported, then ASSERT().
3387 If StartBit is greater than 63, then ASSERT().
3388 If EndBit is greater than 63, then ASSERT().
3389 If EndBit is less than StartBit, then ASSERT().
3390 If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
3392 @param Operand Operand on which to perform the bitfield operation.
3393 @param StartBit The ordinal of the least significant bit in the bit field.
3395 @param EndBit The ordinal of the most significant bit in the bit field.
3397 @param Value New value of the bit field.
3399 @return The new 64-bit value.
3413 Reads a bit field from a 64-bit value, performs a bitwise OR, and returns the
3416 Performs a bitwise OR between the bit field specified by StartBit
3417 and EndBit in Operand and the value specified by OrData. All other bits in
3418 Operand are preserved. The new 64-bit value is returned.
3420 If 64-bit operations are not supported, then ASSERT().
3421 If StartBit is greater than 63, then ASSERT().
3422 If EndBit is greater than 63, then ASSERT().
3423 If EndBit is less than StartBit, then ASSERT().
3424 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
3426 @param Operand Operand on which to perform the bitfield operation.
3427 @param StartBit The ordinal of the least significant bit in the bit field.
3429 @param EndBit The ordinal of the most significant bit in the bit field.
3431 @param OrData The value to OR with the read value from the value
3433 @return The new 64-bit value.
3447 Reads a bit field from a 64-bit value, performs a bitwise AND, and returns
3450 Performs a bitwise AND between the bit field specified by StartBit and EndBit
3451 in Operand and the value specified by AndData. All other bits in Operand are
3452 preserved. The new 64-bit value is returned.
3454 If 64-bit operations are not supported, then ASSERT().
3455 If StartBit is greater than 63, then ASSERT().
3456 If EndBit is greater than 63, then ASSERT().
3457 If EndBit is less than StartBit, then ASSERT().
3458 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
3460 @param Operand Operand on which to perform the bitfield operation.
3461 @param StartBit The ordinal of the least significant bit in the bit field.
3463 @param EndBit The ordinal of the most significant bit in the bit field.
3465 @param AndData The value to AND with the read value from the value
3467 @return The new 64-bit value.
3481 Reads a bit field from a 64-bit value, performs a bitwise AND followed by a
3482 bitwise OR, and returns the result.
3484 Performs a bitwise AND between the bit field specified by StartBit and EndBit
3485 in Operand and the value specified by AndData, followed by a bitwise
3486 OR with value specified by OrData. All other bits in Operand are
3487 preserved. The new 64-bit value is returned.
3489 If 64-bit operations are not supported, then ASSERT().
3490 If StartBit is greater than 63, then ASSERT().
3491 If EndBit is greater than 63, then ASSERT().
3492 If EndBit is less than StartBit, then ASSERT().
3493 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
3494 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
3496 @param Operand Operand on which to perform the bitfield operation.
3497 @param StartBit The ordinal of the least significant bit in the bit field.
3499 @param EndBit The ordinal of the most significant bit in the bit field.
3501 @param AndData The value to AND with the read value from the value.
3502 @param OrData The value to OR with the result of the AND operation.
3504 @return The new 64-bit value.
3509 BitFieldAndThenOr64 (
3518 // Base Library Checksum Functions
3522 Returns the sum of all elements in a buffer in unit of UINT8.
3523 During calculation, the carry bits are dropped.
3525 This function calculates the sum of all elements in a buffer
3526 in unit of UINT8. The carry bits in result of addition are dropped.
3527 The result is returned as UINT8. If Length is Zero, then Zero is
3530 If Buffer is NULL, then ASSERT().
3531 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
3533 @param Buffer The pointer to the buffer to carry out the sum operation.
3534 @param Length The size, in bytes, of Buffer.
3536 @return Sum The sum of Buffer with carry bits dropped during additions.
3542 IN CONST UINT8
*Buffer
,
3548 Returns the two's complement checksum of all elements in a buffer
3551 This function first calculates the sum of the 8-bit values in the
3552 buffer specified by Buffer and Length. The carry bits in the result
3553 of addition are dropped. Then, the two's complement of the sum is
3554 returned. If Length is 0, then 0 is returned.
3556 If Buffer is NULL, then ASSERT().
3557 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
3559 @param Buffer The pointer to the buffer to carry out the checksum operation.
3560 @param Length The size, in bytes, of Buffer.
3562 @return Checksum The two's complement checksum of Buffer.
3567 CalculateCheckSum8 (
3568 IN CONST UINT8
*Buffer
,
3574 Returns the sum of all elements in a buffer of 16-bit values. During
3575 calculation, the carry bits are dropped.
3577 This function calculates the sum of the 16-bit values in the buffer
3578 specified by Buffer and Length. The carry bits in result of addition are dropped.
3579 The 16-bit result is returned. If Length is 0, then 0 is returned.
3581 If Buffer is NULL, then ASSERT().
3582 If Buffer is not aligned on a 16-bit boundary, then ASSERT().
3583 If Length is not aligned on a 16-bit boundary, then ASSERT().
3584 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
3586 @param Buffer The pointer to the buffer to carry out the sum operation.
3587 @param Length The size, in bytes, of Buffer.
3589 @return Sum The sum of Buffer with carry bits dropped during additions.
3595 IN CONST UINT16
*Buffer
,
3601 Returns the two's complement checksum of all elements in a buffer of
3604 This function first calculates the sum of the 16-bit values in the buffer
3605 specified by Buffer and Length. The carry bits in the result of addition
3606 are dropped. Then, the two's complement of the sum is returned. If Length
3607 is 0, then 0 is returned.
3609 If Buffer is NULL, then ASSERT().
3610 If Buffer is not aligned on a 16-bit boundary, then ASSERT().
3611 If Length is not aligned on a 16-bit boundary, then ASSERT().
3612 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
3614 @param Buffer The pointer to the buffer to carry out the checksum operation.
3615 @param Length The size, in bytes, of Buffer.
3617 @return Checksum The two's complement checksum of Buffer.
3622 CalculateCheckSum16 (
3623 IN CONST UINT16
*Buffer
,
3629 Returns the sum of all elements in a buffer of 32-bit values. During
3630 calculation, the carry bits are dropped.
3632 This function calculates the sum of the 32-bit values in the buffer
3633 specified by Buffer and Length. The carry bits in result of addition are dropped.
3634 The 32-bit result is returned. If Length is 0, then 0 is returned.
3636 If Buffer is NULL, then ASSERT().
3637 If Buffer is not aligned on a 32-bit boundary, then ASSERT().
3638 If Length is not aligned on a 32-bit boundary, then ASSERT().
3639 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
3641 @param Buffer The pointer to the buffer to carry out the sum operation.
3642 @param Length The size, in bytes, of Buffer.
3644 @return Sum The sum of Buffer with carry bits dropped during additions.
3650 IN CONST UINT32
*Buffer
,
3656 Returns the two's complement checksum of all elements in a buffer of
3659 This function first calculates the sum of the 32-bit values in the buffer
3660 specified by Buffer and Length. The carry bits in the result of addition
3661 are dropped. Then, the two's complement of the sum is returned. If Length
3662 is 0, then 0 is returned.
3664 If Buffer is NULL, then ASSERT().
3665 If Buffer is not aligned on a 32-bit boundary, then ASSERT().
3666 If Length is not aligned on a 32-bit boundary, then ASSERT().
3667 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
3669 @param Buffer The pointer to the buffer to carry out the checksum operation.
3670 @param Length The size, in bytes, of Buffer.
3672 @return Checksum The two's complement checksum of Buffer.
3677 CalculateCheckSum32 (
3678 IN CONST UINT32
*Buffer
,
3684 Returns the sum of all elements in a buffer of 64-bit values. During
3685 calculation, the carry bits are dropped.
3687 This function calculates the sum of the 64-bit values in the buffer
3688 specified by Buffer and Length. The carry bits in result of addition are dropped.
3689 The 64-bit result is returned. If Length is 0, then 0 is returned.
3691 If Buffer is NULL, then ASSERT().
3692 If Buffer is not aligned on a 64-bit boundary, then ASSERT().
3693 If Length is not aligned on a 64-bit boundary, then ASSERT().
3694 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
3696 @param Buffer The pointer to the buffer to carry out the sum operation.
3697 @param Length The size, in bytes, of Buffer.
3699 @return Sum The sum of Buffer with carry bits dropped during additions.
3705 IN CONST UINT64
*Buffer
,
3711 Returns the two's complement checksum of all elements in a buffer of
3714 This function first calculates the sum of the 64-bit values in the buffer
3715 specified by Buffer and Length. The carry bits in the result of addition
3716 are dropped. Then, the two's complement of the sum is returned. If Length
3717 is 0, then 0 is returned.
3719 If Buffer is NULL, then ASSERT().
3720 If Buffer is not aligned on a 64-bit boundary, then ASSERT().
3721 If Length is not aligned on a 64-bit boundary, then ASSERT().
3722 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
3724 @param Buffer The pointer to the buffer to carry out the checksum operation.
3725 @param Length The size, in bytes, of Buffer.
3727 @return Checksum The two's complement checksum of Buffer.
3732 CalculateCheckSum64 (
3733 IN CONST UINT64
*Buffer
,
3739 // Base Library CPU Functions
3743 Function entry point used when a stack switch is requested with SwitchStack()
3745 @param Context1 Context1 parameter passed into SwitchStack().
3746 @param Context2 Context2 parameter passed into SwitchStack().
3751 (EFIAPI
*SWITCH_STACK_ENTRY_POINT
)(
3752 IN VOID
*Context1
, OPTIONAL
3753 IN VOID
*Context2 OPTIONAL
3758 Used to serialize load and store operations.
3760 All loads and stores that proceed calls to this function are guaranteed to be
3761 globally visible when this function returns.
3772 Saves the current CPU context that can be restored with a call to LongJump()
3775 Saves the current CPU context in the buffer specified by JumpBuffer and
3776 returns 0. The initial call to SetJump() must always return 0. Subsequent
3777 calls to LongJump() cause a non-zero value to be returned by SetJump().
3779 If JumpBuffer is NULL, then ASSERT().
3780 For Itanium processors, if JumpBuffer is not aligned on a 16-byte boundary, then ASSERT().
3782 NOTE: The structure BASE_LIBRARY_JUMP_BUFFER is CPU architecture specific.
3783 The same structure must never be used for more than one CPU architecture context.
3784 For example, a BASE_LIBRARY_JUMP_BUFFER allocated by an IA-32 module must never be used from an x64 module.
3785 SetJump()/LongJump() is not currently supported for the EBC processor type.
3787 @param JumpBuffer A pointer to CPU context buffer.
3789 @retval 0 Indicates a return from SetJump().
3795 OUT BASE_LIBRARY_JUMP_BUFFER
*JumpBuffer
3800 Restores the CPU context that was saved with SetJump().
3802 Restores the CPU context from the buffer specified by JumpBuffer. This
3803 function never returns to the caller. Instead is resumes execution based on
3804 the state of JumpBuffer.
3806 If JumpBuffer is NULL, then ASSERT().
3807 For Itanium processors, if JumpBuffer is not aligned on a 16-byte boundary, then ASSERT().
3808 If Value is 0, then ASSERT().
3810 @param JumpBuffer A pointer to CPU context buffer.
3811 @param Value The value to return when the SetJump() context is
3812 restored and must be non-zero.
3818 IN BASE_LIBRARY_JUMP_BUFFER
*JumpBuffer
,
3824 Enables CPU interrupts.
3835 Disables CPU interrupts.
3846 Disables CPU interrupts and returns the interrupt state prior to the disable
3849 @retval TRUE CPU interrupts were enabled on entry to this call.
3850 @retval FALSE CPU interrupts were disabled on entry to this call.
3855 SaveAndDisableInterrupts (
3861 Enables CPU interrupts for the smallest window required to capture any
3867 EnableDisableInterrupts (
3873 Retrieves the current CPU interrupt state.
3875 Returns TRUE if interrupts are currently enabled. Otherwise
3878 @retval TRUE CPU interrupts are enabled.
3879 @retval FALSE CPU interrupts are disabled.
3890 Set the current CPU interrupt state.
3892 Sets the current CPU interrupt state to the state specified by
3893 InterruptState. If InterruptState is TRUE, then interrupts are enabled. If
3894 InterruptState is FALSE, then interrupts are disabled. InterruptState is
3897 @param InterruptState TRUE if interrupts should enabled. FALSE if
3898 interrupts should be disabled.
3900 @return InterruptState
3906 IN BOOLEAN InterruptState
3911 Requests CPU to pause for a short period of time.
3913 Requests CPU to pause for a short period of time. Typically used in MP
3914 systems to prevent memory starvation while waiting for a spin lock.
3925 Transfers control to a function starting with a new stack.
3927 Transfers control to the function specified by EntryPoint using the
3928 new stack specified by NewStack and passing in the parameters specified
3929 by Context1 and Context2. Context1 and Context2 are optional and may
3930 be NULL. The function EntryPoint must never return. This function
3931 supports a variable number of arguments following the NewStack parameter.
3932 These additional arguments are ignored on IA-32, x64, and EBC architectures.
3933 Itanium processors expect one additional parameter of type VOID * that specifies
3934 the new backing store pointer.
3936 If EntryPoint is NULL, then ASSERT().
3937 If NewStack is NULL, then ASSERT().
3939 @param EntryPoint A pointer to function to call with the new stack.
3940 @param Context1 A pointer to the context to pass into the EntryPoint
3942 @param Context2 A pointer to the context to pass into the EntryPoint
3944 @param NewStack A pointer to the new stack to use for the EntryPoint
3946 @param ... This variable argument list is ignored for IA-32, x64, and
3947 EBC architectures. For Itanium processors, this variable
3948 argument list is expected to contain a single parameter of
3949 type VOID * that specifies the new backing store pointer.
3956 IN SWITCH_STACK_ENTRY_POINT EntryPoint
,
3957 IN VOID
*Context1
, OPTIONAL
3958 IN VOID
*Context2
, OPTIONAL
3965 Generates a breakpoint on the CPU.
3967 Generates a breakpoint on the CPU. The breakpoint must be implemented such
3968 that code can resume normal execution after the breakpoint.
3979 Executes an infinite loop.
3981 Forces the CPU to execute an infinite loop. A debugger may be used to skip
3982 past the loop and the code that follows the loop must execute properly. This
3983 implies that the infinite loop must not cause the code that follow it to be
3993 #if defined (MDE_CPU_IPF)
3996 Flush a range of cache lines in the cache coherency domain of the calling
3999 Flushes the cache lines specified by Address and Length. If Address is not aligned
4000 on a cache line boundary, then entire cache line containing Address is flushed.
4001 If Address + Length is not aligned on a cache line boundary, then the entire cache
4002 line containing Address + Length - 1 is flushed. This function may choose to flush
4003 the entire cache if that is more efficient than flushing the specified range. If
4004 Length is 0, the no cache lines are flushed. Address is returned.
4005 This function is only available on Itanium processors.
4007 If Length is greater than (MAX_ADDRESS - Address + 1), then ASSERT().
4009 @param Address The base address of the instruction lines to invalidate. If
4010 the CPU is in a physical addressing mode, then Address is a
4011 physical address. If the CPU is in a virtual addressing mode,
4012 then Address is a virtual address.
4014 @param Length The number of bytes to invalidate from the instruction cache.
4021 AsmFlushCacheRange (
4028 Executes an FC instruction.
4029 Executes an FC instruction on the cache line specified by Address.
4030 The cache line size affected is at least 32-bytes (aligned on a 32-byte boundary).
4031 An implementation may flush a larger region. This function is only available on Itanium processors.
4033 @param Address The Address of cache line to be flushed.
4035 @return The address of FC instruction executed.
4046 Executes an FC.I instruction.
4047 Executes an FC.I instruction on the cache line specified by Address.
4048 The cache line size affected is at least 32-bytes (aligned on a 32-byte boundary).
4049 An implementation may flush a larger region. This function is only available on Itanium processors.
4051 @param Address The Address of cache line to be flushed.
4053 @return The address of the FC.I instruction executed.
4064 Reads the current value of a Processor Identifier Register (CPUID).
4066 Reads and returns the current value of Processor Identifier Register specified by Index.
4067 The Index of largest implemented CPUID (One less than the number of implemented CPUID
4068 registers) is determined by CPUID [3] bits {7:0}.
4069 No parameter checking is performed on Index. If the Index value is beyond the
4070 implemented CPUID register range, a Reserved Register/Field fault may occur. The caller
4071 must either guarantee that Index is valid, or the caller must set up fault handlers to
4072 catch the faults. This function is only available on Itanium processors.
4074 @param Index The 8-bit Processor Identifier Register index to read.
4076 @return The current value of Processor Identifier Register specified by Index.
4087 Reads the current value of 64-bit Processor Status Register (PSR).
4088 This function is only available on Itanium processors.
4090 @return The current value of PSR.
4101 Writes the current value of 64-bit Processor Status Register (PSR).
4103 No parameter checking is performed on Value. All bits of Value corresponding to
4104 reserved fields of PSR must be 0 or a Reserved Register/Field fault may occur.
4105 The caller must either guarantee that Value is valid, or the caller must set up
4106 fault handlers to catch the faults. This function is only available on Itanium processors.
4108 @param Value The 64-bit value to write to PSR.
4110 @return The 64-bit value written to the PSR.
4121 Reads the current value of 64-bit Kernel Register #0 (KR0).
4123 Reads and returns the current value of KR0.
4124 This function is only available on Itanium processors.
4126 @return The current value of KR0.
4137 Reads the current value of 64-bit Kernel Register #1 (KR1).
4139 Reads and returns the current value of KR1.
4140 This function is only available on Itanium processors.
4142 @return The current value of KR1.
4153 Reads the current value of 64-bit Kernel Register #2 (KR2).
4155 Reads and returns the current value of KR2.
4156 This function is only available on Itanium processors.
4158 @return The current value of KR2.
4169 Reads the current value of 64-bit Kernel Register #3 (KR3).
4171 Reads and returns the current value of KR3.
4172 This function is only available on Itanium processors.
4174 @return The current value of KR3.
4185 Reads the current value of 64-bit Kernel Register #4 (KR4).
4187 Reads and returns the current value of KR4.
4188 This function is only available on Itanium processors.
4190 @return The current value of KR4.
4201 Reads the current value of 64-bit Kernel Register #5 (KR5).
4203 Reads and returns the current value of KR5.
4204 This function is only available on Itanium processors.
4206 @return The current value of KR5.
4217 Reads the current value of 64-bit Kernel Register #6 (KR6).
4219 Reads and returns the current value of KR6.
4220 This function is only available on Itanium processors.
4222 @return The current value of KR6.
4233 Reads the current value of 64-bit Kernel Register #7 (KR7).
4235 Reads and returns the current value of KR7.
4236 This function is only available on Itanium processors.
4238 @return The current value of KR7.
4249 Write the current value of 64-bit Kernel Register #0 (KR0).
4251 Writes the current value of KR0. The 64-bit value written to
4252 the KR0 is returned. This function is only available on Itanium processors.
4254 @param Value The 64-bit value to write to KR0.
4256 @return The 64-bit value written to the KR0.
4267 Write the current value of 64-bit Kernel Register #1 (KR1).
4269 Writes the current value of KR1. The 64-bit value written to
4270 the KR1 is returned. This function is only available on Itanium processors.
4272 @param Value The 64-bit value to write to KR1.
4274 @return The 64-bit value written to the KR1.
4285 Write the current value of 64-bit Kernel Register #2 (KR2).
4287 Writes the current value of KR2. The 64-bit value written to
4288 the KR2 is returned. This function is only available on Itanium processors.
4290 @param Value The 64-bit value to write to KR2.
4292 @return The 64-bit value written to the KR2.
4303 Write the current value of 64-bit Kernel Register #3 (KR3).
4305 Writes the current value of KR3. The 64-bit value written to
4306 the KR3 is returned. This function is only available on Itanium processors.
4308 @param Value The 64-bit value to write to KR3.
4310 @return The 64-bit value written to the KR3.
4321 Write the current value of 64-bit Kernel Register #4 (KR4).
4323 Writes the current value of KR4. The 64-bit value written to
4324 the KR4 is returned. This function is only available on Itanium processors.
4326 @param Value The 64-bit value to write to KR4.
4328 @return The 64-bit value written to the KR4.
4339 Write the current value of 64-bit Kernel Register #5 (KR5).
4341 Writes the current value of KR5. The 64-bit value written to
4342 the KR5 is returned. This function is only available on Itanium processors.
4344 @param Value The 64-bit value to write to KR5.
4346 @return The 64-bit value written to the KR5.
4357 Write the current value of 64-bit Kernel Register #6 (KR6).
4359 Writes the current value of KR6. The 64-bit value written to
4360 the KR6 is returned. This function is only available on Itanium processors.
4362 @param Value The 64-bit value to write to KR6.
4364 @return The 64-bit value written to the KR6.
4375 Write the current value of 64-bit Kernel Register #7 (KR7).
4377 Writes the current value of KR7. The 64-bit value written to
4378 the KR7 is returned. This function is only available on Itanium processors.
4380 @param Value The 64-bit value to write to KR7.
4382 @return The 64-bit value written to the KR7.
4393 Reads the current value of Interval Timer Counter Register (ITC).
4395 Reads and returns the current value of ITC.
4396 This function is only available on Itanium processors.
4398 @return The current value of ITC.
4409 Reads the current value of Interval Timer Vector Register (ITV).
4411 Reads and returns the current value of ITV.
4412 This function is only available on Itanium processors.
4414 @return The current value of ITV.
4425 Reads the current value of Interval Timer Match Register (ITM).
4427 Reads and returns the current value of ITM.
4428 This function is only available on Itanium processors.
4430 @return The current value of ITM.
4440 Writes the current value of 64-bit Interval Timer Counter Register (ITC).
4442 Writes the current value of ITC. The 64-bit value written to the ITC is returned.
4443 This function is only available on Itanium processors.
4445 @param Value The 64-bit value to write to ITC.
4447 @return The 64-bit value written to the ITC.
4458 Writes the current value of 64-bit Interval Timer Match Register (ITM).
4460 Writes the current value of ITM. The 64-bit value written to the ITM is returned.
4461 This function is only available on Itanium processors.
4463 @param Value The 64-bit value to write to ITM.
4465 @return The 64-bit value written to the ITM.
4476 Writes the current value of 64-bit Interval Timer Vector Register (ITV).
4478 Writes the current value of ITV. The 64-bit value written to the ITV is returned.
4479 No parameter checking is performed on Value. All bits of Value corresponding to
4480 reserved fields of ITV must be 0 or a Reserved Register/Field fault may occur.
4481 The caller must either guarantee that Value is valid, or the caller must set up
4482 fault handlers to catch the faults.
4483 This function is only available on Itanium processors.
4485 @param Value The 64-bit value to write to ITV.
4487 @return The 64-bit value written to the ITV.
4498 Reads the current value of Default Control Register (DCR).
4500 Reads and returns the current value of DCR. This function is only available on Itanium processors.
4502 @return The current value of DCR.
4513 Reads the current value of Interruption Vector Address Register (IVA).
4515 Reads and returns the current value of IVA. This function is only available on Itanium processors.
4517 @return The current value of IVA.
4527 Reads the current value of Page Table Address Register (PTA).
4529 Reads and returns the current value of PTA. This function is only available on Itanium processors.
4531 @return The current value of PTA.
4542 Writes the current value of 64-bit Default Control Register (DCR).
4544 Writes the current value of DCR. The 64-bit value written to the DCR is returned.
4545 No parameter checking is performed on Value. All bits of Value corresponding to
4546 reserved fields of DCR must be 0 or a Reserved Register/Field fault may occur.
4547 The caller must either guarantee that Value is valid, or the caller must set up
4548 fault handlers to catch the faults.
4549 This function is only available on Itanium processors.
4551 @param Value The 64-bit value to write to DCR.
4553 @return The 64-bit value written to the DCR.
4564 Writes the current value of 64-bit Interruption Vector Address Register (IVA).
4566 Writes the current value of IVA. The 64-bit value written to the IVA is returned.
4567 The size of vector table is 32 K bytes and is 32 K bytes aligned
4568 the low 15 bits of Value is ignored when written.
4569 This function is only available on Itanium processors.
4571 @param Value The 64-bit value to write to IVA.
4573 @return The 64-bit value written to the IVA.
4584 Writes the current value of 64-bit Page Table Address Register (PTA).
4586 Writes the current value of PTA. The 64-bit value written to the PTA is returned.
4587 No parameter checking is performed on Value. All bits of Value corresponding to
4588 reserved fields of DCR must be 0 or a Reserved Register/Field fault may occur.
4589 The caller must either guarantee that Value is valid, or the caller must set up
4590 fault handlers to catch the faults.
4591 This function is only available on Itanium processors.
4593 @param Value The 64-bit value to write to PTA.
4595 @return The 64-bit value written to the PTA.
4605 Reads the current value of Local Interrupt ID Register (LID).
4607 Reads and returns the current value of LID. This function is only available on Itanium processors.
4609 @return The current value of LID.
4620 Reads the current value of External Interrupt Vector Register (IVR).
4622 Reads and returns the current value of IVR. This function is only available on Itanium processors.
4624 @return The current value of IVR.
4635 Reads the current value of Task Priority Register (TPR).
4637 Reads and returns the current value of TPR. This function is only available on Itanium processors.
4639 @return The current value of TPR.
4650 Reads the current value of External Interrupt Request Register #0 (IRR0).
4652 Reads and returns the current value of IRR0. This function is only available on Itanium processors.
4654 @return The current value of IRR0.
4665 Reads the current value of External Interrupt Request Register #1 (IRR1).
4667 Reads and returns the current value of IRR1. This function is only available on Itanium processors.
4669 @return The current value of IRR1.
4680 Reads the current value of External Interrupt Request Register #2 (IRR2).
4682 Reads and returns the current value of IRR2. This function is only available on Itanium processors.
4684 @return The current value of IRR2.
4695 Reads the current value of External Interrupt Request Register #3 (IRR3).
4697 Reads and returns the current value of IRR3. This function is only available on Itanium processors.
4699 @return The current value of IRR3.
4710 Reads the current value of Performance Monitor Vector Register (PMV).
4712 Reads and returns the current value of PMV. This function is only available on Itanium processors.
4714 @return The current value of PMV.
4725 Reads the current value of Corrected Machine Check Vector Register (CMCV).
4727 Reads and returns the current value of CMCV. This function is only available on Itanium processors.
4729 @return The current value of CMCV.
4740 Reads the current value of Local Redirection Register #0 (LRR0).
4742 Reads and returns the current value of LRR0. This function is only available on Itanium processors.
4744 @return The current value of LRR0.
4755 Reads the current value of Local Redirection Register #1 (LRR1).
4757 Reads and returns the current value of LRR1. This function is only available on Itanium processors.
4759 @return The current value of LRR1.
4770 Writes the current value of 64-bit Page Local Interrupt ID Register (LID).
4772 Writes the current value of LID. The 64-bit value written to the LID is returned.
4773 No parameter checking is performed on Value. All bits of Value corresponding to
4774 reserved fields of LID must be 0 or a Reserved Register/Field fault may occur.
4775 The caller must either guarantee that Value is valid, or the caller must set up
4776 fault handlers to catch the faults.
4777 This function is only available on Itanium processors.
4779 @param Value The 64-bit value to write to LID.
4781 @return The 64-bit value written to the LID.
4792 Writes the current value of 64-bit Task Priority Register (TPR).
4794 Writes the current value of TPR. The 64-bit value written to the TPR is returned.
4795 No parameter checking is performed on Value. All bits of Value corresponding to
4796 reserved fields of TPR must be 0 or a Reserved Register/Field fault may occur.
4797 The caller must either guarantee that Value is valid, or the caller must set up
4798 fault handlers to catch the faults.
4799 This function is only available on Itanium processors.
4801 @param Value The 64-bit value to write to TPR.
4803 @return The 64-bit value written to the TPR.
4814 Performs a write operation on End OF External Interrupt Register (EOI).
4816 Writes a value of 0 to the EOI Register. This function is only available on Itanium processors.
4827 Writes the current value of 64-bit Performance Monitor Vector Register (PMV).
4829 Writes the current value of PMV. The 64-bit value written to the PMV is returned.
4830 No parameter checking is performed on Value. All bits of Value corresponding
4831 to reserved fields of PMV must be 0 or a Reserved Register/Field fault may occur.
4832 The caller must either guarantee that Value is valid, or the caller must set up
4833 fault handlers to catch the faults.
4834 This function is only available on Itanium processors.
4836 @param Value The 64-bit value to write to PMV.
4838 @return The 64-bit value written to the PMV.
4849 Writes the current value of 64-bit Corrected Machine Check Vector Register (CMCV).
4851 Writes the current value of CMCV. The 64-bit value written to the CMCV is returned.
4852 No parameter checking is performed on Value. All bits of Value corresponding
4853 to reserved fields of CMCV must be 0 or a Reserved Register/Field fault may occur.
4854 The caller must either guarantee that Value is valid, or the caller must set up
4855 fault handlers to catch the faults.
4856 This function is only available on Itanium processors.
4858 @param Value The 64-bit value to write to CMCV.
4860 @return The 64-bit value written to the CMCV.
4871 Writes the current value of 64-bit Local Redirection Register #0 (LRR0).
4873 Writes the current value of LRR0. The 64-bit value written to the LRR0 is returned.
4874 No parameter checking is performed on Value. All bits of Value corresponding
4875 to reserved fields of LRR0 must be 0 or a Reserved Register/Field fault may occur.
4876 The caller must either guarantee that Value is valid, or the caller must set up
4877 fault handlers to catch the faults.
4878 This function is only available on Itanium processors.
4880 @param Value The 64-bit value to write to LRR0.
4882 @return The 64-bit value written to the LRR0.
4893 Writes the current value of 64-bit Local Redirection Register #1 (LRR1).
4895 Writes the current value of LRR1. The 64-bit value written to the LRR1 is returned.
4896 No parameter checking is performed on Value. All bits of Value corresponding
4897 to reserved fields of LRR1 must be 0 or a Reserved Register/Field fault may occur.
4898 The caller must either guarantee that Value is valid, or the caller must
4899 set up fault handlers to catch the faults.
4900 This function is only available on Itanium processors.
4902 @param Value The 64-bit value to write to LRR1.
4904 @return The 64-bit value written to the LRR1.
4915 Reads the current value of Instruction Breakpoint Register (IBR).
4917 The Instruction Breakpoint Registers are used in pairs. The even numbered
4918 registers contain breakpoint addresses, and the odd numbered registers contain
4919 breakpoint mask conditions. At least four instruction registers pairs are implemented
4920 on all processor models. Implemented registers are contiguous starting with
4921 register 0. No parameter checking is performed on Index, and if the Index value
4922 is beyond the implemented IBR register range, a Reserved Register/Field fault may
4923 occur. The caller must either guarantee that Index is valid, or the caller must
4924 set up fault handlers to catch the faults.
4925 This function is only available on Itanium processors.
4927 @param Index The 8-bit Instruction Breakpoint Register index to read.
4929 @return The current value of Instruction Breakpoint Register specified by Index.
4940 Reads the current value of Data Breakpoint Register (DBR).
4942 The Data Breakpoint Registers are used in pairs. The even numbered registers
4943 contain breakpoint addresses, and odd numbered registers contain breakpoint
4944 mask conditions. At least four data registers pairs are implemented on all processor
4945 models. Implemented registers are contiguous starting with register 0.
4946 No parameter checking is performed on Index. If the Index value is beyond
4947 the implemented DBR register range, a Reserved Register/Field fault may occur.
4948 The caller must either guarantee that Index is valid, or the caller must set up
4949 fault handlers to catch the faults.
4950 This function is only available on Itanium processors.
4952 @param Index The 8-bit Data Breakpoint Register index to read.
4954 @return The current value of Data Breakpoint Register specified by Index.
4965 Reads the current value of Performance Monitor Configuration Register (PMC).
4967 All processor implementations provide at least four performance counters
4968 (PMC/PMD [4]...PMC/PMD [7] pairs), and four performance monitor counter overflow
4969 status registers (PMC [0]... PMC [3]). Processor implementations may provide
4970 additional implementation-dependent PMC and PMD to increase the number of
4971 'generic' performance counters (PMC/PMD pairs). The remainder of PMC and PMD
4972 register set is implementation dependent. No parameter checking is performed
4973 on Index. If the Index value is beyond the implemented PMC register range,
4974 zero value will be returned.
4975 This function is only available on Itanium processors.
4977 @param Index The 8-bit Performance Monitor Configuration Register index to read.
4979 @return The current value of Performance Monitor Configuration Register
4991 Reads the current value of Performance Monitor Data Register (PMD).
4993 All processor implementations provide at least 4 performance counters
4994 (PMC/PMD [4]...PMC/PMD [7] pairs), and 4 performance monitor counter
4995 overflow status registers (PMC [0]... PMC [3]). Processor implementations may
4996 provide additional implementation-dependent PMC and PMD to increase the number
4997 of 'generic' performance counters (PMC/PMD pairs). The remainder of PMC and PMD
4998 register set is implementation dependent. No parameter checking is performed
4999 on Index. If the Index value is beyond the implemented PMD register range,
5000 zero value will be returned.
5001 This function is only available on Itanium processors.
5003 @param Index The 8-bit Performance Monitor Data Register index to read.
5005 @return The current value of Performance Monitor Data Register specified by Index.
5016 Writes the current value of 64-bit Instruction Breakpoint Register (IBR).
5018 Writes current value of Instruction Breakpoint Register specified by Index.
5019 The Instruction Breakpoint Registers are used in pairs. The even numbered
5020 registers contain breakpoint addresses, and odd numbered registers contain
5021 breakpoint mask conditions. At least four instruction registers pairs are implemented
5022 on all processor models. Implemented registers are contiguous starting with
5023 register 0. No parameter checking is performed on Index. If the Index value
5024 is beyond the implemented IBR register range, a Reserved Register/Field fault may
5025 occur. The caller must either guarantee that Index is valid, or the caller must
5026 set up fault handlers to catch the faults.
5027 This function is only available on Itanium processors.
5029 @param Index The 8-bit Instruction Breakpoint Register index to write.
5030 @param Value The 64-bit value to write to IBR.
5032 @return The 64-bit value written to the IBR.
5044 Writes the current value of 64-bit Data Breakpoint Register (DBR).
5046 Writes current value of Data Breakpoint Register specified by Index.
5047 The Data Breakpoint Registers are used in pairs. The even numbered registers
5048 contain breakpoint addresses, and odd numbered registers contain breakpoint
5049 mask conditions. At least four data registers pairs are implemented on all processor
5050 models. Implemented registers are contiguous starting with register 0. No parameter
5051 checking is performed on Index. If the Index value is beyond the implemented
5052 DBR register range, a Reserved Register/Field fault may occur. The caller must
5053 either guarantee that Index is valid, or the caller must set up fault handlers to
5055 This function is only available on Itanium processors.
5057 @param Index The 8-bit Data Breakpoint Register index to write.
5058 @param Value The 64-bit value to write to DBR.
5060 @return The 64-bit value written to the DBR.
5072 Writes the current value of 64-bit Performance Monitor Configuration Register (PMC).
5074 Writes current value of Performance Monitor Configuration Register specified by Index.
5075 All processor implementations provide at least four performance counters
5076 (PMC/PMD [4]...PMC/PMD [7] pairs), and four performance monitor counter overflow status
5077 registers (PMC [0]... PMC [3]). Processor implementations may provide additional
5078 implementation-dependent PMC and PMD to increase the number of 'generic' performance
5079 counters (PMC/PMD pairs). The remainder of PMC and PMD register set is implementation
5080 dependent. No parameter checking is performed on Index. If the Index value is
5081 beyond the implemented PMC register range, the write is ignored.
5082 This function is only available on Itanium processors.
5084 @param Index The 8-bit Performance Monitor Configuration Register index to write.
5085 @param Value The 64-bit value to write to PMC.
5087 @return The 64-bit value written to the PMC.
5099 Writes the current value of 64-bit Performance Monitor Data Register (PMD).
5101 Writes current value of Performance Monitor Data Register specified by Index.
5102 All processor implementations provide at least four performance counters
5103 (PMC/PMD [4]...PMC/PMD [7] pairs), and four performance monitor counter overflow
5104 status registers (PMC [0]... PMC [3]). Processor implementations may provide
5105 additional implementation-dependent PMC and PMD to increase the number of 'generic'
5106 performance counters (PMC/PMD pairs). The remainder of PMC and PMD register set
5107 is implementation dependent. No parameter checking is performed on Index. If the
5108 Index value is beyond the implemented PMD register range, the write is ignored.
5109 This function is only available on Itanium processors.
5111 @param Index The 8-bit Performance Monitor Data Register index to write.
5112 @param Value The 64-bit value to write to PMD.
5114 @return The 64-bit value written to the PMD.
5126 Reads the current value of 64-bit Global Pointer (GP).
5128 Reads and returns the current value of GP.
5129 This function is only available on Itanium processors.
5131 @return The current value of GP.
5142 Write the current value of 64-bit Global Pointer (GP).
5144 Writes the current value of GP. The 64-bit value written to the GP is returned.
5145 No parameter checking is performed on Value.
5146 This function is only available on Itanium processors.
5148 @param Value The 64-bit value to write to GP.
5150 @return The 64-bit value written to the GP.
5161 Reads the current value of 64-bit Stack Pointer (SP).
5163 Reads and returns the current value of SP.
5164 This function is only available on Itanium processors.
5166 @return The current value of SP.
5177 /// Valid Index value for AsmReadControlRegister().
5179 #define IPF_CONTROL_REGISTER_DCR 0
5180 #define IPF_CONTROL_REGISTER_ITM 1
5181 #define IPF_CONTROL_REGISTER_IVA 2
5182 #define IPF_CONTROL_REGISTER_PTA 8
5183 #define IPF_CONTROL_REGISTER_IPSR 16
5184 #define IPF_CONTROL_REGISTER_ISR 17
5185 #define IPF_CONTROL_REGISTER_IIP 19
5186 #define IPF_CONTROL_REGISTER_IFA 20
5187 #define IPF_CONTROL_REGISTER_ITIR 21
5188 #define IPF_CONTROL_REGISTER_IIPA 22
5189 #define IPF_CONTROL_REGISTER_IFS 23
5190 #define IPF_CONTROL_REGISTER_IIM 24
5191 #define IPF_CONTROL_REGISTER_IHA 25
5192 #define IPF_CONTROL_REGISTER_LID 64
5193 #define IPF_CONTROL_REGISTER_IVR 65
5194 #define IPF_CONTROL_REGISTER_TPR 66
5195 #define IPF_CONTROL_REGISTER_EOI 67
5196 #define IPF_CONTROL_REGISTER_IRR0 68
5197 #define IPF_CONTROL_REGISTER_IRR1 69
5198 #define IPF_CONTROL_REGISTER_IRR2 70
5199 #define IPF_CONTROL_REGISTER_IRR3 71
5200 #define IPF_CONTROL_REGISTER_ITV 72
5201 #define IPF_CONTROL_REGISTER_PMV 73
5202 #define IPF_CONTROL_REGISTER_CMCV 74
5203 #define IPF_CONTROL_REGISTER_LRR0 80
5204 #define IPF_CONTROL_REGISTER_LRR1 81
5207 Reads a 64-bit control register.
5209 Reads and returns the control register specified by Index. The valid Index valued
5210 are defined above in "Related Definitions".
5211 If Index is invalid then 0xFFFFFFFFFFFFFFFF is returned. This function is only
5212 available on Itanium processors.
5214 @param Index The index of the control register to read.
5216 @return The control register specified by Index.
5221 AsmReadControlRegister (
5227 /// Valid Index value for AsmReadApplicationRegister().
5229 #define IPF_APPLICATION_REGISTER_K0 0
5230 #define IPF_APPLICATION_REGISTER_K1 1
5231 #define IPF_APPLICATION_REGISTER_K2 2
5232 #define IPF_APPLICATION_REGISTER_K3 3
5233 #define IPF_APPLICATION_REGISTER_K4 4
5234 #define IPF_APPLICATION_REGISTER_K5 5
5235 #define IPF_APPLICATION_REGISTER_K6 6
5236 #define IPF_APPLICATION_REGISTER_K7 7
5237 #define IPF_APPLICATION_REGISTER_RSC 16
5238 #define IPF_APPLICATION_REGISTER_BSP 17
5239 #define IPF_APPLICATION_REGISTER_BSPSTORE 18
5240 #define IPF_APPLICATION_REGISTER_RNAT 19
5241 #define IPF_APPLICATION_REGISTER_FCR 21
5242 #define IPF_APPLICATION_REGISTER_EFLAG 24
5243 #define IPF_APPLICATION_REGISTER_CSD 25
5244 #define IPF_APPLICATION_REGISTER_SSD 26
5245 #define IPF_APPLICATION_REGISTER_CFLG 27
5246 #define IPF_APPLICATION_REGISTER_FSR 28
5247 #define IPF_APPLICATION_REGISTER_FIR 29
5248 #define IPF_APPLICATION_REGISTER_FDR 30
5249 #define IPF_APPLICATION_REGISTER_CCV 32
5250 #define IPF_APPLICATION_REGISTER_UNAT 36
5251 #define IPF_APPLICATION_REGISTER_FPSR 40
5252 #define IPF_APPLICATION_REGISTER_ITC 44
5253 #define IPF_APPLICATION_REGISTER_PFS 64
5254 #define IPF_APPLICATION_REGISTER_LC 65
5255 #define IPF_APPLICATION_REGISTER_EC 66
5258 Reads a 64-bit application register.
5260 Reads and returns the application register specified by Index. The valid Index
5261 valued are defined above in "Related Definitions".
5262 If Index is invalid then 0xFFFFFFFFFFFFFFFF is returned. This function is only
5263 available on Itanium processors.
5265 @param Index The index of the application register to read.
5267 @return The application register specified by Index.
5272 AsmReadApplicationRegister (
5278 Reads the current value of a Machine Specific Register (MSR).
5280 Reads and returns the current value of the Machine Specific Register specified by Index. No
5281 parameter checking is performed on Index, and if the Index value is beyond the implemented MSR
5282 register range, a Reserved Register/Field fault may occur. The caller must either guarantee that
5283 Index is valid, or the caller must set up fault handlers to catch the faults. This function is
5284 only available on Itanium processors.
5286 @param Index The 8-bit Machine Specific Register index to read.
5288 @return The current value of the Machine Specific Register specified by Index.
5299 Writes the current value of a Machine Specific Register (MSR).
5301 Writes Value to the Machine Specific Register specified by Index. Value is returned. No
5302 parameter checking is performed on Index, and if the Index value is beyond the implemented MSR
5303 register range, a Reserved Register/Field fault may occur. The caller must either guarantee that
5304 Index is valid, or the caller must set up fault handlers to catch the faults. This function is
5305 only available on Itanium processors.
5307 @param Index The 8-bit Machine Specific Register index to write.
5308 @param Value The 64-bit value to write to the Machine Specific Register.
5310 @return The 64-bit value to write to the Machine Specific Register.
5322 Determines if the CPU is currently executing in virtual, physical, or mixed mode.
5324 Determines the current execution mode of the CPU.
5325 If the CPU is in virtual mode(PSR.RT=1, PSR.DT=1, PSR.IT=1), then 1 is returned.
5326 If the CPU is in physical mode(PSR.RT=0, PSR.DT=0, PSR.IT=0), then 0 is returned.
5327 If the CPU is not in physical mode or virtual mode, then it is in mixed mode,
5329 This function is only available on Itanium processors.
5331 @retval 1 The CPU is in virtual mode.
5332 @retval 0 The CPU is in physical mode.
5333 @retval -1 The CPU is in mixed mode.
5344 Makes a PAL procedure call.
5346 This is a wrapper function to make a PAL procedure call. Based on the Index
5347 value this API will make static or stacked PAL call. The following table
5348 describes the usage of PAL Procedure Index Assignment. Architected procedures
5349 may be designated as required or optional. If a PAL procedure is specified
5350 as optional, a unique return code of 0xFFFFFFFFFFFFFFFF is returned in the
5351 Status field of the PAL_CALL_RETURN structure.
5352 This indicates that the procedure is not present in this PAL implementation.
5353 It is the caller's responsibility to check for this return code after calling
5354 any optional PAL procedure.
5355 No parameter checking is performed on the 5 input parameters, but there are
5356 some common rules that the caller should follow when making a PAL call. Any
5357 address passed to PAL as buffers for return parameters must be 8-byte aligned.
5358 Unaligned addresses may cause undefined results. For those parameters defined
5359 as reserved or some fields defined as reserved must be zero filled or the invalid
5360 argument return value may be returned or undefined result may occur during the
5361 execution of the procedure. If the PalEntryPoint does not point to a valid
5362 PAL entry point then the system behavior is undefined. This function is only
5363 available on Itanium processors.
5365 @param PalEntryPoint The PAL procedure calls entry point.
5366 @param Index The PAL procedure Index number.
5367 @param Arg2 The 2nd parameter for PAL procedure calls.
5368 @param Arg3 The 3rd parameter for PAL procedure calls.
5369 @param Arg4 The 4th parameter for PAL procedure calls.
5371 @return structure returned from the PAL Call procedure, including the status and return value.
5377 IN UINT64 PalEntryPoint
,
5385 #if defined (MDE_CPU_IA32) || defined (MDE_CPU_X64)
5387 /// IA32 and x64 Specific Functions.
5388 /// Byte packed structure for 16-bit Real Mode EFLAGS.
5392 UINT32 CF
:1; ///< Carry Flag.
5393 UINT32 Reserved_0
:1; ///< Reserved.
5394 UINT32 PF
:1; ///< Parity Flag.
5395 UINT32 Reserved_1
:1; ///< Reserved.
5396 UINT32 AF
:1; ///< Auxiliary Carry Flag.
5397 UINT32 Reserved_2
:1; ///< Reserved.
5398 UINT32 ZF
:1; ///< Zero Flag.
5399 UINT32 SF
:1; ///< Sign Flag.
5400 UINT32 TF
:1; ///< Trap Flag.
5401 UINT32 IF
:1; ///< Interrupt Enable Flag.
5402 UINT32 DF
:1; ///< Direction Flag.
5403 UINT32 OF
:1; ///< Overflow Flag.
5404 UINT32 IOPL
:2; ///< I/O Privilege Level.
5405 UINT32 NT
:1; ///< Nested Task.
5406 UINT32 Reserved_3
:1; ///< Reserved.
5412 /// Byte packed structure for EFLAGS/RFLAGS.
5413 /// 32-bits on IA-32.
5414 /// 64-bits on x64. The upper 32-bits on x64 are reserved.
5418 UINT32 CF
:1; ///< Carry Flag.
5419 UINT32 Reserved_0
:1; ///< Reserved.
5420 UINT32 PF
:1; ///< Parity Flag.
5421 UINT32 Reserved_1
:1; ///< Reserved.
5422 UINT32 AF
:1; ///< Auxiliary Carry Flag.
5423 UINT32 Reserved_2
:1; ///< Reserved.
5424 UINT32 ZF
:1; ///< Zero Flag.
5425 UINT32 SF
:1; ///< Sign Flag.
5426 UINT32 TF
:1; ///< Trap Flag.
5427 UINT32 IF
:1; ///< Interrupt Enable Flag.
5428 UINT32 DF
:1; ///< Direction Flag.
5429 UINT32 OF
:1; ///< Overflow Flag.
5430 UINT32 IOPL
:2; ///< I/O Privilege Level.
5431 UINT32 NT
:1; ///< Nested Task.
5432 UINT32 Reserved_3
:1; ///< Reserved.
5433 UINT32 RF
:1; ///< Resume Flag.
5434 UINT32 VM
:1; ///< Virtual 8086 Mode.
5435 UINT32 AC
:1; ///< Alignment Check.
5436 UINT32 VIF
:1; ///< Virtual Interrupt Flag.
5437 UINT32 VIP
:1; ///< Virtual Interrupt Pending.
5438 UINT32 ID
:1; ///< ID Flag.
5439 UINT32 Reserved_4
:10; ///< Reserved.
5445 /// Byte packed structure for Control Register 0 (CR0).
5446 /// 32-bits on IA-32.
5447 /// 64-bits on x64. The upper 32-bits on x64 are reserved.
5451 UINT32 PE
:1; ///< Protection Enable.
5452 UINT32 MP
:1; ///< Monitor Coprocessor.
5453 UINT32 EM
:1; ///< Emulation.
5454 UINT32 TS
:1; ///< Task Switched.
5455 UINT32 ET
:1; ///< Extension Type.
5456 UINT32 NE
:1; ///< Numeric Error.
5457 UINT32 Reserved_0
:10; ///< Reserved.
5458 UINT32 WP
:1; ///< Write Protect.
5459 UINT32 Reserved_1
:1; ///< Reserved.
5460 UINT32 AM
:1; ///< Alignment Mask.
5461 UINT32 Reserved_2
:10; ///< Reserved.
5462 UINT32 NW
:1; ///< Mot Write-through.
5463 UINT32 CD
:1; ///< Cache Disable.
5464 UINT32 PG
:1; ///< Paging.
5470 /// Byte packed structure for Control Register 4 (CR4).
5471 /// 32-bits on IA-32.
5472 /// 64-bits on x64. The upper 32-bits on x64 are reserved.
5476 UINT32 VME
:1; ///< Virtual-8086 Mode Extensions.
5477 UINT32 PVI
:1; ///< Protected-Mode Virtual Interrupts.
5478 UINT32 TSD
:1; ///< Time Stamp Disable.
5479 UINT32 DE
:1; ///< Debugging Extensions.
5480 UINT32 PSE
:1; ///< Page Size Extensions.
5481 UINT32 PAE
:1; ///< Physical Address Extension.
5482 UINT32 MCE
:1; ///< Machine Check Enable.
5483 UINT32 PGE
:1; ///< Page Global Enable.
5484 UINT32 PCE
:1; ///< Performance Monitoring Counter
5486 UINT32 OSFXSR
:1; ///< Operating System Support for
5487 ///< FXSAVE and FXRSTOR instructions
5488 UINT32 OSXMMEXCPT
:1; ///< Operating System Support for
5489 ///< Unmasked SIMD Floating Point
5491 UINT32 Reserved_0
:2; ///< Reserved.
5492 UINT32 VMXE
:1; ///< VMX Enable
5493 UINT32 Reserved_1
:18; ///< Reserved.
5499 /// Byte packed structure for a segment descriptor in a GDT/LDT.
5518 } IA32_SEGMENT_DESCRIPTOR
;
5521 /// Byte packed structure for an IDTR, GDTR, LDTR descriptor.
5530 #define IA32_IDT_GATE_TYPE_TASK 0x85
5531 #define IA32_IDT_GATE_TYPE_INTERRUPT_16 0x86
5532 #define IA32_IDT_GATE_TYPE_TRAP_16 0x87
5533 #define IA32_IDT_GATE_TYPE_INTERRUPT_32 0x8E
5534 #define IA32_IDT_GATE_TYPE_TRAP_32 0x8F
5537 #if defined (MDE_CPU_IA32)
5539 /// Byte packed structure for an IA-32 Interrupt Gate Descriptor.
5543 UINT32 OffsetLow
:16; ///< Offset bits 15..0.
5544 UINT32 Selector
:16; ///< Selector.
5545 UINT32 Reserved_0
:8; ///< Reserved.
5546 UINT32 GateType
:8; ///< Gate Type. See #defines above.
5547 UINT32 OffsetHigh
:16; ///< Offset bits 31..16.
5550 } IA32_IDT_GATE_DESCRIPTOR
;
5554 #if defined (MDE_CPU_X64)
5556 /// Byte packed structure for an x64 Interrupt Gate Descriptor.
5560 UINT32 OffsetLow
:16; ///< Offset bits 15..0.
5561 UINT32 Selector
:16; ///< Selector.
5562 UINT32 Reserved_0
:8; ///< Reserved.
5563 UINT32 GateType
:8; ///< Gate Type. See #defines above.
5564 UINT32 OffsetHigh
:16; ///< Offset bits 31..16.
5565 UINT32 OffsetUpper
:32; ///< Offset bits 63..32.
5566 UINT32 Reserved_1
:32; ///< Reserved.
5572 } IA32_IDT_GATE_DESCRIPTOR
;
5577 /// Byte packed structure for an FP/SSE/SSE2 context.
5584 /// Structures for the 16-bit real mode thunks.
5637 IA32_EFLAGS32 EFLAGS
;
5647 } IA32_REGISTER_SET
;
5650 /// Byte packed structure for an 16-bit real mode thunks.
5653 IA32_REGISTER_SET
*RealModeState
;
5654 VOID
*RealModeBuffer
;
5655 UINT32 RealModeBufferSize
;
5656 UINT32 ThunkAttributes
;
5659 #define THUNK_ATTRIBUTE_BIG_REAL_MODE 0x00000001
5660 #define THUNK_ATTRIBUTE_DISABLE_A20_MASK_INT_15 0x00000002
5661 #define THUNK_ATTRIBUTE_DISABLE_A20_MASK_KBD_CTRL 0x00000004
5664 Retrieves CPUID information.
5666 Executes the CPUID instruction with EAX set to the value specified by Index.
5667 This function always returns Index.
5668 If Eax is not NULL, then the value of EAX after CPUID is returned in Eax.
5669 If Ebx is not NULL, then the value of EBX after CPUID is returned in Ebx.
5670 If Ecx is not NULL, then the value of ECX after CPUID is returned in Ecx.
5671 If Edx is not NULL, then the value of EDX after CPUID is returned in Edx.
5672 This function is only available on IA-32 and x64.
5674 @param Index The 32-bit value to load into EAX prior to invoking the CPUID
5676 @param Eax The pointer to the 32-bit EAX value returned by the CPUID
5677 instruction. This is an optional parameter that may be NULL.
5678 @param Ebx The pointer to the 32-bit EBX value returned by the CPUID
5679 instruction. This is an optional parameter that may be NULL.
5680 @param Ecx The pointer to the 32-bit ECX value returned by the CPUID
5681 instruction. This is an optional parameter that may be NULL.
5682 @param Edx The pointer to the 32-bit EDX value returned by the CPUID
5683 instruction. This is an optional parameter that may be NULL.
5692 OUT UINT32
*Eax
, OPTIONAL
5693 OUT UINT32
*Ebx
, OPTIONAL
5694 OUT UINT32
*Ecx
, OPTIONAL
5695 OUT UINT32
*Edx OPTIONAL
5700 Retrieves CPUID information using an extended leaf identifier.
5702 Executes the CPUID instruction with EAX set to the value specified by Index
5703 and ECX set to the value specified by SubIndex. This function always returns
5704 Index. This function is only available on IA-32 and x64.
5706 If Eax is not NULL, then the value of EAX after CPUID is returned in Eax.
5707 If Ebx is not NULL, then the value of EBX after CPUID is returned in Ebx.
5708 If Ecx is not NULL, then the value of ECX after CPUID is returned in Ecx.
5709 If Edx is not NULL, then the value of EDX after CPUID is returned in Edx.
5711 @param Index The 32-bit value to load into EAX prior to invoking the
5713 @param SubIndex The 32-bit value to load into ECX prior to invoking the
5715 @param Eax The pointer to the 32-bit EAX value returned by the CPUID
5716 instruction. This is an optional parameter that may be
5718 @param Ebx The pointer to the 32-bit EBX value returned by the CPUID
5719 instruction. This is an optional parameter that may be
5721 @param Ecx The pointer to the 32-bit ECX value returned by the CPUID
5722 instruction. This is an optional parameter that may be
5724 @param Edx The pointer to the 32-bit EDX value returned by the CPUID
5725 instruction. This is an optional parameter that may be
5736 OUT UINT32
*Eax
, OPTIONAL
5737 OUT UINT32
*Ebx
, OPTIONAL
5738 OUT UINT32
*Ecx
, OPTIONAL
5739 OUT UINT32
*Edx OPTIONAL
5744 Set CD bit and clear NW bit of CR0 followed by a WBINVD.
5746 Disables the caches by setting the CD bit of CR0 to 1, clearing the NW bit of CR0 to 0,
5747 and executing a WBINVD instruction. This function is only available on IA-32 and x64.
5758 Perform a WBINVD and clear both the CD and NW bits of CR0.
5760 Enables the caches by executing a WBINVD instruction and then clear both the CD and NW
5761 bits of CR0 to 0. This function is only available on IA-32 and x64.
5772 Returns the lower 32-bits of a Machine Specific Register(MSR).
5774 Reads and returns the lower 32-bits of the MSR specified by Index.
5775 No parameter checking is performed on Index, and some Index values may cause
5776 CPU exceptions. The caller must either guarantee that Index is valid, or the
5777 caller must set up exception handlers to catch the exceptions. This function
5778 is only available on IA-32 and x64.
5780 @param Index The 32-bit MSR index to read.
5782 @return The lower 32 bits of the MSR identified by Index.
5793 Writes a 32-bit value to a Machine Specific Register(MSR), and returns the value.
5794 The upper 32-bits of the MSR are set to zero.
5796 Writes the 32-bit value specified by Value to the MSR specified by Index. The
5797 upper 32-bits of the MSR write are set to zero. The 32-bit value written to
5798 the MSR is returned. No parameter checking is performed on Index or Value,
5799 and some of these may cause CPU exceptions. The caller must either guarantee
5800 that Index and Value are valid, or the caller must establish proper exception
5801 handlers. This function is only available on IA-32 and x64.
5803 @param Index The 32-bit MSR index to write.
5804 @param Value The 32-bit value to write to the MSR.
5818 Reads a 64-bit MSR, performs a bitwise OR on the lower 32-bits, and
5819 writes the result back to the 64-bit MSR.
5821 Reads the 64-bit MSR specified by Index, performs a bitwise OR
5822 between the lower 32-bits of the read result and the value specified by
5823 OrData, and writes the result to the 64-bit MSR specified by Index. The lower
5824 32-bits of the value written to the MSR is returned. No parameter checking is
5825 performed on Index or OrData, and some of these may cause CPU exceptions. The
5826 caller must either guarantee that Index and OrData are valid, or the caller
5827 must establish proper exception handlers. This function is only available on
5830 @param Index The 32-bit MSR index to write.
5831 @param OrData The value to OR with the read value from the MSR.
5833 @return The lower 32-bit value written to the MSR.
5845 Reads a 64-bit MSR, performs a bitwise AND on the lower 32-bits, and writes
5846 the result back to the 64-bit MSR.
5848 Reads the 64-bit MSR specified by Index, performs a bitwise AND between the
5849 lower 32-bits of the read result and the value specified by AndData, and
5850 writes the result to the 64-bit MSR specified by Index. The lower 32-bits of
5851 the value written to the MSR is returned. No parameter checking is performed
5852 on Index or AndData, and some of these may cause CPU exceptions. The caller
5853 must either guarantee that Index and AndData are valid, or the caller must
5854 establish proper exception handlers. This function is only available on IA-32
5857 @param Index The 32-bit MSR index to write.
5858 @param AndData The value to AND with the read value from the MSR.
5860 @return The lower 32-bit value written to the MSR.
5872 Reads a 64-bit MSR, performs a bitwise AND followed by a bitwise OR
5873 on the lower 32-bits, and writes the result back to the 64-bit MSR.
5875 Reads the 64-bit MSR specified by Index, performs a bitwise AND between the
5876 lower 32-bits of the read result and the value specified by AndData
5877 preserving the upper 32-bits, performs a bitwise OR between the
5878 result of the AND operation and the value specified by OrData, and writes the
5879 result to the 64-bit MSR specified by Address. The lower 32-bits of the value
5880 written to the MSR is returned. No parameter checking is performed on Index,
5881 AndData, or OrData, and some of these may cause CPU exceptions. The caller
5882 must either guarantee that Index, AndData, and OrData are valid, or the
5883 caller must establish proper exception handlers. This function is only
5884 available on IA-32 and x64.
5886 @param Index The 32-bit MSR index to write.
5887 @param AndData The value to AND with the read value from the MSR.
5888 @param OrData The value to OR with the result of the AND operation.
5890 @return The lower 32-bit value written to the MSR.
5903 Reads a bit field of an MSR.
5905 Reads the bit field in the lower 32-bits of a 64-bit MSR. The bit field is
5906 specified by the StartBit and the EndBit. The value of the bit field is
5907 returned. The caller must either guarantee that Index is valid, or the caller
5908 must set up exception handlers to catch the exceptions. This function is only
5909 available on IA-32 and x64.
5911 If StartBit is greater than 31, then ASSERT().
5912 If EndBit is greater than 31, then ASSERT().
5913 If EndBit is less than StartBit, then ASSERT().
5915 @param Index The 32-bit MSR index to read.
5916 @param StartBit The ordinal of the least significant bit in the bit field.
5918 @param EndBit The ordinal of the most significant bit in the bit field.
5921 @return The bit field read from the MSR.
5926 AsmMsrBitFieldRead32 (
5934 Writes a bit field to an MSR.
5936 Writes Value to a bit field in the lower 32-bits of a 64-bit MSR. The bit
5937 field is specified by the StartBit and the EndBit. All other bits in the
5938 destination MSR are preserved. The lower 32-bits of the MSR written is
5939 returned. The caller must either guarantee that Index and the data written
5940 is valid, or the caller must set up exception handlers to catch the exceptions.
5941 This function is only available on IA-32 and x64.
5943 If StartBit is greater than 31, then ASSERT().
5944 If EndBit is greater than 31, then ASSERT().
5945 If EndBit is less than StartBit, then ASSERT().
5946 If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
5948 @param Index The 32-bit MSR index to write.
5949 @param StartBit The ordinal of the least significant bit in the bit field.
5951 @param EndBit The ordinal of the most significant bit in the bit field.
5953 @param Value New value of the bit field.
5955 @return The lower 32-bit of the value written to the MSR.
5960 AsmMsrBitFieldWrite32 (
5969 Reads a bit field in a 64-bit MSR, performs a bitwise OR, and writes the
5970 result back to the bit field in the 64-bit MSR.
5972 Reads the 64-bit MSR specified by Index, performs a bitwise OR
5973 between the read result and the value specified by OrData, and writes the
5974 result to the 64-bit MSR specified by Index. The lower 32-bits of the value
5975 written to the MSR are returned. Extra left bits in OrData are stripped. The
5976 caller must either guarantee that Index and the data written is valid, or
5977 the caller must set up exception handlers to catch the exceptions. This
5978 function is only available on IA-32 and x64.
5980 If StartBit is greater than 31, then ASSERT().
5981 If EndBit is greater than 31, then ASSERT().
5982 If EndBit is less than StartBit, then ASSERT().
5983 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
5985 @param Index The 32-bit MSR index to write.
5986 @param StartBit The ordinal of the least significant bit in the bit field.
5988 @param EndBit The ordinal of the most significant bit in the bit field.
5990 @param OrData The value to OR with the read value from the MSR.
5992 @return The lower 32-bit of the value written to the MSR.
5997 AsmMsrBitFieldOr32 (
6006 Reads a bit field in a 64-bit MSR, performs a bitwise AND, and writes the
6007 result back to the bit field in the 64-bit MSR.
6009 Reads the 64-bit MSR specified by Index, performs a bitwise AND between the
6010 read result and the value specified by AndData, and writes the result to the
6011 64-bit MSR specified by Index. The lower 32-bits of the value written to the
6012 MSR are returned. Extra left bits in AndData are stripped. The caller must
6013 either guarantee that Index and the data written is valid, or the caller must
6014 set up exception handlers to catch the exceptions. This function is only
6015 available on IA-32 and x64.
6017 If StartBit is greater than 31, then ASSERT().
6018 If EndBit is greater than 31, then ASSERT().
6019 If EndBit is less than StartBit, then ASSERT().
6020 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
6022 @param Index The 32-bit MSR index to write.
6023 @param StartBit The ordinal of the least significant bit in the bit field.
6025 @param EndBit The ordinal of the most significant bit in the bit field.
6027 @param AndData The value to AND with the read value from the MSR.
6029 @return The lower 32-bit of the value written to the MSR.
6034 AsmMsrBitFieldAnd32 (
6043 Reads a bit field in a 64-bit MSR, performs a bitwise AND followed by a
6044 bitwise OR, and writes the result back to the bit field in the
6047 Reads the 64-bit MSR specified by Index, performs a bitwise AND followed by a
6048 bitwise OR between the read result and the value specified by
6049 AndData, and writes the result to the 64-bit MSR specified by Index. The
6050 lower 32-bits of the value written to the MSR are returned. Extra left bits
6051 in both AndData and OrData are stripped. The caller must either guarantee
6052 that Index and the data written is valid, or the caller must set up exception
6053 handlers to catch the exceptions. This function is only available on IA-32
6056 If StartBit is greater than 31, then ASSERT().
6057 If EndBit is greater than 31, then ASSERT().
6058 If EndBit is less than StartBit, then ASSERT().
6059 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
6060 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
6062 @param Index The 32-bit MSR index to write.
6063 @param StartBit The ordinal of the least significant bit in the bit field.
6065 @param EndBit The ordinal of the most significant bit in the bit field.
6067 @param AndData The value to AND with the read value from the MSR.
6068 @param OrData The value to OR with the result of the AND operation.
6070 @return The lower 32-bit of the value written to the MSR.
6075 AsmMsrBitFieldAndThenOr32 (
6085 Returns a 64-bit Machine Specific Register(MSR).
6087 Reads and returns the 64-bit MSR specified by Index. No parameter checking is
6088 performed on Index, and some Index values may cause CPU exceptions. The
6089 caller must either guarantee that Index is valid, or the caller must set up
6090 exception handlers to catch the exceptions. This function is only available
6093 @param Index The 32-bit MSR index to read.
6095 @return The value of the MSR identified by Index.
6106 Writes a 64-bit value to a Machine Specific Register(MSR), and returns the
6109 Writes the 64-bit value specified by Value to the MSR specified by Index. The
6110 64-bit value written to the MSR is returned. No parameter checking is
6111 performed on Index or Value, and some of these may cause CPU exceptions. The
6112 caller must either guarantee that Index and Value are valid, or the caller
6113 must establish proper exception handlers. This function is only available on
6116 @param Index The 32-bit MSR index to write.
6117 @param Value The 64-bit value to write to the MSR.
6131 Reads a 64-bit MSR, performs a bitwise OR, and writes the result
6132 back to the 64-bit MSR.
6134 Reads the 64-bit MSR specified by Index, performs a bitwise OR
6135 between the read result and the value specified by OrData, and writes the
6136 result to the 64-bit MSR specified by Index. The value written to the MSR is
6137 returned. No parameter checking is performed on Index or OrData, and some of
6138 these may cause CPU exceptions. The caller must either guarantee that Index
6139 and OrData are valid, or the caller must establish proper exception handlers.
6140 This function is only available on IA-32 and x64.
6142 @param Index The 32-bit MSR index to write.
6143 @param OrData The value to OR with the read value from the MSR.
6145 @return The value written back to the MSR.
6157 Reads a 64-bit MSR, performs a bitwise AND, and writes the result back to the
6160 Reads the 64-bit MSR specified by Index, performs a bitwise AND between the
6161 read result and the value specified by OrData, and writes the result to the
6162 64-bit MSR specified by Index. The value written to the MSR is returned. No
6163 parameter checking is performed on Index or OrData, and some of these may
6164 cause CPU exceptions. The caller must either guarantee that Index and OrData
6165 are valid, or the caller must establish proper exception handlers. This
6166 function is only available on IA-32 and x64.
6168 @param Index The 32-bit MSR index to write.
6169 @param AndData The value to AND with the read value from the MSR.
6171 @return The value written back to the MSR.
6183 Reads a 64-bit MSR, performs a bitwise AND followed by a bitwise
6184 OR, and writes the result back to the 64-bit MSR.
6186 Reads the 64-bit MSR specified by Index, performs a bitwise AND between read
6187 result and the value specified by AndData, performs a bitwise OR
6188 between the result of the AND operation and the value specified by OrData,
6189 and writes the result to the 64-bit MSR specified by Index. The value written
6190 to the MSR is returned. No parameter checking is performed on Index, AndData,
6191 or OrData, and some of these may cause CPU exceptions. The caller must either
6192 guarantee that Index, AndData, and OrData are valid, or the caller must
6193 establish proper exception handlers. This function is only available on IA-32
6196 @param Index The 32-bit MSR index to write.
6197 @param AndData The value to AND with the read value from the MSR.
6198 @param OrData The value to OR with the result of the AND operation.
6200 @return The value written back to the MSR.
6213 Reads a bit field of an MSR.
6215 Reads the bit field in the 64-bit MSR. The bit field is specified by the
6216 StartBit and the EndBit. The value of the bit field is returned. The caller
6217 must either guarantee that Index is valid, or the caller must set up
6218 exception handlers to catch the exceptions. This function is only available
6221 If StartBit is greater than 63, then ASSERT().
6222 If EndBit is greater than 63, then ASSERT().
6223 If EndBit is less than StartBit, then ASSERT().
6225 @param Index The 32-bit MSR index to read.
6226 @param StartBit The ordinal of the least significant bit in the bit field.
6228 @param EndBit The ordinal of the most significant bit in the bit field.
6231 @return The value read from the MSR.
6236 AsmMsrBitFieldRead64 (
6244 Writes a bit field to an MSR.
6246 Writes Value to a bit field in a 64-bit MSR. The bit field is specified by
6247 the StartBit and the EndBit. All other bits in the destination MSR are
6248 preserved. The MSR written is returned. The caller must either guarantee
6249 that Index and the data written is valid, or the caller must set up exception
6250 handlers to catch the exceptions. This function is only available on IA-32 and x64.
6252 If StartBit is greater than 63, then ASSERT().
6253 If EndBit is greater than 63, then ASSERT().
6254 If EndBit is less than StartBit, then ASSERT().
6255 If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
6257 @param Index The 32-bit MSR index to write.
6258 @param StartBit The ordinal of the least significant bit in the bit field.
6260 @param EndBit The ordinal of the most significant bit in the bit field.
6262 @param Value New value of the bit field.
6264 @return The value written back to the MSR.
6269 AsmMsrBitFieldWrite64 (
6278 Reads a bit field in a 64-bit MSR, performs a bitwise OR, and
6279 writes the result back to the bit field in the 64-bit MSR.
6281 Reads the 64-bit MSR specified by Index, performs a bitwise OR
6282 between the read result and the value specified by OrData, and writes the
6283 result to the 64-bit MSR specified by Index. The value written to the MSR is
6284 returned. Extra left bits in OrData are stripped. The caller must either
6285 guarantee that Index and the data written is valid, or the caller must set up
6286 exception handlers to catch the exceptions. This function is only available
6289 If StartBit is greater than 63, then ASSERT().
6290 If EndBit is greater than 63, then ASSERT().
6291 If EndBit is less than StartBit, then ASSERT().
6292 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
6294 @param Index The 32-bit MSR index to write.
6295 @param StartBit The ordinal of the least significant bit in the bit field.
6297 @param EndBit The ordinal of the most significant bit in the bit field.
6299 @param OrData The value to OR with the read value from the bit field.
6301 @return The value written back to the MSR.
6306 AsmMsrBitFieldOr64 (
6315 Reads a bit field in a 64-bit MSR, performs a bitwise AND, and writes the
6316 result back to the bit field in the 64-bit MSR.
6318 Reads the 64-bit MSR specified by Index, performs a bitwise AND between the
6319 read result and the value specified by AndData, and writes the result to the
6320 64-bit MSR specified by Index. The value written to the MSR is returned.
6321 Extra left bits in AndData are stripped. The caller must either guarantee
6322 that Index and the data written is valid, or the caller must set up exception
6323 handlers to catch the exceptions. This function is only available on IA-32
6326 If StartBit is greater than 63, then ASSERT().
6327 If EndBit is greater than 63, then ASSERT().
6328 If EndBit is less than StartBit, then ASSERT().
6329 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
6331 @param Index The 32-bit MSR index to write.
6332 @param StartBit The ordinal of the least significant bit in the bit field.
6334 @param EndBit The ordinal of the most significant bit in the bit field.
6336 @param AndData The value to AND with the read value from the bit field.
6338 @return The value written back to the MSR.
6343 AsmMsrBitFieldAnd64 (
6352 Reads a bit field in a 64-bit MSR, performs a bitwise AND followed by a
6353 bitwise OR, and writes the result back to the bit field in the
6356 Reads the 64-bit MSR specified by Index, performs a bitwise AND followed by
6357 a bitwise OR between the read result and the value specified by
6358 AndData, and writes the result to the 64-bit MSR specified by Index. The
6359 value written to the MSR is returned. Extra left bits in both AndData and
6360 OrData are stripped. The caller must either guarantee that Index and the data
6361 written is valid, or the caller must set up exception handlers to catch the
6362 exceptions. This function is only available on IA-32 and x64.
6364 If StartBit is greater than 63, then ASSERT().
6365 If EndBit is greater than 63, then ASSERT().
6366 If EndBit is less than StartBit, then ASSERT().
6367 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
6368 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
6370 @param Index The 32-bit MSR index to write.
6371 @param StartBit The ordinal of the least significant bit in the bit field.
6373 @param EndBit The ordinal of the most significant bit in the bit field.
6375 @param AndData The value to AND with the read value from the bit field.
6376 @param OrData The value to OR with the result of the AND operation.
6378 @return The value written back to the MSR.
6383 AsmMsrBitFieldAndThenOr64 (
6393 Reads the current value of the EFLAGS register.
6395 Reads and returns the current value of the EFLAGS register. This function is
6396 only available on IA-32 and x64. This returns a 32-bit value on IA-32 and a
6397 64-bit value on x64.
6399 @return EFLAGS on IA-32 or RFLAGS on x64.
6410 Reads the current value of the Control Register 0 (CR0).
6412 Reads and returns the current value of CR0. This function is only available
6413 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
6416 @return The value of the Control Register 0 (CR0).
6427 Reads the current value of the Control Register 2 (CR2).
6429 Reads and returns the current value of CR2. This function is only available
6430 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
6433 @return The value of the Control Register 2 (CR2).
6444 Reads the current value of the Control Register 3 (CR3).
6446 Reads and returns the current value of CR3. This function is only available
6447 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
6450 @return The value of the Control Register 3 (CR3).
6461 Reads the current value of the Control Register 4 (CR4).
6463 Reads and returns the current value of CR4. This function is only available
6464 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
6467 @return The value of the Control Register 4 (CR4).
6478 Writes a value to Control Register 0 (CR0).
6480 Writes and returns a new value to CR0. This function is only available on
6481 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
6483 @param Cr0 The value to write to CR0.
6485 @return The value written to CR0.
6496 Writes a value to Control Register 2 (CR2).
6498 Writes and returns a new value to CR2. This function is only available on
6499 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
6501 @param Cr2 The value to write to CR2.
6503 @return The value written to CR2.
6514 Writes a value to Control Register 3 (CR3).
6516 Writes and returns a new value to CR3. This function is only available on
6517 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
6519 @param Cr3 The value to write to CR3.
6521 @return The value written to CR3.
6532 Writes a value to Control Register 4 (CR4).
6534 Writes and returns a new value to CR4. This function is only available on
6535 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
6537 @param Cr4 The value to write to CR4.
6539 @return The value written to CR4.
6550 Reads the current value of Debug Register 0 (DR0).
6552 Reads and returns the current value of DR0. This function is only available
6553 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
6556 @return The value of Debug Register 0 (DR0).
6567 Reads the current value of Debug Register 1 (DR1).
6569 Reads and returns the current value of DR1. This function is only available
6570 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
6573 @return The value of Debug Register 1 (DR1).
6584 Reads the current value of Debug Register 2 (DR2).
6586 Reads and returns the current value of DR2. This function is only available
6587 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
6590 @return The value of Debug Register 2 (DR2).
6601 Reads the current value of Debug Register 3 (DR3).
6603 Reads and returns the current value of DR3. This function is only available
6604 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
6607 @return The value of Debug Register 3 (DR3).
6618 Reads the current value of Debug Register 4 (DR4).
6620 Reads and returns the current value of DR4. This function is only available
6621 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
6624 @return The value of Debug Register 4 (DR4).
6635 Reads the current value of Debug Register 5 (DR5).
6637 Reads and returns the current value of DR5. This function is only available
6638 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
6641 @return The value of Debug Register 5 (DR5).
6652 Reads the current value of Debug Register 6 (DR6).
6654 Reads and returns the current value of DR6. This function is only available
6655 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
6658 @return The value of Debug Register 6 (DR6).
6669 Reads the current value of Debug Register 7 (DR7).
6671 Reads and returns the current value of DR7. This function is only available
6672 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
6675 @return The value of Debug Register 7 (DR7).
6686 Writes a value to Debug Register 0 (DR0).
6688 Writes and returns a new value to DR0. This function is only available on
6689 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
6691 @param Dr0 The value to write to Dr0.
6693 @return The value written to Debug Register 0 (DR0).
6704 Writes a value to Debug Register 1 (DR1).
6706 Writes and returns a new value to DR1. This function is only available on
6707 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
6709 @param Dr1 The value to write to Dr1.
6711 @return The value written to Debug Register 1 (DR1).
6722 Writes a value to Debug Register 2 (DR2).
6724 Writes and returns a new value to DR2. This function is only available on
6725 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
6727 @param Dr2 The value to write to Dr2.
6729 @return The value written to Debug Register 2 (DR2).
6740 Writes a value to Debug Register 3 (DR3).
6742 Writes and returns a new value to DR3. This function is only available on
6743 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
6745 @param Dr3 The value to write to Dr3.
6747 @return The value written to Debug Register 3 (DR3).
6758 Writes a value to Debug Register 4 (DR4).
6760 Writes and returns a new value to DR4. This function is only available on
6761 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
6763 @param Dr4 The value to write to Dr4.
6765 @return The value written to Debug Register 4 (DR4).
6776 Writes a value to Debug Register 5 (DR5).
6778 Writes and returns a new value to DR5. This function is only available on
6779 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
6781 @param Dr5 The value to write to Dr5.
6783 @return The value written to Debug Register 5 (DR5).
6794 Writes a value to Debug Register 6 (DR6).
6796 Writes and returns a new value to DR6. This function is only available on
6797 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
6799 @param Dr6 The value to write to Dr6.
6801 @return The value written to Debug Register 6 (DR6).
6812 Writes a value to Debug Register 7 (DR7).
6814 Writes and returns a new value to DR7. This function is only available on
6815 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
6817 @param Dr7 The value to write to Dr7.
6819 @return The value written to Debug Register 7 (DR7).
6830 Reads the current value of Code Segment Register (CS).
6832 Reads and returns the current value of CS. This function is only available on
6835 @return The current value of CS.
6846 Reads the current value of Data Segment Register (DS).
6848 Reads and returns the current value of DS. This function is only available on
6851 @return The current value of DS.
6862 Reads the current value of Extra Segment Register (ES).
6864 Reads and returns the current value of ES. This function is only available on
6867 @return The current value of ES.
6878 Reads the current value of FS Data Segment Register (FS).
6880 Reads and returns the current value of FS. This function is only available on
6883 @return The current value of FS.
6894 Reads the current value of GS Data Segment Register (GS).
6896 Reads and returns the current value of GS. This function is only available on
6899 @return The current value of GS.
6910 Reads the current value of Stack Segment Register (SS).
6912 Reads and returns the current value of SS. This function is only available on
6915 @return The current value of SS.
6926 Reads the current value of Task Register (TR).
6928 Reads and returns the current value of TR. This function is only available on
6931 @return The current value of TR.
6942 Reads the current Global Descriptor Table Register(GDTR) descriptor.
6944 Reads and returns the current GDTR descriptor and returns it in Gdtr. This
6945 function is only available on IA-32 and x64.
6947 If Gdtr is NULL, then ASSERT().
6949 @param Gdtr The pointer to a GDTR descriptor.
6955 OUT IA32_DESCRIPTOR
*Gdtr
6960 Writes the current Global Descriptor Table Register (GDTR) descriptor.
6962 Writes and the current GDTR descriptor specified by Gdtr. This function is
6963 only available on IA-32 and x64.
6965 If Gdtr is NULL, then ASSERT().
6967 @param Gdtr The pointer to a GDTR descriptor.
6973 IN CONST IA32_DESCRIPTOR
*Gdtr
6978 Reads the current Interrupt Descriptor Table Register(IDTR) descriptor.
6980 Reads and returns the current IDTR descriptor and returns it in Idtr. This
6981 function is only available on IA-32 and x64.
6983 If Idtr is NULL, then ASSERT().
6985 @param Idtr The pointer to a IDTR descriptor.
6991 OUT IA32_DESCRIPTOR
*Idtr
6996 Writes the current Interrupt Descriptor Table Register(IDTR) descriptor.
6998 Writes the current IDTR descriptor and returns it in Idtr. This function is
6999 only available on IA-32 and x64.
7001 If Idtr is NULL, then ASSERT().
7003 @param Idtr The pointer to a IDTR descriptor.
7009 IN CONST IA32_DESCRIPTOR
*Idtr
7014 Reads the current Local Descriptor Table Register(LDTR) selector.
7016 Reads and returns the current 16-bit LDTR descriptor value. This function is
7017 only available on IA-32 and x64.
7019 @return The current selector of LDT.
7030 Writes the current Local Descriptor Table Register (LDTR) selector.
7032 Writes and the current LDTR descriptor specified by Ldtr. This function is
7033 only available on IA-32 and x64.
7035 @param Ldtr 16-bit LDTR selector value.
7046 Save the current floating point/SSE/SSE2 context to a buffer.
7048 Saves the current floating point/SSE/SSE2 state to the buffer specified by
7049 Buffer. Buffer must be aligned on a 16-byte boundary. This function is only
7050 available on IA-32 and x64.
7052 If Buffer is NULL, then ASSERT().
7053 If Buffer is not aligned on a 16-byte boundary, then ASSERT().
7055 @param Buffer The pointer to a buffer to save the floating point/SSE/SSE2 context.
7061 OUT IA32_FX_BUFFER
*Buffer
7066 Restores the current floating point/SSE/SSE2 context from a buffer.
7068 Restores the current floating point/SSE/SSE2 state from the buffer specified
7069 by Buffer. Buffer must be aligned on a 16-byte boundary. This function is
7070 only available on IA-32 and x64.
7072 If Buffer is NULL, then ASSERT().
7073 If Buffer is not aligned on a 16-byte boundary, then ASSERT().
7074 If Buffer was not saved with AsmFxSave(), then ASSERT().
7076 @param Buffer The pointer to a buffer to save the floating point/SSE/SSE2 context.
7082 IN CONST IA32_FX_BUFFER
*Buffer
7087 Reads the current value of 64-bit MMX Register #0 (MM0).
7089 Reads and returns the current value of MM0. This function is only available
7092 @return The current value of MM0.
7103 Reads the current value of 64-bit MMX Register #1 (MM1).
7105 Reads and returns the current value of MM1. This function is only available
7108 @return The current value of MM1.
7119 Reads the current value of 64-bit MMX Register #2 (MM2).
7121 Reads and returns the current value of MM2. This function is only available
7124 @return The current value of MM2.
7135 Reads the current value of 64-bit MMX Register #3 (MM3).
7137 Reads and returns the current value of MM3. This function is only available
7140 @return The current value of MM3.
7151 Reads the current value of 64-bit MMX Register #4 (MM4).
7153 Reads and returns the current value of MM4. This function is only available
7156 @return The current value of MM4.
7167 Reads the current value of 64-bit MMX Register #5 (MM5).
7169 Reads and returns the current value of MM5. This function is only available
7172 @return The current value of MM5.
7183 Reads the current value of 64-bit MMX Register #6 (MM6).
7185 Reads and returns the current value of MM6. This function is only available
7188 @return The current value of MM6.
7199 Reads the current value of 64-bit MMX Register #7 (MM7).
7201 Reads and returns the current value of MM7. This function is only available
7204 @return The current value of MM7.
7215 Writes the current value of 64-bit MMX Register #0 (MM0).
7217 Writes the current value of MM0. This function is only available on IA32 and
7220 @param Value The 64-bit value to write to MM0.
7231 Writes the current value of 64-bit MMX Register #1 (MM1).
7233 Writes the current value of MM1. This function is only available on IA32 and
7236 @param Value The 64-bit value to write to MM1.
7247 Writes the current value of 64-bit MMX Register #2 (MM2).
7249 Writes the current value of MM2. This function is only available on IA32 and
7252 @param Value The 64-bit value to write to MM2.
7263 Writes the current value of 64-bit MMX Register #3 (MM3).
7265 Writes the current value of MM3. This function is only available on IA32 and
7268 @param Value The 64-bit value to write to MM3.
7279 Writes the current value of 64-bit MMX Register #4 (MM4).
7281 Writes the current value of MM4. This function is only available on IA32 and
7284 @param Value The 64-bit value to write to MM4.
7295 Writes the current value of 64-bit MMX Register #5 (MM5).
7297 Writes the current value of MM5. This function is only available on IA32 and
7300 @param Value The 64-bit value to write to MM5.
7311 Writes the current value of 64-bit MMX Register #6 (MM6).
7313 Writes the current value of MM6. This function is only available on IA32 and
7316 @param Value The 64-bit value to write to MM6.
7327 Writes the current value of 64-bit MMX Register #7 (MM7).
7329 Writes the current value of MM7. This function is only available on IA32 and
7332 @param Value The 64-bit value to write to MM7.
7343 Reads the current value of Time Stamp Counter (TSC).
7345 Reads and returns the current value of TSC. This function is only available
7348 @return The current value of TSC
7359 Reads the current value of a Performance Counter (PMC).
7361 Reads and returns the current value of performance counter specified by
7362 Index. This function is only available on IA-32 and x64.
7364 @param Index The 32-bit Performance Counter index to read.
7366 @return The value of the PMC specified by Index.
7377 Sets up a monitor buffer that is used by AsmMwait().
7379 Executes a MONITOR instruction with the register state specified by Eax, Ecx
7380 and Edx. Returns Eax. This function is only available on IA-32 and x64.
7382 @param Eax The value to load into EAX or RAX before executing the MONITOR
7384 @param Ecx The value to load into ECX or RCX before executing the MONITOR
7386 @param Edx The value to load into EDX or RDX before executing the MONITOR
7402 Executes an MWAIT instruction.
7404 Executes an MWAIT instruction with the register state specified by Eax and
7405 Ecx. Returns Eax. This function is only available on IA-32 and x64.
7407 @param Eax The value to load into EAX or RAX before executing the MONITOR
7409 @param Ecx The value to load into ECX or RCX before executing the MONITOR
7424 Executes a WBINVD instruction.
7426 Executes a WBINVD instruction. This function is only available on IA-32 and
7438 Executes a INVD instruction.
7440 Executes a INVD instruction. This function is only available on IA-32 and
7452 Flushes a cache line from all the instruction and data caches within the
7453 coherency domain of the CPU.
7455 Flushed the cache line specified by LinearAddress, and returns LinearAddress.
7456 This function is only available on IA-32 and x64.
7458 @param LinearAddress The address of the cache line to flush. If the CPU is
7459 in a physical addressing mode, then LinearAddress is a
7460 physical address. If the CPU is in a virtual
7461 addressing mode, then LinearAddress is a virtual
7464 @return LinearAddress.
7469 IN VOID
*LinearAddress
7474 Enables the 32-bit paging mode on the CPU.
7476 Enables the 32-bit paging mode on the CPU. CR0, CR3, CR4, and the page tables
7477 must be properly initialized prior to calling this service. This function
7478 assumes the current execution mode is 32-bit protected mode. This function is
7479 only available on IA-32. After the 32-bit paging mode is enabled, control is
7480 transferred to the function specified by EntryPoint using the new stack
7481 specified by NewStack and passing in the parameters specified by Context1 and
7482 Context2. Context1 and Context2 are optional and may be NULL. The function
7483 EntryPoint must never return.
7485 If the current execution mode is not 32-bit protected mode, then ASSERT().
7486 If EntryPoint is NULL, then ASSERT().
7487 If NewStack is NULL, then ASSERT().
7489 There are a number of constraints that must be followed before calling this
7491 1) Interrupts must be disabled.
7492 2) The caller must be in 32-bit protected mode with flat descriptors. This
7493 means all descriptors must have a base of 0 and a limit of 4GB.
7494 3) CR0 and CR4 must be compatible with 32-bit protected mode with flat
7496 4) CR3 must point to valid page tables that will be used once the transition
7497 is complete, and those page tables must guarantee that the pages for this
7498 function and the stack are identity mapped.
7500 @param EntryPoint A pointer to function to call with the new stack after
7502 @param Context1 A pointer to the context to pass into the EntryPoint
7503 function as the first parameter after paging is enabled.
7504 @param Context2 A pointer to the context to pass into the EntryPoint
7505 function as the second parameter after paging is enabled.
7506 @param NewStack A pointer to the new stack to use for the EntryPoint
7507 function after paging is enabled.
7513 IN SWITCH_STACK_ENTRY_POINT EntryPoint
,
7514 IN VOID
*Context1
, OPTIONAL
7515 IN VOID
*Context2
, OPTIONAL
7521 Disables the 32-bit paging mode on the CPU.
7523 Disables the 32-bit paging mode on the CPU and returns to 32-bit protected
7524 mode. This function assumes the current execution mode is 32-paged protected
7525 mode. This function is only available on IA-32. After the 32-bit paging mode
7526 is disabled, control is transferred to the function specified by EntryPoint
7527 using the new stack specified by NewStack and passing in the parameters
7528 specified by Context1 and Context2. Context1 and Context2 are optional and
7529 may be NULL. The function EntryPoint must never return.
7531 If the current execution mode is not 32-bit paged mode, then ASSERT().
7532 If EntryPoint is NULL, then ASSERT().
7533 If NewStack is NULL, then ASSERT().
7535 There are a number of constraints that must be followed before calling this
7537 1) Interrupts must be disabled.
7538 2) The caller must be in 32-bit paged mode.
7539 3) CR0, CR3, and CR4 must be compatible with 32-bit paged mode.
7540 4) CR3 must point to valid page tables that guarantee that the pages for
7541 this function and the stack are identity mapped.
7543 @param EntryPoint A pointer to function to call with the new stack after
7545 @param Context1 A pointer to the context to pass into the EntryPoint
7546 function as the first parameter after paging is disabled.
7547 @param Context2 A pointer to the context to pass into the EntryPoint
7548 function as the second parameter after paging is
7550 @param NewStack A pointer to the new stack to use for the EntryPoint
7551 function after paging is disabled.
7556 AsmDisablePaging32 (
7557 IN SWITCH_STACK_ENTRY_POINT EntryPoint
,
7558 IN VOID
*Context1
, OPTIONAL
7559 IN VOID
*Context2
, OPTIONAL
7565 Enables the 64-bit paging mode on the CPU.
7567 Enables the 64-bit paging mode on the CPU. CR0, CR3, CR4, and the page tables
7568 must be properly initialized prior to calling this service. This function
7569 assumes the current execution mode is 32-bit protected mode with flat
7570 descriptors. This function is only available on IA-32. After the 64-bit
7571 paging mode is enabled, control is transferred to the function specified by
7572 EntryPoint using the new stack specified by NewStack and passing in the
7573 parameters specified by Context1 and Context2. Context1 and Context2 are
7574 optional and may be 0. The function EntryPoint must never return.
7576 If the current execution mode is not 32-bit protected mode with flat
7577 descriptors, then ASSERT().
7578 If EntryPoint is 0, then ASSERT().
7579 If NewStack is 0, then ASSERT().
7581 @param Cs The 16-bit selector to load in the CS before EntryPoint
7582 is called. The descriptor in the GDT that this selector
7583 references must be setup for long mode.
7584 @param EntryPoint The 64-bit virtual address of the function to call with
7585 the new stack after paging is enabled.
7586 @param Context1 The 64-bit virtual address of the context to pass into
7587 the EntryPoint function as the first parameter after
7589 @param Context2 The 64-bit virtual address of the context to pass into
7590 the EntryPoint function as the second parameter after
7592 @param NewStack The 64-bit virtual address of the new stack to use for
7593 the EntryPoint function after paging is enabled.
7600 IN UINT64 EntryPoint
,
7601 IN UINT64 Context1
, OPTIONAL
7602 IN UINT64 Context2
, OPTIONAL
7608 Disables the 64-bit paging mode on the CPU.
7610 Disables the 64-bit paging mode on the CPU and returns to 32-bit protected
7611 mode. This function assumes the current execution mode is 64-paging mode.
7612 This function is only available on x64. After the 64-bit paging mode is
7613 disabled, control is transferred to the function specified by EntryPoint
7614 using the new stack specified by NewStack and passing in the parameters
7615 specified by Context1 and Context2. Context1 and Context2 are optional and
7616 may be 0. The function EntryPoint must never return.
7618 If the current execution mode is not 64-bit paged mode, then ASSERT().
7619 If EntryPoint is 0, then ASSERT().
7620 If NewStack is 0, then ASSERT().
7622 @param Cs The 16-bit selector to load in the CS before EntryPoint
7623 is called. The descriptor in the GDT that this selector
7624 references must be setup for 32-bit protected mode.
7625 @param EntryPoint The 64-bit virtual address of the function to call with
7626 the new stack after paging is disabled.
7627 @param Context1 The 64-bit virtual address of the context to pass into
7628 the EntryPoint function as the first parameter after
7630 @param Context2 The 64-bit virtual address of the context to pass into
7631 the EntryPoint function as the second parameter after
7633 @param NewStack The 64-bit virtual address of the new stack to use for
7634 the EntryPoint function after paging is disabled.
7639 AsmDisablePaging64 (
7641 IN UINT32 EntryPoint
,
7642 IN UINT32 Context1
, OPTIONAL
7643 IN UINT32 Context2
, OPTIONAL
7649 // 16-bit thunking services
7653 Retrieves the properties for 16-bit thunk functions.
7655 Computes the size of the buffer and stack below 1MB required to use the
7656 AsmPrepareThunk16(), AsmThunk16() and AsmPrepareAndThunk16() functions. This
7657 buffer size is returned in RealModeBufferSize, and the stack size is returned
7658 in ExtraStackSize. If parameters are passed to the 16-bit real mode code,
7659 then the actual minimum stack size is ExtraStackSize plus the maximum number
7660 of bytes that need to be passed to the 16-bit real mode code.
7662 If RealModeBufferSize is NULL, then ASSERT().
7663 If ExtraStackSize is NULL, then ASSERT().
7665 @param RealModeBufferSize A pointer to the size of the buffer below 1MB
7666 required to use the 16-bit thunk functions.
7667 @param ExtraStackSize A pointer to the extra size of stack below 1MB
7668 that the 16-bit thunk functions require for
7669 temporary storage in the transition to and from
7675 AsmGetThunk16Properties (
7676 OUT UINT32
*RealModeBufferSize
,
7677 OUT UINT32
*ExtraStackSize
7682 Prepares all structures a code required to use AsmThunk16().
7684 Prepares all structures and code required to use AsmThunk16().
7686 This interface is limited to be used in either physical mode or virtual modes with paging enabled where the
7687 virtual to physical mappings for ThunkContext.RealModeBuffer is mapped 1:1.
7689 If ThunkContext is NULL, then ASSERT().
7691 @param ThunkContext A pointer to the context structure that describes the
7692 16-bit real mode code to call.
7698 IN OUT THUNK_CONTEXT
*ThunkContext
7703 Transfers control to a 16-bit real mode entry point and returns the results.
7705 Transfers control to a 16-bit real mode entry point and returns the results.
7706 AsmPrepareThunk16() must be called with ThunkContext before this function is used.
7707 This function must be called with interrupts disabled.
7709 The register state from the RealModeState field of ThunkContext is restored just prior
7710 to calling the 16-bit real mode entry point. This includes the EFLAGS field of RealModeState,
7711 which is used to set the interrupt state when a 16-bit real mode entry point is called.
7712 Control is transferred to the 16-bit real mode entry point specified by the CS and Eip fields of RealModeState.
7713 The stack is initialized to the SS and ESP fields of RealModeState. Any parameters passed to
7714 the 16-bit real mode code must be populated by the caller at SS:ESP prior to calling this function.
7715 The 16-bit real mode entry point is invoked with a 16-bit CALL FAR instruction,
7716 so when accessing stack contents, the 16-bit real mode code must account for the 16-bit segment
7717 and 16-bit offset of the return address that were pushed onto the stack. The 16-bit real mode entry
7718 point must exit with a RETF instruction. The register state is captured into RealModeState immediately
7719 after the RETF instruction is executed.
7721 If EFLAGS specifies interrupts enabled, or any of the 16-bit real mode code enables interrupts,
7722 or any of the 16-bit real mode code makes a SW interrupt, then the caller is responsible for making sure
7723 the IDT at address 0 is initialized to handle any HW or SW interrupts that may occur while in 16-bit real mode.
7725 If EFLAGS specifies interrupts enabled, or any of the 16-bit real mode code enables interrupts,
7726 then the caller is responsible for making sure the 8259 PIC is in a state compatible with 16-bit real mode.
7727 This includes the base vectors, the interrupt masks, and the edge/level trigger mode.
7729 If THUNK_ATTRIBUTE_BIG_REAL_MODE is set in the ThunkAttributes field of ThunkContext, then the user code
7730 is invoked in big real mode. Otherwise, the user code is invoked in 16-bit real mode with 64KB segment limits.
7732 If neither THUNK_ATTRIBUTE_DISABLE_A20_MASK_INT_15 nor THUNK_ATTRIBUTE_DISABLE_A20_MASK_KBD_CTRL are set in
7733 ThunkAttributes, then it is assumed that the user code did not enable the A20 mask, and no attempt is made to
7734 disable the A20 mask.
7736 If THUNK_ATTRIBUTE_DISABLE_A20_MASK_INT_15 is set and THUNK_ATTRIBUTE_DISABLE_A20_MASK_KBD_CTRL is clear in
7737 ThunkAttributes, then attempt to use the INT 15 service to disable the A20 mask. If this INT 15 call fails,
7738 then attempt to disable the A20 mask by directly accessing the 8042 keyboard controller I/O ports.
7740 If THUNK_ATTRIBUTE_DISABLE_A20_MASK_INT_15 is clear and THUNK_ATTRIBUTE_DISABLE_A20_MASK_KBD_CTRL is set in
7741 ThunkAttributes, then attempt to disable the A20 mask by directly accessing the 8042 keyboard controller I/O ports.
7743 If ThunkContext is NULL, then ASSERT().
7744 If AsmPrepareThunk16() was not previously called with ThunkContext, then ASSERT().
7745 If both THUNK_ATTRIBUTE_DISABLE_A20_MASK_INT_15 and THUNK_ATTRIBUTE_DISABLE_A20_MASK_KBD_CTRL are set in
7746 ThunkAttributes, then ASSERT().
7748 This interface is limited to be used in either physical mode or virtual modes with paging enabled where the
7749 virtual to physical mappings for ThunkContext.RealModeBuffer are mapped 1:1.
7751 @param ThunkContext A pointer to the context structure that describes the
7752 16-bit real mode code to call.
7758 IN OUT THUNK_CONTEXT
*ThunkContext
7763 Prepares all structures and code for a 16-bit real mode thunk, transfers
7764 control to a 16-bit real mode entry point, and returns the results.
7766 Prepares all structures and code for a 16-bit real mode thunk, transfers
7767 control to a 16-bit real mode entry point, and returns the results. If the
7768 caller only need to perform a single 16-bit real mode thunk, then this
7769 service should be used. If the caller intends to make more than one 16-bit
7770 real mode thunk, then it is more efficient if AsmPrepareThunk16() is called
7771 once and AsmThunk16() can be called for each 16-bit real mode thunk.
7773 This interface is limited to be used in either physical mode or virtual modes with paging enabled where the
7774 virtual to physical mappings for ThunkContext.RealModeBuffer is mapped 1:1.
7776 See AsmPrepareThunk16() and AsmThunk16() for the detailed description and ASSERT() conditions.
7778 @param ThunkContext A pointer to the context structure that describes the
7779 16-bit real mode code to call.
7784 AsmPrepareAndThunk16 (
7785 IN OUT THUNK_CONTEXT
*ThunkContext
7789 Generates a 16-bit random number through RDRAND instruction.
7791 if Rand is NULL, then ASSERT().
7793 @param[out] Rand Buffer pointer to store the random result.
7795 @retval TRUE RDRAND call was successful.
7796 @retval FALSE Failed attempts to call RDRAND.
7806 Generates a 32-bit random number through RDRAND instruction.
7808 if Rand is NULL, then ASSERT().
7810 @param[out] Rand Buffer pointer to store the random result.
7812 @retval TRUE RDRAND call was successful.
7813 @retval FALSE Failed attempts to call RDRAND.
7823 Generates a 64-bit random number through RDRAND instruction.
7825 if Rand is NULL, then ASSERT().
7827 @param[out] Rand Buffer pointer to store the random result.
7829 @retval TRUE RDRAND call was successful.
7830 @retval FALSE Failed attempts to call RDRAND.