2 Provides string functions, linked list functions, math functions, synchronization
3 functions, file path functions, and CPU architecture-specific functions.
5 Copyright (c) 2006 - 2015, Intel Corporation. All rights reserved.<BR>
6 Portions copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>
7 This program and the accompanying materials
8 are licensed and made available under the terms and conditions of the BSD License
9 which accompanies this distribution. The full text of the license may be found at
10 http://opensource.org/licenses/bsd-license.php.
12 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
13 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
21 // Definitions for architecture-specific types
23 #if defined (MDE_CPU_IA32)
25 /// The IA-32 architecture context buffer used by SetJump() and LongJump().
34 } BASE_LIBRARY_JUMP_BUFFER
;
36 #define BASE_LIBRARY_JUMP_BUFFER_ALIGNMENT 4
38 #endif // defined (MDE_CPU_IA32)
40 #if defined (MDE_CPU_IPF)
43 /// The Itanium architecture context buffer used by SetJump() and LongJump().
78 UINT64 AfterSpillUNAT
;
84 } BASE_LIBRARY_JUMP_BUFFER
;
86 #define BASE_LIBRARY_JUMP_BUFFER_ALIGNMENT 0x10
88 #endif // defined (MDE_CPU_IPF)
90 #if defined (MDE_CPU_X64)
92 /// The x64 architecture context buffer used by SetJump() and LongJump().
106 UINT8 XmmBuffer
[160]; ///< XMM6-XMM15.
107 } BASE_LIBRARY_JUMP_BUFFER
;
109 #define BASE_LIBRARY_JUMP_BUFFER_ALIGNMENT 8
111 #endif // defined (MDE_CPU_X64)
113 #if defined (MDE_CPU_EBC)
115 /// The EBC context buffer used by SetJump() and LongJump().
123 } BASE_LIBRARY_JUMP_BUFFER
;
125 #define BASE_LIBRARY_JUMP_BUFFER_ALIGNMENT 8
127 #endif // defined (MDE_CPU_EBC)
129 #if defined (MDE_CPU_ARM)
132 UINT32 R3
; ///< A copy of R13.
143 } BASE_LIBRARY_JUMP_BUFFER
;
145 #define BASE_LIBRARY_JUMP_BUFFER_ALIGNMENT 4
147 #endif // defined (MDE_CPU_ARM)
149 #if defined (MDE_CPU_AARCH64)
175 } BASE_LIBRARY_JUMP_BUFFER
;
177 #define BASE_LIBRARY_JUMP_BUFFER_ALIGNMENT 8
179 #endif // defined (MDE_CPU_AARCH64)
188 Returns the length of a Null-terminated Unicode string.
190 This function is similar as strlen_s defined in C11.
192 If String is not aligned on a 16-bit boundary, then ASSERT().
194 @param String A pointer to a Null-terminated Unicode string.
195 @param MaxSize The maximum number of Destination Unicode
196 char, including terminating null char.
198 @retval 0 If String is NULL.
199 @retval MaxSize If there is no null character in the first MaxSize characters of String.
200 @return The number of characters that percede the terminating null character.
206 IN CONST CHAR16
*String
,
211 Copies the string pointed to by Source (including the terminating null char)
212 to the array pointed to by Destination.
214 This function is similar as strcpy_s defined in C11.
216 If Destination is not aligned on a 16-bit boundary, then ASSERT().
217 If Source is not aligned on a 16-bit boundary, then ASSERT().
218 If an error would be returned, then the function will also ASSERT().
220 If an error is returned, then the Destination is unmodified.
222 @param Destination A pointer to a Null-terminated Unicode string.
223 @param DestMax The maximum number of Destination Unicode
224 char, including terminating null char.
225 @param Source A pointer to a Null-terminated Unicode string.
227 @retval RETURN_SUCCESS String is copied.
228 @retval RETURN_BUFFER_TOO_SMALL If DestMax is NOT greater than StrLen(Source).
229 @retval RETURN_INVALID_PARAMETER If Destination is NULL.
231 If PcdMaximumUnicodeStringLength is not zero,
232 and DestMax is greater than
233 PcdMaximumUnicodeStringLength.
235 @retval RETURN_ACCESS_DENIED If Source and Destination overlap.
240 OUT CHAR16
*Destination
,
242 IN CONST CHAR16
*Source
246 Copies not more than Length successive char from the string pointed to by
247 Source to the array pointed to by Destination. If no null char is copied from
248 Source, then Destination[Length] is always set to null.
250 This function is similar as strncpy_s defined in C11.
252 If Length > 0 and Destination is not aligned on a 16-bit boundary, then ASSERT().
253 If Length > 0 and Source is not aligned on a 16-bit boundary, then ASSERT().
254 If an error would be returned, then the function will also ASSERT().
256 If an error is returned, then the Destination is unmodified.
258 @param Destination A pointer to a Null-terminated Unicode string.
259 @param DestMax The maximum number of Destination Unicode
260 char, including terminating null char.
261 @param Source A pointer to a Null-terminated Unicode string.
262 @param Length The maximum number of Unicode characters to copy.
264 @retval RETURN_SUCCESS String is copied.
265 @retval RETURN_BUFFER_TOO_SMALL If DestMax is NOT greater than
266 MIN(StrLen(Source), Length).
267 @retval RETURN_INVALID_PARAMETER If Destination is NULL.
269 If PcdMaximumUnicodeStringLength is not zero,
270 and DestMax is greater than
271 PcdMaximumUnicodeStringLength.
273 @retval RETURN_ACCESS_DENIED If Source and Destination overlap.
278 OUT CHAR16
*Destination
,
280 IN CONST CHAR16
*Source
,
285 Appends a copy of the string pointed to by Source (including the terminating
286 null char) to the end of the string pointed to by Destination.
288 This function is similar as strcat_s defined in C11.
290 If Destination is not aligned on a 16-bit boundary, then ASSERT().
291 If Source is not aligned on a 16-bit boundary, then ASSERT().
292 If an error would be returned, then the function will also ASSERT().
294 If an error is returned, then the Destination is unmodified.
296 @param Destination A pointer to a Null-terminated Unicode string.
297 @param DestMax The maximum number of Destination Unicode
298 char, including terminating null char.
299 @param Source A pointer to a Null-terminated Unicode string.
301 @retval RETURN_SUCCESS String is appended.
302 @retval RETURN_BAD_BUFFER_SIZE If DestMax is NOT greater than
304 @retval RETURN_BUFFER_TOO_SMALL If (DestMax - StrLen(Destination)) is NOT
305 greater than StrLen(Source).
306 @retval RETURN_INVALID_PARAMETER If Destination is NULL.
308 If PcdMaximumUnicodeStringLength is not zero,
309 and DestMax is greater than
310 PcdMaximumUnicodeStringLength.
312 @retval RETURN_ACCESS_DENIED If Source and Destination overlap.
317 IN OUT CHAR16
*Destination
,
319 IN CONST CHAR16
*Source
323 Appends not more than Length successive char from the string pointed to by
324 Source to the end of the string pointed to by Destination. If no null char is
325 copied from Source, then Destination[StrLen(Destination) + Length] is always
328 This function is similar as strncat_s defined in C11.
330 If Destination is not aligned on a 16-bit boundary, then ASSERT().
331 If Source is not aligned on a 16-bit boundary, then ASSERT().
332 If an error would be returned, then the function will also ASSERT().
334 If an error is returned, then the Destination is unmodified.
336 @param Destination A pointer to a Null-terminated Unicode string.
337 @param DestMax The maximum number of Destination Unicode
338 char, including terminating null char.
339 @param Source A pointer to a Null-terminated Unicode string.
340 @param Length The maximum number of Unicode characters to copy.
342 @retval RETURN_SUCCESS String is appended.
343 @retval RETURN_BAD_BUFFER_SIZE If DestMax is NOT greater than
345 @retval RETURN_BUFFER_TOO_SMALL If (DestMax - StrLen(Destination)) is NOT
346 greater than MIN(StrLen(Source), Length).
347 @retval RETURN_INVALID_PARAMETER If Destination is NULL.
349 If PcdMaximumUnicodeStringLength is not zero,
350 and DestMax is greater than
351 PcdMaximumUnicodeStringLength.
353 @retval RETURN_ACCESS_DENIED If Source and Destination overlap.
358 IN OUT CHAR16
*Destination
,
360 IN CONST CHAR16
*Source
,
365 Returns the length of a Null-terminated Ascii string.
367 This function is similar as strlen_s defined in C11.
369 @param String A pointer to a Null-terminated Ascii string.
370 @param MaxSize The maximum number of Destination Ascii
371 char, including terminating null char.
373 @retval 0 If String is NULL.
374 @retval MaxSize If there is no null character in the first MaxSize characters of String.
375 @return The number of characters that percede the terminating null character.
381 IN CONST CHAR8
*String
,
386 Copies the string pointed to by Source (including the terminating null char)
387 to the array pointed to by Destination.
389 This function is similar as strcpy_s defined in C11.
391 If an error would be returned, then the function will also ASSERT().
393 If an error is returned, then the Destination is unmodified.
395 @param Destination A pointer to a Null-terminated Ascii string.
396 @param DestMax The maximum number of Destination Ascii
397 char, including terminating null char.
398 @param Source A pointer to a Null-terminated Ascii string.
400 @retval RETURN_SUCCESS String is copied.
401 @retval RETURN_BUFFER_TOO_SMALL If DestMax is NOT greater than StrLen(Source).
402 @retval RETURN_INVALID_PARAMETER If Destination is NULL.
404 If PcdMaximumAsciiStringLength is not zero,
405 and DestMax is greater than
406 PcdMaximumAsciiStringLength.
408 @retval RETURN_ACCESS_DENIED If Source and Destination overlap.
413 OUT CHAR8
*Destination
,
415 IN CONST CHAR8
*Source
419 Copies not more than Length successive char from the string pointed to by
420 Source to the array pointed to by Destination. If no null char is copied from
421 Source, then Destination[Length] is always set to null.
423 This function is similar as strncpy_s defined in C11.
425 If an error would be returned, then the function will also ASSERT().
427 If an error is returned, then the Destination is unmodified.
429 @param Destination A pointer to a Null-terminated Ascii string.
430 @param DestMax The maximum number of Destination Ascii
431 char, including terminating null char.
432 @param Source A pointer to a Null-terminated Ascii string.
433 @param Length The maximum number of Ascii characters to copy.
435 @retval RETURN_SUCCESS String is copied.
436 @retval RETURN_BUFFER_TOO_SMALL If DestMax is NOT greater than
437 MIN(StrLen(Source), Length).
438 @retval RETURN_INVALID_PARAMETER If Destination is NULL.
440 If PcdMaximumAsciiStringLength is not zero,
441 and DestMax is greater than
442 PcdMaximumAsciiStringLength.
444 @retval RETURN_ACCESS_DENIED If Source and Destination overlap.
449 OUT CHAR8
*Destination
,
451 IN CONST CHAR8
*Source
,
456 Appends a copy of the string pointed to by Source (including the terminating
457 null char) to the end of the string pointed to by Destination.
459 This function is similar as strcat_s defined in C11.
461 If an error would be returned, then the function will also ASSERT().
463 If an error is returned, then the Destination is unmodified.
465 @param Destination A pointer to a Null-terminated Ascii string.
466 @param DestMax The maximum number of Destination Ascii
467 char, including terminating null char.
468 @param Source A pointer to a Null-terminated Ascii string.
470 @retval RETURN_SUCCESS String is appended.
471 @retval RETURN_BAD_BUFFER_SIZE If DestMax is NOT greater than
473 @retval RETURN_BUFFER_TOO_SMALL If (DestMax - StrLen(Destination)) is NOT
474 greater than StrLen(Source).
475 @retval RETURN_INVALID_PARAMETER If Destination is NULL.
477 If PcdMaximumAsciiStringLength is not zero,
478 and DestMax is greater than
479 PcdMaximumAsciiStringLength.
481 @retval RETURN_ACCESS_DENIED If Source and Destination overlap.
486 IN OUT CHAR8
*Destination
,
488 IN CONST CHAR8
*Source
492 Appends not more than Length successive char from the string pointed to by
493 Source to the end of the string pointed to by Destination. If no null char is
494 copied from Source, then Destination[StrLen(Destination) + Length] is always
497 This function is similar as strncat_s defined in C11.
499 If an error would be returned, then the function will also ASSERT().
501 If an error is returned, then the Destination is unmodified.
503 @param Destination A pointer to a Null-terminated Ascii string.
504 @param DestMax The maximum number of Destination Ascii
505 char, including terminating null char.
506 @param Source A pointer to a Null-terminated Ascii string.
507 @param Length The maximum number of Ascii characters to copy.
509 @retval RETURN_SUCCESS String is appended.
510 @retval RETURN_BAD_BUFFER_SIZE If DestMax is NOT greater than
512 @retval RETURN_BUFFER_TOO_SMALL If (DestMax - StrLen(Destination)) is NOT
513 greater than MIN(StrLen(Source), Length).
514 @retval RETURN_INVALID_PARAMETER If Destination is NULL.
516 If PcdMaximumAsciiStringLength is not zero,
517 and DestMax is greater than
518 PcdMaximumAsciiStringLength.
520 @retval RETURN_ACCESS_DENIED If Source and Destination overlap.
525 IN OUT CHAR8
*Destination
,
527 IN CONST CHAR8
*Source
,
532 #ifndef DISABLE_NEW_DEPRECATED_INTERFACES
535 [ATTENTION] This function is deprecated for security reason.
537 Copies one Null-terminated Unicode string to another Null-terminated Unicode
538 string and returns the new Unicode string.
540 This function copies the contents of the Unicode string Source to the Unicode
541 string Destination, and returns Destination. If Source and Destination
542 overlap, then the results are undefined.
544 If Destination is NULL, then ASSERT().
545 If Destination is not aligned on a 16-bit boundary, then ASSERT().
546 If Source is NULL, then ASSERT().
547 If Source is not aligned on a 16-bit boundary, then ASSERT().
548 If Source and Destination overlap, then ASSERT().
549 If PcdMaximumUnicodeStringLength is not zero, and Source contains more than
550 PcdMaximumUnicodeStringLength Unicode characters not including the
551 Null-terminator, then ASSERT().
553 @param Destination The pointer to a Null-terminated Unicode string.
554 @param Source The pointer to a Null-terminated Unicode string.
562 OUT CHAR16
*Destination
,
563 IN CONST CHAR16
*Source
568 [ATTENTION] This function is deprecated for security reason.
570 Copies up to a specified length from one Null-terminated Unicode string to
571 another Null-terminated Unicode string and returns the new Unicode string.
573 This function copies the contents of the Unicode string Source to the Unicode
574 string Destination, and returns Destination. At most, Length Unicode
575 characters are copied from Source to Destination. If Length is 0, then
576 Destination is returned unmodified. If Length is greater that the number of
577 Unicode characters in Source, then Destination is padded with Null Unicode
578 characters. If Source and Destination overlap, then the results are
581 If Length > 0 and Destination is NULL, then ASSERT().
582 If Length > 0 and Destination is not aligned on a 16-bit boundary, then ASSERT().
583 If Length > 0 and Source is NULL, then ASSERT().
584 If Length > 0 and Source is not aligned on a 16-bit boundary, then ASSERT().
585 If Source and Destination overlap, then ASSERT().
586 If PcdMaximumUnicodeStringLength is not zero, and Length is greater than
587 PcdMaximumUnicodeStringLength, then ASSERT().
588 If PcdMaximumUnicodeStringLength is not zero, and Source contains more than
589 PcdMaximumUnicodeStringLength Unicode characters, not including the Null-terminator,
592 @param Destination The pointer to a Null-terminated Unicode string.
593 @param Source The pointer to a Null-terminated Unicode string.
594 @param Length The maximum number of Unicode characters to copy.
602 OUT CHAR16
*Destination
,
603 IN CONST CHAR16
*Source
,
609 Returns the length of a Null-terminated Unicode string.
611 This function returns the number of Unicode characters in the Null-terminated
612 Unicode string specified by String.
614 If String is NULL, then ASSERT().
615 If String is not aligned on a 16-bit boundary, then ASSERT().
616 If PcdMaximumUnicodeStringLength is not zero, and String contains more than
617 PcdMaximumUnicodeStringLength Unicode characters not including the
618 Null-terminator, then ASSERT().
620 @param String Pointer to a Null-terminated Unicode string.
622 @return The length of String.
628 IN CONST CHAR16
*String
633 Returns the size of a Null-terminated Unicode string in bytes, including the
636 This function returns the size, in bytes, of the Null-terminated Unicode string
639 If String is NULL, then ASSERT().
640 If String is not aligned on a 16-bit boundary, then ASSERT().
641 If PcdMaximumUnicodeStringLength is not zero, and String contains more than
642 PcdMaximumUnicodeStringLength Unicode characters not including the
643 Null-terminator, then ASSERT().
645 @param String The pointer to a Null-terminated Unicode string.
647 @return The size of String.
653 IN CONST CHAR16
*String
658 Compares two Null-terminated Unicode strings, and returns the difference
659 between the first mismatched Unicode characters.
661 This function compares the Null-terminated Unicode string FirstString to the
662 Null-terminated Unicode string SecondString. If FirstString is identical to
663 SecondString, then 0 is returned. Otherwise, the value returned is the first
664 mismatched Unicode character in SecondString subtracted from the first
665 mismatched Unicode character in FirstString.
667 If FirstString is NULL, then ASSERT().
668 If FirstString is not aligned on a 16-bit boundary, then ASSERT().
669 If SecondString is NULL, then ASSERT().
670 If SecondString is not aligned on a 16-bit boundary, then ASSERT().
671 If PcdMaximumUnicodeStringLength is not zero, and FirstString contains more
672 than PcdMaximumUnicodeStringLength Unicode characters not including the
673 Null-terminator, then ASSERT().
674 If PcdMaximumUnicodeStringLength is not zero, and SecondString contains more
675 than PcdMaximumUnicodeStringLength Unicode characters, not including the
676 Null-terminator, then ASSERT().
678 @param FirstString The pointer to a Null-terminated Unicode string.
679 @param SecondString The pointer to a Null-terminated Unicode string.
681 @retval 0 FirstString is identical to SecondString.
682 @return others FirstString is not identical to SecondString.
688 IN CONST CHAR16
*FirstString
,
689 IN CONST CHAR16
*SecondString
694 Compares up to a specified length the contents of two Null-terminated Unicode strings,
695 and returns the difference between the first mismatched Unicode characters.
697 This function compares the Null-terminated Unicode string FirstString to the
698 Null-terminated Unicode string SecondString. At most, Length Unicode
699 characters will be compared. If Length is 0, then 0 is returned. If
700 FirstString is identical to SecondString, then 0 is returned. Otherwise, the
701 value returned is the first mismatched Unicode character in SecondString
702 subtracted from the first mismatched Unicode character in FirstString.
704 If Length > 0 and FirstString is NULL, then ASSERT().
705 If Length > 0 and FirstString is not aligned on a 16-bit boundary, then ASSERT().
706 If Length > 0 and SecondString is NULL, then ASSERT().
707 If Length > 0 and SecondString is not aligned on a 16-bit boundary, then ASSERT().
708 If PcdMaximumUnicodeStringLength is not zero, and Length is greater than
709 PcdMaximumUnicodeStringLength, then ASSERT().
710 If PcdMaximumUnicodeStringLength is not zero, and FirstString contains more than
711 PcdMaximumUnicodeStringLength Unicode characters, not including the Null-terminator,
713 If PcdMaximumUnicodeStringLength is not zero, and SecondString contains more than
714 PcdMaximumUnicodeStringLength Unicode characters, not including the Null-terminator,
717 @param FirstString The pointer to a Null-terminated Unicode string.
718 @param SecondString The pointer to a Null-terminated Unicode string.
719 @param Length The maximum number of Unicode characters to compare.
721 @retval 0 FirstString is identical to SecondString.
722 @return others FirstString is not identical to SecondString.
728 IN CONST CHAR16
*FirstString
,
729 IN CONST CHAR16
*SecondString
,
734 #ifndef DISABLE_NEW_DEPRECATED_INTERFACES
737 [ATTENTION] This function is deprecated for security reason.
739 Concatenates one Null-terminated Unicode string to another Null-terminated
740 Unicode string, and returns the concatenated Unicode string.
742 This function concatenates two Null-terminated Unicode strings. The contents
743 of Null-terminated Unicode string Source are concatenated to the end of
744 Null-terminated Unicode string Destination. The Null-terminated concatenated
745 Unicode String is returned. If Source and Destination overlap, then the
746 results are undefined.
748 If Destination is NULL, then ASSERT().
749 If Destination is not aligned on a 16-bit boundary, then ASSERT().
750 If Source is NULL, then ASSERT().
751 If Source is not aligned on a 16-bit boundary, then ASSERT().
752 If Source and Destination overlap, then ASSERT().
753 If PcdMaximumUnicodeStringLength is not zero, and Destination contains more
754 than PcdMaximumUnicodeStringLength Unicode characters, not including the
755 Null-terminator, then ASSERT().
756 If PcdMaximumUnicodeStringLength is not zero, and Source contains more than
757 PcdMaximumUnicodeStringLength Unicode characters, not including the
758 Null-terminator, then ASSERT().
759 If PcdMaximumUnicodeStringLength is not zero, and concatenating Destination
760 and Source results in a Unicode string with more than
761 PcdMaximumUnicodeStringLength Unicode characters, not including the
762 Null-terminator, then ASSERT().
764 @param Destination The pointer to a Null-terminated Unicode string.
765 @param Source The pointer to a Null-terminated Unicode string.
773 IN OUT CHAR16
*Destination
,
774 IN CONST CHAR16
*Source
779 [ATTENTION] This function is deprecated for security reason.
781 Concatenates up to a specified length one Null-terminated Unicode to the end
782 of another Null-terminated Unicode string, and returns the concatenated
785 This function concatenates two Null-terminated Unicode strings. The contents
786 of Null-terminated Unicode string Source are concatenated to the end of
787 Null-terminated Unicode string Destination, and Destination is returned. At
788 most, Length Unicode characters are concatenated from Source to the end of
789 Destination, and Destination is always Null-terminated. If Length is 0, then
790 Destination is returned unmodified. If Source and Destination overlap, then
791 the results are undefined.
793 If Destination is NULL, then ASSERT().
794 If Length > 0 and Destination is not aligned on a 16-bit boundary, then ASSERT().
795 If Length > 0 and Source is NULL, then ASSERT().
796 If Length > 0 and Source is not aligned on a 16-bit boundary, then ASSERT().
797 If Source and Destination overlap, then ASSERT().
798 If PcdMaximumUnicodeStringLength is not zero, and Length is greater than
799 PcdMaximumUnicodeStringLength, then ASSERT().
800 If PcdMaximumUnicodeStringLength is not zero, and Destination contains more
801 than PcdMaximumUnicodeStringLength Unicode characters, not including the
802 Null-terminator, then ASSERT().
803 If PcdMaximumUnicodeStringLength is not zero, and Source contains more than
804 PcdMaximumUnicodeStringLength Unicode characters, not including the
805 Null-terminator, then ASSERT().
806 If PcdMaximumUnicodeStringLength is not zero, and concatenating Destination
807 and Source results in a Unicode string with more than PcdMaximumUnicodeStringLength
808 Unicode characters, not including the Null-terminator, then ASSERT().
810 @param Destination The pointer to a Null-terminated Unicode string.
811 @param Source The pointer to a Null-terminated Unicode string.
812 @param Length The maximum number of Unicode characters to concatenate from
821 IN OUT CHAR16
*Destination
,
822 IN CONST CHAR16
*Source
,
828 Returns the first occurrence of a Null-terminated Unicode sub-string
829 in a Null-terminated Unicode string.
831 This function scans the contents of the Null-terminated Unicode string
832 specified by String and returns the first occurrence of SearchString.
833 If SearchString is not found in String, then NULL is returned. If
834 the length of SearchString is zero, then String is returned.
836 If String is NULL, then ASSERT().
837 If String is not aligned on a 16-bit boundary, then ASSERT().
838 If SearchString is NULL, then ASSERT().
839 If SearchString is not aligned on a 16-bit boundary, then ASSERT().
841 If PcdMaximumUnicodeStringLength is not zero, and SearchString
842 or String contains more than PcdMaximumUnicodeStringLength Unicode
843 characters, not including the Null-terminator, then ASSERT().
845 @param String The pointer to a Null-terminated Unicode string.
846 @param SearchString The pointer to a Null-terminated Unicode string to search for.
848 @retval NULL If the SearchString does not appear in String.
849 @return others If there is a match.
855 IN CONST CHAR16
*String
,
856 IN CONST CHAR16
*SearchString
860 Convert a Null-terminated Unicode decimal string to a value of
863 This function returns a value of type UINTN by interpreting the contents
864 of the Unicode string specified by String as a decimal number. The format
865 of the input Unicode string String is:
867 [spaces] [decimal digits].
869 The valid decimal digit character is in the range [0-9]. The
870 function will ignore the pad space, which includes spaces or
871 tab characters, before [decimal digits]. The running zero in the
872 beginning of [decimal digits] will be ignored. Then, the function
873 stops at the first character that is a not a valid decimal character
874 or a Null-terminator, whichever one comes first.
876 If String is NULL, then ASSERT().
877 If String is not aligned in a 16-bit boundary, then ASSERT().
878 If String has only pad spaces, then 0 is returned.
879 If String has no pad spaces or valid decimal digits,
881 If the number represented by String overflows according
882 to the range defined by UINTN, then ASSERT().
884 If PcdMaximumUnicodeStringLength is not zero, and String contains
885 more than PcdMaximumUnicodeStringLength Unicode characters not including
886 the Null-terminator, then ASSERT().
888 @param String The pointer to a Null-terminated Unicode string.
890 @retval Value translated from String.
896 IN CONST CHAR16
*String
900 Convert a Null-terminated Unicode decimal string to a value of
903 This function returns a value of type UINT64 by interpreting the contents
904 of the Unicode string specified by String as a decimal number. The format
905 of the input Unicode string String is:
907 [spaces] [decimal digits].
909 The valid decimal digit character is in the range [0-9]. The
910 function will ignore the pad space, which includes spaces or
911 tab characters, before [decimal digits]. The running zero in the
912 beginning of [decimal digits] will be ignored. Then, the function
913 stops at the first character that is a not a valid decimal character
914 or a Null-terminator, whichever one comes first.
916 If String is NULL, then ASSERT().
917 If String is not aligned in a 16-bit boundary, then ASSERT().
918 If String has only pad spaces, then 0 is returned.
919 If String has no pad spaces or valid decimal digits,
921 If the number represented by String overflows according
922 to the range defined by UINT64, then ASSERT().
924 If PcdMaximumUnicodeStringLength is not zero, and String contains
925 more than PcdMaximumUnicodeStringLength Unicode characters not including
926 the Null-terminator, then ASSERT().
928 @param String The pointer to a Null-terminated Unicode string.
930 @retval Value translated from String.
936 IN CONST CHAR16
*String
941 Convert a Null-terminated Unicode hexadecimal string to a value of type UINTN.
943 This function returns a value of type UINTN by interpreting the contents
944 of the Unicode string specified by String as a hexadecimal number.
945 The format of the input Unicode string String is:
947 [spaces][zeros][x][hexadecimal digits].
949 The valid hexadecimal digit character is in the range [0-9], [a-f] and [A-F].
950 The prefix "0x" is optional. Both "x" and "X" is allowed in "0x" prefix.
951 If "x" appears in the input string, it must be prefixed with at least one 0.
952 The function will ignore the pad space, which includes spaces or tab characters,
953 before [zeros], [x] or [hexadecimal digit]. The running zero before [x] or
954 [hexadecimal digit] will be ignored. Then, the decoding starts after [x] or the
955 first valid hexadecimal digit. Then, the function stops at the first character
956 that is a not a valid hexadecimal character or NULL, whichever one comes first.
958 If String is NULL, then ASSERT().
959 If String is not aligned in a 16-bit boundary, then ASSERT().
960 If String has only pad spaces, then zero is returned.
961 If String has no leading pad spaces, leading zeros or valid hexadecimal digits,
962 then zero is returned.
963 If the number represented by String overflows according to the range defined by
964 UINTN, then ASSERT().
966 If PcdMaximumUnicodeStringLength is not zero, and String contains more than
967 PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator,
970 @param String The pointer to a Null-terminated Unicode string.
972 @retval Value translated from String.
978 IN CONST CHAR16
*String
983 Convert a Null-terminated Unicode hexadecimal string to a value of type UINT64.
985 This function returns a value of type UINT64 by interpreting the contents
986 of the Unicode string specified by String as a hexadecimal number.
987 The format of the input Unicode string String is
989 [spaces][zeros][x][hexadecimal digits].
991 The valid hexadecimal digit character is in the range [0-9], [a-f] and [A-F].
992 The prefix "0x" is optional. Both "x" and "X" is allowed in "0x" prefix.
993 If "x" appears in the input string, it must be prefixed with at least one 0.
994 The function will ignore the pad space, which includes spaces or tab characters,
995 before [zeros], [x] or [hexadecimal digit]. The running zero before [x] or
996 [hexadecimal digit] will be ignored. Then, the decoding starts after [x] or the
997 first valid hexadecimal digit. Then, the function stops at the first character that is
998 a not a valid hexadecimal character or NULL, whichever one comes first.
1000 If String is NULL, then ASSERT().
1001 If String is not aligned in a 16-bit boundary, then ASSERT().
1002 If String has only pad spaces, then zero is returned.
1003 If String has no leading pad spaces, leading zeros or valid hexadecimal digits,
1004 then zero is returned.
1005 If the number represented by String overflows according to the range defined by
1006 UINT64, then ASSERT().
1008 If PcdMaximumUnicodeStringLength is not zero, and String contains more than
1009 PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator,
1012 @param String The pointer to a Null-terminated Unicode string.
1014 @retval Value translated from String.
1020 IN CONST CHAR16
*String
1024 Convert a Null-terminated Unicode string to a Null-terminated
1025 ASCII string and returns the ASCII string.
1027 This function converts the content of the Unicode string Source
1028 to the ASCII string Destination by copying the lower 8 bits of
1029 each Unicode character. It returns Destination.
1031 The caller is responsible to make sure Destination points to a buffer with size
1032 equal or greater than ((StrLen (Source) + 1) * sizeof (CHAR8)) in bytes.
1034 If any Unicode characters in Source contain non-zero value in
1035 the upper 8 bits, then ASSERT().
1037 If Destination is NULL, then ASSERT().
1038 If Source is NULL, then ASSERT().
1039 If Source is not aligned on a 16-bit boundary, then ASSERT().
1040 If Source and Destination overlap, then ASSERT().
1042 If PcdMaximumUnicodeStringLength is not zero, and Source contains
1043 more than PcdMaximumUnicodeStringLength Unicode characters not including
1044 the Null-terminator, then ASSERT().
1046 If PcdMaximumAsciiStringLength is not zero, and Source contains more
1047 than PcdMaximumAsciiStringLength Unicode characters not including the
1048 Null-terminator, then ASSERT().
1050 @param Source The pointer to a Null-terminated Unicode string.
1051 @param Destination The pointer to a Null-terminated ASCII string.
1053 @return Destination.
1058 UnicodeStrToAsciiStr (
1059 IN CONST CHAR16
*Source
,
1060 OUT CHAR8
*Destination
1064 #ifndef DISABLE_NEW_DEPRECATED_INTERFACES
1067 [ATTENTION] This function is deprecated for security reason.
1069 Copies one Null-terminated ASCII string to another Null-terminated ASCII
1070 string and returns the new ASCII string.
1072 This function copies the contents of the ASCII string Source to the ASCII
1073 string Destination, and returns Destination. If Source and Destination
1074 overlap, then the results are undefined.
1076 If Destination is NULL, then ASSERT().
1077 If Source is NULL, then ASSERT().
1078 If Source and Destination overlap, then ASSERT().
1079 If PcdMaximumAsciiStringLength is not zero and Source contains more than
1080 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
1083 @param Destination The pointer to a Null-terminated ASCII string.
1084 @param Source The pointer to a Null-terminated ASCII string.
1092 OUT CHAR8
*Destination
,
1093 IN CONST CHAR8
*Source
1098 [ATTENTION] This function is deprecated for security reason.
1100 Copies up to a specified length one Null-terminated ASCII string to another
1101 Null-terminated ASCII string and returns the new ASCII string.
1103 This function copies the contents of the ASCII string Source to the ASCII
1104 string Destination, and returns Destination. At most, Length ASCII characters
1105 are copied from Source to Destination. If Length is 0, then Destination is
1106 returned unmodified. If Length is greater that the number of ASCII characters
1107 in Source, then Destination is padded with Null ASCII characters. If Source
1108 and Destination overlap, then the results are undefined.
1110 If Destination is NULL, then ASSERT().
1111 If Source is NULL, then ASSERT().
1112 If Source and Destination overlap, then ASSERT().
1113 If PcdMaximumAsciiStringLength is not zero, and Length is greater than
1114 PcdMaximumAsciiStringLength, then ASSERT().
1115 If PcdMaximumAsciiStringLength is not zero, and Source contains more than
1116 PcdMaximumAsciiStringLength ASCII characters, not including the Null-terminator,
1119 @param Destination The pointer to a Null-terminated ASCII string.
1120 @param Source The pointer to a Null-terminated ASCII string.
1121 @param Length The maximum number of ASCII characters to copy.
1129 OUT CHAR8
*Destination
,
1130 IN CONST CHAR8
*Source
,
1136 Returns the length of a Null-terminated ASCII string.
1138 This function returns the number of ASCII characters in the Null-terminated
1139 ASCII string specified by String.
1141 If Length > 0 and Destination is NULL, then ASSERT().
1142 If Length > 0 and Source is NULL, then ASSERT().
1143 If PcdMaximumAsciiStringLength is not zero and String contains more than
1144 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
1147 @param String The pointer to a Null-terminated ASCII string.
1149 @return The length of String.
1155 IN CONST CHAR8
*String
1160 Returns the size of a Null-terminated ASCII string in bytes, including the
1163 This function returns the size, in bytes, of the Null-terminated ASCII string
1164 specified by String.
1166 If String is NULL, then ASSERT().
1167 If PcdMaximumAsciiStringLength is not zero and String contains more than
1168 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
1171 @param String The pointer to a Null-terminated ASCII string.
1173 @return The size of String.
1179 IN CONST CHAR8
*String
1184 Compares two Null-terminated ASCII strings, and returns the difference
1185 between the first mismatched ASCII characters.
1187 This function compares the Null-terminated ASCII string FirstString to the
1188 Null-terminated ASCII string SecondString. If FirstString is identical to
1189 SecondString, then 0 is returned. Otherwise, the value returned is the first
1190 mismatched ASCII character in SecondString subtracted from the first
1191 mismatched ASCII character in FirstString.
1193 If FirstString is NULL, then ASSERT().
1194 If SecondString is NULL, then ASSERT().
1195 If PcdMaximumAsciiStringLength is not zero and FirstString contains more than
1196 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
1198 If PcdMaximumAsciiStringLength is not zero and SecondString contains more
1199 than PcdMaximumAsciiStringLength ASCII characters not including the
1200 Null-terminator, then ASSERT().
1202 @param FirstString The pointer to a Null-terminated ASCII string.
1203 @param SecondString The pointer to a Null-terminated ASCII string.
1205 @retval ==0 FirstString is identical to SecondString.
1206 @retval !=0 FirstString is not identical to SecondString.
1212 IN CONST CHAR8
*FirstString
,
1213 IN CONST CHAR8
*SecondString
1218 Performs a case insensitive comparison of two Null-terminated ASCII strings,
1219 and returns the difference between the first mismatched ASCII characters.
1221 This function performs a case insensitive comparison of the Null-terminated
1222 ASCII string FirstString to the Null-terminated ASCII string SecondString. If
1223 FirstString is identical to SecondString, then 0 is returned. Otherwise, the
1224 value returned is the first mismatched lower case ASCII character in
1225 SecondString subtracted from the first mismatched lower case ASCII character
1228 If FirstString is NULL, then ASSERT().
1229 If SecondString is NULL, then ASSERT().
1230 If PcdMaximumAsciiStringLength is not zero and FirstString contains more than
1231 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
1233 If PcdMaximumAsciiStringLength is not zero and SecondString contains more
1234 than PcdMaximumAsciiStringLength ASCII characters not including the
1235 Null-terminator, then ASSERT().
1237 @param FirstString The pointer to a Null-terminated ASCII string.
1238 @param SecondString The pointer to a Null-terminated ASCII string.
1240 @retval ==0 FirstString is identical to SecondString using case insensitive
1242 @retval !=0 FirstString is not identical to SecondString using case
1243 insensitive comparisons.
1249 IN CONST CHAR8
*FirstString
,
1250 IN CONST CHAR8
*SecondString
1255 Compares two Null-terminated ASCII strings with maximum lengths, and returns
1256 the difference between the first mismatched ASCII characters.
1258 This function compares the Null-terminated ASCII string FirstString to the
1259 Null-terminated ASCII string SecondString. At most, Length ASCII characters
1260 will be compared. If Length is 0, then 0 is returned. If FirstString is
1261 identical to SecondString, then 0 is returned. Otherwise, the value returned
1262 is the first mismatched ASCII character in SecondString subtracted from the
1263 first mismatched ASCII character in FirstString.
1265 If Length > 0 and FirstString is NULL, then ASSERT().
1266 If Length > 0 and SecondString is NULL, then ASSERT().
1267 If PcdMaximumAsciiStringLength is not zero, and Length is greater than
1268 PcdMaximumAsciiStringLength, then ASSERT().
1269 If PcdMaximumAsciiStringLength is not zero, and FirstString contains more than
1270 PcdMaximumAsciiStringLength ASCII characters, not including the Null-terminator,
1272 If PcdMaximumAsciiStringLength is not zero, and SecondString contains more than
1273 PcdMaximumAsciiStringLength ASCII characters, not including the Null-terminator,
1276 @param FirstString The pointer to a Null-terminated ASCII string.
1277 @param SecondString The pointer to a Null-terminated ASCII string.
1278 @param Length The maximum number of ASCII characters for compare.
1280 @retval ==0 FirstString is identical to SecondString.
1281 @retval !=0 FirstString is not identical to SecondString.
1287 IN CONST CHAR8
*FirstString
,
1288 IN CONST CHAR8
*SecondString
,
1293 #ifndef DISABLE_NEW_DEPRECATED_INTERFACES
1296 [ATTENTION] This function is deprecated for security reason.
1298 Concatenates one Null-terminated ASCII string to another Null-terminated
1299 ASCII string, and returns the concatenated ASCII string.
1301 This function concatenates two Null-terminated ASCII strings. The contents of
1302 Null-terminated ASCII string Source are concatenated to the end of Null-
1303 terminated ASCII string Destination. The Null-terminated concatenated ASCII
1306 If Destination is NULL, then ASSERT().
1307 If Source is NULL, then ASSERT().
1308 If PcdMaximumAsciiStringLength is not zero and Destination contains more than
1309 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
1311 If PcdMaximumAsciiStringLength is not zero and Source contains more than
1312 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
1314 If PcdMaximumAsciiStringLength is not zero and concatenating Destination and
1315 Source results in a ASCII string with more than PcdMaximumAsciiStringLength
1316 ASCII characters, then ASSERT().
1318 @param Destination The pointer to a Null-terminated ASCII string.
1319 @param Source The pointer to a Null-terminated ASCII string.
1327 IN OUT CHAR8
*Destination
,
1328 IN CONST CHAR8
*Source
1333 [ATTENTION] This function is deprecated for security reason.
1335 Concatenates up to a specified length one Null-terminated ASCII string to
1336 the end of another Null-terminated ASCII string, and returns the
1337 concatenated ASCII string.
1339 This function concatenates two Null-terminated ASCII strings. The contents
1340 of Null-terminated ASCII string Source are concatenated to the end of Null-
1341 terminated ASCII string Destination, and Destination is returned. At most,
1342 Length ASCII characters are concatenated from Source to the end of
1343 Destination, and Destination is always Null-terminated. If Length is 0, then
1344 Destination is returned unmodified. If Source and Destination overlap, then
1345 the results are undefined.
1347 If Length > 0 and Destination is NULL, then ASSERT().
1348 If Length > 0 and Source is NULL, then ASSERT().
1349 If Source and Destination overlap, then ASSERT().
1350 If PcdMaximumAsciiStringLength is not zero, and Length is greater than
1351 PcdMaximumAsciiStringLength, then ASSERT().
1352 If PcdMaximumAsciiStringLength is not zero, and Destination contains more than
1353 PcdMaximumAsciiStringLength ASCII characters, not including the Null-terminator,
1355 If PcdMaximumAsciiStringLength is not zero, and Source contains more than
1356 PcdMaximumAsciiStringLength ASCII characters, not including the Null-terminator,
1358 If PcdMaximumAsciiStringLength is not zero, and concatenating Destination and
1359 Source results in a ASCII string with more than PcdMaximumAsciiStringLength
1360 ASCII characters, not including the Null-terminator, then ASSERT().
1362 @param Destination The pointer to a Null-terminated ASCII string.
1363 @param Source The pointer to a Null-terminated ASCII string.
1364 @param Length The maximum number of ASCII characters to concatenate from
1373 IN OUT CHAR8
*Destination
,
1374 IN CONST CHAR8
*Source
,
1380 Returns the first occurrence of a Null-terminated ASCII sub-string
1381 in a Null-terminated ASCII string.
1383 This function scans the contents of the ASCII string specified by String
1384 and returns the first occurrence of SearchString. If SearchString is not
1385 found in String, then NULL is returned. If the length of SearchString is zero,
1386 then String is returned.
1388 If String is NULL, then ASSERT().
1389 If SearchString is NULL, then ASSERT().
1391 If PcdMaximumAsciiStringLength is not zero, and SearchString or
1392 String contains more than PcdMaximumAsciiStringLength Unicode characters
1393 not including the Null-terminator, then ASSERT().
1395 @param String The pointer to a Null-terminated ASCII string.
1396 @param SearchString The pointer to a Null-terminated ASCII string to search for.
1398 @retval NULL If the SearchString does not appear in String.
1399 @retval others If there is a match return the first occurrence of SearchingString.
1400 If the length of SearchString is zero,return String.
1406 IN CONST CHAR8
*String
,
1407 IN CONST CHAR8
*SearchString
1412 Convert a Null-terminated ASCII decimal string to a value of type
1415 This function returns a value of type UINTN by interpreting the contents
1416 of the ASCII string String as a decimal number. The format of the input
1417 ASCII string String is:
1419 [spaces] [decimal digits].
1421 The valid decimal digit character is in the range [0-9]. The function will
1422 ignore the pad space, which includes spaces or tab characters, before the digits.
1423 The running zero in the beginning of [decimal digits] will be ignored. Then, the
1424 function stops at the first character that is a not a valid decimal character or
1425 Null-terminator, whichever on comes first.
1427 If String has only pad spaces, then 0 is returned.
1428 If String has no pad spaces or valid decimal digits, then 0 is returned.
1429 If the number represented by String overflows according to the range defined by
1430 UINTN, then ASSERT().
1431 If String is NULL, then ASSERT().
1432 If PcdMaximumAsciiStringLength is not zero, and String contains more than
1433 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
1436 @param String The pointer to a Null-terminated ASCII string.
1438 @retval The value translated from String.
1443 AsciiStrDecimalToUintn (
1444 IN CONST CHAR8
*String
1449 Convert a Null-terminated ASCII decimal string to a value of type
1452 This function returns a value of type UINT64 by interpreting the contents
1453 of the ASCII string String as a decimal number. The format of the input
1454 ASCII string String is:
1456 [spaces] [decimal digits].
1458 The valid decimal digit character is in the range [0-9]. The function will
1459 ignore the pad space, which includes spaces or tab characters, before the digits.
1460 The running zero in the beginning of [decimal digits] will be ignored. Then, the
1461 function stops at the first character that is a not a valid decimal character or
1462 Null-terminator, whichever on comes first.
1464 If String has only pad spaces, then 0 is returned.
1465 If String has no pad spaces or valid decimal digits, then 0 is returned.
1466 If the number represented by String overflows according to the range defined by
1467 UINT64, then ASSERT().
1468 If String is NULL, then ASSERT().
1469 If PcdMaximumAsciiStringLength is not zero, and String contains more than
1470 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
1473 @param String The pointer to a Null-terminated ASCII string.
1475 @retval Value translated from String.
1480 AsciiStrDecimalToUint64 (
1481 IN CONST CHAR8
*String
1486 Convert a Null-terminated ASCII hexadecimal string to a value of type UINTN.
1488 This function returns a value of type UINTN by interpreting the contents of
1489 the ASCII string String as a hexadecimal number. The format of the input ASCII
1492 [spaces][zeros][x][hexadecimal digits].
1494 The valid hexadecimal digit character is in the range [0-9], [a-f] and [A-F].
1495 The prefix "0x" is optional. Both "x" and "X" is allowed in "0x" prefix. If "x"
1496 appears in the input string, it must be prefixed with at least one 0. The function
1497 will ignore the pad space, which includes spaces or tab characters, before [zeros],
1498 [x] or [hexadecimal digits]. The running zero before [x] or [hexadecimal digits]
1499 will be ignored. Then, the decoding starts after [x] or the first valid hexadecimal
1500 digit. Then, the function stops at the first character that is a not a valid
1501 hexadecimal character or Null-terminator, whichever on comes first.
1503 If String has only pad spaces, then 0 is returned.
1504 If String has no leading pad spaces, leading zeros or valid hexadecimal digits, then
1507 If the number represented by String overflows according to the range defined by UINTN,
1509 If String is NULL, then ASSERT().
1510 If PcdMaximumAsciiStringLength is not zero,
1511 and String contains more than PcdMaximumAsciiStringLength ASCII characters not including
1512 the Null-terminator, then ASSERT().
1514 @param String The pointer to a Null-terminated ASCII string.
1516 @retval Value translated from String.
1521 AsciiStrHexToUintn (
1522 IN CONST CHAR8
*String
1527 Convert a Null-terminated ASCII hexadecimal string to a value of type UINT64.
1529 This function returns a value of type UINT64 by interpreting the contents of
1530 the ASCII string String as a hexadecimal number. The format of the input ASCII
1533 [spaces][zeros][x][hexadecimal digits].
1535 The valid hexadecimal digit character is in the range [0-9], [a-f] and [A-F].
1536 The prefix "0x" is optional. Both "x" and "X" is allowed in "0x" prefix. If "x"
1537 appears in the input string, it must be prefixed with at least one 0. The function
1538 will ignore the pad space, which includes spaces or tab characters, before [zeros],
1539 [x] or [hexadecimal digits]. The running zero before [x] or [hexadecimal digits]
1540 will be ignored. Then, the decoding starts after [x] or the first valid hexadecimal
1541 digit. Then, the function stops at the first character that is a not a valid
1542 hexadecimal character or Null-terminator, whichever on comes first.
1544 If String has only pad spaces, then 0 is returned.
1545 If String has no leading pad spaces, leading zeros or valid hexadecimal digits, then
1548 If the number represented by String overflows according to the range defined by UINT64,
1550 If String is NULL, then ASSERT().
1551 If PcdMaximumAsciiStringLength is not zero,
1552 and String contains more than PcdMaximumAsciiStringLength ASCII characters not including
1553 the Null-terminator, then ASSERT().
1555 @param String The pointer to a Null-terminated ASCII string.
1557 @retval Value translated from String.
1562 AsciiStrHexToUint64 (
1563 IN CONST CHAR8
*String
1568 Convert one Null-terminated ASCII string to a Null-terminated
1569 Unicode string and returns the Unicode string.
1571 This function converts the contents of the ASCII string Source to the Unicode
1572 string Destination, and returns Destination. The function terminates the
1573 Unicode string Destination by appending a Null-terminator character at the end.
1574 The caller is responsible to make sure Destination points to a buffer with size
1575 equal or greater than ((AsciiStrLen (Source) + 1) * sizeof (CHAR16)) in bytes.
1577 If Destination is NULL, then ASSERT().
1578 If Destination is not aligned on a 16-bit boundary, then ASSERT().
1579 If Source is NULL, then ASSERT().
1580 If Source and Destination overlap, then ASSERT().
1581 If PcdMaximumAsciiStringLength is not zero, and Source contains more than
1582 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
1584 If PcdMaximumUnicodeStringLength is not zero, and Source contains more than
1585 PcdMaximumUnicodeStringLength ASCII characters not including the
1586 Null-terminator, then ASSERT().
1588 @param Source The pointer to a Null-terminated ASCII string.
1589 @param Destination The pointer to a Null-terminated Unicode string.
1591 @return Destination.
1596 AsciiStrToUnicodeStr (
1597 IN CONST CHAR8
*Source
,
1598 OUT CHAR16
*Destination
1603 Converts an 8-bit value to an 8-bit BCD value.
1605 Converts the 8-bit value specified by Value to BCD. The BCD value is
1608 If Value >= 100, then ASSERT().
1610 @param Value The 8-bit value to convert to BCD. Range 0..99.
1612 @return The BCD value.
1623 Converts an 8-bit BCD value to an 8-bit value.
1625 Converts the 8-bit BCD value specified by Value to an 8-bit value. The 8-bit
1628 If Value >= 0xA0, then ASSERT().
1629 If (Value & 0x0F) >= 0x0A, then ASSERT().
1631 @param Value The 8-bit BCD value to convert to an 8-bit value.
1633 @return The 8-bit value is returned.
1643 // File Path Manipulation Functions
1647 Removes the last directory or file entry in a path by changing the last
1648 L'\' to a CHAR_NULL.
1650 @param[in, out] Path The pointer to the path to modify.
1652 @retval FALSE Nothing was found to remove.
1653 @retval TRUE A directory or file was removed.
1662 Function to clean up paths.
1663 - Single periods in the path are removed.
1664 - Double periods in the path are removed along with a single parent directory.
1665 - Forward slashes L'/' are converted to backward slashes L'\'.
1667 This will be done inline and the existing buffer may be larger than required
1670 @param[in] Path The pointer to the string containing the path.
1672 @return Returns Path, otherwise returns NULL to indicate that an error has occured.
1676 PathCleanUpDirectories(
1681 // Linked List Functions and Macros
1685 Initializes the head node of a doubly linked list that is declared as a
1686 global variable in a module.
1688 Initializes the forward and backward links of a new linked list. After
1689 initializing a linked list with this macro, the other linked list functions
1690 may be used to add and remove nodes from the linked list. This macro results
1691 in smaller executables by initializing the linked list in the data section,
1692 instead if calling the InitializeListHead() function to perform the
1693 equivalent operation.
1695 @param ListHead The head note of a list to initialize.
1698 #define INITIALIZE_LIST_HEAD_VARIABLE(ListHead) {&(ListHead), &(ListHead)}
1702 Initializes the head node of a doubly linked list, and returns the pointer to
1703 the head node of the doubly linked list.
1705 Initializes the forward and backward links of a new linked list. After
1706 initializing a linked list with this function, the other linked list
1707 functions may be used to add and remove nodes from the linked list. It is up
1708 to the caller of this function to allocate the memory for ListHead.
1710 If ListHead is NULL, then ASSERT().
1712 @param ListHead A pointer to the head node of a new doubly linked list.
1719 InitializeListHead (
1720 IN OUT LIST_ENTRY
*ListHead
1725 Adds a node to the beginning of a doubly linked list, and returns the pointer
1726 to the head node of the doubly linked list.
1728 Adds the node Entry at the beginning of the doubly linked list denoted by
1729 ListHead, and returns ListHead.
1731 If ListHead is NULL, then ASSERT().
1732 If Entry is NULL, then ASSERT().
1733 If ListHead was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or
1734 InitializeListHead(), then ASSERT().
1735 If PcdMaximumLinkedListLength is not zero, and prior to insertion the number
1736 of nodes in ListHead, including the ListHead node, is greater than or
1737 equal to PcdMaximumLinkedListLength, then ASSERT().
1739 @param ListHead A pointer to the head node of a doubly linked list.
1740 @param Entry A pointer to a node that is to be inserted at the beginning
1741 of a doubly linked list.
1749 IN OUT LIST_ENTRY
*ListHead
,
1750 IN OUT LIST_ENTRY
*Entry
1755 Adds a node to the end of a doubly linked list, and returns the pointer to
1756 the head node of the doubly linked list.
1758 Adds the node Entry to the end of the doubly linked list denoted by ListHead,
1759 and returns ListHead.
1761 If ListHead is NULL, then ASSERT().
1762 If Entry is NULL, then ASSERT().
1763 If ListHead was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or
1764 InitializeListHead(), then ASSERT().
1765 If PcdMaximumLinkedListLength is not zero, and prior to insertion the number
1766 of nodes in ListHead, including the ListHead node, is greater than or
1767 equal to PcdMaximumLinkedListLength, then ASSERT().
1769 @param ListHead A pointer to the head node of a doubly linked list.
1770 @param Entry A pointer to a node that is to be added at the end of the
1779 IN OUT LIST_ENTRY
*ListHead
,
1780 IN OUT LIST_ENTRY
*Entry
1785 Retrieves the first node of a doubly linked list.
1787 Returns the first node of a doubly linked list. List must have been
1788 initialized with INTIALIZE_LIST_HEAD_VARIABLE() or InitializeListHead().
1789 If List is empty, then List is returned.
1791 If List is NULL, then ASSERT().
1792 If List was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or
1793 InitializeListHead(), then ASSERT().
1794 If PcdMaximumLinkedListLength is not zero, and the number of nodes
1795 in List, including the List node, is greater than or equal to
1796 PcdMaximumLinkedListLength, then ASSERT().
1798 @param List A pointer to the head node of a doubly linked list.
1800 @return The first node of a doubly linked list.
1801 @retval List The list is empty.
1807 IN CONST LIST_ENTRY
*List
1812 Retrieves the next node of a doubly linked list.
1814 Returns the node of a doubly linked list that follows Node.
1815 List must have been initialized with INTIALIZE_LIST_HEAD_VARIABLE()
1816 or InitializeListHead(). If List is empty, then List is returned.
1818 If List is NULL, then ASSERT().
1819 If Node is NULL, then ASSERT().
1820 If List was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or
1821 InitializeListHead(), then ASSERT().
1822 If PcdMaximumLinkedListLength is not zero, and List contains more than
1823 PcdMaximumLinkedListLength nodes, then ASSERT().
1824 If PcdVerifyNodeInList is TRUE and Node is not a node in List, then ASSERT().
1826 @param List A pointer to the head node of a doubly linked list.
1827 @param Node A pointer to a node in the doubly linked list.
1829 @return The pointer to the next node if one exists. Otherwise List is returned.
1835 IN CONST LIST_ENTRY
*List
,
1836 IN CONST LIST_ENTRY
*Node
1841 Retrieves the previous node of a doubly linked list.
1843 Returns the node of a doubly linked list that precedes Node.
1844 List must have been initialized with INTIALIZE_LIST_HEAD_VARIABLE()
1845 or InitializeListHead(). If List is empty, then List is returned.
1847 If List is NULL, then ASSERT().
1848 If Node is NULL, then ASSERT().
1849 If List was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or
1850 InitializeListHead(), then ASSERT().
1851 If PcdMaximumLinkedListLength is not zero, and List contains more than
1852 PcdMaximumLinkedListLength nodes, then ASSERT().
1853 If PcdVerifyNodeInList is TRUE and Node is not a node in List, then ASSERT().
1855 @param List A pointer to the head node of a doubly linked list.
1856 @param Node A pointer to a node in the doubly linked list.
1858 @return The pointer to the previous node if one exists. Otherwise List is returned.
1864 IN CONST LIST_ENTRY
*List
,
1865 IN CONST LIST_ENTRY
*Node
1870 Checks to see if a doubly linked list is empty or not.
1872 Checks to see if the doubly linked list is empty. If the linked list contains
1873 zero nodes, this function returns TRUE. Otherwise, it returns FALSE.
1875 If ListHead is NULL, then ASSERT().
1876 If ListHead was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or
1877 InitializeListHead(), then ASSERT().
1878 If PcdMaximumLinkedListLength is not zero, and the number of nodes
1879 in List, including the List node, is greater than or equal to
1880 PcdMaximumLinkedListLength, then ASSERT().
1882 @param ListHead A pointer to the head node of a doubly linked list.
1884 @retval TRUE The linked list is empty.
1885 @retval FALSE The linked list is not empty.
1891 IN CONST LIST_ENTRY
*ListHead
1896 Determines if a node in a doubly linked list is the head node of a the same
1897 doubly linked list. This function is typically used to terminate a loop that
1898 traverses all the nodes in a doubly linked list starting with the head node.
1900 Returns TRUE if Node is equal to List. Returns FALSE if Node is one of the
1901 nodes in the doubly linked list specified by List. List must have been
1902 initialized with INTIALIZE_LIST_HEAD_VARIABLE() or InitializeListHead().
1904 If List is NULL, then ASSERT().
1905 If Node is NULL, then ASSERT().
1906 If List was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or InitializeListHead(),
1908 If PcdMaximumLinkedListLength is not zero, and the number of nodes
1909 in List, including the List node, is greater than or equal to
1910 PcdMaximumLinkedListLength, then ASSERT().
1911 If PcdVerifyNodeInList is TRUE and Node is not a node in List the and Node is not equal
1912 to List, then ASSERT().
1914 @param List A pointer to the head node of a doubly linked list.
1915 @param Node A pointer to a node in the doubly linked list.
1917 @retval TRUE Node is the head of the doubly-linked list pointed by List.
1918 @retval FALSE Node is not the head of the doubly-linked list pointed by List.
1924 IN CONST LIST_ENTRY
*List
,
1925 IN CONST LIST_ENTRY
*Node
1930 Determines if a node the last node in a doubly linked list.
1932 Returns TRUE if Node is the last node in the doubly linked list specified by
1933 List. Otherwise, FALSE is returned. List must have been initialized with
1934 INTIALIZE_LIST_HEAD_VARIABLE() or InitializeListHead().
1936 If List is NULL, then ASSERT().
1937 If Node is NULL, then ASSERT().
1938 If List was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or
1939 InitializeListHead(), then ASSERT().
1940 If PcdMaximumLinkedListLength is not zero, and the number of nodes
1941 in List, including the List node, is greater than or equal to
1942 PcdMaximumLinkedListLength, then ASSERT().
1943 If PcdVerifyNodeInList is TRUE and Node is not a node in List, then ASSERT().
1945 @param List A pointer to the head node of a doubly linked list.
1946 @param Node A pointer to a node in the doubly linked list.
1948 @retval TRUE Node is the last node in the linked list.
1949 @retval FALSE Node is not the last node in the linked list.
1955 IN CONST LIST_ENTRY
*List
,
1956 IN CONST LIST_ENTRY
*Node
1961 Swaps the location of two nodes in a doubly linked list, and returns the
1962 first node after the swap.
1964 If FirstEntry is identical to SecondEntry, then SecondEntry is returned.
1965 Otherwise, the location of the FirstEntry node is swapped with the location
1966 of the SecondEntry node in a doubly linked list. SecondEntry must be in the
1967 same double linked list as FirstEntry and that double linked list must have
1968 been initialized with INTIALIZE_LIST_HEAD_VARIABLE() or InitializeListHead().
1969 SecondEntry is returned after the nodes are swapped.
1971 If FirstEntry is NULL, then ASSERT().
1972 If SecondEntry is NULL, then ASSERT().
1973 If PcdVerifyNodeInList is TRUE and SecondEntry and FirstEntry are not in the
1974 same linked list, then ASSERT().
1975 If PcdMaximumLinkedListLength is not zero, and the number of nodes in the
1976 linked list containing the FirstEntry and SecondEntry nodes, including
1977 the FirstEntry and SecondEntry nodes, is greater than or equal to
1978 PcdMaximumLinkedListLength, then ASSERT().
1980 @param FirstEntry A pointer to a node in a linked list.
1981 @param SecondEntry A pointer to another node in the same linked list.
1983 @return SecondEntry.
1989 IN OUT LIST_ENTRY
*FirstEntry
,
1990 IN OUT LIST_ENTRY
*SecondEntry
1995 Removes a node from a doubly linked list, and returns the node that follows
1998 Removes the node Entry from a doubly linked list. It is up to the caller of
1999 this function to release the memory used by this node if that is required. On
2000 exit, the node following Entry in the doubly linked list is returned. If
2001 Entry is the only node in the linked list, then the head node of the linked
2004 If Entry is NULL, then ASSERT().
2005 If Entry is the head node of an empty list, then ASSERT().
2006 If PcdMaximumLinkedListLength is not zero, and the number of nodes in the
2007 linked list containing Entry, including the Entry node, is greater than
2008 or equal to PcdMaximumLinkedListLength, then ASSERT().
2010 @param Entry A pointer to a node in a linked list.
2018 IN CONST LIST_ENTRY
*Entry
2026 Shifts a 64-bit integer left between 0 and 63 bits. The low bits are filled
2027 with zeros. The shifted value is returned.
2029 This function shifts the 64-bit value Operand to the left by Count bits. The
2030 low Count bits are set to zero. The shifted value is returned.
2032 If Count is greater than 63, then ASSERT().
2034 @param Operand The 64-bit operand to shift left.
2035 @param Count The number of bits to shift left.
2037 @return Operand << Count.
2049 Shifts a 64-bit integer right between 0 and 63 bits. This high bits are
2050 filled with zeros. The shifted value is returned.
2052 This function shifts the 64-bit value Operand to the right by Count bits. The
2053 high Count bits are set to zero. The shifted value is returned.
2055 If Count is greater than 63, then ASSERT().
2057 @param Operand The 64-bit operand to shift right.
2058 @param Count The number of bits to shift right.
2060 @return Operand >> Count
2072 Shifts a 64-bit integer right between 0 and 63 bits. The high bits are filled
2073 with original integer's bit 63. The shifted value is returned.
2075 This function shifts the 64-bit value Operand to the right by Count bits. The
2076 high Count bits are set to bit 63 of Operand. The shifted value is returned.
2078 If Count is greater than 63, then ASSERT().
2080 @param Operand The 64-bit operand to shift right.
2081 @param Count The number of bits to shift right.
2083 @return Operand >> Count
2095 Rotates a 32-bit integer left between 0 and 31 bits, filling the low bits
2096 with the high bits that were rotated.
2098 This function rotates the 32-bit value Operand to the left by Count bits. The
2099 low Count bits are fill with the high Count bits of Operand. The rotated
2102 If Count is greater than 31, then ASSERT().
2104 @param Operand The 32-bit operand to rotate left.
2105 @param Count The number of bits to rotate left.
2107 @return Operand << Count
2119 Rotates a 32-bit integer right between 0 and 31 bits, filling the high bits
2120 with the low bits that were rotated.
2122 This function rotates the 32-bit value Operand to the right by Count bits.
2123 The high Count bits are fill with the low Count bits of Operand. The rotated
2126 If Count is greater than 31, then ASSERT().
2128 @param Operand The 32-bit operand to rotate right.
2129 @param Count The number of bits to rotate right.
2131 @return Operand >> Count
2143 Rotates a 64-bit integer left between 0 and 63 bits, filling the low bits
2144 with the high bits that were rotated.
2146 This function rotates the 64-bit value Operand to the left by Count bits. The
2147 low Count bits are fill with the high Count bits of Operand. The rotated
2150 If Count is greater than 63, then ASSERT().
2152 @param Operand The 64-bit operand to rotate left.
2153 @param Count The number of bits to rotate left.
2155 @return Operand << Count
2167 Rotates a 64-bit integer right between 0 and 63 bits, filling the high bits
2168 with the high low bits that were rotated.
2170 This function rotates the 64-bit value Operand to the right by Count bits.
2171 The high Count bits are fill with the low Count bits of Operand. The rotated
2174 If Count is greater than 63, then ASSERT().
2176 @param Operand The 64-bit operand to rotate right.
2177 @param Count The number of bits to rotate right.
2179 @return Operand >> Count
2191 Returns the bit position of the lowest bit set in a 32-bit value.
2193 This function computes the bit position of the lowest bit set in the 32-bit
2194 value specified by Operand. If Operand is zero, then -1 is returned.
2195 Otherwise, a value between 0 and 31 is returned.
2197 @param Operand The 32-bit operand to evaluate.
2199 @retval 0..31 The lowest bit set in Operand was found.
2200 @retval -1 Operand is zero.
2211 Returns the bit position of the lowest bit set in a 64-bit value.
2213 This function computes the bit position of the lowest bit set in the 64-bit
2214 value specified by Operand. If Operand is zero, then -1 is returned.
2215 Otherwise, a value between 0 and 63 is returned.
2217 @param Operand The 64-bit operand to evaluate.
2219 @retval 0..63 The lowest bit set in Operand was found.
2220 @retval -1 Operand is zero.
2232 Returns the bit position of the highest bit set in a 32-bit value. Equivalent
2235 This function computes the bit position of the highest bit set in the 32-bit
2236 value specified by Operand. If Operand is zero, then -1 is returned.
2237 Otherwise, a value between 0 and 31 is returned.
2239 @param Operand The 32-bit operand to evaluate.
2241 @retval 0..31 Position of the highest bit set in Operand if found.
2242 @retval -1 Operand is zero.
2253 Returns the bit position of the highest bit set in a 64-bit value. Equivalent
2256 This function computes the bit position of the highest bit set in the 64-bit
2257 value specified by Operand. If Operand is zero, then -1 is returned.
2258 Otherwise, a value between 0 and 63 is returned.
2260 @param Operand The 64-bit operand to evaluate.
2262 @retval 0..63 Position of the highest bit set in Operand if found.
2263 @retval -1 Operand is zero.
2274 Returns the value of the highest bit set in a 32-bit value. Equivalent to
2277 This function computes the value of the highest bit set in the 32-bit value
2278 specified by Operand. If Operand is zero, then zero is returned.
2280 @param Operand The 32-bit operand to evaluate.
2282 @return 1 << HighBitSet32(Operand)
2283 @retval 0 Operand is zero.
2294 Returns the value of the highest bit set in a 64-bit value. Equivalent to
2297 This function computes the value of the highest bit set in the 64-bit value
2298 specified by Operand. If Operand is zero, then zero is returned.
2300 @param Operand The 64-bit operand to evaluate.
2302 @return 1 << HighBitSet64(Operand)
2303 @retval 0 Operand is zero.
2314 Switches the endianness of a 16-bit integer.
2316 This function swaps the bytes in a 16-bit unsigned value to switch the value
2317 from little endian to big endian or vice versa. The byte swapped value is
2320 @param Value A 16-bit unsigned value.
2322 @return The byte swapped Value.
2333 Switches the endianness of a 32-bit integer.
2335 This function swaps the bytes in a 32-bit unsigned value to switch the value
2336 from little endian to big endian or vice versa. The byte swapped value is
2339 @param Value A 32-bit unsigned value.
2341 @return The byte swapped Value.
2352 Switches the endianness of a 64-bit integer.
2354 This function swaps the bytes in a 64-bit unsigned value to switch the value
2355 from little endian to big endian or vice versa. The byte swapped value is
2358 @param Value A 64-bit unsigned value.
2360 @return The byte swapped Value.
2371 Multiples a 64-bit unsigned integer by a 32-bit unsigned integer and
2372 generates a 64-bit unsigned result.
2374 This function multiples the 64-bit unsigned value Multiplicand by the 32-bit
2375 unsigned value Multiplier and generates a 64-bit unsigned result. This 64-
2376 bit unsigned result is returned.
2378 @param Multiplicand A 64-bit unsigned value.
2379 @param Multiplier A 32-bit unsigned value.
2381 @return Multiplicand * Multiplier
2387 IN UINT64 Multiplicand
,
2388 IN UINT32 Multiplier
2393 Multiples a 64-bit unsigned integer by a 64-bit unsigned integer and
2394 generates a 64-bit unsigned result.
2396 This function multiples the 64-bit unsigned value Multiplicand by the 64-bit
2397 unsigned value Multiplier and generates a 64-bit unsigned result. This 64-
2398 bit unsigned result is returned.
2400 @param Multiplicand A 64-bit unsigned value.
2401 @param Multiplier A 64-bit unsigned value.
2403 @return Multiplicand * Multiplier.
2409 IN UINT64 Multiplicand
,
2410 IN UINT64 Multiplier
2415 Multiples a 64-bit signed integer by a 64-bit signed integer and generates a
2416 64-bit signed result.
2418 This function multiples the 64-bit signed value Multiplicand by the 64-bit
2419 signed value Multiplier and generates a 64-bit signed result. This 64-bit
2420 signed result is returned.
2422 @param Multiplicand A 64-bit signed value.
2423 @param Multiplier A 64-bit signed value.
2425 @return Multiplicand * Multiplier
2431 IN INT64 Multiplicand
,
2437 Divides a 64-bit unsigned integer by a 32-bit unsigned integer and generates
2438 a 64-bit unsigned result.
2440 This function divides the 64-bit unsigned value Dividend by the 32-bit
2441 unsigned value Divisor and generates a 64-bit unsigned quotient. This
2442 function returns the 64-bit unsigned quotient.
2444 If Divisor is 0, then ASSERT().
2446 @param Dividend A 64-bit unsigned value.
2447 @param Divisor A 32-bit unsigned value.
2449 @return Dividend / Divisor.
2461 Divides a 64-bit unsigned integer by a 32-bit unsigned integer and generates
2462 a 32-bit unsigned remainder.
2464 This function divides the 64-bit unsigned value Dividend by the 32-bit
2465 unsigned value Divisor and generates a 32-bit remainder. This function
2466 returns the 32-bit unsigned remainder.
2468 If Divisor is 0, then ASSERT().
2470 @param Dividend A 64-bit unsigned value.
2471 @param Divisor A 32-bit unsigned value.
2473 @return Dividend % Divisor.
2485 Divides a 64-bit unsigned integer by a 32-bit unsigned integer and generates
2486 a 64-bit unsigned result and an optional 32-bit unsigned remainder.
2488 This function divides the 64-bit unsigned value Dividend by the 32-bit
2489 unsigned value Divisor and generates a 64-bit unsigned quotient. If Remainder
2490 is not NULL, then the 32-bit unsigned remainder is returned in Remainder.
2491 This function returns the 64-bit unsigned quotient.
2493 If Divisor is 0, then ASSERT().
2495 @param Dividend A 64-bit unsigned value.
2496 @param Divisor A 32-bit unsigned value.
2497 @param Remainder A pointer to a 32-bit unsigned value. This parameter is
2498 optional and may be NULL.
2500 @return Dividend / Divisor.
2505 DivU64x32Remainder (
2508 OUT UINT32
*Remainder OPTIONAL
2513 Divides a 64-bit unsigned integer by a 64-bit unsigned integer and generates
2514 a 64-bit unsigned result and an optional 64-bit unsigned remainder.
2516 This function divides the 64-bit unsigned value Dividend by the 64-bit
2517 unsigned value Divisor and generates a 64-bit unsigned quotient. If Remainder
2518 is not NULL, then the 64-bit unsigned remainder is returned in Remainder.
2519 This function returns the 64-bit unsigned quotient.
2521 If Divisor is 0, then ASSERT().
2523 @param Dividend A 64-bit unsigned value.
2524 @param Divisor A 64-bit unsigned value.
2525 @param Remainder A pointer to a 64-bit unsigned value. This parameter is
2526 optional and may be NULL.
2528 @return Dividend / Divisor.
2533 DivU64x64Remainder (
2536 OUT UINT64
*Remainder OPTIONAL
2541 Divides a 64-bit signed integer by a 64-bit signed integer and generates a
2542 64-bit signed result and a optional 64-bit signed remainder.
2544 This function divides the 64-bit signed value Dividend by the 64-bit signed
2545 value Divisor and generates a 64-bit signed quotient. If Remainder is not
2546 NULL, then the 64-bit signed remainder is returned in Remainder. This
2547 function returns the 64-bit signed quotient.
2549 It is the caller's responsibility to not call this function with a Divisor of 0.
2550 If Divisor is 0, then the quotient and remainder should be assumed to be
2551 the largest negative integer.
2553 If Divisor is 0, then ASSERT().
2555 @param Dividend A 64-bit signed value.
2556 @param Divisor A 64-bit signed value.
2557 @param Remainder A pointer to a 64-bit signed value. This parameter is
2558 optional and may be NULL.
2560 @return Dividend / Divisor.
2565 DivS64x64Remainder (
2568 OUT INT64
*Remainder OPTIONAL
2573 Reads a 16-bit value from memory that may be unaligned.
2575 This function returns the 16-bit value pointed to by Buffer. The function
2576 guarantees that the read operation does not produce an alignment fault.
2578 If the Buffer is NULL, then ASSERT().
2580 @param Buffer The pointer to a 16-bit value that may be unaligned.
2582 @return The 16-bit value read from Buffer.
2588 IN CONST UINT16
*Buffer
2593 Writes a 16-bit value to memory that may be unaligned.
2595 This function writes the 16-bit value specified by Value to Buffer. Value is
2596 returned. The function guarantees that the write operation does not produce
2599 If the Buffer is NULL, then ASSERT().
2601 @param Buffer The pointer to a 16-bit value that may be unaligned.
2602 @param Value 16-bit value to write to Buffer.
2604 @return The 16-bit value to write to Buffer.
2616 Reads a 24-bit value from memory that may be unaligned.
2618 This function returns the 24-bit value pointed to by Buffer. The function
2619 guarantees that the read operation does not produce an alignment fault.
2621 If the Buffer is NULL, then ASSERT().
2623 @param Buffer The pointer to a 24-bit value that may be unaligned.
2625 @return The 24-bit value read from Buffer.
2631 IN CONST UINT32
*Buffer
2636 Writes a 24-bit value to memory that may be unaligned.
2638 This function writes the 24-bit value specified by Value to Buffer. Value is
2639 returned. The function guarantees that the write operation does not produce
2642 If the Buffer is NULL, then ASSERT().
2644 @param Buffer The pointer to a 24-bit value that may be unaligned.
2645 @param Value 24-bit value to write to Buffer.
2647 @return The 24-bit value to write to Buffer.
2659 Reads a 32-bit value from memory that may be unaligned.
2661 This function returns the 32-bit value pointed to by Buffer. The function
2662 guarantees that the read operation does not produce an alignment fault.
2664 If the Buffer is NULL, then ASSERT().
2666 @param Buffer The pointer to a 32-bit value that may be unaligned.
2668 @return The 32-bit value read from Buffer.
2674 IN CONST UINT32
*Buffer
2679 Writes a 32-bit value to memory that may be unaligned.
2681 This function writes the 32-bit value specified by Value to Buffer. Value is
2682 returned. The function guarantees that the write operation does not produce
2685 If the Buffer is NULL, then ASSERT().
2687 @param Buffer The pointer to a 32-bit value that may be unaligned.
2688 @param Value 32-bit value to write to Buffer.
2690 @return The 32-bit value to write to Buffer.
2702 Reads a 64-bit value from memory that may be unaligned.
2704 This function returns the 64-bit value pointed to by Buffer. The function
2705 guarantees that the read operation does not produce an alignment fault.
2707 If the Buffer is NULL, then ASSERT().
2709 @param Buffer The pointer to a 64-bit value that may be unaligned.
2711 @return The 64-bit value read from Buffer.
2717 IN CONST UINT64
*Buffer
2722 Writes a 64-bit value to memory that may be unaligned.
2724 This function writes the 64-bit value specified by Value to Buffer. Value is
2725 returned. The function guarantees that the write operation does not produce
2728 If the Buffer is NULL, then ASSERT().
2730 @param Buffer The pointer to a 64-bit value that may be unaligned.
2731 @param Value 64-bit value to write to Buffer.
2733 @return The 64-bit value to write to Buffer.
2745 // Bit Field Functions
2749 Returns a bit field from an 8-bit value.
2751 Returns the bitfield specified by the StartBit and the EndBit from Operand.
2753 If 8-bit operations are not supported, then ASSERT().
2754 If StartBit is greater than 7, then ASSERT().
2755 If EndBit is greater than 7, then ASSERT().
2756 If EndBit is less than StartBit, then ASSERT().
2758 @param Operand Operand on which to perform the bitfield operation.
2759 @param StartBit The ordinal of the least significant bit in the bit field.
2761 @param EndBit The ordinal of the most significant bit in the bit field.
2764 @return The bit field read.
2777 Writes a bit field to an 8-bit value, and returns the result.
2779 Writes Value to the bit field specified by the StartBit and the EndBit in
2780 Operand. All other bits in Operand are preserved. The new 8-bit value is
2783 If 8-bit operations are not supported, then ASSERT().
2784 If StartBit is greater than 7, then ASSERT().
2785 If EndBit is greater than 7, then ASSERT().
2786 If EndBit is less than StartBit, then ASSERT().
2787 If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
2789 @param Operand Operand on which to perform the bitfield operation.
2790 @param StartBit The ordinal of the least significant bit in the bit field.
2792 @param EndBit The ordinal of the most significant bit in the bit field.
2794 @param Value New value of the bit field.
2796 @return The new 8-bit value.
2810 Reads a bit field from an 8-bit value, performs a bitwise OR, and returns the
2813 Performs a bitwise OR between the bit field specified by StartBit
2814 and EndBit in Operand and the value specified by OrData. All other bits in
2815 Operand are preserved. The new 8-bit value is returned.
2817 If 8-bit operations are not supported, then ASSERT().
2818 If StartBit is greater than 7, then ASSERT().
2819 If EndBit is greater than 7, then ASSERT().
2820 If EndBit is less than StartBit, then ASSERT().
2821 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
2823 @param Operand Operand on which to perform the bitfield operation.
2824 @param StartBit The ordinal of the least significant bit in the bit field.
2826 @param EndBit The ordinal of the most significant bit in the bit field.
2828 @param OrData The value to OR with the read value from the value
2830 @return The new 8-bit value.
2844 Reads a bit field from an 8-bit value, performs a bitwise AND, and returns
2847 Performs a bitwise AND between the bit field specified by StartBit and EndBit
2848 in Operand and the value specified by AndData. All other bits in Operand are
2849 preserved. The new 8-bit value is returned.
2851 If 8-bit operations are not supported, then ASSERT().
2852 If StartBit is greater than 7, then ASSERT().
2853 If EndBit is greater than 7, then ASSERT().
2854 If EndBit is less than StartBit, then ASSERT().
2855 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
2857 @param Operand Operand on which to perform the bitfield operation.
2858 @param StartBit The ordinal of the least significant bit in the bit field.
2860 @param EndBit The ordinal of the most significant bit in the bit field.
2862 @param AndData The value to AND with the read value from the value.
2864 @return The new 8-bit value.
2878 Reads a bit field from an 8-bit value, performs a bitwise AND followed by a
2879 bitwise OR, and returns the result.
2881 Performs a bitwise AND between the bit field specified by StartBit and EndBit
2882 in Operand and the value specified by AndData, followed by a bitwise
2883 OR with value specified by OrData. All other bits in Operand are
2884 preserved. The new 8-bit value is returned.
2886 If 8-bit operations are not supported, then ASSERT().
2887 If StartBit is greater than 7, then ASSERT().
2888 If EndBit is greater than 7, then ASSERT().
2889 If EndBit is less than StartBit, then ASSERT().
2890 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
2891 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
2893 @param Operand Operand on which to perform the bitfield operation.
2894 @param StartBit The ordinal of the least significant bit in the bit field.
2896 @param EndBit The ordinal of the most significant bit in the bit field.
2898 @param AndData The value to AND with the read value from the value.
2899 @param OrData The value to OR with the result of the AND operation.
2901 @return The new 8-bit value.
2906 BitFieldAndThenOr8 (
2916 Returns a bit field from a 16-bit value.
2918 Returns the bitfield specified by the StartBit and the EndBit from Operand.
2920 If 16-bit operations are not supported, then ASSERT().
2921 If StartBit is greater than 15, then ASSERT().
2922 If EndBit is greater than 15, then ASSERT().
2923 If EndBit is less than StartBit, 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.
2931 @return The bit field read.
2944 Writes a bit field to a 16-bit value, and returns the result.
2946 Writes Value to the bit field specified by the StartBit and the EndBit in
2947 Operand. All other bits in Operand are preserved. The new 16-bit value is
2950 If 16-bit operations are not supported, then ASSERT().
2951 If StartBit is greater than 15, then ASSERT().
2952 If EndBit is greater than 15, then ASSERT().
2953 If EndBit is less than StartBit, then ASSERT().
2954 If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
2956 @param Operand Operand on which to perform the bitfield operation.
2957 @param StartBit The ordinal of the least significant bit in the bit field.
2959 @param EndBit The ordinal of the most significant bit in the bit field.
2961 @param Value New value of the bit field.
2963 @return The new 16-bit value.
2977 Reads a bit field from a 16-bit value, performs a bitwise OR, and returns the
2980 Performs a bitwise OR between the bit field specified by StartBit
2981 and EndBit in Operand and the value specified by OrData. All other bits in
2982 Operand are preserved. The new 16-bit value is returned.
2984 If 16-bit operations are not supported, then ASSERT().
2985 If StartBit is greater than 15, then ASSERT().
2986 If EndBit is greater than 15, then ASSERT().
2987 If EndBit is less than StartBit, then ASSERT().
2988 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
2990 @param Operand Operand on which to perform the bitfield operation.
2991 @param StartBit The ordinal of the least significant bit in the bit field.
2993 @param EndBit The ordinal of the most significant bit in the bit field.
2995 @param OrData The value to OR with the read value from the value
2997 @return The new 16-bit value.
3011 Reads a bit field from a 16-bit value, performs a bitwise AND, and returns
3014 Performs a bitwise AND between the bit field specified by StartBit and EndBit
3015 in Operand and the value specified by AndData. All other bits in Operand are
3016 preserved. The new 16-bit value is returned.
3018 If 16-bit operations are not supported, then ASSERT().
3019 If StartBit is greater than 15, then ASSERT().
3020 If EndBit is greater than 15, then ASSERT().
3021 If EndBit is less than StartBit, then ASSERT().
3022 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
3024 @param Operand Operand on which to perform the bitfield operation.
3025 @param StartBit The ordinal of the least significant bit in the bit field.
3027 @param EndBit The ordinal of the most significant bit in the bit field.
3029 @param AndData The value to AND with the read value from the value
3031 @return The new 16-bit value.
3045 Reads a bit field from a 16-bit value, performs a bitwise AND followed by a
3046 bitwise OR, and returns the result.
3048 Performs a bitwise AND between the bit field specified by StartBit and EndBit
3049 in Operand and the value specified by AndData, followed by a bitwise
3050 OR with value specified by OrData. All other bits in Operand are
3051 preserved. The new 16-bit value is returned.
3053 If 16-bit operations are not supported, then ASSERT().
3054 If StartBit is greater than 15, then ASSERT().
3055 If EndBit is greater than 15, then ASSERT().
3056 If EndBit is less than StartBit, then ASSERT().
3057 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
3058 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
3060 @param Operand Operand on which to perform the bitfield operation.
3061 @param StartBit The ordinal of the least significant bit in the bit field.
3063 @param EndBit The ordinal of the most significant bit in the bit field.
3065 @param AndData The value to AND with the read value from the value.
3066 @param OrData The value to OR with the result of the AND operation.
3068 @return The new 16-bit value.
3073 BitFieldAndThenOr16 (
3083 Returns a bit field from a 32-bit value.
3085 Returns the bitfield specified by the StartBit and the EndBit from Operand.
3087 If 32-bit operations are not supported, then ASSERT().
3088 If StartBit is greater than 31, then ASSERT().
3089 If EndBit is greater than 31, then ASSERT().
3090 If EndBit is less than StartBit, 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.
3098 @return The bit field read.
3111 Writes a bit field to a 32-bit value, and returns the result.
3113 Writes Value to the bit field specified by the StartBit and the EndBit in
3114 Operand. All other bits in Operand are preserved. The new 32-bit value is
3117 If 32-bit operations are not supported, then ASSERT().
3118 If StartBit is greater than 31, then ASSERT().
3119 If EndBit is greater than 31, then ASSERT().
3120 If EndBit is less than StartBit, then ASSERT().
3121 If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
3123 @param Operand Operand on which to perform the bitfield operation.
3124 @param StartBit The ordinal of the least significant bit in the bit field.
3126 @param EndBit The ordinal of the most significant bit in the bit field.
3128 @param Value New value of the bit field.
3130 @return The new 32-bit value.
3144 Reads a bit field from a 32-bit value, performs a bitwise OR, and returns the
3147 Performs a bitwise OR between the bit field specified by StartBit
3148 and EndBit in Operand and the value specified by OrData. All other bits in
3149 Operand are preserved. The new 32-bit value is returned.
3151 If 32-bit operations are not supported, then ASSERT().
3152 If StartBit is greater than 31, then ASSERT().
3153 If EndBit is greater than 31, then ASSERT().
3154 If EndBit is less than StartBit, then ASSERT().
3155 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
3157 @param Operand Operand on which to perform the bitfield operation.
3158 @param StartBit The ordinal of the least significant bit in the bit field.
3160 @param EndBit The ordinal of the most significant bit in the bit field.
3162 @param OrData The value to OR with the read value from the value.
3164 @return The new 32-bit value.
3178 Reads a bit field from a 32-bit value, performs a bitwise AND, and returns
3181 Performs a bitwise AND between the bit field specified by StartBit and EndBit
3182 in Operand and the value specified by AndData. All other bits in Operand are
3183 preserved. The new 32-bit value is returned.
3185 If 32-bit operations are not supported, then ASSERT().
3186 If StartBit is greater than 31, then ASSERT().
3187 If EndBit is greater than 31, then ASSERT().
3188 If EndBit is less than StartBit, then ASSERT().
3189 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
3191 @param Operand Operand on which to perform the bitfield operation.
3192 @param StartBit The ordinal of the least significant bit in the bit field.
3194 @param EndBit The ordinal of the most significant bit in the bit field.
3196 @param AndData The value to AND with the read value from the value
3198 @return The new 32-bit value.
3212 Reads a bit field from a 32-bit value, performs a bitwise AND followed by a
3213 bitwise OR, and returns the result.
3215 Performs a bitwise AND between the bit field specified by StartBit and EndBit
3216 in Operand and the value specified by AndData, followed by a bitwise
3217 OR with value specified by OrData. All other bits in Operand are
3218 preserved. The new 32-bit value is returned.
3220 If 32-bit operations are not supported, then ASSERT().
3221 If StartBit is greater than 31, then ASSERT().
3222 If EndBit is greater than 31, then ASSERT().
3223 If EndBit is less than StartBit, then ASSERT().
3224 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
3225 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
3227 @param Operand Operand on which to perform the bitfield operation.
3228 @param StartBit The ordinal of the least significant bit in the bit field.
3230 @param EndBit The ordinal of the most significant bit in the bit field.
3232 @param AndData The value to AND with the read value from the value.
3233 @param OrData The value to OR with the result of the AND operation.
3235 @return The new 32-bit value.
3240 BitFieldAndThenOr32 (
3250 Returns a bit field from a 64-bit value.
3252 Returns the bitfield specified by the StartBit and the EndBit from Operand.
3254 If 64-bit operations are not supported, then ASSERT().
3255 If StartBit is greater than 63, then ASSERT().
3256 If EndBit is greater than 63, then ASSERT().
3257 If EndBit is less than StartBit, 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.
3265 @return The bit field read.
3278 Writes a bit field to a 64-bit value, and returns the result.
3280 Writes Value to the bit field specified by the StartBit and the EndBit in
3281 Operand. All other bits in Operand are preserved. The new 64-bit value is
3284 If 64-bit operations are not supported, then ASSERT().
3285 If StartBit is greater than 63, then ASSERT().
3286 If EndBit is greater than 63, then ASSERT().
3287 If EndBit is less than StartBit, then ASSERT().
3288 If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
3290 @param Operand Operand on which to perform the bitfield operation.
3291 @param StartBit The ordinal of the least significant bit in the bit field.
3293 @param EndBit The ordinal of the most significant bit in the bit field.
3295 @param Value New value of the bit field.
3297 @return The new 64-bit value.
3311 Reads a bit field from a 64-bit value, performs a bitwise OR, and returns the
3314 Performs a bitwise OR between the bit field specified by StartBit
3315 and EndBit in Operand and the value specified by OrData. All other bits in
3316 Operand are preserved. The new 64-bit value is returned.
3318 If 64-bit operations are not supported, then ASSERT().
3319 If StartBit is greater than 63, then ASSERT().
3320 If EndBit is greater than 63, then ASSERT().
3321 If EndBit is less than StartBit, then ASSERT().
3322 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
3324 @param Operand Operand on which to perform the bitfield operation.
3325 @param StartBit The ordinal of the least significant bit in the bit field.
3327 @param EndBit The ordinal of the most significant bit in the bit field.
3329 @param OrData The value to OR with the read value from the value
3331 @return The new 64-bit value.
3345 Reads a bit field from a 64-bit value, performs a bitwise AND, and returns
3348 Performs a bitwise AND between the bit field specified by StartBit and EndBit
3349 in Operand and the value specified by AndData. All other bits in Operand are
3350 preserved. The new 64-bit value is returned.
3352 If 64-bit operations are not supported, then ASSERT().
3353 If StartBit is greater than 63, then ASSERT().
3354 If EndBit is greater than 63, then ASSERT().
3355 If EndBit is less than StartBit, then ASSERT().
3356 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
3358 @param Operand Operand on which to perform the bitfield operation.
3359 @param StartBit The ordinal of the least significant bit in the bit field.
3361 @param EndBit The ordinal of the most significant bit in the bit field.
3363 @param AndData The value to AND with the read value from the value
3365 @return The new 64-bit value.
3379 Reads a bit field from a 64-bit value, performs a bitwise AND followed by a
3380 bitwise OR, and returns the result.
3382 Performs a bitwise AND between the bit field specified by StartBit and EndBit
3383 in Operand and the value specified by AndData, followed by a bitwise
3384 OR with value specified by OrData. All other bits in Operand are
3385 preserved. The new 64-bit value is returned.
3387 If 64-bit operations are not supported, then ASSERT().
3388 If StartBit is greater than 63, then ASSERT().
3389 If EndBit is greater than 63, then ASSERT().
3390 If EndBit is less than StartBit, then ASSERT().
3391 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
3392 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
3394 @param Operand Operand on which to perform the bitfield operation.
3395 @param StartBit The ordinal of the least significant bit in the bit field.
3397 @param EndBit The ordinal of the most significant bit in the bit field.
3399 @param AndData The value to AND with the read value from the value.
3400 @param OrData The value to OR with the result of the AND operation.
3402 @return The new 64-bit value.
3407 BitFieldAndThenOr64 (
3416 // Base Library Checksum Functions
3420 Returns the sum of all elements in a buffer in unit of UINT8.
3421 During calculation, the carry bits are dropped.
3423 This function calculates the sum of all elements in a buffer
3424 in unit of UINT8. The carry bits in result of addition are dropped.
3425 The result is returned as UINT8. If Length is Zero, then Zero is
3428 If Buffer is NULL, then ASSERT().
3429 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
3431 @param Buffer The pointer to the buffer to carry out the sum operation.
3432 @param Length The size, in bytes, of Buffer.
3434 @return Sum The sum of Buffer with carry bits dropped during additions.
3440 IN CONST UINT8
*Buffer
,
3446 Returns the two's complement checksum of all elements in a buffer
3449 This function first calculates the sum of the 8-bit values in the
3450 buffer specified by Buffer and Length. The carry bits in the result
3451 of addition are dropped. Then, the two's complement of the sum is
3452 returned. If Length is 0, then 0 is returned.
3454 If Buffer is NULL, then ASSERT().
3455 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
3457 @param Buffer The pointer to the buffer to carry out the checksum operation.
3458 @param Length The size, in bytes, of Buffer.
3460 @return Checksum The two's complement checksum of Buffer.
3465 CalculateCheckSum8 (
3466 IN CONST UINT8
*Buffer
,
3472 Returns the sum of all elements in a buffer of 16-bit values. During
3473 calculation, the carry bits are dropped.
3475 This function calculates the sum of the 16-bit values in the buffer
3476 specified by Buffer and Length. The carry bits in result of addition are dropped.
3477 The 16-bit result is returned. If Length is 0, then 0 is returned.
3479 If Buffer is NULL, then ASSERT().
3480 If Buffer is not aligned on a 16-bit boundary, then ASSERT().
3481 If Length is not aligned on a 16-bit boundary, then ASSERT().
3482 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
3484 @param Buffer The pointer to the buffer to carry out the sum operation.
3485 @param Length The size, in bytes, of Buffer.
3487 @return Sum The sum of Buffer with carry bits dropped during additions.
3493 IN CONST UINT16
*Buffer
,
3499 Returns the two's complement checksum of all elements in a buffer of
3502 This function first calculates the sum of the 16-bit values in the buffer
3503 specified by Buffer and Length. The carry bits in the result of addition
3504 are dropped. Then, the two's complement of the sum is returned. If Length
3505 is 0, then 0 is returned.
3507 If Buffer is NULL, then ASSERT().
3508 If Buffer is not aligned on a 16-bit boundary, then ASSERT().
3509 If Length is not aligned on a 16-bit boundary, then ASSERT().
3510 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
3512 @param Buffer The pointer to the buffer to carry out the checksum operation.
3513 @param Length The size, in bytes, of Buffer.
3515 @return Checksum The two's complement checksum of Buffer.
3520 CalculateCheckSum16 (
3521 IN CONST UINT16
*Buffer
,
3527 Returns the sum of all elements in a buffer of 32-bit values. During
3528 calculation, the carry bits are dropped.
3530 This function calculates the sum of the 32-bit values in the buffer
3531 specified by Buffer and Length. The carry bits in result of addition are dropped.
3532 The 32-bit result is returned. If Length is 0, then 0 is returned.
3534 If Buffer is NULL, then ASSERT().
3535 If Buffer is not aligned on a 32-bit boundary, then ASSERT().
3536 If Length is not aligned on a 32-bit boundary, then ASSERT().
3537 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
3539 @param Buffer The pointer to the buffer to carry out the sum operation.
3540 @param Length The size, in bytes, of Buffer.
3542 @return Sum The sum of Buffer with carry bits dropped during additions.
3548 IN CONST UINT32
*Buffer
,
3554 Returns the two's complement checksum of all elements in a buffer of
3557 This function first calculates the sum of the 32-bit values in the buffer
3558 specified by Buffer and Length. The carry bits in the result of addition
3559 are dropped. Then, the two's complement of the sum is returned. If Length
3560 is 0, then 0 is returned.
3562 If Buffer is NULL, then ASSERT().
3563 If Buffer is not aligned on a 32-bit boundary, then ASSERT().
3564 If Length is not aligned on a 32-bit boundary, then ASSERT().
3565 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
3567 @param Buffer The pointer to the buffer to carry out the checksum operation.
3568 @param Length The size, in bytes, of Buffer.
3570 @return Checksum The two's complement checksum of Buffer.
3575 CalculateCheckSum32 (
3576 IN CONST UINT32
*Buffer
,
3582 Returns the sum of all elements in a buffer of 64-bit values. During
3583 calculation, the carry bits are dropped.
3585 This function calculates the sum of the 64-bit values in the buffer
3586 specified by Buffer and Length. The carry bits in result of addition are dropped.
3587 The 64-bit result is returned. If Length is 0, then 0 is returned.
3589 If Buffer is NULL, then ASSERT().
3590 If Buffer is not aligned on a 64-bit boundary, then ASSERT().
3591 If Length is not aligned on a 64-bit boundary, then ASSERT().
3592 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
3594 @param Buffer The pointer to the buffer to carry out the sum operation.
3595 @param Length The size, in bytes, of Buffer.
3597 @return Sum The sum of Buffer with carry bits dropped during additions.
3603 IN CONST UINT64
*Buffer
,
3609 Returns the two's complement checksum of all elements in a buffer of
3612 This function first calculates the sum of the 64-bit values in the buffer
3613 specified by Buffer and Length. The carry bits in the result of addition
3614 are dropped. Then, the two's complement of the sum is returned. If Length
3615 is 0, then 0 is returned.
3617 If Buffer is NULL, then ASSERT().
3618 If Buffer is not aligned on a 64-bit boundary, then ASSERT().
3619 If Length is not aligned on a 64-bit boundary, then ASSERT().
3620 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
3622 @param Buffer The pointer to the buffer to carry out the checksum operation.
3623 @param Length The size, in bytes, of Buffer.
3625 @return Checksum The two's complement checksum of Buffer.
3630 CalculateCheckSum64 (
3631 IN CONST UINT64
*Buffer
,
3637 // Base Library CPU Functions
3641 Function entry point used when a stack switch is requested with SwitchStack()
3643 @param Context1 Context1 parameter passed into SwitchStack().
3644 @param Context2 Context2 parameter passed into SwitchStack().
3649 (EFIAPI
*SWITCH_STACK_ENTRY_POINT
)(
3650 IN VOID
*Context1
, OPTIONAL
3651 IN VOID
*Context2 OPTIONAL
3656 Used to serialize load and store operations.
3658 All loads and stores that proceed calls to this function are guaranteed to be
3659 globally visible when this function returns.
3670 Saves the current CPU context that can be restored with a call to LongJump()
3673 Saves the current CPU context in the buffer specified by JumpBuffer and
3674 returns 0. The initial call to SetJump() must always return 0. Subsequent
3675 calls to LongJump() cause a non-zero value to be returned by SetJump().
3677 If JumpBuffer is NULL, then ASSERT().
3678 For Itanium processors, if JumpBuffer is not aligned on a 16-byte boundary, then ASSERT().
3680 NOTE: The structure BASE_LIBRARY_JUMP_BUFFER is CPU architecture specific.
3681 The same structure must never be used for more than one CPU architecture context.
3682 For example, a BASE_LIBRARY_JUMP_BUFFER allocated by an IA-32 module must never be used from an x64 module.
3683 SetJump()/LongJump() is not currently supported for the EBC processor type.
3685 @param JumpBuffer A pointer to CPU context buffer.
3687 @retval 0 Indicates a return from SetJump().
3693 OUT BASE_LIBRARY_JUMP_BUFFER
*JumpBuffer
3698 Restores the CPU context that was saved with SetJump().
3700 Restores the CPU context from the buffer specified by JumpBuffer. This
3701 function never returns to the caller. Instead is resumes execution based on
3702 the state of JumpBuffer.
3704 If JumpBuffer is NULL, then ASSERT().
3705 For Itanium processors, if JumpBuffer is not aligned on a 16-byte boundary, then ASSERT().
3706 If Value is 0, then ASSERT().
3708 @param JumpBuffer A pointer to CPU context buffer.
3709 @param Value The value to return when the SetJump() context is
3710 restored and must be non-zero.
3716 IN BASE_LIBRARY_JUMP_BUFFER
*JumpBuffer
,
3722 Enables CPU interrupts.
3733 Disables CPU interrupts.
3744 Disables CPU interrupts and returns the interrupt state prior to the disable
3747 @retval TRUE CPU interrupts were enabled on entry to this call.
3748 @retval FALSE CPU interrupts were disabled on entry to this call.
3753 SaveAndDisableInterrupts (
3759 Enables CPU interrupts for the smallest window required to capture any
3765 EnableDisableInterrupts (
3771 Retrieves the current CPU interrupt state.
3773 Returns TRUE if interrupts are currently enabled. Otherwise
3776 @retval TRUE CPU interrupts are enabled.
3777 @retval FALSE CPU interrupts are disabled.
3788 Set the current CPU interrupt state.
3790 Sets the current CPU interrupt state to the state specified by
3791 InterruptState. If InterruptState is TRUE, then interrupts are enabled. If
3792 InterruptState is FALSE, then interrupts are disabled. InterruptState is
3795 @param InterruptState TRUE if interrupts should enabled. FALSE if
3796 interrupts should be disabled.
3798 @return InterruptState
3804 IN BOOLEAN InterruptState
3809 Requests CPU to pause for a short period of time.
3811 Requests CPU to pause for a short period of time. Typically used in MP
3812 systems to prevent memory starvation while waiting for a spin lock.
3823 Transfers control to a function starting with a new stack.
3825 Transfers control to the function specified by EntryPoint using the
3826 new stack specified by NewStack and passing in the parameters specified
3827 by Context1 and Context2. Context1 and Context2 are optional and may
3828 be NULL. The function EntryPoint must never return. This function
3829 supports a variable number of arguments following the NewStack parameter.
3830 These additional arguments are ignored on IA-32, x64, and EBC architectures.
3831 Itanium processors expect one additional parameter of type VOID * that specifies
3832 the new backing store pointer.
3834 If EntryPoint is NULL, then ASSERT().
3835 If NewStack is NULL, then ASSERT().
3837 @param EntryPoint A pointer to function to call with the new stack.
3838 @param Context1 A pointer to the context to pass into the EntryPoint
3840 @param Context2 A pointer to the context to pass into the EntryPoint
3842 @param NewStack A pointer to the new stack to use for the EntryPoint
3844 @param ... This variable argument list is ignored for IA-32, x64, and
3845 EBC architectures. For Itanium processors, this variable
3846 argument list is expected to contain a single parameter of
3847 type VOID * that specifies the new backing store pointer.
3854 IN SWITCH_STACK_ENTRY_POINT EntryPoint
,
3855 IN VOID
*Context1
, OPTIONAL
3856 IN VOID
*Context2
, OPTIONAL
3863 Generates a breakpoint on the CPU.
3865 Generates a breakpoint on the CPU. The breakpoint must be implemented such
3866 that code can resume normal execution after the breakpoint.
3877 Executes an infinite loop.
3879 Forces the CPU to execute an infinite loop. A debugger may be used to skip
3880 past the loop and the code that follows the loop must execute properly. This
3881 implies that the infinite loop must not cause the code that follow it to be
3891 #if defined (MDE_CPU_IPF)
3894 Flush a range of cache lines in the cache coherency domain of the calling
3897 Flushes the cache lines specified by Address and Length. If Address is not aligned
3898 on a cache line boundary, then entire cache line containing Address is flushed.
3899 If Address + Length is not aligned on a cache line boundary, then the entire cache
3900 line containing Address + Length - 1 is flushed. This function may choose to flush
3901 the entire cache if that is more efficient than flushing the specified range. If
3902 Length is 0, the no cache lines are flushed. Address is returned.
3903 This function is only available on Itanium processors.
3905 If Length is greater than (MAX_ADDRESS - Address + 1), then ASSERT().
3907 @param Address The base address of the instruction lines to invalidate. If
3908 the CPU is in a physical addressing mode, then Address is a
3909 physical address. If the CPU is in a virtual addressing mode,
3910 then Address is a virtual address.
3912 @param Length The number of bytes to invalidate from the instruction cache.
3919 AsmFlushCacheRange (
3926 Executes an FC instruction.
3927 Executes an FC instruction on the cache line specified by Address.
3928 The cache line size affected is at least 32-bytes (aligned on a 32-byte boundary).
3929 An implementation may flush a larger region. This function is only available on Itanium processors.
3931 @param Address The Address of cache line to be flushed.
3933 @return The address of FC instruction executed.
3944 Executes an FC.I instruction.
3945 Executes an FC.I instruction on the cache line specified by Address.
3946 The cache line size affected is at least 32-bytes (aligned on a 32-byte boundary).
3947 An implementation may flush a larger region. This function is only available on Itanium processors.
3949 @param Address The Address of cache line to be flushed.
3951 @return The address of the FC.I instruction executed.
3962 Reads the current value of a Processor Identifier Register (CPUID).
3964 Reads and returns the current value of Processor Identifier Register specified by Index.
3965 The Index of largest implemented CPUID (One less than the number of implemented CPUID
3966 registers) is determined by CPUID [3] bits {7:0}.
3967 No parameter checking is performed on Index. If the Index value is beyond the
3968 implemented CPUID register range, a Reserved Register/Field fault may occur. The caller
3969 must either guarantee that Index is valid, or the caller must set up fault handlers to
3970 catch the faults. This function is only available on Itanium processors.
3972 @param Index The 8-bit Processor Identifier Register index to read.
3974 @return The current value of Processor Identifier Register specified by Index.
3985 Reads the current value of 64-bit Processor Status Register (PSR).
3986 This function is only available on Itanium processors.
3988 @return The current value of PSR.
3999 Writes the current value of 64-bit Processor Status Register (PSR).
4001 No parameter checking is performed on Value. All bits of Value corresponding to
4002 reserved fields of PSR must be 0 or a Reserved Register/Field fault may occur.
4003 The caller must either guarantee that Value is valid, or the caller must set up
4004 fault handlers to catch the faults. This function is only available on Itanium processors.
4006 @param Value The 64-bit value to write to PSR.
4008 @return The 64-bit value written to the PSR.
4019 Reads the current value of 64-bit Kernel Register #0 (KR0).
4021 Reads and returns the current value of KR0.
4022 This function is only available on Itanium processors.
4024 @return The current value of KR0.
4035 Reads the current value of 64-bit Kernel Register #1 (KR1).
4037 Reads and returns the current value of KR1.
4038 This function is only available on Itanium processors.
4040 @return The current value of KR1.
4051 Reads the current value of 64-bit Kernel Register #2 (KR2).
4053 Reads and returns the current value of KR2.
4054 This function is only available on Itanium processors.
4056 @return The current value of KR2.
4067 Reads the current value of 64-bit Kernel Register #3 (KR3).
4069 Reads and returns the current value of KR3.
4070 This function is only available on Itanium processors.
4072 @return The current value of KR3.
4083 Reads the current value of 64-bit Kernel Register #4 (KR4).
4085 Reads and returns the current value of KR4.
4086 This function is only available on Itanium processors.
4088 @return The current value of KR4.
4099 Reads the current value of 64-bit Kernel Register #5 (KR5).
4101 Reads and returns the current value of KR5.
4102 This function is only available on Itanium processors.
4104 @return The current value of KR5.
4115 Reads the current value of 64-bit Kernel Register #6 (KR6).
4117 Reads and returns the current value of KR6.
4118 This function is only available on Itanium processors.
4120 @return The current value of KR6.
4131 Reads the current value of 64-bit Kernel Register #7 (KR7).
4133 Reads and returns the current value of KR7.
4134 This function is only available on Itanium processors.
4136 @return The current value of KR7.
4147 Write the current value of 64-bit Kernel Register #0 (KR0).
4149 Writes the current value of KR0. The 64-bit value written to
4150 the KR0 is returned. This function is only available on Itanium processors.
4152 @param Value The 64-bit value to write to KR0.
4154 @return The 64-bit value written to the KR0.
4165 Write the current value of 64-bit Kernel Register #1 (KR1).
4167 Writes the current value of KR1. The 64-bit value written to
4168 the KR1 is returned. This function is only available on Itanium processors.
4170 @param Value The 64-bit value to write to KR1.
4172 @return The 64-bit value written to the KR1.
4183 Write the current value of 64-bit Kernel Register #2 (KR2).
4185 Writes the current value of KR2. The 64-bit value written to
4186 the KR2 is returned. This function is only available on Itanium processors.
4188 @param Value The 64-bit value to write to KR2.
4190 @return The 64-bit value written to the KR2.
4201 Write the current value of 64-bit Kernel Register #3 (KR3).
4203 Writes the current value of KR3. The 64-bit value written to
4204 the KR3 is returned. This function is only available on Itanium processors.
4206 @param Value The 64-bit value to write to KR3.
4208 @return The 64-bit value written to the KR3.
4219 Write the current value of 64-bit Kernel Register #4 (KR4).
4221 Writes the current value of KR4. The 64-bit value written to
4222 the KR4 is returned. This function is only available on Itanium processors.
4224 @param Value The 64-bit value to write to KR4.
4226 @return The 64-bit value written to the KR4.
4237 Write the current value of 64-bit Kernel Register #5 (KR5).
4239 Writes the current value of KR5. The 64-bit value written to
4240 the KR5 is returned. This function is only available on Itanium processors.
4242 @param Value The 64-bit value to write to KR5.
4244 @return The 64-bit value written to the KR5.
4255 Write the current value of 64-bit Kernel Register #6 (KR6).
4257 Writes the current value of KR6. The 64-bit value written to
4258 the KR6 is returned. This function is only available on Itanium processors.
4260 @param Value The 64-bit value to write to KR6.
4262 @return The 64-bit value written to the KR6.
4273 Write the current value of 64-bit Kernel Register #7 (KR7).
4275 Writes the current value of KR7. The 64-bit value written to
4276 the KR7 is returned. This function is only available on Itanium processors.
4278 @param Value The 64-bit value to write to KR7.
4280 @return The 64-bit value written to the KR7.
4291 Reads the current value of Interval Timer Counter Register (ITC).
4293 Reads and returns the current value of ITC.
4294 This function is only available on Itanium processors.
4296 @return The current value of ITC.
4307 Reads the current value of Interval Timer Vector Register (ITV).
4309 Reads and returns the current value of ITV.
4310 This function is only available on Itanium processors.
4312 @return The current value of ITV.
4323 Reads the current value of Interval Timer Match Register (ITM).
4325 Reads and returns the current value of ITM.
4326 This function is only available on Itanium processors.
4328 @return The current value of ITM.
4338 Writes the current value of 64-bit Interval Timer Counter Register (ITC).
4340 Writes the current value of ITC. The 64-bit value written to the ITC is returned.
4341 This function is only available on Itanium processors.
4343 @param Value The 64-bit value to write to ITC.
4345 @return The 64-bit value written to the ITC.
4356 Writes the current value of 64-bit Interval Timer Match Register (ITM).
4358 Writes the current value of ITM. The 64-bit value written to the ITM is returned.
4359 This function is only available on Itanium processors.
4361 @param Value The 64-bit value to write to ITM.
4363 @return The 64-bit value written to the ITM.
4374 Writes the current value of 64-bit Interval Timer Vector Register (ITV).
4376 Writes the current value of ITV. The 64-bit value written to the ITV is returned.
4377 No parameter checking is performed on Value. All bits of Value corresponding to
4378 reserved fields of ITV must be 0 or a Reserved Register/Field fault may occur.
4379 The caller must either guarantee that Value is valid, or the caller must set up
4380 fault handlers to catch the faults.
4381 This function is only available on Itanium processors.
4383 @param Value The 64-bit value to write to ITV.
4385 @return The 64-bit value written to the ITV.
4396 Reads the current value of Default Control Register (DCR).
4398 Reads and returns the current value of DCR. This function is only available on Itanium processors.
4400 @return The current value of DCR.
4411 Reads the current value of Interruption Vector Address Register (IVA).
4413 Reads and returns the current value of IVA. This function is only available on Itanium processors.
4415 @return The current value of IVA.
4425 Reads the current value of Page Table Address Register (PTA).
4427 Reads and returns the current value of PTA. This function is only available on Itanium processors.
4429 @return The current value of PTA.
4440 Writes the current value of 64-bit Default Control Register (DCR).
4442 Writes the current value of DCR. The 64-bit value written to the DCR is returned.
4443 No parameter checking is performed on Value. All bits of Value corresponding to
4444 reserved fields of DCR must be 0 or a Reserved Register/Field fault may occur.
4445 The caller must either guarantee that Value is valid, or the caller must set up
4446 fault handlers to catch the faults.
4447 This function is only available on Itanium processors.
4449 @param Value The 64-bit value to write to DCR.
4451 @return The 64-bit value written to the DCR.
4462 Writes the current value of 64-bit Interruption Vector Address Register (IVA).
4464 Writes the current value of IVA. The 64-bit value written to the IVA is returned.
4465 The size of vector table is 32 K bytes and is 32 K bytes aligned
4466 the low 15 bits of Value is ignored when written.
4467 This function is only available on Itanium processors.
4469 @param Value The 64-bit value to write to IVA.
4471 @return The 64-bit value written to the IVA.
4482 Writes the current value of 64-bit Page Table Address Register (PTA).
4484 Writes the current value of PTA. The 64-bit value written to the PTA is returned.
4485 No parameter checking is performed on Value. All bits of Value corresponding to
4486 reserved fields of DCR must be 0 or a Reserved Register/Field fault may occur.
4487 The caller must either guarantee that Value is valid, or the caller must set up
4488 fault handlers to catch the faults.
4489 This function is only available on Itanium processors.
4491 @param Value The 64-bit value to write to PTA.
4493 @return The 64-bit value written to the PTA.
4503 Reads the current value of Local Interrupt ID Register (LID).
4505 Reads and returns the current value of LID. This function is only available on Itanium processors.
4507 @return The current value of LID.
4518 Reads the current value of External Interrupt Vector Register (IVR).
4520 Reads and returns the current value of IVR. This function is only available on Itanium processors.
4522 @return The current value of IVR.
4533 Reads the current value of Task Priority Register (TPR).
4535 Reads and returns the current value of TPR. This function is only available on Itanium processors.
4537 @return The current value of TPR.
4548 Reads the current value of External Interrupt Request Register #0 (IRR0).
4550 Reads and returns the current value of IRR0. This function is only available on Itanium processors.
4552 @return The current value of IRR0.
4563 Reads the current value of External Interrupt Request Register #1 (IRR1).
4565 Reads and returns the current value of IRR1. This function is only available on Itanium processors.
4567 @return The current value of IRR1.
4578 Reads the current value of External Interrupt Request Register #2 (IRR2).
4580 Reads and returns the current value of IRR2. This function is only available on Itanium processors.
4582 @return The current value of IRR2.
4593 Reads the current value of External Interrupt Request Register #3 (IRR3).
4595 Reads and returns the current value of IRR3. This function is only available on Itanium processors.
4597 @return The current value of IRR3.
4608 Reads the current value of Performance Monitor Vector Register (PMV).
4610 Reads and returns the current value of PMV. This function is only available on Itanium processors.
4612 @return The current value of PMV.
4623 Reads the current value of Corrected Machine Check Vector Register (CMCV).
4625 Reads and returns the current value of CMCV. This function is only available on Itanium processors.
4627 @return The current value of CMCV.
4638 Reads the current value of Local Redirection Register #0 (LRR0).
4640 Reads and returns the current value of LRR0. This function is only available on Itanium processors.
4642 @return The current value of LRR0.
4653 Reads the current value of Local Redirection Register #1 (LRR1).
4655 Reads and returns the current value of LRR1. This function is only available on Itanium processors.
4657 @return The current value of LRR1.
4668 Writes the current value of 64-bit Page Local Interrupt ID Register (LID).
4670 Writes the current value of LID. The 64-bit value written to the LID is returned.
4671 No parameter checking is performed on Value. All bits of Value corresponding to
4672 reserved fields of LID must be 0 or a Reserved Register/Field fault may occur.
4673 The caller must either guarantee that Value is valid, or the caller must set up
4674 fault handlers to catch the faults.
4675 This function is only available on Itanium processors.
4677 @param Value The 64-bit value to write to LID.
4679 @return The 64-bit value written to the LID.
4690 Writes the current value of 64-bit Task Priority Register (TPR).
4692 Writes the current value of TPR. The 64-bit value written to the TPR is returned.
4693 No parameter checking is performed on Value. All bits of Value corresponding to
4694 reserved fields of TPR must be 0 or a Reserved Register/Field fault may occur.
4695 The caller must either guarantee that Value is valid, or the caller must set up
4696 fault handlers to catch the faults.
4697 This function is only available on Itanium processors.
4699 @param Value The 64-bit value to write to TPR.
4701 @return The 64-bit value written to the TPR.
4712 Performs a write operation on End OF External Interrupt Register (EOI).
4714 Writes a value of 0 to the EOI Register. This function is only available on Itanium processors.
4725 Writes the current value of 64-bit Performance Monitor Vector Register (PMV).
4727 Writes the current value of PMV. The 64-bit value written to the PMV is returned.
4728 No parameter checking is performed on Value. All bits of Value corresponding
4729 to reserved fields of PMV must be 0 or a Reserved Register/Field fault may occur.
4730 The caller must either guarantee that Value is valid, or the caller must set up
4731 fault handlers to catch the faults.
4732 This function is only available on Itanium processors.
4734 @param Value The 64-bit value to write to PMV.
4736 @return The 64-bit value written to the PMV.
4747 Writes the current value of 64-bit Corrected Machine Check Vector Register (CMCV).
4749 Writes the current value of CMCV. The 64-bit value written to the CMCV is returned.
4750 No parameter checking is performed on Value. All bits of Value corresponding
4751 to reserved fields of CMCV must be 0 or a Reserved Register/Field fault may occur.
4752 The caller must either guarantee that Value is valid, or the caller must set up
4753 fault handlers to catch the faults.
4754 This function is only available on Itanium processors.
4756 @param Value The 64-bit value to write to CMCV.
4758 @return The 64-bit value written to the CMCV.
4769 Writes the current value of 64-bit Local Redirection Register #0 (LRR0).
4771 Writes the current value of LRR0. The 64-bit value written to the LRR0 is returned.
4772 No parameter checking is performed on Value. All bits of Value corresponding
4773 to reserved fields of LRR0 must be 0 or a Reserved Register/Field fault may occur.
4774 The caller must either guarantee that Value is valid, or the caller must set up
4775 fault handlers to catch the faults.
4776 This function is only available on Itanium processors.
4778 @param Value The 64-bit value to write to LRR0.
4780 @return The 64-bit value written to the LRR0.
4791 Writes the current value of 64-bit Local Redirection Register #1 (LRR1).
4793 Writes the current value of LRR1. The 64-bit value written to the LRR1 is returned.
4794 No parameter checking is performed on Value. All bits of Value corresponding
4795 to reserved fields of LRR1 must be 0 or a Reserved Register/Field fault may occur.
4796 The caller must either guarantee that Value is valid, or the caller must
4797 set up fault handlers to catch the faults.
4798 This function is only available on Itanium processors.
4800 @param Value The 64-bit value to write to LRR1.
4802 @return The 64-bit value written to the LRR1.
4813 Reads the current value of Instruction Breakpoint Register (IBR).
4815 The Instruction Breakpoint Registers are used in pairs. The even numbered
4816 registers contain breakpoint addresses, and the odd numbered registers contain
4817 breakpoint mask conditions. At least four instruction registers pairs are implemented
4818 on all processor models. Implemented registers are contiguous starting with
4819 register 0. No parameter checking is performed on Index, and if the Index value
4820 is beyond the implemented IBR register range, a Reserved Register/Field fault may
4821 occur. The caller must either guarantee that Index is valid, or the caller must
4822 set up fault handlers to catch the faults.
4823 This function is only available on Itanium processors.
4825 @param Index The 8-bit Instruction Breakpoint Register index to read.
4827 @return The current value of Instruction Breakpoint Register specified by Index.
4838 Reads the current value of Data Breakpoint Register (DBR).
4840 The Data Breakpoint Registers are used in pairs. The even numbered registers
4841 contain breakpoint addresses, and odd numbered registers contain breakpoint
4842 mask conditions. At least four data registers pairs are implemented on all processor
4843 models. Implemented registers are contiguous starting with register 0.
4844 No parameter checking is performed on Index. If the Index value is beyond
4845 the implemented DBR register range, a Reserved Register/Field fault may occur.
4846 The caller must either guarantee that Index is valid, or the caller must set up
4847 fault handlers to catch the faults.
4848 This function is only available on Itanium processors.
4850 @param Index The 8-bit Data Breakpoint Register index to read.
4852 @return The current value of Data Breakpoint Register specified by Index.
4863 Reads the current value of Performance Monitor Configuration Register (PMC).
4865 All processor implementations provide at least four performance counters
4866 (PMC/PMD [4]...PMC/PMD [7] pairs), and four performance monitor counter overflow
4867 status registers (PMC [0]... PMC [3]). Processor implementations may provide
4868 additional implementation-dependent PMC and PMD to increase the number of
4869 'generic' performance counters (PMC/PMD pairs). The remainder of PMC and PMD
4870 register set is implementation dependent. No parameter checking is performed
4871 on Index. If the Index value is beyond the implemented PMC register range,
4872 zero value will be returned.
4873 This function is only available on Itanium processors.
4875 @param Index The 8-bit Performance Monitor Configuration Register index to read.
4877 @return The current value of Performance Monitor Configuration Register
4889 Reads the current value of Performance Monitor Data Register (PMD).
4891 All processor implementations provide at least 4 performance counters
4892 (PMC/PMD [4]...PMC/PMD [7] pairs), and 4 performance monitor counter
4893 overflow status registers (PMC [0]... PMC [3]). Processor implementations may
4894 provide additional implementation-dependent PMC and PMD to increase the number
4895 of 'generic' performance counters (PMC/PMD pairs). The remainder of PMC and PMD
4896 register set is implementation dependent. No parameter checking is performed
4897 on Index. If the Index value is beyond the implemented PMD register range,
4898 zero value will be returned.
4899 This function is only available on Itanium processors.
4901 @param Index The 8-bit Performance Monitor Data Register index to read.
4903 @return The current value of Performance Monitor Data Register specified by Index.
4914 Writes the current value of 64-bit Instruction Breakpoint Register (IBR).
4916 Writes current value of Instruction Breakpoint Register specified by Index.
4917 The Instruction Breakpoint Registers are used in pairs. The even numbered
4918 registers contain breakpoint addresses, and 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. 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 write.
4928 @param Value The 64-bit value to write to IBR.
4930 @return The 64-bit value written to the IBR.
4942 Writes the current value of 64-bit Data Breakpoint Register (DBR).
4944 Writes current value of Data Breakpoint Register specified by Index.
4945 The Data Breakpoint Registers are used in pairs. The even numbered registers
4946 contain breakpoint addresses, and odd numbered registers contain breakpoint
4947 mask conditions. At least four data registers pairs are implemented on all processor
4948 models. Implemented registers are contiguous starting with register 0. No parameter
4949 checking is performed on Index. If the Index value is beyond the implemented
4950 DBR register range, a Reserved Register/Field fault may occur. The caller must
4951 either guarantee that Index is valid, or the caller must set up fault handlers to
4953 This function is only available on Itanium processors.
4955 @param Index The 8-bit Data Breakpoint Register index to write.
4956 @param Value The 64-bit value to write to DBR.
4958 @return The 64-bit value written to the DBR.
4970 Writes the current value of 64-bit Performance Monitor Configuration Register (PMC).
4972 Writes current value of Performance Monitor Configuration Register specified by Index.
4973 All processor implementations provide at least four performance counters
4974 (PMC/PMD [4]...PMC/PMD [7] pairs), and four performance monitor counter overflow status
4975 registers (PMC [0]... PMC [3]). Processor implementations may provide additional
4976 implementation-dependent PMC and PMD to increase the number of 'generic' performance
4977 counters (PMC/PMD pairs). The remainder of PMC and PMD register set is implementation
4978 dependent. No parameter checking is performed on Index. If the Index value is
4979 beyond the implemented PMC register range, the write is ignored.
4980 This function is only available on Itanium processors.
4982 @param Index The 8-bit Performance Monitor Configuration Register index to write.
4983 @param Value The 64-bit value to write to PMC.
4985 @return The 64-bit value written to the PMC.
4997 Writes the current value of 64-bit Performance Monitor Data Register (PMD).
4999 Writes current value of Performance Monitor Data Register specified by Index.
5000 All processor implementations provide at least four performance counters
5001 (PMC/PMD [4]...PMC/PMD [7] pairs), and four performance monitor counter overflow
5002 status registers (PMC [0]... PMC [3]). Processor implementations may provide
5003 additional implementation-dependent PMC and PMD to increase the number of 'generic'
5004 performance counters (PMC/PMD pairs). The remainder of PMC and PMD register set
5005 is implementation dependent. No parameter checking is performed on Index. If the
5006 Index value is beyond the implemented PMD register range, the write is ignored.
5007 This function is only available on Itanium processors.
5009 @param Index The 8-bit Performance Monitor Data Register index to write.
5010 @param Value The 64-bit value to write to PMD.
5012 @return The 64-bit value written to the PMD.
5024 Reads the current value of 64-bit Global Pointer (GP).
5026 Reads and returns the current value of GP.
5027 This function is only available on Itanium processors.
5029 @return The current value of GP.
5040 Write the current value of 64-bit Global Pointer (GP).
5042 Writes the current value of GP. The 64-bit value written to the GP is returned.
5043 No parameter checking is performed on Value.
5044 This function is only available on Itanium processors.
5046 @param Value The 64-bit value to write to GP.
5048 @return The 64-bit value written to the GP.
5059 Reads the current value of 64-bit Stack Pointer (SP).
5061 Reads and returns the current value of SP.
5062 This function is only available on Itanium processors.
5064 @return The current value of SP.
5075 /// Valid Index value for AsmReadControlRegister().
5077 #define IPF_CONTROL_REGISTER_DCR 0
5078 #define IPF_CONTROL_REGISTER_ITM 1
5079 #define IPF_CONTROL_REGISTER_IVA 2
5080 #define IPF_CONTROL_REGISTER_PTA 8
5081 #define IPF_CONTROL_REGISTER_IPSR 16
5082 #define IPF_CONTROL_REGISTER_ISR 17
5083 #define IPF_CONTROL_REGISTER_IIP 19
5084 #define IPF_CONTROL_REGISTER_IFA 20
5085 #define IPF_CONTROL_REGISTER_ITIR 21
5086 #define IPF_CONTROL_REGISTER_IIPA 22
5087 #define IPF_CONTROL_REGISTER_IFS 23
5088 #define IPF_CONTROL_REGISTER_IIM 24
5089 #define IPF_CONTROL_REGISTER_IHA 25
5090 #define IPF_CONTROL_REGISTER_LID 64
5091 #define IPF_CONTROL_REGISTER_IVR 65
5092 #define IPF_CONTROL_REGISTER_TPR 66
5093 #define IPF_CONTROL_REGISTER_EOI 67
5094 #define IPF_CONTROL_REGISTER_IRR0 68
5095 #define IPF_CONTROL_REGISTER_IRR1 69
5096 #define IPF_CONTROL_REGISTER_IRR2 70
5097 #define IPF_CONTROL_REGISTER_IRR3 71
5098 #define IPF_CONTROL_REGISTER_ITV 72
5099 #define IPF_CONTROL_REGISTER_PMV 73
5100 #define IPF_CONTROL_REGISTER_CMCV 74
5101 #define IPF_CONTROL_REGISTER_LRR0 80
5102 #define IPF_CONTROL_REGISTER_LRR1 81
5105 Reads a 64-bit control register.
5107 Reads and returns the control register specified by Index. The valid Index valued
5108 are defined above in "Related Definitions".
5109 If Index is invalid then 0xFFFFFFFFFFFFFFFF is returned. This function is only
5110 available on Itanium processors.
5112 @param Index The index of the control register to read.
5114 @return The control register specified by Index.
5119 AsmReadControlRegister (
5125 /// Valid Index value for AsmReadApplicationRegister().
5127 #define IPF_APPLICATION_REGISTER_K0 0
5128 #define IPF_APPLICATION_REGISTER_K1 1
5129 #define IPF_APPLICATION_REGISTER_K2 2
5130 #define IPF_APPLICATION_REGISTER_K3 3
5131 #define IPF_APPLICATION_REGISTER_K4 4
5132 #define IPF_APPLICATION_REGISTER_K5 5
5133 #define IPF_APPLICATION_REGISTER_K6 6
5134 #define IPF_APPLICATION_REGISTER_K7 7
5135 #define IPF_APPLICATION_REGISTER_RSC 16
5136 #define IPF_APPLICATION_REGISTER_BSP 17
5137 #define IPF_APPLICATION_REGISTER_BSPSTORE 18
5138 #define IPF_APPLICATION_REGISTER_RNAT 19
5139 #define IPF_APPLICATION_REGISTER_FCR 21
5140 #define IPF_APPLICATION_REGISTER_EFLAG 24
5141 #define IPF_APPLICATION_REGISTER_CSD 25
5142 #define IPF_APPLICATION_REGISTER_SSD 26
5143 #define IPF_APPLICATION_REGISTER_CFLG 27
5144 #define IPF_APPLICATION_REGISTER_FSR 28
5145 #define IPF_APPLICATION_REGISTER_FIR 29
5146 #define IPF_APPLICATION_REGISTER_FDR 30
5147 #define IPF_APPLICATION_REGISTER_CCV 32
5148 #define IPF_APPLICATION_REGISTER_UNAT 36
5149 #define IPF_APPLICATION_REGISTER_FPSR 40
5150 #define IPF_APPLICATION_REGISTER_ITC 44
5151 #define IPF_APPLICATION_REGISTER_PFS 64
5152 #define IPF_APPLICATION_REGISTER_LC 65
5153 #define IPF_APPLICATION_REGISTER_EC 66
5156 Reads a 64-bit application register.
5158 Reads and returns the application register specified by Index. The valid Index
5159 valued are defined above in "Related Definitions".
5160 If Index is invalid then 0xFFFFFFFFFFFFFFFF is returned. This function is only
5161 available on Itanium processors.
5163 @param Index The index of the application register to read.
5165 @return The application register specified by Index.
5170 AsmReadApplicationRegister (
5176 Reads the current value of a Machine Specific Register (MSR).
5178 Reads and returns the current value of the Machine Specific Register specified by Index. No
5179 parameter checking is performed on Index, and if the Index value is beyond the implemented MSR
5180 register range, a Reserved Register/Field fault may occur. The caller must either guarantee that
5181 Index is valid, or the caller must set up fault handlers to catch the faults. This function is
5182 only available on Itanium processors.
5184 @param Index The 8-bit Machine Specific Register index to read.
5186 @return The current value of the Machine Specific Register specified by Index.
5197 Writes the current value of a Machine Specific Register (MSR).
5199 Writes Value to the Machine Specific Register specified by Index. Value is returned. No
5200 parameter checking is performed on Index, and if the Index value is beyond the implemented MSR
5201 register range, a Reserved Register/Field fault may occur. The caller must either guarantee that
5202 Index is valid, or the caller must set up fault handlers to catch the faults. This function is
5203 only available on Itanium processors.
5205 @param Index The 8-bit Machine Specific Register index to write.
5206 @param Value The 64-bit value to write to the Machine Specific Register.
5208 @return The 64-bit value to write to the Machine Specific Register.
5220 Determines if the CPU is currently executing in virtual, physical, or mixed mode.
5222 Determines the current execution mode of the CPU.
5223 If the CPU is in virtual mode(PSR.RT=1, PSR.DT=1, PSR.IT=1), then 1 is returned.
5224 If the CPU is in physical mode(PSR.RT=0, PSR.DT=0, PSR.IT=0), then 0 is returned.
5225 If the CPU is not in physical mode or virtual mode, then it is in mixed mode,
5227 This function is only available on Itanium processors.
5229 @retval 1 The CPU is in virtual mode.
5230 @retval 0 The CPU is in physical mode.
5231 @retval -1 The CPU is in mixed mode.
5242 Makes a PAL procedure call.
5244 This is a wrapper function to make a PAL procedure call. Based on the Index
5245 value this API will make static or stacked PAL call. The following table
5246 describes the usage of PAL Procedure Index Assignment. Architected procedures
5247 may be designated as required or optional. If a PAL procedure is specified
5248 as optional, a unique return code of 0xFFFFFFFFFFFFFFFF is returned in the
5249 Status field of the PAL_CALL_RETURN structure.
5250 This indicates that the procedure is not present in this PAL implementation.
5251 It is the caller's responsibility to check for this return code after calling
5252 any optional PAL procedure.
5253 No parameter checking is performed on the 5 input parameters, but there are
5254 some common rules that the caller should follow when making a PAL call. Any
5255 address passed to PAL as buffers for return parameters must be 8-byte aligned.
5256 Unaligned addresses may cause undefined results. For those parameters defined
5257 as reserved or some fields defined as reserved must be zero filled or the invalid
5258 argument return value may be returned or undefined result may occur during the
5259 execution of the procedure. If the PalEntryPoint does not point to a valid
5260 PAL entry point then the system behavior is undefined. This function is only
5261 available on Itanium processors.
5263 @param PalEntryPoint The PAL procedure calls entry point.
5264 @param Index The PAL procedure Index number.
5265 @param Arg2 The 2nd parameter for PAL procedure calls.
5266 @param Arg3 The 3rd parameter for PAL procedure calls.
5267 @param Arg4 The 4th parameter for PAL procedure calls.
5269 @return structure returned from the PAL Call procedure, including the status and return value.
5275 IN UINT64 PalEntryPoint
,
5283 #if defined (MDE_CPU_IA32) || defined (MDE_CPU_X64)
5285 /// IA32 and x64 Specific Functions.
5286 /// Byte packed structure for 16-bit Real Mode EFLAGS.
5290 UINT32 CF
:1; ///< Carry Flag.
5291 UINT32 Reserved_0
:1; ///< Reserved.
5292 UINT32 PF
:1; ///< Parity Flag.
5293 UINT32 Reserved_1
:1; ///< Reserved.
5294 UINT32 AF
:1; ///< Auxiliary Carry Flag.
5295 UINT32 Reserved_2
:1; ///< Reserved.
5296 UINT32 ZF
:1; ///< Zero Flag.
5297 UINT32 SF
:1; ///< Sign Flag.
5298 UINT32 TF
:1; ///< Trap Flag.
5299 UINT32 IF
:1; ///< Interrupt Enable Flag.
5300 UINT32 DF
:1; ///< Direction Flag.
5301 UINT32 OF
:1; ///< Overflow Flag.
5302 UINT32 IOPL
:2; ///< I/O Privilege Level.
5303 UINT32 NT
:1; ///< Nested Task.
5304 UINT32 Reserved_3
:1; ///< Reserved.
5310 /// Byte packed structure for EFLAGS/RFLAGS.
5311 /// 32-bits on IA-32.
5312 /// 64-bits on x64. The upper 32-bits on x64 are reserved.
5316 UINT32 CF
:1; ///< Carry Flag.
5317 UINT32 Reserved_0
:1; ///< Reserved.
5318 UINT32 PF
:1; ///< Parity Flag.
5319 UINT32 Reserved_1
:1; ///< Reserved.
5320 UINT32 AF
:1; ///< Auxiliary Carry Flag.
5321 UINT32 Reserved_2
:1; ///< Reserved.
5322 UINT32 ZF
:1; ///< Zero Flag.
5323 UINT32 SF
:1; ///< Sign Flag.
5324 UINT32 TF
:1; ///< Trap Flag.
5325 UINT32 IF
:1; ///< Interrupt Enable Flag.
5326 UINT32 DF
:1; ///< Direction Flag.
5327 UINT32 OF
:1; ///< Overflow Flag.
5328 UINT32 IOPL
:2; ///< I/O Privilege Level.
5329 UINT32 NT
:1; ///< Nested Task.
5330 UINT32 Reserved_3
:1; ///< Reserved.
5331 UINT32 RF
:1; ///< Resume Flag.
5332 UINT32 VM
:1; ///< Virtual 8086 Mode.
5333 UINT32 AC
:1; ///< Alignment Check.
5334 UINT32 VIF
:1; ///< Virtual Interrupt Flag.
5335 UINT32 VIP
:1; ///< Virtual Interrupt Pending.
5336 UINT32 ID
:1; ///< ID Flag.
5337 UINT32 Reserved_4
:10; ///< Reserved.
5343 /// Byte packed structure for Control Register 0 (CR0).
5344 /// 32-bits on IA-32.
5345 /// 64-bits on x64. The upper 32-bits on x64 are reserved.
5349 UINT32 PE
:1; ///< Protection Enable.
5350 UINT32 MP
:1; ///< Monitor Coprocessor.
5351 UINT32 EM
:1; ///< Emulation.
5352 UINT32 TS
:1; ///< Task Switched.
5353 UINT32 ET
:1; ///< Extension Type.
5354 UINT32 NE
:1; ///< Numeric Error.
5355 UINT32 Reserved_0
:10; ///< Reserved.
5356 UINT32 WP
:1; ///< Write Protect.
5357 UINT32 Reserved_1
:1; ///< Reserved.
5358 UINT32 AM
:1; ///< Alignment Mask.
5359 UINT32 Reserved_2
:10; ///< Reserved.
5360 UINT32 NW
:1; ///< Mot Write-through.
5361 UINT32 CD
:1; ///< Cache Disable.
5362 UINT32 PG
:1; ///< Paging.
5368 /// Byte packed structure for Control Register 4 (CR4).
5369 /// 32-bits on IA-32.
5370 /// 64-bits on x64. The upper 32-bits on x64 are reserved.
5374 UINT32 VME
:1; ///< Virtual-8086 Mode Extensions.
5375 UINT32 PVI
:1; ///< Protected-Mode Virtual Interrupts.
5376 UINT32 TSD
:1; ///< Time Stamp Disable.
5377 UINT32 DE
:1; ///< Debugging Extensions.
5378 UINT32 PSE
:1; ///< Page Size Extensions.
5379 UINT32 PAE
:1; ///< Physical Address Extension.
5380 UINT32 MCE
:1; ///< Machine Check Enable.
5381 UINT32 PGE
:1; ///< Page Global Enable.
5382 UINT32 PCE
:1; ///< Performance Monitoring Counter
5384 UINT32 OSFXSR
:1; ///< Operating System Support for
5385 ///< FXSAVE and FXRSTOR instructions
5386 UINT32 OSXMMEXCPT
:1; ///< Operating System Support for
5387 ///< Unmasked SIMD Floating Point
5389 UINT32 Reserved_0
:2; ///< Reserved.
5390 UINT32 VMXE
:1; ///< VMX Enable
5391 UINT32 Reserved_1
:18; ///< Reserved.
5397 /// Byte packed structure for a segment descriptor in a GDT/LDT.
5416 } IA32_SEGMENT_DESCRIPTOR
;
5419 /// Byte packed structure for an IDTR, GDTR, LDTR descriptor.
5428 #define IA32_IDT_GATE_TYPE_TASK 0x85
5429 #define IA32_IDT_GATE_TYPE_INTERRUPT_16 0x86
5430 #define IA32_IDT_GATE_TYPE_TRAP_16 0x87
5431 #define IA32_IDT_GATE_TYPE_INTERRUPT_32 0x8E
5432 #define IA32_IDT_GATE_TYPE_TRAP_32 0x8F
5435 #if defined (MDE_CPU_IA32)
5437 /// Byte packed structure for an IA-32 Interrupt Gate Descriptor.
5441 UINT32 OffsetLow
:16; ///< Offset bits 15..0.
5442 UINT32 Selector
:16; ///< Selector.
5443 UINT32 Reserved_0
:8; ///< Reserved.
5444 UINT32 GateType
:8; ///< Gate Type. See #defines above.
5445 UINT32 OffsetHigh
:16; ///< Offset bits 31..16.
5448 } IA32_IDT_GATE_DESCRIPTOR
;
5452 #if defined (MDE_CPU_X64)
5454 /// Byte packed structure for an x64 Interrupt Gate Descriptor.
5458 UINT32 OffsetLow
:16; ///< Offset bits 15..0.
5459 UINT32 Selector
:16; ///< Selector.
5460 UINT32 Reserved_0
:8; ///< Reserved.
5461 UINT32 GateType
:8; ///< Gate Type. See #defines above.
5462 UINT32 OffsetHigh
:16; ///< Offset bits 31..16.
5463 UINT32 OffsetUpper
:32; ///< Offset bits 63..32.
5464 UINT32 Reserved_1
:32; ///< Reserved.
5470 } IA32_IDT_GATE_DESCRIPTOR
;
5475 /// Byte packed structure for an FP/SSE/SSE2 context.
5482 /// Structures for the 16-bit real mode thunks.
5535 IA32_EFLAGS32 EFLAGS
;
5545 } IA32_REGISTER_SET
;
5548 /// Byte packed structure for an 16-bit real mode thunks.
5551 IA32_REGISTER_SET
*RealModeState
;
5552 VOID
*RealModeBuffer
;
5553 UINT32 RealModeBufferSize
;
5554 UINT32 ThunkAttributes
;
5557 #define THUNK_ATTRIBUTE_BIG_REAL_MODE 0x00000001
5558 #define THUNK_ATTRIBUTE_DISABLE_A20_MASK_INT_15 0x00000002
5559 #define THUNK_ATTRIBUTE_DISABLE_A20_MASK_KBD_CTRL 0x00000004
5562 Retrieves CPUID information.
5564 Executes the CPUID instruction with EAX set to the value specified by Index.
5565 This function always returns Index.
5566 If Eax is not NULL, then the value of EAX after CPUID is returned in Eax.
5567 If Ebx is not NULL, then the value of EBX after CPUID is returned in Ebx.
5568 If Ecx is not NULL, then the value of ECX after CPUID is returned in Ecx.
5569 If Edx is not NULL, then the value of EDX after CPUID is returned in Edx.
5570 This function is only available on IA-32 and x64.
5572 @param Index The 32-bit value to load into EAX prior to invoking the CPUID
5574 @param Eax The pointer to the 32-bit EAX value returned by the CPUID
5575 instruction. This is an optional parameter that may be NULL.
5576 @param Ebx The pointer to the 32-bit EBX value returned by the CPUID
5577 instruction. This is an optional parameter that may be NULL.
5578 @param Ecx The pointer to the 32-bit ECX value returned by the CPUID
5579 instruction. This is an optional parameter that may be NULL.
5580 @param Edx The pointer to the 32-bit EDX value returned by the CPUID
5581 instruction. This is an optional parameter that may be NULL.
5590 OUT UINT32
*Eax
, OPTIONAL
5591 OUT UINT32
*Ebx
, OPTIONAL
5592 OUT UINT32
*Ecx
, OPTIONAL
5593 OUT UINT32
*Edx OPTIONAL
5598 Retrieves CPUID information using an extended leaf identifier.
5600 Executes the CPUID instruction with EAX set to the value specified by Index
5601 and ECX set to the value specified by SubIndex. This function always returns
5602 Index. This function is only available on IA-32 and x64.
5604 If Eax is not NULL, then the value of EAX after CPUID is returned in Eax.
5605 If Ebx is not NULL, then the value of EBX after CPUID is returned in Ebx.
5606 If Ecx is not NULL, then the value of ECX after CPUID is returned in Ecx.
5607 If Edx is not NULL, then the value of EDX after CPUID is returned in Edx.
5609 @param Index The 32-bit value to load into EAX prior to invoking the
5611 @param SubIndex The 32-bit value to load into ECX prior to invoking the
5613 @param Eax The pointer to the 32-bit EAX value returned by the CPUID
5614 instruction. This is an optional parameter that may be
5616 @param Ebx The pointer to the 32-bit EBX value returned by the CPUID
5617 instruction. This is an optional parameter that may be
5619 @param Ecx The pointer to the 32-bit ECX value returned by the CPUID
5620 instruction. This is an optional parameter that may be
5622 @param Edx The pointer to the 32-bit EDX value returned by the CPUID
5623 instruction. This is an optional parameter that may be
5634 OUT UINT32
*Eax
, OPTIONAL
5635 OUT UINT32
*Ebx
, OPTIONAL
5636 OUT UINT32
*Ecx
, OPTIONAL
5637 OUT UINT32
*Edx OPTIONAL
5642 Set CD bit and clear NW bit of CR0 followed by a WBINVD.
5644 Disables the caches by setting the CD bit of CR0 to 1, clearing the NW bit of CR0 to 0,
5645 and executing a WBINVD instruction. This function is only available on IA-32 and x64.
5656 Perform a WBINVD and clear both the CD and NW bits of CR0.
5658 Enables the caches by executing a WBINVD instruction and then clear both the CD and NW
5659 bits of CR0 to 0. This function is only available on IA-32 and x64.
5670 Returns the lower 32-bits of a Machine Specific Register(MSR).
5672 Reads and returns the lower 32-bits of the MSR specified by Index.
5673 No parameter checking is performed on Index, and some Index values may cause
5674 CPU exceptions. The caller must either guarantee that Index is valid, or the
5675 caller must set up exception handlers to catch the exceptions. This function
5676 is only available on IA-32 and x64.
5678 @param Index The 32-bit MSR index to read.
5680 @return The lower 32 bits of the MSR identified by Index.
5691 Writes a 32-bit value to a Machine Specific Register(MSR), and returns the value.
5692 The upper 32-bits of the MSR are set to zero.
5694 Writes the 32-bit value specified by Value to the MSR specified by Index. The
5695 upper 32-bits of the MSR write are set to zero. The 32-bit value written to
5696 the MSR is returned. No parameter checking is performed on Index or Value,
5697 and some of these may cause CPU exceptions. The caller must either guarantee
5698 that Index and Value are valid, or the caller must establish proper exception
5699 handlers. This function is only available on IA-32 and x64.
5701 @param Index The 32-bit MSR index to write.
5702 @param Value The 32-bit value to write to the MSR.
5716 Reads a 64-bit MSR, performs a bitwise OR on the lower 32-bits, and
5717 writes the result back to the 64-bit MSR.
5719 Reads the 64-bit MSR specified by Index, performs a bitwise OR
5720 between the lower 32-bits of the read result and the value specified by
5721 OrData, and writes the result to the 64-bit MSR specified by Index. The lower
5722 32-bits of the value written to the MSR is returned. No parameter checking is
5723 performed on Index or OrData, and some of these may cause CPU exceptions. The
5724 caller must either guarantee that Index and OrData are valid, or the caller
5725 must establish proper exception handlers. This function is only available on
5728 @param Index The 32-bit MSR index to write.
5729 @param OrData The value to OR with the read value from the MSR.
5731 @return The lower 32-bit value written to the MSR.
5743 Reads a 64-bit MSR, performs a bitwise AND on the lower 32-bits, and writes
5744 the result back to the 64-bit MSR.
5746 Reads the 64-bit MSR specified by Index, performs a bitwise AND between the
5747 lower 32-bits of the read result and the value specified by AndData, and
5748 writes the result to the 64-bit MSR specified by Index. The lower 32-bits of
5749 the value written to the MSR is returned. No parameter checking is performed
5750 on Index or AndData, and some of these may cause CPU exceptions. The caller
5751 must either guarantee that Index and AndData are valid, or the caller must
5752 establish proper exception handlers. This function is only available on IA-32
5755 @param Index The 32-bit MSR index to write.
5756 @param AndData The value to AND with the read value from the MSR.
5758 @return The lower 32-bit value written to the MSR.
5770 Reads a 64-bit MSR, performs a bitwise AND followed by a bitwise OR
5771 on the lower 32-bits, and writes the result back to the 64-bit MSR.
5773 Reads the 64-bit MSR specified by Index, performs a bitwise AND between the
5774 lower 32-bits of the read result and the value specified by AndData
5775 preserving the upper 32-bits, performs a bitwise OR between the
5776 result of the AND operation and the value specified by OrData, and writes the
5777 result to the 64-bit MSR specified by Address. The lower 32-bits of the value
5778 written to the MSR is returned. No parameter checking is performed on Index,
5779 AndData, or OrData, and some of these may cause CPU exceptions. The caller
5780 must either guarantee that Index, AndData, and OrData are valid, or the
5781 caller must establish proper exception handlers. This function is only
5782 available on IA-32 and x64.
5784 @param Index The 32-bit MSR index to write.
5785 @param AndData The value to AND with the read value from the MSR.
5786 @param OrData The value to OR with the result of the AND operation.
5788 @return The lower 32-bit value written to the MSR.
5801 Reads a bit field of an MSR.
5803 Reads the bit field in the lower 32-bits of a 64-bit MSR. The bit field is
5804 specified by the StartBit and the EndBit. The value of the bit field is
5805 returned. The caller must either guarantee that Index is valid, or the caller
5806 must set up exception handlers to catch the exceptions. This function is only
5807 available on IA-32 and x64.
5809 If StartBit is greater than 31, then ASSERT().
5810 If EndBit is greater than 31, then ASSERT().
5811 If EndBit is less than StartBit, then ASSERT().
5813 @param Index The 32-bit MSR index to read.
5814 @param StartBit The ordinal of the least significant bit in the bit field.
5816 @param EndBit The ordinal of the most significant bit in the bit field.
5819 @return The bit field read from the MSR.
5824 AsmMsrBitFieldRead32 (
5832 Writes a bit field to an MSR.
5834 Writes Value to a bit field in the lower 32-bits of a 64-bit MSR. The bit
5835 field is specified by the StartBit and the EndBit. All other bits in the
5836 destination MSR are preserved. The lower 32-bits of the MSR written is
5837 returned. The caller must either guarantee that Index and the data written
5838 is valid, or the caller must set up exception handlers to catch the exceptions.
5839 This function is only available on IA-32 and x64.
5841 If StartBit is greater than 31, then ASSERT().
5842 If EndBit is greater than 31, then ASSERT().
5843 If EndBit is less than StartBit, then ASSERT().
5844 If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
5846 @param Index The 32-bit MSR index to write.
5847 @param StartBit The ordinal of the least significant bit in the bit field.
5849 @param EndBit The ordinal of the most significant bit in the bit field.
5851 @param Value New value of the bit field.
5853 @return The lower 32-bit of the value written to the MSR.
5858 AsmMsrBitFieldWrite32 (
5867 Reads a bit field in a 64-bit MSR, performs a bitwise OR, and writes the
5868 result back to the bit field in the 64-bit MSR.
5870 Reads the 64-bit MSR specified by Index, performs a bitwise OR
5871 between the read result and the value specified by OrData, and writes the
5872 result to the 64-bit MSR specified by Index. The lower 32-bits of the value
5873 written to the MSR are returned. Extra left bits in OrData are stripped. The
5874 caller must either guarantee that Index and the data written is valid, or
5875 the caller must set up exception handlers to catch the exceptions. This
5876 function is only available on IA-32 and x64.
5878 If StartBit is greater than 31, then ASSERT().
5879 If EndBit is greater than 31, then ASSERT().
5880 If EndBit is less than StartBit, then ASSERT().
5881 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
5883 @param Index The 32-bit MSR index to write.
5884 @param StartBit The ordinal of the least significant bit in the bit field.
5886 @param EndBit The ordinal of the most significant bit in the bit field.
5888 @param OrData The value to OR with the read value from the MSR.
5890 @return The lower 32-bit of the value written to the MSR.
5895 AsmMsrBitFieldOr32 (
5904 Reads a bit field in a 64-bit MSR, performs a bitwise AND, and writes the
5905 result back to the bit field in the 64-bit MSR.
5907 Reads the 64-bit MSR specified by Index, performs a bitwise AND between the
5908 read result and the value specified by AndData, and writes the result to the
5909 64-bit MSR specified by Index. The lower 32-bits of the value written to the
5910 MSR are returned. Extra left bits in AndData are stripped. The caller must
5911 either guarantee that Index and the data written is valid, or the caller must
5912 set up exception handlers to catch the exceptions. This function is only
5913 available on IA-32 and x64.
5915 If StartBit is greater than 31, then ASSERT().
5916 If EndBit is greater than 31, then ASSERT().
5917 If EndBit is less than StartBit, then ASSERT().
5918 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
5920 @param Index The 32-bit MSR index to write.
5921 @param StartBit The ordinal of the least significant bit in the bit field.
5923 @param EndBit The ordinal of the most significant bit in the bit field.
5925 @param AndData The value to AND with the read value from the MSR.
5927 @return The lower 32-bit of the value written to the MSR.
5932 AsmMsrBitFieldAnd32 (
5941 Reads a bit field in a 64-bit MSR, performs a bitwise AND followed by a
5942 bitwise OR, and writes the result back to the bit field in the
5945 Reads the 64-bit MSR specified by Index, performs a bitwise AND followed by a
5946 bitwise OR between the read result and the value specified by
5947 AndData, and writes the result to the 64-bit MSR specified by Index. The
5948 lower 32-bits of the value written to the MSR are returned. Extra left bits
5949 in both AndData and OrData are stripped. The caller must either guarantee
5950 that Index and the data written is valid, or the caller must set up exception
5951 handlers to catch the exceptions. This function is only available on IA-32
5954 If StartBit is greater than 31, then ASSERT().
5955 If EndBit is greater than 31, then ASSERT().
5956 If EndBit is less than StartBit, then ASSERT().
5957 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
5958 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
5960 @param Index The 32-bit MSR index to write.
5961 @param StartBit The ordinal of the least significant bit in the bit field.
5963 @param EndBit The ordinal of the most significant bit in the bit field.
5965 @param AndData The value to AND with the read value from the MSR.
5966 @param OrData The value to OR with the result of the AND operation.
5968 @return The lower 32-bit of the value written to the MSR.
5973 AsmMsrBitFieldAndThenOr32 (
5983 Returns a 64-bit Machine Specific Register(MSR).
5985 Reads and returns the 64-bit MSR specified by Index. No parameter checking is
5986 performed on Index, and some Index values may cause CPU exceptions. The
5987 caller must either guarantee that Index is valid, or the caller must set up
5988 exception handlers to catch the exceptions. This function is only available
5991 @param Index The 32-bit MSR index to read.
5993 @return The value of the MSR identified by Index.
6004 Writes a 64-bit value to a Machine Specific Register(MSR), and returns the
6007 Writes the 64-bit value specified by Value to the MSR specified by Index. The
6008 64-bit value written to the MSR is returned. No parameter checking is
6009 performed on Index or Value, and some of these may cause CPU exceptions. The
6010 caller must either guarantee that Index and Value are valid, or the caller
6011 must establish proper exception handlers. This function is only available on
6014 @param Index The 32-bit MSR index to write.
6015 @param Value The 64-bit value to write to the MSR.
6029 Reads a 64-bit MSR, performs a bitwise OR, and writes the result
6030 back to the 64-bit MSR.
6032 Reads the 64-bit MSR specified by Index, performs a bitwise OR
6033 between the read result and the value specified by OrData, and writes the
6034 result to the 64-bit MSR specified by Index. The value written to the MSR is
6035 returned. No parameter checking is performed on Index or OrData, and some of
6036 these may cause CPU exceptions. The caller must either guarantee that Index
6037 and OrData are valid, or the caller must establish proper exception handlers.
6038 This function is only available on IA-32 and x64.
6040 @param Index The 32-bit MSR index to write.
6041 @param OrData The value to OR with the read value from the MSR.
6043 @return The value written back to the MSR.
6055 Reads a 64-bit MSR, performs a bitwise AND, and writes the result back to the
6058 Reads the 64-bit MSR specified by Index, performs a bitwise AND between the
6059 read result and the value specified by OrData, and writes the result to the
6060 64-bit MSR specified by Index. The value written to the MSR is returned. No
6061 parameter checking is performed on Index or OrData, and some of these may
6062 cause CPU exceptions. The caller must either guarantee that Index and OrData
6063 are valid, or the caller must establish proper exception handlers. This
6064 function is only available on IA-32 and x64.
6066 @param Index The 32-bit MSR index to write.
6067 @param AndData The value to AND with the read value from the MSR.
6069 @return The value written back to the MSR.
6081 Reads a 64-bit MSR, performs a bitwise AND followed by a bitwise
6082 OR, and writes the result back to the 64-bit MSR.
6084 Reads the 64-bit MSR specified by Index, performs a bitwise AND between read
6085 result and the value specified by AndData, performs a bitwise OR
6086 between the result of the AND operation and the value specified by OrData,
6087 and writes the result to the 64-bit MSR specified by Index. The value written
6088 to the MSR is returned. No parameter checking is performed on Index, AndData,
6089 or OrData, and some of these may cause CPU exceptions. The caller must either
6090 guarantee that Index, AndData, and OrData are valid, or the caller must
6091 establish proper exception handlers. This function is only available on IA-32
6094 @param Index The 32-bit MSR index to write.
6095 @param AndData The value to AND with the read value from the MSR.
6096 @param OrData The value to OR with the result of the AND operation.
6098 @return The value written back to the MSR.
6111 Reads a bit field of an MSR.
6113 Reads the bit field in the 64-bit MSR. The bit field is specified by the
6114 StartBit and the EndBit. The value of the bit field is returned. The caller
6115 must either guarantee that Index is valid, or the caller must set up
6116 exception handlers to catch the exceptions. This function is only available
6119 If StartBit is greater than 63, then ASSERT().
6120 If EndBit is greater than 63, then ASSERT().
6121 If EndBit is less than StartBit, then ASSERT().
6123 @param Index The 32-bit MSR index to read.
6124 @param StartBit The ordinal of the least significant bit in the bit field.
6126 @param EndBit The ordinal of the most significant bit in the bit field.
6129 @return The value read from the MSR.
6134 AsmMsrBitFieldRead64 (
6142 Writes a bit field to an MSR.
6144 Writes Value to a bit field in a 64-bit MSR. The bit field is specified by
6145 the StartBit and the EndBit. All other bits in the destination MSR are
6146 preserved. The MSR written is returned. The caller must either guarantee
6147 that Index and the data written is valid, or the caller must set up exception
6148 handlers to catch the exceptions. This function is only available on IA-32 and x64.
6150 If StartBit is greater than 63, then ASSERT().
6151 If EndBit is greater than 63, then ASSERT().
6152 If EndBit is less than StartBit, then ASSERT().
6153 If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
6155 @param Index The 32-bit MSR index to write.
6156 @param StartBit The ordinal of the least significant bit in the bit field.
6158 @param EndBit The ordinal of the most significant bit in the bit field.
6160 @param Value New value of the bit field.
6162 @return The value written back to the MSR.
6167 AsmMsrBitFieldWrite64 (
6176 Reads a bit field in a 64-bit MSR, performs a bitwise OR, and
6177 writes the result back to the bit field in the 64-bit MSR.
6179 Reads the 64-bit MSR specified by Index, performs a bitwise OR
6180 between the read result and the value specified by OrData, and writes the
6181 result to the 64-bit MSR specified by Index. The value written to the MSR is
6182 returned. Extra left bits in OrData are stripped. The caller must either
6183 guarantee that Index and the data written is valid, or the caller must set up
6184 exception handlers to catch the exceptions. This function is only available
6187 If StartBit is greater than 63, then ASSERT().
6188 If EndBit is greater than 63, then ASSERT().
6189 If EndBit is less than StartBit, then ASSERT().
6190 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
6192 @param Index The 32-bit MSR index to write.
6193 @param StartBit The ordinal of the least significant bit in the bit field.
6195 @param EndBit The ordinal of the most significant bit in the bit field.
6197 @param OrData The value to OR with the read value from the bit field.
6199 @return The value written back to the MSR.
6204 AsmMsrBitFieldOr64 (
6213 Reads a bit field in a 64-bit MSR, performs a bitwise AND, and writes the
6214 result back to the bit field in the 64-bit MSR.
6216 Reads the 64-bit MSR specified by Index, performs a bitwise AND between the
6217 read result and the value specified by AndData, and writes the result to the
6218 64-bit MSR specified by Index. The value written to the MSR is returned.
6219 Extra left bits in AndData are stripped. The caller must either guarantee
6220 that Index and the data written is valid, or the caller must set up exception
6221 handlers to catch the exceptions. This function is only available on IA-32
6224 If StartBit is greater than 63, then ASSERT().
6225 If EndBit is greater than 63, then ASSERT().
6226 If EndBit is less than StartBit, then ASSERT().
6227 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
6229 @param Index The 32-bit MSR index to write.
6230 @param StartBit The ordinal of the least significant bit in the bit field.
6232 @param EndBit The ordinal of the most significant bit in the bit field.
6234 @param AndData The value to AND with the read value from the bit field.
6236 @return The value written back to the MSR.
6241 AsmMsrBitFieldAnd64 (
6250 Reads a bit field in a 64-bit MSR, performs a bitwise AND followed by a
6251 bitwise OR, and writes the result back to the bit field in the
6254 Reads the 64-bit MSR specified by Index, performs a bitwise AND followed by
6255 a bitwise OR between the read result and the value specified by
6256 AndData, and writes the result to the 64-bit MSR specified by Index. The
6257 value written to the MSR is returned. Extra left bits in both AndData and
6258 OrData are stripped. The caller must either guarantee that Index and the data
6259 written is valid, or the caller must set up exception handlers to catch the
6260 exceptions. This function is only available on IA-32 and x64.
6262 If StartBit is greater than 63, then ASSERT().
6263 If EndBit is greater than 63, then ASSERT().
6264 If EndBit is less than StartBit, then ASSERT().
6265 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
6266 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
6268 @param Index The 32-bit MSR index to write.
6269 @param StartBit The ordinal of the least significant bit in the bit field.
6271 @param EndBit The ordinal of the most significant bit in the bit field.
6273 @param AndData The value to AND with the read value from the bit field.
6274 @param OrData The value to OR with the result of the AND operation.
6276 @return The value written back to the MSR.
6281 AsmMsrBitFieldAndThenOr64 (
6291 Reads the current value of the EFLAGS register.
6293 Reads and returns the current value of the EFLAGS register. This function is
6294 only available on IA-32 and x64. This returns a 32-bit value on IA-32 and a
6295 64-bit value on x64.
6297 @return EFLAGS on IA-32 or RFLAGS on x64.
6308 Reads the current value of the Control Register 0 (CR0).
6310 Reads and returns the current value of CR0. This function is only available
6311 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
6314 @return The value of the Control Register 0 (CR0).
6325 Reads the current value of the Control Register 2 (CR2).
6327 Reads and returns the current value of CR2. This function is only available
6328 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
6331 @return The value of the Control Register 2 (CR2).
6342 Reads the current value of the Control Register 3 (CR3).
6344 Reads and returns the current value of CR3. This function is only available
6345 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
6348 @return The value of the Control Register 3 (CR3).
6359 Reads the current value of the Control Register 4 (CR4).
6361 Reads and returns the current value of CR4. This function is only available
6362 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
6365 @return The value of the Control Register 4 (CR4).
6376 Writes a value to Control Register 0 (CR0).
6378 Writes and returns a new value to CR0. This function is only available on
6379 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
6381 @param Cr0 The value to write to CR0.
6383 @return The value written to CR0.
6394 Writes a value to Control Register 2 (CR2).
6396 Writes and returns a new value to CR2. This function is only available on
6397 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
6399 @param Cr2 The value to write to CR2.
6401 @return The value written to CR2.
6412 Writes a value to Control Register 3 (CR3).
6414 Writes and returns a new value to CR3. This function is only available on
6415 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
6417 @param Cr3 The value to write to CR3.
6419 @return The value written to CR3.
6430 Writes a value to Control Register 4 (CR4).
6432 Writes and returns a new value to CR4. This function is only available on
6433 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
6435 @param Cr4 The value to write to CR4.
6437 @return The value written to CR4.
6448 Reads the current value of Debug Register 0 (DR0).
6450 Reads and returns the current value of DR0. This function is only available
6451 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
6454 @return The value of Debug Register 0 (DR0).
6465 Reads the current value of Debug Register 1 (DR1).
6467 Reads and returns the current value of DR1. This function is only available
6468 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
6471 @return The value of Debug Register 1 (DR1).
6482 Reads the current value of Debug Register 2 (DR2).
6484 Reads and returns the current value of DR2. This function is only available
6485 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
6488 @return The value of Debug Register 2 (DR2).
6499 Reads the current value of Debug Register 3 (DR3).
6501 Reads and returns the current value of DR3. This function is only available
6502 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
6505 @return The value of Debug Register 3 (DR3).
6516 Reads the current value of Debug Register 4 (DR4).
6518 Reads and returns the current value of DR4. This function is only available
6519 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
6522 @return The value of Debug Register 4 (DR4).
6533 Reads the current value of Debug Register 5 (DR5).
6535 Reads and returns the current value of DR5. This function is only available
6536 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
6539 @return The value of Debug Register 5 (DR5).
6550 Reads the current value of Debug Register 6 (DR6).
6552 Reads and returns the current value of DR6. 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 6 (DR6).
6567 Reads the current value of Debug Register 7 (DR7).
6569 Reads and returns the current value of DR7. 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 7 (DR7).
6584 Writes a value to Debug Register 0 (DR0).
6586 Writes and returns a new value to DR0. This function is only available on
6587 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
6589 @param Dr0 The value to write to Dr0.
6591 @return The value written to Debug Register 0 (DR0).
6602 Writes a value to Debug Register 1 (DR1).
6604 Writes and returns a new value to DR1. This function is only available on
6605 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
6607 @param Dr1 The value to write to Dr1.
6609 @return The value written to Debug Register 1 (DR1).
6620 Writes a value to Debug Register 2 (DR2).
6622 Writes and returns a new value to DR2. This function is only available on
6623 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
6625 @param Dr2 The value to write to Dr2.
6627 @return The value written to Debug Register 2 (DR2).
6638 Writes a value to Debug Register 3 (DR3).
6640 Writes and returns a new value to DR3. This function is only available on
6641 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
6643 @param Dr3 The value to write to Dr3.
6645 @return The value written to Debug Register 3 (DR3).
6656 Writes a value to Debug Register 4 (DR4).
6658 Writes and returns a new value to DR4. This function is only available on
6659 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
6661 @param Dr4 The value to write to Dr4.
6663 @return The value written to Debug Register 4 (DR4).
6674 Writes a value to Debug Register 5 (DR5).
6676 Writes and returns a new value to DR5. This function is only available on
6677 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
6679 @param Dr5 The value to write to Dr5.
6681 @return The value written to Debug Register 5 (DR5).
6692 Writes a value to Debug Register 6 (DR6).
6694 Writes and returns a new value to DR6. This function is only available on
6695 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
6697 @param Dr6 The value to write to Dr6.
6699 @return The value written to Debug Register 6 (DR6).
6710 Writes a value to Debug Register 7 (DR7).
6712 Writes and returns a new value to DR7. This function is only available on
6713 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
6715 @param Dr7 The value to write to Dr7.
6717 @return The value written to Debug Register 7 (DR7).
6728 Reads the current value of Code Segment Register (CS).
6730 Reads and returns the current value of CS. This function is only available on
6733 @return The current value of CS.
6744 Reads the current value of Data Segment Register (DS).
6746 Reads and returns the current value of DS. This function is only available on
6749 @return The current value of DS.
6760 Reads the current value of Extra Segment Register (ES).
6762 Reads and returns the current value of ES. This function is only available on
6765 @return The current value of ES.
6776 Reads the current value of FS Data Segment Register (FS).
6778 Reads and returns the current value of FS. This function is only available on
6781 @return The current value of FS.
6792 Reads the current value of GS Data Segment Register (GS).
6794 Reads and returns the current value of GS. This function is only available on
6797 @return The current value of GS.
6808 Reads the current value of Stack Segment Register (SS).
6810 Reads and returns the current value of SS. This function is only available on
6813 @return The current value of SS.
6824 Reads the current value of Task Register (TR).
6826 Reads and returns the current value of TR. This function is only available on
6829 @return The current value of TR.
6840 Reads the current Global Descriptor Table Register(GDTR) descriptor.
6842 Reads and returns the current GDTR descriptor and returns it in Gdtr. This
6843 function is only available on IA-32 and x64.
6845 If Gdtr is NULL, then ASSERT().
6847 @param Gdtr The pointer to a GDTR descriptor.
6853 OUT IA32_DESCRIPTOR
*Gdtr
6858 Writes the current Global Descriptor Table Register (GDTR) descriptor.
6860 Writes and the current GDTR descriptor specified by Gdtr. This function is
6861 only available on IA-32 and x64.
6863 If Gdtr is NULL, then ASSERT().
6865 @param Gdtr The pointer to a GDTR descriptor.
6871 IN CONST IA32_DESCRIPTOR
*Gdtr
6876 Reads the current Interrupt Descriptor Table Register(IDTR) descriptor.
6878 Reads and returns the current IDTR descriptor and returns it in Idtr. This
6879 function is only available on IA-32 and x64.
6881 If Idtr is NULL, then ASSERT().
6883 @param Idtr The pointer to a IDTR descriptor.
6889 OUT IA32_DESCRIPTOR
*Idtr
6894 Writes the current Interrupt Descriptor Table Register(IDTR) descriptor.
6896 Writes the current IDTR descriptor and returns it in Idtr. This function is
6897 only available on IA-32 and x64.
6899 If Idtr is NULL, then ASSERT().
6901 @param Idtr The pointer to a IDTR descriptor.
6907 IN CONST IA32_DESCRIPTOR
*Idtr
6912 Reads the current Local Descriptor Table Register(LDTR) selector.
6914 Reads and returns the current 16-bit LDTR descriptor value. This function is
6915 only available on IA-32 and x64.
6917 @return The current selector of LDT.
6928 Writes the current Local Descriptor Table Register (LDTR) selector.
6930 Writes and the current LDTR descriptor specified by Ldtr. This function is
6931 only available on IA-32 and x64.
6933 @param Ldtr 16-bit LDTR selector value.
6944 Save the current floating point/SSE/SSE2 context to a buffer.
6946 Saves the current floating point/SSE/SSE2 state to the buffer specified by
6947 Buffer. Buffer must be aligned on a 16-byte boundary. This function is only
6948 available on IA-32 and x64.
6950 If Buffer is NULL, then ASSERT().
6951 If Buffer is not aligned on a 16-byte boundary, then ASSERT().
6953 @param Buffer The pointer to a buffer to save the floating point/SSE/SSE2 context.
6959 OUT IA32_FX_BUFFER
*Buffer
6964 Restores the current floating point/SSE/SSE2 context from a buffer.
6966 Restores the current floating point/SSE/SSE2 state from the buffer specified
6967 by Buffer. Buffer must be aligned on a 16-byte boundary. This function is
6968 only available on IA-32 and x64.
6970 If Buffer is NULL, then ASSERT().
6971 If Buffer is not aligned on a 16-byte boundary, then ASSERT().
6972 If Buffer was not saved with AsmFxSave(), then ASSERT().
6974 @param Buffer The pointer to a buffer to save the floating point/SSE/SSE2 context.
6980 IN CONST IA32_FX_BUFFER
*Buffer
6985 Reads the current value of 64-bit MMX Register #0 (MM0).
6987 Reads and returns the current value of MM0. This function is only available
6990 @return The current value of MM0.
7001 Reads the current value of 64-bit MMX Register #1 (MM1).
7003 Reads and returns the current value of MM1. This function is only available
7006 @return The current value of MM1.
7017 Reads the current value of 64-bit MMX Register #2 (MM2).
7019 Reads and returns the current value of MM2. This function is only available
7022 @return The current value of MM2.
7033 Reads the current value of 64-bit MMX Register #3 (MM3).
7035 Reads and returns the current value of MM3. This function is only available
7038 @return The current value of MM3.
7049 Reads the current value of 64-bit MMX Register #4 (MM4).
7051 Reads and returns the current value of MM4. This function is only available
7054 @return The current value of MM4.
7065 Reads the current value of 64-bit MMX Register #5 (MM5).
7067 Reads and returns the current value of MM5. This function is only available
7070 @return The current value of MM5.
7081 Reads the current value of 64-bit MMX Register #6 (MM6).
7083 Reads and returns the current value of MM6. This function is only available
7086 @return The current value of MM6.
7097 Reads the current value of 64-bit MMX Register #7 (MM7).
7099 Reads and returns the current value of MM7. This function is only available
7102 @return The current value of MM7.
7113 Writes the current value of 64-bit MMX Register #0 (MM0).
7115 Writes the current value of MM0. This function is only available on IA32 and
7118 @param Value The 64-bit value to write to MM0.
7129 Writes the current value of 64-bit MMX Register #1 (MM1).
7131 Writes the current value of MM1. This function is only available on IA32 and
7134 @param Value The 64-bit value to write to MM1.
7145 Writes the current value of 64-bit MMX Register #2 (MM2).
7147 Writes the current value of MM2. This function is only available on IA32 and
7150 @param Value The 64-bit value to write to MM2.
7161 Writes the current value of 64-bit MMX Register #3 (MM3).
7163 Writes the current value of MM3. This function is only available on IA32 and
7166 @param Value The 64-bit value to write to MM3.
7177 Writes the current value of 64-bit MMX Register #4 (MM4).
7179 Writes the current value of MM4. This function is only available on IA32 and
7182 @param Value The 64-bit value to write to MM4.
7193 Writes the current value of 64-bit MMX Register #5 (MM5).
7195 Writes the current value of MM5. This function is only available on IA32 and
7198 @param Value The 64-bit value to write to MM5.
7209 Writes the current value of 64-bit MMX Register #6 (MM6).
7211 Writes the current value of MM6. This function is only available on IA32 and
7214 @param Value The 64-bit value to write to MM6.
7225 Writes the current value of 64-bit MMX Register #7 (MM7).
7227 Writes the current value of MM7. This function is only available on IA32 and
7230 @param Value The 64-bit value to write to MM7.
7241 Reads the current value of Time Stamp Counter (TSC).
7243 Reads and returns the current value of TSC. This function is only available
7246 @return The current value of TSC
7257 Reads the current value of a Performance Counter (PMC).
7259 Reads and returns the current value of performance counter specified by
7260 Index. This function is only available on IA-32 and x64.
7262 @param Index The 32-bit Performance Counter index to read.
7264 @return The value of the PMC specified by Index.
7275 Sets up a monitor buffer that is used by AsmMwait().
7277 Executes a MONITOR instruction with the register state specified by Eax, Ecx
7278 and Edx. Returns Eax. This function is only available on IA-32 and x64.
7280 @param Eax The value to load into EAX or RAX before executing the MONITOR
7282 @param Ecx The value to load into ECX or RCX before executing the MONITOR
7284 @param Edx The value to load into EDX or RDX before executing the MONITOR
7300 Executes an MWAIT instruction.
7302 Executes an MWAIT instruction with the register state specified by Eax and
7303 Ecx. Returns Eax. This function is only available on IA-32 and x64.
7305 @param Eax The value to load into EAX or RAX before executing the MONITOR
7307 @param Ecx The value to load into ECX or RCX before executing the MONITOR
7322 Executes a WBINVD instruction.
7324 Executes a WBINVD instruction. This function is only available on IA-32 and
7336 Executes a INVD instruction.
7338 Executes a INVD instruction. This function is only available on IA-32 and
7350 Flushes a cache line from all the instruction and data caches within the
7351 coherency domain of the CPU.
7353 Flushed the cache line specified by LinearAddress, and returns LinearAddress.
7354 This function is only available on IA-32 and x64.
7356 @param LinearAddress The address of the cache line to flush. If the CPU is
7357 in a physical addressing mode, then LinearAddress is a
7358 physical address. If the CPU is in a virtual
7359 addressing mode, then LinearAddress is a virtual
7362 @return LinearAddress.
7367 IN VOID
*LinearAddress
7372 Enables the 32-bit paging mode on the CPU.
7374 Enables the 32-bit paging mode on the CPU. CR0, CR3, CR4, and the page tables
7375 must be properly initialized prior to calling this service. This function
7376 assumes the current execution mode is 32-bit protected mode. This function is
7377 only available on IA-32. After the 32-bit paging mode is enabled, control is
7378 transferred to the function specified by EntryPoint using the new stack
7379 specified by NewStack and passing in the parameters specified by Context1 and
7380 Context2. Context1 and Context2 are optional and may be NULL. The function
7381 EntryPoint must never return.
7383 If the current execution mode is not 32-bit protected mode, then ASSERT().
7384 If EntryPoint is NULL, then ASSERT().
7385 If NewStack is NULL, then ASSERT().
7387 There are a number of constraints that must be followed before calling this
7389 1) Interrupts must be disabled.
7390 2) The caller must be in 32-bit protected mode with flat descriptors. This
7391 means all descriptors must have a base of 0 and a limit of 4GB.
7392 3) CR0 and CR4 must be compatible with 32-bit protected mode with flat
7394 4) CR3 must point to valid page tables that will be used once the transition
7395 is complete, and those page tables must guarantee that the pages for this
7396 function and the stack are identity mapped.
7398 @param EntryPoint A pointer to function to call with the new stack after
7400 @param Context1 A pointer to the context to pass into the EntryPoint
7401 function as the first parameter after paging is enabled.
7402 @param Context2 A pointer to the context to pass into the EntryPoint
7403 function as the second parameter after paging is enabled.
7404 @param NewStack A pointer to the new stack to use for the EntryPoint
7405 function after paging is enabled.
7411 IN SWITCH_STACK_ENTRY_POINT EntryPoint
,
7412 IN VOID
*Context1
, OPTIONAL
7413 IN VOID
*Context2
, OPTIONAL
7419 Disables the 32-bit paging mode on the CPU.
7421 Disables the 32-bit paging mode on the CPU and returns to 32-bit protected
7422 mode. This function assumes the current execution mode is 32-paged protected
7423 mode. This function is only available on IA-32. After the 32-bit paging mode
7424 is disabled, control is transferred to the function specified by EntryPoint
7425 using the new stack specified by NewStack and passing in the parameters
7426 specified by Context1 and Context2. Context1 and Context2 are optional and
7427 may be NULL. The function EntryPoint must never return.
7429 If the current execution mode is not 32-bit paged mode, then ASSERT().
7430 If EntryPoint is NULL, then ASSERT().
7431 If NewStack is NULL, then ASSERT().
7433 There are a number of constraints that must be followed before calling this
7435 1) Interrupts must be disabled.
7436 2) The caller must be in 32-bit paged mode.
7437 3) CR0, CR3, and CR4 must be compatible with 32-bit paged mode.
7438 4) CR3 must point to valid page tables that guarantee that the pages for
7439 this function and the stack are identity mapped.
7441 @param EntryPoint A pointer to function to call with the new stack after
7443 @param Context1 A pointer to the context to pass into the EntryPoint
7444 function as the first parameter after paging is disabled.
7445 @param Context2 A pointer to the context to pass into the EntryPoint
7446 function as the second parameter after paging is
7448 @param NewStack A pointer to the new stack to use for the EntryPoint
7449 function after paging is disabled.
7454 AsmDisablePaging32 (
7455 IN SWITCH_STACK_ENTRY_POINT EntryPoint
,
7456 IN VOID
*Context1
, OPTIONAL
7457 IN VOID
*Context2
, OPTIONAL
7463 Enables the 64-bit paging mode on the CPU.
7465 Enables the 64-bit paging mode on the CPU. CR0, CR3, CR4, and the page tables
7466 must be properly initialized prior to calling this service. This function
7467 assumes the current execution mode is 32-bit protected mode with flat
7468 descriptors. This function is only available on IA-32. After the 64-bit
7469 paging mode is enabled, control is transferred to the function specified by
7470 EntryPoint using the new stack specified by NewStack and passing in the
7471 parameters specified by Context1 and Context2. Context1 and Context2 are
7472 optional and may be 0. The function EntryPoint must never return.
7474 If the current execution mode is not 32-bit protected mode with flat
7475 descriptors, then ASSERT().
7476 If EntryPoint is 0, then ASSERT().
7477 If NewStack is 0, then ASSERT().
7479 @param Cs The 16-bit selector to load in the CS before EntryPoint
7480 is called. The descriptor in the GDT that this selector
7481 references must be setup for long mode.
7482 @param EntryPoint The 64-bit virtual address of the function to call with
7483 the new stack after paging is enabled.
7484 @param Context1 The 64-bit virtual address of the context to pass into
7485 the EntryPoint function as the first parameter after
7487 @param Context2 The 64-bit virtual address of the context to pass into
7488 the EntryPoint function as the second parameter after
7490 @param NewStack The 64-bit virtual address of the new stack to use for
7491 the EntryPoint function after paging is enabled.
7498 IN UINT64 EntryPoint
,
7499 IN UINT64 Context1
, OPTIONAL
7500 IN UINT64 Context2
, OPTIONAL
7506 Disables the 64-bit paging mode on the CPU.
7508 Disables the 64-bit paging mode on the CPU and returns to 32-bit protected
7509 mode. This function assumes the current execution mode is 64-paging mode.
7510 This function is only available on x64. After the 64-bit paging mode is
7511 disabled, control is transferred to the function specified by EntryPoint
7512 using the new stack specified by NewStack and passing in the parameters
7513 specified by Context1 and Context2. Context1 and Context2 are optional and
7514 may be 0. The function EntryPoint must never return.
7516 If the current execution mode is not 64-bit paged mode, then ASSERT().
7517 If EntryPoint is 0, then ASSERT().
7518 If NewStack is 0, then ASSERT().
7520 @param Cs The 16-bit selector to load in the CS before EntryPoint
7521 is called. The descriptor in the GDT that this selector
7522 references must be setup for 32-bit protected mode.
7523 @param EntryPoint The 64-bit virtual address of the function to call with
7524 the new stack after paging is disabled.
7525 @param Context1 The 64-bit virtual address of the context to pass into
7526 the EntryPoint function as the first parameter after
7528 @param Context2 The 64-bit virtual address of the context to pass into
7529 the EntryPoint function as the second parameter after
7531 @param NewStack The 64-bit virtual address of the new stack to use for
7532 the EntryPoint function after paging is disabled.
7537 AsmDisablePaging64 (
7539 IN UINT32 EntryPoint
,
7540 IN UINT32 Context1
, OPTIONAL
7541 IN UINT32 Context2
, OPTIONAL
7547 // 16-bit thunking services
7551 Retrieves the properties for 16-bit thunk functions.
7553 Computes the size of the buffer and stack below 1MB required to use the
7554 AsmPrepareThunk16(), AsmThunk16() and AsmPrepareAndThunk16() functions. This
7555 buffer size is returned in RealModeBufferSize, and the stack size is returned
7556 in ExtraStackSize. If parameters are passed to the 16-bit real mode code,
7557 then the actual minimum stack size is ExtraStackSize plus the maximum number
7558 of bytes that need to be passed to the 16-bit real mode code.
7560 If RealModeBufferSize is NULL, then ASSERT().
7561 If ExtraStackSize is NULL, then ASSERT().
7563 @param RealModeBufferSize A pointer to the size of the buffer below 1MB
7564 required to use the 16-bit thunk functions.
7565 @param ExtraStackSize A pointer to the extra size of stack below 1MB
7566 that the 16-bit thunk functions require for
7567 temporary storage in the transition to and from
7573 AsmGetThunk16Properties (
7574 OUT UINT32
*RealModeBufferSize
,
7575 OUT UINT32
*ExtraStackSize
7580 Prepares all structures a code required to use AsmThunk16().
7582 Prepares all structures and code required to use AsmThunk16().
7584 This interface is limited to be used in either physical mode or virtual modes with paging enabled where the
7585 virtual to physical mappings for ThunkContext.RealModeBuffer is mapped 1:1.
7587 If ThunkContext is NULL, then ASSERT().
7589 @param ThunkContext A pointer to the context structure that describes the
7590 16-bit real mode code to call.
7596 IN OUT THUNK_CONTEXT
*ThunkContext
7601 Transfers control to a 16-bit real mode entry point and returns the results.
7603 Transfers control to a 16-bit real mode entry point and returns the results.
7604 AsmPrepareThunk16() must be called with ThunkContext before this function is used.
7605 This function must be called with interrupts disabled.
7607 The register state from the RealModeState field of ThunkContext is restored just prior
7608 to calling the 16-bit real mode entry point. This includes the EFLAGS field of RealModeState,
7609 which is used to set the interrupt state when a 16-bit real mode entry point is called.
7610 Control is transferred to the 16-bit real mode entry point specified by the CS and Eip fields of RealModeState.
7611 The stack is initialized to the SS and ESP fields of RealModeState. Any parameters passed to
7612 the 16-bit real mode code must be populated by the caller at SS:ESP prior to calling this function.
7613 The 16-bit real mode entry point is invoked with a 16-bit CALL FAR instruction,
7614 so when accessing stack contents, the 16-bit real mode code must account for the 16-bit segment
7615 and 16-bit offset of the return address that were pushed onto the stack. The 16-bit real mode entry
7616 point must exit with a RETF instruction. The register state is captured into RealModeState immediately
7617 after the RETF instruction is executed.
7619 If EFLAGS specifies interrupts enabled, or any of the 16-bit real mode code enables interrupts,
7620 or any of the 16-bit real mode code makes a SW interrupt, then the caller is responsible for making sure
7621 the IDT at address 0 is initialized to handle any HW or SW interrupts that may occur while in 16-bit real mode.
7623 If EFLAGS specifies interrupts enabled, or any of the 16-bit real mode code enables interrupts,
7624 then the caller is responsible for making sure the 8259 PIC is in a state compatible with 16-bit real mode.
7625 This includes the base vectors, the interrupt masks, and the edge/level trigger mode.
7627 If THUNK_ATTRIBUTE_BIG_REAL_MODE is set in the ThunkAttributes field of ThunkContext, then the user code
7628 is invoked in big real mode. Otherwise, the user code is invoked in 16-bit real mode with 64KB segment limits.
7630 If neither THUNK_ATTRIBUTE_DISABLE_A20_MASK_INT_15 nor THUNK_ATTRIBUTE_DISABLE_A20_MASK_KBD_CTRL are set in
7631 ThunkAttributes, then it is assumed that the user code did not enable the A20 mask, and no attempt is made to
7632 disable the A20 mask.
7634 If THUNK_ATTRIBUTE_DISABLE_A20_MASK_INT_15 is set and THUNK_ATTRIBUTE_DISABLE_A20_MASK_KBD_CTRL is clear in
7635 ThunkAttributes, then attempt to use the INT 15 service to disable the A20 mask. If this INT 15 call fails,
7636 then attempt to disable the A20 mask by directly accessing the 8042 keyboard controller I/O ports.
7638 If THUNK_ATTRIBUTE_DISABLE_A20_MASK_INT_15 is clear and THUNK_ATTRIBUTE_DISABLE_A20_MASK_KBD_CTRL is set in
7639 ThunkAttributes, then attempt to disable the A20 mask by directly accessing the 8042 keyboard controller I/O ports.
7641 If ThunkContext is NULL, then ASSERT().
7642 If AsmPrepareThunk16() was not previously called with ThunkContext, then ASSERT().
7643 If both THUNK_ATTRIBUTE_DISABLE_A20_MASK_INT_15 and THUNK_ATTRIBUTE_DISABLE_A20_MASK_KBD_CTRL are set in
7644 ThunkAttributes, then ASSERT().
7646 This interface is limited to be used in either physical mode or virtual modes with paging enabled where the
7647 virtual to physical mappings for ThunkContext.RealModeBuffer are mapped 1:1.
7649 @param ThunkContext A pointer to the context structure that describes the
7650 16-bit real mode code to call.
7656 IN OUT THUNK_CONTEXT
*ThunkContext
7661 Prepares all structures and code for a 16-bit real mode thunk, transfers
7662 control to a 16-bit real mode entry point, and returns the results.
7664 Prepares all structures and code for a 16-bit real mode thunk, transfers
7665 control to a 16-bit real mode entry point, and returns the results. If the
7666 caller only need to perform a single 16-bit real mode thunk, then this
7667 service should be used. If the caller intends to make more than one 16-bit
7668 real mode thunk, then it is more efficient if AsmPrepareThunk16() is called
7669 once and AsmThunk16() can be called for each 16-bit real mode thunk.
7671 This interface is limited to be used in either physical mode or virtual modes with paging enabled where the
7672 virtual to physical mappings for ThunkContext.RealModeBuffer is mapped 1:1.
7674 See AsmPrepareThunk16() and AsmThunk16() for the detailed description and ASSERT() conditions.
7676 @param ThunkContext A pointer to the context structure that describes the
7677 16-bit real mode code to call.
7682 AsmPrepareAndThunk16 (
7683 IN OUT THUNK_CONTEXT
*ThunkContext
7687 Generates a 16-bit random number through RDRAND instruction.
7689 if Rand is NULL, then ASSERT().
7691 @param[out] Rand Buffer pointer to store the random result.
7693 @retval TRUE RDRAND call was successful.
7694 @retval FALSE Failed attempts to call RDRAND.
7704 Generates a 32-bit random number through RDRAND instruction.
7706 if Rand is NULL, then ASSERT().
7708 @param[out] Rand Buffer pointer to store the random result.
7710 @retval TRUE RDRAND call was successful.
7711 @retval FALSE Failed attempts to call RDRAND.
7721 Generates a 64-bit random number through RDRAND instruction.
7723 if Rand is NULL, then ASSERT().
7725 @param[out] Rand Buffer pointer to store the random result.
7727 @retval TRUE RDRAND call was successful.
7728 @retval FALSE Failed attempts to call RDRAND.