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 If String is not aligned on a 16-bit boundary, then ASSERT().
192 @param String A pointer to a Null-terminated Unicode string.
193 @param MaxSize The maximum number of Destination Unicode
194 char, including terminating null char.
196 @retval 0 If String is NULL.
197 @retval MaxSize If there is no null character in the first MaxSize characters of String.
198 @return The number of characters that percede the terminating null character.
204 IN CONST CHAR16
*String
,
209 Copies the string pointed to by Source (including the terminating null char)
210 to the array pointed to by Destination.
212 If Destination is not aligned on a 16-bit boundary, then ASSERT().
213 If Source is not aligned on a 16-bit boundary, then ASSERT().
214 If an error would be returned, then the function will also ASSERT().
216 @param Destination A pointer to a Null-terminated Unicode string.
217 @param DestMax The maximum number of Destination Unicode
218 char, including terminating null char.
219 @param Source A pointer to a Null-terminated Unicode string.
221 @retval RETURN_SUCCESS String is copied.
222 @retval RETURN_BUFFER_TOO_SMALL If DestMax is NOT greater than StrLen(Source).
223 @retval RETURN_INVALID_PARAMETER If Destination is NULL.
225 If PcdMaximumUnicodeStringLength is not zero,
226 and DestMax is greater than
227 PcdMaximumUnicodeStringLength.
229 @retval RETURN_ACCESS_DENIED If Source and Destination overlap.
234 OUT CHAR16
*Destination
,
236 IN CONST CHAR16
*Source
240 Copies not more than Length successive char from the string pointed to by
241 Source to the array pointed to by Destination. If no null char is copied from
242 Source, then Destination[Length] is always set to null.
244 If Length > 0 and Destination is not aligned on a 16-bit boundary, then ASSERT().
245 If Length > 0 and Source is not aligned on a 16-bit boundary, then ASSERT().
246 If an error would be returned, then the function will also ASSERT().
248 @param Destination A pointer to a Null-terminated Unicode string.
249 @param DestMax The maximum number of Destination Unicode
250 char, including terminating null char.
251 @param Source A pointer to a Null-terminated Unicode string.
252 @param Length The maximum number of Unicode characters to copy.
254 @retval RETURN_SUCCESS String is copied.
255 @retval RETURN_BUFFER_TOO_SMALL If DestMax is NOT greater than
256 MIN(StrLen(Source), Length).
257 @retval RETURN_INVALID_PARAMETER If Destination is NULL.
259 If PcdMaximumUnicodeStringLength is not zero,
260 and DestMax is greater than
261 PcdMaximumUnicodeStringLength.
263 @retval RETURN_ACCESS_DENIED If Source and Destination overlap.
268 OUT CHAR16
*Destination
,
270 IN CONST CHAR16
*Source
,
275 Appends a copy of the string pointed to by Source (including the terminating
276 null char) to the end of the string pointed to by Destination.
278 If Destination is not aligned on a 16-bit boundary, then ASSERT().
279 If Source is not aligned on a 16-bit boundary, then ASSERT().
280 If an error would be returned, then the function will also ASSERT().
282 @param Destination A pointer to a Null-terminated Unicode string.
283 @param DestMax The maximum number of Destination Unicode
284 char, including terminating null char.
285 @param Source A pointer to a Null-terminated Unicode string.
287 @retval RETURN_SUCCESS String is appended.
288 @retval RETURN_BAD_BUFFER_SIZE If DestMax is NOT greater than
290 @retval RETURN_BUFFER_TOO_SMALL If (DestMax - StrLen(Destination)) is NOT
291 greater than StrLen(Source).
292 @retval RETURN_INVALID_PARAMETER If Destination is NULL.
294 If PcdMaximumUnicodeStringLength is not zero,
295 and DestMax is greater than
296 PcdMaximumUnicodeStringLength.
298 @retval RETURN_ACCESS_DENIED If Source and Destination overlap.
303 IN OUT CHAR16
*Destination
,
305 IN CONST CHAR16
*Source
309 Appends not more than Length successive char from the string pointed to by
310 Source to the end of the string pointed to by Destination. If no null char is
311 copied from Source, then Destination[StrLen(Destination) + Length] is always
314 If Destination is not aligned on a 16-bit boundary, then ASSERT().
315 If Source is not aligned on a 16-bit boundary, then ASSERT().
316 If an error would be returned, then the function will also ASSERT().
318 @param Destination A pointer to a Null-terminated Unicode string.
319 @param DestMax The maximum number of Destination Unicode
320 char, including terminating null char.
321 @param Source A pointer to a Null-terminated Unicode string.
322 @param Length The maximum number of Unicode characters to copy.
324 @retval RETURN_SUCCESS String is appended.
325 @retval RETURN_BAD_BUFFER_SIZE If DestMax is NOT greater than
327 @retval RETURN_BUFFER_TOO_SMALL If (DestMax - StrLen(Destination)) is NOT
328 greater than MIN(StrLen(Source), Length).
329 @retval RETURN_INVALID_PARAMETER If Destination is NULL.
331 If PcdMaximumUnicodeStringLength is not zero,
332 and DestMax is greater than
333 PcdMaximumUnicodeStringLength.
335 @retval RETURN_ACCESS_DENIED If Source and Destination overlap.
340 IN OUT CHAR16
*Destination
,
342 IN CONST CHAR16
*Source
,
347 Returns the length of a Null-terminated Ascii string.
349 @param String A pointer to a Null-terminated Ascii string.
350 @param MaxSize The maximum number of Destination Ascii
351 char, including terminating null char.
353 @retval 0 If String is NULL.
354 @retval MaxSize If there is no null character in the first MaxSize characters of String.
355 @return The number of characters that percede the terminating null character.
361 IN CONST CHAR8
*String
,
366 Copies the string pointed to by Source (including the terminating null char)
367 to the array pointed to by Destination.
369 If an error would be returned, then the function will also ASSERT().
371 @param Destination A pointer to a Null-terminated Ascii string.
372 @param DestMax The maximum number of Destination Ascii
373 char, including terminating null char.
374 @param Source A pointer to a Null-terminated Ascii string.
376 @retval RETURN_SUCCESS String is copied.
377 @retval RETURN_BUFFER_TOO_SMALL If DestMax is NOT greater than StrLen(Source).
378 @retval RETURN_INVALID_PARAMETER If Destination is NULL.
380 If PcdMaximumAsciiStringLength is not zero,
381 and DestMax is greater than
382 PcdMaximumAsciiStringLength.
384 @retval RETURN_ACCESS_DENIED If Source and Destination overlap.
389 OUT CHAR8
*Destination
,
391 IN CONST CHAR8
*Source
395 Copies not more than Length successive char from the string pointed to by
396 Source to the array pointed to by Destination. If no null char is copied from
397 Source, then Destination[Length] is always set to null.
399 If an error would be returned, then the function will also ASSERT().
401 @param Destination A pointer to a Null-terminated Ascii string.
402 @param DestMax The maximum number of Destination Ascii
403 char, including terminating null char.
404 @param Source A pointer to a Null-terminated Ascii string.
405 @param Length The maximum number of Ascii characters to copy.
407 @retval RETURN_SUCCESS String is copied.
408 @retval RETURN_BUFFER_TOO_SMALL If DestMax is NOT greater than
409 MIN(StrLen(Source), Length).
410 @retval RETURN_INVALID_PARAMETER If Destination is NULL.
412 If PcdMaximumAsciiStringLength is not zero,
413 and DestMax is greater than
414 PcdMaximumAsciiStringLength.
416 @retval RETURN_ACCESS_DENIED If Source and Destination overlap.
421 OUT CHAR8
*Destination
,
423 IN CONST CHAR8
*Source
,
428 Appends a copy of the string pointed to by Source (including the terminating
429 null char) to the end of the string pointed to by Destination.
431 If an error would be returned, then the function will also ASSERT().
433 @param Destination A pointer to a Null-terminated Ascii string.
434 @param DestMax The maximum number of Destination Ascii
435 char, including terminating null char.
436 @param Source A pointer to a Null-terminated Ascii string.
438 @retval RETURN_SUCCESS String is appended.
439 @retval RETURN_BAD_BUFFER_SIZE If DestMax is NOT greater than
441 @retval RETURN_BUFFER_TOO_SMALL If (DestMax - StrLen(Destination)) is NOT
442 greater than StrLen(Source).
443 @retval RETURN_INVALID_PARAMETER If Destination is NULL.
445 If PcdMaximumAsciiStringLength is not zero,
446 and DestMax is greater than
447 PcdMaximumAsciiStringLength.
449 @retval RETURN_ACCESS_DENIED If Source and Destination overlap.
454 IN OUT CHAR8
*Destination
,
456 IN CONST CHAR8
*Source
460 Appends not more than Length successive char from the string pointed to by
461 Source to the end of the string pointed to by Destination. If no null char is
462 copied from Source, then Destination[StrLen(Destination) + Length] is always
465 If an error would be returned, then the function will also ASSERT().
467 @param Destination A pointer to a Null-terminated Ascii string.
468 @param DestMax The maximum number of Destination Ascii
469 char, including terminating null char.
470 @param Source A pointer to a Null-terminated Ascii string.
471 @param Length The maximum number of Ascii characters to copy.
473 @retval RETURN_SUCCESS String is appended.
474 @retval RETURN_BAD_BUFFER_SIZE If DestMax is NOT greater than
476 @retval RETURN_BUFFER_TOO_SMALL If (DestMax - StrLen(Destination)) is NOT
477 greater than MIN(StrLen(Source), Length).
478 @retval RETURN_INVALID_PARAMETER If Destination is NULL.
480 If PcdMaximumAsciiStringLength is not zero,
481 and DestMax is greater than
482 PcdMaximumAsciiStringLength.
484 @retval RETURN_ACCESS_DENIED If Source and Destination overlap.
489 IN OUT CHAR8
*Destination
,
491 IN CONST CHAR8
*Source
,
496 #ifndef DISABLE_NEW_DEPRECATED_INTERFACES
499 [ATTENTION] This function is deprecated for security reason.
501 Copies one Null-terminated Unicode string to another Null-terminated Unicode
502 string and returns the new Unicode string.
504 This function copies the contents of the Unicode string Source to the Unicode
505 string Destination, and returns Destination. If Source and Destination
506 overlap, then the results are undefined.
508 If Destination is NULL, then ASSERT().
509 If Destination is not aligned on a 16-bit boundary, then ASSERT().
510 If Source is NULL, then ASSERT().
511 If Source is not aligned on a 16-bit boundary, then ASSERT().
512 If Source and Destination overlap, then ASSERT().
513 If PcdMaximumUnicodeStringLength is not zero, and Source contains more than
514 PcdMaximumUnicodeStringLength Unicode characters not including the
515 Null-terminator, then ASSERT().
517 @param Destination The pointer to a Null-terminated Unicode string.
518 @param Source The pointer to a Null-terminated Unicode string.
526 OUT CHAR16
*Destination
,
527 IN CONST CHAR16
*Source
532 [ATTENTION] This function is deprecated for security reason.
534 Copies up to a specified length from one Null-terminated Unicode string to
535 another Null-terminated Unicode string and returns the new Unicode string.
537 This function copies the contents of the Unicode string Source to the Unicode
538 string Destination, and returns Destination. At most, Length Unicode
539 characters are copied from Source to Destination. If Length is 0, then
540 Destination is returned unmodified. If Length is greater that the number of
541 Unicode characters in Source, then Destination is padded with Null Unicode
542 characters. If Source and Destination overlap, then the results are
545 If Length > 0 and Destination is NULL, then ASSERT().
546 If Length > 0 and Destination is not aligned on a 16-bit boundary, then ASSERT().
547 If Length > 0 and Source is NULL, then ASSERT().
548 If Length > 0 and Source is not aligned on a 16-bit boundary, then ASSERT().
549 If Source and Destination overlap, then ASSERT().
550 If PcdMaximumUnicodeStringLength is not zero, and Length is greater than
551 PcdMaximumUnicodeStringLength, then ASSERT().
552 If PcdMaximumUnicodeStringLength is not zero, and Source contains more than
553 PcdMaximumUnicodeStringLength Unicode characters, not including the Null-terminator,
556 @param Destination The pointer to a Null-terminated Unicode string.
557 @param Source The pointer to a Null-terminated Unicode string.
558 @param Length The maximum number of Unicode characters to copy.
566 OUT CHAR16
*Destination
,
567 IN CONST CHAR16
*Source
,
573 Returns the length of a Null-terminated Unicode string.
575 This function returns the number of Unicode characters in the Null-terminated
576 Unicode string specified by String.
578 If String is NULL, then ASSERT().
579 If String is not aligned on a 16-bit boundary, then ASSERT().
580 If PcdMaximumUnicodeStringLength is not zero, and String contains more than
581 PcdMaximumUnicodeStringLength Unicode characters not including the
582 Null-terminator, then ASSERT().
584 @param String Pointer to a Null-terminated Unicode string.
586 @return The length of String.
592 IN CONST CHAR16
*String
597 Returns the size of a Null-terminated Unicode string in bytes, including the
600 This function returns the size, in bytes, of the Null-terminated Unicode string
603 If String is NULL, then ASSERT().
604 If String is not aligned on a 16-bit boundary, then ASSERT().
605 If PcdMaximumUnicodeStringLength is not zero, and String contains more than
606 PcdMaximumUnicodeStringLength Unicode characters not including the
607 Null-terminator, then ASSERT().
609 @param String The pointer to a Null-terminated Unicode string.
611 @return The size of String.
617 IN CONST CHAR16
*String
622 Compares two Null-terminated Unicode strings, and returns the difference
623 between the first mismatched Unicode characters.
625 This function compares the Null-terminated Unicode string FirstString to the
626 Null-terminated Unicode string SecondString. If FirstString is identical to
627 SecondString, then 0 is returned. Otherwise, the value returned is the first
628 mismatched Unicode character in SecondString subtracted from the first
629 mismatched Unicode character in FirstString.
631 If FirstString is NULL, then ASSERT().
632 If FirstString is not aligned on a 16-bit boundary, then ASSERT().
633 If SecondString is NULL, then ASSERT().
634 If SecondString is not aligned on a 16-bit boundary, then ASSERT().
635 If PcdMaximumUnicodeStringLength is not zero, and FirstString contains more
636 than PcdMaximumUnicodeStringLength Unicode characters not including the
637 Null-terminator, then ASSERT().
638 If PcdMaximumUnicodeStringLength is not zero, and SecondString contains more
639 than PcdMaximumUnicodeStringLength Unicode characters, not including the
640 Null-terminator, then ASSERT().
642 @param FirstString The pointer to a Null-terminated Unicode string.
643 @param SecondString The pointer to a Null-terminated Unicode string.
645 @retval 0 FirstString is identical to SecondString.
646 @return others FirstString is not identical to SecondString.
652 IN CONST CHAR16
*FirstString
,
653 IN CONST CHAR16
*SecondString
658 Compares up to a specified length the contents of two Null-terminated Unicode strings,
659 and returns the difference between the first mismatched Unicode characters.
661 This function compares the Null-terminated Unicode string FirstString to the
662 Null-terminated Unicode string SecondString. At most, Length Unicode
663 characters will be compared. If Length is 0, then 0 is returned. If
664 FirstString is identical to SecondString, then 0 is returned. Otherwise, the
665 value returned is the first mismatched Unicode character in SecondString
666 subtracted from the first mismatched Unicode character in FirstString.
668 If Length > 0 and FirstString is NULL, then ASSERT().
669 If Length > 0 and FirstString is not aligned on a 16-bit boundary, then ASSERT().
670 If Length > 0 and SecondString is NULL, then ASSERT().
671 If Length > 0 and SecondString is not aligned on a 16-bit boundary, then ASSERT().
672 If PcdMaximumUnicodeStringLength is not zero, and Length is greater than
673 PcdMaximumUnicodeStringLength, then ASSERT().
674 If PcdMaximumUnicodeStringLength is not zero, and FirstString contains more than
675 PcdMaximumUnicodeStringLength Unicode characters, not including the Null-terminator,
677 If PcdMaximumUnicodeStringLength is not zero, and SecondString contains more than
678 PcdMaximumUnicodeStringLength Unicode characters, not including the Null-terminator,
681 @param FirstString The pointer to a Null-terminated Unicode string.
682 @param SecondString The pointer to a Null-terminated Unicode string.
683 @param Length The maximum number of Unicode characters to compare.
685 @retval 0 FirstString is identical to SecondString.
686 @return others FirstString is not identical to SecondString.
692 IN CONST CHAR16
*FirstString
,
693 IN CONST CHAR16
*SecondString
,
698 #ifndef DISABLE_NEW_DEPRECATED_INTERFACES
701 [ATTENTION] This function is deprecated for security reason.
703 Concatenates one Null-terminated Unicode string to another Null-terminated
704 Unicode string, and returns the concatenated Unicode string.
706 This function concatenates two Null-terminated Unicode strings. The contents
707 of Null-terminated Unicode string Source are concatenated to the end of
708 Null-terminated Unicode string Destination. The Null-terminated concatenated
709 Unicode String is returned. If Source and Destination overlap, then the
710 results are undefined.
712 If Destination is NULL, then ASSERT().
713 If Destination is not aligned on a 16-bit boundary, then ASSERT().
714 If Source is NULL, then ASSERT().
715 If Source is not aligned on a 16-bit boundary, then ASSERT().
716 If Source and Destination overlap, then ASSERT().
717 If PcdMaximumUnicodeStringLength is not zero, and Destination contains more
718 than PcdMaximumUnicodeStringLength Unicode characters, not including the
719 Null-terminator, then ASSERT().
720 If PcdMaximumUnicodeStringLength is not zero, and Source contains more than
721 PcdMaximumUnicodeStringLength Unicode characters, not including the
722 Null-terminator, then ASSERT().
723 If PcdMaximumUnicodeStringLength is not zero, and concatenating Destination
724 and Source results in a Unicode string with more than
725 PcdMaximumUnicodeStringLength Unicode characters, not including the
726 Null-terminator, then ASSERT().
728 @param Destination The pointer to a Null-terminated Unicode string.
729 @param Source The pointer to a Null-terminated Unicode string.
737 IN OUT CHAR16
*Destination
,
738 IN CONST CHAR16
*Source
743 [ATTENTION] This function is deprecated for security reason.
745 Concatenates up to a specified length one Null-terminated Unicode to the end
746 of another Null-terminated Unicode string, and returns the concatenated
749 This function concatenates two Null-terminated Unicode strings. The contents
750 of Null-terminated Unicode string Source are concatenated to the end of
751 Null-terminated Unicode string Destination, and Destination is returned. At
752 most, Length Unicode characters are concatenated from Source to the end of
753 Destination, and Destination is always Null-terminated. If Length is 0, then
754 Destination is returned unmodified. If Source and Destination overlap, then
755 the results are undefined.
757 If Destination is NULL, then ASSERT().
758 If Length > 0 and Destination is not aligned on a 16-bit boundary, then ASSERT().
759 If Length > 0 and Source is NULL, then ASSERT().
760 If Length > 0 and Source is not aligned on a 16-bit boundary, then ASSERT().
761 If Source and Destination overlap, then ASSERT().
762 If PcdMaximumUnicodeStringLength is not zero, and Length is greater than
763 PcdMaximumUnicodeStringLength, then ASSERT().
764 If PcdMaximumUnicodeStringLength is not zero, and Destination contains more
765 than PcdMaximumUnicodeStringLength Unicode characters, not including the
766 Null-terminator, then ASSERT().
767 If PcdMaximumUnicodeStringLength is not zero, and Source contains more than
768 PcdMaximumUnicodeStringLength Unicode characters, not including the
769 Null-terminator, then ASSERT().
770 If PcdMaximumUnicodeStringLength is not zero, and concatenating Destination
771 and Source results in a Unicode string with more than PcdMaximumUnicodeStringLength
772 Unicode characters, not including the Null-terminator, then ASSERT().
774 @param Destination The pointer to a Null-terminated Unicode string.
775 @param Source The pointer to a Null-terminated Unicode string.
776 @param Length The maximum number of Unicode characters to concatenate from
785 IN OUT CHAR16
*Destination
,
786 IN CONST CHAR16
*Source
,
792 Returns the first occurrence of a Null-terminated Unicode sub-string
793 in a Null-terminated Unicode string.
795 This function scans the contents of the Null-terminated Unicode string
796 specified by String and returns the first occurrence of SearchString.
797 If SearchString is not found in String, then NULL is returned. If
798 the length of SearchString is zero, then String is returned.
800 If String is NULL, then ASSERT().
801 If String is not aligned on a 16-bit boundary, then ASSERT().
802 If SearchString is NULL, then ASSERT().
803 If SearchString is not aligned on a 16-bit boundary, then ASSERT().
805 If PcdMaximumUnicodeStringLength is not zero, and SearchString
806 or String contains more than PcdMaximumUnicodeStringLength Unicode
807 characters, not including the Null-terminator, then ASSERT().
809 @param String The pointer to a Null-terminated Unicode string.
810 @param SearchString The pointer to a Null-terminated Unicode string to search for.
812 @retval NULL If the SearchString does not appear in String.
813 @return others If there is a match.
819 IN CONST CHAR16
*String
,
820 IN CONST CHAR16
*SearchString
824 Convert a Null-terminated Unicode decimal string to a value of
827 This function returns a value of type UINTN by interpreting the contents
828 of the Unicode string specified by String as a decimal number. The format
829 of the input Unicode string String is:
831 [spaces] [decimal digits].
833 The valid decimal digit character is in the range [0-9]. The
834 function will ignore the pad space, which includes spaces or
835 tab characters, before [decimal digits]. The running zero in the
836 beginning of [decimal digits] will be ignored. Then, the function
837 stops at the first character that is a not a valid decimal character
838 or a Null-terminator, whichever one comes first.
840 If String is NULL, then ASSERT().
841 If String is not aligned in a 16-bit boundary, then ASSERT().
842 If String has only pad spaces, then 0 is returned.
843 If String has no pad spaces or valid decimal digits,
845 If the number represented by String overflows according
846 to the range defined by UINTN, then ASSERT().
848 If PcdMaximumUnicodeStringLength is not zero, and String contains
849 more than PcdMaximumUnicodeStringLength Unicode characters not including
850 the Null-terminator, then ASSERT().
852 @param String The pointer to a Null-terminated Unicode string.
854 @retval Value translated from String.
860 IN CONST CHAR16
*String
864 Convert a Null-terminated Unicode decimal string to a value of
867 This function returns a value of type UINT64 by interpreting the contents
868 of the Unicode string specified by String as a decimal number. The format
869 of the input Unicode string String is:
871 [spaces] [decimal digits].
873 The valid decimal digit character is in the range [0-9]. The
874 function will ignore the pad space, which includes spaces or
875 tab characters, before [decimal digits]. The running zero in the
876 beginning of [decimal digits] will be ignored. Then, the function
877 stops at the first character that is a not a valid decimal character
878 or a Null-terminator, whichever one comes first.
880 If String is NULL, then ASSERT().
881 If String is not aligned in a 16-bit boundary, then ASSERT().
882 If String has only pad spaces, then 0 is returned.
883 If String has no pad spaces or valid decimal digits,
885 If the number represented by String overflows according
886 to the range defined by UINT64, then ASSERT().
888 If PcdMaximumUnicodeStringLength is not zero, and String contains
889 more than PcdMaximumUnicodeStringLength Unicode characters not including
890 the Null-terminator, then ASSERT().
892 @param String The pointer to a Null-terminated Unicode string.
894 @retval Value translated from String.
900 IN CONST CHAR16
*String
905 Convert a Null-terminated Unicode hexadecimal string to a value of type UINTN.
907 This function returns a value of type UINTN by interpreting the contents
908 of the Unicode string specified by String as a hexadecimal number.
909 The format of the input Unicode string String is:
911 [spaces][zeros][x][hexadecimal digits].
913 The valid hexadecimal digit character is in the range [0-9], [a-f] and [A-F].
914 The prefix "0x" is optional. Both "x" and "X" is allowed in "0x" prefix.
915 If "x" appears in the input string, it must be prefixed with at least one 0.
916 The function will ignore the pad space, which includes spaces or tab characters,
917 before [zeros], [x] or [hexadecimal digit]. The running zero before [x] or
918 [hexadecimal digit] will be ignored. Then, the decoding starts after [x] or the
919 first valid hexadecimal digit. Then, the function stops at the first character
920 that is a not a valid hexadecimal character or NULL, whichever one comes first.
922 If String is NULL, then ASSERT().
923 If String is not aligned in a 16-bit boundary, then ASSERT().
924 If String has only pad spaces, then zero is returned.
925 If String has no leading pad spaces, leading zeros or valid hexadecimal digits,
926 then zero is returned.
927 If the number represented by String overflows according to the range defined by
928 UINTN, then ASSERT().
930 If PcdMaximumUnicodeStringLength is not zero, and String contains more than
931 PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator,
934 @param String The pointer to a Null-terminated Unicode string.
936 @retval Value translated from String.
942 IN CONST CHAR16
*String
947 Convert a Null-terminated Unicode hexadecimal string to a value of type UINT64.
949 This function returns a value of type UINT64 by interpreting the contents
950 of the Unicode string specified by String as a hexadecimal number.
951 The format of the input Unicode string String is
953 [spaces][zeros][x][hexadecimal digits].
955 The valid hexadecimal digit character is in the range [0-9], [a-f] and [A-F].
956 The prefix "0x" is optional. Both "x" and "X" is allowed in "0x" prefix.
957 If "x" appears in the input string, it must be prefixed with at least one 0.
958 The function will ignore the pad space, which includes spaces or tab characters,
959 before [zeros], [x] or [hexadecimal digit]. The running zero before [x] or
960 [hexadecimal digit] will be ignored. Then, the decoding starts after [x] or the
961 first valid hexadecimal digit. Then, the function stops at the first character that is
962 a not a valid hexadecimal character or NULL, whichever one comes first.
964 If String is NULL, then ASSERT().
965 If String is not aligned in a 16-bit boundary, then ASSERT().
966 If String has only pad spaces, then zero is returned.
967 If String has no leading pad spaces, leading zeros or valid hexadecimal digits,
968 then zero is returned.
969 If the number represented by String overflows according to the range defined by
970 UINT64, then ASSERT().
972 If PcdMaximumUnicodeStringLength is not zero, and String contains more than
973 PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator,
976 @param String The pointer to a Null-terminated Unicode string.
978 @retval Value translated from String.
984 IN CONST CHAR16
*String
988 Convert a Null-terminated Unicode string to a Null-terminated
989 ASCII string and returns the ASCII string.
991 This function converts the content of the Unicode string Source
992 to the ASCII string Destination by copying the lower 8 bits of
993 each Unicode character. It returns Destination.
995 The caller is responsible to make sure Destination points to a buffer with size
996 equal or greater than ((StrLen (Source) + 1) * sizeof (CHAR8)) in bytes.
998 If any Unicode characters in Source contain non-zero value in
999 the upper 8 bits, then ASSERT().
1001 If Destination is NULL, then ASSERT().
1002 If Source is NULL, then ASSERT().
1003 If Source is not aligned on a 16-bit boundary, then ASSERT().
1004 If Source and Destination overlap, then ASSERT().
1006 If PcdMaximumUnicodeStringLength is not zero, and Source contains
1007 more than PcdMaximumUnicodeStringLength Unicode characters not including
1008 the Null-terminator, then ASSERT().
1010 If PcdMaximumAsciiStringLength is not zero, and Source contains more
1011 than PcdMaximumAsciiStringLength Unicode characters not including the
1012 Null-terminator, then ASSERT().
1014 @param Source The pointer to a Null-terminated Unicode string.
1015 @param Destination The pointer to a Null-terminated ASCII string.
1017 @return Destination.
1022 UnicodeStrToAsciiStr (
1023 IN CONST CHAR16
*Source
,
1024 OUT CHAR8
*Destination
1028 #ifndef DISABLE_NEW_DEPRECATED_INTERFACES
1031 [ATTENTION] This function is deprecated for security reason.
1033 Copies one Null-terminated ASCII string to another Null-terminated ASCII
1034 string and returns the new ASCII string.
1036 This function copies the contents of the ASCII string Source to the ASCII
1037 string Destination, and returns Destination. If Source and Destination
1038 overlap, then the results are undefined.
1040 If Destination is NULL, then ASSERT().
1041 If Source is NULL, then ASSERT().
1042 If Source and Destination overlap, then ASSERT().
1043 If PcdMaximumAsciiStringLength is not zero and Source contains more than
1044 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
1047 @param Destination The pointer to a Null-terminated ASCII string.
1048 @param Source The pointer to a Null-terminated ASCII string.
1056 OUT CHAR8
*Destination
,
1057 IN CONST CHAR8
*Source
1062 [ATTENTION] This function is deprecated for security reason.
1064 Copies up to a specified length one Null-terminated ASCII string to another
1065 Null-terminated ASCII string and returns the new ASCII string.
1067 This function copies the contents of the ASCII string Source to the ASCII
1068 string Destination, and returns Destination. At most, Length ASCII characters
1069 are copied from Source to Destination. If Length is 0, then Destination is
1070 returned unmodified. If Length is greater that the number of ASCII characters
1071 in Source, then Destination is padded with Null ASCII characters. If Source
1072 and Destination overlap, then the results are undefined.
1074 If Destination is NULL, then ASSERT().
1075 If Source is NULL, then ASSERT().
1076 If Source and Destination overlap, then ASSERT().
1077 If PcdMaximumAsciiStringLength is not zero, and Length is greater than
1078 PcdMaximumAsciiStringLength, 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.
1085 @param Length The maximum number of ASCII characters to copy.
1093 OUT CHAR8
*Destination
,
1094 IN CONST CHAR8
*Source
,
1100 Returns the length of a Null-terminated ASCII string.
1102 This function returns the number of ASCII characters in the Null-terminated
1103 ASCII string specified by String.
1105 If Length > 0 and Destination is NULL, then ASSERT().
1106 If Length > 0 and Source is NULL, then ASSERT().
1107 If PcdMaximumAsciiStringLength is not zero and String contains more than
1108 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
1111 @param String The pointer to a Null-terminated ASCII string.
1113 @return The length of String.
1119 IN CONST CHAR8
*String
1124 Returns the size of a Null-terminated ASCII string in bytes, including the
1127 This function returns the size, in bytes, of the Null-terminated ASCII string
1128 specified by String.
1130 If String is NULL, then ASSERT().
1131 If PcdMaximumAsciiStringLength is not zero and String contains more than
1132 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
1135 @param String The pointer to a Null-terminated ASCII string.
1137 @return The size of String.
1143 IN CONST CHAR8
*String
1148 Compares two Null-terminated ASCII strings, and returns the difference
1149 between the first mismatched ASCII characters.
1151 This function compares the Null-terminated ASCII string FirstString to the
1152 Null-terminated ASCII string SecondString. If FirstString is identical to
1153 SecondString, then 0 is returned. Otherwise, the value returned is the first
1154 mismatched ASCII character in SecondString subtracted from the first
1155 mismatched ASCII character in FirstString.
1157 If FirstString is NULL, then ASSERT().
1158 If SecondString is NULL, then ASSERT().
1159 If PcdMaximumAsciiStringLength is not zero and FirstString contains more than
1160 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
1162 If PcdMaximumAsciiStringLength is not zero and SecondString contains more
1163 than PcdMaximumAsciiStringLength ASCII characters not including the
1164 Null-terminator, then ASSERT().
1166 @param FirstString The pointer to a Null-terminated ASCII string.
1167 @param SecondString The pointer to a Null-terminated ASCII string.
1169 @retval ==0 FirstString is identical to SecondString.
1170 @retval !=0 FirstString is not identical to SecondString.
1176 IN CONST CHAR8
*FirstString
,
1177 IN CONST CHAR8
*SecondString
1182 Performs a case insensitive comparison of two Null-terminated ASCII strings,
1183 and returns the difference between the first mismatched ASCII characters.
1185 This function performs a case insensitive comparison of the Null-terminated
1186 ASCII string FirstString to the Null-terminated ASCII string SecondString. If
1187 FirstString is identical to SecondString, then 0 is returned. Otherwise, the
1188 value returned is the first mismatched lower case ASCII character in
1189 SecondString subtracted from the first mismatched lower case ASCII character
1192 If FirstString is NULL, then ASSERT().
1193 If SecondString is NULL, then ASSERT().
1194 If PcdMaximumAsciiStringLength is not zero and FirstString contains more than
1195 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
1197 If PcdMaximumAsciiStringLength is not zero and SecondString contains more
1198 than PcdMaximumAsciiStringLength ASCII characters not including the
1199 Null-terminator, then ASSERT().
1201 @param FirstString The pointer to a Null-terminated ASCII string.
1202 @param SecondString The pointer to a Null-terminated ASCII string.
1204 @retval ==0 FirstString is identical to SecondString using case insensitive
1206 @retval !=0 FirstString is not identical to SecondString using case
1207 insensitive comparisons.
1213 IN CONST CHAR8
*FirstString
,
1214 IN CONST CHAR8
*SecondString
1219 Compares two Null-terminated ASCII strings with maximum lengths, and returns
1220 the difference between the first mismatched ASCII characters.
1222 This function compares the Null-terminated ASCII string FirstString to the
1223 Null-terminated ASCII string SecondString. At most, Length ASCII characters
1224 will be compared. If Length is 0, then 0 is returned. If FirstString is
1225 identical to SecondString, then 0 is returned. Otherwise, the value returned
1226 is the first mismatched ASCII character in SecondString subtracted from the
1227 first mismatched ASCII character in FirstString.
1229 If Length > 0 and FirstString is NULL, then ASSERT().
1230 If Length > 0 and SecondString is NULL, then ASSERT().
1231 If PcdMaximumAsciiStringLength is not zero, and Length is greater than
1232 PcdMaximumAsciiStringLength, then ASSERT().
1233 If PcdMaximumAsciiStringLength is not zero, and FirstString contains more than
1234 PcdMaximumAsciiStringLength ASCII characters, not including the Null-terminator,
1236 If PcdMaximumAsciiStringLength is not zero, and SecondString contains more than
1237 PcdMaximumAsciiStringLength ASCII characters, not including the Null-terminator,
1240 @param FirstString The pointer to a Null-terminated ASCII string.
1241 @param SecondString The pointer to a Null-terminated ASCII string.
1242 @param Length The maximum number of ASCII characters for compare.
1244 @retval ==0 FirstString is identical to SecondString.
1245 @retval !=0 FirstString is not identical to SecondString.
1251 IN CONST CHAR8
*FirstString
,
1252 IN CONST CHAR8
*SecondString
,
1257 #ifndef DISABLE_NEW_DEPRECATED_INTERFACES
1260 [ATTENTION] This function is deprecated for security reason.
1262 Concatenates one Null-terminated ASCII string to another Null-terminated
1263 ASCII string, and returns the concatenated ASCII string.
1265 This function concatenates two Null-terminated ASCII strings. The contents of
1266 Null-terminated ASCII string Source are concatenated to the end of Null-
1267 terminated ASCII string Destination. The Null-terminated concatenated ASCII
1270 If Destination is NULL, then ASSERT().
1271 If Source is NULL, then ASSERT().
1272 If PcdMaximumAsciiStringLength is not zero and Destination contains more than
1273 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
1275 If PcdMaximumAsciiStringLength is not zero and Source contains more than
1276 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
1278 If PcdMaximumAsciiStringLength is not zero and concatenating Destination and
1279 Source results in a ASCII string with more than PcdMaximumAsciiStringLength
1280 ASCII characters, then ASSERT().
1282 @param Destination The pointer to a Null-terminated ASCII string.
1283 @param Source The pointer to a Null-terminated ASCII string.
1291 IN OUT CHAR8
*Destination
,
1292 IN CONST CHAR8
*Source
1297 [ATTENTION] This function is deprecated for security reason.
1299 Concatenates up to a specified length one Null-terminated ASCII string to
1300 the end of another Null-terminated ASCII string, and returns the
1301 concatenated ASCII string.
1303 This function concatenates two Null-terminated ASCII strings. The contents
1304 of Null-terminated ASCII string Source are concatenated to the end of Null-
1305 terminated ASCII string Destination, and Destination is returned. At most,
1306 Length ASCII characters are concatenated from Source to the end of
1307 Destination, and Destination is always Null-terminated. If Length is 0, then
1308 Destination is returned unmodified. If Source and Destination overlap, then
1309 the results are undefined.
1311 If Length > 0 and Destination is NULL, then ASSERT().
1312 If Length > 0 and Source is NULL, then ASSERT().
1313 If Source and Destination overlap, then ASSERT().
1314 If PcdMaximumAsciiStringLength is not zero, and Length is greater than
1315 PcdMaximumAsciiStringLength, then ASSERT().
1316 If PcdMaximumAsciiStringLength is not zero, and Destination contains more than
1317 PcdMaximumAsciiStringLength ASCII characters, not including the Null-terminator,
1319 If PcdMaximumAsciiStringLength is not zero, and Source contains more than
1320 PcdMaximumAsciiStringLength ASCII characters, not including the Null-terminator,
1322 If PcdMaximumAsciiStringLength is not zero, and concatenating Destination and
1323 Source results in a ASCII string with more than PcdMaximumAsciiStringLength
1324 ASCII characters, not including the Null-terminator, then ASSERT().
1326 @param Destination The pointer to a Null-terminated ASCII string.
1327 @param Source The pointer to a Null-terminated ASCII string.
1328 @param Length The maximum number of ASCII characters to concatenate from
1337 IN OUT CHAR8
*Destination
,
1338 IN CONST CHAR8
*Source
,
1344 Returns the first occurrence of a Null-terminated ASCII sub-string
1345 in a Null-terminated ASCII string.
1347 This function scans the contents of the ASCII string specified by String
1348 and returns the first occurrence of SearchString. If SearchString is not
1349 found in String, then NULL is returned. If the length of SearchString is zero,
1350 then String is returned.
1352 If String is NULL, then ASSERT().
1353 If SearchString is NULL, then ASSERT().
1355 If PcdMaximumAsciiStringLength is not zero, and SearchString or
1356 String contains more than PcdMaximumAsciiStringLength Unicode characters
1357 not including the Null-terminator, then ASSERT().
1359 @param String The pointer to a Null-terminated ASCII string.
1360 @param SearchString The pointer to a Null-terminated ASCII string to search for.
1362 @retval NULL If the SearchString does not appear in String.
1363 @retval others If there is a match return the first occurrence of SearchingString.
1364 If the length of SearchString is zero,return String.
1370 IN CONST CHAR8
*String
,
1371 IN CONST CHAR8
*SearchString
1376 Convert a Null-terminated ASCII decimal string to a value of type
1379 This function returns a value of type UINTN by interpreting the contents
1380 of the ASCII string String as a decimal number. The format of the input
1381 ASCII string String is:
1383 [spaces] [decimal digits].
1385 The valid decimal digit character is in the range [0-9]. The function will
1386 ignore the pad space, which includes spaces or tab characters, before the digits.
1387 The running zero in the beginning of [decimal digits] will be ignored. Then, the
1388 function stops at the first character that is a not a valid decimal character or
1389 Null-terminator, whichever on comes first.
1391 If String has only pad spaces, then 0 is returned.
1392 If String has no pad spaces or valid decimal digits, then 0 is returned.
1393 If the number represented by String overflows according to the range defined by
1394 UINTN, then ASSERT().
1395 If String is NULL, then ASSERT().
1396 If PcdMaximumAsciiStringLength is not zero, and String contains more than
1397 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
1400 @param String The pointer to a Null-terminated ASCII string.
1402 @retval The value translated from String.
1407 AsciiStrDecimalToUintn (
1408 IN CONST CHAR8
*String
1413 Convert a Null-terminated ASCII decimal string to a value of type
1416 This function returns a value of type UINT64 by interpreting the contents
1417 of the ASCII string String as a decimal number. The format of the input
1418 ASCII string String is:
1420 [spaces] [decimal digits].
1422 The valid decimal digit character is in the range [0-9]. The function will
1423 ignore the pad space, which includes spaces or tab characters, before the digits.
1424 The running zero in the beginning of [decimal digits] will be ignored. Then, the
1425 function stops at the first character that is a not a valid decimal character or
1426 Null-terminator, whichever on comes first.
1428 If String has only pad spaces, then 0 is returned.
1429 If String has no pad spaces or valid decimal digits, then 0 is returned.
1430 If the number represented by String overflows according to the range defined by
1431 UINT64, then ASSERT().
1432 If String is NULL, then ASSERT().
1433 If PcdMaximumAsciiStringLength is not zero, and String contains more than
1434 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
1437 @param String The pointer to a Null-terminated ASCII string.
1439 @retval Value translated from String.
1444 AsciiStrDecimalToUint64 (
1445 IN CONST CHAR8
*String
1450 Convert a Null-terminated ASCII hexadecimal string to a value of type UINTN.
1452 This function returns a value of type UINTN by interpreting the contents of
1453 the ASCII string String as a hexadecimal number. The format of the input ASCII
1456 [spaces][zeros][x][hexadecimal digits].
1458 The valid hexadecimal digit character is in the range [0-9], [a-f] and [A-F].
1459 The prefix "0x" is optional. Both "x" and "X" is allowed in "0x" prefix. If "x"
1460 appears in the input string, it must be prefixed with at least one 0. The function
1461 will ignore the pad space, which includes spaces or tab characters, before [zeros],
1462 [x] or [hexadecimal digits]. The running zero before [x] or [hexadecimal digits]
1463 will be ignored. Then, the decoding starts after [x] or the first valid hexadecimal
1464 digit. Then, the function stops at the first character that is a not a valid
1465 hexadecimal character or Null-terminator, whichever on comes first.
1467 If String has only pad spaces, then 0 is returned.
1468 If String has no leading pad spaces, leading zeros or valid hexadecimal digits, then
1471 If the number represented by String overflows according to the range defined by UINTN,
1473 If String is NULL, then ASSERT().
1474 If PcdMaximumAsciiStringLength is not zero,
1475 and String contains more than PcdMaximumAsciiStringLength ASCII characters not including
1476 the Null-terminator, then ASSERT().
1478 @param String The pointer to a Null-terminated ASCII string.
1480 @retval Value translated from String.
1485 AsciiStrHexToUintn (
1486 IN CONST CHAR8
*String
1491 Convert a Null-terminated ASCII hexadecimal string to a value of type UINT64.
1493 This function returns a value of type UINT64 by interpreting the contents of
1494 the ASCII string String as a hexadecimal number. The format of the input ASCII
1497 [spaces][zeros][x][hexadecimal digits].
1499 The valid hexadecimal digit character is in the range [0-9], [a-f] and [A-F].
1500 The prefix "0x" is optional. Both "x" and "X" is allowed in "0x" prefix. If "x"
1501 appears in the input string, it must be prefixed with at least one 0. The function
1502 will ignore the pad space, which includes spaces or tab characters, before [zeros],
1503 [x] or [hexadecimal digits]. The running zero before [x] or [hexadecimal digits]
1504 will be ignored. Then, the decoding starts after [x] or the first valid hexadecimal
1505 digit. Then, the function stops at the first character that is a not a valid
1506 hexadecimal character or Null-terminator, whichever on comes first.
1508 If String has only pad spaces, then 0 is returned.
1509 If String has no leading pad spaces, leading zeros or valid hexadecimal digits, then
1512 If the number represented by String overflows according to the range defined by UINT64,
1514 If String is NULL, then ASSERT().
1515 If PcdMaximumAsciiStringLength is not zero,
1516 and String contains more than PcdMaximumAsciiStringLength ASCII characters not including
1517 the Null-terminator, then ASSERT().
1519 @param String The pointer to a Null-terminated ASCII string.
1521 @retval Value translated from String.
1526 AsciiStrHexToUint64 (
1527 IN CONST CHAR8
*String
1532 Convert one Null-terminated ASCII string to a Null-terminated
1533 Unicode string and returns the Unicode string.
1535 This function converts the contents of the ASCII string Source to the Unicode
1536 string Destination, and returns Destination. The function terminates the
1537 Unicode string Destination by appending a Null-terminator character at the end.
1538 The caller is responsible to make sure Destination points to a buffer with size
1539 equal or greater than ((AsciiStrLen (Source) + 1) * sizeof (CHAR16)) in bytes.
1541 If Destination is NULL, then ASSERT().
1542 If Destination is not aligned on a 16-bit boundary, then ASSERT().
1543 If Source is NULL, then ASSERT().
1544 If Source and Destination overlap, then ASSERT().
1545 If PcdMaximumAsciiStringLength is not zero, and Source contains more than
1546 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
1548 If PcdMaximumUnicodeStringLength is not zero, and Source contains more than
1549 PcdMaximumUnicodeStringLength ASCII characters not including the
1550 Null-terminator, then ASSERT().
1552 @param Source The pointer to a Null-terminated ASCII string.
1553 @param Destination The pointer to a Null-terminated Unicode string.
1555 @return Destination.
1560 AsciiStrToUnicodeStr (
1561 IN CONST CHAR8
*Source
,
1562 OUT CHAR16
*Destination
1567 Converts an 8-bit value to an 8-bit BCD value.
1569 Converts the 8-bit value specified by Value to BCD. The BCD value is
1572 If Value >= 100, then ASSERT().
1574 @param Value The 8-bit value to convert to BCD. Range 0..99.
1576 @return The BCD value.
1587 Converts an 8-bit BCD value to an 8-bit value.
1589 Converts the 8-bit BCD value specified by Value to an 8-bit value. The 8-bit
1592 If Value >= 0xA0, then ASSERT().
1593 If (Value & 0x0F) >= 0x0A, then ASSERT().
1595 @param Value The 8-bit BCD value to convert to an 8-bit value.
1597 @return The 8-bit value is returned.
1607 // File Path Manipulation Functions
1611 Removes the last directory or file entry in a path by changing the last
1612 L'\' to a CHAR_NULL.
1614 @param[in, out] Path The pointer to the path to modify.
1616 @retval FALSE Nothing was found to remove.
1617 @retval TRUE A directory or file was removed.
1626 Function to clean up paths.
1627 - Single periods in the path are removed.
1628 - Double periods in the path are removed along with a single parent directory.
1629 - Forward slashes L'/' are converted to backward slashes L'\'.
1631 This will be done inline and the existing buffer may be larger than required
1634 @param[in] Path The pointer to the string containing the path.
1636 @return Returns Path, otherwise returns NULL to indicate that an error has occured.
1640 PathCleanUpDirectories(
1645 // Linked List Functions and Macros
1649 Initializes the head node of a doubly linked list that is declared as a
1650 global variable in a module.
1652 Initializes the forward and backward links of a new linked list. After
1653 initializing a linked list with this macro, the other linked list functions
1654 may be used to add and remove nodes from the linked list. This macro results
1655 in smaller executables by initializing the linked list in the data section,
1656 instead if calling the InitializeListHead() function to perform the
1657 equivalent operation.
1659 @param ListHead The head note of a list to initialize.
1662 #define INITIALIZE_LIST_HEAD_VARIABLE(ListHead) {&(ListHead), &(ListHead)}
1666 Initializes the head node of a doubly linked list, and returns the pointer to
1667 the head node of the doubly linked list.
1669 Initializes the forward and backward links of a new linked list. After
1670 initializing a linked list with this function, the other linked list
1671 functions may be used to add and remove nodes from the linked list. It is up
1672 to the caller of this function to allocate the memory for ListHead.
1674 If ListHead is NULL, then ASSERT().
1676 @param ListHead A pointer to the head node of a new doubly linked list.
1683 InitializeListHead (
1684 IN OUT LIST_ENTRY
*ListHead
1689 Adds a node to the beginning of a doubly linked list, and returns the pointer
1690 to the head node of the doubly linked list.
1692 Adds the node Entry at the beginning of the doubly linked list denoted by
1693 ListHead, and returns ListHead.
1695 If ListHead is NULL, then ASSERT().
1696 If Entry is NULL, then ASSERT().
1697 If ListHead was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or
1698 InitializeListHead(), then ASSERT().
1699 If PcdMaximumLinkedListLength is not zero, and prior to insertion the number
1700 of nodes in ListHead, including the ListHead node, is greater than or
1701 equal to PcdMaximumLinkedListLength, then ASSERT().
1703 @param ListHead A pointer to the head node of a doubly linked list.
1704 @param Entry A pointer to a node that is to be inserted at the beginning
1705 of a doubly linked list.
1713 IN OUT LIST_ENTRY
*ListHead
,
1714 IN OUT LIST_ENTRY
*Entry
1719 Adds a node to the end of a doubly linked list, and returns the pointer to
1720 the head node of the doubly linked list.
1722 Adds the node Entry to the end of the doubly linked list denoted by ListHead,
1723 and returns ListHead.
1725 If ListHead is NULL, then ASSERT().
1726 If Entry is NULL, then ASSERT().
1727 If ListHead was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or
1728 InitializeListHead(), then ASSERT().
1729 If PcdMaximumLinkedListLength is not zero, and prior to insertion the number
1730 of nodes in ListHead, including the ListHead node, is greater than or
1731 equal to PcdMaximumLinkedListLength, then ASSERT().
1733 @param ListHead A pointer to the head node of a doubly linked list.
1734 @param Entry A pointer to a node that is to be added at the end of the
1743 IN OUT LIST_ENTRY
*ListHead
,
1744 IN OUT LIST_ENTRY
*Entry
1749 Retrieves the first node of a doubly linked list.
1751 Returns the first node of a doubly linked list. List must have been
1752 initialized with INTIALIZE_LIST_HEAD_VARIABLE() or InitializeListHead().
1753 If List is empty, then List is returned.
1755 If List is NULL, then ASSERT().
1756 If List was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or
1757 InitializeListHead(), then ASSERT().
1758 If PcdMaximumLinkedListLength is not zero, and the number of nodes
1759 in List, including the List node, is greater than or equal to
1760 PcdMaximumLinkedListLength, then ASSERT().
1762 @param List A pointer to the head node of a doubly linked list.
1764 @return The first node of a doubly linked list.
1765 @retval List The list is empty.
1771 IN CONST LIST_ENTRY
*List
1776 Retrieves the next node of a doubly linked list.
1778 Returns the node of a doubly linked list that follows Node.
1779 List must have been initialized with INTIALIZE_LIST_HEAD_VARIABLE()
1780 or InitializeListHead(). If List is empty, then List is returned.
1782 If List is NULL, then ASSERT().
1783 If Node is NULL, then ASSERT().
1784 If List was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or
1785 InitializeListHead(), then ASSERT().
1786 If PcdMaximumLinkedListLength is not zero, and List contains more than
1787 PcdMaximumLinkedListLength nodes, then ASSERT().
1788 If PcdVerifyNodeInList is TRUE and Node is not a node in List, then ASSERT().
1790 @param List A pointer to the head node of a doubly linked list.
1791 @param Node A pointer to a node in the doubly linked list.
1793 @return The pointer to the next node if one exists. Otherwise List is returned.
1799 IN CONST LIST_ENTRY
*List
,
1800 IN CONST LIST_ENTRY
*Node
1805 Retrieves the previous node of a doubly linked list.
1807 Returns the node of a doubly linked list that precedes Node.
1808 List must have been initialized with INTIALIZE_LIST_HEAD_VARIABLE()
1809 or InitializeListHead(). If List is empty, then List is returned.
1811 If List is NULL, then ASSERT().
1812 If Node is NULL, then ASSERT().
1813 If List was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or
1814 InitializeListHead(), then ASSERT().
1815 If PcdMaximumLinkedListLength is not zero, and List contains more than
1816 PcdMaximumLinkedListLength nodes, then ASSERT().
1817 If PcdVerifyNodeInList is TRUE and Node is not a node in List, then ASSERT().
1819 @param List A pointer to the head node of a doubly linked list.
1820 @param Node A pointer to a node in the doubly linked list.
1822 @return The pointer to the previous node if one exists. Otherwise List is returned.
1828 IN CONST LIST_ENTRY
*List
,
1829 IN CONST LIST_ENTRY
*Node
1834 Checks to see if a doubly linked list is empty or not.
1836 Checks to see if the doubly linked list is empty. If the linked list contains
1837 zero nodes, this function returns TRUE. Otherwise, it returns FALSE.
1839 If ListHead is NULL, then ASSERT().
1840 If ListHead was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or
1841 InitializeListHead(), then ASSERT().
1842 If PcdMaximumLinkedListLength is not zero, and the number of nodes
1843 in List, including the List node, is greater than or equal to
1844 PcdMaximumLinkedListLength, then ASSERT().
1846 @param ListHead A pointer to the head node of a doubly linked list.
1848 @retval TRUE The linked list is empty.
1849 @retval FALSE The linked list is not empty.
1855 IN CONST LIST_ENTRY
*ListHead
1860 Determines if a node in a doubly linked list is the head node of a the same
1861 doubly linked list. This function is typically used to terminate a loop that
1862 traverses all the nodes in a doubly linked list starting with the head node.
1864 Returns TRUE if Node is equal to List. Returns FALSE if Node is one of the
1865 nodes in the doubly linked list specified by List. List must have been
1866 initialized with INTIALIZE_LIST_HEAD_VARIABLE() or InitializeListHead().
1868 If List is NULL, then ASSERT().
1869 If Node is NULL, then ASSERT().
1870 If List was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or InitializeListHead(),
1872 If PcdMaximumLinkedListLength is not zero, and the number of nodes
1873 in List, including the List node, is greater than or equal to
1874 PcdMaximumLinkedListLength, then ASSERT().
1875 If PcdVerifyNodeInList is TRUE and Node is not a node in List the and Node is not equal
1876 to List, then ASSERT().
1878 @param List A pointer to the head node of a doubly linked list.
1879 @param Node A pointer to a node in the doubly linked list.
1881 @retval TRUE Node is the head of the doubly-linked list pointed by List.
1882 @retval FALSE Node is not the head of the doubly-linked list pointed by List.
1888 IN CONST LIST_ENTRY
*List
,
1889 IN CONST LIST_ENTRY
*Node
1894 Determines if a node the last node in a doubly linked list.
1896 Returns TRUE if Node is the last node in the doubly linked list specified by
1897 List. Otherwise, FALSE is returned. List must have been initialized with
1898 INTIALIZE_LIST_HEAD_VARIABLE() or InitializeListHead().
1900 If List is NULL, then ASSERT().
1901 If Node is NULL, then ASSERT().
1902 If List was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or
1903 InitializeListHead(), then ASSERT().
1904 If PcdMaximumLinkedListLength is not zero, and the number of nodes
1905 in List, including the List node, is greater than or equal to
1906 PcdMaximumLinkedListLength, then ASSERT().
1907 If PcdVerifyNodeInList is TRUE and Node is not a node in List, then ASSERT().
1909 @param List A pointer to the head node of a doubly linked list.
1910 @param Node A pointer to a node in the doubly linked list.
1912 @retval TRUE Node is the last node in the linked list.
1913 @retval FALSE Node is not the last node in the linked list.
1919 IN CONST LIST_ENTRY
*List
,
1920 IN CONST LIST_ENTRY
*Node
1925 Swaps the location of two nodes in a doubly linked list, and returns the
1926 first node after the swap.
1928 If FirstEntry is identical to SecondEntry, then SecondEntry is returned.
1929 Otherwise, the location of the FirstEntry node is swapped with the location
1930 of the SecondEntry node in a doubly linked list. SecondEntry must be in the
1931 same double linked list as FirstEntry and that double linked list must have
1932 been initialized with INTIALIZE_LIST_HEAD_VARIABLE() or InitializeListHead().
1933 SecondEntry is returned after the nodes are swapped.
1935 If FirstEntry is NULL, then ASSERT().
1936 If SecondEntry is NULL, then ASSERT().
1937 If PcdVerifyNodeInList is TRUE and SecondEntry and FirstEntry are not in the
1938 same linked list, then ASSERT().
1939 If PcdMaximumLinkedListLength is not zero, and the number of nodes in the
1940 linked list containing the FirstEntry and SecondEntry nodes, including
1941 the FirstEntry and SecondEntry nodes, is greater than or equal to
1942 PcdMaximumLinkedListLength, then ASSERT().
1944 @param FirstEntry A pointer to a node in a linked list.
1945 @param SecondEntry A pointer to another node in the same linked list.
1947 @return SecondEntry.
1953 IN OUT LIST_ENTRY
*FirstEntry
,
1954 IN OUT LIST_ENTRY
*SecondEntry
1959 Removes a node from a doubly linked list, and returns the node that follows
1962 Removes the node Entry from a doubly linked list. It is up to the caller of
1963 this function to release the memory used by this node if that is required. On
1964 exit, the node following Entry in the doubly linked list is returned. If
1965 Entry is the only node in the linked list, then the head node of the linked
1968 If Entry is NULL, then ASSERT().
1969 If Entry is the head node of an empty list, then ASSERT().
1970 If PcdMaximumLinkedListLength is not zero, and the number of nodes in the
1971 linked list containing Entry, including the Entry node, is greater than
1972 or equal to PcdMaximumLinkedListLength, then ASSERT().
1974 @param Entry A pointer to a node in a linked list.
1982 IN CONST LIST_ENTRY
*Entry
1990 Shifts a 64-bit integer left between 0 and 63 bits. The low bits are filled
1991 with zeros. The shifted value is returned.
1993 This function shifts the 64-bit value Operand to the left by Count bits. The
1994 low Count bits are set to zero. The shifted value is returned.
1996 If Count is greater than 63, then ASSERT().
1998 @param Operand The 64-bit operand to shift left.
1999 @param Count The number of bits to shift left.
2001 @return Operand << Count.
2013 Shifts a 64-bit integer right between 0 and 63 bits. This high bits are
2014 filled with zeros. The shifted value is returned.
2016 This function shifts the 64-bit value Operand to the right by Count bits. The
2017 high Count bits are set to zero. The shifted value is returned.
2019 If Count is greater than 63, then ASSERT().
2021 @param Operand The 64-bit operand to shift right.
2022 @param Count The number of bits to shift right.
2024 @return Operand >> Count
2036 Shifts a 64-bit integer right between 0 and 63 bits. The high bits are filled
2037 with original integer's bit 63. The shifted value is returned.
2039 This function shifts the 64-bit value Operand to the right by Count bits. The
2040 high Count bits are set to bit 63 of Operand. The shifted value is returned.
2042 If Count is greater than 63, then ASSERT().
2044 @param Operand The 64-bit operand to shift right.
2045 @param Count The number of bits to shift right.
2047 @return Operand >> Count
2059 Rotates a 32-bit integer left between 0 and 31 bits, filling the low bits
2060 with the high bits that were rotated.
2062 This function rotates the 32-bit value Operand to the left by Count bits. The
2063 low Count bits are fill with the high Count bits of Operand. The rotated
2066 If Count is greater than 31, then ASSERT().
2068 @param Operand The 32-bit operand to rotate left.
2069 @param Count The number of bits to rotate left.
2071 @return Operand << Count
2083 Rotates a 32-bit integer right between 0 and 31 bits, filling the high bits
2084 with the low bits that were rotated.
2086 This function rotates the 32-bit value Operand to the right by Count bits.
2087 The high Count bits are fill with the low Count bits of Operand. The rotated
2090 If Count is greater than 31, then ASSERT().
2092 @param Operand The 32-bit operand to rotate right.
2093 @param Count The number of bits to rotate right.
2095 @return Operand >> Count
2107 Rotates a 64-bit integer left between 0 and 63 bits, filling the low bits
2108 with the high bits that were rotated.
2110 This function rotates the 64-bit value Operand to the left by Count bits. The
2111 low Count bits are fill with the high Count bits of Operand. The rotated
2114 If Count is greater than 63, then ASSERT().
2116 @param Operand The 64-bit operand to rotate left.
2117 @param Count The number of bits to rotate left.
2119 @return Operand << Count
2131 Rotates a 64-bit integer right between 0 and 63 bits, filling the high bits
2132 with the high low bits that were rotated.
2134 This function rotates the 64-bit value Operand to the right by Count bits.
2135 The high Count bits are fill with the low Count bits of Operand. The rotated
2138 If Count is greater than 63, then ASSERT().
2140 @param Operand The 64-bit operand to rotate right.
2141 @param Count The number of bits to rotate right.
2143 @return Operand >> Count
2155 Returns the bit position of the lowest bit set in a 32-bit value.
2157 This function computes the bit position of the lowest bit set in the 32-bit
2158 value specified by Operand. If Operand is zero, then -1 is returned.
2159 Otherwise, a value between 0 and 31 is returned.
2161 @param Operand The 32-bit operand to evaluate.
2163 @retval 0..31 The lowest bit set in Operand was found.
2164 @retval -1 Operand is zero.
2175 Returns the bit position of the lowest bit set in a 64-bit value.
2177 This function computes the bit position of the lowest bit set in the 64-bit
2178 value specified by Operand. If Operand is zero, then -1 is returned.
2179 Otherwise, a value between 0 and 63 is returned.
2181 @param Operand The 64-bit operand to evaluate.
2183 @retval 0..63 The lowest bit set in Operand was found.
2184 @retval -1 Operand is zero.
2196 Returns the bit position of the highest bit set in a 32-bit value. Equivalent
2199 This function computes the bit position of the highest bit set in the 32-bit
2200 value specified by Operand. If Operand is zero, then -1 is returned.
2201 Otherwise, a value between 0 and 31 is returned.
2203 @param Operand The 32-bit operand to evaluate.
2205 @retval 0..31 Position of the highest bit set in Operand if found.
2206 @retval -1 Operand is zero.
2217 Returns the bit position of the highest bit set in a 64-bit value. Equivalent
2220 This function computes the bit position of the highest bit set in the 64-bit
2221 value specified by Operand. If Operand is zero, then -1 is returned.
2222 Otherwise, a value between 0 and 63 is returned.
2224 @param Operand The 64-bit operand to evaluate.
2226 @retval 0..63 Position of the highest bit set in Operand if found.
2227 @retval -1 Operand is zero.
2238 Returns the value of the highest bit set in a 32-bit value. Equivalent to
2241 This function computes the value of the highest bit set in the 32-bit value
2242 specified by Operand. If Operand is zero, then zero is returned.
2244 @param Operand The 32-bit operand to evaluate.
2246 @return 1 << HighBitSet32(Operand)
2247 @retval 0 Operand is zero.
2258 Returns the value of the highest bit set in a 64-bit value. Equivalent to
2261 This function computes the value of the highest bit set in the 64-bit value
2262 specified by Operand. If Operand is zero, then zero is returned.
2264 @param Operand The 64-bit operand to evaluate.
2266 @return 1 << HighBitSet64(Operand)
2267 @retval 0 Operand is zero.
2278 Switches the endianness of a 16-bit integer.
2280 This function swaps the bytes in a 16-bit unsigned value to switch the value
2281 from little endian to big endian or vice versa. The byte swapped value is
2284 @param Value A 16-bit unsigned value.
2286 @return The byte swapped Value.
2297 Switches the endianness of a 32-bit integer.
2299 This function swaps the bytes in a 32-bit unsigned value to switch the value
2300 from little endian to big endian or vice versa. The byte swapped value is
2303 @param Value A 32-bit unsigned value.
2305 @return The byte swapped Value.
2316 Switches the endianness of a 64-bit integer.
2318 This function swaps the bytes in a 64-bit unsigned value to switch the value
2319 from little endian to big endian or vice versa. The byte swapped value is
2322 @param Value A 64-bit unsigned value.
2324 @return The byte swapped Value.
2335 Multiples a 64-bit unsigned integer by a 32-bit unsigned integer and
2336 generates a 64-bit unsigned result.
2338 This function multiples the 64-bit unsigned value Multiplicand by the 32-bit
2339 unsigned value Multiplier and generates a 64-bit unsigned result. This 64-
2340 bit unsigned result is returned.
2342 @param Multiplicand A 64-bit unsigned value.
2343 @param Multiplier A 32-bit unsigned value.
2345 @return Multiplicand * Multiplier
2351 IN UINT64 Multiplicand
,
2352 IN UINT32 Multiplier
2357 Multiples a 64-bit unsigned integer by a 64-bit unsigned integer and
2358 generates a 64-bit unsigned result.
2360 This function multiples the 64-bit unsigned value Multiplicand by the 64-bit
2361 unsigned value Multiplier and generates a 64-bit unsigned result. This 64-
2362 bit unsigned result is returned.
2364 @param Multiplicand A 64-bit unsigned value.
2365 @param Multiplier A 64-bit unsigned value.
2367 @return Multiplicand * Multiplier.
2373 IN UINT64 Multiplicand
,
2374 IN UINT64 Multiplier
2379 Multiples a 64-bit signed integer by a 64-bit signed integer and generates a
2380 64-bit signed result.
2382 This function multiples the 64-bit signed value Multiplicand by the 64-bit
2383 signed value Multiplier and generates a 64-bit signed result. This 64-bit
2384 signed result is returned.
2386 @param Multiplicand A 64-bit signed value.
2387 @param Multiplier A 64-bit signed value.
2389 @return Multiplicand * Multiplier
2395 IN INT64 Multiplicand
,
2401 Divides a 64-bit unsigned integer by a 32-bit unsigned integer and generates
2402 a 64-bit unsigned result.
2404 This function divides the 64-bit unsigned value Dividend by the 32-bit
2405 unsigned value Divisor and generates a 64-bit unsigned quotient. This
2406 function returns the 64-bit unsigned quotient.
2408 If Divisor is 0, then ASSERT().
2410 @param Dividend A 64-bit unsigned value.
2411 @param Divisor A 32-bit unsigned value.
2413 @return Dividend / Divisor.
2425 Divides a 64-bit unsigned integer by a 32-bit unsigned integer and generates
2426 a 32-bit unsigned remainder.
2428 This function divides the 64-bit unsigned value Dividend by the 32-bit
2429 unsigned value Divisor and generates a 32-bit remainder. This function
2430 returns the 32-bit unsigned remainder.
2432 If Divisor is 0, then ASSERT().
2434 @param Dividend A 64-bit unsigned value.
2435 @param Divisor A 32-bit unsigned value.
2437 @return Dividend % Divisor.
2449 Divides a 64-bit unsigned integer by a 32-bit unsigned integer and generates
2450 a 64-bit unsigned result and an optional 32-bit unsigned remainder.
2452 This function divides the 64-bit unsigned value Dividend by the 32-bit
2453 unsigned value Divisor and generates a 64-bit unsigned quotient. If Remainder
2454 is not NULL, then the 32-bit unsigned remainder is returned in Remainder.
2455 This function returns the 64-bit unsigned quotient.
2457 If Divisor is 0, then ASSERT().
2459 @param Dividend A 64-bit unsigned value.
2460 @param Divisor A 32-bit unsigned value.
2461 @param Remainder A pointer to a 32-bit unsigned value. This parameter is
2462 optional and may be NULL.
2464 @return Dividend / Divisor.
2469 DivU64x32Remainder (
2472 OUT UINT32
*Remainder OPTIONAL
2477 Divides a 64-bit unsigned integer by a 64-bit unsigned integer and generates
2478 a 64-bit unsigned result and an optional 64-bit unsigned remainder.
2480 This function divides the 64-bit unsigned value Dividend by the 64-bit
2481 unsigned value Divisor and generates a 64-bit unsigned quotient. If Remainder
2482 is not NULL, then the 64-bit unsigned remainder is returned in Remainder.
2483 This function returns the 64-bit unsigned quotient.
2485 If Divisor is 0, then ASSERT().
2487 @param Dividend A 64-bit unsigned value.
2488 @param Divisor A 64-bit unsigned value.
2489 @param Remainder A pointer to a 64-bit unsigned value. This parameter is
2490 optional and may be NULL.
2492 @return Dividend / Divisor.
2497 DivU64x64Remainder (
2500 OUT UINT64
*Remainder OPTIONAL
2505 Divides a 64-bit signed integer by a 64-bit signed integer and generates a
2506 64-bit signed result and a optional 64-bit signed remainder.
2508 This function divides the 64-bit signed value Dividend by the 64-bit signed
2509 value Divisor and generates a 64-bit signed quotient. If Remainder is not
2510 NULL, then the 64-bit signed remainder is returned in Remainder. This
2511 function returns the 64-bit signed quotient.
2513 It is the caller's responsibility to not call this function with a Divisor of 0.
2514 If Divisor is 0, then the quotient and remainder should be assumed to be
2515 the largest negative integer.
2517 If Divisor is 0, then ASSERT().
2519 @param Dividend A 64-bit signed value.
2520 @param Divisor A 64-bit signed value.
2521 @param Remainder A pointer to a 64-bit signed value. This parameter is
2522 optional and may be NULL.
2524 @return Dividend / Divisor.
2529 DivS64x64Remainder (
2532 OUT INT64
*Remainder OPTIONAL
2537 Reads a 16-bit value from memory that may be unaligned.
2539 This function returns the 16-bit value pointed to by Buffer. The function
2540 guarantees that the read operation does not produce an alignment fault.
2542 If the Buffer is NULL, then ASSERT().
2544 @param Buffer The pointer to a 16-bit value that may be unaligned.
2546 @return The 16-bit value read from Buffer.
2552 IN CONST UINT16
*Buffer
2557 Writes a 16-bit value to memory that may be unaligned.
2559 This function writes the 16-bit value specified by Value to Buffer. Value is
2560 returned. The function guarantees that the write operation does not produce
2563 If the Buffer is NULL, then ASSERT().
2565 @param Buffer The pointer to a 16-bit value that may be unaligned.
2566 @param Value 16-bit value to write to Buffer.
2568 @return The 16-bit value to write to Buffer.
2580 Reads a 24-bit value from memory that may be unaligned.
2582 This function returns the 24-bit value pointed to by Buffer. The function
2583 guarantees that the read operation does not produce an alignment fault.
2585 If the Buffer is NULL, then ASSERT().
2587 @param Buffer The pointer to a 24-bit value that may be unaligned.
2589 @return The 24-bit value read from Buffer.
2595 IN CONST UINT32
*Buffer
2600 Writes a 24-bit value to memory that may be unaligned.
2602 This function writes the 24-bit value specified by Value to Buffer. Value is
2603 returned. The function guarantees that the write operation does not produce
2606 If the Buffer is NULL, then ASSERT().
2608 @param Buffer The pointer to a 24-bit value that may be unaligned.
2609 @param Value 24-bit value to write to Buffer.
2611 @return The 24-bit value to write to Buffer.
2623 Reads a 32-bit value from memory that may be unaligned.
2625 This function returns the 32-bit value pointed to by Buffer. The function
2626 guarantees that the read operation does not produce an alignment fault.
2628 If the Buffer is NULL, then ASSERT().
2630 @param Buffer The pointer to a 32-bit value that may be unaligned.
2632 @return The 32-bit value read from Buffer.
2638 IN CONST UINT32
*Buffer
2643 Writes a 32-bit value to memory that may be unaligned.
2645 This function writes the 32-bit value specified by Value to Buffer. Value is
2646 returned. The function guarantees that the write operation does not produce
2649 If the Buffer is NULL, then ASSERT().
2651 @param Buffer The pointer to a 32-bit value that may be unaligned.
2652 @param Value 32-bit value to write to Buffer.
2654 @return The 32-bit value to write to Buffer.
2666 Reads a 64-bit value from memory that may be unaligned.
2668 This function returns the 64-bit value pointed to by Buffer. The function
2669 guarantees that the read operation does not produce an alignment fault.
2671 If the Buffer is NULL, then ASSERT().
2673 @param Buffer The pointer to a 64-bit value that may be unaligned.
2675 @return The 64-bit value read from Buffer.
2681 IN CONST UINT64
*Buffer
2686 Writes a 64-bit value to memory that may be unaligned.
2688 This function writes the 64-bit value specified by Value to Buffer. Value is
2689 returned. The function guarantees that the write operation does not produce
2692 If the Buffer is NULL, then ASSERT().
2694 @param Buffer The pointer to a 64-bit value that may be unaligned.
2695 @param Value 64-bit value to write to Buffer.
2697 @return The 64-bit value to write to Buffer.
2709 // Bit Field Functions
2713 Returns a bit field from an 8-bit value.
2715 Returns the bitfield specified by the StartBit and the EndBit from Operand.
2717 If 8-bit operations are not supported, then ASSERT().
2718 If StartBit is greater than 7, then ASSERT().
2719 If EndBit is greater than 7, then ASSERT().
2720 If EndBit is less than StartBit, then ASSERT().
2722 @param Operand Operand on which to perform the bitfield operation.
2723 @param StartBit The ordinal of the least significant bit in the bit field.
2725 @param EndBit The ordinal of the most significant bit in the bit field.
2728 @return The bit field read.
2741 Writes a bit field to an 8-bit value, and returns the result.
2743 Writes Value to the bit field specified by the StartBit and the EndBit in
2744 Operand. All other bits in Operand are preserved. The new 8-bit value is
2747 If 8-bit operations are not supported, then ASSERT().
2748 If StartBit is greater than 7, then ASSERT().
2749 If EndBit is greater than 7, then ASSERT().
2750 If EndBit is less than StartBit, then ASSERT().
2751 If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
2753 @param Operand Operand on which to perform the bitfield operation.
2754 @param StartBit The ordinal of the least significant bit in the bit field.
2756 @param EndBit The ordinal of the most significant bit in the bit field.
2758 @param Value New value of the bit field.
2760 @return The new 8-bit value.
2774 Reads a bit field from an 8-bit value, performs a bitwise OR, and returns the
2777 Performs a bitwise OR between the bit field specified by StartBit
2778 and EndBit in Operand and the value specified by OrData. All other bits in
2779 Operand are preserved. The new 8-bit value is returned.
2781 If 8-bit operations are not supported, then ASSERT().
2782 If StartBit is greater than 7, then ASSERT().
2783 If EndBit is greater than 7, then ASSERT().
2784 If EndBit is less than StartBit, then ASSERT().
2785 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
2787 @param Operand Operand on which to perform the bitfield operation.
2788 @param StartBit The ordinal of the least significant bit in the bit field.
2790 @param EndBit The ordinal of the most significant bit in the bit field.
2792 @param OrData The value to OR with the read value from the value
2794 @return The new 8-bit value.
2808 Reads a bit field from an 8-bit value, performs a bitwise AND, and returns
2811 Performs a bitwise AND between the bit field specified by StartBit and EndBit
2812 in Operand and the value specified by AndData. All other bits in Operand are
2813 preserved. The new 8-bit value is returned.
2815 If 8-bit operations are not supported, then ASSERT().
2816 If StartBit is greater than 7, then ASSERT().
2817 If EndBit is greater than 7, then ASSERT().
2818 If EndBit is less than StartBit, then ASSERT().
2819 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
2821 @param Operand Operand on which to perform the bitfield operation.
2822 @param StartBit The ordinal of the least significant bit in the bit field.
2824 @param EndBit The ordinal of the most significant bit in the bit field.
2826 @param AndData The value to AND with the read value from the value.
2828 @return The new 8-bit value.
2842 Reads a bit field from an 8-bit value, performs a bitwise AND followed by a
2843 bitwise OR, and returns the result.
2845 Performs a bitwise AND between the bit field specified by StartBit and EndBit
2846 in Operand and the value specified by AndData, followed by a bitwise
2847 OR with value specified by OrData. All other bits in Operand are
2848 preserved. The new 8-bit value is returned.
2850 If 8-bit operations are not supported, then ASSERT().
2851 If StartBit is greater than 7, then ASSERT().
2852 If EndBit is greater than 7, then ASSERT().
2853 If EndBit is less than StartBit, then ASSERT().
2854 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
2855 If OrData 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.
2863 @param OrData The value to OR with the result of the AND operation.
2865 @return The new 8-bit value.
2870 BitFieldAndThenOr8 (
2880 Returns a bit field from a 16-bit value.
2882 Returns the bitfield specified by the StartBit and the EndBit from Operand.
2884 If 16-bit operations are not supported, then ASSERT().
2885 If StartBit is greater than 15, then ASSERT().
2886 If EndBit is greater than 15, then ASSERT().
2887 If EndBit is less than StartBit, then ASSERT().
2889 @param Operand Operand on which to perform the bitfield operation.
2890 @param StartBit The ordinal of the least significant bit in the bit field.
2892 @param EndBit The ordinal of the most significant bit in the bit field.
2895 @return The bit field read.
2908 Writes a bit field to a 16-bit value, and returns the result.
2910 Writes Value to the bit field specified by the StartBit and the EndBit in
2911 Operand. All other bits in Operand are preserved. The new 16-bit value is
2914 If 16-bit operations are not supported, then ASSERT().
2915 If StartBit is greater than 15, then ASSERT().
2916 If EndBit is greater than 15, then ASSERT().
2917 If EndBit is less than StartBit, then ASSERT().
2918 If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
2920 @param Operand Operand on which to perform the bitfield operation.
2921 @param StartBit The ordinal of the least significant bit in the bit field.
2923 @param EndBit The ordinal of the most significant bit in the bit field.
2925 @param Value New value of the bit field.
2927 @return The new 16-bit value.
2941 Reads a bit field from a 16-bit value, performs a bitwise OR, and returns the
2944 Performs a bitwise OR between the bit field specified by StartBit
2945 and EndBit in Operand and the value specified by OrData. All other bits in
2946 Operand are preserved. The new 16-bit value is returned.
2948 If 16-bit operations are not supported, then ASSERT().
2949 If StartBit is greater than 15, then ASSERT().
2950 If EndBit is greater than 15, then ASSERT().
2951 If EndBit is less than StartBit, then ASSERT().
2952 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
2954 @param Operand Operand on which to perform the bitfield operation.
2955 @param StartBit The ordinal of the least significant bit in the bit field.
2957 @param EndBit The ordinal of the most significant bit in the bit field.
2959 @param OrData The value to OR with the read value from the value
2961 @return The new 16-bit value.
2975 Reads a bit field from a 16-bit value, performs a bitwise AND, and returns
2978 Performs a bitwise AND between the bit field specified by StartBit and EndBit
2979 in Operand and the value specified by AndData. All other bits in Operand are
2980 preserved. The new 16-bit value is returned.
2982 If 16-bit operations are not supported, then ASSERT().
2983 If StartBit is greater than 15, then ASSERT().
2984 If EndBit is greater than 15, then ASSERT().
2985 If EndBit is less than StartBit, then ASSERT().
2986 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
2988 @param Operand Operand on which to perform the bitfield operation.
2989 @param StartBit The ordinal of the least significant bit in the bit field.
2991 @param EndBit The ordinal of the most significant bit in the bit field.
2993 @param AndData The value to AND with the read value from the value
2995 @return The new 16-bit value.
3009 Reads a bit field from a 16-bit value, performs a bitwise AND followed by a
3010 bitwise OR, and returns the result.
3012 Performs a bitwise AND between the bit field specified by StartBit and EndBit
3013 in Operand and the value specified by AndData, followed by a bitwise
3014 OR with value specified by OrData. All other bits in Operand are
3015 preserved. The new 16-bit value is returned.
3017 If 16-bit operations are not supported, then ASSERT().
3018 If StartBit is greater than 15, then ASSERT().
3019 If EndBit is greater than 15, then ASSERT().
3020 If EndBit is less than StartBit, then ASSERT().
3021 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
3022 If OrData 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.
3030 @param OrData The value to OR with the result of the AND operation.
3032 @return The new 16-bit value.
3037 BitFieldAndThenOr16 (
3047 Returns a bit field from a 32-bit value.
3049 Returns the bitfield specified by the StartBit and the EndBit from Operand.
3051 If 32-bit operations are not supported, then ASSERT().
3052 If StartBit is greater than 31, then ASSERT().
3053 If EndBit is greater than 31, then ASSERT().
3054 If EndBit is less than StartBit, then ASSERT().
3056 @param Operand Operand on which to perform the bitfield operation.
3057 @param StartBit The ordinal of the least significant bit in the bit field.
3059 @param EndBit The ordinal of the most significant bit in the bit field.
3062 @return The bit field read.
3075 Writes a bit field to a 32-bit value, and returns the result.
3077 Writes Value to the bit field specified by the StartBit and the EndBit in
3078 Operand. All other bits in Operand are preserved. The new 32-bit value is
3081 If 32-bit operations are not supported, then ASSERT().
3082 If StartBit is greater than 31, then ASSERT().
3083 If EndBit is greater than 31, then ASSERT().
3084 If EndBit is less than StartBit, then ASSERT().
3085 If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
3087 @param Operand Operand on which to perform the bitfield operation.
3088 @param StartBit The ordinal of the least significant bit in the bit field.
3090 @param EndBit The ordinal of the most significant bit in the bit field.
3092 @param Value New value of the bit field.
3094 @return The new 32-bit value.
3108 Reads a bit field from a 32-bit value, performs a bitwise OR, and returns the
3111 Performs a bitwise OR between the bit field specified by StartBit
3112 and EndBit in Operand and the value specified by OrData. All other bits in
3113 Operand are preserved. The new 32-bit value is returned.
3115 If 32-bit operations are not supported, then ASSERT().
3116 If StartBit is greater than 31, then ASSERT().
3117 If EndBit is greater than 31, then ASSERT().
3118 If EndBit is less than StartBit, then ASSERT().
3119 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
3121 @param Operand Operand on which to perform the bitfield operation.
3122 @param StartBit The ordinal of the least significant bit in the bit field.
3124 @param EndBit The ordinal of the most significant bit in the bit field.
3126 @param OrData The value to OR with the read value from the value.
3128 @return The new 32-bit value.
3142 Reads a bit field from a 32-bit value, performs a bitwise AND, and returns
3145 Performs a bitwise AND between the bit field specified by StartBit and EndBit
3146 in Operand and the value specified by AndData. All other bits in Operand are
3147 preserved. The new 32-bit value is returned.
3149 If 32-bit operations are not supported, then ASSERT().
3150 If StartBit is greater than 31, then ASSERT().
3151 If EndBit is greater than 31, then ASSERT().
3152 If EndBit is less than StartBit, then ASSERT().
3153 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
3155 @param Operand Operand on which to perform the bitfield operation.
3156 @param StartBit The ordinal of the least significant bit in the bit field.
3158 @param EndBit The ordinal of the most significant bit in the bit field.
3160 @param AndData The value to AND with the read value from the value
3162 @return The new 32-bit value.
3176 Reads a bit field from a 32-bit value, performs a bitwise AND followed by a
3177 bitwise OR, and returns the result.
3179 Performs a bitwise AND between the bit field specified by StartBit and EndBit
3180 in Operand and the value specified by AndData, followed by a bitwise
3181 OR with value specified by OrData. All other bits in Operand are
3182 preserved. The new 32-bit value is returned.
3184 If 32-bit operations are not supported, then ASSERT().
3185 If StartBit is greater than 31, then ASSERT().
3186 If EndBit is greater than 31, then ASSERT().
3187 If EndBit is less than StartBit, then ASSERT().
3188 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
3189 If OrData 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.
3197 @param OrData The value to OR with the result of the AND operation.
3199 @return The new 32-bit value.
3204 BitFieldAndThenOr32 (
3214 Returns a bit field from a 64-bit value.
3216 Returns the bitfield specified by the StartBit and the EndBit from Operand.
3218 If 64-bit operations are not supported, then ASSERT().
3219 If StartBit is greater than 63, then ASSERT().
3220 If EndBit is greater than 63, then ASSERT().
3221 If EndBit is less than StartBit, then ASSERT().
3223 @param Operand Operand on which to perform the bitfield operation.
3224 @param StartBit The ordinal of the least significant bit in the bit field.
3226 @param EndBit The ordinal of the most significant bit in the bit field.
3229 @return The bit field read.
3242 Writes a bit field to a 64-bit value, and returns the result.
3244 Writes Value to the bit field specified by the StartBit and the EndBit in
3245 Operand. All other bits in Operand are preserved. The new 64-bit value is
3248 If 64-bit operations are not supported, then ASSERT().
3249 If StartBit is greater than 63, then ASSERT().
3250 If EndBit is greater than 63, then ASSERT().
3251 If EndBit is less than StartBit, then ASSERT().
3252 If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
3254 @param Operand Operand on which to perform the bitfield operation.
3255 @param StartBit The ordinal of the least significant bit in the bit field.
3257 @param EndBit The ordinal of the most significant bit in the bit field.
3259 @param Value New value of the bit field.
3261 @return The new 64-bit value.
3275 Reads a bit field from a 64-bit value, performs a bitwise OR, and returns the
3278 Performs a bitwise OR between the bit field specified by StartBit
3279 and EndBit in Operand and the value specified by OrData. All other bits in
3280 Operand are preserved. The new 64-bit value is returned.
3282 If 64-bit operations are not supported, then ASSERT().
3283 If StartBit is greater than 63, then ASSERT().
3284 If EndBit is greater than 63, then ASSERT().
3285 If EndBit is less than StartBit, then ASSERT().
3286 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
3288 @param Operand Operand on which to perform the bitfield operation.
3289 @param StartBit The ordinal of the least significant bit in the bit field.
3291 @param EndBit The ordinal of the most significant bit in the bit field.
3293 @param OrData The value to OR with the read value from the value
3295 @return The new 64-bit value.
3309 Reads a bit field from a 64-bit value, performs a bitwise AND, and returns
3312 Performs a bitwise AND between the bit field specified by StartBit and EndBit
3313 in Operand and the value specified by AndData. All other bits in Operand are
3314 preserved. The new 64-bit value is returned.
3316 If 64-bit operations are not supported, then ASSERT().
3317 If StartBit is greater than 63, then ASSERT().
3318 If EndBit is greater than 63, then ASSERT().
3319 If EndBit is less than StartBit, then ASSERT().
3320 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
3322 @param Operand Operand on which to perform the bitfield operation.
3323 @param StartBit The ordinal of the least significant bit in the bit field.
3325 @param EndBit The ordinal of the most significant bit in the bit field.
3327 @param AndData The value to AND with the read value from the value
3329 @return The new 64-bit value.
3343 Reads a bit field from a 64-bit value, performs a bitwise AND followed by a
3344 bitwise OR, and returns the result.
3346 Performs a bitwise AND between the bit field specified by StartBit and EndBit
3347 in Operand and the value specified by AndData, followed by a bitwise
3348 OR with value specified by OrData. All other bits in Operand are
3349 preserved. The new 64-bit value is returned.
3351 If 64-bit operations are not supported, then ASSERT().
3352 If StartBit is greater than 63, then ASSERT().
3353 If EndBit is greater than 63, then ASSERT().
3354 If EndBit is less than StartBit, then ASSERT().
3355 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
3356 If OrData 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.
3364 @param OrData The value to OR with the result of the AND operation.
3366 @return The new 64-bit value.
3371 BitFieldAndThenOr64 (
3380 // Base Library Checksum Functions
3384 Returns the sum of all elements in a buffer in unit of UINT8.
3385 During calculation, the carry bits are dropped.
3387 This function calculates the sum of all elements in a buffer
3388 in unit of UINT8. The carry bits in result of addition are dropped.
3389 The result is returned as UINT8. If Length is Zero, then Zero is
3392 If Buffer is NULL, then ASSERT().
3393 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
3395 @param Buffer The pointer to the buffer to carry out the sum operation.
3396 @param Length The size, in bytes, of Buffer.
3398 @return Sum The sum of Buffer with carry bits dropped during additions.
3404 IN CONST UINT8
*Buffer
,
3410 Returns the two's complement checksum of all elements in a buffer
3413 This function first calculates the sum of the 8-bit values in the
3414 buffer specified by Buffer and Length. The carry bits in the result
3415 of addition are dropped. Then, the two's complement of the sum is
3416 returned. If Length is 0, then 0 is returned.
3418 If Buffer is NULL, then ASSERT().
3419 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
3421 @param Buffer The pointer to the buffer to carry out the checksum operation.
3422 @param Length The size, in bytes, of Buffer.
3424 @return Checksum The two's complement checksum of Buffer.
3429 CalculateCheckSum8 (
3430 IN CONST UINT8
*Buffer
,
3436 Returns the sum of all elements in a buffer of 16-bit values. During
3437 calculation, the carry bits are dropped.
3439 This function calculates the sum of the 16-bit values in the buffer
3440 specified by Buffer and Length. The carry bits in result of addition are dropped.
3441 The 16-bit result is returned. If Length is 0, then 0 is returned.
3443 If Buffer is NULL, then ASSERT().
3444 If Buffer is not aligned on a 16-bit boundary, then ASSERT().
3445 If Length is not aligned on a 16-bit boundary, then ASSERT().
3446 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
3448 @param Buffer The pointer to the buffer to carry out the sum operation.
3449 @param Length The size, in bytes, of Buffer.
3451 @return Sum The sum of Buffer with carry bits dropped during additions.
3457 IN CONST UINT16
*Buffer
,
3463 Returns the two's complement checksum of all elements in a buffer of
3466 This function first calculates the sum of the 16-bit values in the buffer
3467 specified by Buffer and Length. The carry bits in the result of addition
3468 are dropped. Then, the two's complement of the sum is returned. If Length
3469 is 0, then 0 is returned.
3471 If Buffer is NULL, then ASSERT().
3472 If Buffer is not aligned on a 16-bit boundary, then ASSERT().
3473 If Length is not aligned on a 16-bit boundary, then ASSERT().
3474 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
3476 @param Buffer The pointer to the buffer to carry out the checksum operation.
3477 @param Length The size, in bytes, of Buffer.
3479 @return Checksum The two's complement checksum of Buffer.
3484 CalculateCheckSum16 (
3485 IN CONST UINT16
*Buffer
,
3491 Returns the sum of all elements in a buffer of 32-bit values. During
3492 calculation, the carry bits are dropped.
3494 This function calculates the sum of the 32-bit values in the buffer
3495 specified by Buffer and Length. The carry bits in result of addition are dropped.
3496 The 32-bit result is returned. If Length is 0, then 0 is returned.
3498 If Buffer is NULL, then ASSERT().
3499 If Buffer is not aligned on a 32-bit boundary, then ASSERT().
3500 If Length is not aligned on a 32-bit boundary, then ASSERT().
3501 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
3503 @param Buffer The pointer to the buffer to carry out the sum operation.
3504 @param Length The size, in bytes, of Buffer.
3506 @return Sum The sum of Buffer with carry bits dropped during additions.
3512 IN CONST UINT32
*Buffer
,
3518 Returns the two's complement checksum of all elements in a buffer of
3521 This function first calculates the sum of the 32-bit values in the buffer
3522 specified by Buffer and Length. The carry bits in the result of addition
3523 are dropped. Then, the two's complement of the sum is returned. If Length
3524 is 0, then 0 is returned.
3526 If Buffer is NULL, then ASSERT().
3527 If Buffer is not aligned on a 32-bit boundary, then ASSERT().
3528 If Length is not aligned on a 32-bit boundary, then ASSERT().
3529 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
3531 @param Buffer The pointer to the buffer to carry out the checksum operation.
3532 @param Length The size, in bytes, of Buffer.
3534 @return Checksum The two's complement checksum of Buffer.
3539 CalculateCheckSum32 (
3540 IN CONST UINT32
*Buffer
,
3546 Returns the sum of all elements in a buffer of 64-bit values. During
3547 calculation, the carry bits are dropped.
3549 This function calculates the sum of the 64-bit values in the buffer
3550 specified by Buffer and Length. The carry bits in result of addition are dropped.
3551 The 64-bit result is returned. If Length is 0, then 0 is returned.
3553 If Buffer is NULL, then ASSERT().
3554 If Buffer is not aligned on a 64-bit boundary, then ASSERT().
3555 If Length is not aligned on a 64-bit boundary, then ASSERT().
3556 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
3558 @param Buffer The pointer to the buffer to carry out the sum operation.
3559 @param Length The size, in bytes, of Buffer.
3561 @return Sum The sum of Buffer with carry bits dropped during additions.
3567 IN CONST UINT64
*Buffer
,
3573 Returns the two's complement checksum of all elements in a buffer of
3576 This function first calculates the sum of the 64-bit values in the buffer
3577 specified by Buffer and Length. The carry bits in the result of addition
3578 are dropped. Then, the two's complement of the sum is returned. If Length
3579 is 0, then 0 is returned.
3581 If Buffer is NULL, then ASSERT().
3582 If Buffer is not aligned on a 64-bit boundary, then ASSERT().
3583 If Length is not aligned on a 64-bit boundary, then ASSERT().
3584 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
3586 @param Buffer The pointer to the buffer to carry out the checksum operation.
3587 @param Length The size, in bytes, of Buffer.
3589 @return Checksum The two's complement checksum of Buffer.
3594 CalculateCheckSum64 (
3595 IN CONST UINT64
*Buffer
,
3601 // Base Library CPU Functions
3605 Function entry point used when a stack switch is requested with SwitchStack()
3607 @param Context1 Context1 parameter passed into SwitchStack().
3608 @param Context2 Context2 parameter passed into SwitchStack().
3613 (EFIAPI
*SWITCH_STACK_ENTRY_POINT
)(
3614 IN VOID
*Context1
, OPTIONAL
3615 IN VOID
*Context2 OPTIONAL
3620 Used to serialize load and store operations.
3622 All loads and stores that proceed calls to this function are guaranteed to be
3623 globally visible when this function returns.
3634 Saves the current CPU context that can be restored with a call to LongJump()
3637 Saves the current CPU context in the buffer specified by JumpBuffer and
3638 returns 0. The initial call to SetJump() must always return 0. Subsequent
3639 calls to LongJump() cause a non-zero value to be returned by SetJump().
3641 If JumpBuffer is NULL, then ASSERT().
3642 For Itanium processors, if JumpBuffer is not aligned on a 16-byte boundary, then ASSERT().
3644 NOTE: The structure BASE_LIBRARY_JUMP_BUFFER is CPU architecture specific.
3645 The same structure must never be used for more than one CPU architecture context.
3646 For example, a BASE_LIBRARY_JUMP_BUFFER allocated by an IA-32 module must never be used from an x64 module.
3647 SetJump()/LongJump() is not currently supported for the EBC processor type.
3649 @param JumpBuffer A pointer to CPU context buffer.
3651 @retval 0 Indicates a return from SetJump().
3657 OUT BASE_LIBRARY_JUMP_BUFFER
*JumpBuffer
3662 Restores the CPU context that was saved with SetJump().
3664 Restores the CPU context from the buffer specified by JumpBuffer. This
3665 function never returns to the caller. Instead is resumes execution based on
3666 the state of JumpBuffer.
3668 If JumpBuffer is NULL, then ASSERT().
3669 For Itanium processors, if JumpBuffer is not aligned on a 16-byte boundary, then ASSERT().
3670 If Value is 0, then ASSERT().
3672 @param JumpBuffer A pointer to CPU context buffer.
3673 @param Value The value to return when the SetJump() context is
3674 restored and must be non-zero.
3680 IN BASE_LIBRARY_JUMP_BUFFER
*JumpBuffer
,
3686 Enables CPU interrupts.
3697 Disables CPU interrupts.
3708 Disables CPU interrupts and returns the interrupt state prior to the disable
3711 @retval TRUE CPU interrupts were enabled on entry to this call.
3712 @retval FALSE CPU interrupts were disabled on entry to this call.
3717 SaveAndDisableInterrupts (
3723 Enables CPU interrupts for the smallest window required to capture any
3729 EnableDisableInterrupts (
3735 Retrieves the current CPU interrupt state.
3737 Returns TRUE if interrupts are currently enabled. Otherwise
3740 @retval TRUE CPU interrupts are enabled.
3741 @retval FALSE CPU interrupts are disabled.
3752 Set the current CPU interrupt state.
3754 Sets the current CPU interrupt state to the state specified by
3755 InterruptState. If InterruptState is TRUE, then interrupts are enabled. If
3756 InterruptState is FALSE, then interrupts are disabled. InterruptState is
3759 @param InterruptState TRUE if interrupts should enabled. FALSE if
3760 interrupts should be disabled.
3762 @return InterruptState
3768 IN BOOLEAN InterruptState
3773 Requests CPU to pause for a short period of time.
3775 Requests CPU to pause for a short period of time. Typically used in MP
3776 systems to prevent memory starvation while waiting for a spin lock.
3787 Transfers control to a function starting with a new stack.
3789 Transfers control to the function specified by EntryPoint using the
3790 new stack specified by NewStack and passing in the parameters specified
3791 by Context1 and Context2. Context1 and Context2 are optional and may
3792 be NULL. The function EntryPoint must never return. This function
3793 supports a variable number of arguments following the NewStack parameter.
3794 These additional arguments are ignored on IA-32, x64, and EBC architectures.
3795 Itanium processors expect one additional parameter of type VOID * that specifies
3796 the new backing store pointer.
3798 If EntryPoint is NULL, then ASSERT().
3799 If NewStack is NULL, then ASSERT().
3801 @param EntryPoint A pointer to function to call with the new stack.
3802 @param Context1 A pointer to the context to pass into the EntryPoint
3804 @param Context2 A pointer to the context to pass into the EntryPoint
3806 @param NewStack A pointer to the new stack to use for the EntryPoint
3808 @param ... This variable argument list is ignored for IA-32, x64, and
3809 EBC architectures. For Itanium processors, this variable
3810 argument list is expected to contain a single parameter of
3811 type VOID * that specifies the new backing store pointer.
3818 IN SWITCH_STACK_ENTRY_POINT EntryPoint
,
3819 IN VOID
*Context1
, OPTIONAL
3820 IN VOID
*Context2
, OPTIONAL
3827 Generates a breakpoint on the CPU.
3829 Generates a breakpoint on the CPU. The breakpoint must be implemented such
3830 that code can resume normal execution after the breakpoint.
3841 Executes an infinite loop.
3843 Forces the CPU to execute an infinite loop. A debugger may be used to skip
3844 past the loop and the code that follows the loop must execute properly. This
3845 implies that the infinite loop must not cause the code that follow it to be
3855 #if defined (MDE_CPU_IPF)
3858 Flush a range of cache lines in the cache coherency domain of the calling
3861 Flushes the cache lines specified by Address and Length. If Address is not aligned
3862 on a cache line boundary, then entire cache line containing Address is flushed.
3863 If Address + Length is not aligned on a cache line boundary, then the entire cache
3864 line containing Address + Length - 1 is flushed. This function may choose to flush
3865 the entire cache if that is more efficient than flushing the specified range. If
3866 Length is 0, the no cache lines are flushed. Address is returned.
3867 This function is only available on Itanium processors.
3869 If Length is greater than (MAX_ADDRESS - Address + 1), then ASSERT().
3871 @param Address The base address of the instruction lines to invalidate. If
3872 the CPU is in a physical addressing mode, then Address is a
3873 physical address. If the CPU is in a virtual addressing mode,
3874 then Address is a virtual address.
3876 @param Length The number of bytes to invalidate from the instruction cache.
3883 AsmFlushCacheRange (
3890 Executes an FC instruction.
3891 Executes an FC instruction on the cache line specified by Address.
3892 The cache line size affected is at least 32-bytes (aligned on a 32-byte boundary).
3893 An implementation may flush a larger region. This function is only available on Itanium processors.
3895 @param Address The Address of cache line to be flushed.
3897 @return The address of FC instruction executed.
3908 Executes an FC.I instruction.
3909 Executes an FC.I instruction on the cache line specified by Address.
3910 The cache line size affected is at least 32-bytes (aligned on a 32-byte boundary).
3911 An implementation may flush a larger region. This function is only available on Itanium processors.
3913 @param Address The Address of cache line to be flushed.
3915 @return The address of the FC.I instruction executed.
3926 Reads the current value of a Processor Identifier Register (CPUID).
3928 Reads and returns the current value of Processor Identifier Register specified by Index.
3929 The Index of largest implemented CPUID (One less than the number of implemented CPUID
3930 registers) is determined by CPUID [3] bits {7:0}.
3931 No parameter checking is performed on Index. If the Index value is beyond the
3932 implemented CPUID register range, a Reserved Register/Field fault may occur. The caller
3933 must either guarantee that Index is valid, or the caller must set up fault handlers to
3934 catch the faults. This function is only available on Itanium processors.
3936 @param Index The 8-bit Processor Identifier Register index to read.
3938 @return The current value of Processor Identifier Register specified by Index.
3949 Reads the current value of 64-bit Processor Status Register (PSR).
3950 This function is only available on Itanium processors.
3952 @return The current value of PSR.
3963 Writes the current value of 64-bit Processor Status Register (PSR).
3965 No parameter checking is performed on Value. All bits of Value corresponding to
3966 reserved fields of PSR must be 0 or a Reserved Register/Field fault may occur.
3967 The caller must either guarantee that Value is valid, or the caller must set up
3968 fault handlers to catch the faults. This function is only available on Itanium processors.
3970 @param Value The 64-bit value to write to PSR.
3972 @return The 64-bit value written to the PSR.
3983 Reads the current value of 64-bit Kernel Register #0 (KR0).
3985 Reads and returns the current value of KR0.
3986 This function is only available on Itanium processors.
3988 @return The current value of KR0.
3999 Reads the current value of 64-bit Kernel Register #1 (KR1).
4001 Reads and returns the current value of KR1.
4002 This function is only available on Itanium processors.
4004 @return The current value of KR1.
4015 Reads the current value of 64-bit Kernel Register #2 (KR2).
4017 Reads and returns the current value of KR2.
4018 This function is only available on Itanium processors.
4020 @return The current value of KR2.
4031 Reads the current value of 64-bit Kernel Register #3 (KR3).
4033 Reads and returns the current value of KR3.
4034 This function is only available on Itanium processors.
4036 @return The current value of KR3.
4047 Reads the current value of 64-bit Kernel Register #4 (KR4).
4049 Reads and returns the current value of KR4.
4050 This function is only available on Itanium processors.
4052 @return The current value of KR4.
4063 Reads the current value of 64-bit Kernel Register #5 (KR5).
4065 Reads and returns the current value of KR5.
4066 This function is only available on Itanium processors.
4068 @return The current value of KR5.
4079 Reads the current value of 64-bit Kernel Register #6 (KR6).
4081 Reads and returns the current value of KR6.
4082 This function is only available on Itanium processors.
4084 @return The current value of KR6.
4095 Reads the current value of 64-bit Kernel Register #7 (KR7).
4097 Reads and returns the current value of KR7.
4098 This function is only available on Itanium processors.
4100 @return The current value of KR7.
4111 Write the current value of 64-bit Kernel Register #0 (KR0).
4113 Writes the current value of KR0. The 64-bit value written to
4114 the KR0 is returned. This function is only available on Itanium processors.
4116 @param Value The 64-bit value to write to KR0.
4118 @return The 64-bit value written to the KR0.
4129 Write the current value of 64-bit Kernel Register #1 (KR1).
4131 Writes the current value of KR1. The 64-bit value written to
4132 the KR1 is returned. This function is only available on Itanium processors.
4134 @param Value The 64-bit value to write to KR1.
4136 @return The 64-bit value written to the KR1.
4147 Write the current value of 64-bit Kernel Register #2 (KR2).
4149 Writes the current value of KR2. The 64-bit value written to
4150 the KR2 is returned. This function is only available on Itanium processors.
4152 @param Value The 64-bit value to write to KR2.
4154 @return The 64-bit value written to the KR2.
4165 Write the current value of 64-bit Kernel Register #3 (KR3).
4167 Writes the current value of KR3. The 64-bit value written to
4168 the KR3 is returned. This function is only available on Itanium processors.
4170 @param Value The 64-bit value to write to KR3.
4172 @return The 64-bit value written to the KR3.
4183 Write the current value of 64-bit Kernel Register #4 (KR4).
4185 Writes the current value of KR4. The 64-bit value written to
4186 the KR4 is returned. This function is only available on Itanium processors.
4188 @param Value The 64-bit value to write to KR4.
4190 @return The 64-bit value written to the KR4.
4201 Write the current value of 64-bit Kernel Register #5 (KR5).
4203 Writes the current value of KR5. The 64-bit value written to
4204 the KR5 is returned. This function is only available on Itanium processors.
4206 @param Value The 64-bit value to write to KR5.
4208 @return The 64-bit value written to the KR5.
4219 Write the current value of 64-bit Kernel Register #6 (KR6).
4221 Writes the current value of KR6. The 64-bit value written to
4222 the KR6 is returned. This function is only available on Itanium processors.
4224 @param Value The 64-bit value to write to KR6.
4226 @return The 64-bit value written to the KR6.
4237 Write the current value of 64-bit Kernel Register #7 (KR7).
4239 Writes the current value of KR7. The 64-bit value written to
4240 the KR7 is returned. This function is only available on Itanium processors.
4242 @param Value The 64-bit value to write to KR7.
4244 @return The 64-bit value written to the KR7.
4255 Reads the current value of Interval Timer Counter Register (ITC).
4257 Reads and returns the current value of ITC.
4258 This function is only available on Itanium processors.
4260 @return The current value of ITC.
4271 Reads the current value of Interval Timer Vector Register (ITV).
4273 Reads and returns the current value of ITV.
4274 This function is only available on Itanium processors.
4276 @return The current value of ITV.
4287 Reads the current value of Interval Timer Match Register (ITM).
4289 Reads and returns the current value of ITM.
4290 This function is only available on Itanium processors.
4292 @return The current value of ITM.
4302 Writes the current value of 64-bit Interval Timer Counter Register (ITC).
4304 Writes the current value of ITC. The 64-bit value written to the ITC is returned.
4305 This function is only available on Itanium processors.
4307 @param Value The 64-bit value to write to ITC.
4309 @return The 64-bit value written to the ITC.
4320 Writes the current value of 64-bit Interval Timer Match Register (ITM).
4322 Writes the current value of ITM. The 64-bit value written to the ITM is returned.
4323 This function is only available on Itanium processors.
4325 @param Value The 64-bit value to write to ITM.
4327 @return The 64-bit value written to the ITM.
4338 Writes the current value of 64-bit Interval Timer Vector Register (ITV).
4340 Writes the current value of ITV. The 64-bit value written to the ITV is returned.
4341 No parameter checking is performed on Value. All bits of Value corresponding to
4342 reserved fields of ITV must be 0 or a Reserved Register/Field fault may occur.
4343 The caller must either guarantee that Value is valid, or the caller must set up
4344 fault handlers to catch the faults.
4345 This function is only available on Itanium processors.
4347 @param Value The 64-bit value to write to ITV.
4349 @return The 64-bit value written to the ITV.
4360 Reads the current value of Default Control Register (DCR).
4362 Reads and returns the current value of DCR. This function is only available on Itanium processors.
4364 @return The current value of DCR.
4375 Reads the current value of Interruption Vector Address Register (IVA).
4377 Reads and returns the current value of IVA. This function is only available on Itanium processors.
4379 @return The current value of IVA.
4389 Reads the current value of Page Table Address Register (PTA).
4391 Reads and returns the current value of PTA. This function is only available on Itanium processors.
4393 @return The current value of PTA.
4404 Writes the current value of 64-bit Default Control Register (DCR).
4406 Writes the current value of DCR. The 64-bit value written to the DCR is returned.
4407 No parameter checking is performed on Value. All bits of Value corresponding to
4408 reserved fields of DCR must be 0 or a Reserved Register/Field fault may occur.
4409 The caller must either guarantee that Value is valid, or the caller must set up
4410 fault handlers to catch the faults.
4411 This function is only available on Itanium processors.
4413 @param Value The 64-bit value to write to DCR.
4415 @return The 64-bit value written to the DCR.
4426 Writes the current value of 64-bit Interruption Vector Address Register (IVA).
4428 Writes the current value of IVA. The 64-bit value written to the IVA is returned.
4429 The size of vector table is 32 K bytes and is 32 K bytes aligned
4430 the low 15 bits of Value is ignored when written.
4431 This function is only available on Itanium processors.
4433 @param Value The 64-bit value to write to IVA.
4435 @return The 64-bit value written to the IVA.
4446 Writes the current value of 64-bit Page Table Address Register (PTA).
4448 Writes the current value of PTA. The 64-bit value written to the PTA is returned.
4449 No parameter checking is performed on Value. All bits of Value corresponding to
4450 reserved fields of DCR must be 0 or a Reserved Register/Field fault may occur.
4451 The caller must either guarantee that Value is valid, or the caller must set up
4452 fault handlers to catch the faults.
4453 This function is only available on Itanium processors.
4455 @param Value The 64-bit value to write to PTA.
4457 @return The 64-bit value written to the PTA.
4467 Reads the current value of Local Interrupt ID Register (LID).
4469 Reads and returns the current value of LID. This function is only available on Itanium processors.
4471 @return The current value of LID.
4482 Reads the current value of External Interrupt Vector Register (IVR).
4484 Reads and returns the current value of IVR. This function is only available on Itanium processors.
4486 @return The current value of IVR.
4497 Reads the current value of Task Priority Register (TPR).
4499 Reads and returns the current value of TPR. This function is only available on Itanium processors.
4501 @return The current value of TPR.
4512 Reads the current value of External Interrupt Request Register #0 (IRR0).
4514 Reads and returns the current value of IRR0. This function is only available on Itanium processors.
4516 @return The current value of IRR0.
4527 Reads the current value of External Interrupt Request Register #1 (IRR1).
4529 Reads and returns the current value of IRR1. This function is only available on Itanium processors.
4531 @return The current value of IRR1.
4542 Reads the current value of External Interrupt Request Register #2 (IRR2).
4544 Reads and returns the current value of IRR2. This function is only available on Itanium processors.
4546 @return The current value of IRR2.
4557 Reads the current value of External Interrupt Request Register #3 (IRR3).
4559 Reads and returns the current value of IRR3. This function is only available on Itanium processors.
4561 @return The current value of IRR3.
4572 Reads the current value of Performance Monitor Vector Register (PMV).
4574 Reads and returns the current value of PMV. This function is only available on Itanium processors.
4576 @return The current value of PMV.
4587 Reads the current value of Corrected Machine Check Vector Register (CMCV).
4589 Reads and returns the current value of CMCV. This function is only available on Itanium processors.
4591 @return The current value of CMCV.
4602 Reads the current value of Local Redirection Register #0 (LRR0).
4604 Reads and returns the current value of LRR0. This function is only available on Itanium processors.
4606 @return The current value of LRR0.
4617 Reads the current value of Local Redirection Register #1 (LRR1).
4619 Reads and returns the current value of LRR1. This function is only available on Itanium processors.
4621 @return The current value of LRR1.
4632 Writes the current value of 64-bit Page Local Interrupt ID Register (LID).
4634 Writes the current value of LID. The 64-bit value written to the LID is returned.
4635 No parameter checking is performed on Value. All bits of Value corresponding to
4636 reserved fields of LID must be 0 or a Reserved Register/Field fault may occur.
4637 The caller must either guarantee that Value is valid, or the caller must set up
4638 fault handlers to catch the faults.
4639 This function is only available on Itanium processors.
4641 @param Value The 64-bit value to write to LID.
4643 @return The 64-bit value written to the LID.
4654 Writes the current value of 64-bit Task Priority Register (TPR).
4656 Writes the current value of TPR. The 64-bit value written to the TPR is returned.
4657 No parameter checking is performed on Value. All bits of Value corresponding to
4658 reserved fields of TPR must be 0 or a Reserved Register/Field fault may occur.
4659 The caller must either guarantee that Value is valid, or the caller must set up
4660 fault handlers to catch the faults.
4661 This function is only available on Itanium processors.
4663 @param Value The 64-bit value to write to TPR.
4665 @return The 64-bit value written to the TPR.
4676 Performs a write operation on End OF External Interrupt Register (EOI).
4678 Writes a value of 0 to the EOI Register. This function is only available on Itanium processors.
4689 Writes the current value of 64-bit Performance Monitor Vector Register (PMV).
4691 Writes the current value of PMV. The 64-bit value written to the PMV is returned.
4692 No parameter checking is performed on Value. All bits of Value corresponding
4693 to reserved fields of PMV must be 0 or a Reserved Register/Field fault may occur.
4694 The caller must either guarantee that Value is valid, or the caller must set up
4695 fault handlers to catch the faults.
4696 This function is only available on Itanium processors.
4698 @param Value The 64-bit value to write to PMV.
4700 @return The 64-bit value written to the PMV.
4711 Writes the current value of 64-bit Corrected Machine Check Vector Register (CMCV).
4713 Writes the current value of CMCV. The 64-bit value written to the CMCV is returned.
4714 No parameter checking is performed on Value. All bits of Value corresponding
4715 to reserved fields of CMCV must be 0 or a Reserved Register/Field fault may occur.
4716 The caller must either guarantee that Value is valid, or the caller must set up
4717 fault handlers to catch the faults.
4718 This function is only available on Itanium processors.
4720 @param Value The 64-bit value to write to CMCV.
4722 @return The 64-bit value written to the CMCV.
4733 Writes the current value of 64-bit Local Redirection Register #0 (LRR0).
4735 Writes the current value of LRR0. The 64-bit value written to the LRR0 is returned.
4736 No parameter checking is performed on Value. All bits of Value corresponding
4737 to reserved fields of LRR0 must be 0 or a Reserved Register/Field fault may occur.
4738 The caller must either guarantee that Value is valid, or the caller must set up
4739 fault handlers to catch the faults.
4740 This function is only available on Itanium processors.
4742 @param Value The 64-bit value to write to LRR0.
4744 @return The 64-bit value written to the LRR0.
4755 Writes the current value of 64-bit Local Redirection Register #1 (LRR1).
4757 Writes the current value of LRR1. The 64-bit value written to the LRR1 is returned.
4758 No parameter checking is performed on Value. All bits of Value corresponding
4759 to reserved fields of LRR1 must be 0 or a Reserved Register/Field fault may occur.
4760 The caller must either guarantee that Value is valid, or the caller must
4761 set up fault handlers to catch the faults.
4762 This function is only available on Itanium processors.
4764 @param Value The 64-bit value to write to LRR1.
4766 @return The 64-bit value written to the LRR1.
4777 Reads the current value of Instruction Breakpoint Register (IBR).
4779 The Instruction Breakpoint Registers are used in pairs. The even numbered
4780 registers contain breakpoint addresses, and the odd numbered registers contain
4781 breakpoint mask conditions. At least four instruction registers pairs are implemented
4782 on all processor models. Implemented registers are contiguous starting with
4783 register 0. No parameter checking is performed on Index, and if the Index value
4784 is beyond the implemented IBR register range, a Reserved Register/Field fault may
4785 occur. The caller must either guarantee that Index is valid, or the caller must
4786 set up fault handlers to catch the faults.
4787 This function is only available on Itanium processors.
4789 @param Index The 8-bit Instruction Breakpoint Register index to read.
4791 @return The current value of Instruction Breakpoint Register specified by Index.
4802 Reads the current value of Data Breakpoint Register (DBR).
4804 The Data Breakpoint Registers are used in pairs. The even numbered registers
4805 contain breakpoint addresses, and odd numbered registers contain breakpoint
4806 mask conditions. At least four data registers pairs are implemented on all processor
4807 models. Implemented registers are contiguous starting with register 0.
4808 No parameter checking is performed on Index. If the Index value is beyond
4809 the implemented DBR register range, a Reserved Register/Field fault may occur.
4810 The caller must either guarantee that Index is valid, or the caller must set up
4811 fault handlers to catch the faults.
4812 This function is only available on Itanium processors.
4814 @param Index The 8-bit Data Breakpoint Register index to read.
4816 @return The current value of Data Breakpoint Register specified by Index.
4827 Reads the current value of Performance Monitor Configuration Register (PMC).
4829 All processor implementations provide at least four performance counters
4830 (PMC/PMD [4]...PMC/PMD [7] pairs), and four performance monitor counter overflow
4831 status registers (PMC [0]... PMC [3]). Processor implementations may provide
4832 additional implementation-dependent PMC and PMD to increase the number of
4833 'generic' performance counters (PMC/PMD pairs). The remainder of PMC and PMD
4834 register set is implementation dependent. No parameter checking is performed
4835 on Index. If the Index value is beyond the implemented PMC register range,
4836 zero value will be returned.
4837 This function is only available on Itanium processors.
4839 @param Index The 8-bit Performance Monitor Configuration Register index to read.
4841 @return The current value of Performance Monitor Configuration Register
4853 Reads the current value of Performance Monitor Data Register (PMD).
4855 All processor implementations provide at least 4 performance counters
4856 (PMC/PMD [4]...PMC/PMD [7] pairs), and 4 performance monitor counter
4857 overflow status registers (PMC [0]... PMC [3]). Processor implementations may
4858 provide additional implementation-dependent PMC and PMD to increase the number
4859 of 'generic' performance counters (PMC/PMD pairs). The remainder of PMC and PMD
4860 register set is implementation dependent. No parameter checking is performed
4861 on Index. If the Index value is beyond the implemented PMD register range,
4862 zero value will be returned.
4863 This function is only available on Itanium processors.
4865 @param Index The 8-bit Performance Monitor Data Register index to read.
4867 @return The current value of Performance Monitor Data Register specified by Index.
4878 Writes the current value of 64-bit Instruction Breakpoint Register (IBR).
4880 Writes current value of Instruction Breakpoint Register specified by Index.
4881 The Instruction Breakpoint Registers are used in pairs. The even numbered
4882 registers contain breakpoint addresses, and odd numbered registers contain
4883 breakpoint mask conditions. At least four instruction registers pairs are implemented
4884 on all processor models. Implemented registers are contiguous starting with
4885 register 0. No parameter checking is performed on Index. If the Index value
4886 is beyond the implemented IBR register range, a Reserved Register/Field fault may
4887 occur. The caller must either guarantee that Index is valid, or the caller must
4888 set up fault handlers to catch the faults.
4889 This function is only available on Itanium processors.
4891 @param Index The 8-bit Instruction Breakpoint Register index to write.
4892 @param Value The 64-bit value to write to IBR.
4894 @return The 64-bit value written to the IBR.
4906 Writes the current value of 64-bit Data Breakpoint Register (DBR).
4908 Writes current value of Data Breakpoint Register specified by Index.
4909 The Data Breakpoint Registers are used in pairs. The even numbered registers
4910 contain breakpoint addresses, and odd numbered registers contain breakpoint
4911 mask conditions. At least four data registers pairs are implemented on all processor
4912 models. Implemented registers are contiguous starting with register 0. No parameter
4913 checking is performed on Index. If the Index value is beyond the implemented
4914 DBR register range, a Reserved Register/Field fault may occur. The caller must
4915 either guarantee that Index is valid, or the caller must set up fault handlers to
4917 This function is only available on Itanium processors.
4919 @param Index The 8-bit Data Breakpoint Register index to write.
4920 @param Value The 64-bit value to write to DBR.
4922 @return The 64-bit value written to the DBR.
4934 Writes the current value of 64-bit Performance Monitor Configuration Register (PMC).
4936 Writes current value of Performance Monitor Configuration Register specified by Index.
4937 All processor implementations provide at least four performance counters
4938 (PMC/PMD [4]...PMC/PMD [7] pairs), and four performance monitor counter overflow status
4939 registers (PMC [0]... PMC [3]). Processor implementations may provide additional
4940 implementation-dependent PMC and PMD to increase the number of 'generic' performance
4941 counters (PMC/PMD pairs). The remainder of PMC and PMD register set is implementation
4942 dependent. No parameter checking is performed on Index. If the Index value is
4943 beyond the implemented PMC register range, the write is ignored.
4944 This function is only available on Itanium processors.
4946 @param Index The 8-bit Performance Monitor Configuration Register index to write.
4947 @param Value The 64-bit value to write to PMC.
4949 @return The 64-bit value written to the PMC.
4961 Writes the current value of 64-bit Performance Monitor Data Register (PMD).
4963 Writes current value of Performance Monitor Data Register specified by Index.
4964 All processor implementations provide at least four performance counters
4965 (PMC/PMD [4]...PMC/PMD [7] pairs), and four performance monitor counter overflow
4966 status registers (PMC [0]... PMC [3]). Processor implementations may provide
4967 additional implementation-dependent PMC and PMD to increase the number of 'generic'
4968 performance counters (PMC/PMD pairs). The remainder of PMC and PMD register set
4969 is implementation dependent. No parameter checking is performed on Index. If the
4970 Index value is beyond the implemented PMD register range, the write is ignored.
4971 This function is only available on Itanium processors.
4973 @param Index The 8-bit Performance Monitor Data Register index to write.
4974 @param Value The 64-bit value to write to PMD.
4976 @return The 64-bit value written to the PMD.
4988 Reads the current value of 64-bit Global Pointer (GP).
4990 Reads and returns the current value of GP.
4991 This function is only available on Itanium processors.
4993 @return The current value of GP.
5004 Write the current value of 64-bit Global Pointer (GP).
5006 Writes the current value of GP. The 64-bit value written to the GP is returned.
5007 No parameter checking is performed on Value.
5008 This function is only available on Itanium processors.
5010 @param Value The 64-bit value to write to GP.
5012 @return The 64-bit value written to the GP.
5023 Reads the current value of 64-bit Stack Pointer (SP).
5025 Reads and returns the current value of SP.
5026 This function is only available on Itanium processors.
5028 @return The current value of SP.
5039 /// Valid Index value for AsmReadControlRegister().
5041 #define IPF_CONTROL_REGISTER_DCR 0
5042 #define IPF_CONTROL_REGISTER_ITM 1
5043 #define IPF_CONTROL_REGISTER_IVA 2
5044 #define IPF_CONTROL_REGISTER_PTA 8
5045 #define IPF_CONTROL_REGISTER_IPSR 16
5046 #define IPF_CONTROL_REGISTER_ISR 17
5047 #define IPF_CONTROL_REGISTER_IIP 19
5048 #define IPF_CONTROL_REGISTER_IFA 20
5049 #define IPF_CONTROL_REGISTER_ITIR 21
5050 #define IPF_CONTROL_REGISTER_IIPA 22
5051 #define IPF_CONTROL_REGISTER_IFS 23
5052 #define IPF_CONTROL_REGISTER_IIM 24
5053 #define IPF_CONTROL_REGISTER_IHA 25
5054 #define IPF_CONTROL_REGISTER_LID 64
5055 #define IPF_CONTROL_REGISTER_IVR 65
5056 #define IPF_CONTROL_REGISTER_TPR 66
5057 #define IPF_CONTROL_REGISTER_EOI 67
5058 #define IPF_CONTROL_REGISTER_IRR0 68
5059 #define IPF_CONTROL_REGISTER_IRR1 69
5060 #define IPF_CONTROL_REGISTER_IRR2 70
5061 #define IPF_CONTROL_REGISTER_IRR3 71
5062 #define IPF_CONTROL_REGISTER_ITV 72
5063 #define IPF_CONTROL_REGISTER_PMV 73
5064 #define IPF_CONTROL_REGISTER_CMCV 74
5065 #define IPF_CONTROL_REGISTER_LRR0 80
5066 #define IPF_CONTROL_REGISTER_LRR1 81
5069 Reads a 64-bit control register.
5071 Reads and returns the control register specified by Index. The valid Index valued
5072 are defined above in "Related Definitions".
5073 If Index is invalid then 0xFFFFFFFFFFFFFFFF is returned. This function is only
5074 available on Itanium processors.
5076 @param Index The index of the control register to read.
5078 @return The control register specified by Index.
5083 AsmReadControlRegister (
5089 /// Valid Index value for AsmReadApplicationRegister().
5091 #define IPF_APPLICATION_REGISTER_K0 0
5092 #define IPF_APPLICATION_REGISTER_K1 1
5093 #define IPF_APPLICATION_REGISTER_K2 2
5094 #define IPF_APPLICATION_REGISTER_K3 3
5095 #define IPF_APPLICATION_REGISTER_K4 4
5096 #define IPF_APPLICATION_REGISTER_K5 5
5097 #define IPF_APPLICATION_REGISTER_K6 6
5098 #define IPF_APPLICATION_REGISTER_K7 7
5099 #define IPF_APPLICATION_REGISTER_RSC 16
5100 #define IPF_APPLICATION_REGISTER_BSP 17
5101 #define IPF_APPLICATION_REGISTER_BSPSTORE 18
5102 #define IPF_APPLICATION_REGISTER_RNAT 19
5103 #define IPF_APPLICATION_REGISTER_FCR 21
5104 #define IPF_APPLICATION_REGISTER_EFLAG 24
5105 #define IPF_APPLICATION_REGISTER_CSD 25
5106 #define IPF_APPLICATION_REGISTER_SSD 26
5107 #define IPF_APPLICATION_REGISTER_CFLG 27
5108 #define IPF_APPLICATION_REGISTER_FSR 28
5109 #define IPF_APPLICATION_REGISTER_FIR 29
5110 #define IPF_APPLICATION_REGISTER_FDR 30
5111 #define IPF_APPLICATION_REGISTER_CCV 32
5112 #define IPF_APPLICATION_REGISTER_UNAT 36
5113 #define IPF_APPLICATION_REGISTER_FPSR 40
5114 #define IPF_APPLICATION_REGISTER_ITC 44
5115 #define IPF_APPLICATION_REGISTER_PFS 64
5116 #define IPF_APPLICATION_REGISTER_LC 65
5117 #define IPF_APPLICATION_REGISTER_EC 66
5120 Reads a 64-bit application register.
5122 Reads and returns the application register specified by Index. The valid Index
5123 valued are defined above in "Related Definitions".
5124 If Index is invalid then 0xFFFFFFFFFFFFFFFF is returned. This function is only
5125 available on Itanium processors.
5127 @param Index The index of the application register to read.
5129 @return The application register specified by Index.
5134 AsmReadApplicationRegister (
5140 Reads the current value of a Machine Specific Register (MSR).
5142 Reads and returns the current value of the Machine Specific Register specified by Index. No
5143 parameter checking is performed on Index, and if the Index value is beyond the implemented MSR
5144 register range, a Reserved Register/Field fault may occur. The caller must either guarantee that
5145 Index is valid, or the caller must set up fault handlers to catch the faults. This function is
5146 only available on Itanium processors.
5148 @param Index The 8-bit Machine Specific Register index to read.
5150 @return The current value of the Machine Specific Register specified by Index.
5161 Writes the current value of a Machine Specific Register (MSR).
5163 Writes Value to the Machine Specific Register specified by Index. Value is returned. No
5164 parameter checking is performed on Index, and if the Index value is beyond the implemented MSR
5165 register range, a Reserved Register/Field fault may occur. The caller must either guarantee that
5166 Index is valid, or the caller must set up fault handlers to catch the faults. This function is
5167 only available on Itanium processors.
5169 @param Index The 8-bit Machine Specific Register index to write.
5170 @param Value The 64-bit value to write to the Machine Specific Register.
5172 @return The 64-bit value to write to the Machine Specific Register.
5184 Determines if the CPU is currently executing in virtual, physical, or mixed mode.
5186 Determines the current execution mode of the CPU.
5187 If the CPU is in virtual mode(PSR.RT=1, PSR.DT=1, PSR.IT=1), then 1 is returned.
5188 If the CPU is in physical mode(PSR.RT=0, PSR.DT=0, PSR.IT=0), then 0 is returned.
5189 If the CPU is not in physical mode or virtual mode, then it is in mixed mode,
5191 This function is only available on Itanium processors.
5193 @retval 1 The CPU is in virtual mode.
5194 @retval 0 The CPU is in physical mode.
5195 @retval -1 The CPU is in mixed mode.
5206 Makes a PAL procedure call.
5208 This is a wrapper function to make a PAL procedure call. Based on the Index
5209 value this API will make static or stacked PAL call. The following table
5210 describes the usage of PAL Procedure Index Assignment. Architected procedures
5211 may be designated as required or optional. If a PAL procedure is specified
5212 as optional, a unique return code of 0xFFFFFFFFFFFFFFFF is returned in the
5213 Status field of the PAL_CALL_RETURN structure.
5214 This indicates that the procedure is not present in this PAL implementation.
5215 It is the caller's responsibility to check for this return code after calling
5216 any optional PAL procedure.
5217 No parameter checking is performed on the 5 input parameters, but there are
5218 some common rules that the caller should follow when making a PAL call. Any
5219 address passed to PAL as buffers for return parameters must be 8-byte aligned.
5220 Unaligned addresses may cause undefined results. For those parameters defined
5221 as reserved or some fields defined as reserved must be zero filled or the invalid
5222 argument return value may be returned or undefined result may occur during the
5223 execution of the procedure. If the PalEntryPoint does not point to a valid
5224 PAL entry point then the system behavior is undefined. This function is only
5225 available on Itanium processors.
5227 @param PalEntryPoint The PAL procedure calls entry point.
5228 @param Index The PAL procedure Index number.
5229 @param Arg2 The 2nd parameter for PAL procedure calls.
5230 @param Arg3 The 3rd parameter for PAL procedure calls.
5231 @param Arg4 The 4th parameter for PAL procedure calls.
5233 @return structure returned from the PAL Call procedure, including the status and return value.
5239 IN UINT64 PalEntryPoint
,
5247 #if defined (MDE_CPU_IA32) || defined (MDE_CPU_X64)
5249 /// IA32 and x64 Specific Functions.
5250 /// Byte packed structure for 16-bit Real Mode EFLAGS.
5254 UINT32 CF
:1; ///< Carry Flag.
5255 UINT32 Reserved_0
:1; ///< Reserved.
5256 UINT32 PF
:1; ///< Parity Flag.
5257 UINT32 Reserved_1
:1; ///< Reserved.
5258 UINT32 AF
:1; ///< Auxiliary Carry Flag.
5259 UINT32 Reserved_2
:1; ///< Reserved.
5260 UINT32 ZF
:1; ///< Zero Flag.
5261 UINT32 SF
:1; ///< Sign Flag.
5262 UINT32 TF
:1; ///< Trap Flag.
5263 UINT32 IF
:1; ///< Interrupt Enable Flag.
5264 UINT32 DF
:1; ///< Direction Flag.
5265 UINT32 OF
:1; ///< Overflow Flag.
5266 UINT32 IOPL
:2; ///< I/O Privilege Level.
5267 UINT32 NT
:1; ///< Nested Task.
5268 UINT32 Reserved_3
:1; ///< Reserved.
5274 /// Byte packed structure for EFLAGS/RFLAGS.
5275 /// 32-bits on IA-32.
5276 /// 64-bits on x64. The upper 32-bits on x64 are reserved.
5280 UINT32 CF
:1; ///< Carry Flag.
5281 UINT32 Reserved_0
:1; ///< Reserved.
5282 UINT32 PF
:1; ///< Parity Flag.
5283 UINT32 Reserved_1
:1; ///< Reserved.
5284 UINT32 AF
:1; ///< Auxiliary Carry Flag.
5285 UINT32 Reserved_2
:1; ///< Reserved.
5286 UINT32 ZF
:1; ///< Zero Flag.
5287 UINT32 SF
:1; ///< Sign Flag.
5288 UINT32 TF
:1; ///< Trap Flag.
5289 UINT32 IF
:1; ///< Interrupt Enable Flag.
5290 UINT32 DF
:1; ///< Direction Flag.
5291 UINT32 OF
:1; ///< Overflow Flag.
5292 UINT32 IOPL
:2; ///< I/O Privilege Level.
5293 UINT32 NT
:1; ///< Nested Task.
5294 UINT32 Reserved_3
:1; ///< Reserved.
5295 UINT32 RF
:1; ///< Resume Flag.
5296 UINT32 VM
:1; ///< Virtual 8086 Mode.
5297 UINT32 AC
:1; ///< Alignment Check.
5298 UINT32 VIF
:1; ///< Virtual Interrupt Flag.
5299 UINT32 VIP
:1; ///< Virtual Interrupt Pending.
5300 UINT32 ID
:1; ///< ID Flag.
5301 UINT32 Reserved_4
:10; ///< Reserved.
5307 /// Byte packed structure for Control Register 0 (CR0).
5308 /// 32-bits on IA-32.
5309 /// 64-bits on x64. The upper 32-bits on x64 are reserved.
5313 UINT32 PE
:1; ///< Protection Enable.
5314 UINT32 MP
:1; ///< Monitor Coprocessor.
5315 UINT32 EM
:1; ///< Emulation.
5316 UINT32 TS
:1; ///< Task Switched.
5317 UINT32 ET
:1; ///< Extension Type.
5318 UINT32 NE
:1; ///< Numeric Error.
5319 UINT32 Reserved_0
:10; ///< Reserved.
5320 UINT32 WP
:1; ///< Write Protect.
5321 UINT32 Reserved_1
:1; ///< Reserved.
5322 UINT32 AM
:1; ///< Alignment Mask.
5323 UINT32 Reserved_2
:10; ///< Reserved.
5324 UINT32 NW
:1; ///< Mot Write-through.
5325 UINT32 CD
:1; ///< Cache Disable.
5326 UINT32 PG
:1; ///< Paging.
5332 /// Byte packed structure for Control Register 4 (CR4).
5333 /// 32-bits on IA-32.
5334 /// 64-bits on x64. The upper 32-bits on x64 are reserved.
5338 UINT32 VME
:1; ///< Virtual-8086 Mode Extensions.
5339 UINT32 PVI
:1; ///< Protected-Mode Virtual Interrupts.
5340 UINT32 TSD
:1; ///< Time Stamp Disable.
5341 UINT32 DE
:1; ///< Debugging Extensions.
5342 UINT32 PSE
:1; ///< Page Size Extensions.
5343 UINT32 PAE
:1; ///< Physical Address Extension.
5344 UINT32 MCE
:1; ///< Machine Check Enable.
5345 UINT32 PGE
:1; ///< Page Global Enable.
5346 UINT32 PCE
:1; ///< Performance Monitoring Counter
5348 UINT32 OSFXSR
:1; ///< Operating System Support for
5349 ///< FXSAVE and FXRSTOR instructions
5350 UINT32 OSXMMEXCPT
:1; ///< Operating System Support for
5351 ///< Unmasked SIMD Floating Point
5353 UINT32 Reserved_0
:2; ///< Reserved.
5354 UINT32 VMXE
:1; ///< VMX Enable
5355 UINT32 Reserved_1
:18; ///< Reserved.
5361 /// Byte packed structure for a segment descriptor in a GDT/LDT.
5380 } IA32_SEGMENT_DESCRIPTOR
;
5383 /// Byte packed structure for an IDTR, GDTR, LDTR descriptor.
5392 #define IA32_IDT_GATE_TYPE_TASK 0x85
5393 #define IA32_IDT_GATE_TYPE_INTERRUPT_16 0x86
5394 #define IA32_IDT_GATE_TYPE_TRAP_16 0x87
5395 #define IA32_IDT_GATE_TYPE_INTERRUPT_32 0x8E
5396 #define IA32_IDT_GATE_TYPE_TRAP_32 0x8F
5399 #if defined (MDE_CPU_IA32)
5401 /// Byte packed structure for an IA-32 Interrupt Gate Descriptor.
5405 UINT32 OffsetLow
:16; ///< Offset bits 15..0.
5406 UINT32 Selector
:16; ///< Selector.
5407 UINT32 Reserved_0
:8; ///< Reserved.
5408 UINT32 GateType
:8; ///< Gate Type. See #defines above.
5409 UINT32 OffsetHigh
:16; ///< Offset bits 31..16.
5412 } IA32_IDT_GATE_DESCRIPTOR
;
5416 #if defined (MDE_CPU_X64)
5418 /// Byte packed structure for an x64 Interrupt Gate Descriptor.
5422 UINT32 OffsetLow
:16; ///< Offset bits 15..0.
5423 UINT32 Selector
:16; ///< Selector.
5424 UINT32 Reserved_0
:8; ///< Reserved.
5425 UINT32 GateType
:8; ///< Gate Type. See #defines above.
5426 UINT32 OffsetHigh
:16; ///< Offset bits 31..16.
5427 UINT32 OffsetUpper
:32; ///< Offset bits 63..32.
5428 UINT32 Reserved_1
:32; ///< Reserved.
5434 } IA32_IDT_GATE_DESCRIPTOR
;
5439 /// Byte packed structure for an FP/SSE/SSE2 context.
5446 /// Structures for the 16-bit real mode thunks.
5499 IA32_EFLAGS32 EFLAGS
;
5509 } IA32_REGISTER_SET
;
5512 /// Byte packed structure for an 16-bit real mode thunks.
5515 IA32_REGISTER_SET
*RealModeState
;
5516 VOID
*RealModeBuffer
;
5517 UINT32 RealModeBufferSize
;
5518 UINT32 ThunkAttributes
;
5521 #define THUNK_ATTRIBUTE_BIG_REAL_MODE 0x00000001
5522 #define THUNK_ATTRIBUTE_DISABLE_A20_MASK_INT_15 0x00000002
5523 #define THUNK_ATTRIBUTE_DISABLE_A20_MASK_KBD_CTRL 0x00000004
5526 Retrieves CPUID information.
5528 Executes the CPUID instruction with EAX set to the value specified by Index.
5529 This function always returns Index.
5530 If Eax is not NULL, then the value of EAX after CPUID is returned in Eax.
5531 If Ebx is not NULL, then the value of EBX after CPUID is returned in Ebx.
5532 If Ecx is not NULL, then the value of ECX after CPUID is returned in Ecx.
5533 If Edx is not NULL, then the value of EDX after CPUID is returned in Edx.
5534 This function is only available on IA-32 and x64.
5536 @param Index The 32-bit value to load into EAX prior to invoking the CPUID
5538 @param Eax The pointer to the 32-bit EAX value returned by the CPUID
5539 instruction. This is an optional parameter that may be NULL.
5540 @param Ebx The pointer to the 32-bit EBX value returned by the CPUID
5541 instruction. This is an optional parameter that may be NULL.
5542 @param Ecx The pointer to the 32-bit ECX value returned by the CPUID
5543 instruction. This is an optional parameter that may be NULL.
5544 @param Edx The pointer to the 32-bit EDX value returned by the CPUID
5545 instruction. This is an optional parameter that may be NULL.
5554 OUT UINT32
*Eax
, OPTIONAL
5555 OUT UINT32
*Ebx
, OPTIONAL
5556 OUT UINT32
*Ecx
, OPTIONAL
5557 OUT UINT32
*Edx OPTIONAL
5562 Retrieves CPUID information using an extended leaf identifier.
5564 Executes the CPUID instruction with EAX set to the value specified by Index
5565 and ECX set to the value specified by SubIndex. This function always returns
5566 Index. This function is only available on IA-32 and x64.
5568 If Eax is not NULL, then the value of EAX after CPUID is returned in Eax.
5569 If Ebx is not NULL, then the value of EBX after CPUID is returned in Ebx.
5570 If Ecx is not NULL, then the value of ECX after CPUID is returned in Ecx.
5571 If Edx is not NULL, then the value of EDX after CPUID is returned in Edx.
5573 @param Index The 32-bit value to load into EAX prior to invoking the
5575 @param SubIndex The 32-bit value to load into ECX prior to invoking the
5577 @param Eax The pointer to the 32-bit EAX value returned by the CPUID
5578 instruction. This is an optional parameter that may be
5580 @param Ebx The pointer to the 32-bit EBX value returned by the CPUID
5581 instruction. This is an optional parameter that may be
5583 @param Ecx The pointer to the 32-bit ECX value returned by the CPUID
5584 instruction. This is an optional parameter that may be
5586 @param Edx The pointer to the 32-bit EDX value returned by the CPUID
5587 instruction. This is an optional parameter that may be
5598 OUT UINT32
*Eax
, OPTIONAL
5599 OUT UINT32
*Ebx
, OPTIONAL
5600 OUT UINT32
*Ecx
, OPTIONAL
5601 OUT UINT32
*Edx OPTIONAL
5606 Set CD bit and clear NW bit of CR0 followed by a WBINVD.
5608 Disables the caches by setting the CD bit of CR0 to 1, clearing the NW bit of CR0 to 0,
5609 and executing a WBINVD instruction. This function is only available on IA-32 and x64.
5620 Perform a WBINVD and clear both the CD and NW bits of CR0.
5622 Enables the caches by executing a WBINVD instruction and then clear both the CD and NW
5623 bits of CR0 to 0. This function is only available on IA-32 and x64.
5634 Returns the lower 32-bits of a Machine Specific Register(MSR).
5636 Reads and returns the lower 32-bits of the MSR specified by Index.
5637 No parameter checking is performed on Index, and some Index values may cause
5638 CPU exceptions. The caller must either guarantee that Index is valid, or the
5639 caller must set up exception handlers to catch the exceptions. This function
5640 is only available on IA-32 and x64.
5642 @param Index The 32-bit MSR index to read.
5644 @return The lower 32 bits of the MSR identified by Index.
5655 Writes a 32-bit value to a Machine Specific Register(MSR), and returns the value.
5656 The upper 32-bits of the MSR are set to zero.
5658 Writes the 32-bit value specified by Value to the MSR specified by Index. The
5659 upper 32-bits of the MSR write are set to zero. The 32-bit value written to
5660 the MSR is returned. No parameter checking is performed on Index or Value,
5661 and some of these may cause CPU exceptions. The caller must either guarantee
5662 that Index and Value are valid, or the caller must establish proper exception
5663 handlers. This function is only available on IA-32 and x64.
5665 @param Index The 32-bit MSR index to write.
5666 @param Value The 32-bit value to write to the MSR.
5680 Reads a 64-bit MSR, performs a bitwise OR on the lower 32-bits, and
5681 writes the result back to the 64-bit MSR.
5683 Reads the 64-bit MSR specified by Index, performs a bitwise OR
5684 between the lower 32-bits of the read result and the value specified by
5685 OrData, and writes the result to the 64-bit MSR specified by Index. The lower
5686 32-bits of the value written to the MSR is returned. No parameter checking is
5687 performed on Index or OrData, and some of these may cause CPU exceptions. The
5688 caller must either guarantee that Index and OrData are valid, or the caller
5689 must establish proper exception handlers. This function is only available on
5692 @param Index The 32-bit MSR index to write.
5693 @param OrData The value to OR with the read value from the MSR.
5695 @return The lower 32-bit value written to the MSR.
5707 Reads a 64-bit MSR, performs a bitwise AND on the lower 32-bits, and writes
5708 the result back to the 64-bit MSR.
5710 Reads the 64-bit MSR specified by Index, performs a bitwise AND between the
5711 lower 32-bits of the read result and the value specified by AndData, and
5712 writes the result to the 64-bit MSR specified by Index. The lower 32-bits of
5713 the value written to the MSR is returned. No parameter checking is performed
5714 on Index or AndData, and some of these may cause CPU exceptions. The caller
5715 must either guarantee that Index and AndData are valid, or the caller must
5716 establish proper exception handlers. This function is only available on IA-32
5719 @param Index The 32-bit MSR index to write.
5720 @param AndData The value to AND with the read value from the MSR.
5722 @return The lower 32-bit value written to the MSR.
5734 Reads a 64-bit MSR, performs a bitwise AND followed by a bitwise OR
5735 on the lower 32-bits, and writes the result back to the 64-bit MSR.
5737 Reads the 64-bit MSR specified by Index, performs a bitwise AND between the
5738 lower 32-bits of the read result and the value specified by AndData
5739 preserving the upper 32-bits, performs a bitwise OR between the
5740 result of the AND operation and the value specified by OrData, and writes the
5741 result to the 64-bit MSR specified by Address. The lower 32-bits of the value
5742 written to the MSR is returned. No parameter checking is performed on Index,
5743 AndData, or OrData, and some of these may cause CPU exceptions. The caller
5744 must either guarantee that Index, AndData, and OrData are valid, or the
5745 caller must establish proper exception handlers. This function is only
5746 available on IA-32 and x64.
5748 @param Index The 32-bit MSR index to write.
5749 @param AndData The value to AND with the read value from the MSR.
5750 @param OrData The value to OR with the result of the AND operation.
5752 @return The lower 32-bit value written to the MSR.
5765 Reads a bit field of an MSR.
5767 Reads the bit field in the lower 32-bits of a 64-bit MSR. The bit field is
5768 specified by the StartBit and the EndBit. The value of the bit field is
5769 returned. The caller must either guarantee that Index is valid, or the caller
5770 must set up exception handlers to catch the exceptions. This function is only
5771 available on IA-32 and x64.
5773 If StartBit is greater than 31, then ASSERT().
5774 If EndBit is greater than 31, then ASSERT().
5775 If EndBit is less than StartBit, then ASSERT().
5777 @param Index The 32-bit MSR index to read.
5778 @param StartBit The ordinal of the least significant bit in the bit field.
5780 @param EndBit The ordinal of the most significant bit in the bit field.
5783 @return The bit field read from the MSR.
5788 AsmMsrBitFieldRead32 (
5796 Writes a bit field to an MSR.
5798 Writes Value to a bit field in the lower 32-bits of a 64-bit MSR. The bit
5799 field is specified by the StartBit and the EndBit. All other bits in the
5800 destination MSR are preserved. The lower 32-bits of the MSR written is
5801 returned. The caller must either guarantee that Index and the data written
5802 is valid, or the caller must set up exception handlers to catch the exceptions.
5803 This function is only available on IA-32 and x64.
5805 If StartBit is greater than 31, then ASSERT().
5806 If EndBit is greater than 31, then ASSERT().
5807 If EndBit is less than StartBit, then ASSERT().
5808 If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
5810 @param Index The 32-bit MSR index to write.
5811 @param StartBit The ordinal of the least significant bit in the bit field.
5813 @param EndBit The ordinal of the most significant bit in the bit field.
5815 @param Value New value of the bit field.
5817 @return The lower 32-bit of the value written to the MSR.
5822 AsmMsrBitFieldWrite32 (
5831 Reads a bit field in a 64-bit MSR, performs a bitwise OR, and writes the
5832 result back to the bit field in the 64-bit MSR.
5834 Reads the 64-bit MSR specified by Index, performs a bitwise OR
5835 between the read result and the value specified by OrData, and writes the
5836 result to the 64-bit MSR specified by Index. The lower 32-bits of the value
5837 written to the MSR are returned. Extra left bits in OrData are stripped. The
5838 caller must either guarantee that Index and the data written is valid, or
5839 the caller must set up exception handlers to catch the exceptions. This
5840 function is only available on IA-32 and x64.
5842 If StartBit is greater than 31, then ASSERT().
5843 If EndBit is greater than 31, then ASSERT().
5844 If EndBit is less than StartBit, then ASSERT().
5845 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
5847 @param Index The 32-bit MSR index to write.
5848 @param StartBit The ordinal of the least significant bit in the bit field.
5850 @param EndBit The ordinal of the most significant bit in the bit field.
5852 @param OrData The value to OR with the read value from the MSR.
5854 @return The lower 32-bit of the value written to the MSR.
5859 AsmMsrBitFieldOr32 (
5868 Reads a bit field in a 64-bit MSR, performs a bitwise AND, and writes the
5869 result back to the bit field in the 64-bit MSR.
5871 Reads the 64-bit MSR specified by Index, performs a bitwise AND between the
5872 read result and the value specified by AndData, and writes the result to the
5873 64-bit MSR specified by Index. The lower 32-bits of the value written to the
5874 MSR are returned. Extra left bits in AndData are stripped. The caller must
5875 either guarantee that Index and the data written is valid, or the caller must
5876 set up exception handlers to catch the exceptions. This function is only
5877 available on IA-32 and x64.
5879 If StartBit is greater than 31, then ASSERT().
5880 If EndBit is greater than 31, then ASSERT().
5881 If EndBit is less than StartBit, then ASSERT().
5882 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
5884 @param Index The 32-bit MSR index to write.
5885 @param StartBit The ordinal of the least significant bit in the bit field.
5887 @param EndBit The ordinal of the most significant bit in the bit field.
5889 @param AndData The value to AND with the read value from the MSR.
5891 @return The lower 32-bit of the value written to the MSR.
5896 AsmMsrBitFieldAnd32 (
5905 Reads a bit field in a 64-bit MSR, performs a bitwise AND followed by a
5906 bitwise OR, and writes the result back to the bit field in the
5909 Reads the 64-bit MSR specified by Index, performs a bitwise AND followed by a
5910 bitwise OR between the read result and the value specified by
5911 AndData, and writes the result to the 64-bit MSR specified by Index. The
5912 lower 32-bits of the value written to the MSR are returned. Extra left bits
5913 in both AndData and OrData are stripped. The caller must either guarantee
5914 that Index and the data written is valid, or the caller must set up exception
5915 handlers to catch the exceptions. This function is only available on IA-32
5918 If StartBit is greater than 31, then ASSERT().
5919 If EndBit is greater than 31, then ASSERT().
5920 If EndBit is less than StartBit, then ASSERT().
5921 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
5922 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
5924 @param Index The 32-bit MSR index to write.
5925 @param StartBit The ordinal of the least significant bit in the bit field.
5927 @param EndBit The ordinal of the most significant bit in the bit field.
5929 @param AndData The value to AND with the read value from the MSR.
5930 @param OrData The value to OR with the result of the AND operation.
5932 @return The lower 32-bit of the value written to the MSR.
5937 AsmMsrBitFieldAndThenOr32 (
5947 Returns a 64-bit Machine Specific Register(MSR).
5949 Reads and returns the 64-bit MSR specified by Index. No parameter checking is
5950 performed on Index, and some Index values may cause CPU exceptions. The
5951 caller must either guarantee that Index is valid, or the caller must set up
5952 exception handlers to catch the exceptions. This function is only available
5955 @param Index The 32-bit MSR index to read.
5957 @return The value of the MSR identified by Index.
5968 Writes a 64-bit value to a Machine Specific Register(MSR), and returns the
5971 Writes the 64-bit value specified by Value to the MSR specified by Index. The
5972 64-bit value written to the MSR is returned. No parameter checking is
5973 performed on Index or Value, and some of these may cause CPU exceptions. The
5974 caller must either guarantee that Index and Value are valid, or the caller
5975 must establish proper exception handlers. This function is only available on
5978 @param Index The 32-bit MSR index to write.
5979 @param Value The 64-bit value to write to the MSR.
5993 Reads a 64-bit MSR, performs a bitwise OR, and writes the result
5994 back to the 64-bit MSR.
5996 Reads the 64-bit MSR specified by Index, performs a bitwise OR
5997 between the read result and the value specified by OrData, and writes the
5998 result to the 64-bit MSR specified by Index. The value written to the MSR is
5999 returned. No parameter checking is performed on Index or OrData, and some of
6000 these may cause CPU exceptions. The caller must either guarantee that Index
6001 and OrData are valid, or the caller must establish proper exception handlers.
6002 This function is only available on IA-32 and x64.
6004 @param Index The 32-bit MSR index to write.
6005 @param OrData The value to OR with the read value from the MSR.
6007 @return The value written back to the MSR.
6019 Reads a 64-bit MSR, performs a bitwise AND, and writes the result back to the
6022 Reads the 64-bit MSR specified by Index, performs a bitwise AND between the
6023 read result and the value specified by OrData, and writes the result to the
6024 64-bit MSR specified by Index. The value written to the MSR is returned. No
6025 parameter checking is performed on Index or OrData, and some of these may
6026 cause CPU exceptions. The caller must either guarantee that Index and OrData
6027 are valid, or the caller must establish proper exception handlers. This
6028 function is only available on IA-32 and x64.
6030 @param Index The 32-bit MSR index to write.
6031 @param AndData The value to AND with the read value from the MSR.
6033 @return The value written back to the MSR.
6045 Reads a 64-bit MSR, performs a bitwise AND followed by a bitwise
6046 OR, and writes the result back to the 64-bit MSR.
6048 Reads the 64-bit MSR specified by Index, performs a bitwise AND between read
6049 result and the value specified by AndData, performs a bitwise OR
6050 between the result of the AND operation and the value specified by OrData,
6051 and writes the result to the 64-bit MSR specified by Index. The value written
6052 to the MSR is returned. No parameter checking is performed on Index, AndData,
6053 or OrData, and some of these may cause CPU exceptions. The caller must either
6054 guarantee that Index, AndData, and OrData are valid, or the caller must
6055 establish proper exception handlers. This function is only available on IA-32
6058 @param Index The 32-bit MSR index to write.
6059 @param AndData The value to AND with the read value from the MSR.
6060 @param OrData The value to OR with the result of the AND operation.
6062 @return The value written back to the MSR.
6075 Reads a bit field of an MSR.
6077 Reads the bit field in the 64-bit MSR. The bit field is specified by the
6078 StartBit and the EndBit. The value of the bit field is returned. The caller
6079 must either guarantee that Index is valid, or the caller must set up
6080 exception handlers to catch the exceptions. This function is only available
6083 If StartBit is greater than 63, then ASSERT().
6084 If EndBit is greater than 63, then ASSERT().
6085 If EndBit is less than StartBit, then ASSERT().
6087 @param Index The 32-bit MSR index to read.
6088 @param StartBit The ordinal of the least significant bit in the bit field.
6090 @param EndBit The ordinal of the most significant bit in the bit field.
6093 @return The value read from the MSR.
6098 AsmMsrBitFieldRead64 (
6106 Writes a bit field to an MSR.
6108 Writes Value to a bit field in a 64-bit MSR. The bit field is specified by
6109 the StartBit and the EndBit. All other bits in the destination MSR are
6110 preserved. The MSR written is returned. The caller must either guarantee
6111 that Index and the data written is valid, or the caller must set up exception
6112 handlers to catch the exceptions. This function is only available on IA-32 and x64.
6114 If StartBit is greater than 63, then ASSERT().
6115 If EndBit is greater than 63, then ASSERT().
6116 If EndBit is less than StartBit, then ASSERT().
6117 If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
6119 @param Index The 32-bit MSR index to write.
6120 @param StartBit The ordinal of the least significant bit in the bit field.
6122 @param EndBit The ordinal of the most significant bit in the bit field.
6124 @param Value New value of the bit field.
6126 @return The value written back to the MSR.
6131 AsmMsrBitFieldWrite64 (
6140 Reads a bit field in a 64-bit MSR, performs a bitwise OR, and
6141 writes the result back to the bit field in the 64-bit MSR.
6143 Reads the 64-bit MSR specified by Index, performs a bitwise OR
6144 between the read result and the value specified by OrData, and writes the
6145 result to the 64-bit MSR specified by Index. The value written to the MSR is
6146 returned. Extra left bits in OrData are stripped. The caller must either
6147 guarantee that Index and the data written is valid, or the caller must set up
6148 exception handlers to catch the exceptions. This function is only available
6151 If StartBit is greater than 63, then ASSERT().
6152 If EndBit is greater than 63, then ASSERT().
6153 If EndBit is less than StartBit, then ASSERT().
6154 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
6156 @param Index The 32-bit MSR index to write.
6157 @param StartBit The ordinal of the least significant bit in the bit field.
6159 @param EndBit The ordinal of the most significant bit in the bit field.
6161 @param OrData The value to OR with the read value from the bit field.
6163 @return The value written back to the MSR.
6168 AsmMsrBitFieldOr64 (
6177 Reads a bit field in a 64-bit MSR, performs a bitwise AND, and writes the
6178 result back to the bit field in the 64-bit MSR.
6180 Reads the 64-bit MSR specified by Index, performs a bitwise AND between the
6181 read result and the value specified by AndData, and writes the result to the
6182 64-bit MSR specified by Index. The value written to the MSR is returned.
6183 Extra left bits in AndData are stripped. The caller must either guarantee
6184 that Index and the data written is valid, or the caller must set up exception
6185 handlers to catch the exceptions. This function is only available on IA-32
6188 If StartBit is greater than 63, then ASSERT().
6189 If EndBit is greater than 63, then ASSERT().
6190 If EndBit is less than StartBit, then ASSERT().
6191 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
6193 @param Index The 32-bit MSR index to write.
6194 @param StartBit The ordinal of the least significant bit in the bit field.
6196 @param EndBit The ordinal of the most significant bit in the bit field.
6198 @param AndData The value to AND with the read value from the bit field.
6200 @return The value written back to the MSR.
6205 AsmMsrBitFieldAnd64 (
6214 Reads a bit field in a 64-bit MSR, performs a bitwise AND followed by a
6215 bitwise OR, and writes the result back to the bit field in the
6218 Reads the 64-bit MSR specified by Index, performs a bitwise AND followed by
6219 a bitwise OR between the read result and the value specified by
6220 AndData, and writes the result to the 64-bit MSR specified by Index. The
6221 value written to the MSR is returned. Extra left bits in both AndData and
6222 OrData are stripped. The caller must either guarantee that Index and the data
6223 written is valid, or the caller must set up exception handlers to catch the
6224 exceptions. This function is only available on IA-32 and x64.
6226 If StartBit is greater than 63, then ASSERT().
6227 If EndBit is greater than 63, then ASSERT().
6228 If EndBit is less than StartBit, then ASSERT().
6229 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
6230 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
6232 @param Index The 32-bit MSR index to write.
6233 @param StartBit The ordinal of the least significant bit in the bit field.
6235 @param EndBit The ordinal of the most significant bit in the bit field.
6237 @param AndData The value to AND with the read value from the bit field.
6238 @param OrData The value to OR with the result of the AND operation.
6240 @return The value written back to the MSR.
6245 AsmMsrBitFieldAndThenOr64 (
6255 Reads the current value of the EFLAGS register.
6257 Reads and returns the current value of the EFLAGS register. This function is
6258 only available on IA-32 and x64. This returns a 32-bit value on IA-32 and a
6259 64-bit value on x64.
6261 @return EFLAGS on IA-32 or RFLAGS on x64.
6272 Reads the current value of the Control Register 0 (CR0).
6274 Reads and returns the current value of CR0. This function is only available
6275 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
6278 @return The value of the Control Register 0 (CR0).
6289 Reads the current value of the Control Register 2 (CR2).
6291 Reads and returns the current value of CR2. This function is only available
6292 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
6295 @return The value of the Control Register 2 (CR2).
6306 Reads the current value of the Control Register 3 (CR3).
6308 Reads and returns the current value of CR3. This function is only available
6309 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
6312 @return The value of the Control Register 3 (CR3).
6323 Reads the current value of the Control Register 4 (CR4).
6325 Reads and returns the current value of CR4. This function is only available
6326 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
6329 @return The value of the Control Register 4 (CR4).
6340 Writes a value to Control Register 0 (CR0).
6342 Writes and returns a new value to CR0. This function is only available on
6343 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
6345 @param Cr0 The value to write to CR0.
6347 @return The value written to CR0.
6358 Writes a value to Control Register 2 (CR2).
6360 Writes and returns a new value to CR2. This function is only available on
6361 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
6363 @param Cr2 The value to write to CR2.
6365 @return The value written to CR2.
6376 Writes a value to Control Register 3 (CR3).
6378 Writes and returns a new value to CR3. 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 Cr3 The value to write to CR3.
6383 @return The value written to CR3.
6394 Writes a value to Control Register 4 (CR4).
6396 Writes and returns a new value to CR4. 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 Cr4 The value to write to CR4.
6401 @return The value written to CR4.
6412 Reads the current value of Debug Register 0 (DR0).
6414 Reads and returns the current value of DR0. This function is only available
6415 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
6418 @return The value of Debug Register 0 (DR0).
6429 Reads the current value of Debug Register 1 (DR1).
6431 Reads and returns the current value of DR1. This function is only available
6432 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
6435 @return The value of Debug Register 1 (DR1).
6446 Reads the current value of Debug Register 2 (DR2).
6448 Reads and returns the current value of DR2. This function is only available
6449 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
6452 @return The value of Debug Register 2 (DR2).
6463 Reads the current value of Debug Register 3 (DR3).
6465 Reads and returns the current value of DR3. This function is only available
6466 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
6469 @return The value of Debug Register 3 (DR3).
6480 Reads the current value of Debug Register 4 (DR4).
6482 Reads and returns the current value of DR4. This function is only available
6483 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
6486 @return The value of Debug Register 4 (DR4).
6497 Reads the current value of Debug Register 5 (DR5).
6499 Reads and returns the current value of DR5. This function is only available
6500 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
6503 @return The value of Debug Register 5 (DR5).
6514 Reads the current value of Debug Register 6 (DR6).
6516 Reads and returns the current value of DR6. This function is only available
6517 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
6520 @return The value of Debug Register 6 (DR6).
6531 Reads the current value of Debug Register 7 (DR7).
6533 Reads and returns the current value of DR7. This function is only available
6534 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
6537 @return The value of Debug Register 7 (DR7).
6548 Writes a value to Debug Register 0 (DR0).
6550 Writes and returns a new value to DR0. This function is only available on
6551 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
6553 @param Dr0 The value to write to Dr0.
6555 @return The value written to Debug Register 0 (DR0).
6566 Writes a value to Debug Register 1 (DR1).
6568 Writes and returns a new value to DR1. This function is only available on
6569 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
6571 @param Dr1 The value to write to Dr1.
6573 @return The value written to Debug Register 1 (DR1).
6584 Writes a value to Debug Register 2 (DR2).
6586 Writes and returns a new value to DR2. 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 Dr2 The value to write to Dr2.
6591 @return The value written to Debug Register 2 (DR2).
6602 Writes a value to Debug Register 3 (DR3).
6604 Writes and returns a new value to DR3. 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 Dr3 The value to write to Dr3.
6609 @return The value written to Debug Register 3 (DR3).
6620 Writes a value to Debug Register 4 (DR4).
6622 Writes and returns a new value to DR4. 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 Dr4 The value to write to Dr4.
6627 @return The value written to Debug Register 4 (DR4).
6638 Writes a value to Debug Register 5 (DR5).
6640 Writes and returns a new value to DR5. 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 Dr5 The value to write to Dr5.
6645 @return The value written to Debug Register 5 (DR5).
6656 Writes a value to Debug Register 6 (DR6).
6658 Writes and returns a new value to DR6. 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 Dr6 The value to write to Dr6.
6663 @return The value written to Debug Register 6 (DR6).
6674 Writes a value to Debug Register 7 (DR7).
6676 Writes and returns a new value to DR7. 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 Dr7 The value to write to Dr7.
6681 @return The value written to Debug Register 7 (DR7).
6692 Reads the current value of Code Segment Register (CS).
6694 Reads and returns the current value of CS. This function is only available on
6697 @return The current value of CS.
6708 Reads the current value of Data Segment Register (DS).
6710 Reads and returns the current value of DS. This function is only available on
6713 @return The current value of DS.
6724 Reads the current value of Extra Segment Register (ES).
6726 Reads and returns the current value of ES. This function is only available on
6729 @return The current value of ES.
6740 Reads the current value of FS Data Segment Register (FS).
6742 Reads and returns the current value of FS. This function is only available on
6745 @return The current value of FS.
6756 Reads the current value of GS Data Segment Register (GS).
6758 Reads and returns the current value of GS. This function is only available on
6761 @return The current value of GS.
6772 Reads the current value of Stack Segment Register (SS).
6774 Reads and returns the current value of SS. This function is only available on
6777 @return The current value of SS.
6788 Reads the current value of Task Register (TR).
6790 Reads and returns the current value of TR. This function is only available on
6793 @return The current value of TR.
6804 Reads the current Global Descriptor Table Register(GDTR) descriptor.
6806 Reads and returns the current GDTR descriptor and returns it in Gdtr. This
6807 function is only available on IA-32 and x64.
6809 If Gdtr is NULL, then ASSERT().
6811 @param Gdtr The pointer to a GDTR descriptor.
6817 OUT IA32_DESCRIPTOR
*Gdtr
6822 Writes the current Global Descriptor Table Register (GDTR) descriptor.
6824 Writes and the current GDTR descriptor specified by Gdtr. This function is
6825 only available on IA-32 and x64.
6827 If Gdtr is NULL, then ASSERT().
6829 @param Gdtr The pointer to a GDTR descriptor.
6835 IN CONST IA32_DESCRIPTOR
*Gdtr
6840 Reads the current Interrupt Descriptor Table Register(IDTR) descriptor.
6842 Reads and returns the current IDTR descriptor and returns it in Idtr. This
6843 function is only available on IA-32 and x64.
6845 If Idtr is NULL, then ASSERT().
6847 @param Idtr The pointer to a IDTR descriptor.
6853 OUT IA32_DESCRIPTOR
*Idtr
6858 Writes the current Interrupt Descriptor Table Register(IDTR) descriptor.
6860 Writes the current IDTR descriptor and returns it in Idtr. This function is
6861 only available on IA-32 and x64.
6863 If Idtr is NULL, then ASSERT().
6865 @param Idtr The pointer to a IDTR descriptor.
6871 IN CONST IA32_DESCRIPTOR
*Idtr
6876 Reads the current Local Descriptor Table Register(LDTR) selector.
6878 Reads and returns the current 16-bit LDTR descriptor value. This function is
6879 only available on IA-32 and x64.
6881 @return The current selector of LDT.
6892 Writes the current Local Descriptor Table Register (LDTR) selector.
6894 Writes and the current LDTR descriptor specified by Ldtr. This function is
6895 only available on IA-32 and x64.
6897 @param Ldtr 16-bit LDTR selector value.
6908 Save the current floating point/SSE/SSE2 context to a buffer.
6910 Saves the current floating point/SSE/SSE2 state to the buffer specified by
6911 Buffer. Buffer must be aligned on a 16-byte boundary. This function is only
6912 available on IA-32 and x64.
6914 If Buffer is NULL, then ASSERT().
6915 If Buffer is not aligned on a 16-byte boundary, then ASSERT().
6917 @param Buffer The pointer to a buffer to save the floating point/SSE/SSE2 context.
6923 OUT IA32_FX_BUFFER
*Buffer
6928 Restores the current floating point/SSE/SSE2 context from a buffer.
6930 Restores the current floating point/SSE/SSE2 state from the buffer specified
6931 by Buffer. Buffer must be aligned on a 16-byte boundary. This function is
6932 only available on IA-32 and x64.
6934 If Buffer is NULL, then ASSERT().
6935 If Buffer is not aligned on a 16-byte boundary, then ASSERT().
6936 If Buffer was not saved with AsmFxSave(), then ASSERT().
6938 @param Buffer The pointer to a buffer to save the floating point/SSE/SSE2 context.
6944 IN CONST IA32_FX_BUFFER
*Buffer
6949 Reads the current value of 64-bit MMX Register #0 (MM0).
6951 Reads and returns the current value of MM0. This function is only available
6954 @return The current value of MM0.
6965 Reads the current value of 64-bit MMX Register #1 (MM1).
6967 Reads and returns the current value of MM1. This function is only available
6970 @return The current value of MM1.
6981 Reads the current value of 64-bit MMX Register #2 (MM2).
6983 Reads and returns the current value of MM2. This function is only available
6986 @return The current value of MM2.
6997 Reads the current value of 64-bit MMX Register #3 (MM3).
6999 Reads and returns the current value of MM3. This function is only available
7002 @return The current value of MM3.
7013 Reads the current value of 64-bit MMX Register #4 (MM4).
7015 Reads and returns the current value of MM4. This function is only available
7018 @return The current value of MM4.
7029 Reads the current value of 64-bit MMX Register #5 (MM5).
7031 Reads and returns the current value of MM5. This function is only available
7034 @return The current value of MM5.
7045 Reads the current value of 64-bit MMX Register #6 (MM6).
7047 Reads and returns the current value of MM6. This function is only available
7050 @return The current value of MM6.
7061 Reads the current value of 64-bit MMX Register #7 (MM7).
7063 Reads and returns the current value of MM7. This function is only available
7066 @return The current value of MM7.
7077 Writes the current value of 64-bit MMX Register #0 (MM0).
7079 Writes the current value of MM0. This function is only available on IA32 and
7082 @param Value The 64-bit value to write to MM0.
7093 Writes the current value of 64-bit MMX Register #1 (MM1).
7095 Writes the current value of MM1. This function is only available on IA32 and
7098 @param Value The 64-bit value to write to MM1.
7109 Writes the current value of 64-bit MMX Register #2 (MM2).
7111 Writes the current value of MM2. This function is only available on IA32 and
7114 @param Value The 64-bit value to write to MM2.
7125 Writes the current value of 64-bit MMX Register #3 (MM3).
7127 Writes the current value of MM3. This function is only available on IA32 and
7130 @param Value The 64-bit value to write to MM3.
7141 Writes the current value of 64-bit MMX Register #4 (MM4).
7143 Writes the current value of MM4. This function is only available on IA32 and
7146 @param Value The 64-bit value to write to MM4.
7157 Writes the current value of 64-bit MMX Register #5 (MM5).
7159 Writes the current value of MM5. This function is only available on IA32 and
7162 @param Value The 64-bit value to write to MM5.
7173 Writes the current value of 64-bit MMX Register #6 (MM6).
7175 Writes the current value of MM6. This function is only available on IA32 and
7178 @param Value The 64-bit value to write to MM6.
7189 Writes the current value of 64-bit MMX Register #7 (MM7).
7191 Writes the current value of MM7. This function is only available on IA32 and
7194 @param Value The 64-bit value to write to MM7.
7205 Reads the current value of Time Stamp Counter (TSC).
7207 Reads and returns the current value of TSC. This function is only available
7210 @return The current value of TSC
7221 Reads the current value of a Performance Counter (PMC).
7223 Reads and returns the current value of performance counter specified by
7224 Index. This function is only available on IA-32 and x64.
7226 @param Index The 32-bit Performance Counter index to read.
7228 @return The value of the PMC specified by Index.
7239 Sets up a monitor buffer that is used by AsmMwait().
7241 Executes a MONITOR instruction with the register state specified by Eax, Ecx
7242 and Edx. Returns Eax. This function is only available on IA-32 and x64.
7244 @param Eax The value to load into EAX or RAX before executing the MONITOR
7246 @param Ecx The value to load into ECX or RCX before executing the MONITOR
7248 @param Edx The value to load into EDX or RDX before executing the MONITOR
7264 Executes an MWAIT instruction.
7266 Executes an MWAIT instruction with the register state specified by Eax and
7267 Ecx. Returns Eax. This function is only available on IA-32 and x64.
7269 @param Eax The value to load into EAX or RAX before executing the MONITOR
7271 @param Ecx The value to load into ECX or RCX before executing the MONITOR
7286 Executes a WBINVD instruction.
7288 Executes a WBINVD instruction. This function is only available on IA-32 and
7300 Executes a INVD instruction.
7302 Executes a INVD instruction. This function is only available on IA-32 and
7314 Flushes a cache line from all the instruction and data caches within the
7315 coherency domain of the CPU.
7317 Flushed the cache line specified by LinearAddress, and returns LinearAddress.
7318 This function is only available on IA-32 and x64.
7320 @param LinearAddress The address of the cache line to flush. If the CPU is
7321 in a physical addressing mode, then LinearAddress is a
7322 physical address. If the CPU is in a virtual
7323 addressing mode, then LinearAddress is a virtual
7326 @return LinearAddress.
7331 IN VOID
*LinearAddress
7336 Enables the 32-bit paging mode on the CPU.
7338 Enables the 32-bit paging mode on the CPU. CR0, CR3, CR4, and the page tables
7339 must be properly initialized prior to calling this service. This function
7340 assumes the current execution mode is 32-bit protected mode. This function is
7341 only available on IA-32. After the 32-bit paging mode is enabled, control is
7342 transferred to the function specified by EntryPoint using the new stack
7343 specified by NewStack and passing in the parameters specified by Context1 and
7344 Context2. Context1 and Context2 are optional and may be NULL. The function
7345 EntryPoint must never return.
7347 If the current execution mode is not 32-bit protected mode, then ASSERT().
7348 If EntryPoint is NULL, then ASSERT().
7349 If NewStack is NULL, then ASSERT().
7351 There are a number of constraints that must be followed before calling this
7353 1) Interrupts must be disabled.
7354 2) The caller must be in 32-bit protected mode with flat descriptors. This
7355 means all descriptors must have a base of 0 and a limit of 4GB.
7356 3) CR0 and CR4 must be compatible with 32-bit protected mode with flat
7358 4) CR3 must point to valid page tables that will be used once the transition
7359 is complete, and those page tables must guarantee that the pages for this
7360 function and the stack are identity mapped.
7362 @param EntryPoint A pointer to function to call with the new stack after
7364 @param Context1 A pointer to the context to pass into the EntryPoint
7365 function as the first parameter after paging is enabled.
7366 @param Context2 A pointer to the context to pass into the EntryPoint
7367 function as the second parameter after paging is enabled.
7368 @param NewStack A pointer to the new stack to use for the EntryPoint
7369 function after paging is enabled.
7375 IN SWITCH_STACK_ENTRY_POINT EntryPoint
,
7376 IN VOID
*Context1
, OPTIONAL
7377 IN VOID
*Context2
, OPTIONAL
7383 Disables the 32-bit paging mode on the CPU.
7385 Disables the 32-bit paging mode on the CPU and returns to 32-bit protected
7386 mode. This function assumes the current execution mode is 32-paged protected
7387 mode. This function is only available on IA-32. After the 32-bit paging mode
7388 is disabled, control is transferred to the function specified by EntryPoint
7389 using the new stack specified by NewStack and passing in the parameters
7390 specified by Context1 and Context2. Context1 and Context2 are optional and
7391 may be NULL. The function EntryPoint must never return.
7393 If the current execution mode is not 32-bit paged mode, then ASSERT().
7394 If EntryPoint is NULL, then ASSERT().
7395 If NewStack is NULL, then ASSERT().
7397 There are a number of constraints that must be followed before calling this
7399 1) Interrupts must be disabled.
7400 2) The caller must be in 32-bit paged mode.
7401 3) CR0, CR3, and CR4 must be compatible with 32-bit paged mode.
7402 4) CR3 must point to valid page tables that guarantee that the pages for
7403 this function and the stack are identity mapped.
7405 @param EntryPoint A pointer to function to call with the new stack after
7407 @param Context1 A pointer to the context to pass into the EntryPoint
7408 function as the first parameter after paging is disabled.
7409 @param Context2 A pointer to the context to pass into the EntryPoint
7410 function as the second parameter after paging is
7412 @param NewStack A pointer to the new stack to use for the EntryPoint
7413 function after paging is disabled.
7418 AsmDisablePaging32 (
7419 IN SWITCH_STACK_ENTRY_POINT EntryPoint
,
7420 IN VOID
*Context1
, OPTIONAL
7421 IN VOID
*Context2
, OPTIONAL
7427 Enables the 64-bit paging mode on the CPU.
7429 Enables the 64-bit paging mode on the CPU. CR0, CR3, CR4, and the page tables
7430 must be properly initialized prior to calling this service. This function
7431 assumes the current execution mode is 32-bit protected mode with flat
7432 descriptors. This function is only available on IA-32. After the 64-bit
7433 paging mode is enabled, control is transferred to the function specified by
7434 EntryPoint using the new stack specified by NewStack and passing in the
7435 parameters specified by Context1 and Context2. Context1 and Context2 are
7436 optional and may be 0. The function EntryPoint must never return.
7438 If the current execution mode is not 32-bit protected mode with flat
7439 descriptors, then ASSERT().
7440 If EntryPoint is 0, then ASSERT().
7441 If NewStack is 0, then ASSERT().
7443 @param Cs The 16-bit selector to load in the CS before EntryPoint
7444 is called. The descriptor in the GDT that this selector
7445 references must be setup for long mode.
7446 @param EntryPoint The 64-bit virtual address of the function to call with
7447 the new stack after paging is enabled.
7448 @param Context1 The 64-bit virtual address of the context to pass into
7449 the EntryPoint function as the first parameter after
7451 @param Context2 The 64-bit virtual address of the context to pass into
7452 the EntryPoint function as the second parameter after
7454 @param NewStack The 64-bit virtual address of the new stack to use for
7455 the EntryPoint function after paging is enabled.
7462 IN UINT64 EntryPoint
,
7463 IN UINT64 Context1
, OPTIONAL
7464 IN UINT64 Context2
, OPTIONAL
7470 Disables the 64-bit paging mode on the CPU.
7472 Disables the 64-bit paging mode on the CPU and returns to 32-bit protected
7473 mode. This function assumes the current execution mode is 64-paging mode.
7474 This function is only available on x64. After the 64-bit paging mode is
7475 disabled, control is transferred to the function specified by EntryPoint
7476 using the new stack specified by NewStack and passing in the parameters
7477 specified by Context1 and Context2. Context1 and Context2 are optional and
7478 may be 0. The function EntryPoint must never return.
7480 If the current execution mode is not 64-bit paged mode, then ASSERT().
7481 If EntryPoint is 0, then ASSERT().
7482 If NewStack is 0, then ASSERT().
7484 @param Cs The 16-bit selector to load in the CS before EntryPoint
7485 is called. The descriptor in the GDT that this selector
7486 references must be setup for 32-bit protected mode.
7487 @param EntryPoint The 64-bit virtual address of the function to call with
7488 the new stack after paging is disabled.
7489 @param Context1 The 64-bit virtual address of the context to pass into
7490 the EntryPoint function as the first parameter after
7492 @param Context2 The 64-bit virtual address of the context to pass into
7493 the EntryPoint function as the second parameter after
7495 @param NewStack The 64-bit virtual address of the new stack to use for
7496 the EntryPoint function after paging is disabled.
7501 AsmDisablePaging64 (
7503 IN UINT32 EntryPoint
,
7504 IN UINT32 Context1
, OPTIONAL
7505 IN UINT32 Context2
, OPTIONAL
7511 // 16-bit thunking services
7515 Retrieves the properties for 16-bit thunk functions.
7517 Computes the size of the buffer and stack below 1MB required to use the
7518 AsmPrepareThunk16(), AsmThunk16() and AsmPrepareAndThunk16() functions. This
7519 buffer size is returned in RealModeBufferSize, and the stack size is returned
7520 in ExtraStackSize. If parameters are passed to the 16-bit real mode code,
7521 then the actual minimum stack size is ExtraStackSize plus the maximum number
7522 of bytes that need to be passed to the 16-bit real mode code.
7524 If RealModeBufferSize is NULL, then ASSERT().
7525 If ExtraStackSize is NULL, then ASSERT().
7527 @param RealModeBufferSize A pointer to the size of the buffer below 1MB
7528 required to use the 16-bit thunk functions.
7529 @param ExtraStackSize A pointer to the extra size of stack below 1MB
7530 that the 16-bit thunk functions require for
7531 temporary storage in the transition to and from
7537 AsmGetThunk16Properties (
7538 OUT UINT32
*RealModeBufferSize
,
7539 OUT UINT32
*ExtraStackSize
7544 Prepares all structures a code required to use AsmThunk16().
7546 Prepares all structures and code required to use AsmThunk16().
7548 This interface is limited to be used in either physical mode or virtual modes with paging enabled where the
7549 virtual to physical mappings for ThunkContext.RealModeBuffer is mapped 1:1.
7551 If ThunkContext is NULL, then ASSERT().
7553 @param ThunkContext A pointer to the context structure that describes the
7554 16-bit real mode code to call.
7560 IN OUT THUNK_CONTEXT
*ThunkContext
7565 Transfers control to a 16-bit real mode entry point and returns the results.
7567 Transfers control to a 16-bit real mode entry point and returns the results.
7568 AsmPrepareThunk16() must be called with ThunkContext before this function is used.
7569 This function must be called with interrupts disabled.
7571 The register state from the RealModeState field of ThunkContext is restored just prior
7572 to calling the 16-bit real mode entry point. This includes the EFLAGS field of RealModeState,
7573 which is used to set the interrupt state when a 16-bit real mode entry point is called.
7574 Control is transferred to the 16-bit real mode entry point specified by the CS and Eip fields of RealModeState.
7575 The stack is initialized to the SS and ESP fields of RealModeState. Any parameters passed to
7576 the 16-bit real mode code must be populated by the caller at SS:ESP prior to calling this function.
7577 The 16-bit real mode entry point is invoked with a 16-bit CALL FAR instruction,
7578 so when accessing stack contents, the 16-bit real mode code must account for the 16-bit segment
7579 and 16-bit offset of the return address that were pushed onto the stack. The 16-bit real mode entry
7580 point must exit with a RETF instruction. The register state is captured into RealModeState immediately
7581 after the RETF instruction is executed.
7583 If EFLAGS specifies interrupts enabled, or any of the 16-bit real mode code enables interrupts,
7584 or any of the 16-bit real mode code makes a SW interrupt, then the caller is responsible for making sure
7585 the IDT at address 0 is initialized to handle any HW or SW interrupts that may occur while in 16-bit real mode.
7587 If EFLAGS specifies interrupts enabled, or any of the 16-bit real mode code enables interrupts,
7588 then the caller is responsible for making sure the 8259 PIC is in a state compatible with 16-bit real mode.
7589 This includes the base vectors, the interrupt masks, and the edge/level trigger mode.
7591 If THUNK_ATTRIBUTE_BIG_REAL_MODE is set in the ThunkAttributes field of ThunkContext, then the user code
7592 is invoked in big real mode. Otherwise, the user code is invoked in 16-bit real mode with 64KB segment limits.
7594 If neither THUNK_ATTRIBUTE_DISABLE_A20_MASK_INT_15 nor THUNK_ATTRIBUTE_DISABLE_A20_MASK_KBD_CTRL are set in
7595 ThunkAttributes, then it is assumed that the user code did not enable the A20 mask, and no attempt is made to
7596 disable the A20 mask.
7598 If THUNK_ATTRIBUTE_DISABLE_A20_MASK_INT_15 is set and THUNK_ATTRIBUTE_DISABLE_A20_MASK_KBD_CTRL is clear in
7599 ThunkAttributes, then attempt to use the INT 15 service to disable the A20 mask. If this INT 15 call fails,
7600 then attempt to disable the A20 mask by directly accessing the 8042 keyboard controller I/O ports.
7602 If THUNK_ATTRIBUTE_DISABLE_A20_MASK_INT_15 is clear and THUNK_ATTRIBUTE_DISABLE_A20_MASK_KBD_CTRL is set in
7603 ThunkAttributes, then attempt to disable the A20 mask by directly accessing the 8042 keyboard controller I/O ports.
7605 If ThunkContext is NULL, then ASSERT().
7606 If AsmPrepareThunk16() was not previously called with ThunkContext, then ASSERT().
7607 If both THUNK_ATTRIBUTE_DISABLE_A20_MASK_INT_15 and THUNK_ATTRIBUTE_DISABLE_A20_MASK_KBD_CTRL are set in
7608 ThunkAttributes, then ASSERT().
7610 This interface is limited to be used in either physical mode or virtual modes with paging enabled where the
7611 virtual to physical mappings for ThunkContext.RealModeBuffer are mapped 1:1.
7613 @param ThunkContext A pointer to the context structure that describes the
7614 16-bit real mode code to call.
7620 IN OUT THUNK_CONTEXT
*ThunkContext
7625 Prepares all structures and code for a 16-bit real mode thunk, transfers
7626 control to a 16-bit real mode entry point, and returns the results.
7628 Prepares all structures and code for a 16-bit real mode thunk, transfers
7629 control to a 16-bit real mode entry point, and returns the results. If the
7630 caller only need to perform a single 16-bit real mode thunk, then this
7631 service should be used. If the caller intends to make more than one 16-bit
7632 real mode thunk, then it is more efficient if AsmPrepareThunk16() is called
7633 once and AsmThunk16() can be called for each 16-bit real mode thunk.
7635 This interface is limited to be used in either physical mode or virtual modes with paging enabled where the
7636 virtual to physical mappings for ThunkContext.RealModeBuffer is mapped 1:1.
7638 See AsmPrepareThunk16() and AsmThunk16() for the detailed description and ASSERT() conditions.
7640 @param ThunkContext A pointer to the context structure that describes the
7641 16-bit real mode code to call.
7646 AsmPrepareAndThunk16 (
7647 IN OUT THUNK_CONTEXT
*ThunkContext