2 Provides string functions, linked list functions, math functions, synchronization
3 functions, and CPU architecture-specific functions.
5 Copyright (c) 2006 - 2014, 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().
215 @param Destination A pointer to a Null-terminated Unicode string.
216 @param DestMax The maximum number of Destination Unicode
217 char, including terminating null char.
218 @param Source A pointer to a Null-terminated Unicode string.
220 @retval RETURN_SUCCESS String is copied.
221 @retval RETURN_BUFFER_TOO_SMALL If DestMax is NOT greater than StrLen(Source).
222 @retval RETURN_INVALID_PARAMETER If Destination is NULL.
224 If PcdMaximumUnicodeStringLength is not zero,
225 and DestMax is greater than
226 PcdMaximumUnicodeStringLength.
228 @retval RETURN_ACCESS_DENIED If Source and Destination overlap.
233 OUT CHAR16
*Destination
,
235 IN CONST CHAR16
*Source
239 Copies not more than Length successive char from the string pointed to by
240 Source to the array pointed to by Destination. If no null char is copied from
241 Source, then Destination[Length] is always set to null.
243 If Length > 0 and Destination is not aligned on a 16-bit boundary, then ASSERT().
244 If Length > 0 and Source is not aligned on a 16-bit boundary, then ASSERT().
246 @param Destination A pointer to a Null-terminated Unicode string.
247 @param DestMax The maximum number of Destination Unicode
248 char, including terminating null char.
249 @param Source A pointer to a Null-terminated Unicode string.
250 @param Length The maximum number of Unicode characters to copy.
252 @retval RETURN_SUCCESS String is copied.
253 @retval RETURN_BUFFER_TOO_SMALL If DestMax is NOT greater than
254 MIN(StrLen(Source), Length).
255 @retval RETURN_INVALID_PARAMETER If Destination is NULL.
257 If PcdMaximumUnicodeStringLength is not zero,
258 and DestMax is greater than
259 PcdMaximumUnicodeStringLength.
261 @retval RETURN_ACCESS_DENIED If Source and Destination overlap.
266 OUT CHAR16
*Destination
,
268 IN CONST CHAR16
*Source
,
273 Appends a copy of the string pointed to by Source (including the terminating
274 null char) to the end of the string pointed to by Destination.
276 If Destination is not aligned on a 16-bit boundary, then ASSERT().
277 If Source is not aligned on a 16-bit boundary, then ASSERT().
279 @param Destination A pointer to a Null-terminated Unicode string.
280 @param DestMax The maximum number of Destination Unicode
281 char, including terminating null char.
282 @param Source A pointer to a Null-terminated Unicode string.
284 @retval RETURN_SUCCESS String is appended.
285 @retval RETURN_BAD_BUFFER_SIZE If DestMax is NOT greater than
287 @retval RETURN_BUFFER_TOO_SMALL If (DestMax - StrLen(Destination)) is NOT
288 greater than StrLen(Source).
289 @retval RETURN_INVALID_PARAMETER If Destination is NULL.
291 If PcdMaximumUnicodeStringLength is not zero,
292 and DestMax is greater than
293 PcdMaximumUnicodeStringLength.
295 @retval RETURN_ACCESS_DENIED If Source and Destination overlap.
300 IN OUT CHAR16
*Destination
,
302 IN CONST CHAR16
*Source
306 Appends not more than Length successive char from the string pointed to by
307 Source to the end of the string pointed to by Destination. If no null char is
308 copied from Source, then Destination[StrLen(Destination) + Length] is always
311 If Destination is not aligned on a 16-bit boundary, then ASSERT().
312 If and Source is not aligned on a 16-bit boundary, then ASSERT().
314 @param Destination A pointer to a Null-terminated Unicode string.
315 @param DestMax The maximum number of Destination Unicode
316 char, including terminating null char.
317 @param Source A pointer to a Null-terminated Unicode string.
318 @param Length The maximum number of Unicode characters to copy.
320 @retval RETURN_SUCCESS String is appended.
321 @retval RETURN_BAD_BUFFER_SIZE If DestMax is NOT greater than
323 @retval RETURN_BUFFER_TOO_SMALL If (DestMax - StrLen(Destination)) is NOT
324 greater than MIN(StrLen(Source), Length).
325 @retval RETURN_INVALID_PARAMETER If Destination is NULL.
327 If PcdMaximumUnicodeStringLength is not zero,
328 and DestMax is greater than
329 PcdMaximumUnicodeStringLength.
331 @retval RETURN_ACCESS_DENIED If Source and Destination overlap.
336 IN OUT CHAR16
*Destination
,
338 IN CONST CHAR16
*Source
,
343 Returns the length of a Null-terminated Ascii string.
345 @param String A pointer to a Null-terminated Ascii string.
346 @param MaxSize The maximum number of Destination Ascii
347 char, including terminating null char.
349 @retval 0 If String is NULL.
350 @retval MaxSize If there is no null character in the first MaxSize characters of String.
351 @return The number of characters that percede the terminating null character.
357 IN CONST CHAR8
*String
,
362 Copies the string pointed to by Source (including the terminating null char)
363 to the array pointed to by Destination.
365 @param Destination A pointer to a Null-terminated Ascii string.
366 @param DestMax The maximum number of Destination Ascii
367 char, including terminating null char.
368 @param Source A pointer to a Null-terminated Ascii string.
370 @retval RETURN_SUCCESS String is copied.
371 @retval RETURN_BUFFER_TOO_SMALL If DestMax is NOT greater than StrLen(Source).
372 @retval RETURN_INVALID_PARAMETER If Destination is NULL.
374 If PcdMaximumAsciiStringLength is not zero,
375 and DestMax is greater than
376 PcdMaximumAsciiStringLength.
378 @retval RETURN_ACCESS_DENIED If Source and Destination overlap.
383 OUT CHAR8
*Destination
,
385 IN CONST CHAR8
*Source
389 Copies not more than Length successive char from the string pointed to by
390 Source to the array pointed to by Destination. If no null char is copied from
391 Source, then Destination[Length] is always set to null.
393 @param Destination A pointer to a Null-terminated Ascii string.
394 @param DestMax The maximum number of Destination Ascii
395 char, including terminating null char.
396 @param Source A pointer to a Null-terminated Ascii string.
397 @param Length The maximum number of Ascii characters to copy.
399 @retval RETURN_SUCCESS String is copied.
400 @retval RETURN_BUFFER_TOO_SMALL If DestMax is NOT greater than
401 MIN(StrLen(Source), Length).
402 @retval RETURN_INVALID_PARAMETER If Destination is NULL.
404 If PcdMaximumAsciiStringLength is not zero,
405 and DestMax is greater than
406 PcdMaximumAsciiStringLength.
408 @retval RETURN_ACCESS_DENIED If Source and Destination overlap.
413 OUT CHAR8
*Destination
,
415 IN CONST CHAR8
*Source
,
420 Appends a copy of the string pointed to by Source (including the terminating
421 null char) to the end of the string pointed to by Destination.
423 @param Destination A pointer to a Null-terminated Ascii string.
424 @param DestMax The maximum number of Destination Ascii
425 char, including terminating null char.
426 @param Source A pointer to a Null-terminated Ascii string.
428 @retval RETURN_SUCCESS String is appended.
429 @retval RETURN_BAD_BUFFER_SIZE If DestMax is NOT greater than
431 @retval RETURN_BUFFER_TOO_SMALL If (DestMax - StrLen(Destination)) is NOT
432 greater than StrLen(Source).
433 @retval RETURN_INVALID_PARAMETER If Destination is NULL.
435 If PcdMaximumAsciiStringLength is not zero,
436 and DestMax is greater than
437 PcdMaximumAsciiStringLength.
439 @retval RETURN_ACCESS_DENIED If Source and Destination overlap.
444 IN OUT CHAR8
*Destination
,
446 IN CONST CHAR8
*Source
450 Appends not more than Length successive char from the string pointed to by
451 Source to the end of the string pointed to by Destination. If no null char is
452 copied from Source, then Destination[StrLen(Destination) + Length] is always
455 @param Destination A pointer to a Null-terminated Ascii string.
456 @param DestMax The maximum number of Destination Ascii
457 char, including terminating null char.
458 @param Source A pointer to a Null-terminated Ascii string.
459 @param Length The maximum number of Ascii characters to copy.
461 @retval RETURN_SUCCESS String is appended.
462 @retval RETURN_BAD_BUFFER_SIZE If DestMax is NOT greater than
464 @retval RETURN_BUFFER_TOO_SMALL If (DestMax - StrLen(Destination)) is NOT
465 greater than MIN(StrLen(Source), Length).
466 @retval RETURN_INVALID_PARAMETER If Destination is NULL.
468 If PcdMaximumAsciiStringLength is not zero,
469 and DestMax is greater than
470 PcdMaximumAsciiStringLength.
472 @retval RETURN_ACCESS_DENIED If Source and Destination overlap.
477 IN OUT CHAR8
*Destination
,
479 IN CONST CHAR8
*Source
,
484 #ifndef DISABLE_NEW_DEPRECATED_INTERFACES
487 [ATTENTION] This function will be deprecated for security reason.
489 Copies one Null-terminated Unicode string to another Null-terminated Unicode
490 string and returns the new Unicode string.
492 This function copies the contents of the Unicode string Source to the Unicode
493 string Destination, and returns Destination. If Source and Destination
494 overlap, then the results are undefined.
496 If Destination is NULL, then ASSERT().
497 If Destination is not aligned on a 16-bit boundary, then ASSERT().
498 If Source is NULL, then ASSERT().
499 If Source is not aligned on a 16-bit boundary, then ASSERT().
500 If Source and Destination overlap, then ASSERT().
501 If PcdMaximumUnicodeStringLength is not zero, and Source contains more than
502 PcdMaximumUnicodeStringLength Unicode characters not including the
503 Null-terminator, then ASSERT().
505 @param Destination The pointer to a Null-terminated Unicode string.
506 @param Source The pointer to a Null-terminated Unicode string.
514 OUT CHAR16
*Destination
,
515 IN CONST CHAR16
*Source
520 [ATTENTION] This function will be deprecated for security reason.
522 Copies up to a specified length from one Null-terminated Unicode string to
523 another Null-terminated Unicode string and returns the new Unicode string.
525 This function copies the contents of the Unicode string Source to the Unicode
526 string Destination, and returns Destination. At most, Length Unicode
527 characters are copied from Source to Destination. If Length is 0, then
528 Destination is returned unmodified. If Length is greater that the number of
529 Unicode characters in Source, then Destination is padded with Null Unicode
530 characters. If Source and Destination overlap, then the results are
533 If Length > 0 and Destination is NULL, then ASSERT().
534 If Length > 0 and Destination is not aligned on a 16-bit boundary, then ASSERT().
535 If Length > 0 and Source is NULL, then ASSERT().
536 If Length > 0 and Source is not aligned on a 16-bit boundary, then ASSERT().
537 If Source and Destination overlap, then ASSERT().
538 If PcdMaximumUnicodeStringLength is not zero, and Length is greater than
539 PcdMaximumUnicodeStringLength, then ASSERT().
540 If PcdMaximumUnicodeStringLength is not zero, and Source contains more than
541 PcdMaximumUnicodeStringLength Unicode characters, not including the Null-terminator,
544 @param Destination The pointer to a Null-terminated Unicode string.
545 @param Source The pointer to a Null-terminated Unicode string.
546 @param Length The maximum number of Unicode characters to copy.
554 OUT CHAR16
*Destination
,
555 IN CONST CHAR16
*Source
,
561 Returns the length of a Null-terminated Unicode string.
563 This function returns the number of Unicode characters in the Null-terminated
564 Unicode string specified by String.
566 If String is NULL, then ASSERT().
567 If String is not aligned on a 16-bit boundary, then ASSERT().
568 If PcdMaximumUnicodeStringLength is not zero, and String contains more than
569 PcdMaximumUnicodeStringLength Unicode characters not including the
570 Null-terminator, then ASSERT().
572 @param String Pointer to a Null-terminated Unicode string.
574 @return The length of String.
580 IN CONST CHAR16
*String
585 Returns the size of a Null-terminated Unicode string in bytes, including the
588 This function returns the size, in bytes, of the Null-terminated Unicode string
591 If String is NULL, then ASSERT().
592 If String is not aligned on a 16-bit boundary, then ASSERT().
593 If PcdMaximumUnicodeStringLength is not zero, and String contains more than
594 PcdMaximumUnicodeStringLength Unicode characters not including the
595 Null-terminator, then ASSERT().
597 @param String The pointer to a Null-terminated Unicode string.
599 @return The size of String.
605 IN CONST CHAR16
*String
610 Compares two Null-terminated Unicode strings, and returns the difference
611 between the first mismatched Unicode characters.
613 This function compares the Null-terminated Unicode string FirstString to the
614 Null-terminated Unicode string SecondString. If FirstString is identical to
615 SecondString, then 0 is returned. Otherwise, the value returned is the first
616 mismatched Unicode character in SecondString subtracted from the first
617 mismatched Unicode character in FirstString.
619 If FirstString is NULL, then ASSERT().
620 If FirstString is not aligned on a 16-bit boundary, then ASSERT().
621 If SecondString is NULL, then ASSERT().
622 If SecondString is not aligned on a 16-bit boundary, then ASSERT().
623 If PcdMaximumUnicodeStringLength is not zero, and FirstString contains more
624 than PcdMaximumUnicodeStringLength Unicode characters not including the
625 Null-terminator, then ASSERT().
626 If PcdMaximumUnicodeStringLength is not zero, and SecondString contains more
627 than PcdMaximumUnicodeStringLength Unicode characters, not including the
628 Null-terminator, then ASSERT().
630 @param FirstString The pointer to a Null-terminated Unicode string.
631 @param SecondString The pointer to a Null-terminated Unicode string.
633 @retval 0 FirstString is identical to SecondString.
634 @return others FirstString is not identical to SecondString.
640 IN CONST CHAR16
*FirstString
,
641 IN CONST CHAR16
*SecondString
646 Compares up to a specified length the contents of two Null-terminated Unicode strings,
647 and returns the difference between the first mismatched Unicode characters.
649 This function compares the Null-terminated Unicode string FirstString to the
650 Null-terminated Unicode string SecondString. At most, Length Unicode
651 characters will be compared. If Length is 0, then 0 is returned. If
652 FirstString is identical to SecondString, then 0 is returned. Otherwise, the
653 value returned is the first mismatched Unicode character in SecondString
654 subtracted from the first mismatched Unicode character in FirstString.
656 If Length > 0 and FirstString is NULL, then ASSERT().
657 If Length > 0 and FirstString is not aligned on a 16-bit boundary, then ASSERT().
658 If Length > 0 and SecondString is NULL, then ASSERT().
659 If Length > 0 and SecondString is not aligned on a 16-bit boundary, then ASSERT().
660 If PcdMaximumUnicodeStringLength is not zero, and Length is greater than
661 PcdMaximumUnicodeStringLength, then ASSERT().
662 If PcdMaximumUnicodeStringLength is not zero, and FirstString contains more than
663 PcdMaximumUnicodeStringLength Unicode characters, not including the Null-terminator,
665 If PcdMaximumUnicodeStringLength is not zero, and SecondString contains more than
666 PcdMaximumUnicodeStringLength Unicode characters, not including the Null-terminator,
669 @param FirstString The pointer to a Null-terminated Unicode string.
670 @param SecondString The pointer to a Null-terminated Unicode string.
671 @param Length The maximum number of Unicode characters to compare.
673 @retval 0 FirstString is identical to SecondString.
674 @return others FirstString is not identical to SecondString.
680 IN CONST CHAR16
*FirstString
,
681 IN CONST CHAR16
*SecondString
,
686 #ifndef DISABLE_NEW_DEPRECATED_INTERFACES
689 [ATTENTION] This function will be deprecated for security reason.
691 Concatenates one Null-terminated Unicode string to another Null-terminated
692 Unicode string, and returns the concatenated Unicode string.
694 This function concatenates two Null-terminated Unicode strings. The contents
695 of Null-terminated Unicode string Source are concatenated to the end of
696 Null-terminated Unicode string Destination. The Null-terminated concatenated
697 Unicode String is returned. If Source and Destination overlap, then the
698 results are undefined.
700 If Destination is NULL, then ASSERT().
701 If Destination is not aligned on a 16-bit boundary, then ASSERT().
702 If Source is NULL, then ASSERT().
703 If Source is not aligned on a 16-bit boundary, then ASSERT().
704 If Source and Destination overlap, then ASSERT().
705 If PcdMaximumUnicodeStringLength is not zero, and Destination contains more
706 than PcdMaximumUnicodeStringLength Unicode characters, not including the
707 Null-terminator, then ASSERT().
708 If PcdMaximumUnicodeStringLength is not zero, and Source contains more than
709 PcdMaximumUnicodeStringLength Unicode characters, not including the
710 Null-terminator, then ASSERT().
711 If PcdMaximumUnicodeStringLength is not zero, and concatenating Destination
712 and Source results in a Unicode string with more than
713 PcdMaximumUnicodeStringLength Unicode characters, not including the
714 Null-terminator, then ASSERT().
716 @param Destination The pointer to a Null-terminated Unicode string.
717 @param Source The pointer to a Null-terminated Unicode string.
725 IN OUT CHAR16
*Destination
,
726 IN CONST CHAR16
*Source
731 [ATTENTION] This function will be deprecated for security reason.
733 Concatenates up to a specified length one Null-terminated Unicode to the end
734 of another Null-terminated Unicode string, and returns the concatenated
737 This function concatenates two Null-terminated Unicode strings. The contents
738 of Null-terminated Unicode string Source are concatenated to the end of
739 Null-terminated Unicode string Destination, and Destination is returned. At
740 most, Length Unicode characters are concatenated from Source to the end of
741 Destination, and Destination is always Null-terminated. If Length is 0, then
742 Destination is returned unmodified. If Source and Destination overlap, then
743 the results are undefined.
745 If Destination is NULL, then ASSERT().
746 If Length > 0 and Destination is not aligned on a 16-bit boundary, then ASSERT().
747 If Length > 0 and Source is NULL, then ASSERT().
748 If Length > 0 and Source is not aligned on a 16-bit boundary, then ASSERT().
749 If Source and Destination overlap, then ASSERT().
750 If PcdMaximumUnicodeStringLength is not zero, and Length is greater than
751 PcdMaximumUnicodeStringLength, then ASSERT().
752 If PcdMaximumUnicodeStringLength is not zero, and Destination contains more
753 than PcdMaximumUnicodeStringLength Unicode characters, not including the
754 Null-terminator, then ASSERT().
755 If PcdMaximumUnicodeStringLength is not zero, and Source contains more than
756 PcdMaximumUnicodeStringLength Unicode characters, not including the
757 Null-terminator, then ASSERT().
758 If PcdMaximumUnicodeStringLength is not zero, and concatenating Destination
759 and Source results in a Unicode string with more than PcdMaximumUnicodeStringLength
760 Unicode characters, not including the Null-terminator, then ASSERT().
762 @param Destination The pointer to a Null-terminated Unicode string.
763 @param Source The pointer to a Null-terminated Unicode string.
764 @param Length The maximum number of Unicode characters to concatenate from
773 IN OUT CHAR16
*Destination
,
774 IN CONST CHAR16
*Source
,
780 Returns the first occurrence of a Null-terminated Unicode sub-string
781 in a Null-terminated Unicode string.
783 This function scans the contents of the Null-terminated Unicode string
784 specified by String and returns the first occurrence of SearchString.
785 If SearchString is not found in String, then NULL is returned. If
786 the length of SearchString is zero, then String is returned.
788 If String is NULL, then ASSERT().
789 If String is not aligned on a 16-bit boundary, then ASSERT().
790 If SearchString is NULL, then ASSERT().
791 If SearchString is not aligned on a 16-bit boundary, then ASSERT().
793 If PcdMaximumUnicodeStringLength is not zero, and SearchString
794 or String contains more than PcdMaximumUnicodeStringLength Unicode
795 characters, not including the Null-terminator, then ASSERT().
797 @param String The pointer to a Null-terminated Unicode string.
798 @param SearchString The pointer to a Null-terminated Unicode string to search for.
800 @retval NULL If the SearchString does not appear in String.
801 @return others If there is a match.
807 IN CONST CHAR16
*String
,
808 IN CONST CHAR16
*SearchString
812 Convert a Null-terminated Unicode decimal string to a value of
815 This function returns a value of type UINTN by interpreting the contents
816 of the Unicode string specified by String as a decimal number. The format
817 of the input Unicode string String is:
819 [spaces] [decimal digits].
821 The valid decimal digit character is in the range [0-9]. The
822 function will ignore the pad space, which includes spaces or
823 tab characters, before [decimal digits]. The running zero in the
824 beginning of [decimal digits] will be ignored. Then, the function
825 stops at the first character that is a not a valid decimal character
826 or a Null-terminator, whichever one comes first.
828 If String is NULL, then ASSERT().
829 If String is not aligned in a 16-bit boundary, then ASSERT().
830 If String has only pad spaces, then 0 is returned.
831 If String has no pad spaces or valid decimal digits,
833 If the number represented by String overflows according
834 to the range defined by UINTN, then ASSERT().
836 If PcdMaximumUnicodeStringLength is not zero, and String contains
837 more than PcdMaximumUnicodeStringLength Unicode characters not including
838 the Null-terminator, then ASSERT().
840 @param String The pointer to a Null-terminated Unicode string.
842 @retval Value translated from String.
848 IN CONST CHAR16
*String
852 Convert a Null-terminated Unicode decimal string to a value of
855 This function returns a value of type UINT64 by interpreting the contents
856 of the Unicode string specified by String as a decimal number. The format
857 of the input Unicode string String is:
859 [spaces] [decimal digits].
861 The valid decimal digit character is in the range [0-9]. The
862 function will ignore the pad space, which includes spaces or
863 tab characters, before [decimal digits]. The running zero in the
864 beginning of [decimal digits] will be ignored. Then, the function
865 stops at the first character that is a not a valid decimal character
866 or a Null-terminator, whichever one comes first.
868 If String is NULL, then ASSERT().
869 If String is not aligned in a 16-bit boundary, then ASSERT().
870 If String has only pad spaces, then 0 is returned.
871 If String has no pad spaces or valid decimal digits,
873 If the number represented by String overflows according
874 to the range defined by UINT64, then ASSERT().
876 If PcdMaximumUnicodeStringLength is not zero, and String contains
877 more than PcdMaximumUnicodeStringLength Unicode characters not including
878 the Null-terminator, then ASSERT().
880 @param String The pointer to a Null-terminated Unicode string.
882 @retval Value translated from String.
888 IN CONST CHAR16
*String
893 Convert a Null-terminated Unicode hexadecimal string to a value of type UINTN.
895 This function returns a value of type UINTN by interpreting the contents
896 of the Unicode string specified by String as a hexadecimal number.
897 The format of the input Unicode string String is:
899 [spaces][zeros][x][hexadecimal digits].
901 The valid hexadecimal digit character is in the range [0-9], [a-f] and [A-F].
902 The prefix "0x" is optional. Both "x" and "X" is allowed in "0x" prefix.
903 If "x" appears in the input string, it must be prefixed with at least one 0.
904 The function will ignore the pad space, which includes spaces or tab characters,
905 before [zeros], [x] or [hexadecimal digit]. The running zero before [x] or
906 [hexadecimal digit] will be ignored. Then, the decoding starts after [x] or the
907 first valid hexadecimal digit. Then, the function stops at the first character
908 that is a not a valid hexadecimal character or NULL, whichever one comes first.
910 If String is NULL, then ASSERT().
911 If String is not aligned in a 16-bit boundary, then ASSERT().
912 If String has only pad spaces, then zero is returned.
913 If String has no leading pad spaces, leading zeros or valid hexadecimal digits,
914 then zero is returned.
915 If the number represented by String overflows according to the range defined by
916 UINTN, then ASSERT().
918 If PcdMaximumUnicodeStringLength is not zero, and String contains more than
919 PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator,
922 @param String The pointer to a Null-terminated Unicode string.
924 @retval Value translated from String.
930 IN CONST CHAR16
*String
935 Convert a Null-terminated Unicode hexadecimal string to a value of type UINT64.
937 This function returns a value of type UINT64 by interpreting the contents
938 of the Unicode string specified by String as a hexadecimal number.
939 The format of the input Unicode string String is
941 [spaces][zeros][x][hexadecimal digits].
943 The valid hexadecimal digit character is in the range [0-9], [a-f] and [A-F].
944 The prefix "0x" is optional. Both "x" and "X" is allowed in "0x" prefix.
945 If "x" appears in the input string, it must be prefixed with at least one 0.
946 The function will ignore the pad space, which includes spaces or tab characters,
947 before [zeros], [x] or [hexadecimal digit]. The running zero before [x] or
948 [hexadecimal digit] will be ignored. Then, the decoding starts after [x] or the
949 first valid hexadecimal digit. Then, the function stops at the first character that is
950 a not a valid hexadecimal character or NULL, whichever one comes first.
952 If String is NULL, then ASSERT().
953 If String is not aligned in a 16-bit boundary, then ASSERT().
954 If String has only pad spaces, then zero is returned.
955 If String has no leading pad spaces, leading zeros or valid hexadecimal digits,
956 then zero is returned.
957 If the number represented by String overflows according to the range defined by
958 UINT64, then ASSERT().
960 If PcdMaximumUnicodeStringLength is not zero, and String contains more than
961 PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator,
964 @param String The pointer to a Null-terminated Unicode string.
966 @retval Value translated from String.
972 IN CONST CHAR16
*String
976 Convert a Null-terminated Unicode string to a Null-terminated
977 ASCII string and returns the ASCII string.
979 This function converts the content of the Unicode string Source
980 to the ASCII string Destination by copying the lower 8 bits of
981 each Unicode character. It returns Destination.
983 The caller is responsible to make sure Destination points to a buffer with size
984 equal or greater than ((StrLen (Source) + 1) * sizeof (CHAR8)) in bytes.
986 If any Unicode characters in Source contain non-zero value in
987 the upper 8 bits, then ASSERT().
989 If Destination is NULL, then ASSERT().
990 If Source is NULL, then ASSERT().
991 If Source is not aligned on a 16-bit boundary, then ASSERT().
992 If Source and Destination overlap, then ASSERT().
994 If PcdMaximumUnicodeStringLength is not zero, and Source contains
995 more than PcdMaximumUnicodeStringLength Unicode characters not including
996 the Null-terminator, then ASSERT().
998 If PcdMaximumAsciiStringLength is not zero, and Source contains more
999 than PcdMaximumAsciiStringLength Unicode characters not including the
1000 Null-terminator, then ASSERT().
1002 @param Source The pointer to a Null-terminated Unicode string.
1003 @param Destination The pointer to a Null-terminated ASCII string.
1005 @return Destination.
1010 UnicodeStrToAsciiStr (
1011 IN CONST CHAR16
*Source
,
1012 OUT CHAR8
*Destination
1016 #ifndef DISABLE_NEW_DEPRECATED_INTERFACES
1019 [ATTENTION] This function will be deprecated for security reason.
1021 Copies one Null-terminated ASCII string to another Null-terminated ASCII
1022 string and returns the new ASCII string.
1024 This function copies the contents of the ASCII string Source to the ASCII
1025 string Destination, and returns Destination. If Source and Destination
1026 overlap, then the results are undefined.
1028 If Destination is NULL, then ASSERT().
1029 If Source is NULL, then ASSERT().
1030 If Source and Destination overlap, then ASSERT().
1031 If PcdMaximumAsciiStringLength is not zero and Source contains more than
1032 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
1035 @param Destination The pointer to a Null-terminated ASCII string.
1036 @param Source The pointer to a Null-terminated ASCII string.
1044 OUT CHAR8
*Destination
,
1045 IN CONST CHAR8
*Source
1050 [ATTENTION] This function will be deprecated for security reason.
1052 Copies up to a specified length one Null-terminated ASCII string to another
1053 Null-terminated ASCII string and returns the new ASCII string.
1055 This function copies the contents of the ASCII string Source to the ASCII
1056 string Destination, and returns Destination. At most, Length ASCII characters
1057 are copied from Source to Destination. If Length is 0, then Destination is
1058 returned unmodified. If Length is greater that the number of ASCII characters
1059 in Source, then Destination is padded with Null ASCII characters. If Source
1060 and Destination overlap, then the results are undefined.
1062 If Destination is NULL, then ASSERT().
1063 If Source is NULL, then ASSERT().
1064 If Source and Destination overlap, then ASSERT().
1065 If PcdMaximumAsciiStringLength is not zero, and Length is greater than
1066 PcdMaximumAsciiStringLength, then ASSERT().
1067 If PcdMaximumAsciiStringLength is not zero, and Source contains more than
1068 PcdMaximumAsciiStringLength ASCII characters, not including the Null-terminator,
1071 @param Destination The pointer to a Null-terminated ASCII string.
1072 @param Source The pointer to a Null-terminated ASCII string.
1073 @param Length The maximum number of ASCII characters to copy.
1081 OUT CHAR8
*Destination
,
1082 IN CONST CHAR8
*Source
,
1088 Returns the length of a Null-terminated ASCII string.
1090 This function returns the number of ASCII characters in the Null-terminated
1091 ASCII string specified by String.
1093 If Length > 0 and Destination is NULL, then ASSERT().
1094 If Length > 0 and Source is NULL, then ASSERT().
1095 If PcdMaximumAsciiStringLength is not zero and String contains more than
1096 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
1099 @param String The pointer to a Null-terminated ASCII string.
1101 @return The length of String.
1107 IN CONST CHAR8
*String
1112 Returns the size of a Null-terminated ASCII string in bytes, including the
1115 This function returns the size, in bytes, of the Null-terminated ASCII string
1116 specified by String.
1118 If String is NULL, then ASSERT().
1119 If PcdMaximumAsciiStringLength is not zero and String contains more than
1120 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
1123 @param String The pointer to a Null-terminated ASCII string.
1125 @return The size of String.
1131 IN CONST CHAR8
*String
1136 Compares two Null-terminated ASCII strings, and returns the difference
1137 between the first mismatched ASCII characters.
1139 This function compares the Null-terminated ASCII string FirstString to the
1140 Null-terminated ASCII string SecondString. If FirstString is identical to
1141 SecondString, then 0 is returned. Otherwise, the value returned is the first
1142 mismatched ASCII character in SecondString subtracted from the first
1143 mismatched ASCII character in FirstString.
1145 If FirstString is NULL, then ASSERT().
1146 If SecondString is NULL, then ASSERT().
1147 If PcdMaximumAsciiStringLength is not zero and FirstString contains more than
1148 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
1150 If PcdMaximumAsciiStringLength is not zero and SecondString contains more
1151 than PcdMaximumAsciiStringLength ASCII characters not including the
1152 Null-terminator, then ASSERT().
1154 @param FirstString The pointer to a Null-terminated ASCII string.
1155 @param SecondString The pointer to a Null-terminated ASCII string.
1157 @retval ==0 FirstString is identical to SecondString.
1158 @retval !=0 FirstString is not identical to SecondString.
1164 IN CONST CHAR8
*FirstString
,
1165 IN CONST CHAR8
*SecondString
1170 Performs a case insensitive comparison of two Null-terminated ASCII strings,
1171 and returns the difference between the first mismatched ASCII characters.
1173 This function performs a case insensitive comparison of the Null-terminated
1174 ASCII string FirstString to the Null-terminated ASCII string SecondString. If
1175 FirstString is identical to SecondString, then 0 is returned. Otherwise, the
1176 value returned is the first mismatched lower case ASCII character in
1177 SecondString subtracted from the first mismatched lower case ASCII character
1180 If FirstString is NULL, then ASSERT().
1181 If SecondString is NULL, then ASSERT().
1182 If PcdMaximumAsciiStringLength is not zero and FirstString contains more than
1183 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
1185 If PcdMaximumAsciiStringLength is not zero and SecondString contains more
1186 than PcdMaximumAsciiStringLength ASCII characters not including the
1187 Null-terminator, then ASSERT().
1189 @param FirstString The pointer to a Null-terminated ASCII string.
1190 @param SecondString The pointer to a Null-terminated ASCII string.
1192 @retval ==0 FirstString is identical to SecondString using case insensitive
1194 @retval !=0 FirstString is not identical to SecondString using case
1195 insensitive comparisons.
1201 IN CONST CHAR8
*FirstString
,
1202 IN CONST CHAR8
*SecondString
1207 Compares two Null-terminated ASCII strings with maximum lengths, and returns
1208 the difference between the first mismatched ASCII characters.
1210 This function compares the Null-terminated ASCII string FirstString to the
1211 Null-terminated ASCII string SecondString. At most, Length ASCII characters
1212 will be compared. If Length is 0, then 0 is returned. If FirstString is
1213 identical to SecondString, then 0 is returned. Otherwise, the value returned
1214 is the first mismatched ASCII character in SecondString subtracted from the
1215 first mismatched ASCII character in FirstString.
1217 If Length > 0 and FirstString is NULL, then ASSERT().
1218 If Length > 0 and SecondString is NULL, then ASSERT().
1219 If PcdMaximumAsciiStringLength is not zero, and Length is greater than
1220 PcdMaximumAsciiStringLength, then ASSERT().
1221 If PcdMaximumAsciiStringLength is not zero, and FirstString contains more than
1222 PcdMaximumAsciiStringLength ASCII characters, not including the Null-terminator,
1224 If PcdMaximumAsciiStringLength is not zero, and SecondString contains more than
1225 PcdMaximumAsciiStringLength ASCII characters, not including the Null-terminator,
1228 @param FirstString The pointer to a Null-terminated ASCII string.
1229 @param SecondString The pointer to a Null-terminated ASCII string.
1230 @param Length The maximum number of ASCII characters for compare.
1232 @retval ==0 FirstString is identical to SecondString.
1233 @retval !=0 FirstString is not identical to SecondString.
1239 IN CONST CHAR8
*FirstString
,
1240 IN CONST CHAR8
*SecondString
,
1245 #ifndef DISABLE_NEW_DEPRECATED_INTERFACES
1248 [ATTENTION] This function will be deprecated for security reason.
1250 Concatenates one Null-terminated ASCII string to another Null-terminated
1251 ASCII string, and returns the concatenated ASCII string.
1253 This function concatenates two Null-terminated ASCII strings. The contents of
1254 Null-terminated ASCII string Source are concatenated to the end of Null-
1255 terminated ASCII string Destination. The Null-terminated concatenated ASCII
1258 If Destination is NULL, then ASSERT().
1259 If Source is NULL, then ASSERT().
1260 If PcdMaximumAsciiStringLength is not zero and Destination contains more than
1261 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
1263 If PcdMaximumAsciiStringLength is not zero and Source contains more than
1264 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
1266 If PcdMaximumAsciiStringLength is not zero and concatenating Destination and
1267 Source results in a ASCII string with more than PcdMaximumAsciiStringLength
1268 ASCII characters, then ASSERT().
1270 @param Destination The pointer to a Null-terminated ASCII string.
1271 @param Source The pointer to a Null-terminated ASCII string.
1279 IN OUT CHAR8
*Destination
,
1280 IN CONST CHAR8
*Source
1285 [ATTENTION] This function will be deprecated for security reason.
1287 Concatenates up to a specified length one Null-terminated ASCII string to
1288 the end of another Null-terminated ASCII string, and returns the
1289 concatenated ASCII string.
1291 This function concatenates two Null-terminated ASCII strings. The contents
1292 of Null-terminated ASCII string Source are concatenated to the end of Null-
1293 terminated ASCII string Destination, and Destination is returned. At most,
1294 Length ASCII characters are concatenated from Source to the end of
1295 Destination, and Destination is always Null-terminated. If Length is 0, then
1296 Destination is returned unmodified. If Source and Destination overlap, then
1297 the results are undefined.
1299 If Length > 0 and Destination is NULL, then ASSERT().
1300 If Length > 0 and Source is NULL, then ASSERT().
1301 If Source and Destination overlap, then ASSERT().
1302 If PcdMaximumAsciiStringLength is not zero, and Length is greater than
1303 PcdMaximumAsciiStringLength, then ASSERT().
1304 If PcdMaximumAsciiStringLength is not zero, and Destination contains more than
1305 PcdMaximumAsciiStringLength ASCII characters, not including the Null-terminator,
1307 If PcdMaximumAsciiStringLength is not zero, and Source contains more than
1308 PcdMaximumAsciiStringLength ASCII characters, not including the Null-terminator,
1310 If PcdMaximumAsciiStringLength is not zero, and concatenating Destination and
1311 Source results in a ASCII string with more than PcdMaximumAsciiStringLength
1312 ASCII characters, not including the Null-terminator, then ASSERT().
1314 @param Destination The pointer to a Null-terminated ASCII string.
1315 @param Source The pointer to a Null-terminated ASCII string.
1316 @param Length The maximum number of ASCII characters to concatenate from
1325 IN OUT CHAR8
*Destination
,
1326 IN CONST CHAR8
*Source
,
1332 Returns the first occurrence of a Null-terminated ASCII sub-string
1333 in a Null-terminated ASCII string.
1335 This function scans the contents of the ASCII string specified by String
1336 and returns the first occurrence of SearchString. If SearchString is not
1337 found in String, then NULL is returned. If the length of SearchString is zero,
1338 then String is returned.
1340 If String is NULL, then ASSERT().
1341 If SearchString is NULL, then ASSERT().
1343 If PcdMaximumAsciiStringLength is not zero, and SearchString or
1344 String contains more than PcdMaximumAsciiStringLength Unicode characters
1345 not including the Null-terminator, then ASSERT().
1347 @param String The pointer to a Null-terminated ASCII string.
1348 @param SearchString The pointer to a Null-terminated ASCII string to search for.
1350 @retval NULL If the SearchString does not appear in String.
1351 @retval others If there is a match return the first occurrence of SearchingString.
1352 If the length of SearchString is zero,return String.
1358 IN CONST CHAR8
*String
,
1359 IN CONST CHAR8
*SearchString
1364 Convert a Null-terminated ASCII decimal string to a value of type
1367 This function returns a value of type UINTN by interpreting the contents
1368 of the ASCII string String as a decimal number. The format of the input
1369 ASCII string String is:
1371 [spaces] [decimal digits].
1373 The valid decimal digit character is in the range [0-9]. The function will
1374 ignore the pad space, which includes spaces or tab characters, before the digits.
1375 The running zero in the beginning of [decimal digits] will be ignored. Then, the
1376 function stops at the first character that is a not a valid decimal character or
1377 Null-terminator, whichever on comes first.
1379 If String has only pad spaces, then 0 is returned.
1380 If String has no pad spaces or valid decimal digits, then 0 is returned.
1381 If the number represented by String overflows according to the range defined by
1382 UINTN, then ASSERT().
1383 If String is NULL, then ASSERT().
1384 If PcdMaximumAsciiStringLength is not zero, and String contains more than
1385 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
1388 @param String The pointer to a Null-terminated ASCII string.
1390 @retval The value translated from String.
1395 AsciiStrDecimalToUintn (
1396 IN CONST CHAR8
*String
1401 Convert a Null-terminated ASCII decimal string to a value of type
1404 This function returns a value of type UINT64 by interpreting the contents
1405 of the ASCII string String as a decimal number. The format of the input
1406 ASCII string String is:
1408 [spaces] [decimal digits].
1410 The valid decimal digit character is in the range [0-9]. The function will
1411 ignore the pad space, which includes spaces or tab characters, before the digits.
1412 The running zero in the beginning of [decimal digits] will be ignored. Then, the
1413 function stops at the first character that is a not a valid decimal character or
1414 Null-terminator, whichever on comes first.
1416 If String has only pad spaces, then 0 is returned.
1417 If String has no pad spaces or valid decimal digits, then 0 is returned.
1418 If the number represented by String overflows according to the range defined by
1419 UINT64, then ASSERT().
1420 If String is NULL, then ASSERT().
1421 If PcdMaximumAsciiStringLength is not zero, and String contains more than
1422 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
1425 @param String The pointer to a Null-terminated ASCII string.
1427 @retval Value translated from String.
1432 AsciiStrDecimalToUint64 (
1433 IN CONST CHAR8
*String
1438 Convert a Null-terminated ASCII hexadecimal string to a value of type UINTN.
1440 This function returns a value of type UINTN by interpreting the contents of
1441 the ASCII string String as a hexadecimal number. The format of the input ASCII
1444 [spaces][zeros][x][hexadecimal digits].
1446 The valid hexadecimal digit character is in the range [0-9], [a-f] and [A-F].
1447 The prefix "0x" is optional. Both "x" and "X" is allowed in "0x" prefix. If "x"
1448 appears in the input string, it must be prefixed with at least one 0. The function
1449 will ignore the pad space, which includes spaces or tab characters, before [zeros],
1450 [x] or [hexadecimal digits]. The running zero before [x] or [hexadecimal digits]
1451 will be ignored. Then, the decoding starts after [x] or the first valid hexadecimal
1452 digit. Then, the function stops at the first character that is a not a valid
1453 hexadecimal character or Null-terminator, whichever on comes first.
1455 If String has only pad spaces, then 0 is returned.
1456 If String has no leading pad spaces, leading zeros or valid hexadecimal digits, then
1459 If the number represented by String overflows according to the range defined by UINTN,
1461 If String is NULL, then ASSERT().
1462 If PcdMaximumAsciiStringLength is not zero,
1463 and String contains more than PcdMaximumAsciiStringLength ASCII characters not including
1464 the Null-terminator, then ASSERT().
1466 @param String The pointer to a Null-terminated ASCII string.
1468 @retval Value translated from String.
1473 AsciiStrHexToUintn (
1474 IN CONST CHAR8
*String
1479 Convert a Null-terminated ASCII hexadecimal string to a value of type UINT64.
1481 This function returns a value of type UINT64 by interpreting the contents of
1482 the ASCII string String as a hexadecimal number. The format of the input ASCII
1485 [spaces][zeros][x][hexadecimal digits].
1487 The valid hexadecimal digit character is in the range [0-9], [a-f] and [A-F].
1488 The prefix "0x" is optional. Both "x" and "X" is allowed in "0x" prefix. If "x"
1489 appears in the input string, it must be prefixed with at least one 0. The function
1490 will ignore the pad space, which includes spaces or tab characters, before [zeros],
1491 [x] or [hexadecimal digits]. The running zero before [x] or [hexadecimal digits]
1492 will be ignored. Then, the decoding starts after [x] or the first valid hexadecimal
1493 digit. Then, the function stops at the first character that is a not a valid
1494 hexadecimal character or Null-terminator, whichever on comes first.
1496 If String has only pad spaces, then 0 is returned.
1497 If String has no leading pad spaces, leading zeros or valid hexadecimal digits, then
1500 If the number represented by String overflows according to the range defined by UINT64,
1502 If String is NULL, then ASSERT().
1503 If PcdMaximumAsciiStringLength is not zero,
1504 and String contains more than PcdMaximumAsciiStringLength ASCII characters not including
1505 the Null-terminator, then ASSERT().
1507 @param String The pointer to a Null-terminated ASCII string.
1509 @retval Value translated from String.
1514 AsciiStrHexToUint64 (
1515 IN CONST CHAR8
*String
1520 Convert one Null-terminated ASCII string to a Null-terminated
1521 Unicode string and returns the Unicode string.
1523 This function converts the contents of the ASCII string Source to the Unicode
1524 string Destination, and returns Destination. The function terminates the
1525 Unicode string Destination by appending a Null-terminator character at the end.
1526 The caller is responsible to make sure Destination points to a buffer with size
1527 equal or greater than ((AsciiStrLen (Source) + 1) * sizeof (CHAR16)) in bytes.
1529 If Destination is NULL, then ASSERT().
1530 If Destination is not aligned on a 16-bit boundary, then ASSERT().
1531 If Source is NULL, then ASSERT().
1532 If Source and Destination overlap, then ASSERT().
1533 If PcdMaximumAsciiStringLength is not zero, and Source contains more than
1534 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
1536 If PcdMaximumUnicodeStringLength is not zero, and Source contains more than
1537 PcdMaximumUnicodeStringLength ASCII characters not including the
1538 Null-terminator, then ASSERT().
1540 @param Source The pointer to a Null-terminated ASCII string.
1541 @param Destination The pointer to a Null-terminated Unicode string.
1543 @return Destination.
1548 AsciiStrToUnicodeStr (
1549 IN CONST CHAR8
*Source
,
1550 OUT CHAR16
*Destination
1555 Converts an 8-bit value to an 8-bit BCD value.
1557 Converts the 8-bit value specified by Value to BCD. The BCD value is
1560 If Value >= 100, then ASSERT().
1562 @param Value The 8-bit value to convert to BCD. Range 0..99.
1564 @return The BCD value.
1575 Converts an 8-bit BCD value to an 8-bit value.
1577 Converts the 8-bit BCD value specified by Value to an 8-bit value. The 8-bit
1580 If Value >= 0xA0, then ASSERT().
1581 If (Value & 0x0F) >= 0x0A, then ASSERT().
1583 @param Value The 8-bit BCD value to convert to an 8-bit value.
1585 @return The 8-bit value is returned.
1596 // Linked List Functions and Macros
1600 Initializes the head node of a doubly linked list that is declared as a
1601 global variable in a module.
1603 Initializes the forward and backward links of a new linked list. After
1604 initializing a linked list with this macro, the other linked list functions
1605 may be used to add and remove nodes from the linked list. This macro results
1606 in smaller executables by initializing the linked list in the data section,
1607 instead if calling the InitializeListHead() function to perform the
1608 equivalent operation.
1610 @param ListHead The head note of a list to initialize.
1613 #define INITIALIZE_LIST_HEAD_VARIABLE(ListHead) {&(ListHead), &(ListHead)}
1617 Initializes the head node of a doubly linked list, and returns the pointer to
1618 the head node of the doubly linked list.
1620 Initializes the forward and backward links of a new linked list. After
1621 initializing a linked list with this function, the other linked list
1622 functions may be used to add and remove nodes from the linked list. It is up
1623 to the caller of this function to allocate the memory for ListHead.
1625 If ListHead is NULL, then ASSERT().
1627 @param ListHead A pointer to the head node of a new doubly linked list.
1634 InitializeListHead (
1635 IN OUT LIST_ENTRY
*ListHead
1640 Adds a node to the beginning of a doubly linked list, and returns the pointer
1641 to the head node of the doubly linked list.
1643 Adds the node Entry at the beginning of the doubly linked list denoted by
1644 ListHead, and returns ListHead.
1646 If ListHead is NULL, then ASSERT().
1647 If Entry is NULL, then ASSERT().
1648 If ListHead was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or
1649 InitializeListHead(), then ASSERT().
1650 If PcdMaximumLinkedListLength is not zero, and prior to insertion the number
1651 of nodes in ListHead, including the ListHead node, is greater than or
1652 equal to PcdMaximumLinkedListLength, then ASSERT().
1654 @param ListHead A pointer to the head node of a doubly linked list.
1655 @param Entry A pointer to a node that is to be inserted at the beginning
1656 of a doubly linked list.
1664 IN OUT LIST_ENTRY
*ListHead
,
1665 IN OUT LIST_ENTRY
*Entry
1670 Adds a node to the end of a doubly linked list, and returns the pointer to
1671 the head node of the doubly linked list.
1673 Adds the node Entry to the end of the doubly linked list denoted by ListHead,
1674 and returns ListHead.
1676 If ListHead is NULL, then ASSERT().
1677 If Entry is NULL, then ASSERT().
1678 If ListHead was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or
1679 InitializeListHead(), then ASSERT().
1680 If PcdMaximumLinkedListLength is not zero, and prior to insertion the number
1681 of nodes in ListHead, including the ListHead node, is greater than or
1682 equal to PcdMaximumLinkedListLength, then ASSERT().
1684 @param ListHead A pointer to the head node of a doubly linked list.
1685 @param Entry A pointer to a node that is to be added at the end of the
1694 IN OUT LIST_ENTRY
*ListHead
,
1695 IN OUT LIST_ENTRY
*Entry
1700 Retrieves the first node of a doubly linked list.
1702 Returns the first node of a doubly linked list. List must have been
1703 initialized with INTIALIZE_LIST_HEAD_VARIABLE() or InitializeListHead().
1704 If List is empty, then List is returned.
1706 If List is NULL, then ASSERT().
1707 If List was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or
1708 InitializeListHead(), then ASSERT().
1709 If PcdMaximumLinkedListLength is not zero, and the number of nodes
1710 in List, including the List node, is greater than or equal to
1711 PcdMaximumLinkedListLength, then ASSERT().
1713 @param List A pointer to the head node of a doubly linked list.
1715 @return The first node of a doubly linked list.
1716 @retval List The list is empty.
1722 IN CONST LIST_ENTRY
*List
1727 Retrieves the next node of a doubly linked list.
1729 Returns the node of a doubly linked list that follows Node.
1730 List must have been initialized with INTIALIZE_LIST_HEAD_VARIABLE()
1731 or InitializeListHead(). If List is empty, then List is returned.
1733 If List is NULL, then ASSERT().
1734 If Node is NULL, then ASSERT().
1735 If List was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or
1736 InitializeListHead(), then ASSERT().
1737 If PcdMaximumLinkedListLength is not zero, and List contains more than
1738 PcdMaximumLinkedListLength nodes, then ASSERT().
1739 If PcdVerifyNodeInList is TRUE and Node is not a node in List, then ASSERT().
1741 @param List A pointer to the head node of a doubly linked list.
1742 @param Node A pointer to a node in the doubly linked list.
1744 @return The pointer to the next node if one exists. Otherwise List is returned.
1750 IN CONST LIST_ENTRY
*List
,
1751 IN CONST LIST_ENTRY
*Node
1756 Retrieves the previous node of a doubly linked list.
1758 Returns the node of a doubly linked list that precedes Node.
1759 List must have been initialized with INTIALIZE_LIST_HEAD_VARIABLE()
1760 or InitializeListHead(). If List is empty, then List is returned.
1762 If List is NULL, then ASSERT().
1763 If Node is NULL, then ASSERT().
1764 If List was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or
1765 InitializeListHead(), then ASSERT().
1766 If PcdMaximumLinkedListLength is not zero, and List contains more than
1767 PcdMaximumLinkedListLength nodes, then ASSERT().
1768 If PcdVerifyNodeInList is TRUE and Node is not a node in List, then ASSERT().
1770 @param List A pointer to the head node of a doubly linked list.
1771 @param Node A pointer to a node in the doubly linked list.
1773 @return The pointer to the previous node if one exists. Otherwise List is returned.
1779 IN CONST LIST_ENTRY
*List
,
1780 IN CONST LIST_ENTRY
*Node
1785 Checks to see if a doubly linked list is empty or not.
1787 Checks to see if the doubly linked list is empty. If the linked list contains
1788 zero nodes, this function returns TRUE. Otherwise, it returns FALSE.
1790 If ListHead is NULL, then ASSERT().
1791 If ListHead was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or
1792 InitializeListHead(), then ASSERT().
1793 If PcdMaximumLinkedListLength is not zero, and the number of nodes
1794 in List, including the List node, is greater than or equal to
1795 PcdMaximumLinkedListLength, then ASSERT().
1797 @param ListHead A pointer to the head node of a doubly linked list.
1799 @retval TRUE The linked list is empty.
1800 @retval FALSE The linked list is not empty.
1806 IN CONST LIST_ENTRY
*ListHead
1811 Determines if a node in a doubly linked list is the head node of a the same
1812 doubly linked list. This function is typically used to terminate a loop that
1813 traverses all the nodes in a doubly linked list starting with the head node.
1815 Returns TRUE if Node is equal to List. Returns FALSE if Node is one of the
1816 nodes in the doubly linked list specified by List. List must have been
1817 initialized with INTIALIZE_LIST_HEAD_VARIABLE() or InitializeListHead().
1819 If List is NULL, then ASSERT().
1820 If Node is NULL, then ASSERT().
1821 If List was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or InitializeListHead(),
1823 If PcdMaximumLinkedListLength is not zero, and the number of nodes
1824 in List, including the List node, is greater than or equal to
1825 PcdMaximumLinkedListLength, then ASSERT().
1826 If PcdVerifyNodeInList is TRUE and Node is not a node in List the and Node is not equal
1827 to List, then ASSERT().
1829 @param List A pointer to the head node of a doubly linked list.
1830 @param Node A pointer to a node in the doubly linked list.
1832 @retval TRUE Node is the head of the doubly-linked list pointed by List.
1833 @retval FALSE Node is not the head of the doubly-linked list pointed by List.
1839 IN CONST LIST_ENTRY
*List
,
1840 IN CONST LIST_ENTRY
*Node
1845 Determines if a node the last node in a doubly linked list.
1847 Returns TRUE if Node is the last node in the doubly linked list specified by
1848 List. Otherwise, FALSE is returned. List must have been initialized with
1849 INTIALIZE_LIST_HEAD_VARIABLE() or InitializeListHead().
1851 If List is NULL, then ASSERT().
1852 If Node is NULL, then ASSERT().
1853 If List was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or
1854 InitializeListHead(), then ASSERT().
1855 If PcdMaximumLinkedListLength is not zero, and the number of nodes
1856 in List, including the List node, is greater than or equal to
1857 PcdMaximumLinkedListLength, then ASSERT().
1858 If PcdVerifyNodeInList is TRUE and Node is not a node in List, then ASSERT().
1860 @param List A pointer to the head node of a doubly linked list.
1861 @param Node A pointer to a node in the doubly linked list.
1863 @retval TRUE Node is the last node in the linked list.
1864 @retval FALSE Node is not the last node in the linked list.
1870 IN CONST LIST_ENTRY
*List
,
1871 IN CONST LIST_ENTRY
*Node
1876 Swaps the location of two nodes in a doubly linked list, and returns the
1877 first node after the swap.
1879 If FirstEntry is identical to SecondEntry, then SecondEntry is returned.
1880 Otherwise, the location of the FirstEntry node is swapped with the location
1881 of the SecondEntry node in a doubly linked list. SecondEntry must be in the
1882 same double linked list as FirstEntry and that double linked list must have
1883 been initialized with INTIALIZE_LIST_HEAD_VARIABLE() or InitializeListHead().
1884 SecondEntry is returned after the nodes are swapped.
1886 If FirstEntry is NULL, then ASSERT().
1887 If SecondEntry is NULL, then ASSERT().
1888 If PcdVerifyNodeInList is TRUE and SecondEntry and FirstEntry are not in the
1889 same linked list, then ASSERT().
1890 If PcdMaximumLinkedListLength is not zero, and the number of nodes in the
1891 linked list containing the FirstEntry and SecondEntry nodes, including
1892 the FirstEntry and SecondEntry nodes, is greater than or equal to
1893 PcdMaximumLinkedListLength, then ASSERT().
1895 @param FirstEntry A pointer to a node in a linked list.
1896 @param SecondEntry A pointer to another node in the same linked list.
1898 @return SecondEntry.
1904 IN OUT LIST_ENTRY
*FirstEntry
,
1905 IN OUT LIST_ENTRY
*SecondEntry
1910 Removes a node from a doubly linked list, and returns the node that follows
1913 Removes the node Entry from a doubly linked list. It is up to the caller of
1914 this function to release the memory used by this node if that is required. On
1915 exit, the node following Entry in the doubly linked list is returned. If
1916 Entry is the only node in the linked list, then the head node of the linked
1919 If Entry is NULL, then ASSERT().
1920 If Entry is the head node of an empty list, then ASSERT().
1921 If PcdMaximumLinkedListLength is not zero, and the number of nodes in the
1922 linked list containing Entry, including the Entry node, is greater than
1923 or equal to PcdMaximumLinkedListLength, then ASSERT().
1925 @param Entry A pointer to a node in a linked list.
1933 IN CONST LIST_ENTRY
*Entry
1941 Shifts a 64-bit integer left between 0 and 63 bits. The low bits are filled
1942 with zeros. The shifted value is returned.
1944 This function shifts the 64-bit value Operand to the left by Count bits. The
1945 low Count bits are set to zero. The shifted value is returned.
1947 If Count is greater than 63, then ASSERT().
1949 @param Operand The 64-bit operand to shift left.
1950 @param Count The number of bits to shift left.
1952 @return Operand << Count.
1964 Shifts a 64-bit integer right between 0 and 63 bits. This high bits are
1965 filled with zeros. The shifted value is returned.
1967 This function shifts the 64-bit value Operand to the right by Count bits. The
1968 high Count bits are set to zero. The shifted value is returned.
1970 If Count is greater than 63, then ASSERT().
1972 @param Operand The 64-bit operand to shift right.
1973 @param Count The number of bits to shift right.
1975 @return Operand >> Count
1987 Shifts a 64-bit integer right between 0 and 63 bits. The high bits are filled
1988 with original integer's bit 63. The shifted value is returned.
1990 This function shifts the 64-bit value Operand to the right by Count bits. The
1991 high Count bits are set to bit 63 of Operand. The shifted value is returned.
1993 If Count is greater than 63, then ASSERT().
1995 @param Operand The 64-bit operand to shift right.
1996 @param Count The number of bits to shift right.
1998 @return Operand >> Count
2010 Rotates a 32-bit integer left between 0 and 31 bits, filling the low bits
2011 with the high bits that were rotated.
2013 This function rotates the 32-bit value Operand to the left by Count bits. The
2014 low Count bits are fill with the high Count bits of Operand. The rotated
2017 If Count is greater than 31, then ASSERT().
2019 @param Operand The 32-bit operand to rotate left.
2020 @param Count The number of bits to rotate left.
2022 @return Operand << Count
2034 Rotates a 32-bit integer right between 0 and 31 bits, filling the high bits
2035 with the low bits that were rotated.
2037 This function rotates the 32-bit value Operand to the right by Count bits.
2038 The high Count bits are fill with the low Count bits of Operand. The rotated
2041 If Count is greater than 31, then ASSERT().
2043 @param Operand The 32-bit operand to rotate right.
2044 @param Count The number of bits to rotate right.
2046 @return Operand >> Count
2058 Rotates a 64-bit integer left between 0 and 63 bits, filling the low bits
2059 with the high bits that were rotated.
2061 This function rotates the 64-bit value Operand to the left by Count bits. The
2062 low Count bits are fill with the high Count bits of Operand. The rotated
2065 If Count is greater than 63, then ASSERT().
2067 @param Operand The 64-bit operand to rotate left.
2068 @param Count The number of bits to rotate left.
2070 @return Operand << Count
2082 Rotates a 64-bit integer right between 0 and 63 bits, filling the high bits
2083 with the high low bits that were rotated.
2085 This function rotates the 64-bit value Operand to the right by Count bits.
2086 The high Count bits are fill with the low Count bits of Operand. The rotated
2089 If Count is greater than 63, then ASSERT().
2091 @param Operand The 64-bit operand to rotate right.
2092 @param Count The number of bits to rotate right.
2094 @return Operand >> Count
2106 Returns the bit position of the lowest bit set in a 32-bit value.
2108 This function computes the bit position of the lowest bit set in the 32-bit
2109 value specified by Operand. If Operand is zero, then -1 is returned.
2110 Otherwise, a value between 0 and 31 is returned.
2112 @param Operand The 32-bit operand to evaluate.
2114 @retval 0..31 The lowest bit set in Operand was found.
2115 @retval -1 Operand is zero.
2126 Returns the bit position of the lowest bit set in a 64-bit value.
2128 This function computes the bit position of the lowest bit set in the 64-bit
2129 value specified by Operand. If Operand is zero, then -1 is returned.
2130 Otherwise, a value between 0 and 63 is returned.
2132 @param Operand The 64-bit operand to evaluate.
2134 @retval 0..63 The lowest bit set in Operand was found.
2135 @retval -1 Operand is zero.
2147 Returns the bit position of the highest bit set in a 32-bit value. Equivalent
2150 This function computes the bit position of the highest bit set in the 32-bit
2151 value specified by Operand. If Operand is zero, then -1 is returned.
2152 Otherwise, a value between 0 and 31 is returned.
2154 @param Operand The 32-bit operand to evaluate.
2156 @retval 0..31 Position of the highest bit set in Operand if found.
2157 @retval -1 Operand is zero.
2168 Returns the bit position of the highest bit set in a 64-bit value. Equivalent
2171 This function computes the bit position of the highest bit set in the 64-bit
2172 value specified by Operand. If Operand is zero, then -1 is returned.
2173 Otherwise, a value between 0 and 63 is returned.
2175 @param Operand The 64-bit operand to evaluate.
2177 @retval 0..63 Position of the highest bit set in Operand if found.
2178 @retval -1 Operand is zero.
2189 Returns the value of the highest bit set in a 32-bit value. Equivalent to
2192 This function computes the value of the highest bit set in the 32-bit value
2193 specified by Operand. If Operand is zero, then zero is returned.
2195 @param Operand The 32-bit operand to evaluate.
2197 @return 1 << HighBitSet32(Operand)
2198 @retval 0 Operand is zero.
2209 Returns the value of the highest bit set in a 64-bit value. Equivalent to
2212 This function computes the value of the highest bit set in the 64-bit value
2213 specified by Operand. If Operand is zero, then zero is returned.
2215 @param Operand The 64-bit operand to evaluate.
2217 @return 1 << HighBitSet64(Operand)
2218 @retval 0 Operand is zero.
2229 Switches the endianness of a 16-bit integer.
2231 This function swaps the bytes in a 16-bit unsigned value to switch the value
2232 from little endian to big endian or vice versa. The byte swapped value is
2235 @param Value A 16-bit unsigned value.
2237 @return The byte swapped Value.
2248 Switches the endianness of a 32-bit integer.
2250 This function swaps the bytes in a 32-bit unsigned value to switch the value
2251 from little endian to big endian or vice versa. The byte swapped value is
2254 @param Value A 32-bit unsigned value.
2256 @return The byte swapped Value.
2267 Switches the endianness of a 64-bit integer.
2269 This function swaps the bytes in a 64-bit unsigned value to switch the value
2270 from little endian to big endian or vice versa. The byte swapped value is
2273 @param Value A 64-bit unsigned value.
2275 @return The byte swapped Value.
2286 Multiples a 64-bit unsigned integer by a 32-bit unsigned integer and
2287 generates a 64-bit unsigned result.
2289 This function multiples the 64-bit unsigned value Multiplicand by the 32-bit
2290 unsigned value Multiplier and generates a 64-bit unsigned result. This 64-
2291 bit unsigned result is returned.
2293 @param Multiplicand A 64-bit unsigned value.
2294 @param Multiplier A 32-bit unsigned value.
2296 @return Multiplicand * Multiplier
2302 IN UINT64 Multiplicand
,
2303 IN UINT32 Multiplier
2308 Multiples a 64-bit unsigned integer by a 64-bit unsigned integer and
2309 generates a 64-bit unsigned result.
2311 This function multiples the 64-bit unsigned value Multiplicand by the 64-bit
2312 unsigned value Multiplier and generates a 64-bit unsigned result. This 64-
2313 bit unsigned result is returned.
2315 @param Multiplicand A 64-bit unsigned value.
2316 @param Multiplier A 64-bit unsigned value.
2318 @return Multiplicand * Multiplier.
2324 IN UINT64 Multiplicand
,
2325 IN UINT64 Multiplier
2330 Multiples a 64-bit signed integer by a 64-bit signed integer and generates a
2331 64-bit signed result.
2333 This function multiples the 64-bit signed value Multiplicand by the 64-bit
2334 signed value Multiplier and generates a 64-bit signed result. This 64-bit
2335 signed result is returned.
2337 @param Multiplicand A 64-bit signed value.
2338 @param Multiplier A 64-bit signed value.
2340 @return Multiplicand * Multiplier
2346 IN INT64 Multiplicand
,
2352 Divides a 64-bit unsigned integer by a 32-bit unsigned integer and generates
2353 a 64-bit unsigned result.
2355 This function divides the 64-bit unsigned value Dividend by the 32-bit
2356 unsigned value Divisor and generates a 64-bit unsigned quotient. This
2357 function returns the 64-bit unsigned quotient.
2359 If Divisor is 0, then ASSERT().
2361 @param Dividend A 64-bit unsigned value.
2362 @param Divisor A 32-bit unsigned value.
2364 @return Dividend / Divisor.
2376 Divides a 64-bit unsigned integer by a 32-bit unsigned integer and generates
2377 a 32-bit unsigned remainder.
2379 This function divides the 64-bit unsigned value Dividend by the 32-bit
2380 unsigned value Divisor and generates a 32-bit remainder. This function
2381 returns the 32-bit unsigned remainder.
2383 If Divisor is 0, then ASSERT().
2385 @param Dividend A 64-bit unsigned value.
2386 @param Divisor A 32-bit unsigned value.
2388 @return Dividend % Divisor.
2400 Divides a 64-bit unsigned integer by a 32-bit unsigned integer and generates
2401 a 64-bit unsigned result and an optional 32-bit unsigned remainder.
2403 This function divides the 64-bit unsigned value Dividend by the 32-bit
2404 unsigned value Divisor and generates a 64-bit unsigned quotient. If Remainder
2405 is not NULL, then the 32-bit unsigned remainder is returned in Remainder.
2406 This 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.
2412 @param Remainder A pointer to a 32-bit unsigned value. This parameter is
2413 optional and may be NULL.
2415 @return Dividend / Divisor.
2420 DivU64x32Remainder (
2423 OUT UINT32
*Remainder OPTIONAL
2428 Divides a 64-bit unsigned integer by a 64-bit unsigned integer and generates
2429 a 64-bit unsigned result and an optional 64-bit unsigned remainder.
2431 This function divides the 64-bit unsigned value Dividend by the 64-bit
2432 unsigned value Divisor and generates a 64-bit unsigned quotient. If Remainder
2433 is not NULL, then the 64-bit unsigned remainder is returned in Remainder.
2434 This function returns the 64-bit unsigned quotient.
2436 If Divisor is 0, then ASSERT().
2438 @param Dividend A 64-bit unsigned value.
2439 @param Divisor A 64-bit unsigned value.
2440 @param Remainder A pointer to a 64-bit unsigned value. This parameter is
2441 optional and may be NULL.
2443 @return Dividend / Divisor.
2448 DivU64x64Remainder (
2451 OUT UINT64
*Remainder OPTIONAL
2456 Divides a 64-bit signed integer by a 64-bit signed integer and generates a
2457 64-bit signed result and a optional 64-bit signed remainder.
2459 This function divides the 64-bit signed value Dividend by the 64-bit signed
2460 value Divisor and generates a 64-bit signed quotient. If Remainder is not
2461 NULL, then the 64-bit signed remainder is returned in Remainder. This
2462 function returns the 64-bit signed quotient.
2464 It is the caller's responsibility to not call this function with a Divisor of 0.
2465 If Divisor is 0, then the quotient and remainder should be assumed to be
2466 the largest negative integer.
2468 If Divisor is 0, then ASSERT().
2470 @param Dividend A 64-bit signed value.
2471 @param Divisor A 64-bit signed value.
2472 @param Remainder A pointer to a 64-bit signed value. This parameter is
2473 optional and may be NULL.
2475 @return Dividend / Divisor.
2480 DivS64x64Remainder (
2483 OUT INT64
*Remainder OPTIONAL
2488 Reads a 16-bit value from memory that may be unaligned.
2490 This function returns the 16-bit value pointed to by Buffer. The function
2491 guarantees that the read operation does not produce an alignment fault.
2493 If the Buffer is NULL, then ASSERT().
2495 @param Buffer The pointer to a 16-bit value that may be unaligned.
2497 @return The 16-bit value read from Buffer.
2503 IN CONST UINT16
*Buffer
2508 Writes a 16-bit value to memory that may be unaligned.
2510 This function writes the 16-bit value specified by Value to Buffer. Value is
2511 returned. The function guarantees that the write operation does not produce
2514 If the Buffer is NULL, then ASSERT().
2516 @param Buffer The pointer to a 16-bit value that may be unaligned.
2517 @param Value 16-bit value to write to Buffer.
2519 @return The 16-bit value to write to Buffer.
2531 Reads a 24-bit value from memory that may be unaligned.
2533 This function returns the 24-bit value pointed to by Buffer. The function
2534 guarantees that the read operation does not produce an alignment fault.
2536 If the Buffer is NULL, then ASSERT().
2538 @param Buffer The pointer to a 24-bit value that may be unaligned.
2540 @return The 24-bit value read from Buffer.
2546 IN CONST UINT32
*Buffer
2551 Writes a 24-bit value to memory that may be unaligned.
2553 This function writes the 24-bit value specified by Value to Buffer. Value is
2554 returned. The function guarantees that the write operation does not produce
2557 If the Buffer is NULL, then ASSERT().
2559 @param Buffer The pointer to a 24-bit value that may be unaligned.
2560 @param Value 24-bit value to write to Buffer.
2562 @return The 24-bit value to write to Buffer.
2574 Reads a 32-bit value from memory that may be unaligned.
2576 This function returns the 32-bit value pointed to by Buffer. The function
2577 guarantees that the read operation does not produce an alignment fault.
2579 If the Buffer is NULL, then ASSERT().
2581 @param Buffer The pointer to a 32-bit value that may be unaligned.
2583 @return The 32-bit value read from Buffer.
2589 IN CONST UINT32
*Buffer
2594 Writes a 32-bit value to memory that may be unaligned.
2596 This function writes the 32-bit value specified by Value to Buffer. Value is
2597 returned. The function guarantees that the write operation does not produce
2600 If the Buffer is NULL, then ASSERT().
2602 @param Buffer The pointer to a 32-bit value that may be unaligned.
2603 @param Value 32-bit value to write to Buffer.
2605 @return The 32-bit value to write to Buffer.
2617 Reads a 64-bit value from memory that may be unaligned.
2619 This function returns the 64-bit value pointed to by Buffer. The function
2620 guarantees that the read operation does not produce an alignment fault.
2622 If the Buffer is NULL, then ASSERT().
2624 @param Buffer The pointer to a 64-bit value that may be unaligned.
2626 @return The 64-bit value read from Buffer.
2632 IN CONST UINT64
*Buffer
2637 Writes a 64-bit value to memory that may be unaligned.
2639 This function writes the 64-bit value specified by Value to Buffer. Value is
2640 returned. The function guarantees that the write operation does not produce
2643 If the Buffer is NULL, then ASSERT().
2645 @param Buffer The pointer to a 64-bit value that may be unaligned.
2646 @param Value 64-bit value to write to Buffer.
2648 @return The 64-bit value to write to Buffer.
2660 // Bit Field Functions
2664 Returns a bit field from an 8-bit value.
2666 Returns the bitfield specified by the StartBit and the EndBit from Operand.
2668 If 8-bit operations are not supported, then ASSERT().
2669 If StartBit is greater than 7, then ASSERT().
2670 If EndBit is greater than 7, then ASSERT().
2671 If EndBit is less than StartBit, then ASSERT().
2673 @param Operand Operand on which to perform the bitfield operation.
2674 @param StartBit The ordinal of the least significant bit in the bit field.
2676 @param EndBit The ordinal of the most significant bit in the bit field.
2679 @return The bit field read.
2692 Writes a bit field to an 8-bit value, and returns the result.
2694 Writes Value to the bit field specified by the StartBit and the EndBit in
2695 Operand. All other bits in Operand are preserved. The new 8-bit value is
2698 If 8-bit operations are not supported, then ASSERT().
2699 If StartBit is greater than 7, then ASSERT().
2700 If EndBit is greater than 7, then ASSERT().
2701 If EndBit is less than StartBit, then ASSERT().
2702 If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
2704 @param Operand Operand on which to perform the bitfield operation.
2705 @param StartBit The ordinal of the least significant bit in the bit field.
2707 @param EndBit The ordinal of the most significant bit in the bit field.
2709 @param Value New value of the bit field.
2711 @return The new 8-bit value.
2725 Reads a bit field from an 8-bit value, performs a bitwise OR, and returns the
2728 Performs a bitwise OR between the bit field specified by StartBit
2729 and EndBit in Operand and the value specified by OrData. All other bits in
2730 Operand are preserved. The new 8-bit value is returned.
2732 If 8-bit operations are not supported, then ASSERT().
2733 If StartBit is greater than 7, then ASSERT().
2734 If EndBit is greater than 7, then ASSERT().
2735 If EndBit is less than StartBit, then ASSERT().
2736 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
2738 @param Operand Operand on which to perform the bitfield operation.
2739 @param StartBit The ordinal of the least significant bit in the bit field.
2741 @param EndBit The ordinal of the most significant bit in the bit field.
2743 @param OrData The value to OR with the read value from the value
2745 @return The new 8-bit value.
2759 Reads a bit field from an 8-bit value, performs a bitwise AND, and returns
2762 Performs a bitwise AND between the bit field specified by StartBit and EndBit
2763 in Operand and the value specified by AndData. All other bits in Operand are
2764 preserved. The new 8-bit value is returned.
2766 If 8-bit operations are not supported, then ASSERT().
2767 If StartBit is greater than 7, then ASSERT().
2768 If EndBit is greater than 7, then ASSERT().
2769 If EndBit is less than StartBit, then ASSERT().
2770 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
2772 @param Operand Operand on which to perform the bitfield operation.
2773 @param StartBit The ordinal of the least significant bit in the bit field.
2775 @param EndBit The ordinal of the most significant bit in the bit field.
2777 @param AndData The value to AND with the read value from the value.
2779 @return The new 8-bit value.
2793 Reads a bit field from an 8-bit value, performs a bitwise AND followed by a
2794 bitwise OR, and returns the result.
2796 Performs a bitwise AND between the bit field specified by StartBit and EndBit
2797 in Operand and the value specified by AndData, followed by a bitwise
2798 OR with value specified by OrData. All other bits in Operand are
2799 preserved. The new 8-bit value is returned.
2801 If 8-bit operations are not supported, then ASSERT().
2802 If StartBit is greater than 7, then ASSERT().
2803 If EndBit is greater than 7, then ASSERT().
2804 If EndBit is less than StartBit, then ASSERT().
2805 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
2806 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
2808 @param Operand Operand on which to perform the bitfield operation.
2809 @param StartBit The ordinal of the least significant bit in the bit field.
2811 @param EndBit The ordinal of the most significant bit in the bit field.
2813 @param AndData The value to AND with the read value from the value.
2814 @param OrData The value to OR with the result of the AND operation.
2816 @return The new 8-bit value.
2821 BitFieldAndThenOr8 (
2831 Returns a bit field from a 16-bit value.
2833 Returns the bitfield specified by the StartBit and the EndBit from Operand.
2835 If 16-bit operations are not supported, then ASSERT().
2836 If StartBit is greater than 15, then ASSERT().
2837 If EndBit is greater than 15, then ASSERT().
2838 If EndBit is less than StartBit, then ASSERT().
2840 @param Operand Operand on which to perform the bitfield operation.
2841 @param StartBit The ordinal of the least significant bit in the bit field.
2843 @param EndBit The ordinal of the most significant bit in the bit field.
2846 @return The bit field read.
2859 Writes a bit field to a 16-bit value, and returns the result.
2861 Writes Value to the bit field specified by the StartBit and the EndBit in
2862 Operand. All other bits in Operand are preserved. The new 16-bit value is
2865 If 16-bit operations are not supported, then ASSERT().
2866 If StartBit is greater than 15, then ASSERT().
2867 If EndBit is greater than 15, then ASSERT().
2868 If EndBit is less than StartBit, then ASSERT().
2869 If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
2871 @param Operand Operand on which to perform the bitfield operation.
2872 @param StartBit The ordinal of the least significant bit in the bit field.
2874 @param EndBit The ordinal of the most significant bit in the bit field.
2876 @param Value New value of the bit field.
2878 @return The new 16-bit value.
2892 Reads a bit field from a 16-bit value, performs a bitwise OR, and returns the
2895 Performs a bitwise OR between the bit field specified by StartBit
2896 and EndBit in Operand and the value specified by OrData. All other bits in
2897 Operand are preserved. The new 16-bit value is returned.
2899 If 16-bit operations are not supported, then ASSERT().
2900 If StartBit is greater than 15, then ASSERT().
2901 If EndBit is greater than 15, then ASSERT().
2902 If EndBit is less than StartBit, then ASSERT().
2903 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
2905 @param Operand Operand on which to perform the bitfield operation.
2906 @param StartBit The ordinal of the least significant bit in the bit field.
2908 @param EndBit The ordinal of the most significant bit in the bit field.
2910 @param OrData The value to OR with the read value from the value
2912 @return The new 16-bit value.
2926 Reads a bit field from a 16-bit value, performs a bitwise AND, and returns
2929 Performs a bitwise AND between the bit field specified by StartBit and EndBit
2930 in Operand and the value specified by AndData. All other bits in Operand are
2931 preserved. The new 16-bit value is returned.
2933 If 16-bit operations are not supported, then ASSERT().
2934 If StartBit is greater than 15, then ASSERT().
2935 If EndBit is greater than 15, then ASSERT().
2936 If EndBit is less than StartBit, then ASSERT().
2937 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
2939 @param Operand Operand on which to perform the bitfield operation.
2940 @param StartBit The ordinal of the least significant bit in the bit field.
2942 @param EndBit The ordinal of the most significant bit in the bit field.
2944 @param AndData The value to AND with the read value from the value
2946 @return The new 16-bit value.
2960 Reads a bit field from a 16-bit value, performs a bitwise AND followed by a
2961 bitwise OR, and returns the result.
2963 Performs a bitwise AND between the bit field specified by StartBit and EndBit
2964 in Operand and the value specified by AndData, followed by a bitwise
2965 OR with value specified by OrData. All other bits in Operand are
2966 preserved. The new 16-bit value is returned.
2968 If 16-bit operations are not supported, then ASSERT().
2969 If StartBit is greater than 15, then ASSERT().
2970 If EndBit is greater than 15, then ASSERT().
2971 If EndBit is less than StartBit, then ASSERT().
2972 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
2973 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
2975 @param Operand Operand on which to perform the bitfield operation.
2976 @param StartBit The ordinal of the least significant bit in the bit field.
2978 @param EndBit The ordinal of the most significant bit in the bit field.
2980 @param AndData The value to AND with the read value from the value.
2981 @param OrData The value to OR with the result of the AND operation.
2983 @return The new 16-bit value.
2988 BitFieldAndThenOr16 (
2998 Returns a bit field from a 32-bit value.
3000 Returns the bitfield specified by the StartBit and the EndBit from Operand.
3002 If 32-bit operations are not supported, then ASSERT().
3003 If StartBit is greater than 31, then ASSERT().
3004 If EndBit is greater than 31, then ASSERT().
3005 If EndBit is less than StartBit, then ASSERT().
3007 @param Operand Operand on which to perform the bitfield operation.
3008 @param StartBit The ordinal of the least significant bit in the bit field.
3010 @param EndBit The ordinal of the most significant bit in the bit field.
3013 @return The bit field read.
3026 Writes a bit field to a 32-bit value, and returns the result.
3028 Writes Value to the bit field specified by the StartBit and the EndBit in
3029 Operand. All other bits in Operand are preserved. The new 32-bit value is
3032 If 32-bit operations are not supported, then ASSERT().
3033 If StartBit is greater than 31, then ASSERT().
3034 If EndBit is greater than 31, then ASSERT().
3035 If EndBit is less than StartBit, then ASSERT().
3036 If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
3038 @param Operand Operand on which to perform the bitfield operation.
3039 @param StartBit The ordinal of the least significant bit in the bit field.
3041 @param EndBit The ordinal of the most significant bit in the bit field.
3043 @param Value New value of the bit field.
3045 @return The new 32-bit value.
3059 Reads a bit field from a 32-bit value, performs a bitwise OR, and returns the
3062 Performs a bitwise OR between the bit field specified by StartBit
3063 and EndBit in Operand and the value specified by OrData. All other bits in
3064 Operand are preserved. The new 32-bit value is returned.
3066 If 32-bit operations are not supported, then ASSERT().
3067 If StartBit is greater than 31, then ASSERT().
3068 If EndBit is greater than 31, then ASSERT().
3069 If EndBit is less than StartBit, then ASSERT().
3070 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
3072 @param Operand Operand on which to perform the bitfield operation.
3073 @param StartBit The ordinal of the least significant bit in the bit field.
3075 @param EndBit The ordinal of the most significant bit in the bit field.
3077 @param OrData The value to OR with the read value from the value.
3079 @return The new 32-bit value.
3093 Reads a bit field from a 32-bit value, performs a bitwise AND, and returns
3096 Performs a bitwise AND between the bit field specified by StartBit and EndBit
3097 in Operand and the value specified by AndData. All other bits in Operand are
3098 preserved. The new 32-bit value is returned.
3100 If 32-bit operations are not supported, then ASSERT().
3101 If StartBit is greater than 31, then ASSERT().
3102 If EndBit is greater than 31, then ASSERT().
3103 If EndBit is less than StartBit, then ASSERT().
3104 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
3106 @param Operand Operand on which to perform the bitfield operation.
3107 @param StartBit The ordinal of the least significant bit in the bit field.
3109 @param EndBit The ordinal of the most significant bit in the bit field.
3111 @param AndData The value to AND with the read value from the value
3113 @return The new 32-bit value.
3127 Reads a bit field from a 32-bit value, performs a bitwise AND followed by a
3128 bitwise OR, and returns the result.
3130 Performs a bitwise AND between the bit field specified by StartBit and EndBit
3131 in Operand and the value specified by AndData, followed by a bitwise
3132 OR with value specified by OrData. All other bits in Operand are
3133 preserved. The new 32-bit value is returned.
3135 If 32-bit operations are not supported, then ASSERT().
3136 If StartBit is greater than 31, then ASSERT().
3137 If EndBit is greater than 31, then ASSERT().
3138 If EndBit is less than StartBit, then ASSERT().
3139 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
3140 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
3142 @param Operand Operand on which to perform the bitfield operation.
3143 @param StartBit The ordinal of the least significant bit in the bit field.
3145 @param EndBit The ordinal of the most significant bit in the bit field.
3147 @param AndData The value to AND with the read value from the value.
3148 @param OrData The value to OR with the result of the AND operation.
3150 @return The new 32-bit value.
3155 BitFieldAndThenOr32 (
3165 Returns a bit field from a 64-bit value.
3167 Returns the bitfield specified by the StartBit and the EndBit from Operand.
3169 If 64-bit operations are not supported, then ASSERT().
3170 If StartBit is greater than 63, then ASSERT().
3171 If EndBit is greater than 63, then ASSERT().
3172 If EndBit is less than StartBit, then ASSERT().
3174 @param Operand Operand on which to perform the bitfield operation.
3175 @param StartBit The ordinal of the least significant bit in the bit field.
3177 @param EndBit The ordinal of the most significant bit in the bit field.
3180 @return The bit field read.
3193 Writes a bit field to a 64-bit value, and returns the result.
3195 Writes Value to the bit field specified by the StartBit and the EndBit in
3196 Operand. All other bits in Operand are preserved. The new 64-bit value is
3199 If 64-bit operations are not supported, then ASSERT().
3200 If StartBit is greater than 63, then ASSERT().
3201 If EndBit is greater than 63, then ASSERT().
3202 If EndBit is less than StartBit, then ASSERT().
3203 If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
3205 @param Operand Operand on which to perform the bitfield operation.
3206 @param StartBit The ordinal of the least significant bit in the bit field.
3208 @param EndBit The ordinal of the most significant bit in the bit field.
3210 @param Value New value of the bit field.
3212 @return The new 64-bit value.
3226 Reads a bit field from a 64-bit value, performs a bitwise OR, and returns the
3229 Performs a bitwise OR between the bit field specified by StartBit
3230 and EndBit in Operand and the value specified by OrData. All other bits in
3231 Operand are preserved. The new 64-bit value is returned.
3233 If 64-bit operations are not supported, then ASSERT().
3234 If StartBit is greater than 63, then ASSERT().
3235 If EndBit is greater than 63, then ASSERT().
3236 If EndBit is less than StartBit, then ASSERT().
3237 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
3239 @param Operand Operand on which to perform the bitfield operation.
3240 @param StartBit The ordinal of the least significant bit in the bit field.
3242 @param EndBit The ordinal of the most significant bit in the bit field.
3244 @param OrData The value to OR with the read value from the value
3246 @return The new 64-bit value.
3260 Reads a bit field from a 64-bit value, performs a bitwise AND, and returns
3263 Performs a bitwise AND between the bit field specified by StartBit and EndBit
3264 in Operand and the value specified by AndData. All other bits in Operand are
3265 preserved. The new 64-bit value is returned.
3267 If 64-bit operations are not supported, then ASSERT().
3268 If StartBit is greater than 63, then ASSERT().
3269 If EndBit is greater than 63, then ASSERT().
3270 If EndBit is less than StartBit, then ASSERT().
3271 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
3273 @param Operand Operand on which to perform the bitfield operation.
3274 @param StartBit The ordinal of the least significant bit in the bit field.
3276 @param EndBit The ordinal of the most significant bit in the bit field.
3278 @param AndData The value to AND with the read value from the value
3280 @return The new 64-bit value.
3294 Reads a bit field from a 64-bit value, performs a bitwise AND followed by a
3295 bitwise OR, and returns the result.
3297 Performs a bitwise AND between the bit field specified by StartBit and EndBit
3298 in Operand and the value specified by AndData, followed by a bitwise
3299 OR with value specified by OrData. All other bits in Operand are
3300 preserved. The new 64-bit value is returned.
3302 If 64-bit operations are not supported, then ASSERT().
3303 If StartBit is greater than 63, then ASSERT().
3304 If EndBit is greater than 63, then ASSERT().
3305 If EndBit is less than StartBit, then ASSERT().
3306 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
3307 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
3309 @param Operand Operand on which to perform the bitfield operation.
3310 @param StartBit The ordinal of the least significant bit in the bit field.
3312 @param EndBit The ordinal of the most significant bit in the bit field.
3314 @param AndData The value to AND with the read value from the value.
3315 @param OrData The value to OR with the result of the AND operation.
3317 @return The new 64-bit value.
3322 BitFieldAndThenOr64 (
3331 // Base Library Checksum Functions
3335 Returns the sum of all elements in a buffer in unit of UINT8.
3336 During calculation, the carry bits are dropped.
3338 This function calculates the sum of all elements in a buffer
3339 in unit of UINT8. The carry bits in result of addition are dropped.
3340 The result is returned as UINT8. If Length is Zero, then Zero is
3343 If Buffer is NULL, then ASSERT().
3344 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
3346 @param Buffer The pointer to the buffer to carry out the sum operation.
3347 @param Length The size, in bytes, of Buffer.
3349 @return Sum The sum of Buffer with carry bits dropped during additions.
3355 IN CONST UINT8
*Buffer
,
3361 Returns the two's complement checksum of all elements in a buffer
3364 This function first calculates the sum of the 8-bit values in the
3365 buffer specified by Buffer and Length. The carry bits in the result
3366 of addition are dropped. Then, the two's complement of the sum is
3367 returned. If Length is 0, then 0 is returned.
3369 If Buffer is NULL, then ASSERT().
3370 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
3372 @param Buffer The pointer to the buffer to carry out the checksum operation.
3373 @param Length The size, in bytes, of Buffer.
3375 @return Checksum The two's complement checksum of Buffer.
3380 CalculateCheckSum8 (
3381 IN CONST UINT8
*Buffer
,
3387 Returns the sum of all elements in a buffer of 16-bit values. During
3388 calculation, the carry bits are dropped.
3390 This function calculates the sum of the 16-bit values in the buffer
3391 specified by Buffer and Length. The carry bits in result of addition are dropped.
3392 The 16-bit result is returned. If Length is 0, then 0 is returned.
3394 If Buffer is NULL, then ASSERT().
3395 If Buffer is not aligned on a 16-bit boundary, then ASSERT().
3396 If Length is not aligned on a 16-bit boundary, then ASSERT().
3397 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
3399 @param Buffer The pointer to the buffer to carry out the sum operation.
3400 @param Length The size, in bytes, of Buffer.
3402 @return Sum The sum of Buffer with carry bits dropped during additions.
3408 IN CONST UINT16
*Buffer
,
3414 Returns the two's complement checksum of all elements in a buffer of
3417 This function first calculates the sum of the 16-bit values in the buffer
3418 specified by Buffer and Length. The carry bits in the result of addition
3419 are dropped. Then, the two's complement of the sum is returned. If Length
3420 is 0, then 0 is returned.
3422 If Buffer is NULL, then ASSERT().
3423 If Buffer is not aligned on a 16-bit boundary, then ASSERT().
3424 If Length is not aligned on a 16-bit boundary, then ASSERT().
3425 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
3427 @param Buffer The pointer to the buffer to carry out the checksum operation.
3428 @param Length The size, in bytes, of Buffer.
3430 @return Checksum The two's complement checksum of Buffer.
3435 CalculateCheckSum16 (
3436 IN CONST UINT16
*Buffer
,
3442 Returns the sum of all elements in a buffer of 32-bit values. During
3443 calculation, the carry bits are dropped.
3445 This function calculates the sum of the 32-bit values in the buffer
3446 specified by Buffer and Length. The carry bits in result of addition are dropped.
3447 The 32-bit result is returned. If Length is 0, then 0 is returned.
3449 If Buffer is NULL, then ASSERT().
3450 If Buffer is not aligned on a 32-bit boundary, then ASSERT().
3451 If Length is not aligned on a 32-bit boundary, then ASSERT().
3452 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
3454 @param Buffer The pointer to the buffer to carry out the sum operation.
3455 @param Length The size, in bytes, of Buffer.
3457 @return Sum The sum of Buffer with carry bits dropped during additions.
3463 IN CONST UINT32
*Buffer
,
3469 Returns the two's complement checksum of all elements in a buffer of
3472 This function first calculates the sum of the 32-bit values in the buffer
3473 specified by Buffer and Length. The carry bits in the result of addition
3474 are dropped. Then, the two's complement of the sum is returned. If Length
3475 is 0, then 0 is returned.
3477 If Buffer is NULL, then ASSERT().
3478 If Buffer is not aligned on a 32-bit boundary, then ASSERT().
3479 If Length is not aligned on a 32-bit boundary, then ASSERT().
3480 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
3482 @param Buffer The pointer to the buffer to carry out the checksum operation.
3483 @param Length The size, in bytes, of Buffer.
3485 @return Checksum The two's complement checksum of Buffer.
3490 CalculateCheckSum32 (
3491 IN CONST UINT32
*Buffer
,
3497 Returns the sum of all elements in a buffer of 64-bit values. During
3498 calculation, the carry bits are dropped.
3500 This function calculates the sum of the 64-bit values in the buffer
3501 specified by Buffer and Length. The carry bits in result of addition are dropped.
3502 The 64-bit result is returned. If Length is 0, then 0 is returned.
3504 If Buffer is NULL, then ASSERT().
3505 If Buffer is not aligned on a 64-bit boundary, then ASSERT().
3506 If Length is not aligned on a 64-bit boundary, then ASSERT().
3507 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
3509 @param Buffer The pointer to the buffer to carry out the sum operation.
3510 @param Length The size, in bytes, of Buffer.
3512 @return Sum The sum of Buffer with carry bits dropped during additions.
3518 IN CONST UINT64
*Buffer
,
3524 Returns the two's complement checksum of all elements in a buffer of
3527 This function first calculates the sum of the 64-bit values in the buffer
3528 specified by Buffer and Length. The carry bits in the result of addition
3529 are dropped. Then, the two's complement of the sum is returned. If Length
3530 is 0, then 0 is returned.
3532 If Buffer is NULL, then ASSERT().
3533 If Buffer is not aligned on a 64-bit boundary, then ASSERT().
3534 If Length is not aligned on a 64-bit boundary, then ASSERT().
3535 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
3537 @param Buffer The pointer to the buffer to carry out the checksum operation.
3538 @param Length The size, in bytes, of Buffer.
3540 @return Checksum The two's complement checksum of Buffer.
3545 CalculateCheckSum64 (
3546 IN CONST UINT64
*Buffer
,
3552 // Base Library CPU Functions
3556 Function entry point used when a stack switch is requested with SwitchStack()
3558 @param Context1 Context1 parameter passed into SwitchStack().
3559 @param Context2 Context2 parameter passed into SwitchStack().
3564 (EFIAPI
*SWITCH_STACK_ENTRY_POINT
)(
3565 IN VOID
*Context1
, OPTIONAL
3566 IN VOID
*Context2 OPTIONAL
3571 Used to serialize load and store operations.
3573 All loads and stores that proceed calls to this function are guaranteed to be
3574 globally visible when this function returns.
3585 Saves the current CPU context that can be restored with a call to LongJump()
3588 Saves the current CPU context in the buffer specified by JumpBuffer and
3589 returns 0. The initial call to SetJump() must always return 0. Subsequent
3590 calls to LongJump() cause a non-zero value to be returned by SetJump().
3592 If JumpBuffer is NULL, then ASSERT().
3593 For Itanium processors, if JumpBuffer is not aligned on a 16-byte boundary, then ASSERT().
3595 NOTE: The structure BASE_LIBRARY_JUMP_BUFFER is CPU architecture specific.
3596 The same structure must never be used for more than one CPU architecture context.
3597 For example, a BASE_LIBRARY_JUMP_BUFFER allocated by an IA-32 module must never be used from an x64 module.
3598 SetJump()/LongJump() is not currently supported for the EBC processor type.
3600 @param JumpBuffer A pointer to CPU context buffer.
3602 @retval 0 Indicates a return from SetJump().
3608 OUT BASE_LIBRARY_JUMP_BUFFER
*JumpBuffer
3613 Restores the CPU context that was saved with SetJump().
3615 Restores the CPU context from the buffer specified by JumpBuffer. This
3616 function never returns to the caller. Instead is resumes execution based on
3617 the state of JumpBuffer.
3619 If JumpBuffer is NULL, then ASSERT().
3620 For Itanium processors, if JumpBuffer is not aligned on a 16-byte boundary, then ASSERT().
3621 If Value is 0, then ASSERT().
3623 @param JumpBuffer A pointer to CPU context buffer.
3624 @param Value The value to return when the SetJump() context is
3625 restored and must be non-zero.
3631 IN BASE_LIBRARY_JUMP_BUFFER
*JumpBuffer
,
3637 Enables CPU interrupts.
3648 Disables CPU interrupts.
3659 Disables CPU interrupts and returns the interrupt state prior to the disable
3662 @retval TRUE CPU interrupts were enabled on entry to this call.
3663 @retval FALSE CPU interrupts were disabled on entry to this call.
3668 SaveAndDisableInterrupts (
3674 Enables CPU interrupts for the smallest window required to capture any
3680 EnableDisableInterrupts (
3686 Retrieves the current CPU interrupt state.
3688 Returns TRUE if interrupts are currently enabled. Otherwise
3691 @retval TRUE CPU interrupts are enabled.
3692 @retval FALSE CPU interrupts are disabled.
3703 Set the current CPU interrupt state.
3705 Sets the current CPU interrupt state to the state specified by
3706 InterruptState. If InterruptState is TRUE, then interrupts are enabled. If
3707 InterruptState is FALSE, then interrupts are disabled. InterruptState is
3710 @param InterruptState TRUE if interrupts should enabled. FALSE if
3711 interrupts should be disabled.
3713 @return InterruptState
3719 IN BOOLEAN InterruptState
3724 Requests CPU to pause for a short period of time.
3726 Requests CPU to pause for a short period of time. Typically used in MP
3727 systems to prevent memory starvation while waiting for a spin lock.
3738 Transfers control to a function starting with a new stack.
3740 Transfers control to the function specified by EntryPoint using the
3741 new stack specified by NewStack and passing in the parameters specified
3742 by Context1 and Context2. Context1 and Context2 are optional and may
3743 be NULL. The function EntryPoint must never return. This function
3744 supports a variable number of arguments following the NewStack parameter.
3745 These additional arguments are ignored on IA-32, x64, and EBC architectures.
3746 Itanium processors expect one additional parameter of type VOID * that specifies
3747 the new backing store pointer.
3749 If EntryPoint is NULL, then ASSERT().
3750 If NewStack is NULL, then ASSERT().
3752 @param EntryPoint A pointer to function to call with the new stack.
3753 @param Context1 A pointer to the context to pass into the EntryPoint
3755 @param Context2 A pointer to the context to pass into the EntryPoint
3757 @param NewStack A pointer to the new stack to use for the EntryPoint
3759 @param ... This variable argument list is ignored for IA-32, x64, and
3760 EBC architectures. For Itanium processors, this variable
3761 argument list is expected to contain a single parameter of
3762 type VOID * that specifies the new backing store pointer.
3769 IN SWITCH_STACK_ENTRY_POINT EntryPoint
,
3770 IN VOID
*Context1
, OPTIONAL
3771 IN VOID
*Context2
, OPTIONAL
3778 Generates a breakpoint on the CPU.
3780 Generates a breakpoint on the CPU. The breakpoint must be implemented such
3781 that code can resume normal execution after the breakpoint.
3792 Executes an infinite loop.
3794 Forces the CPU to execute an infinite loop. A debugger may be used to skip
3795 past the loop and the code that follows the loop must execute properly. This
3796 implies that the infinite loop must not cause the code that follow it to be
3806 #if defined (MDE_CPU_IPF)
3809 Flush a range of cache lines in the cache coherency domain of the calling
3812 Flushes the cache lines specified by Address and Length. If Address is not aligned
3813 on a cache line boundary, then entire cache line containing Address is flushed.
3814 If Address + Length is not aligned on a cache line boundary, then the entire cache
3815 line containing Address + Length - 1 is flushed. This function may choose to flush
3816 the entire cache if that is more efficient than flushing the specified range. If
3817 Length is 0, the no cache lines are flushed. Address is returned.
3818 This function is only available on Itanium processors.
3820 If Length is greater than (MAX_ADDRESS - Address + 1), then ASSERT().
3822 @param Address The base address of the instruction lines to invalidate. If
3823 the CPU is in a physical addressing mode, then Address is a
3824 physical address. If the CPU is in a virtual addressing mode,
3825 then Address is a virtual address.
3827 @param Length The number of bytes to invalidate from the instruction cache.
3834 AsmFlushCacheRange (
3841 Executes an FC instruction.
3842 Executes an FC instruction on the cache line specified by Address.
3843 The cache line size affected is at least 32-bytes (aligned on a 32-byte boundary).
3844 An implementation may flush a larger region. This function is only available on Itanium processors.
3846 @param Address The Address of cache line to be flushed.
3848 @return The address of FC instruction executed.
3859 Executes an FC.I instruction.
3860 Executes an FC.I instruction on the cache line specified by Address.
3861 The cache line size affected is at least 32-bytes (aligned on a 32-byte boundary).
3862 An implementation may flush a larger region. This function is only available on Itanium processors.
3864 @param Address The Address of cache line to be flushed.
3866 @return The address of the FC.I instruction executed.
3877 Reads the current value of a Processor Identifier Register (CPUID).
3879 Reads and returns the current value of Processor Identifier Register specified by Index.
3880 The Index of largest implemented CPUID (One less than the number of implemented CPUID
3881 registers) is determined by CPUID [3] bits {7:0}.
3882 No parameter checking is performed on Index. If the Index value is beyond the
3883 implemented CPUID register range, a Reserved Register/Field fault may occur. The caller
3884 must either guarantee that Index is valid, or the caller must set up fault handlers to
3885 catch the faults. This function is only available on Itanium processors.
3887 @param Index The 8-bit Processor Identifier Register index to read.
3889 @return The current value of Processor Identifier Register specified by Index.
3900 Reads the current value of 64-bit Processor Status Register (PSR).
3901 This function is only available on Itanium processors.
3903 @return The current value of PSR.
3914 Writes the current value of 64-bit Processor Status Register (PSR).
3916 No parameter checking is performed on Value. All bits of Value corresponding to
3917 reserved fields of PSR must be 0 or a Reserved Register/Field fault may occur.
3918 The caller must either guarantee that Value is valid, or the caller must set up
3919 fault handlers to catch the faults. This function is only available on Itanium processors.
3921 @param Value The 64-bit value to write to PSR.
3923 @return The 64-bit value written to the PSR.
3934 Reads the current value of 64-bit Kernel Register #0 (KR0).
3936 Reads and returns the current value of KR0.
3937 This function is only available on Itanium processors.
3939 @return The current value of KR0.
3950 Reads the current value of 64-bit Kernel Register #1 (KR1).
3952 Reads and returns the current value of KR1.
3953 This function is only available on Itanium processors.
3955 @return The current value of KR1.
3966 Reads the current value of 64-bit Kernel Register #2 (KR2).
3968 Reads and returns the current value of KR2.
3969 This function is only available on Itanium processors.
3971 @return The current value of KR2.
3982 Reads the current value of 64-bit Kernel Register #3 (KR3).
3984 Reads and returns the current value of KR3.
3985 This function is only available on Itanium processors.
3987 @return The current value of KR3.
3998 Reads the current value of 64-bit Kernel Register #4 (KR4).
4000 Reads and returns the current value of KR4.
4001 This function is only available on Itanium processors.
4003 @return The current value of KR4.
4014 Reads the current value of 64-bit Kernel Register #5 (KR5).
4016 Reads and returns the current value of KR5.
4017 This function is only available on Itanium processors.
4019 @return The current value of KR5.
4030 Reads the current value of 64-bit Kernel Register #6 (KR6).
4032 Reads and returns the current value of KR6.
4033 This function is only available on Itanium processors.
4035 @return The current value of KR6.
4046 Reads the current value of 64-bit Kernel Register #7 (KR7).
4048 Reads and returns the current value of KR7.
4049 This function is only available on Itanium processors.
4051 @return The current value of KR7.
4062 Write the current value of 64-bit Kernel Register #0 (KR0).
4064 Writes the current value of KR0. The 64-bit value written to
4065 the KR0 is returned. This function is only available on Itanium processors.
4067 @param Value The 64-bit value to write to KR0.
4069 @return The 64-bit value written to the KR0.
4080 Write the current value of 64-bit Kernel Register #1 (KR1).
4082 Writes the current value of KR1. The 64-bit value written to
4083 the KR1 is returned. This function is only available on Itanium processors.
4085 @param Value The 64-bit value to write to KR1.
4087 @return The 64-bit value written to the KR1.
4098 Write the current value of 64-bit Kernel Register #2 (KR2).
4100 Writes the current value of KR2. The 64-bit value written to
4101 the KR2 is returned. This function is only available on Itanium processors.
4103 @param Value The 64-bit value to write to KR2.
4105 @return The 64-bit value written to the KR2.
4116 Write the current value of 64-bit Kernel Register #3 (KR3).
4118 Writes the current value of KR3. The 64-bit value written to
4119 the KR3 is returned. This function is only available on Itanium processors.
4121 @param Value The 64-bit value to write to KR3.
4123 @return The 64-bit value written to the KR3.
4134 Write the current value of 64-bit Kernel Register #4 (KR4).
4136 Writes the current value of KR4. The 64-bit value written to
4137 the KR4 is returned. This function is only available on Itanium processors.
4139 @param Value The 64-bit value to write to KR4.
4141 @return The 64-bit value written to the KR4.
4152 Write the current value of 64-bit Kernel Register #5 (KR5).
4154 Writes the current value of KR5. The 64-bit value written to
4155 the KR5 is returned. This function is only available on Itanium processors.
4157 @param Value The 64-bit value to write to KR5.
4159 @return The 64-bit value written to the KR5.
4170 Write the current value of 64-bit Kernel Register #6 (KR6).
4172 Writes the current value of KR6. The 64-bit value written to
4173 the KR6 is returned. This function is only available on Itanium processors.
4175 @param Value The 64-bit value to write to KR6.
4177 @return The 64-bit value written to the KR6.
4188 Write the current value of 64-bit Kernel Register #7 (KR7).
4190 Writes the current value of KR7. The 64-bit value written to
4191 the KR7 is returned. This function is only available on Itanium processors.
4193 @param Value The 64-bit value to write to KR7.
4195 @return The 64-bit value written to the KR7.
4206 Reads the current value of Interval Timer Counter Register (ITC).
4208 Reads and returns the current value of ITC.
4209 This function is only available on Itanium processors.
4211 @return The current value of ITC.
4222 Reads the current value of Interval Timer Vector Register (ITV).
4224 Reads and returns the current value of ITV.
4225 This function is only available on Itanium processors.
4227 @return The current value of ITV.
4238 Reads the current value of Interval Timer Match Register (ITM).
4240 Reads and returns the current value of ITM.
4241 This function is only available on Itanium processors.
4243 @return The current value of ITM.
4253 Writes the current value of 64-bit Interval Timer Counter Register (ITC).
4255 Writes the current value of ITC. The 64-bit value written to the ITC is returned.
4256 This function is only available on Itanium processors.
4258 @param Value The 64-bit value to write to ITC.
4260 @return The 64-bit value written to the ITC.
4271 Writes the current value of 64-bit Interval Timer Match Register (ITM).
4273 Writes the current value of ITM. The 64-bit value written to the ITM is returned.
4274 This function is only available on Itanium processors.
4276 @param Value The 64-bit value to write to ITM.
4278 @return The 64-bit value written to the ITM.
4289 Writes the current value of 64-bit Interval Timer Vector Register (ITV).
4291 Writes the current value of ITV. The 64-bit value written to the ITV is returned.
4292 No parameter checking is performed on Value. All bits of Value corresponding to
4293 reserved fields of ITV must be 0 or a Reserved Register/Field fault may occur.
4294 The caller must either guarantee that Value is valid, or the caller must set up
4295 fault handlers to catch the faults.
4296 This function is only available on Itanium processors.
4298 @param Value The 64-bit value to write to ITV.
4300 @return The 64-bit value written to the ITV.
4311 Reads the current value of Default Control Register (DCR).
4313 Reads and returns the current value of DCR. This function is only available on Itanium processors.
4315 @return The current value of DCR.
4326 Reads the current value of Interruption Vector Address Register (IVA).
4328 Reads and returns the current value of IVA. This function is only available on Itanium processors.
4330 @return The current value of IVA.
4340 Reads the current value of Page Table Address Register (PTA).
4342 Reads and returns the current value of PTA. This function is only available on Itanium processors.
4344 @return The current value of PTA.
4355 Writes the current value of 64-bit Default Control Register (DCR).
4357 Writes the current value of DCR. The 64-bit value written to the DCR is returned.
4358 No parameter checking is performed on Value. All bits of Value corresponding to
4359 reserved fields of DCR must be 0 or a Reserved Register/Field fault may occur.
4360 The caller must either guarantee that Value is valid, or the caller must set up
4361 fault handlers to catch the faults.
4362 This function is only available on Itanium processors.
4364 @param Value The 64-bit value to write to DCR.
4366 @return The 64-bit value written to the DCR.
4377 Writes the current value of 64-bit Interruption Vector Address Register (IVA).
4379 Writes the current value of IVA. The 64-bit value written to the IVA is returned.
4380 The size of vector table is 32 K bytes and is 32 K bytes aligned
4381 the low 15 bits of Value is ignored when written.
4382 This function is only available on Itanium processors.
4384 @param Value The 64-bit value to write to IVA.
4386 @return The 64-bit value written to the IVA.
4397 Writes the current value of 64-bit Page Table Address Register (PTA).
4399 Writes the current value of PTA. The 64-bit value written to the PTA is returned.
4400 No parameter checking is performed on Value. All bits of Value corresponding to
4401 reserved fields of DCR must be 0 or a Reserved Register/Field fault may occur.
4402 The caller must either guarantee that Value is valid, or the caller must set up
4403 fault handlers to catch the faults.
4404 This function is only available on Itanium processors.
4406 @param Value The 64-bit value to write to PTA.
4408 @return The 64-bit value written to the PTA.
4418 Reads the current value of Local Interrupt ID Register (LID).
4420 Reads and returns the current value of LID. This function is only available on Itanium processors.
4422 @return The current value of LID.
4433 Reads the current value of External Interrupt Vector Register (IVR).
4435 Reads and returns the current value of IVR. This function is only available on Itanium processors.
4437 @return The current value of IVR.
4448 Reads the current value of Task Priority Register (TPR).
4450 Reads and returns the current value of TPR. This function is only available on Itanium processors.
4452 @return The current value of TPR.
4463 Reads the current value of External Interrupt Request Register #0 (IRR0).
4465 Reads and returns the current value of IRR0. This function is only available on Itanium processors.
4467 @return The current value of IRR0.
4478 Reads the current value of External Interrupt Request Register #1 (IRR1).
4480 Reads and returns the current value of IRR1. This function is only available on Itanium processors.
4482 @return The current value of IRR1.
4493 Reads the current value of External Interrupt Request Register #2 (IRR2).
4495 Reads and returns the current value of IRR2. This function is only available on Itanium processors.
4497 @return The current value of IRR2.
4508 Reads the current value of External Interrupt Request Register #3 (IRR3).
4510 Reads and returns the current value of IRR3. This function is only available on Itanium processors.
4512 @return The current value of IRR3.
4523 Reads the current value of Performance Monitor Vector Register (PMV).
4525 Reads and returns the current value of PMV. This function is only available on Itanium processors.
4527 @return The current value of PMV.
4538 Reads the current value of Corrected Machine Check Vector Register (CMCV).
4540 Reads and returns the current value of CMCV. This function is only available on Itanium processors.
4542 @return The current value of CMCV.
4553 Reads the current value of Local Redirection Register #0 (LRR0).
4555 Reads and returns the current value of LRR0. This function is only available on Itanium processors.
4557 @return The current value of LRR0.
4568 Reads the current value of Local Redirection Register #1 (LRR1).
4570 Reads and returns the current value of LRR1. This function is only available on Itanium processors.
4572 @return The current value of LRR1.
4583 Writes the current value of 64-bit Page Local Interrupt ID Register (LID).
4585 Writes the current value of LID. The 64-bit value written to the LID is returned.
4586 No parameter checking is performed on Value. All bits of Value corresponding to
4587 reserved fields of LID must be 0 or a Reserved Register/Field fault may occur.
4588 The caller must either guarantee that Value is valid, or the caller must set up
4589 fault handlers to catch the faults.
4590 This function is only available on Itanium processors.
4592 @param Value The 64-bit value to write to LID.
4594 @return The 64-bit value written to the LID.
4605 Writes the current value of 64-bit Task Priority Register (TPR).
4607 Writes the current value of TPR. The 64-bit value written to the TPR is returned.
4608 No parameter checking is performed on Value. All bits of Value corresponding to
4609 reserved fields of TPR must be 0 or a Reserved Register/Field fault may occur.
4610 The caller must either guarantee that Value is valid, or the caller must set up
4611 fault handlers to catch the faults.
4612 This function is only available on Itanium processors.
4614 @param Value The 64-bit value to write to TPR.
4616 @return The 64-bit value written to the TPR.
4627 Performs a write operation on End OF External Interrupt Register (EOI).
4629 Writes a value of 0 to the EOI Register. This function is only available on Itanium processors.
4640 Writes the current value of 64-bit Performance Monitor Vector Register (PMV).
4642 Writes the current value of PMV. The 64-bit value written to the PMV is returned.
4643 No parameter checking is performed on Value. All bits of Value corresponding
4644 to reserved fields of PMV must be 0 or a Reserved Register/Field fault may occur.
4645 The caller must either guarantee that Value is valid, or the caller must set up
4646 fault handlers to catch the faults.
4647 This function is only available on Itanium processors.
4649 @param Value The 64-bit value to write to PMV.
4651 @return The 64-bit value written to the PMV.
4662 Writes the current value of 64-bit Corrected Machine Check Vector Register (CMCV).
4664 Writes the current value of CMCV. The 64-bit value written to the CMCV is returned.
4665 No parameter checking is performed on Value. All bits of Value corresponding
4666 to reserved fields of CMCV must be 0 or a Reserved Register/Field fault may occur.
4667 The caller must either guarantee that Value is valid, or the caller must set up
4668 fault handlers to catch the faults.
4669 This function is only available on Itanium processors.
4671 @param Value The 64-bit value to write to CMCV.
4673 @return The 64-bit value written to the CMCV.
4684 Writes the current value of 64-bit Local Redirection Register #0 (LRR0).
4686 Writes the current value of LRR0. The 64-bit value written to the LRR0 is returned.
4687 No parameter checking is performed on Value. All bits of Value corresponding
4688 to reserved fields of LRR0 must be 0 or a Reserved Register/Field fault may occur.
4689 The caller must either guarantee that Value is valid, or the caller must set up
4690 fault handlers to catch the faults.
4691 This function is only available on Itanium processors.
4693 @param Value The 64-bit value to write to LRR0.
4695 @return The 64-bit value written to the LRR0.
4706 Writes the current value of 64-bit Local Redirection Register #1 (LRR1).
4708 Writes the current value of LRR1. The 64-bit value written to the LRR1 is returned.
4709 No parameter checking is performed on Value. All bits of Value corresponding
4710 to reserved fields of LRR1 must be 0 or a Reserved Register/Field fault may occur.
4711 The caller must either guarantee that Value is valid, or the caller must
4712 set up fault handlers to catch the faults.
4713 This function is only available on Itanium processors.
4715 @param Value The 64-bit value to write to LRR1.
4717 @return The 64-bit value written to the LRR1.
4728 Reads the current value of Instruction Breakpoint Register (IBR).
4730 The Instruction Breakpoint Registers are used in pairs. The even numbered
4731 registers contain breakpoint addresses, and the odd numbered registers contain
4732 breakpoint mask conditions. At least four instruction registers pairs are implemented
4733 on all processor models. Implemented registers are contiguous starting with
4734 register 0. No parameter checking is performed on Index, and if the Index value
4735 is beyond the implemented IBR register range, a Reserved Register/Field fault may
4736 occur. The caller must either guarantee that Index is valid, or the caller must
4737 set up fault handlers to catch the faults.
4738 This function is only available on Itanium processors.
4740 @param Index The 8-bit Instruction Breakpoint Register index to read.
4742 @return The current value of Instruction Breakpoint Register specified by Index.
4753 Reads the current value of Data Breakpoint Register (DBR).
4755 The Data Breakpoint Registers are used in pairs. The even numbered registers
4756 contain breakpoint addresses, and odd numbered registers contain breakpoint
4757 mask conditions. At least four data registers pairs are implemented on all processor
4758 models. Implemented registers are contiguous starting with register 0.
4759 No parameter checking is performed on Index. If the Index value is beyond
4760 the implemented DBR register range, a Reserved Register/Field fault may occur.
4761 The caller must either guarantee that Index is valid, or the caller must set up
4762 fault handlers to catch the faults.
4763 This function is only available on Itanium processors.
4765 @param Index The 8-bit Data Breakpoint Register index to read.
4767 @return The current value of Data Breakpoint Register specified by Index.
4778 Reads the current value of Performance Monitor Configuration Register (PMC).
4780 All processor implementations provide at least four performance counters
4781 (PMC/PMD [4]...PMC/PMD [7] pairs), and four performance monitor counter overflow
4782 status registers (PMC [0]... PMC [3]). Processor implementations may provide
4783 additional implementation-dependent PMC and PMD to increase the number of
4784 'generic' performance counters (PMC/PMD pairs). The remainder of PMC and PMD
4785 register set is implementation dependent. No parameter checking is performed
4786 on Index. If the Index value is beyond the implemented PMC register range,
4787 zero value will be returned.
4788 This function is only available on Itanium processors.
4790 @param Index The 8-bit Performance Monitor Configuration Register index to read.
4792 @return The current value of Performance Monitor Configuration Register
4804 Reads the current value of Performance Monitor Data Register (PMD).
4806 All processor implementations provide at least 4 performance counters
4807 (PMC/PMD [4]...PMC/PMD [7] pairs), and 4 performance monitor counter
4808 overflow status registers (PMC [0]... PMC [3]). Processor implementations may
4809 provide additional implementation-dependent PMC and PMD to increase the number
4810 of 'generic' performance counters (PMC/PMD pairs). The remainder of PMC and PMD
4811 register set is implementation dependent. No parameter checking is performed
4812 on Index. If the Index value is beyond the implemented PMD register range,
4813 zero value will be returned.
4814 This function is only available on Itanium processors.
4816 @param Index The 8-bit Performance Monitor Data Register index to read.
4818 @return The current value of Performance Monitor Data Register specified by Index.
4829 Writes the current value of 64-bit Instruction Breakpoint Register (IBR).
4831 Writes current value of Instruction Breakpoint Register specified by Index.
4832 The Instruction Breakpoint Registers are used in pairs. The even numbered
4833 registers contain breakpoint addresses, and odd numbered registers contain
4834 breakpoint mask conditions. At least four instruction registers pairs are implemented
4835 on all processor models. Implemented registers are contiguous starting with
4836 register 0. No parameter checking is performed on Index. If the Index value
4837 is beyond the implemented IBR register range, a Reserved Register/Field fault may
4838 occur. The caller must either guarantee that Index is valid, or the caller must
4839 set up fault handlers to catch the faults.
4840 This function is only available on Itanium processors.
4842 @param Index The 8-bit Instruction Breakpoint Register index to write.
4843 @param Value The 64-bit value to write to IBR.
4845 @return The 64-bit value written to the IBR.
4857 Writes the current value of 64-bit Data Breakpoint Register (DBR).
4859 Writes current value of Data Breakpoint Register specified by Index.
4860 The Data Breakpoint Registers are used in pairs. The even numbered registers
4861 contain breakpoint addresses, and odd numbered registers contain breakpoint
4862 mask conditions. At least four data registers pairs are implemented on all processor
4863 models. Implemented registers are contiguous starting with register 0. No parameter
4864 checking is performed on Index. If the Index value is beyond the implemented
4865 DBR register range, a Reserved Register/Field fault may occur. The caller must
4866 either guarantee that Index is valid, or the caller must set up fault handlers to
4868 This function is only available on Itanium processors.
4870 @param Index The 8-bit Data Breakpoint Register index to write.
4871 @param Value The 64-bit value to write to DBR.
4873 @return The 64-bit value written to the DBR.
4885 Writes the current value of 64-bit Performance Monitor Configuration Register (PMC).
4887 Writes current value of Performance Monitor Configuration Register specified by Index.
4888 All processor implementations provide at least four performance counters
4889 (PMC/PMD [4]...PMC/PMD [7] pairs), and four performance monitor counter overflow status
4890 registers (PMC [0]... PMC [3]). Processor implementations may provide additional
4891 implementation-dependent PMC and PMD to increase the number of 'generic' performance
4892 counters (PMC/PMD pairs). The remainder of PMC and PMD register set is implementation
4893 dependent. No parameter checking is performed on Index. If the Index value is
4894 beyond the implemented PMC register range, the write is ignored.
4895 This function is only available on Itanium processors.
4897 @param Index The 8-bit Performance Monitor Configuration Register index to write.
4898 @param Value The 64-bit value to write to PMC.
4900 @return The 64-bit value written to the PMC.
4912 Writes the current value of 64-bit Performance Monitor Data Register (PMD).
4914 Writes current value of Performance Monitor Data Register specified by Index.
4915 All processor implementations provide at least four performance counters
4916 (PMC/PMD [4]...PMC/PMD [7] pairs), and four performance monitor counter overflow
4917 status registers (PMC [0]... PMC [3]). Processor implementations may provide
4918 additional implementation-dependent PMC and PMD to increase the number of 'generic'
4919 performance counters (PMC/PMD pairs). The remainder of PMC and PMD register set
4920 is implementation dependent. No parameter checking is performed on Index. If the
4921 Index value is beyond the implemented PMD register range, the write is ignored.
4922 This function is only available on Itanium processors.
4924 @param Index The 8-bit Performance Monitor Data Register index to write.
4925 @param Value The 64-bit value to write to PMD.
4927 @return The 64-bit value written to the PMD.
4939 Reads the current value of 64-bit Global Pointer (GP).
4941 Reads and returns the current value of GP.
4942 This function is only available on Itanium processors.
4944 @return The current value of GP.
4955 Write the current value of 64-bit Global Pointer (GP).
4957 Writes the current value of GP. The 64-bit value written to the GP is returned.
4958 No parameter checking is performed on Value.
4959 This function is only available on Itanium processors.
4961 @param Value The 64-bit value to write to GP.
4963 @return The 64-bit value written to the GP.
4974 Reads the current value of 64-bit Stack Pointer (SP).
4976 Reads and returns the current value of SP.
4977 This function is only available on Itanium processors.
4979 @return The current value of SP.
4990 /// Valid Index value for AsmReadControlRegister().
4992 #define IPF_CONTROL_REGISTER_DCR 0
4993 #define IPF_CONTROL_REGISTER_ITM 1
4994 #define IPF_CONTROL_REGISTER_IVA 2
4995 #define IPF_CONTROL_REGISTER_PTA 8
4996 #define IPF_CONTROL_REGISTER_IPSR 16
4997 #define IPF_CONTROL_REGISTER_ISR 17
4998 #define IPF_CONTROL_REGISTER_IIP 19
4999 #define IPF_CONTROL_REGISTER_IFA 20
5000 #define IPF_CONTROL_REGISTER_ITIR 21
5001 #define IPF_CONTROL_REGISTER_IIPA 22
5002 #define IPF_CONTROL_REGISTER_IFS 23
5003 #define IPF_CONTROL_REGISTER_IIM 24
5004 #define IPF_CONTROL_REGISTER_IHA 25
5005 #define IPF_CONTROL_REGISTER_LID 64
5006 #define IPF_CONTROL_REGISTER_IVR 65
5007 #define IPF_CONTROL_REGISTER_TPR 66
5008 #define IPF_CONTROL_REGISTER_EOI 67
5009 #define IPF_CONTROL_REGISTER_IRR0 68
5010 #define IPF_CONTROL_REGISTER_IRR1 69
5011 #define IPF_CONTROL_REGISTER_IRR2 70
5012 #define IPF_CONTROL_REGISTER_IRR3 71
5013 #define IPF_CONTROL_REGISTER_ITV 72
5014 #define IPF_CONTROL_REGISTER_PMV 73
5015 #define IPF_CONTROL_REGISTER_CMCV 74
5016 #define IPF_CONTROL_REGISTER_LRR0 80
5017 #define IPF_CONTROL_REGISTER_LRR1 81
5020 Reads a 64-bit control register.
5022 Reads and returns the control register specified by Index. The valid Index valued
5023 are defined above in "Related Definitions".
5024 If Index is invalid then 0xFFFFFFFFFFFFFFFF is returned. This function is only
5025 available on Itanium processors.
5027 @param Index The index of the control register to read.
5029 @return The control register specified by Index.
5034 AsmReadControlRegister (
5040 /// Valid Index value for AsmReadApplicationRegister().
5042 #define IPF_APPLICATION_REGISTER_K0 0
5043 #define IPF_APPLICATION_REGISTER_K1 1
5044 #define IPF_APPLICATION_REGISTER_K2 2
5045 #define IPF_APPLICATION_REGISTER_K3 3
5046 #define IPF_APPLICATION_REGISTER_K4 4
5047 #define IPF_APPLICATION_REGISTER_K5 5
5048 #define IPF_APPLICATION_REGISTER_K6 6
5049 #define IPF_APPLICATION_REGISTER_K7 7
5050 #define IPF_APPLICATION_REGISTER_RSC 16
5051 #define IPF_APPLICATION_REGISTER_BSP 17
5052 #define IPF_APPLICATION_REGISTER_BSPSTORE 18
5053 #define IPF_APPLICATION_REGISTER_RNAT 19
5054 #define IPF_APPLICATION_REGISTER_FCR 21
5055 #define IPF_APPLICATION_REGISTER_EFLAG 24
5056 #define IPF_APPLICATION_REGISTER_CSD 25
5057 #define IPF_APPLICATION_REGISTER_SSD 26
5058 #define IPF_APPLICATION_REGISTER_CFLG 27
5059 #define IPF_APPLICATION_REGISTER_FSR 28
5060 #define IPF_APPLICATION_REGISTER_FIR 29
5061 #define IPF_APPLICATION_REGISTER_FDR 30
5062 #define IPF_APPLICATION_REGISTER_CCV 32
5063 #define IPF_APPLICATION_REGISTER_UNAT 36
5064 #define IPF_APPLICATION_REGISTER_FPSR 40
5065 #define IPF_APPLICATION_REGISTER_ITC 44
5066 #define IPF_APPLICATION_REGISTER_PFS 64
5067 #define IPF_APPLICATION_REGISTER_LC 65
5068 #define IPF_APPLICATION_REGISTER_EC 66
5071 Reads a 64-bit application register.
5073 Reads and returns the application register specified by Index. The valid Index
5074 valued are defined above in "Related Definitions".
5075 If Index is invalid then 0xFFFFFFFFFFFFFFFF is returned. This function is only
5076 available on Itanium processors.
5078 @param Index The index of the application register to read.
5080 @return The application register specified by Index.
5085 AsmReadApplicationRegister (
5091 Reads the current value of a Machine Specific Register (MSR).
5093 Reads and returns the current value of the Machine Specific Register specified by Index. No
5094 parameter checking is performed on Index, and if the Index value is beyond the implemented MSR
5095 register range, a Reserved Register/Field fault may occur. The caller must either guarantee that
5096 Index is valid, or the caller must set up fault handlers to catch the faults. This function is
5097 only available on Itanium processors.
5099 @param Index The 8-bit Machine Specific Register index to read.
5101 @return The current value of the Machine Specific Register specified by Index.
5112 Writes the current value of a Machine Specific Register (MSR).
5114 Writes Value to the Machine Specific Register specified by Index. Value is returned. No
5115 parameter checking is performed on Index, and if the Index value is beyond the implemented MSR
5116 register range, a Reserved Register/Field fault may occur. The caller must either guarantee that
5117 Index is valid, or the caller must set up fault handlers to catch the faults. This function is
5118 only available on Itanium processors.
5120 @param Index The 8-bit Machine Specific Register index to write.
5121 @param Value The 64-bit value to write to the Machine Specific Register.
5123 @return The 64-bit value to write to the Machine Specific Register.
5135 Determines if the CPU is currently executing in virtual, physical, or mixed mode.
5137 Determines the current execution mode of the CPU.
5138 If the CPU is in virtual mode(PSR.RT=1, PSR.DT=1, PSR.IT=1), then 1 is returned.
5139 If the CPU is in physical mode(PSR.RT=0, PSR.DT=0, PSR.IT=0), then 0 is returned.
5140 If the CPU is not in physical mode or virtual mode, then it is in mixed mode,
5142 This function is only available on Itanium processors.
5144 @retval 1 The CPU is in virtual mode.
5145 @retval 0 The CPU is in physical mode.
5146 @retval -1 The CPU is in mixed mode.
5157 Makes a PAL procedure call.
5159 This is a wrapper function to make a PAL procedure call. Based on the Index
5160 value this API will make static or stacked PAL call. The following table
5161 describes the usage of PAL Procedure Index Assignment. Architected procedures
5162 may be designated as required or optional. If a PAL procedure is specified
5163 as optional, a unique return code of 0xFFFFFFFFFFFFFFFF is returned in the
5164 Status field of the PAL_CALL_RETURN structure.
5165 This indicates that the procedure is not present in this PAL implementation.
5166 It is the caller's responsibility to check for this return code after calling
5167 any optional PAL procedure.
5168 No parameter checking is performed on the 5 input parameters, but there are
5169 some common rules that the caller should follow when making a PAL call. Any
5170 address passed to PAL as buffers for return parameters must be 8-byte aligned.
5171 Unaligned addresses may cause undefined results. For those parameters defined
5172 as reserved or some fields defined as reserved must be zero filled or the invalid
5173 argument return value may be returned or undefined result may occur during the
5174 execution of the procedure. If the PalEntryPoint does not point to a valid
5175 PAL entry point then the system behavior is undefined. This function is only
5176 available on Itanium processors.
5178 @param PalEntryPoint The PAL procedure calls entry point.
5179 @param Index The PAL procedure Index number.
5180 @param Arg2 The 2nd parameter for PAL procedure calls.
5181 @param Arg3 The 3rd parameter for PAL procedure calls.
5182 @param Arg4 The 4th parameter for PAL procedure calls.
5184 @return structure returned from the PAL Call procedure, including the status and return value.
5190 IN UINT64 PalEntryPoint
,
5198 #if defined (MDE_CPU_IA32) || defined (MDE_CPU_X64)
5200 /// IA32 and x64 Specific Functions.
5201 /// Byte packed structure for 16-bit Real Mode EFLAGS.
5205 UINT32 CF
:1; ///< Carry Flag.
5206 UINT32 Reserved_0
:1; ///< Reserved.
5207 UINT32 PF
:1; ///< Parity Flag.
5208 UINT32 Reserved_1
:1; ///< Reserved.
5209 UINT32 AF
:1; ///< Auxiliary Carry Flag.
5210 UINT32 Reserved_2
:1; ///< Reserved.
5211 UINT32 ZF
:1; ///< Zero Flag.
5212 UINT32 SF
:1; ///< Sign Flag.
5213 UINT32 TF
:1; ///< Trap Flag.
5214 UINT32 IF
:1; ///< Interrupt Enable Flag.
5215 UINT32 DF
:1; ///< Direction Flag.
5216 UINT32 OF
:1; ///< Overflow Flag.
5217 UINT32 IOPL
:2; ///< I/O Privilege Level.
5218 UINT32 NT
:1; ///< Nested Task.
5219 UINT32 Reserved_3
:1; ///< Reserved.
5225 /// Byte packed structure for EFLAGS/RFLAGS.
5226 /// 32-bits on IA-32.
5227 /// 64-bits on x64. The upper 32-bits on x64 are reserved.
5231 UINT32 CF
:1; ///< Carry Flag.
5232 UINT32 Reserved_0
:1; ///< Reserved.
5233 UINT32 PF
:1; ///< Parity Flag.
5234 UINT32 Reserved_1
:1; ///< Reserved.
5235 UINT32 AF
:1; ///< Auxiliary Carry Flag.
5236 UINT32 Reserved_2
:1; ///< Reserved.
5237 UINT32 ZF
:1; ///< Zero Flag.
5238 UINT32 SF
:1; ///< Sign Flag.
5239 UINT32 TF
:1; ///< Trap Flag.
5240 UINT32 IF
:1; ///< Interrupt Enable Flag.
5241 UINT32 DF
:1; ///< Direction Flag.
5242 UINT32 OF
:1; ///< Overflow Flag.
5243 UINT32 IOPL
:2; ///< I/O Privilege Level.
5244 UINT32 NT
:1; ///< Nested Task.
5245 UINT32 Reserved_3
:1; ///< Reserved.
5246 UINT32 RF
:1; ///< Resume Flag.
5247 UINT32 VM
:1; ///< Virtual 8086 Mode.
5248 UINT32 AC
:1; ///< Alignment Check.
5249 UINT32 VIF
:1; ///< Virtual Interrupt Flag.
5250 UINT32 VIP
:1; ///< Virtual Interrupt Pending.
5251 UINT32 ID
:1; ///< ID Flag.
5252 UINT32 Reserved_4
:10; ///< Reserved.
5258 /// Byte packed structure for Control Register 0 (CR0).
5259 /// 32-bits on IA-32.
5260 /// 64-bits on x64. The upper 32-bits on x64 are reserved.
5264 UINT32 PE
:1; ///< Protection Enable.
5265 UINT32 MP
:1; ///< Monitor Coprocessor.
5266 UINT32 EM
:1; ///< Emulation.
5267 UINT32 TS
:1; ///< Task Switched.
5268 UINT32 ET
:1; ///< Extension Type.
5269 UINT32 NE
:1; ///< Numeric Error.
5270 UINT32 Reserved_0
:10; ///< Reserved.
5271 UINT32 WP
:1; ///< Write Protect.
5272 UINT32 Reserved_1
:1; ///< Reserved.
5273 UINT32 AM
:1; ///< Alignment Mask.
5274 UINT32 Reserved_2
:10; ///< Reserved.
5275 UINT32 NW
:1; ///< Mot Write-through.
5276 UINT32 CD
:1; ///< Cache Disable.
5277 UINT32 PG
:1; ///< Paging.
5283 /// Byte packed structure for Control Register 4 (CR4).
5284 /// 32-bits on IA-32.
5285 /// 64-bits on x64. The upper 32-bits on x64 are reserved.
5289 UINT32 VME
:1; ///< Virtual-8086 Mode Extensions.
5290 UINT32 PVI
:1; ///< Protected-Mode Virtual Interrupts.
5291 UINT32 TSD
:1; ///< Time Stamp Disable.
5292 UINT32 DE
:1; ///< Debugging Extensions.
5293 UINT32 PSE
:1; ///< Page Size Extensions.
5294 UINT32 PAE
:1; ///< Physical Address Extension.
5295 UINT32 MCE
:1; ///< Machine Check Enable.
5296 UINT32 PGE
:1; ///< Page Global Enable.
5297 UINT32 PCE
:1; ///< Performance Monitoring Counter
5299 UINT32 OSFXSR
:1; ///< Operating System Support for
5300 ///< FXSAVE and FXRSTOR instructions
5301 UINT32 OSXMMEXCPT
:1; ///< Operating System Support for
5302 ///< Unmasked SIMD Floating Point
5304 UINT32 Reserved_0
:2; ///< Reserved.
5305 UINT32 VMXE
:1; ///< VMX Enable
5306 UINT32 Reserved_1
:18; ///< Reserved.
5312 /// Byte packed structure for a segment descriptor in a GDT/LDT.
5331 } IA32_SEGMENT_DESCRIPTOR
;
5334 /// Byte packed structure for an IDTR, GDTR, LDTR descriptor.
5343 #define IA32_IDT_GATE_TYPE_TASK 0x85
5344 #define IA32_IDT_GATE_TYPE_INTERRUPT_16 0x86
5345 #define IA32_IDT_GATE_TYPE_TRAP_16 0x87
5346 #define IA32_IDT_GATE_TYPE_INTERRUPT_32 0x8E
5347 #define IA32_IDT_GATE_TYPE_TRAP_32 0x8F
5350 #if defined (MDE_CPU_IA32)
5352 /// Byte packed structure for an IA-32 Interrupt Gate Descriptor.
5356 UINT32 OffsetLow
:16; ///< Offset bits 15..0.
5357 UINT32 Selector
:16; ///< Selector.
5358 UINT32 Reserved_0
:8; ///< Reserved.
5359 UINT32 GateType
:8; ///< Gate Type. See #defines above.
5360 UINT32 OffsetHigh
:16; ///< Offset bits 31..16.
5363 } IA32_IDT_GATE_DESCRIPTOR
;
5367 #if defined (MDE_CPU_X64)
5369 /// Byte packed structure for an x64 Interrupt Gate Descriptor.
5373 UINT32 OffsetLow
:16; ///< Offset bits 15..0.
5374 UINT32 Selector
:16; ///< Selector.
5375 UINT32 Reserved_0
:8; ///< Reserved.
5376 UINT32 GateType
:8; ///< Gate Type. See #defines above.
5377 UINT32 OffsetHigh
:16; ///< Offset bits 31..16.
5378 UINT32 OffsetUpper
:32; ///< Offset bits 63..32.
5379 UINT32 Reserved_1
:32; ///< Reserved.
5385 } IA32_IDT_GATE_DESCRIPTOR
;
5390 /// Byte packed structure for an FP/SSE/SSE2 context.
5397 /// Structures for the 16-bit real mode thunks.
5450 IA32_EFLAGS32 EFLAGS
;
5460 } IA32_REGISTER_SET
;
5463 /// Byte packed structure for an 16-bit real mode thunks.
5466 IA32_REGISTER_SET
*RealModeState
;
5467 VOID
*RealModeBuffer
;
5468 UINT32 RealModeBufferSize
;
5469 UINT32 ThunkAttributes
;
5472 #define THUNK_ATTRIBUTE_BIG_REAL_MODE 0x00000001
5473 #define THUNK_ATTRIBUTE_DISABLE_A20_MASK_INT_15 0x00000002
5474 #define THUNK_ATTRIBUTE_DISABLE_A20_MASK_KBD_CTRL 0x00000004
5477 Retrieves CPUID information.
5479 Executes the CPUID instruction with EAX set to the value specified by Index.
5480 This function always returns Index.
5481 If Eax is not NULL, then the value of EAX after CPUID is returned in Eax.
5482 If Ebx is not NULL, then the value of EBX after CPUID is returned in Ebx.
5483 If Ecx is not NULL, then the value of ECX after CPUID is returned in Ecx.
5484 If Edx is not NULL, then the value of EDX after CPUID is returned in Edx.
5485 This function is only available on IA-32 and x64.
5487 @param Index The 32-bit value to load into EAX prior to invoking the CPUID
5489 @param Eax The pointer to the 32-bit EAX value returned by the CPUID
5490 instruction. This is an optional parameter that may be NULL.
5491 @param Ebx The pointer to the 32-bit EBX value returned by the CPUID
5492 instruction. This is an optional parameter that may be NULL.
5493 @param Ecx The pointer to the 32-bit ECX value returned by the CPUID
5494 instruction. This is an optional parameter that may be NULL.
5495 @param Edx The pointer to the 32-bit EDX value returned by the CPUID
5496 instruction. This is an optional parameter that may be NULL.
5505 OUT UINT32
*Eax
, OPTIONAL
5506 OUT UINT32
*Ebx
, OPTIONAL
5507 OUT UINT32
*Ecx
, OPTIONAL
5508 OUT UINT32
*Edx OPTIONAL
5513 Retrieves CPUID information using an extended leaf identifier.
5515 Executes the CPUID instruction with EAX set to the value specified by Index
5516 and ECX set to the value specified by SubIndex. This function always returns
5517 Index. This function is only available on IA-32 and x64.
5519 If Eax is not NULL, then the value of EAX after CPUID is returned in Eax.
5520 If Ebx is not NULL, then the value of EBX after CPUID is returned in Ebx.
5521 If Ecx is not NULL, then the value of ECX after CPUID is returned in Ecx.
5522 If Edx is not NULL, then the value of EDX after CPUID is returned in Edx.
5524 @param Index The 32-bit value to load into EAX prior to invoking the
5526 @param SubIndex The 32-bit value to load into ECX prior to invoking the
5528 @param Eax The pointer to the 32-bit EAX value returned by the CPUID
5529 instruction. This is an optional parameter that may be
5531 @param Ebx The pointer to the 32-bit EBX value returned by the CPUID
5532 instruction. This is an optional parameter that may be
5534 @param Ecx The pointer to the 32-bit ECX value returned by the CPUID
5535 instruction. This is an optional parameter that may be
5537 @param Edx The pointer to the 32-bit EDX value returned by the CPUID
5538 instruction. This is an optional parameter that may be
5549 OUT UINT32
*Eax
, OPTIONAL
5550 OUT UINT32
*Ebx
, OPTIONAL
5551 OUT UINT32
*Ecx
, OPTIONAL
5552 OUT UINT32
*Edx OPTIONAL
5557 Set CD bit and clear NW bit of CR0 followed by a WBINVD.
5559 Disables the caches by setting the CD bit of CR0 to 1, clearing the NW bit of CR0 to 0,
5560 and executing a WBINVD instruction. This function is only available on IA-32 and x64.
5571 Perform a WBINVD and clear both the CD and NW bits of CR0.
5573 Enables the caches by executing a WBINVD instruction and then clear both the CD and NW
5574 bits of CR0 to 0. This function is only available on IA-32 and x64.
5585 Returns the lower 32-bits of a Machine Specific Register(MSR).
5587 Reads and returns the lower 32-bits of the MSR specified by Index.
5588 No parameter checking is performed on Index, and some Index values may cause
5589 CPU exceptions. The caller must either guarantee that Index is valid, or the
5590 caller must set up exception handlers to catch the exceptions. This function
5591 is only available on IA-32 and x64.
5593 @param Index The 32-bit MSR index to read.
5595 @return The lower 32 bits of the MSR identified by Index.
5606 Writes a 32-bit value to a Machine Specific Register(MSR), and returns the value.
5607 The upper 32-bits of the MSR are set to zero.
5609 Writes the 32-bit value specified by Value to the MSR specified by Index. The
5610 upper 32-bits of the MSR write are set to zero. The 32-bit value written to
5611 the MSR is returned. No parameter checking is performed on Index or Value,
5612 and some of these may cause CPU exceptions. The caller must either guarantee
5613 that Index and Value are valid, or the caller must establish proper exception
5614 handlers. This function is only available on IA-32 and x64.
5616 @param Index The 32-bit MSR index to write.
5617 @param Value The 32-bit value to write to the MSR.
5631 Reads a 64-bit MSR, performs a bitwise OR on the lower 32-bits, and
5632 writes the result back to the 64-bit MSR.
5634 Reads the 64-bit MSR specified by Index, performs a bitwise OR
5635 between the lower 32-bits of the read result and the value specified by
5636 OrData, and writes the result to the 64-bit MSR specified by Index. The lower
5637 32-bits of the value written to the MSR is returned. No parameter checking is
5638 performed on Index or OrData, and some of these may cause CPU exceptions. The
5639 caller must either guarantee that Index and OrData are valid, or the caller
5640 must establish proper exception handlers. This function is only available on
5643 @param Index The 32-bit MSR index to write.
5644 @param OrData The value to OR with the read value from the MSR.
5646 @return The lower 32-bit value written to the MSR.
5658 Reads a 64-bit MSR, performs a bitwise AND on the lower 32-bits, and writes
5659 the result back to the 64-bit MSR.
5661 Reads the 64-bit MSR specified by Index, performs a bitwise AND between the
5662 lower 32-bits of the read result and the value specified by AndData, and
5663 writes the result to the 64-bit MSR specified by Index. The lower 32-bits of
5664 the value written to the MSR is returned. No parameter checking is performed
5665 on Index or AndData, and some of these may cause CPU exceptions. The caller
5666 must either guarantee that Index and AndData are valid, or the caller must
5667 establish proper exception handlers. This function is only available on IA-32
5670 @param Index The 32-bit MSR index to write.
5671 @param AndData The value to AND with the read value from the MSR.
5673 @return The lower 32-bit value written to the MSR.
5685 Reads a 64-bit MSR, performs a bitwise AND followed by a bitwise OR
5686 on the lower 32-bits, and writes the result back to the 64-bit MSR.
5688 Reads the 64-bit MSR specified by Index, performs a bitwise AND between the
5689 lower 32-bits of the read result and the value specified by AndData
5690 preserving the upper 32-bits, performs a bitwise OR between the
5691 result of the AND operation and the value specified by OrData, and writes the
5692 result to the 64-bit MSR specified by Address. The lower 32-bits of the value
5693 written to the MSR is returned. No parameter checking is performed on Index,
5694 AndData, or OrData, and some of these may cause CPU exceptions. The caller
5695 must either guarantee that Index, AndData, and OrData are valid, or the
5696 caller must establish proper exception handlers. This function is only
5697 available on IA-32 and x64.
5699 @param Index The 32-bit MSR index to write.
5700 @param AndData The value to AND with the read value from the MSR.
5701 @param OrData The value to OR with the result of the AND operation.
5703 @return The lower 32-bit value written to the MSR.
5716 Reads a bit field of an MSR.
5718 Reads the bit field in the lower 32-bits of a 64-bit MSR. The bit field is
5719 specified by the StartBit and the EndBit. The value of the bit field is
5720 returned. The caller must either guarantee that Index is valid, or the caller
5721 must set up exception handlers to catch the exceptions. This function is only
5722 available on IA-32 and x64.
5724 If StartBit is greater than 31, then ASSERT().
5725 If EndBit is greater than 31, then ASSERT().
5726 If EndBit is less than StartBit, then ASSERT().
5728 @param Index The 32-bit MSR index to read.
5729 @param StartBit The ordinal of the least significant bit in the bit field.
5731 @param EndBit The ordinal of the most significant bit in the bit field.
5734 @return The bit field read from the MSR.
5739 AsmMsrBitFieldRead32 (
5747 Writes a bit field to an MSR.
5749 Writes Value to a bit field in the lower 32-bits of a 64-bit MSR. The bit
5750 field is specified by the StartBit and the EndBit. All other bits in the
5751 destination MSR are preserved. The lower 32-bits of the MSR written is
5752 returned. The caller must either guarantee that Index and the data written
5753 is valid, or the caller must set up exception handlers to catch the exceptions.
5754 This function is only available on IA-32 and x64.
5756 If StartBit is greater than 31, then ASSERT().
5757 If EndBit is greater than 31, then ASSERT().
5758 If EndBit is less than StartBit, then ASSERT().
5759 If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
5761 @param Index The 32-bit MSR index to write.
5762 @param StartBit The ordinal of the least significant bit in the bit field.
5764 @param EndBit The ordinal of the most significant bit in the bit field.
5766 @param Value New value of the bit field.
5768 @return The lower 32-bit of the value written to the MSR.
5773 AsmMsrBitFieldWrite32 (
5782 Reads a bit field in a 64-bit MSR, performs a bitwise OR, and writes the
5783 result back to the bit field in the 64-bit MSR.
5785 Reads the 64-bit MSR specified by Index, performs a bitwise OR
5786 between the read result and the value specified by OrData, and writes the
5787 result to the 64-bit MSR specified by Index. The lower 32-bits of the value
5788 written to the MSR are returned. Extra left bits in OrData are stripped. The
5789 caller must either guarantee that Index and the data written is valid, or
5790 the caller must set up exception handlers to catch the exceptions. This
5791 function is only available on IA-32 and x64.
5793 If StartBit is greater than 31, then ASSERT().
5794 If EndBit is greater than 31, then ASSERT().
5795 If EndBit is less than StartBit, then ASSERT().
5796 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
5798 @param Index The 32-bit MSR index to write.
5799 @param StartBit The ordinal of the least significant bit in the bit field.
5801 @param EndBit The ordinal of the most significant bit in the bit field.
5803 @param OrData The value to OR with the read value from the MSR.
5805 @return The lower 32-bit of the value written to the MSR.
5810 AsmMsrBitFieldOr32 (
5819 Reads a bit field in a 64-bit MSR, performs a bitwise AND, and writes the
5820 result back to the bit field in the 64-bit MSR.
5822 Reads the 64-bit MSR specified by Index, performs a bitwise AND between the
5823 read result and the value specified by AndData, and writes the result to the
5824 64-bit MSR specified by Index. The lower 32-bits of the value written to the
5825 MSR are returned. Extra left bits in AndData are stripped. The caller must
5826 either guarantee that Index and the data written is valid, or the caller must
5827 set up exception handlers to catch the exceptions. This function is only
5828 available on IA-32 and x64.
5830 If StartBit is greater than 31, then ASSERT().
5831 If EndBit is greater than 31, then ASSERT().
5832 If EndBit is less than StartBit, then ASSERT().
5833 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
5835 @param Index The 32-bit MSR index to write.
5836 @param StartBit The ordinal of the least significant bit in the bit field.
5838 @param EndBit The ordinal of the most significant bit in the bit field.
5840 @param AndData The value to AND with the read value from the MSR.
5842 @return The lower 32-bit of the value written to the MSR.
5847 AsmMsrBitFieldAnd32 (
5856 Reads a bit field in a 64-bit MSR, performs a bitwise AND followed by a
5857 bitwise OR, and writes the result back to the bit field in the
5860 Reads the 64-bit MSR specified by Index, performs a bitwise AND followed by a
5861 bitwise OR between the read result and the value specified by
5862 AndData, and writes the result to the 64-bit MSR specified by Index. The
5863 lower 32-bits of the value written to the MSR are returned. Extra left bits
5864 in both AndData and OrData are stripped. The caller must either guarantee
5865 that Index and the data written is valid, or the caller must set up exception
5866 handlers to catch the exceptions. This function is only available on IA-32
5869 If StartBit is greater than 31, then ASSERT().
5870 If EndBit is greater than 31, then ASSERT().
5871 If EndBit is less than StartBit, then ASSERT().
5872 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
5873 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
5875 @param Index The 32-bit MSR index to write.
5876 @param StartBit The ordinal of the least significant bit in the bit field.
5878 @param EndBit The ordinal of the most significant bit in the bit field.
5880 @param AndData The value to AND with the read value from the MSR.
5881 @param OrData The value to OR with the result of the AND operation.
5883 @return The lower 32-bit of the value written to the MSR.
5888 AsmMsrBitFieldAndThenOr32 (
5898 Returns a 64-bit Machine Specific Register(MSR).
5900 Reads and returns the 64-bit MSR specified by Index. No parameter checking is
5901 performed on Index, and some Index values may cause CPU exceptions. The
5902 caller must either guarantee that Index is valid, or the caller must set up
5903 exception handlers to catch the exceptions. This function is only available
5906 @param Index The 32-bit MSR index to read.
5908 @return The value of the MSR identified by Index.
5919 Writes a 64-bit value to a Machine Specific Register(MSR), and returns the
5922 Writes the 64-bit value specified by Value to the MSR specified by Index. The
5923 64-bit value written to the MSR is returned. No parameter checking is
5924 performed on Index or Value, and some of these may cause CPU exceptions. The
5925 caller must either guarantee that Index and Value are valid, or the caller
5926 must establish proper exception handlers. This function is only available on
5929 @param Index The 32-bit MSR index to write.
5930 @param Value The 64-bit value to write to the MSR.
5944 Reads a 64-bit MSR, performs a bitwise OR, and writes the result
5945 back to the 64-bit MSR.
5947 Reads the 64-bit MSR specified by Index, performs a bitwise OR
5948 between the read result and the value specified by OrData, and writes the
5949 result to the 64-bit MSR specified by Index. The value written to the MSR is
5950 returned. No parameter checking is performed on Index or OrData, and some of
5951 these may cause CPU exceptions. The caller must either guarantee that Index
5952 and OrData are valid, or the caller must establish proper exception handlers.
5953 This function is only available on IA-32 and x64.
5955 @param Index The 32-bit MSR index to write.
5956 @param OrData The value to OR with the read value from the MSR.
5958 @return The value written back to the MSR.
5970 Reads a 64-bit MSR, performs a bitwise AND, and writes the result back to the
5973 Reads the 64-bit MSR specified by Index, performs a bitwise AND between the
5974 read result and the value specified by OrData, and writes the result to the
5975 64-bit MSR specified by Index. The value written to the MSR is returned. No
5976 parameter checking is performed on Index or OrData, and some of these may
5977 cause CPU exceptions. The caller must either guarantee that Index and OrData
5978 are valid, or the caller must establish proper exception handlers. This
5979 function is only available on IA-32 and x64.
5981 @param Index The 32-bit MSR index to write.
5982 @param AndData The value to AND with the read value from the MSR.
5984 @return The value written back to the MSR.
5996 Reads a 64-bit MSR, performs a bitwise AND followed by a bitwise
5997 OR, and writes the result back to the 64-bit MSR.
5999 Reads the 64-bit MSR specified by Index, performs a bitwise AND between read
6000 result and the value specified by AndData, performs a bitwise OR
6001 between the result of the AND operation and the value specified by OrData,
6002 and writes the result to the 64-bit MSR specified by Index. The value written
6003 to the MSR is returned. No parameter checking is performed on Index, AndData,
6004 or OrData, and some of these may cause CPU exceptions. The caller must either
6005 guarantee that Index, AndData, and OrData are valid, or the caller must
6006 establish proper exception handlers. This function is only available on IA-32
6009 @param Index The 32-bit MSR index to write.
6010 @param AndData The value to AND with the read value from the MSR.
6011 @param OrData The value to OR with the result of the AND operation.
6013 @return The value written back to the MSR.
6026 Reads a bit field of an MSR.
6028 Reads the bit field in the 64-bit MSR. The bit field is specified by the
6029 StartBit and the EndBit. The value of the bit field is returned. The caller
6030 must either guarantee that Index is valid, or the caller must set up
6031 exception handlers to catch the exceptions. This function is only available
6034 If StartBit is greater than 63, then ASSERT().
6035 If EndBit is greater than 63, then ASSERT().
6036 If EndBit is less than StartBit, then ASSERT().
6038 @param Index The 32-bit MSR index to read.
6039 @param StartBit The ordinal of the least significant bit in the bit field.
6041 @param EndBit The ordinal of the most significant bit in the bit field.
6044 @return The value read from the MSR.
6049 AsmMsrBitFieldRead64 (
6057 Writes a bit field to an MSR.
6059 Writes Value to a bit field in a 64-bit MSR. The bit field is specified by
6060 the StartBit and the EndBit. All other bits in the destination MSR are
6061 preserved. The MSR written is returned. The caller must either guarantee
6062 that Index and the data written is valid, or the caller must set up exception
6063 handlers to catch the exceptions. This function is only available on IA-32 and x64.
6065 If StartBit is greater than 63, then ASSERT().
6066 If EndBit is greater than 63, then ASSERT().
6067 If EndBit is less than StartBit, then ASSERT().
6068 If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
6070 @param Index The 32-bit MSR index to write.
6071 @param StartBit The ordinal of the least significant bit in the bit field.
6073 @param EndBit The ordinal of the most significant bit in the bit field.
6075 @param Value New value of the bit field.
6077 @return The value written back to the MSR.
6082 AsmMsrBitFieldWrite64 (
6091 Reads a bit field in a 64-bit MSR, performs a bitwise OR, and
6092 writes the result back to the bit field in the 64-bit MSR.
6094 Reads the 64-bit MSR specified by Index, performs a bitwise OR
6095 between the read result and the value specified by OrData, and writes the
6096 result to the 64-bit MSR specified by Index. The value written to the MSR is
6097 returned. Extra left bits in OrData are stripped. The caller must either
6098 guarantee that Index and the data written is valid, or the caller must set up
6099 exception handlers to catch the exceptions. This function is only available
6102 If StartBit is greater than 63, then ASSERT().
6103 If EndBit is greater than 63, then ASSERT().
6104 If EndBit is less than StartBit, then ASSERT().
6105 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
6107 @param Index The 32-bit MSR index to write.
6108 @param StartBit The ordinal of the least significant bit in the bit field.
6110 @param EndBit The ordinal of the most significant bit in the bit field.
6112 @param OrData The value to OR with the read value from the bit field.
6114 @return The value written back to the MSR.
6119 AsmMsrBitFieldOr64 (
6128 Reads a bit field in a 64-bit MSR, performs a bitwise AND, and writes the
6129 result back to the bit field in the 64-bit MSR.
6131 Reads the 64-bit MSR specified by Index, performs a bitwise AND between the
6132 read result and the value specified by AndData, and writes the result to the
6133 64-bit MSR specified by Index. The value written to the MSR is returned.
6134 Extra left bits in AndData are stripped. The caller must either guarantee
6135 that Index and the data written is valid, or the caller must set up exception
6136 handlers to catch the exceptions. This function is only available on IA-32
6139 If StartBit is greater than 63, then ASSERT().
6140 If EndBit is greater than 63, then ASSERT().
6141 If EndBit is less than StartBit, then ASSERT().
6142 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
6144 @param Index The 32-bit MSR index to write.
6145 @param StartBit The ordinal of the least significant bit in the bit field.
6147 @param EndBit The ordinal of the most significant bit in the bit field.
6149 @param AndData The value to AND with the read value from the bit field.
6151 @return The value written back to the MSR.
6156 AsmMsrBitFieldAnd64 (
6165 Reads a bit field in a 64-bit MSR, performs a bitwise AND followed by a
6166 bitwise OR, and writes the result back to the bit field in the
6169 Reads the 64-bit MSR specified by Index, performs a bitwise AND followed by
6170 a bitwise OR between the read result and the value specified by
6171 AndData, and writes the result to the 64-bit MSR specified by Index. The
6172 value written to the MSR is returned. Extra left bits in both AndData and
6173 OrData are stripped. The caller must either guarantee that Index and the data
6174 written is valid, or the caller must set up exception handlers to catch the
6175 exceptions. This function is only available on IA-32 and x64.
6177 If StartBit is greater than 63, then ASSERT().
6178 If EndBit is greater than 63, then ASSERT().
6179 If EndBit is less than StartBit, then ASSERT().
6180 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
6181 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
6183 @param Index The 32-bit MSR index to write.
6184 @param StartBit The ordinal of the least significant bit in the bit field.
6186 @param EndBit The ordinal of the most significant bit in the bit field.
6188 @param AndData The value to AND with the read value from the bit field.
6189 @param OrData The value to OR with the result of the AND operation.
6191 @return The value written back to the MSR.
6196 AsmMsrBitFieldAndThenOr64 (
6206 Reads the current value of the EFLAGS register.
6208 Reads and returns the current value of the EFLAGS register. This function is
6209 only available on IA-32 and x64. This returns a 32-bit value on IA-32 and a
6210 64-bit value on x64.
6212 @return EFLAGS on IA-32 or RFLAGS on x64.
6223 Reads the current value of the Control Register 0 (CR0).
6225 Reads and returns the current value of CR0. This function is only available
6226 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
6229 @return The value of the Control Register 0 (CR0).
6240 Reads the current value of the Control Register 2 (CR2).
6242 Reads and returns the current value of CR2. This function is only available
6243 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
6246 @return The value of the Control Register 2 (CR2).
6257 Reads the current value of the Control Register 3 (CR3).
6259 Reads and returns the current value of CR3. This function is only available
6260 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
6263 @return The value of the Control Register 3 (CR3).
6274 Reads the current value of the Control Register 4 (CR4).
6276 Reads and returns the current value of CR4. This function is only available
6277 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
6280 @return The value of the Control Register 4 (CR4).
6291 Writes a value to Control Register 0 (CR0).
6293 Writes and returns a new value to CR0. This function is only available on
6294 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
6296 @param Cr0 The value to write to CR0.
6298 @return The value written to CR0.
6309 Writes a value to Control Register 2 (CR2).
6311 Writes and returns a new value to CR2. This function is only available on
6312 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
6314 @param Cr2 The value to write to CR2.
6316 @return The value written to CR2.
6327 Writes a value to Control Register 3 (CR3).
6329 Writes and returns a new value to CR3. This function is only available on
6330 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
6332 @param Cr3 The value to write to CR3.
6334 @return The value written to CR3.
6345 Writes a value to Control Register 4 (CR4).
6347 Writes and returns a new value to CR4. This function is only available on
6348 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
6350 @param Cr4 The value to write to CR4.
6352 @return The value written to CR4.
6363 Reads the current value of Debug Register 0 (DR0).
6365 Reads and returns the current value of DR0. This function is only available
6366 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
6369 @return The value of Debug Register 0 (DR0).
6380 Reads the current value of Debug Register 1 (DR1).
6382 Reads and returns the current value of DR1. This function is only available
6383 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
6386 @return The value of Debug Register 1 (DR1).
6397 Reads the current value of Debug Register 2 (DR2).
6399 Reads and returns the current value of DR2. This function is only available
6400 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
6403 @return The value of Debug Register 2 (DR2).
6414 Reads the current value of Debug Register 3 (DR3).
6416 Reads and returns the current value of DR3. This function is only available
6417 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
6420 @return The value of Debug Register 3 (DR3).
6431 Reads the current value of Debug Register 4 (DR4).
6433 Reads and returns the current value of DR4. This function is only available
6434 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
6437 @return The value of Debug Register 4 (DR4).
6448 Reads the current value of Debug Register 5 (DR5).
6450 Reads and returns the current value of DR5. This function is only available
6451 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
6454 @return The value of Debug Register 5 (DR5).
6465 Reads the current value of Debug Register 6 (DR6).
6467 Reads and returns the current value of DR6. This function is only available
6468 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
6471 @return The value of Debug Register 6 (DR6).
6482 Reads the current value of Debug Register 7 (DR7).
6484 Reads and returns the current value of DR7. This function is only available
6485 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
6488 @return The value of Debug Register 7 (DR7).
6499 Writes a value to Debug Register 0 (DR0).
6501 Writes and returns a new value to DR0. This function is only available on
6502 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
6504 @param Dr0 The value to write to Dr0.
6506 @return The value written to Debug Register 0 (DR0).
6517 Writes a value to Debug Register 1 (DR1).
6519 Writes and returns a new value to DR1. This function is only available on
6520 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
6522 @param Dr1 The value to write to Dr1.
6524 @return The value written to Debug Register 1 (DR1).
6535 Writes a value to Debug Register 2 (DR2).
6537 Writes and returns a new value to DR2. This function is only available on
6538 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
6540 @param Dr2 The value to write to Dr2.
6542 @return The value written to Debug Register 2 (DR2).
6553 Writes a value to Debug Register 3 (DR3).
6555 Writes and returns a new value to DR3. This function is only available on
6556 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
6558 @param Dr3 The value to write to Dr3.
6560 @return The value written to Debug Register 3 (DR3).
6571 Writes a value to Debug Register 4 (DR4).
6573 Writes and returns a new value to DR4. This function is only available on
6574 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
6576 @param Dr4 The value to write to Dr4.
6578 @return The value written to Debug Register 4 (DR4).
6589 Writes a value to Debug Register 5 (DR5).
6591 Writes and returns a new value to DR5. This function is only available on
6592 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
6594 @param Dr5 The value to write to Dr5.
6596 @return The value written to Debug Register 5 (DR5).
6607 Writes a value to Debug Register 6 (DR6).
6609 Writes and returns a new value to DR6. This function is only available on
6610 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
6612 @param Dr6 The value to write to Dr6.
6614 @return The value written to Debug Register 6 (DR6).
6625 Writes a value to Debug Register 7 (DR7).
6627 Writes and returns a new value to DR7. This function is only available on
6628 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
6630 @param Dr7 The value to write to Dr7.
6632 @return The value written to Debug Register 7 (DR7).
6643 Reads the current value of Code Segment Register (CS).
6645 Reads and returns the current value of CS. This function is only available on
6648 @return The current value of CS.
6659 Reads the current value of Data Segment Register (DS).
6661 Reads and returns the current value of DS. This function is only available on
6664 @return The current value of DS.
6675 Reads the current value of Extra Segment Register (ES).
6677 Reads and returns the current value of ES. This function is only available on
6680 @return The current value of ES.
6691 Reads the current value of FS Data Segment Register (FS).
6693 Reads and returns the current value of FS. This function is only available on
6696 @return The current value of FS.
6707 Reads the current value of GS Data Segment Register (GS).
6709 Reads and returns the current value of GS. This function is only available on
6712 @return The current value of GS.
6723 Reads the current value of Stack Segment Register (SS).
6725 Reads and returns the current value of SS. This function is only available on
6728 @return The current value of SS.
6739 Reads the current value of Task Register (TR).
6741 Reads and returns the current value of TR. This function is only available on
6744 @return The current value of TR.
6755 Reads the current Global Descriptor Table Register(GDTR) descriptor.
6757 Reads and returns the current GDTR descriptor and returns it in Gdtr. This
6758 function is only available on IA-32 and x64.
6760 If Gdtr is NULL, then ASSERT().
6762 @param Gdtr The pointer to a GDTR descriptor.
6768 OUT IA32_DESCRIPTOR
*Gdtr
6773 Writes the current Global Descriptor Table Register (GDTR) descriptor.
6775 Writes and the current GDTR descriptor specified by Gdtr. This function is
6776 only available on IA-32 and x64.
6778 If Gdtr is NULL, then ASSERT().
6780 @param Gdtr The pointer to a GDTR descriptor.
6786 IN CONST IA32_DESCRIPTOR
*Gdtr
6791 Reads the current Interrupt Descriptor Table Register(IDTR) descriptor.
6793 Reads and returns the current IDTR descriptor and returns it in Idtr. This
6794 function is only available on IA-32 and x64.
6796 If Idtr is NULL, then ASSERT().
6798 @param Idtr The pointer to a IDTR descriptor.
6804 OUT IA32_DESCRIPTOR
*Idtr
6809 Writes the current Interrupt Descriptor Table Register(IDTR) descriptor.
6811 Writes the current IDTR descriptor and returns it in Idtr. This function is
6812 only available on IA-32 and x64.
6814 If Idtr is NULL, then ASSERT().
6816 @param Idtr The pointer to a IDTR descriptor.
6822 IN CONST IA32_DESCRIPTOR
*Idtr
6827 Reads the current Local Descriptor Table Register(LDTR) selector.
6829 Reads and returns the current 16-bit LDTR descriptor value. This function is
6830 only available on IA-32 and x64.
6832 @return The current selector of LDT.
6843 Writes the current Local Descriptor Table Register (LDTR) selector.
6845 Writes and the current LDTR descriptor specified by Ldtr. This function is
6846 only available on IA-32 and x64.
6848 @param Ldtr 16-bit LDTR selector value.
6859 Save the current floating point/SSE/SSE2 context to a buffer.
6861 Saves the current floating point/SSE/SSE2 state to the buffer specified by
6862 Buffer. Buffer must be aligned on a 16-byte boundary. This function is only
6863 available on IA-32 and x64.
6865 If Buffer is NULL, then ASSERT().
6866 If Buffer is not aligned on a 16-byte boundary, then ASSERT().
6868 @param Buffer The pointer to a buffer to save the floating point/SSE/SSE2 context.
6874 OUT IA32_FX_BUFFER
*Buffer
6879 Restores the current floating point/SSE/SSE2 context from a buffer.
6881 Restores the current floating point/SSE/SSE2 state from the buffer specified
6882 by Buffer. Buffer must be aligned on a 16-byte boundary. This function is
6883 only available on IA-32 and x64.
6885 If Buffer is NULL, then ASSERT().
6886 If Buffer is not aligned on a 16-byte boundary, then ASSERT().
6887 If Buffer was not saved with AsmFxSave(), then ASSERT().
6889 @param Buffer The pointer to a buffer to save the floating point/SSE/SSE2 context.
6895 IN CONST IA32_FX_BUFFER
*Buffer
6900 Reads the current value of 64-bit MMX Register #0 (MM0).
6902 Reads and returns the current value of MM0. This function is only available
6905 @return The current value of MM0.
6916 Reads the current value of 64-bit MMX Register #1 (MM1).
6918 Reads and returns the current value of MM1. This function is only available
6921 @return The current value of MM1.
6932 Reads the current value of 64-bit MMX Register #2 (MM2).
6934 Reads and returns the current value of MM2. This function is only available
6937 @return The current value of MM2.
6948 Reads the current value of 64-bit MMX Register #3 (MM3).
6950 Reads and returns the current value of MM3. This function is only available
6953 @return The current value of MM3.
6964 Reads the current value of 64-bit MMX Register #4 (MM4).
6966 Reads and returns the current value of MM4. This function is only available
6969 @return The current value of MM4.
6980 Reads the current value of 64-bit MMX Register #5 (MM5).
6982 Reads and returns the current value of MM5. This function is only available
6985 @return The current value of MM5.
6996 Reads the current value of 64-bit MMX Register #6 (MM6).
6998 Reads and returns the current value of MM6. This function is only available
7001 @return The current value of MM6.
7012 Reads the current value of 64-bit MMX Register #7 (MM7).
7014 Reads and returns the current value of MM7. This function is only available
7017 @return The current value of MM7.
7028 Writes the current value of 64-bit MMX Register #0 (MM0).
7030 Writes the current value of MM0. This function is only available on IA32 and
7033 @param Value The 64-bit value to write to MM0.
7044 Writes the current value of 64-bit MMX Register #1 (MM1).
7046 Writes the current value of MM1. This function is only available on IA32 and
7049 @param Value The 64-bit value to write to MM1.
7060 Writes the current value of 64-bit MMX Register #2 (MM2).
7062 Writes the current value of MM2. This function is only available on IA32 and
7065 @param Value The 64-bit value to write to MM2.
7076 Writes the current value of 64-bit MMX Register #3 (MM3).
7078 Writes the current value of MM3. This function is only available on IA32 and
7081 @param Value The 64-bit value to write to MM3.
7092 Writes the current value of 64-bit MMX Register #4 (MM4).
7094 Writes the current value of MM4. This function is only available on IA32 and
7097 @param Value The 64-bit value to write to MM4.
7108 Writes the current value of 64-bit MMX Register #5 (MM5).
7110 Writes the current value of MM5. This function is only available on IA32 and
7113 @param Value The 64-bit value to write to MM5.
7124 Writes the current value of 64-bit MMX Register #6 (MM6).
7126 Writes the current value of MM6. This function is only available on IA32 and
7129 @param Value The 64-bit value to write to MM6.
7140 Writes the current value of 64-bit MMX Register #7 (MM7).
7142 Writes the current value of MM7. This function is only available on IA32 and
7145 @param Value The 64-bit value to write to MM7.
7156 Reads the current value of Time Stamp Counter (TSC).
7158 Reads and returns the current value of TSC. This function is only available
7161 @return The current value of TSC
7172 Reads the current value of a Performance Counter (PMC).
7174 Reads and returns the current value of performance counter specified by
7175 Index. This function is only available on IA-32 and x64.
7177 @param Index The 32-bit Performance Counter index to read.
7179 @return The value of the PMC specified by Index.
7190 Sets up a monitor buffer that is used by AsmMwait().
7192 Executes a MONITOR instruction with the register state specified by Eax, Ecx
7193 and Edx. Returns Eax. This function is only available on IA-32 and x64.
7195 @param Eax The value to load into EAX or RAX before executing the MONITOR
7197 @param Ecx The value to load into ECX or RCX before executing the MONITOR
7199 @param Edx The value to load into EDX or RDX before executing the MONITOR
7215 Executes an MWAIT instruction.
7217 Executes an MWAIT instruction with the register state specified by Eax and
7218 Ecx. Returns Eax. This function is only available on IA-32 and x64.
7220 @param Eax The value to load into EAX or RAX before executing the MONITOR
7222 @param Ecx The value to load into ECX or RCX before executing the MONITOR
7237 Executes a WBINVD instruction.
7239 Executes a WBINVD instruction. This function is only available on IA-32 and
7251 Executes a INVD instruction.
7253 Executes a INVD instruction. This function is only available on IA-32 and
7265 Flushes a cache line from all the instruction and data caches within the
7266 coherency domain of the CPU.
7268 Flushed the cache line specified by LinearAddress, and returns LinearAddress.
7269 This function is only available on IA-32 and x64.
7271 @param LinearAddress The address of the cache line to flush. If the CPU is
7272 in a physical addressing mode, then LinearAddress is a
7273 physical address. If the CPU is in a virtual
7274 addressing mode, then LinearAddress is a virtual
7277 @return LinearAddress.
7282 IN VOID
*LinearAddress
7287 Enables the 32-bit paging mode on the CPU.
7289 Enables the 32-bit paging mode on the CPU. CR0, CR3, CR4, and the page tables
7290 must be properly initialized prior to calling this service. This function
7291 assumes the current execution mode is 32-bit protected mode. This function is
7292 only available on IA-32. After the 32-bit paging mode is enabled, control is
7293 transferred to the function specified by EntryPoint using the new stack
7294 specified by NewStack and passing in the parameters specified by Context1 and
7295 Context2. Context1 and Context2 are optional and may be NULL. The function
7296 EntryPoint must never return.
7298 If the current execution mode is not 32-bit protected mode, then ASSERT().
7299 If EntryPoint is NULL, then ASSERT().
7300 If NewStack is NULL, then ASSERT().
7302 There are a number of constraints that must be followed before calling this
7304 1) Interrupts must be disabled.
7305 2) The caller must be in 32-bit protected mode with flat descriptors. This
7306 means all descriptors must have a base of 0 and a limit of 4GB.
7307 3) CR0 and CR4 must be compatible with 32-bit protected mode with flat
7309 4) CR3 must point to valid page tables that will be used once the transition
7310 is complete, and those page tables must guarantee that the pages for this
7311 function and the stack are identity mapped.
7313 @param EntryPoint A pointer to function to call with the new stack after
7315 @param Context1 A pointer to the context to pass into the EntryPoint
7316 function as the first parameter after paging is enabled.
7317 @param Context2 A pointer to the context to pass into the EntryPoint
7318 function as the second parameter after paging is enabled.
7319 @param NewStack A pointer to the new stack to use for the EntryPoint
7320 function after paging is enabled.
7326 IN SWITCH_STACK_ENTRY_POINT EntryPoint
,
7327 IN VOID
*Context1
, OPTIONAL
7328 IN VOID
*Context2
, OPTIONAL
7334 Disables the 32-bit paging mode on the CPU.
7336 Disables the 32-bit paging mode on the CPU and returns to 32-bit protected
7337 mode. This function assumes the current execution mode is 32-paged protected
7338 mode. This function is only available on IA-32. After the 32-bit paging mode
7339 is disabled, control is transferred to the function specified by EntryPoint
7340 using the new stack specified by NewStack and passing in the parameters
7341 specified by Context1 and Context2. Context1 and Context2 are optional and
7342 may be NULL. The function EntryPoint must never return.
7344 If the current execution mode is not 32-bit paged mode, then ASSERT().
7345 If EntryPoint is NULL, then ASSERT().
7346 If NewStack is NULL, then ASSERT().
7348 There are a number of constraints that must be followed before calling this
7350 1) Interrupts must be disabled.
7351 2) The caller must be in 32-bit paged mode.
7352 3) CR0, CR3, and CR4 must be compatible with 32-bit paged mode.
7353 4) CR3 must point to valid page tables that guarantee that the pages for
7354 this function and the stack are identity mapped.
7356 @param EntryPoint A pointer to function to call with the new stack after
7358 @param Context1 A pointer to the context to pass into the EntryPoint
7359 function as the first parameter after paging is disabled.
7360 @param Context2 A pointer to the context to pass into the EntryPoint
7361 function as the second parameter after paging is
7363 @param NewStack A pointer to the new stack to use for the EntryPoint
7364 function after paging is disabled.
7369 AsmDisablePaging32 (
7370 IN SWITCH_STACK_ENTRY_POINT EntryPoint
,
7371 IN VOID
*Context1
, OPTIONAL
7372 IN VOID
*Context2
, OPTIONAL
7378 Enables the 64-bit paging mode on the CPU.
7380 Enables the 64-bit paging mode on the CPU. CR0, CR3, CR4, and the page tables
7381 must be properly initialized prior to calling this service. This function
7382 assumes the current execution mode is 32-bit protected mode with flat
7383 descriptors. This function is only available on IA-32. After the 64-bit
7384 paging mode is enabled, control is transferred to the function specified by
7385 EntryPoint using the new stack specified by NewStack and passing in the
7386 parameters specified by Context1 and Context2. Context1 and Context2 are
7387 optional and may be 0. The function EntryPoint must never return.
7389 If the current execution mode is not 32-bit protected mode with flat
7390 descriptors, then ASSERT().
7391 If EntryPoint is 0, then ASSERT().
7392 If NewStack is 0, then ASSERT().
7394 @param Cs The 16-bit selector to load in the CS before EntryPoint
7395 is called. The descriptor in the GDT that this selector
7396 references must be setup for long mode.
7397 @param EntryPoint The 64-bit virtual address of the function to call with
7398 the new stack after paging is enabled.
7399 @param Context1 The 64-bit virtual address of the context to pass into
7400 the EntryPoint function as the first parameter after
7402 @param Context2 The 64-bit virtual address of the context to pass into
7403 the EntryPoint function as the second parameter after
7405 @param NewStack The 64-bit virtual address of the new stack to use for
7406 the EntryPoint function after paging is enabled.
7413 IN UINT64 EntryPoint
,
7414 IN UINT64 Context1
, OPTIONAL
7415 IN UINT64 Context2
, OPTIONAL
7421 Disables the 64-bit paging mode on the CPU.
7423 Disables the 64-bit paging mode on the CPU and returns to 32-bit protected
7424 mode. This function assumes the current execution mode is 64-paging mode.
7425 This function is only available on x64. After the 64-bit paging mode is
7426 disabled, control is transferred to the function specified by EntryPoint
7427 using the new stack specified by NewStack and passing in the parameters
7428 specified by Context1 and Context2. Context1 and Context2 are optional and
7429 may be 0. The function EntryPoint must never return.
7431 If the current execution mode is not 64-bit paged mode, then ASSERT().
7432 If EntryPoint is 0, then ASSERT().
7433 If NewStack is 0, then ASSERT().
7435 @param Cs The 16-bit selector to load in the CS before EntryPoint
7436 is called. The descriptor in the GDT that this selector
7437 references must be setup for 32-bit protected mode.
7438 @param EntryPoint The 64-bit virtual address of the function to call with
7439 the new stack after paging is disabled.
7440 @param Context1 The 64-bit virtual address of the context to pass into
7441 the EntryPoint function as the first parameter after
7443 @param Context2 The 64-bit virtual address of the context to pass into
7444 the EntryPoint function as the second parameter after
7446 @param NewStack The 64-bit virtual address of the new stack to use for
7447 the EntryPoint function after paging is disabled.
7452 AsmDisablePaging64 (
7454 IN UINT32 EntryPoint
,
7455 IN UINT32 Context1
, OPTIONAL
7456 IN UINT32 Context2
, OPTIONAL
7462 // 16-bit thunking services
7466 Retrieves the properties for 16-bit thunk functions.
7468 Computes the size of the buffer and stack below 1MB required to use the
7469 AsmPrepareThunk16(), AsmThunk16() and AsmPrepareAndThunk16() functions. This
7470 buffer size is returned in RealModeBufferSize, and the stack size is returned
7471 in ExtraStackSize. If parameters are passed to the 16-bit real mode code,
7472 then the actual minimum stack size is ExtraStackSize plus the maximum number
7473 of bytes that need to be passed to the 16-bit real mode code.
7475 If RealModeBufferSize is NULL, then ASSERT().
7476 If ExtraStackSize is NULL, then ASSERT().
7478 @param RealModeBufferSize A pointer to the size of the buffer below 1MB
7479 required to use the 16-bit thunk functions.
7480 @param ExtraStackSize A pointer to the extra size of stack below 1MB
7481 that the 16-bit thunk functions require for
7482 temporary storage in the transition to and from
7488 AsmGetThunk16Properties (
7489 OUT UINT32
*RealModeBufferSize
,
7490 OUT UINT32
*ExtraStackSize
7495 Prepares all structures a code required to use AsmThunk16().
7497 Prepares all structures and code required to use AsmThunk16().
7499 This interface is limited to be used in either physical mode or virtual modes with paging enabled where the
7500 virtual to physical mappings for ThunkContext.RealModeBuffer is mapped 1:1.
7502 If ThunkContext is NULL, then ASSERT().
7504 @param ThunkContext A pointer to the context structure that describes the
7505 16-bit real mode code to call.
7511 IN OUT THUNK_CONTEXT
*ThunkContext
7516 Transfers control to a 16-bit real mode entry point and returns the results.
7518 Transfers control to a 16-bit real mode entry point and returns the results.
7519 AsmPrepareThunk16() must be called with ThunkContext before this function is used.
7520 This function must be called with interrupts disabled.
7522 The register state from the RealModeState field of ThunkContext is restored just prior
7523 to calling the 16-bit real mode entry point. This includes the EFLAGS field of RealModeState,
7524 which is used to set the interrupt state when a 16-bit real mode entry point is called.
7525 Control is transferred to the 16-bit real mode entry point specified by the CS and Eip fields of RealModeState.
7526 The stack is initialized to the SS and ESP fields of RealModeState. Any parameters passed to
7527 the 16-bit real mode code must be populated by the caller at SS:ESP prior to calling this function.
7528 The 16-bit real mode entry point is invoked with a 16-bit CALL FAR instruction,
7529 so when accessing stack contents, the 16-bit real mode code must account for the 16-bit segment
7530 and 16-bit offset of the return address that were pushed onto the stack. The 16-bit real mode entry
7531 point must exit with a RETF instruction. The register state is captured into RealModeState immediately
7532 after the RETF instruction is executed.
7534 If EFLAGS specifies interrupts enabled, or any of the 16-bit real mode code enables interrupts,
7535 or any of the 16-bit real mode code makes a SW interrupt, then the caller is responsible for making sure
7536 the IDT at address 0 is initialized to handle any HW or SW interrupts that may occur while in 16-bit real mode.
7538 If EFLAGS specifies interrupts enabled, or any of the 16-bit real mode code enables interrupts,
7539 then the caller is responsible for making sure the 8259 PIC is in a state compatible with 16-bit real mode.
7540 This includes the base vectors, the interrupt masks, and the edge/level trigger mode.
7542 If THUNK_ATTRIBUTE_BIG_REAL_MODE is set in the ThunkAttributes field of ThunkContext, then the user code
7543 is invoked in big real mode. Otherwise, the user code is invoked in 16-bit real mode with 64KB segment limits.
7545 If neither THUNK_ATTRIBUTE_DISABLE_A20_MASK_INT_15 nor THUNK_ATTRIBUTE_DISABLE_A20_MASK_KBD_CTRL are set in
7546 ThunkAttributes, then it is assumed that the user code did not enable the A20 mask, and no attempt is made to
7547 disable the A20 mask.
7549 If THUNK_ATTRIBUTE_DISABLE_A20_MASK_INT_15 is set and THUNK_ATTRIBUTE_DISABLE_A20_MASK_KBD_CTRL is clear in
7550 ThunkAttributes, then attempt to use the INT 15 service to disable the A20 mask. If this INT 15 call fails,
7551 then attempt to disable the A20 mask by directly accessing the 8042 keyboard controller I/O ports.
7553 If THUNK_ATTRIBUTE_DISABLE_A20_MASK_INT_15 is clear and THUNK_ATTRIBUTE_DISABLE_A20_MASK_KBD_CTRL is set in
7554 ThunkAttributes, then attempt to disable the A20 mask by directly accessing the 8042 keyboard controller I/O ports.
7556 If ThunkContext is NULL, then ASSERT().
7557 If AsmPrepareThunk16() was not previously called with ThunkContext, then ASSERT().
7558 If both THUNK_ATTRIBUTE_DISABLE_A20_MASK_INT_15 and THUNK_ATTRIBUTE_DISABLE_A20_MASK_KBD_CTRL are set in
7559 ThunkAttributes, then ASSERT().
7561 This interface is limited to be used in either physical mode or virtual modes with paging enabled where the
7562 virtual to physical mappings for ThunkContext.RealModeBuffer are mapped 1:1.
7564 @param ThunkContext A pointer to the context structure that describes the
7565 16-bit real mode code to call.
7571 IN OUT THUNK_CONTEXT
*ThunkContext
7576 Prepares all structures and code for a 16-bit real mode thunk, transfers
7577 control to a 16-bit real mode entry point, and returns the results.
7579 Prepares all structures and code for a 16-bit real mode thunk, transfers
7580 control to a 16-bit real mode entry point, and returns the results. If the
7581 caller only need to perform a single 16-bit real mode thunk, then this
7582 service should be used. If the caller intends to make more than one 16-bit
7583 real mode thunk, then it is more efficient if AsmPrepareThunk16() is called
7584 once and AsmThunk16() can be called for each 16-bit real mode thunk.
7586 This interface is limited to be used in either physical mode or virtual modes with paging enabled where the
7587 virtual to physical mappings for ThunkContext.RealModeBuffer is mapped 1:1.
7589 See AsmPrepareThunk16() and AsmThunk16() for the detailed description and ASSERT() conditions.
7591 @param ThunkContext A pointer to the context structure that describes the
7592 16-bit real mode code to call.
7597 AsmPrepareAndThunk16 (
7598 IN OUT THUNK_CONTEXT
*ThunkContext