2 Provides string functions, linked list functions, math functions, synchronization
3 functions, file path functions, and CPU architecture-specific functions.
5 Copyright (c) 2006 - 2015, Intel Corporation. All rights reserved.<BR>
6 Portions copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>
7 This program and the accompanying materials
8 are licensed and made available under the terms and conditions of the BSD License
9 which accompanies this distribution. The full text of the license may be found at
10 http://opensource.org/licenses/bsd-license.php.
12 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
13 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
21 // Definitions for architecture-specific types
23 #if defined (MDE_CPU_IA32)
25 /// The IA-32 architecture context buffer used by SetJump() and LongJump().
34 } BASE_LIBRARY_JUMP_BUFFER
;
36 #define BASE_LIBRARY_JUMP_BUFFER_ALIGNMENT 4
38 #endif // defined (MDE_CPU_IA32)
40 #if defined (MDE_CPU_IPF)
43 /// The Itanium architecture context buffer used by SetJump() and LongJump().
78 UINT64 AfterSpillUNAT
;
84 } BASE_LIBRARY_JUMP_BUFFER
;
86 #define BASE_LIBRARY_JUMP_BUFFER_ALIGNMENT 0x10
88 #endif // defined (MDE_CPU_IPF)
90 #if defined (MDE_CPU_X64)
92 /// The x64 architecture context buffer used by SetJump() and LongJump().
106 UINT8 XmmBuffer
[160]; ///< XMM6-XMM15.
107 } BASE_LIBRARY_JUMP_BUFFER
;
109 #define BASE_LIBRARY_JUMP_BUFFER_ALIGNMENT 8
111 #endif // defined (MDE_CPU_X64)
113 #if defined (MDE_CPU_EBC)
115 /// The EBC context buffer used by SetJump() and LongJump().
123 } BASE_LIBRARY_JUMP_BUFFER
;
125 #define BASE_LIBRARY_JUMP_BUFFER_ALIGNMENT 8
127 #endif // defined (MDE_CPU_EBC)
129 #if defined (MDE_CPU_ARM)
132 UINT32 R3
; ///< A copy of R13.
143 } BASE_LIBRARY_JUMP_BUFFER
;
145 #define BASE_LIBRARY_JUMP_BUFFER_ALIGNMENT 4
147 #endif // defined (MDE_CPU_ARM)
149 #if defined (MDE_CPU_AARCH64)
175 } BASE_LIBRARY_JUMP_BUFFER
;
177 #define BASE_LIBRARY_JUMP_BUFFER_ALIGNMENT 8
179 #endif // defined (MDE_CPU_AARCH64)
188 Returns the length of a Null-terminated Unicode string.
190 If String is not aligned on a 16-bit boundary, then ASSERT().
192 @param String A pointer to a Null-terminated Unicode string.
193 @param MaxSize The maximum number of Destination Unicode
194 char, including terminating null char.
196 @retval 0 If String is NULL.
197 @retval MaxSize If there is no null character in the first MaxSize characters of String.
198 @return The number of characters that percede the terminating null character.
204 IN CONST CHAR16
*String
,
209 Copies the string pointed to by Source (including the terminating null char)
210 to the array pointed to by Destination.
212 If Destination is not aligned on a 16-bit boundary, then ASSERT().
213 If Source is not aligned on a 16-bit boundary, then ASSERT().
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 is 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 is 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 is 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 is 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 is 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 is 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 is 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 is 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.
1595 // File Path Manipulation Functions
1599 Removes the last directory or file entry in a path by changing the last
1600 L'\' to a CHAR_NULL.
1602 @param[in, out] Path The pointer to the path to modify.
1604 @retval FALSE Nothing was found to remove.
1605 @retval TRUE A directory or file was removed.
1614 Function to clean up paths.
1615 - Single periods in the path are removed.
1616 - Double periods in the path are removed along with a single parent directory.
1617 - Forward slashes L'/' are converted to backward slashes L'\'.
1619 This will be done inline and the existing buffer may be larger than required
1622 @param[in] Path The pointer to the string containing the path.
1624 @return Returns Path, otherwise returns NULL to indicate that an error has occured.
1628 PathCleanUpDirectories(
1633 // Linked List Functions and Macros
1637 Initializes the head node of a doubly linked list that is declared as a
1638 global variable in a module.
1640 Initializes the forward and backward links of a new linked list. After
1641 initializing a linked list with this macro, the other linked list functions
1642 may be used to add and remove nodes from the linked list. This macro results
1643 in smaller executables by initializing the linked list in the data section,
1644 instead if calling the InitializeListHead() function to perform the
1645 equivalent operation.
1647 @param ListHead The head note of a list to initialize.
1650 #define INITIALIZE_LIST_HEAD_VARIABLE(ListHead) {&(ListHead), &(ListHead)}
1654 Initializes the head node of a doubly linked list, and returns the pointer to
1655 the head node of the doubly linked list.
1657 Initializes the forward and backward links of a new linked list. After
1658 initializing a linked list with this function, the other linked list
1659 functions may be used to add and remove nodes from the linked list. It is up
1660 to the caller of this function to allocate the memory for ListHead.
1662 If ListHead is NULL, then ASSERT().
1664 @param ListHead A pointer to the head node of a new doubly linked list.
1671 InitializeListHead (
1672 IN OUT LIST_ENTRY
*ListHead
1677 Adds a node to the beginning of a doubly linked list, and returns the pointer
1678 to the head node of the doubly linked list.
1680 Adds the node Entry at the beginning of the doubly linked list denoted by
1681 ListHead, and returns ListHead.
1683 If ListHead is NULL, then ASSERT().
1684 If Entry is NULL, then ASSERT().
1685 If ListHead was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or
1686 InitializeListHead(), then ASSERT().
1687 If PcdMaximumLinkedListLength is not zero, and prior to insertion the number
1688 of nodes in ListHead, including the ListHead node, is greater than or
1689 equal to PcdMaximumLinkedListLength, then ASSERT().
1691 @param ListHead A pointer to the head node of a doubly linked list.
1692 @param Entry A pointer to a node that is to be inserted at the beginning
1693 of a doubly linked list.
1701 IN OUT LIST_ENTRY
*ListHead
,
1702 IN OUT LIST_ENTRY
*Entry
1707 Adds a node to the end of a doubly linked list, and returns the pointer to
1708 the head node of the doubly linked list.
1710 Adds the node Entry to the end of the doubly linked list denoted by ListHead,
1711 and returns ListHead.
1713 If ListHead is NULL, then ASSERT().
1714 If Entry is NULL, then ASSERT().
1715 If ListHead was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or
1716 InitializeListHead(), then ASSERT().
1717 If PcdMaximumLinkedListLength is not zero, and prior to insertion the number
1718 of nodes in ListHead, including the ListHead node, is greater than or
1719 equal to PcdMaximumLinkedListLength, then ASSERT().
1721 @param ListHead A pointer to the head node of a doubly linked list.
1722 @param Entry A pointer to a node that is to be added at the end of the
1731 IN OUT LIST_ENTRY
*ListHead
,
1732 IN OUT LIST_ENTRY
*Entry
1737 Retrieves the first node of a doubly linked list.
1739 Returns the first node of a doubly linked list. List must have been
1740 initialized with INTIALIZE_LIST_HEAD_VARIABLE() or InitializeListHead().
1741 If List is empty, then List is returned.
1743 If List is NULL, then ASSERT().
1744 If List was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or
1745 InitializeListHead(), then ASSERT().
1746 If PcdMaximumLinkedListLength is not zero, and the number of nodes
1747 in List, including the List node, is greater than or equal to
1748 PcdMaximumLinkedListLength, then ASSERT().
1750 @param List A pointer to the head node of a doubly linked list.
1752 @return The first node of a doubly linked list.
1753 @retval List The list is empty.
1759 IN CONST LIST_ENTRY
*List
1764 Retrieves the next node of a doubly linked list.
1766 Returns the node of a doubly linked list that follows Node.
1767 List must have been initialized with INTIALIZE_LIST_HEAD_VARIABLE()
1768 or InitializeListHead(). If List is empty, then List is returned.
1770 If List is NULL, then ASSERT().
1771 If Node is NULL, then ASSERT().
1772 If List was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or
1773 InitializeListHead(), then ASSERT().
1774 If PcdMaximumLinkedListLength is not zero, and List contains more than
1775 PcdMaximumLinkedListLength nodes, then ASSERT().
1776 If PcdVerifyNodeInList is TRUE and Node is not a node in List, then ASSERT().
1778 @param List A pointer to the head node of a doubly linked list.
1779 @param Node A pointer to a node in the doubly linked list.
1781 @return The pointer to the next node if one exists. Otherwise List is returned.
1787 IN CONST LIST_ENTRY
*List
,
1788 IN CONST LIST_ENTRY
*Node
1793 Retrieves the previous node of a doubly linked list.
1795 Returns the node of a doubly linked list that precedes Node.
1796 List must have been initialized with INTIALIZE_LIST_HEAD_VARIABLE()
1797 or InitializeListHead(). If List is empty, then List is returned.
1799 If List is NULL, then ASSERT().
1800 If Node is NULL, then ASSERT().
1801 If List was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or
1802 InitializeListHead(), then ASSERT().
1803 If PcdMaximumLinkedListLength is not zero, and List contains more than
1804 PcdMaximumLinkedListLength nodes, then ASSERT().
1805 If PcdVerifyNodeInList is TRUE and Node is not a node in List, then ASSERT().
1807 @param List A pointer to the head node of a doubly linked list.
1808 @param Node A pointer to a node in the doubly linked list.
1810 @return The pointer to the previous node if one exists. Otherwise List is returned.
1816 IN CONST LIST_ENTRY
*List
,
1817 IN CONST LIST_ENTRY
*Node
1822 Checks to see if a doubly linked list is empty or not.
1824 Checks to see if the doubly linked list is empty. If the linked list contains
1825 zero nodes, this function returns TRUE. Otherwise, it returns FALSE.
1827 If ListHead is NULL, then ASSERT().
1828 If ListHead was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or
1829 InitializeListHead(), then ASSERT().
1830 If PcdMaximumLinkedListLength is not zero, and the number of nodes
1831 in List, including the List node, is greater than or equal to
1832 PcdMaximumLinkedListLength, then ASSERT().
1834 @param ListHead A pointer to the head node of a doubly linked list.
1836 @retval TRUE The linked list is empty.
1837 @retval FALSE The linked list is not empty.
1843 IN CONST LIST_ENTRY
*ListHead
1848 Determines if a node in a doubly linked list is the head node of a the same
1849 doubly linked list. This function is typically used to terminate a loop that
1850 traverses all the nodes in a doubly linked list starting with the head node.
1852 Returns TRUE if Node is equal to List. Returns FALSE if Node is one of the
1853 nodes in the doubly linked list specified by List. List must have been
1854 initialized with INTIALIZE_LIST_HEAD_VARIABLE() or InitializeListHead().
1856 If List is NULL, then ASSERT().
1857 If Node is NULL, then ASSERT().
1858 If List was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or InitializeListHead(),
1860 If PcdMaximumLinkedListLength is not zero, and the number of nodes
1861 in List, including the List node, is greater than or equal to
1862 PcdMaximumLinkedListLength, then ASSERT().
1863 If PcdVerifyNodeInList is TRUE and Node is not a node in List the and Node is not equal
1864 to List, then ASSERT().
1866 @param List A pointer to the head node of a doubly linked list.
1867 @param Node A pointer to a node in the doubly linked list.
1869 @retval TRUE Node is the head of the doubly-linked list pointed by List.
1870 @retval FALSE Node is not the head of the doubly-linked list pointed by List.
1876 IN CONST LIST_ENTRY
*List
,
1877 IN CONST LIST_ENTRY
*Node
1882 Determines if a node the last node in a doubly linked list.
1884 Returns TRUE if Node is the last node in the doubly linked list specified by
1885 List. Otherwise, FALSE is returned. List must have been initialized with
1886 INTIALIZE_LIST_HEAD_VARIABLE() or InitializeListHead().
1888 If List is NULL, then ASSERT().
1889 If Node is NULL, then ASSERT().
1890 If List was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or
1891 InitializeListHead(), then ASSERT().
1892 If PcdMaximumLinkedListLength is not zero, and the number of nodes
1893 in List, including the List node, is greater than or equal to
1894 PcdMaximumLinkedListLength, then ASSERT().
1895 If PcdVerifyNodeInList is TRUE and Node is not a node in List, then ASSERT().
1897 @param List A pointer to the head node of a doubly linked list.
1898 @param Node A pointer to a node in the doubly linked list.
1900 @retval TRUE Node is the last node in the linked list.
1901 @retval FALSE Node is not the last node in the linked list.
1907 IN CONST LIST_ENTRY
*List
,
1908 IN CONST LIST_ENTRY
*Node
1913 Swaps the location of two nodes in a doubly linked list, and returns the
1914 first node after the swap.
1916 If FirstEntry is identical to SecondEntry, then SecondEntry is returned.
1917 Otherwise, the location of the FirstEntry node is swapped with the location
1918 of the SecondEntry node in a doubly linked list. SecondEntry must be in the
1919 same double linked list as FirstEntry and that double linked list must have
1920 been initialized with INTIALIZE_LIST_HEAD_VARIABLE() or InitializeListHead().
1921 SecondEntry is returned after the nodes are swapped.
1923 If FirstEntry is NULL, then ASSERT().
1924 If SecondEntry is NULL, then ASSERT().
1925 If PcdVerifyNodeInList is TRUE and SecondEntry and FirstEntry are not in the
1926 same linked list, then ASSERT().
1927 If PcdMaximumLinkedListLength is not zero, and the number of nodes in the
1928 linked list containing the FirstEntry and SecondEntry nodes, including
1929 the FirstEntry and SecondEntry nodes, is greater than or equal to
1930 PcdMaximumLinkedListLength, then ASSERT().
1932 @param FirstEntry A pointer to a node in a linked list.
1933 @param SecondEntry A pointer to another node in the same linked list.
1935 @return SecondEntry.
1941 IN OUT LIST_ENTRY
*FirstEntry
,
1942 IN OUT LIST_ENTRY
*SecondEntry
1947 Removes a node from a doubly linked list, and returns the node that follows
1950 Removes the node Entry from a doubly linked list. It is up to the caller of
1951 this function to release the memory used by this node if that is required. On
1952 exit, the node following Entry in the doubly linked list is returned. If
1953 Entry is the only node in the linked list, then the head node of the linked
1956 If Entry is NULL, then ASSERT().
1957 If Entry is the head node of an empty list, then ASSERT().
1958 If PcdMaximumLinkedListLength is not zero, and the number of nodes in the
1959 linked list containing Entry, including the Entry node, is greater than
1960 or equal to PcdMaximumLinkedListLength, then ASSERT().
1962 @param Entry A pointer to a node in a linked list.
1970 IN CONST LIST_ENTRY
*Entry
1978 Shifts a 64-bit integer left between 0 and 63 bits. The low bits are filled
1979 with zeros. The shifted value is returned.
1981 This function shifts the 64-bit value Operand to the left by Count bits. The
1982 low Count bits are set to zero. The shifted value is returned.
1984 If Count is greater than 63, then ASSERT().
1986 @param Operand The 64-bit operand to shift left.
1987 @param Count The number of bits to shift left.
1989 @return Operand << Count.
2001 Shifts a 64-bit integer right between 0 and 63 bits. This high bits are
2002 filled with zeros. The shifted value is returned.
2004 This function shifts the 64-bit value Operand to the right by Count bits. The
2005 high Count bits are set to zero. The shifted value is returned.
2007 If Count is greater than 63, then ASSERT().
2009 @param Operand The 64-bit operand to shift right.
2010 @param Count The number of bits to shift right.
2012 @return Operand >> Count
2024 Shifts a 64-bit integer right between 0 and 63 bits. The high bits are filled
2025 with original integer's bit 63. The shifted value is returned.
2027 This function shifts the 64-bit value Operand to the right by Count bits. The
2028 high Count bits are set to bit 63 of Operand. The shifted value is returned.
2030 If Count is greater than 63, then ASSERT().
2032 @param Operand The 64-bit operand to shift right.
2033 @param Count The number of bits to shift right.
2035 @return Operand >> Count
2047 Rotates a 32-bit integer left between 0 and 31 bits, filling the low bits
2048 with the high bits that were rotated.
2050 This function rotates the 32-bit value Operand to the left by Count bits. The
2051 low Count bits are fill with the high Count bits of Operand. The rotated
2054 If Count is greater than 31, then ASSERT().
2056 @param Operand The 32-bit operand to rotate left.
2057 @param Count The number of bits to rotate left.
2059 @return Operand << Count
2071 Rotates a 32-bit integer right between 0 and 31 bits, filling the high bits
2072 with the low bits that were rotated.
2074 This function rotates the 32-bit value Operand to the right by Count bits.
2075 The high Count bits are fill with the low Count bits of Operand. The rotated
2078 If Count is greater than 31, then ASSERT().
2080 @param Operand The 32-bit operand to rotate right.
2081 @param Count The number of bits to rotate right.
2083 @return Operand >> Count
2095 Rotates a 64-bit integer left between 0 and 63 bits, filling the low bits
2096 with the high bits that were rotated.
2098 This function rotates the 64-bit value Operand to the left by Count bits. The
2099 low Count bits are fill with the high Count bits of Operand. The rotated
2102 If Count is greater than 63, then ASSERT().
2104 @param Operand The 64-bit operand to rotate left.
2105 @param Count The number of bits to rotate left.
2107 @return Operand << Count
2119 Rotates a 64-bit integer right between 0 and 63 bits, filling the high bits
2120 with the high low bits that were rotated.
2122 This function rotates the 64-bit value Operand to the right by Count bits.
2123 The high Count bits are fill with the low Count bits of Operand. The rotated
2126 If Count is greater than 63, then ASSERT().
2128 @param Operand The 64-bit operand to rotate right.
2129 @param Count The number of bits to rotate right.
2131 @return Operand >> Count
2143 Returns the bit position of the lowest bit set in a 32-bit value.
2145 This function computes the bit position of the lowest bit set in the 32-bit
2146 value specified by Operand. If Operand is zero, then -1 is returned.
2147 Otherwise, a value between 0 and 31 is returned.
2149 @param Operand The 32-bit operand to evaluate.
2151 @retval 0..31 The lowest bit set in Operand was found.
2152 @retval -1 Operand is zero.
2163 Returns the bit position of the lowest bit set in a 64-bit value.
2165 This function computes the bit position of the lowest bit set in the 64-bit
2166 value specified by Operand. If Operand is zero, then -1 is returned.
2167 Otherwise, a value between 0 and 63 is returned.
2169 @param Operand The 64-bit operand to evaluate.
2171 @retval 0..63 The lowest bit set in Operand was found.
2172 @retval -1 Operand is zero.
2184 Returns the bit position of the highest bit set in a 32-bit value. Equivalent
2187 This function computes the bit position of the highest bit set in the 32-bit
2188 value specified by Operand. If Operand is zero, then -1 is returned.
2189 Otherwise, a value between 0 and 31 is returned.
2191 @param Operand The 32-bit operand to evaluate.
2193 @retval 0..31 Position of the highest bit set in Operand if found.
2194 @retval -1 Operand is zero.
2205 Returns the bit position of the highest bit set in a 64-bit value. Equivalent
2208 This function computes the bit position of the highest bit set in the 64-bit
2209 value specified by Operand. If Operand is zero, then -1 is returned.
2210 Otherwise, a value between 0 and 63 is returned.
2212 @param Operand The 64-bit operand to evaluate.
2214 @retval 0..63 Position of the highest bit set in Operand if found.
2215 @retval -1 Operand is zero.
2226 Returns the value of the highest bit set in a 32-bit value. Equivalent to
2229 This function computes the value of the highest bit set in the 32-bit value
2230 specified by Operand. If Operand is zero, then zero is returned.
2232 @param Operand The 32-bit operand to evaluate.
2234 @return 1 << HighBitSet32(Operand)
2235 @retval 0 Operand is zero.
2246 Returns the value of the highest bit set in a 64-bit value. Equivalent to
2249 This function computes the value of the highest bit set in the 64-bit value
2250 specified by Operand. If Operand is zero, then zero is returned.
2252 @param Operand The 64-bit operand to evaluate.
2254 @return 1 << HighBitSet64(Operand)
2255 @retval 0 Operand is zero.
2266 Switches the endianness of a 16-bit integer.
2268 This function swaps the bytes in a 16-bit unsigned value to switch the value
2269 from little endian to big endian or vice versa. The byte swapped value is
2272 @param Value A 16-bit unsigned value.
2274 @return The byte swapped Value.
2285 Switches the endianness of a 32-bit integer.
2287 This function swaps the bytes in a 32-bit unsigned value to switch the value
2288 from little endian to big endian or vice versa. The byte swapped value is
2291 @param Value A 32-bit unsigned value.
2293 @return The byte swapped Value.
2304 Switches the endianness of a 64-bit integer.
2306 This function swaps the bytes in a 64-bit unsigned value to switch the value
2307 from little endian to big endian or vice versa. The byte swapped value is
2310 @param Value A 64-bit unsigned value.
2312 @return The byte swapped Value.
2323 Multiples a 64-bit unsigned integer by a 32-bit unsigned integer and
2324 generates a 64-bit unsigned result.
2326 This function multiples the 64-bit unsigned value Multiplicand by the 32-bit
2327 unsigned value Multiplier and generates a 64-bit unsigned result. This 64-
2328 bit unsigned result is returned.
2330 @param Multiplicand A 64-bit unsigned value.
2331 @param Multiplier A 32-bit unsigned value.
2333 @return Multiplicand * Multiplier
2339 IN UINT64 Multiplicand
,
2340 IN UINT32 Multiplier
2345 Multiples a 64-bit unsigned integer by a 64-bit unsigned integer and
2346 generates a 64-bit unsigned result.
2348 This function multiples the 64-bit unsigned value Multiplicand by the 64-bit
2349 unsigned value Multiplier and generates a 64-bit unsigned result. This 64-
2350 bit unsigned result is returned.
2352 @param Multiplicand A 64-bit unsigned value.
2353 @param Multiplier A 64-bit unsigned value.
2355 @return Multiplicand * Multiplier.
2361 IN UINT64 Multiplicand
,
2362 IN UINT64 Multiplier
2367 Multiples a 64-bit signed integer by a 64-bit signed integer and generates a
2368 64-bit signed result.
2370 This function multiples the 64-bit signed value Multiplicand by the 64-bit
2371 signed value Multiplier and generates a 64-bit signed result. This 64-bit
2372 signed result is returned.
2374 @param Multiplicand A 64-bit signed value.
2375 @param Multiplier A 64-bit signed value.
2377 @return Multiplicand * Multiplier
2383 IN INT64 Multiplicand
,
2389 Divides a 64-bit unsigned integer by a 32-bit unsigned integer and generates
2390 a 64-bit unsigned result.
2392 This function divides the 64-bit unsigned value Dividend by the 32-bit
2393 unsigned value Divisor and generates a 64-bit unsigned quotient. This
2394 function returns the 64-bit unsigned quotient.
2396 If Divisor is 0, then ASSERT().
2398 @param Dividend A 64-bit unsigned value.
2399 @param Divisor A 32-bit unsigned value.
2401 @return Dividend / Divisor.
2413 Divides a 64-bit unsigned integer by a 32-bit unsigned integer and generates
2414 a 32-bit unsigned remainder.
2416 This function divides the 64-bit unsigned value Dividend by the 32-bit
2417 unsigned value Divisor and generates a 32-bit remainder. This function
2418 returns the 32-bit unsigned remainder.
2420 If Divisor is 0, then ASSERT().
2422 @param Dividend A 64-bit unsigned value.
2423 @param Divisor A 32-bit unsigned value.
2425 @return Dividend % Divisor.
2437 Divides a 64-bit unsigned integer by a 32-bit unsigned integer and generates
2438 a 64-bit unsigned result and an optional 32-bit unsigned remainder.
2440 This function divides the 64-bit unsigned value Dividend by the 32-bit
2441 unsigned value Divisor and generates a 64-bit unsigned quotient. If Remainder
2442 is not NULL, then the 32-bit unsigned remainder is returned in Remainder.
2443 This function returns the 64-bit unsigned quotient.
2445 If Divisor is 0, then ASSERT().
2447 @param Dividend A 64-bit unsigned value.
2448 @param Divisor A 32-bit unsigned value.
2449 @param Remainder A pointer to a 32-bit unsigned value. This parameter is
2450 optional and may be NULL.
2452 @return Dividend / Divisor.
2457 DivU64x32Remainder (
2460 OUT UINT32
*Remainder OPTIONAL
2465 Divides a 64-bit unsigned integer by a 64-bit unsigned integer and generates
2466 a 64-bit unsigned result and an optional 64-bit unsigned remainder.
2468 This function divides the 64-bit unsigned value Dividend by the 64-bit
2469 unsigned value Divisor and generates a 64-bit unsigned quotient. If Remainder
2470 is not NULL, then the 64-bit unsigned remainder is returned in Remainder.
2471 This function returns the 64-bit unsigned quotient.
2473 If Divisor is 0, then ASSERT().
2475 @param Dividend A 64-bit unsigned value.
2476 @param Divisor A 64-bit unsigned value.
2477 @param Remainder A pointer to a 64-bit unsigned value. This parameter is
2478 optional and may be NULL.
2480 @return Dividend / Divisor.
2485 DivU64x64Remainder (
2488 OUT UINT64
*Remainder OPTIONAL
2493 Divides a 64-bit signed integer by a 64-bit signed integer and generates a
2494 64-bit signed result and a optional 64-bit signed remainder.
2496 This function divides the 64-bit signed value Dividend by the 64-bit signed
2497 value Divisor and generates a 64-bit signed quotient. If Remainder is not
2498 NULL, then the 64-bit signed remainder is returned in Remainder. This
2499 function returns the 64-bit signed quotient.
2501 It is the caller's responsibility to not call this function with a Divisor of 0.
2502 If Divisor is 0, then the quotient and remainder should be assumed to be
2503 the largest negative integer.
2505 If Divisor is 0, then ASSERT().
2507 @param Dividend A 64-bit signed value.
2508 @param Divisor A 64-bit signed value.
2509 @param Remainder A pointer to a 64-bit signed value. This parameter is
2510 optional and may be NULL.
2512 @return Dividend / Divisor.
2517 DivS64x64Remainder (
2520 OUT INT64
*Remainder OPTIONAL
2525 Reads a 16-bit value from memory that may be unaligned.
2527 This function returns the 16-bit value pointed to by Buffer. The function
2528 guarantees that the read operation does not produce an alignment fault.
2530 If the Buffer is NULL, then ASSERT().
2532 @param Buffer The pointer to a 16-bit value that may be unaligned.
2534 @return The 16-bit value read from Buffer.
2540 IN CONST UINT16
*Buffer
2545 Writes a 16-bit value to memory that may be unaligned.
2547 This function writes the 16-bit value specified by Value to Buffer. Value is
2548 returned. The function guarantees that the write operation does not produce
2551 If the Buffer is NULL, then ASSERT().
2553 @param Buffer The pointer to a 16-bit value that may be unaligned.
2554 @param Value 16-bit value to write to Buffer.
2556 @return The 16-bit value to write to Buffer.
2568 Reads a 24-bit value from memory that may be unaligned.
2570 This function returns the 24-bit value pointed to by Buffer. The function
2571 guarantees that the read operation does not produce an alignment fault.
2573 If the Buffer is NULL, then ASSERT().
2575 @param Buffer The pointer to a 24-bit value that may be unaligned.
2577 @return The 24-bit value read from Buffer.
2583 IN CONST UINT32
*Buffer
2588 Writes a 24-bit value to memory that may be unaligned.
2590 This function writes the 24-bit value specified by Value to Buffer. Value is
2591 returned. The function guarantees that the write operation does not produce
2594 If the Buffer is NULL, then ASSERT().
2596 @param Buffer The pointer to a 24-bit value that may be unaligned.
2597 @param Value 24-bit value to write to Buffer.
2599 @return The 24-bit value to write to Buffer.
2611 Reads a 32-bit value from memory that may be unaligned.
2613 This function returns the 32-bit value pointed to by Buffer. The function
2614 guarantees that the read operation does not produce an alignment fault.
2616 If the Buffer is NULL, then ASSERT().
2618 @param Buffer The pointer to a 32-bit value that may be unaligned.
2620 @return The 32-bit value read from Buffer.
2626 IN CONST UINT32
*Buffer
2631 Writes a 32-bit value to memory that may be unaligned.
2633 This function writes the 32-bit value specified by Value to Buffer. Value is
2634 returned. The function guarantees that the write operation does not produce
2637 If the Buffer is NULL, then ASSERT().
2639 @param Buffer The pointer to a 32-bit value that may be unaligned.
2640 @param Value 32-bit value to write to Buffer.
2642 @return The 32-bit value to write to Buffer.
2654 Reads a 64-bit value from memory that may be unaligned.
2656 This function returns the 64-bit value pointed to by Buffer. The function
2657 guarantees that the read operation does not produce an alignment fault.
2659 If the Buffer is NULL, then ASSERT().
2661 @param Buffer The pointer to a 64-bit value that may be unaligned.
2663 @return The 64-bit value read from Buffer.
2669 IN CONST UINT64
*Buffer
2674 Writes a 64-bit value to memory that may be unaligned.
2676 This function writes the 64-bit value specified by Value to Buffer. Value is
2677 returned. The function guarantees that the write operation does not produce
2680 If the Buffer is NULL, then ASSERT().
2682 @param Buffer The pointer to a 64-bit value that may be unaligned.
2683 @param Value 64-bit value to write to Buffer.
2685 @return The 64-bit value to write to Buffer.
2697 // Bit Field Functions
2701 Returns a bit field from an 8-bit value.
2703 Returns the bitfield specified by the StartBit and the EndBit from Operand.
2705 If 8-bit operations are not supported, then ASSERT().
2706 If StartBit is greater than 7, then ASSERT().
2707 If EndBit is greater than 7, then ASSERT().
2708 If EndBit is less than StartBit, then ASSERT().
2710 @param Operand Operand on which to perform the bitfield operation.
2711 @param StartBit The ordinal of the least significant bit in the bit field.
2713 @param EndBit The ordinal of the most significant bit in the bit field.
2716 @return The bit field read.
2729 Writes a bit field to an 8-bit value, and returns the result.
2731 Writes Value to the bit field specified by the StartBit and the EndBit in
2732 Operand. All other bits in Operand are preserved. The new 8-bit value is
2735 If 8-bit operations are not supported, then ASSERT().
2736 If StartBit is greater than 7, then ASSERT().
2737 If EndBit is greater than 7, then ASSERT().
2738 If EndBit is less than StartBit, then ASSERT().
2739 If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
2741 @param Operand Operand on which to perform the bitfield operation.
2742 @param StartBit The ordinal of the least significant bit in the bit field.
2744 @param EndBit The ordinal of the most significant bit in the bit field.
2746 @param Value New value of the bit field.
2748 @return The new 8-bit value.
2762 Reads a bit field from an 8-bit value, performs a bitwise OR, and returns the
2765 Performs a bitwise OR between the bit field specified by StartBit
2766 and EndBit in Operand and the value specified by OrData. All other bits in
2767 Operand are preserved. The new 8-bit value is returned.
2769 If 8-bit operations are not supported, then ASSERT().
2770 If StartBit is greater than 7, then ASSERT().
2771 If EndBit is greater than 7, then ASSERT().
2772 If EndBit is less than StartBit, then ASSERT().
2773 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
2775 @param Operand Operand on which to perform the bitfield operation.
2776 @param StartBit The ordinal of the least significant bit in the bit field.
2778 @param EndBit The ordinal of the most significant bit in the bit field.
2780 @param OrData The value to OR with the read value from the value
2782 @return The new 8-bit value.
2796 Reads a bit field from an 8-bit value, performs a bitwise AND, and returns
2799 Performs a bitwise AND between the bit field specified by StartBit and EndBit
2800 in Operand and the value specified by AndData. All other bits in Operand are
2801 preserved. The new 8-bit value is returned.
2803 If 8-bit operations are not supported, then ASSERT().
2804 If StartBit is greater than 7, then ASSERT().
2805 If EndBit is greater than 7, then ASSERT().
2806 If EndBit is less than StartBit, then ASSERT().
2807 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
2809 @param Operand Operand on which to perform the bitfield operation.
2810 @param StartBit The ordinal of the least significant bit in the bit field.
2812 @param EndBit The ordinal of the most significant bit in the bit field.
2814 @param AndData The value to AND with the read value from the value.
2816 @return The new 8-bit value.
2830 Reads a bit field from an 8-bit value, performs a bitwise AND followed by a
2831 bitwise OR, and returns the result.
2833 Performs a bitwise AND between the bit field specified by StartBit and EndBit
2834 in Operand and the value specified by AndData, followed by a bitwise
2835 OR with value specified by OrData. All other bits in Operand are
2836 preserved. The new 8-bit value is returned.
2838 If 8-bit operations are not supported, then ASSERT().
2839 If StartBit is greater than 7, then ASSERT().
2840 If EndBit is greater than 7, then ASSERT().
2841 If EndBit is less than StartBit, then ASSERT().
2842 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
2843 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
2845 @param Operand Operand on which to perform the bitfield operation.
2846 @param StartBit The ordinal of the least significant bit in the bit field.
2848 @param EndBit The ordinal of the most significant bit in the bit field.
2850 @param AndData The value to AND with the read value from the value.
2851 @param OrData The value to OR with the result of the AND operation.
2853 @return The new 8-bit value.
2858 BitFieldAndThenOr8 (
2868 Returns a bit field from a 16-bit value.
2870 Returns the bitfield specified by the StartBit and the EndBit from Operand.
2872 If 16-bit operations are not supported, then ASSERT().
2873 If StartBit is greater than 15, then ASSERT().
2874 If EndBit is greater than 15, then ASSERT().
2875 If EndBit is less than StartBit, then ASSERT().
2877 @param Operand Operand on which to perform the bitfield operation.
2878 @param StartBit The ordinal of the least significant bit in the bit field.
2880 @param EndBit The ordinal of the most significant bit in the bit field.
2883 @return The bit field read.
2896 Writes a bit field to a 16-bit value, and returns the result.
2898 Writes Value to the bit field specified by the StartBit and the EndBit in
2899 Operand. All other bits in Operand are preserved. The new 16-bit value is
2902 If 16-bit operations are not supported, then ASSERT().
2903 If StartBit is greater than 15, then ASSERT().
2904 If EndBit is greater than 15, then ASSERT().
2905 If EndBit is less than StartBit, then ASSERT().
2906 If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
2908 @param Operand Operand on which to perform the bitfield operation.
2909 @param StartBit The ordinal of the least significant bit in the bit field.
2911 @param EndBit The ordinal of the most significant bit in the bit field.
2913 @param Value New value of the bit field.
2915 @return The new 16-bit value.
2929 Reads a bit field from a 16-bit value, performs a bitwise OR, and returns the
2932 Performs a bitwise OR between the bit field specified by StartBit
2933 and EndBit in Operand and the value specified by OrData. All other bits in
2934 Operand are preserved. The new 16-bit value is returned.
2936 If 16-bit operations are not supported, then ASSERT().
2937 If StartBit is greater than 15, then ASSERT().
2938 If EndBit is greater than 15, then ASSERT().
2939 If EndBit is less than StartBit, then ASSERT().
2940 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
2942 @param Operand Operand on which to perform the bitfield operation.
2943 @param StartBit The ordinal of the least significant bit in the bit field.
2945 @param EndBit The ordinal of the most significant bit in the bit field.
2947 @param OrData The value to OR with the read value from the value
2949 @return The new 16-bit value.
2963 Reads a bit field from a 16-bit value, performs a bitwise AND, and returns
2966 Performs a bitwise AND between the bit field specified by StartBit and EndBit
2967 in Operand and the value specified by AndData. All other bits in Operand are
2968 preserved. The new 16-bit value is returned.
2970 If 16-bit operations are not supported, then ASSERT().
2971 If StartBit is greater than 15, then ASSERT().
2972 If EndBit is greater than 15, then ASSERT().
2973 If EndBit is less than StartBit, then ASSERT().
2974 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
2976 @param Operand Operand on which to perform the bitfield operation.
2977 @param StartBit The ordinal of the least significant bit in the bit field.
2979 @param EndBit The ordinal of the most significant bit in the bit field.
2981 @param AndData The value to AND with the read value from the value
2983 @return The new 16-bit value.
2997 Reads a bit field from a 16-bit value, performs a bitwise AND followed by a
2998 bitwise OR, and returns the result.
3000 Performs a bitwise AND between the bit field specified by StartBit and EndBit
3001 in Operand and the value specified by AndData, followed by a bitwise
3002 OR with value specified by OrData. All other bits in Operand are
3003 preserved. The new 16-bit value is returned.
3005 If 16-bit operations are not supported, then ASSERT().
3006 If StartBit is greater than 15, then ASSERT().
3007 If EndBit is greater than 15, then ASSERT().
3008 If EndBit is less than StartBit, then ASSERT().
3009 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
3010 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
3012 @param Operand Operand on which to perform the bitfield operation.
3013 @param StartBit The ordinal of the least significant bit in the bit field.
3015 @param EndBit The ordinal of the most significant bit in the bit field.
3017 @param AndData The value to AND with the read value from the value.
3018 @param OrData The value to OR with the result of the AND operation.
3020 @return The new 16-bit value.
3025 BitFieldAndThenOr16 (
3035 Returns a bit field from a 32-bit value.
3037 Returns the bitfield specified by the StartBit and the EndBit from Operand.
3039 If 32-bit operations are not supported, then ASSERT().
3040 If StartBit is greater than 31, then ASSERT().
3041 If EndBit is greater than 31, then ASSERT().
3042 If EndBit is less than StartBit, then ASSERT().
3044 @param Operand Operand on which to perform the bitfield operation.
3045 @param StartBit The ordinal of the least significant bit in the bit field.
3047 @param EndBit The ordinal of the most significant bit in the bit field.
3050 @return The bit field read.
3063 Writes a bit field to a 32-bit value, and returns the result.
3065 Writes Value to the bit field specified by the StartBit and the EndBit in
3066 Operand. All other bits in Operand are preserved. The new 32-bit value is
3069 If 32-bit operations are not supported, then ASSERT().
3070 If StartBit is greater than 31, then ASSERT().
3071 If EndBit is greater than 31, then ASSERT().
3072 If EndBit is less than StartBit, then ASSERT().
3073 If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
3075 @param Operand Operand on which to perform the bitfield operation.
3076 @param StartBit The ordinal of the least significant bit in the bit field.
3078 @param EndBit The ordinal of the most significant bit in the bit field.
3080 @param Value New value of the bit field.
3082 @return The new 32-bit value.
3096 Reads a bit field from a 32-bit value, performs a bitwise OR, and returns the
3099 Performs a bitwise OR between the bit field specified by StartBit
3100 and EndBit in Operand and the value specified by OrData. All other bits in
3101 Operand are preserved. The new 32-bit value is returned.
3103 If 32-bit operations are not supported, then ASSERT().
3104 If StartBit is greater than 31, then ASSERT().
3105 If EndBit is greater than 31, then ASSERT().
3106 If EndBit is less than StartBit, then ASSERT().
3107 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
3109 @param Operand Operand on which to perform the bitfield operation.
3110 @param StartBit The ordinal of the least significant bit in the bit field.
3112 @param EndBit The ordinal of the most significant bit in the bit field.
3114 @param OrData The value to OR with the read value from the value.
3116 @return The new 32-bit value.
3130 Reads a bit field from a 32-bit value, performs a bitwise AND, and returns
3133 Performs a bitwise AND between the bit field specified by StartBit and EndBit
3134 in Operand and the value specified by AndData. All other bits in Operand are
3135 preserved. The new 32-bit value is returned.
3137 If 32-bit operations are not supported, then ASSERT().
3138 If StartBit is greater than 31, then ASSERT().
3139 If EndBit is greater than 31, then ASSERT().
3140 If EndBit is less than StartBit, then ASSERT().
3141 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
3143 @param Operand Operand on which to perform the bitfield operation.
3144 @param StartBit The ordinal of the least significant bit in the bit field.
3146 @param EndBit The ordinal of the most significant bit in the bit field.
3148 @param AndData The value to AND with the read value from the value
3150 @return The new 32-bit value.
3164 Reads a bit field from a 32-bit value, performs a bitwise AND followed by a
3165 bitwise OR, and returns the result.
3167 Performs a bitwise AND between the bit field specified by StartBit and EndBit
3168 in Operand and the value specified by AndData, followed by a bitwise
3169 OR with value specified by OrData. All other bits in Operand are
3170 preserved. The new 32-bit value is returned.
3172 If 32-bit operations are not supported, then ASSERT().
3173 If StartBit is greater than 31, then ASSERT().
3174 If EndBit is greater than 31, then ASSERT().
3175 If EndBit is less than StartBit, then ASSERT().
3176 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
3177 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
3179 @param Operand Operand on which to perform the bitfield operation.
3180 @param StartBit The ordinal of the least significant bit in the bit field.
3182 @param EndBit The ordinal of the most significant bit in the bit field.
3184 @param AndData The value to AND with the read value from the value.
3185 @param OrData The value to OR with the result of the AND operation.
3187 @return The new 32-bit value.
3192 BitFieldAndThenOr32 (
3202 Returns a bit field from a 64-bit value.
3204 Returns the bitfield specified by the StartBit and the EndBit from Operand.
3206 If 64-bit operations are not supported, then ASSERT().
3207 If StartBit is greater than 63, then ASSERT().
3208 If EndBit is greater than 63, then ASSERT().
3209 If EndBit is less than StartBit, then ASSERT().
3211 @param Operand Operand on which to perform the bitfield operation.
3212 @param StartBit The ordinal of the least significant bit in the bit field.
3214 @param EndBit The ordinal of the most significant bit in the bit field.
3217 @return The bit field read.
3230 Writes a bit field to a 64-bit value, and returns the result.
3232 Writes Value to the bit field specified by the StartBit and the EndBit in
3233 Operand. All other bits in Operand are preserved. The new 64-bit value is
3236 If 64-bit operations are not supported, then ASSERT().
3237 If StartBit is greater than 63, then ASSERT().
3238 If EndBit is greater than 63, then ASSERT().
3239 If EndBit is less than StartBit, then ASSERT().
3240 If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
3242 @param Operand Operand on which to perform the bitfield operation.
3243 @param StartBit The ordinal of the least significant bit in the bit field.
3245 @param EndBit The ordinal of the most significant bit in the bit field.
3247 @param Value New value of the bit field.
3249 @return The new 64-bit value.
3263 Reads a bit field from a 64-bit value, performs a bitwise OR, and returns the
3266 Performs a bitwise OR between the bit field specified by StartBit
3267 and EndBit in Operand and the value specified by OrData. All other bits in
3268 Operand are preserved. The new 64-bit value is returned.
3270 If 64-bit operations are not supported, then ASSERT().
3271 If StartBit is greater than 63, then ASSERT().
3272 If EndBit is greater than 63, then ASSERT().
3273 If EndBit is less than StartBit, then ASSERT().
3274 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
3276 @param Operand Operand on which to perform the bitfield operation.
3277 @param StartBit The ordinal of the least significant bit in the bit field.
3279 @param EndBit The ordinal of the most significant bit in the bit field.
3281 @param OrData The value to OR with the read value from the value
3283 @return The new 64-bit value.
3297 Reads a bit field from a 64-bit value, performs a bitwise AND, and returns
3300 Performs a bitwise AND between the bit field specified by StartBit and EndBit
3301 in Operand and the value specified by AndData. All other bits in Operand are
3302 preserved. The new 64-bit value is returned.
3304 If 64-bit operations are not supported, then ASSERT().
3305 If StartBit is greater than 63, then ASSERT().
3306 If EndBit is greater than 63, then ASSERT().
3307 If EndBit is less than StartBit, then ASSERT().
3308 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
3310 @param Operand Operand on which to perform the bitfield operation.
3311 @param StartBit The ordinal of the least significant bit in the bit field.
3313 @param EndBit The ordinal of the most significant bit in the bit field.
3315 @param AndData The value to AND with the read value from the value
3317 @return The new 64-bit value.
3331 Reads a bit field from a 64-bit value, performs a bitwise AND followed by a
3332 bitwise OR, and returns the result.
3334 Performs a bitwise AND between the bit field specified by StartBit and EndBit
3335 in Operand and the value specified by AndData, followed by a bitwise
3336 OR with value specified by OrData. All other bits in Operand are
3337 preserved. The new 64-bit value is returned.
3339 If 64-bit operations are not supported, then ASSERT().
3340 If StartBit is greater than 63, then ASSERT().
3341 If EndBit is greater than 63, then ASSERT().
3342 If EndBit is less than StartBit, then ASSERT().
3343 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
3344 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
3346 @param Operand Operand on which to perform the bitfield operation.
3347 @param StartBit The ordinal of the least significant bit in the bit field.
3349 @param EndBit The ordinal of the most significant bit in the bit field.
3351 @param AndData The value to AND with the read value from the value.
3352 @param OrData The value to OR with the result of the AND operation.
3354 @return The new 64-bit value.
3359 BitFieldAndThenOr64 (
3368 // Base Library Checksum Functions
3372 Returns the sum of all elements in a buffer in unit of UINT8.
3373 During calculation, the carry bits are dropped.
3375 This function calculates the sum of all elements in a buffer
3376 in unit of UINT8. The carry bits in result of addition are dropped.
3377 The result is returned as UINT8. If Length is Zero, then Zero is
3380 If Buffer is NULL, then ASSERT().
3381 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
3383 @param Buffer The pointer to the buffer to carry out the sum operation.
3384 @param Length The size, in bytes, of Buffer.
3386 @return Sum The sum of Buffer with carry bits dropped during additions.
3392 IN CONST UINT8
*Buffer
,
3398 Returns the two's complement checksum of all elements in a buffer
3401 This function first calculates the sum of the 8-bit values in the
3402 buffer specified by Buffer and Length. The carry bits in the result
3403 of addition are dropped. Then, the two's complement of the sum is
3404 returned. If Length is 0, then 0 is returned.
3406 If Buffer is NULL, then ASSERT().
3407 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
3409 @param Buffer The pointer to the buffer to carry out the checksum operation.
3410 @param Length The size, in bytes, of Buffer.
3412 @return Checksum The two's complement checksum of Buffer.
3417 CalculateCheckSum8 (
3418 IN CONST UINT8
*Buffer
,
3424 Returns the sum of all elements in a buffer of 16-bit values. During
3425 calculation, the carry bits are dropped.
3427 This function calculates the sum of the 16-bit values in the buffer
3428 specified by Buffer and Length. The carry bits in result of addition are dropped.
3429 The 16-bit result is returned. If Length is 0, then 0 is returned.
3431 If Buffer is NULL, then ASSERT().
3432 If Buffer is not aligned on a 16-bit boundary, then ASSERT().
3433 If Length is not aligned on a 16-bit boundary, then ASSERT().
3434 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
3436 @param Buffer The pointer to the buffer to carry out the sum operation.
3437 @param Length The size, in bytes, of Buffer.
3439 @return Sum The sum of Buffer with carry bits dropped during additions.
3445 IN CONST UINT16
*Buffer
,
3451 Returns the two's complement checksum of all elements in a buffer of
3454 This function first calculates the sum of the 16-bit values in the buffer
3455 specified by Buffer and Length. The carry bits in the result of addition
3456 are dropped. Then, the two's complement of the sum is returned. If Length
3457 is 0, then 0 is returned.
3459 If Buffer is NULL, then ASSERT().
3460 If Buffer is not aligned on a 16-bit boundary, then ASSERT().
3461 If Length is not aligned on a 16-bit boundary, then ASSERT().
3462 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
3464 @param Buffer The pointer to the buffer to carry out the checksum operation.
3465 @param Length The size, in bytes, of Buffer.
3467 @return Checksum The two's complement checksum of Buffer.
3472 CalculateCheckSum16 (
3473 IN CONST UINT16
*Buffer
,
3479 Returns the sum of all elements in a buffer of 32-bit values. During
3480 calculation, the carry bits are dropped.
3482 This function calculates the sum of the 32-bit values in the buffer
3483 specified by Buffer and Length. The carry bits in result of addition are dropped.
3484 The 32-bit result is returned. If Length is 0, then 0 is returned.
3486 If Buffer is NULL, then ASSERT().
3487 If Buffer is not aligned on a 32-bit boundary, then ASSERT().
3488 If Length is not aligned on a 32-bit boundary, then ASSERT().
3489 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
3491 @param Buffer The pointer to the buffer to carry out the sum operation.
3492 @param Length The size, in bytes, of Buffer.
3494 @return Sum The sum of Buffer with carry bits dropped during additions.
3500 IN CONST UINT32
*Buffer
,
3506 Returns the two's complement checksum of all elements in a buffer of
3509 This function first calculates the sum of the 32-bit values in the buffer
3510 specified by Buffer and Length. The carry bits in the result of addition
3511 are dropped. Then, the two's complement of the sum is returned. If Length
3512 is 0, then 0 is returned.
3514 If Buffer is NULL, then ASSERT().
3515 If Buffer is not aligned on a 32-bit boundary, then ASSERT().
3516 If Length is not aligned on a 32-bit boundary, then ASSERT().
3517 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
3519 @param Buffer The pointer to the buffer to carry out the checksum operation.
3520 @param Length The size, in bytes, of Buffer.
3522 @return Checksum The two's complement checksum of Buffer.
3527 CalculateCheckSum32 (
3528 IN CONST UINT32
*Buffer
,
3534 Returns the sum of all elements in a buffer of 64-bit values. During
3535 calculation, the carry bits are dropped.
3537 This function calculates the sum of the 64-bit values in the buffer
3538 specified by Buffer and Length. The carry bits in result of addition are dropped.
3539 The 64-bit result is returned. If Length is 0, then 0 is returned.
3541 If Buffer is NULL, then ASSERT().
3542 If Buffer is not aligned on a 64-bit boundary, then ASSERT().
3543 If Length is not aligned on a 64-bit boundary, then ASSERT().
3544 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
3546 @param Buffer The pointer to the buffer to carry out the sum operation.
3547 @param Length The size, in bytes, of Buffer.
3549 @return Sum The sum of Buffer with carry bits dropped during additions.
3555 IN CONST UINT64
*Buffer
,
3561 Returns the two's complement checksum of all elements in a buffer of
3564 This function first calculates the sum of the 64-bit values in the buffer
3565 specified by Buffer and Length. The carry bits in the result of addition
3566 are dropped. Then, the two's complement of the sum is returned. If Length
3567 is 0, then 0 is returned.
3569 If Buffer is NULL, then ASSERT().
3570 If Buffer is not aligned on a 64-bit boundary, then ASSERT().
3571 If Length is not aligned on a 64-bit boundary, then ASSERT().
3572 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
3574 @param Buffer The pointer to the buffer to carry out the checksum operation.
3575 @param Length The size, in bytes, of Buffer.
3577 @return Checksum The two's complement checksum of Buffer.
3582 CalculateCheckSum64 (
3583 IN CONST UINT64
*Buffer
,
3589 // Base Library CPU Functions
3593 Function entry point used when a stack switch is requested with SwitchStack()
3595 @param Context1 Context1 parameter passed into SwitchStack().
3596 @param Context2 Context2 parameter passed into SwitchStack().
3601 (EFIAPI
*SWITCH_STACK_ENTRY_POINT
)(
3602 IN VOID
*Context1
, OPTIONAL
3603 IN VOID
*Context2 OPTIONAL
3608 Used to serialize load and store operations.
3610 All loads and stores that proceed calls to this function are guaranteed to be
3611 globally visible when this function returns.
3622 Saves the current CPU context that can be restored with a call to LongJump()
3625 Saves the current CPU context in the buffer specified by JumpBuffer and
3626 returns 0. The initial call to SetJump() must always return 0. Subsequent
3627 calls to LongJump() cause a non-zero value to be returned by SetJump().
3629 If JumpBuffer is NULL, then ASSERT().
3630 For Itanium processors, if JumpBuffer is not aligned on a 16-byte boundary, then ASSERT().
3632 NOTE: The structure BASE_LIBRARY_JUMP_BUFFER is CPU architecture specific.
3633 The same structure must never be used for more than one CPU architecture context.
3634 For example, a BASE_LIBRARY_JUMP_BUFFER allocated by an IA-32 module must never be used from an x64 module.
3635 SetJump()/LongJump() is not currently supported for the EBC processor type.
3637 @param JumpBuffer A pointer to CPU context buffer.
3639 @retval 0 Indicates a return from SetJump().
3645 OUT BASE_LIBRARY_JUMP_BUFFER
*JumpBuffer
3650 Restores the CPU context that was saved with SetJump().
3652 Restores the CPU context from the buffer specified by JumpBuffer. This
3653 function never returns to the caller. Instead is resumes execution based on
3654 the state of JumpBuffer.
3656 If JumpBuffer is NULL, then ASSERT().
3657 For Itanium processors, if JumpBuffer is not aligned on a 16-byte boundary, then ASSERT().
3658 If Value is 0, then ASSERT().
3660 @param JumpBuffer A pointer to CPU context buffer.
3661 @param Value The value to return when the SetJump() context is
3662 restored and must be non-zero.
3668 IN BASE_LIBRARY_JUMP_BUFFER
*JumpBuffer
,
3674 Enables CPU interrupts.
3685 Disables CPU interrupts.
3696 Disables CPU interrupts and returns the interrupt state prior to the disable
3699 @retval TRUE CPU interrupts were enabled on entry to this call.
3700 @retval FALSE CPU interrupts were disabled on entry to this call.
3705 SaveAndDisableInterrupts (
3711 Enables CPU interrupts for the smallest window required to capture any
3717 EnableDisableInterrupts (
3723 Retrieves the current CPU interrupt state.
3725 Returns TRUE if interrupts are currently enabled. Otherwise
3728 @retval TRUE CPU interrupts are enabled.
3729 @retval FALSE CPU interrupts are disabled.
3740 Set the current CPU interrupt state.
3742 Sets the current CPU interrupt state to the state specified by
3743 InterruptState. If InterruptState is TRUE, then interrupts are enabled. If
3744 InterruptState is FALSE, then interrupts are disabled. InterruptState is
3747 @param InterruptState TRUE if interrupts should enabled. FALSE if
3748 interrupts should be disabled.
3750 @return InterruptState
3756 IN BOOLEAN InterruptState
3761 Requests CPU to pause for a short period of time.
3763 Requests CPU to pause for a short period of time. Typically used in MP
3764 systems to prevent memory starvation while waiting for a spin lock.
3775 Transfers control to a function starting with a new stack.
3777 Transfers control to the function specified by EntryPoint using the
3778 new stack specified by NewStack and passing in the parameters specified
3779 by Context1 and Context2. Context1 and Context2 are optional and may
3780 be NULL. The function EntryPoint must never return. This function
3781 supports a variable number of arguments following the NewStack parameter.
3782 These additional arguments are ignored on IA-32, x64, and EBC architectures.
3783 Itanium processors expect one additional parameter of type VOID * that specifies
3784 the new backing store pointer.
3786 If EntryPoint is NULL, then ASSERT().
3787 If NewStack is NULL, then ASSERT().
3789 @param EntryPoint A pointer to function to call with the new stack.
3790 @param Context1 A pointer to the context to pass into the EntryPoint
3792 @param Context2 A pointer to the context to pass into the EntryPoint
3794 @param NewStack A pointer to the new stack to use for the EntryPoint
3796 @param ... This variable argument list is ignored for IA-32, x64, and
3797 EBC architectures. For Itanium processors, this variable
3798 argument list is expected to contain a single parameter of
3799 type VOID * that specifies the new backing store pointer.
3806 IN SWITCH_STACK_ENTRY_POINT EntryPoint
,
3807 IN VOID
*Context1
, OPTIONAL
3808 IN VOID
*Context2
, OPTIONAL
3815 Generates a breakpoint on the CPU.
3817 Generates a breakpoint on the CPU. The breakpoint must be implemented such
3818 that code can resume normal execution after the breakpoint.
3829 Executes an infinite loop.
3831 Forces the CPU to execute an infinite loop. A debugger may be used to skip
3832 past the loop and the code that follows the loop must execute properly. This
3833 implies that the infinite loop must not cause the code that follow it to be
3843 #if defined (MDE_CPU_IPF)
3846 Flush a range of cache lines in the cache coherency domain of the calling
3849 Flushes the cache lines specified by Address and Length. If Address is not aligned
3850 on a cache line boundary, then entire cache line containing Address is flushed.
3851 If Address + Length is not aligned on a cache line boundary, then the entire cache
3852 line containing Address + Length - 1 is flushed. This function may choose to flush
3853 the entire cache if that is more efficient than flushing the specified range. If
3854 Length is 0, the no cache lines are flushed. Address is returned.
3855 This function is only available on Itanium processors.
3857 If Length is greater than (MAX_ADDRESS - Address + 1), then ASSERT().
3859 @param Address The base address of the instruction lines to invalidate. If
3860 the CPU is in a physical addressing mode, then Address is a
3861 physical address. If the CPU is in a virtual addressing mode,
3862 then Address is a virtual address.
3864 @param Length The number of bytes to invalidate from the instruction cache.
3871 AsmFlushCacheRange (
3878 Executes an FC instruction.
3879 Executes an FC instruction on the cache line specified by Address.
3880 The cache line size affected is at least 32-bytes (aligned on a 32-byte boundary).
3881 An implementation may flush a larger region. This function is only available on Itanium processors.
3883 @param Address The Address of cache line to be flushed.
3885 @return The address of FC instruction executed.
3896 Executes an FC.I instruction.
3897 Executes an FC.I instruction on the cache line specified by Address.
3898 The cache line size affected is at least 32-bytes (aligned on a 32-byte boundary).
3899 An implementation may flush a larger region. This function is only available on Itanium processors.
3901 @param Address The Address of cache line to be flushed.
3903 @return The address of the FC.I instruction executed.
3914 Reads the current value of a Processor Identifier Register (CPUID).
3916 Reads and returns the current value of Processor Identifier Register specified by Index.
3917 The Index of largest implemented CPUID (One less than the number of implemented CPUID
3918 registers) is determined by CPUID [3] bits {7:0}.
3919 No parameter checking is performed on Index. If the Index value is beyond the
3920 implemented CPUID register range, a Reserved Register/Field fault may occur. The caller
3921 must either guarantee that Index is valid, or the caller must set up fault handlers to
3922 catch the faults. This function is only available on Itanium processors.
3924 @param Index The 8-bit Processor Identifier Register index to read.
3926 @return The current value of Processor Identifier Register specified by Index.
3937 Reads the current value of 64-bit Processor Status Register (PSR).
3938 This function is only available on Itanium processors.
3940 @return The current value of PSR.
3951 Writes the current value of 64-bit Processor Status Register (PSR).
3953 No parameter checking is performed on Value. All bits of Value corresponding to
3954 reserved fields of PSR must be 0 or a Reserved Register/Field fault may occur.
3955 The caller must either guarantee that Value is valid, or the caller must set up
3956 fault handlers to catch the faults. This function is only available on Itanium processors.
3958 @param Value The 64-bit value to write to PSR.
3960 @return The 64-bit value written to the PSR.
3971 Reads the current value of 64-bit Kernel Register #0 (KR0).
3973 Reads and returns the current value of KR0.
3974 This function is only available on Itanium processors.
3976 @return The current value of KR0.
3987 Reads the current value of 64-bit Kernel Register #1 (KR1).
3989 Reads and returns the current value of KR1.
3990 This function is only available on Itanium processors.
3992 @return The current value of KR1.
4003 Reads the current value of 64-bit Kernel Register #2 (KR2).
4005 Reads and returns the current value of KR2.
4006 This function is only available on Itanium processors.
4008 @return The current value of KR2.
4019 Reads the current value of 64-bit Kernel Register #3 (KR3).
4021 Reads and returns the current value of KR3.
4022 This function is only available on Itanium processors.
4024 @return The current value of KR3.
4035 Reads the current value of 64-bit Kernel Register #4 (KR4).
4037 Reads and returns the current value of KR4.
4038 This function is only available on Itanium processors.
4040 @return The current value of KR4.
4051 Reads the current value of 64-bit Kernel Register #5 (KR5).
4053 Reads and returns the current value of KR5.
4054 This function is only available on Itanium processors.
4056 @return The current value of KR5.
4067 Reads the current value of 64-bit Kernel Register #6 (KR6).
4069 Reads and returns the current value of KR6.
4070 This function is only available on Itanium processors.
4072 @return The current value of KR6.
4083 Reads the current value of 64-bit Kernel Register #7 (KR7).
4085 Reads and returns the current value of KR7.
4086 This function is only available on Itanium processors.
4088 @return The current value of KR7.
4099 Write the current value of 64-bit Kernel Register #0 (KR0).
4101 Writes the current value of KR0. The 64-bit value written to
4102 the KR0 is returned. This function is only available on Itanium processors.
4104 @param Value The 64-bit value to write to KR0.
4106 @return The 64-bit value written to the KR0.
4117 Write the current value of 64-bit Kernel Register #1 (KR1).
4119 Writes the current value of KR1. The 64-bit value written to
4120 the KR1 is returned. This function is only available on Itanium processors.
4122 @param Value The 64-bit value to write to KR1.
4124 @return The 64-bit value written to the KR1.
4135 Write the current value of 64-bit Kernel Register #2 (KR2).
4137 Writes the current value of KR2. The 64-bit value written to
4138 the KR2 is returned. This function is only available on Itanium processors.
4140 @param Value The 64-bit value to write to KR2.
4142 @return The 64-bit value written to the KR2.
4153 Write the current value of 64-bit Kernel Register #3 (KR3).
4155 Writes the current value of KR3. The 64-bit value written to
4156 the KR3 is returned. This function is only available on Itanium processors.
4158 @param Value The 64-bit value to write to KR3.
4160 @return The 64-bit value written to the KR3.
4171 Write the current value of 64-bit Kernel Register #4 (KR4).
4173 Writes the current value of KR4. The 64-bit value written to
4174 the KR4 is returned. This function is only available on Itanium processors.
4176 @param Value The 64-bit value to write to KR4.
4178 @return The 64-bit value written to the KR4.
4189 Write the current value of 64-bit Kernel Register #5 (KR5).
4191 Writes the current value of KR5. The 64-bit value written to
4192 the KR5 is returned. This function is only available on Itanium processors.
4194 @param Value The 64-bit value to write to KR5.
4196 @return The 64-bit value written to the KR5.
4207 Write the current value of 64-bit Kernel Register #6 (KR6).
4209 Writes the current value of KR6. The 64-bit value written to
4210 the KR6 is returned. This function is only available on Itanium processors.
4212 @param Value The 64-bit value to write to KR6.
4214 @return The 64-bit value written to the KR6.
4225 Write the current value of 64-bit Kernel Register #7 (KR7).
4227 Writes the current value of KR7. The 64-bit value written to
4228 the KR7 is returned. This function is only available on Itanium processors.
4230 @param Value The 64-bit value to write to KR7.
4232 @return The 64-bit value written to the KR7.
4243 Reads the current value of Interval Timer Counter Register (ITC).
4245 Reads and returns the current value of ITC.
4246 This function is only available on Itanium processors.
4248 @return The current value of ITC.
4259 Reads the current value of Interval Timer Vector Register (ITV).
4261 Reads and returns the current value of ITV.
4262 This function is only available on Itanium processors.
4264 @return The current value of ITV.
4275 Reads the current value of Interval Timer Match Register (ITM).
4277 Reads and returns the current value of ITM.
4278 This function is only available on Itanium processors.
4280 @return The current value of ITM.
4290 Writes the current value of 64-bit Interval Timer Counter Register (ITC).
4292 Writes the current value of ITC. The 64-bit value written to the ITC is returned.
4293 This function is only available on Itanium processors.
4295 @param Value The 64-bit value to write to ITC.
4297 @return The 64-bit value written to the ITC.
4308 Writes the current value of 64-bit Interval Timer Match Register (ITM).
4310 Writes the current value of ITM. The 64-bit value written to the ITM is returned.
4311 This function is only available on Itanium processors.
4313 @param Value The 64-bit value to write to ITM.
4315 @return The 64-bit value written to the ITM.
4326 Writes the current value of 64-bit Interval Timer Vector Register (ITV).
4328 Writes the current value of ITV. The 64-bit value written to the ITV is returned.
4329 No parameter checking is performed on Value. All bits of Value corresponding to
4330 reserved fields of ITV must be 0 or a Reserved Register/Field fault may occur.
4331 The caller must either guarantee that Value is valid, or the caller must set up
4332 fault handlers to catch the faults.
4333 This function is only available on Itanium processors.
4335 @param Value The 64-bit value to write to ITV.
4337 @return The 64-bit value written to the ITV.
4348 Reads the current value of Default Control Register (DCR).
4350 Reads and returns the current value of DCR. This function is only available on Itanium processors.
4352 @return The current value of DCR.
4363 Reads the current value of Interruption Vector Address Register (IVA).
4365 Reads and returns the current value of IVA. This function is only available on Itanium processors.
4367 @return The current value of IVA.
4377 Reads the current value of Page Table Address Register (PTA).
4379 Reads and returns the current value of PTA. This function is only available on Itanium processors.
4381 @return The current value of PTA.
4392 Writes the current value of 64-bit Default Control Register (DCR).
4394 Writes the current value of DCR. The 64-bit value written to the DCR is returned.
4395 No parameter checking is performed on Value. All bits of Value corresponding to
4396 reserved fields of DCR must be 0 or a Reserved Register/Field fault may occur.
4397 The caller must either guarantee that Value is valid, or the caller must set up
4398 fault handlers to catch the faults.
4399 This function is only available on Itanium processors.
4401 @param Value The 64-bit value to write to DCR.
4403 @return The 64-bit value written to the DCR.
4414 Writes the current value of 64-bit Interruption Vector Address Register (IVA).
4416 Writes the current value of IVA. The 64-bit value written to the IVA is returned.
4417 The size of vector table is 32 K bytes and is 32 K bytes aligned
4418 the low 15 bits of Value is ignored when written.
4419 This function is only available on Itanium processors.
4421 @param Value The 64-bit value to write to IVA.
4423 @return The 64-bit value written to the IVA.
4434 Writes the current value of 64-bit Page Table Address Register (PTA).
4436 Writes the current value of PTA. The 64-bit value written to the PTA is returned.
4437 No parameter checking is performed on Value. All bits of Value corresponding to
4438 reserved fields of DCR must be 0 or a Reserved Register/Field fault may occur.
4439 The caller must either guarantee that Value is valid, or the caller must set up
4440 fault handlers to catch the faults.
4441 This function is only available on Itanium processors.
4443 @param Value The 64-bit value to write to PTA.
4445 @return The 64-bit value written to the PTA.
4455 Reads the current value of Local Interrupt ID Register (LID).
4457 Reads and returns the current value of LID. This function is only available on Itanium processors.
4459 @return The current value of LID.
4470 Reads the current value of External Interrupt Vector Register (IVR).
4472 Reads and returns the current value of IVR. This function is only available on Itanium processors.
4474 @return The current value of IVR.
4485 Reads the current value of Task Priority Register (TPR).
4487 Reads and returns the current value of TPR. This function is only available on Itanium processors.
4489 @return The current value of TPR.
4500 Reads the current value of External Interrupt Request Register #0 (IRR0).
4502 Reads and returns the current value of IRR0. This function is only available on Itanium processors.
4504 @return The current value of IRR0.
4515 Reads the current value of External Interrupt Request Register #1 (IRR1).
4517 Reads and returns the current value of IRR1. This function is only available on Itanium processors.
4519 @return The current value of IRR1.
4530 Reads the current value of External Interrupt Request Register #2 (IRR2).
4532 Reads and returns the current value of IRR2. This function is only available on Itanium processors.
4534 @return The current value of IRR2.
4545 Reads the current value of External Interrupt Request Register #3 (IRR3).
4547 Reads and returns the current value of IRR3. This function is only available on Itanium processors.
4549 @return The current value of IRR3.
4560 Reads the current value of Performance Monitor Vector Register (PMV).
4562 Reads and returns the current value of PMV. This function is only available on Itanium processors.
4564 @return The current value of PMV.
4575 Reads the current value of Corrected Machine Check Vector Register (CMCV).
4577 Reads and returns the current value of CMCV. This function is only available on Itanium processors.
4579 @return The current value of CMCV.
4590 Reads the current value of Local Redirection Register #0 (LRR0).
4592 Reads and returns the current value of LRR0. This function is only available on Itanium processors.
4594 @return The current value of LRR0.
4605 Reads the current value of Local Redirection Register #1 (LRR1).
4607 Reads and returns the current value of LRR1. This function is only available on Itanium processors.
4609 @return The current value of LRR1.
4620 Writes the current value of 64-bit Page Local Interrupt ID Register (LID).
4622 Writes the current value of LID. The 64-bit value written to the LID is returned.
4623 No parameter checking is performed on Value. All bits of Value corresponding to
4624 reserved fields of LID must be 0 or a Reserved Register/Field fault may occur.
4625 The caller must either guarantee that Value is valid, or the caller must set up
4626 fault handlers to catch the faults.
4627 This function is only available on Itanium processors.
4629 @param Value The 64-bit value to write to LID.
4631 @return The 64-bit value written to the LID.
4642 Writes the current value of 64-bit Task Priority Register (TPR).
4644 Writes the current value of TPR. The 64-bit value written to the TPR is returned.
4645 No parameter checking is performed on Value. All bits of Value corresponding to
4646 reserved fields of TPR must be 0 or a Reserved Register/Field fault may occur.
4647 The caller must either guarantee that Value is valid, or the caller must set up
4648 fault handlers to catch the faults.
4649 This function is only available on Itanium processors.
4651 @param Value The 64-bit value to write to TPR.
4653 @return The 64-bit value written to the TPR.
4664 Performs a write operation on End OF External Interrupt Register (EOI).
4666 Writes a value of 0 to the EOI Register. This function is only available on Itanium processors.
4677 Writes the current value of 64-bit Performance Monitor Vector Register (PMV).
4679 Writes the current value of PMV. The 64-bit value written to the PMV is returned.
4680 No parameter checking is performed on Value. All bits of Value corresponding
4681 to reserved fields of PMV must be 0 or a Reserved Register/Field fault may occur.
4682 The caller must either guarantee that Value is valid, or the caller must set up
4683 fault handlers to catch the faults.
4684 This function is only available on Itanium processors.
4686 @param Value The 64-bit value to write to PMV.
4688 @return The 64-bit value written to the PMV.
4699 Writes the current value of 64-bit Corrected Machine Check Vector Register (CMCV).
4701 Writes the current value of CMCV. The 64-bit value written to the CMCV is returned.
4702 No parameter checking is performed on Value. All bits of Value corresponding
4703 to reserved fields of CMCV must be 0 or a Reserved Register/Field fault may occur.
4704 The caller must either guarantee that Value is valid, or the caller must set up
4705 fault handlers to catch the faults.
4706 This function is only available on Itanium processors.
4708 @param Value The 64-bit value to write to CMCV.
4710 @return The 64-bit value written to the CMCV.
4721 Writes the current value of 64-bit Local Redirection Register #0 (LRR0).
4723 Writes the current value of LRR0. The 64-bit value written to the LRR0 is returned.
4724 No parameter checking is performed on Value. All bits of Value corresponding
4725 to reserved fields of LRR0 must be 0 or a Reserved Register/Field fault may occur.
4726 The caller must either guarantee that Value is valid, or the caller must set up
4727 fault handlers to catch the faults.
4728 This function is only available on Itanium processors.
4730 @param Value The 64-bit value to write to LRR0.
4732 @return The 64-bit value written to the LRR0.
4743 Writes the current value of 64-bit Local Redirection Register #1 (LRR1).
4745 Writes the current value of LRR1. The 64-bit value written to the LRR1 is returned.
4746 No parameter checking is performed on Value. All bits of Value corresponding
4747 to reserved fields of LRR1 must be 0 or a Reserved Register/Field fault may occur.
4748 The caller must either guarantee that Value is valid, or the caller must
4749 set up fault handlers to catch the faults.
4750 This function is only available on Itanium processors.
4752 @param Value The 64-bit value to write to LRR1.
4754 @return The 64-bit value written to the LRR1.
4765 Reads the current value of Instruction Breakpoint Register (IBR).
4767 The Instruction Breakpoint Registers are used in pairs. The even numbered
4768 registers contain breakpoint addresses, and the odd numbered registers contain
4769 breakpoint mask conditions. At least four instruction registers pairs are implemented
4770 on all processor models. Implemented registers are contiguous starting with
4771 register 0. No parameter checking is performed on Index, and if the Index value
4772 is beyond the implemented IBR register range, a Reserved Register/Field fault may
4773 occur. The caller must either guarantee that Index is valid, or the caller must
4774 set up fault handlers to catch the faults.
4775 This function is only available on Itanium processors.
4777 @param Index The 8-bit Instruction Breakpoint Register index to read.
4779 @return The current value of Instruction Breakpoint Register specified by Index.
4790 Reads the current value of Data Breakpoint Register (DBR).
4792 The Data Breakpoint Registers are used in pairs. The even numbered registers
4793 contain breakpoint addresses, and odd numbered registers contain breakpoint
4794 mask conditions. At least four data registers pairs are implemented on all processor
4795 models. Implemented registers are contiguous starting with register 0.
4796 No parameter checking is performed on Index. If the Index value is beyond
4797 the implemented DBR register range, a Reserved Register/Field fault may occur.
4798 The caller must either guarantee that Index is valid, or the caller must set up
4799 fault handlers to catch the faults.
4800 This function is only available on Itanium processors.
4802 @param Index The 8-bit Data Breakpoint Register index to read.
4804 @return The current value of Data Breakpoint Register specified by Index.
4815 Reads the current value of Performance Monitor Configuration Register (PMC).
4817 All processor implementations provide at least four performance counters
4818 (PMC/PMD [4]...PMC/PMD [7] pairs), and four performance monitor counter overflow
4819 status registers (PMC [0]... PMC [3]). Processor implementations may provide
4820 additional implementation-dependent PMC and PMD to increase the number of
4821 'generic' performance counters (PMC/PMD pairs). The remainder of PMC and PMD
4822 register set is implementation dependent. No parameter checking is performed
4823 on Index. If the Index value is beyond the implemented PMC register range,
4824 zero value will be returned.
4825 This function is only available on Itanium processors.
4827 @param Index The 8-bit Performance Monitor Configuration Register index to read.
4829 @return The current value of Performance Monitor Configuration Register
4841 Reads the current value of Performance Monitor Data Register (PMD).
4843 All processor implementations provide at least 4 performance counters
4844 (PMC/PMD [4]...PMC/PMD [7] pairs), and 4 performance monitor counter
4845 overflow status registers (PMC [0]... PMC [3]). Processor implementations may
4846 provide additional implementation-dependent PMC and PMD to increase the number
4847 of 'generic' performance counters (PMC/PMD pairs). The remainder of PMC and PMD
4848 register set is implementation dependent. No parameter checking is performed
4849 on Index. If the Index value is beyond the implemented PMD register range,
4850 zero value will be returned.
4851 This function is only available on Itanium processors.
4853 @param Index The 8-bit Performance Monitor Data Register index to read.
4855 @return The current value of Performance Monitor Data Register specified by Index.
4866 Writes the current value of 64-bit Instruction Breakpoint Register (IBR).
4868 Writes current value of Instruction Breakpoint Register specified by Index.
4869 The Instruction Breakpoint Registers are used in pairs. The even numbered
4870 registers contain breakpoint addresses, and odd numbered registers contain
4871 breakpoint mask conditions. At least four instruction registers pairs are implemented
4872 on all processor models. Implemented registers are contiguous starting with
4873 register 0. No parameter checking is performed on Index. If the Index value
4874 is beyond the implemented IBR register range, a Reserved Register/Field fault may
4875 occur. The caller must either guarantee that Index is valid, or the caller must
4876 set up fault handlers to catch the faults.
4877 This function is only available on Itanium processors.
4879 @param Index The 8-bit Instruction Breakpoint Register index to write.
4880 @param Value The 64-bit value to write to IBR.
4882 @return The 64-bit value written to the IBR.
4894 Writes the current value of 64-bit Data Breakpoint Register (DBR).
4896 Writes current value of Data Breakpoint Register specified by Index.
4897 The Data Breakpoint Registers are used in pairs. The even numbered registers
4898 contain breakpoint addresses, and odd numbered registers contain breakpoint
4899 mask conditions. At least four data registers pairs are implemented on all processor
4900 models. Implemented registers are contiguous starting with register 0. No parameter
4901 checking is performed on Index. If the Index value is beyond the implemented
4902 DBR register range, a Reserved Register/Field fault may occur. The caller must
4903 either guarantee that Index is valid, or the caller must set up fault handlers to
4905 This function is only available on Itanium processors.
4907 @param Index The 8-bit Data Breakpoint Register index to write.
4908 @param Value The 64-bit value to write to DBR.
4910 @return The 64-bit value written to the DBR.
4922 Writes the current value of 64-bit Performance Monitor Configuration Register (PMC).
4924 Writes current value of Performance Monitor Configuration Register specified by Index.
4925 All processor implementations provide at least four performance counters
4926 (PMC/PMD [4]...PMC/PMD [7] pairs), and four performance monitor counter overflow status
4927 registers (PMC [0]... PMC [3]). Processor implementations may provide additional
4928 implementation-dependent PMC and PMD to increase the number of 'generic' performance
4929 counters (PMC/PMD pairs). The remainder of PMC and PMD register set is implementation
4930 dependent. No parameter checking is performed on Index. If the Index value is
4931 beyond the implemented PMC register range, the write is ignored.
4932 This function is only available on Itanium processors.
4934 @param Index The 8-bit Performance Monitor Configuration Register index to write.
4935 @param Value The 64-bit value to write to PMC.
4937 @return The 64-bit value written to the PMC.
4949 Writes the current value of 64-bit Performance Monitor Data Register (PMD).
4951 Writes current value of Performance Monitor Data Register specified by Index.
4952 All processor implementations provide at least four performance counters
4953 (PMC/PMD [4]...PMC/PMD [7] pairs), and four performance monitor counter overflow
4954 status registers (PMC [0]... PMC [3]). Processor implementations may provide
4955 additional implementation-dependent PMC and PMD to increase the number of 'generic'
4956 performance counters (PMC/PMD pairs). The remainder of PMC and PMD register set
4957 is implementation dependent. No parameter checking is performed on Index. If the
4958 Index value is beyond the implemented PMD register range, the write is ignored.
4959 This function is only available on Itanium processors.
4961 @param Index The 8-bit Performance Monitor Data Register index to write.
4962 @param Value The 64-bit value to write to PMD.
4964 @return The 64-bit value written to the PMD.
4976 Reads the current value of 64-bit Global Pointer (GP).
4978 Reads and returns the current value of GP.
4979 This function is only available on Itanium processors.
4981 @return The current value of GP.
4992 Write the current value of 64-bit Global Pointer (GP).
4994 Writes the current value of GP. The 64-bit value written to the GP is returned.
4995 No parameter checking is performed on Value.
4996 This function is only available on Itanium processors.
4998 @param Value The 64-bit value to write to GP.
5000 @return The 64-bit value written to the GP.
5011 Reads the current value of 64-bit Stack Pointer (SP).
5013 Reads and returns the current value of SP.
5014 This function is only available on Itanium processors.
5016 @return The current value of SP.
5027 /// Valid Index value for AsmReadControlRegister().
5029 #define IPF_CONTROL_REGISTER_DCR 0
5030 #define IPF_CONTROL_REGISTER_ITM 1
5031 #define IPF_CONTROL_REGISTER_IVA 2
5032 #define IPF_CONTROL_REGISTER_PTA 8
5033 #define IPF_CONTROL_REGISTER_IPSR 16
5034 #define IPF_CONTROL_REGISTER_ISR 17
5035 #define IPF_CONTROL_REGISTER_IIP 19
5036 #define IPF_CONTROL_REGISTER_IFA 20
5037 #define IPF_CONTROL_REGISTER_ITIR 21
5038 #define IPF_CONTROL_REGISTER_IIPA 22
5039 #define IPF_CONTROL_REGISTER_IFS 23
5040 #define IPF_CONTROL_REGISTER_IIM 24
5041 #define IPF_CONTROL_REGISTER_IHA 25
5042 #define IPF_CONTROL_REGISTER_LID 64
5043 #define IPF_CONTROL_REGISTER_IVR 65
5044 #define IPF_CONTROL_REGISTER_TPR 66
5045 #define IPF_CONTROL_REGISTER_EOI 67
5046 #define IPF_CONTROL_REGISTER_IRR0 68
5047 #define IPF_CONTROL_REGISTER_IRR1 69
5048 #define IPF_CONTROL_REGISTER_IRR2 70
5049 #define IPF_CONTROL_REGISTER_IRR3 71
5050 #define IPF_CONTROL_REGISTER_ITV 72
5051 #define IPF_CONTROL_REGISTER_PMV 73
5052 #define IPF_CONTROL_REGISTER_CMCV 74
5053 #define IPF_CONTROL_REGISTER_LRR0 80
5054 #define IPF_CONTROL_REGISTER_LRR1 81
5057 Reads a 64-bit control register.
5059 Reads and returns the control register specified by Index. The valid Index valued
5060 are defined above in "Related Definitions".
5061 If Index is invalid then 0xFFFFFFFFFFFFFFFF is returned. This function is only
5062 available on Itanium processors.
5064 @param Index The index of the control register to read.
5066 @return The control register specified by Index.
5071 AsmReadControlRegister (
5077 /// Valid Index value for AsmReadApplicationRegister().
5079 #define IPF_APPLICATION_REGISTER_K0 0
5080 #define IPF_APPLICATION_REGISTER_K1 1
5081 #define IPF_APPLICATION_REGISTER_K2 2
5082 #define IPF_APPLICATION_REGISTER_K3 3
5083 #define IPF_APPLICATION_REGISTER_K4 4
5084 #define IPF_APPLICATION_REGISTER_K5 5
5085 #define IPF_APPLICATION_REGISTER_K6 6
5086 #define IPF_APPLICATION_REGISTER_K7 7
5087 #define IPF_APPLICATION_REGISTER_RSC 16
5088 #define IPF_APPLICATION_REGISTER_BSP 17
5089 #define IPF_APPLICATION_REGISTER_BSPSTORE 18
5090 #define IPF_APPLICATION_REGISTER_RNAT 19
5091 #define IPF_APPLICATION_REGISTER_FCR 21
5092 #define IPF_APPLICATION_REGISTER_EFLAG 24
5093 #define IPF_APPLICATION_REGISTER_CSD 25
5094 #define IPF_APPLICATION_REGISTER_SSD 26
5095 #define IPF_APPLICATION_REGISTER_CFLG 27
5096 #define IPF_APPLICATION_REGISTER_FSR 28
5097 #define IPF_APPLICATION_REGISTER_FIR 29
5098 #define IPF_APPLICATION_REGISTER_FDR 30
5099 #define IPF_APPLICATION_REGISTER_CCV 32
5100 #define IPF_APPLICATION_REGISTER_UNAT 36
5101 #define IPF_APPLICATION_REGISTER_FPSR 40
5102 #define IPF_APPLICATION_REGISTER_ITC 44
5103 #define IPF_APPLICATION_REGISTER_PFS 64
5104 #define IPF_APPLICATION_REGISTER_LC 65
5105 #define IPF_APPLICATION_REGISTER_EC 66
5108 Reads a 64-bit application register.
5110 Reads and returns the application register specified by Index. The valid Index
5111 valued are defined above in "Related Definitions".
5112 If Index is invalid then 0xFFFFFFFFFFFFFFFF is returned. This function is only
5113 available on Itanium processors.
5115 @param Index The index of the application register to read.
5117 @return The application register specified by Index.
5122 AsmReadApplicationRegister (
5128 Reads the current value of a Machine Specific Register (MSR).
5130 Reads and returns the current value of the Machine Specific Register specified by Index. No
5131 parameter checking is performed on Index, and if the Index value is beyond the implemented MSR
5132 register range, a Reserved Register/Field fault may occur. The caller must either guarantee that
5133 Index is valid, or the caller must set up fault handlers to catch the faults. This function is
5134 only available on Itanium processors.
5136 @param Index The 8-bit Machine Specific Register index to read.
5138 @return The current value of the Machine Specific Register specified by Index.
5149 Writes the current value of a Machine Specific Register (MSR).
5151 Writes Value to the Machine Specific Register specified by Index. Value is returned. No
5152 parameter checking is performed on Index, and if the Index value is beyond the implemented MSR
5153 register range, a Reserved Register/Field fault may occur. The caller must either guarantee that
5154 Index is valid, or the caller must set up fault handlers to catch the faults. This function is
5155 only available on Itanium processors.
5157 @param Index The 8-bit Machine Specific Register index to write.
5158 @param Value The 64-bit value to write to the Machine Specific Register.
5160 @return The 64-bit value to write to the Machine Specific Register.
5172 Determines if the CPU is currently executing in virtual, physical, or mixed mode.
5174 Determines the current execution mode of the CPU.
5175 If the CPU is in virtual mode(PSR.RT=1, PSR.DT=1, PSR.IT=1), then 1 is returned.
5176 If the CPU is in physical mode(PSR.RT=0, PSR.DT=0, PSR.IT=0), then 0 is returned.
5177 If the CPU is not in physical mode or virtual mode, then it is in mixed mode,
5179 This function is only available on Itanium processors.
5181 @retval 1 The CPU is in virtual mode.
5182 @retval 0 The CPU is in physical mode.
5183 @retval -1 The CPU is in mixed mode.
5194 Makes a PAL procedure call.
5196 This is a wrapper function to make a PAL procedure call. Based on the Index
5197 value this API will make static or stacked PAL call. The following table
5198 describes the usage of PAL Procedure Index Assignment. Architected procedures
5199 may be designated as required or optional. If a PAL procedure is specified
5200 as optional, a unique return code of 0xFFFFFFFFFFFFFFFF is returned in the
5201 Status field of the PAL_CALL_RETURN structure.
5202 This indicates that the procedure is not present in this PAL implementation.
5203 It is the caller's responsibility to check for this return code after calling
5204 any optional PAL procedure.
5205 No parameter checking is performed on the 5 input parameters, but there are
5206 some common rules that the caller should follow when making a PAL call. Any
5207 address passed to PAL as buffers for return parameters must be 8-byte aligned.
5208 Unaligned addresses may cause undefined results. For those parameters defined
5209 as reserved or some fields defined as reserved must be zero filled or the invalid
5210 argument return value may be returned or undefined result may occur during the
5211 execution of the procedure. If the PalEntryPoint does not point to a valid
5212 PAL entry point then the system behavior is undefined. This function is only
5213 available on Itanium processors.
5215 @param PalEntryPoint The PAL procedure calls entry point.
5216 @param Index The PAL procedure Index number.
5217 @param Arg2 The 2nd parameter for PAL procedure calls.
5218 @param Arg3 The 3rd parameter for PAL procedure calls.
5219 @param Arg4 The 4th parameter for PAL procedure calls.
5221 @return structure returned from the PAL Call procedure, including the status and return value.
5227 IN UINT64 PalEntryPoint
,
5235 #if defined (MDE_CPU_IA32) || defined (MDE_CPU_X64)
5237 /// IA32 and x64 Specific Functions.
5238 /// Byte packed structure for 16-bit Real Mode EFLAGS.
5242 UINT32 CF
:1; ///< Carry Flag.
5243 UINT32 Reserved_0
:1; ///< Reserved.
5244 UINT32 PF
:1; ///< Parity Flag.
5245 UINT32 Reserved_1
:1; ///< Reserved.
5246 UINT32 AF
:1; ///< Auxiliary Carry Flag.
5247 UINT32 Reserved_2
:1; ///< Reserved.
5248 UINT32 ZF
:1; ///< Zero Flag.
5249 UINT32 SF
:1; ///< Sign Flag.
5250 UINT32 TF
:1; ///< Trap Flag.
5251 UINT32 IF
:1; ///< Interrupt Enable Flag.
5252 UINT32 DF
:1; ///< Direction Flag.
5253 UINT32 OF
:1; ///< Overflow Flag.
5254 UINT32 IOPL
:2; ///< I/O Privilege Level.
5255 UINT32 NT
:1; ///< Nested Task.
5256 UINT32 Reserved_3
:1; ///< Reserved.
5262 /// Byte packed structure for EFLAGS/RFLAGS.
5263 /// 32-bits on IA-32.
5264 /// 64-bits on x64. The upper 32-bits on x64 are reserved.
5268 UINT32 CF
:1; ///< Carry Flag.
5269 UINT32 Reserved_0
:1; ///< Reserved.
5270 UINT32 PF
:1; ///< Parity Flag.
5271 UINT32 Reserved_1
:1; ///< Reserved.
5272 UINT32 AF
:1; ///< Auxiliary Carry Flag.
5273 UINT32 Reserved_2
:1; ///< Reserved.
5274 UINT32 ZF
:1; ///< Zero Flag.
5275 UINT32 SF
:1; ///< Sign Flag.
5276 UINT32 TF
:1; ///< Trap Flag.
5277 UINT32 IF
:1; ///< Interrupt Enable Flag.
5278 UINT32 DF
:1; ///< Direction Flag.
5279 UINT32 OF
:1; ///< Overflow Flag.
5280 UINT32 IOPL
:2; ///< I/O Privilege Level.
5281 UINT32 NT
:1; ///< Nested Task.
5282 UINT32 Reserved_3
:1; ///< Reserved.
5283 UINT32 RF
:1; ///< Resume Flag.
5284 UINT32 VM
:1; ///< Virtual 8086 Mode.
5285 UINT32 AC
:1; ///< Alignment Check.
5286 UINT32 VIF
:1; ///< Virtual Interrupt Flag.
5287 UINT32 VIP
:1; ///< Virtual Interrupt Pending.
5288 UINT32 ID
:1; ///< ID Flag.
5289 UINT32 Reserved_4
:10; ///< Reserved.
5295 /// Byte packed structure for Control Register 0 (CR0).
5296 /// 32-bits on IA-32.
5297 /// 64-bits on x64. The upper 32-bits on x64 are reserved.
5301 UINT32 PE
:1; ///< Protection Enable.
5302 UINT32 MP
:1; ///< Monitor Coprocessor.
5303 UINT32 EM
:1; ///< Emulation.
5304 UINT32 TS
:1; ///< Task Switched.
5305 UINT32 ET
:1; ///< Extension Type.
5306 UINT32 NE
:1; ///< Numeric Error.
5307 UINT32 Reserved_0
:10; ///< Reserved.
5308 UINT32 WP
:1; ///< Write Protect.
5309 UINT32 Reserved_1
:1; ///< Reserved.
5310 UINT32 AM
:1; ///< Alignment Mask.
5311 UINT32 Reserved_2
:10; ///< Reserved.
5312 UINT32 NW
:1; ///< Mot Write-through.
5313 UINT32 CD
:1; ///< Cache Disable.
5314 UINT32 PG
:1; ///< Paging.
5320 /// Byte packed structure for Control Register 4 (CR4).
5321 /// 32-bits on IA-32.
5322 /// 64-bits on x64. The upper 32-bits on x64 are reserved.
5326 UINT32 VME
:1; ///< Virtual-8086 Mode Extensions.
5327 UINT32 PVI
:1; ///< Protected-Mode Virtual Interrupts.
5328 UINT32 TSD
:1; ///< Time Stamp Disable.
5329 UINT32 DE
:1; ///< Debugging Extensions.
5330 UINT32 PSE
:1; ///< Page Size Extensions.
5331 UINT32 PAE
:1; ///< Physical Address Extension.
5332 UINT32 MCE
:1; ///< Machine Check Enable.
5333 UINT32 PGE
:1; ///< Page Global Enable.
5334 UINT32 PCE
:1; ///< Performance Monitoring Counter
5336 UINT32 OSFXSR
:1; ///< Operating System Support for
5337 ///< FXSAVE and FXRSTOR instructions
5338 UINT32 OSXMMEXCPT
:1; ///< Operating System Support for
5339 ///< Unmasked SIMD Floating Point
5341 UINT32 Reserved_0
:2; ///< Reserved.
5342 UINT32 VMXE
:1; ///< VMX Enable
5343 UINT32 Reserved_1
:18; ///< Reserved.
5349 /// Byte packed structure for a segment descriptor in a GDT/LDT.
5368 } IA32_SEGMENT_DESCRIPTOR
;
5371 /// Byte packed structure for an IDTR, GDTR, LDTR descriptor.
5380 #define IA32_IDT_GATE_TYPE_TASK 0x85
5381 #define IA32_IDT_GATE_TYPE_INTERRUPT_16 0x86
5382 #define IA32_IDT_GATE_TYPE_TRAP_16 0x87
5383 #define IA32_IDT_GATE_TYPE_INTERRUPT_32 0x8E
5384 #define IA32_IDT_GATE_TYPE_TRAP_32 0x8F
5387 #if defined (MDE_CPU_IA32)
5389 /// Byte packed structure for an IA-32 Interrupt Gate Descriptor.
5393 UINT32 OffsetLow
:16; ///< Offset bits 15..0.
5394 UINT32 Selector
:16; ///< Selector.
5395 UINT32 Reserved_0
:8; ///< Reserved.
5396 UINT32 GateType
:8; ///< Gate Type. See #defines above.
5397 UINT32 OffsetHigh
:16; ///< Offset bits 31..16.
5400 } IA32_IDT_GATE_DESCRIPTOR
;
5404 #if defined (MDE_CPU_X64)
5406 /// Byte packed structure for an x64 Interrupt Gate Descriptor.
5410 UINT32 OffsetLow
:16; ///< Offset bits 15..0.
5411 UINT32 Selector
:16; ///< Selector.
5412 UINT32 Reserved_0
:8; ///< Reserved.
5413 UINT32 GateType
:8; ///< Gate Type. See #defines above.
5414 UINT32 OffsetHigh
:16; ///< Offset bits 31..16.
5415 UINT32 OffsetUpper
:32; ///< Offset bits 63..32.
5416 UINT32 Reserved_1
:32; ///< Reserved.
5422 } IA32_IDT_GATE_DESCRIPTOR
;
5427 /// Byte packed structure for an FP/SSE/SSE2 context.
5434 /// Structures for the 16-bit real mode thunks.
5487 IA32_EFLAGS32 EFLAGS
;
5497 } IA32_REGISTER_SET
;
5500 /// Byte packed structure for an 16-bit real mode thunks.
5503 IA32_REGISTER_SET
*RealModeState
;
5504 VOID
*RealModeBuffer
;
5505 UINT32 RealModeBufferSize
;
5506 UINT32 ThunkAttributes
;
5509 #define THUNK_ATTRIBUTE_BIG_REAL_MODE 0x00000001
5510 #define THUNK_ATTRIBUTE_DISABLE_A20_MASK_INT_15 0x00000002
5511 #define THUNK_ATTRIBUTE_DISABLE_A20_MASK_KBD_CTRL 0x00000004
5514 Retrieves CPUID information.
5516 Executes the CPUID instruction with EAX set to the value specified by Index.
5517 This function always returns Index.
5518 If Eax is not NULL, then the value of EAX after CPUID is returned in Eax.
5519 If Ebx is not NULL, then the value of EBX after CPUID is returned in Ebx.
5520 If Ecx is not NULL, then the value of ECX after CPUID is returned in Ecx.
5521 If Edx is not NULL, then the value of EDX after CPUID is returned in Edx.
5522 This function is only available on IA-32 and x64.
5524 @param Index The 32-bit value to load into EAX prior to invoking the CPUID
5526 @param Eax The pointer to the 32-bit EAX value returned by the CPUID
5527 instruction. This is an optional parameter that may be NULL.
5528 @param Ebx The pointer to the 32-bit EBX value returned by the CPUID
5529 instruction. This is an optional parameter that may be NULL.
5530 @param Ecx The pointer to the 32-bit ECX value returned by the CPUID
5531 instruction. This is an optional parameter that may be NULL.
5532 @param Edx The pointer to the 32-bit EDX value returned by the CPUID
5533 instruction. This is an optional parameter that may be NULL.
5542 OUT UINT32
*Eax
, OPTIONAL
5543 OUT UINT32
*Ebx
, OPTIONAL
5544 OUT UINT32
*Ecx
, OPTIONAL
5545 OUT UINT32
*Edx OPTIONAL
5550 Retrieves CPUID information using an extended leaf identifier.
5552 Executes the CPUID instruction with EAX set to the value specified by Index
5553 and ECX set to the value specified by SubIndex. This function always returns
5554 Index. This function is only available on IA-32 and x64.
5556 If Eax is not NULL, then the value of EAX after CPUID is returned in Eax.
5557 If Ebx is not NULL, then the value of EBX after CPUID is returned in Ebx.
5558 If Ecx is not NULL, then the value of ECX after CPUID is returned in Ecx.
5559 If Edx is not NULL, then the value of EDX after CPUID is returned in Edx.
5561 @param Index The 32-bit value to load into EAX prior to invoking the
5563 @param SubIndex The 32-bit value to load into ECX prior to invoking the
5565 @param Eax The pointer to the 32-bit EAX value returned by the CPUID
5566 instruction. This is an optional parameter that may be
5568 @param Ebx The pointer to the 32-bit EBX value returned by the CPUID
5569 instruction. This is an optional parameter that may be
5571 @param Ecx The pointer to the 32-bit ECX value returned by the CPUID
5572 instruction. This is an optional parameter that may be
5574 @param Edx The pointer to the 32-bit EDX value returned by the CPUID
5575 instruction. This is an optional parameter that may be
5586 OUT UINT32
*Eax
, OPTIONAL
5587 OUT UINT32
*Ebx
, OPTIONAL
5588 OUT UINT32
*Ecx
, OPTIONAL
5589 OUT UINT32
*Edx OPTIONAL
5594 Set CD bit and clear NW bit of CR0 followed by a WBINVD.
5596 Disables the caches by setting the CD bit of CR0 to 1, clearing the NW bit of CR0 to 0,
5597 and executing a WBINVD instruction. This function is only available on IA-32 and x64.
5608 Perform a WBINVD and clear both the CD and NW bits of CR0.
5610 Enables the caches by executing a WBINVD instruction and then clear both the CD and NW
5611 bits of CR0 to 0. This function is only available on IA-32 and x64.
5622 Returns the lower 32-bits of a Machine Specific Register(MSR).
5624 Reads and returns the lower 32-bits of the MSR specified by Index.
5625 No parameter checking is performed on Index, and some Index values may cause
5626 CPU exceptions. The caller must either guarantee that Index is valid, or the
5627 caller must set up exception handlers to catch the exceptions. This function
5628 is only available on IA-32 and x64.
5630 @param Index The 32-bit MSR index to read.
5632 @return The lower 32 bits of the MSR identified by Index.
5643 Writes a 32-bit value to a Machine Specific Register(MSR), and returns the value.
5644 The upper 32-bits of the MSR are set to zero.
5646 Writes the 32-bit value specified by Value to the MSR specified by Index. The
5647 upper 32-bits of the MSR write are set to zero. The 32-bit value written to
5648 the MSR is returned. No parameter checking is performed on Index or Value,
5649 and some of these may cause CPU exceptions. The caller must either guarantee
5650 that Index and Value are valid, or the caller must establish proper exception
5651 handlers. This function is only available on IA-32 and x64.
5653 @param Index The 32-bit MSR index to write.
5654 @param Value The 32-bit value to write to the MSR.
5668 Reads a 64-bit MSR, performs a bitwise OR on the lower 32-bits, and
5669 writes the result back to the 64-bit MSR.
5671 Reads the 64-bit MSR specified by Index, performs a bitwise OR
5672 between the lower 32-bits of the read result and the value specified by
5673 OrData, and writes the result to the 64-bit MSR specified by Index. The lower
5674 32-bits of the value written to the MSR is returned. No parameter checking is
5675 performed on Index or OrData, and some of these may cause CPU exceptions. The
5676 caller must either guarantee that Index and OrData are valid, or the caller
5677 must establish proper exception handlers. This function is only available on
5680 @param Index The 32-bit MSR index to write.
5681 @param OrData The value to OR with the read value from the MSR.
5683 @return The lower 32-bit value written to the MSR.
5695 Reads a 64-bit MSR, performs a bitwise AND on the lower 32-bits, and writes
5696 the result back to the 64-bit MSR.
5698 Reads the 64-bit MSR specified by Index, performs a bitwise AND between the
5699 lower 32-bits of the read result and the value specified by AndData, and
5700 writes the result to the 64-bit MSR specified by Index. The lower 32-bits of
5701 the value written to the MSR is returned. No parameter checking is performed
5702 on Index or AndData, and some of these may cause CPU exceptions. The caller
5703 must either guarantee that Index and AndData are valid, or the caller must
5704 establish proper exception handlers. This function is only available on IA-32
5707 @param Index The 32-bit MSR index to write.
5708 @param AndData The value to AND with the read value from the MSR.
5710 @return The lower 32-bit value written to the MSR.
5722 Reads a 64-bit MSR, performs a bitwise AND followed by a bitwise OR
5723 on the lower 32-bits, and writes the result back to the 64-bit MSR.
5725 Reads the 64-bit MSR specified by Index, performs a bitwise AND between the
5726 lower 32-bits of the read result and the value specified by AndData
5727 preserving the upper 32-bits, performs a bitwise OR between the
5728 result of the AND operation and the value specified by OrData, and writes the
5729 result to the 64-bit MSR specified by Address. The lower 32-bits of the value
5730 written to the MSR is returned. No parameter checking is performed on Index,
5731 AndData, or OrData, and some of these may cause CPU exceptions. The caller
5732 must either guarantee that Index, AndData, and OrData are valid, or the
5733 caller must establish proper exception handlers. This function is only
5734 available on IA-32 and x64.
5736 @param Index The 32-bit MSR index to write.
5737 @param AndData The value to AND with the read value from the MSR.
5738 @param OrData The value to OR with the result of the AND operation.
5740 @return The lower 32-bit value written to the MSR.
5753 Reads a bit field of an MSR.
5755 Reads the bit field in the lower 32-bits of a 64-bit MSR. The bit field is
5756 specified by the StartBit and the EndBit. The value of the bit field is
5757 returned. The caller must either guarantee that Index is valid, or the caller
5758 must set up exception handlers to catch the exceptions. This function is only
5759 available on IA-32 and x64.
5761 If StartBit is greater than 31, then ASSERT().
5762 If EndBit is greater than 31, then ASSERT().
5763 If EndBit is less than StartBit, then ASSERT().
5765 @param Index The 32-bit MSR index to read.
5766 @param StartBit The ordinal of the least significant bit in the bit field.
5768 @param EndBit The ordinal of the most significant bit in the bit field.
5771 @return The bit field read from the MSR.
5776 AsmMsrBitFieldRead32 (
5784 Writes a bit field to an MSR.
5786 Writes Value to a bit field in the lower 32-bits of a 64-bit MSR. The bit
5787 field is specified by the StartBit and the EndBit. All other bits in the
5788 destination MSR are preserved. The lower 32-bits of the MSR written is
5789 returned. The caller must either guarantee that Index and the data written
5790 is valid, or the caller must set up exception handlers to catch the exceptions.
5791 This 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 Value 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 Value New value of the bit field.
5805 @return The lower 32-bit of the value written to the MSR.
5810 AsmMsrBitFieldWrite32 (
5819 Reads a bit field in a 64-bit MSR, performs a bitwise OR, 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 OR
5823 between the read result and the value specified by OrData, and writes the
5824 result to the 64-bit MSR specified by Index. The lower 32-bits of the value
5825 written to the MSR are returned. Extra left bits in OrData are stripped. The
5826 caller must either guarantee that Index and the data written is valid, or
5827 the caller must set up exception handlers to catch the exceptions. This
5828 function is only 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 OrData 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 OrData The value to OR with the read value from the MSR.
5842 @return The lower 32-bit of the value written to the MSR.
5847 AsmMsrBitFieldOr32 (
5856 Reads a bit field in a 64-bit MSR, performs a bitwise AND, and writes the
5857 result back to the bit field in the 64-bit MSR.
5859 Reads the 64-bit MSR specified by Index, performs a bitwise AND between the
5860 read result and the value specified by AndData, and writes the result to the
5861 64-bit MSR specified by Index. The lower 32-bits of the value written to the
5862 MSR are returned. Extra left bits in AndData are stripped. The caller must
5863 either guarantee that Index and the data written is valid, or the caller must
5864 set up exception handlers to catch the exceptions. This function is only
5865 available on IA-32 and x64.
5867 If StartBit is greater than 31, then ASSERT().
5868 If EndBit is greater than 31, then ASSERT().
5869 If EndBit is less than StartBit, then ASSERT().
5870 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
5872 @param Index The 32-bit MSR index to write.
5873 @param StartBit The ordinal of the least significant bit in the bit field.
5875 @param EndBit The ordinal of the most significant bit in the bit field.
5877 @param AndData The value to AND with the read value from the MSR.
5879 @return The lower 32-bit of the value written to the MSR.
5884 AsmMsrBitFieldAnd32 (
5893 Reads a bit field in a 64-bit MSR, performs a bitwise AND followed by a
5894 bitwise OR, and writes the result back to the bit field in the
5897 Reads the 64-bit MSR specified by Index, performs a bitwise AND followed by a
5898 bitwise OR between the read result and the value specified by
5899 AndData, and writes the result to the 64-bit MSR specified by Index. The
5900 lower 32-bits of the value written to the MSR are returned. Extra left bits
5901 in both AndData and OrData are stripped. The caller must either guarantee
5902 that Index and the data written is valid, or the caller must set up exception
5903 handlers to catch the exceptions. This function is only available on IA-32
5906 If StartBit is greater than 31, then ASSERT().
5907 If EndBit is greater than 31, then ASSERT().
5908 If EndBit is less than StartBit, then ASSERT().
5909 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
5910 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
5912 @param Index The 32-bit MSR index to write.
5913 @param StartBit The ordinal of the least significant bit in the bit field.
5915 @param EndBit The ordinal of the most significant bit in the bit field.
5917 @param AndData The value to AND with the read value from the MSR.
5918 @param OrData The value to OR with the result of the AND operation.
5920 @return The lower 32-bit of the value written to the MSR.
5925 AsmMsrBitFieldAndThenOr32 (
5935 Returns a 64-bit Machine Specific Register(MSR).
5937 Reads and returns the 64-bit MSR specified by Index. No parameter checking is
5938 performed on Index, and some Index values may cause CPU exceptions. The
5939 caller must either guarantee that Index is valid, or the caller must set up
5940 exception handlers to catch the exceptions. This function is only available
5943 @param Index The 32-bit MSR index to read.
5945 @return The value of the MSR identified by Index.
5956 Writes a 64-bit value to a Machine Specific Register(MSR), and returns the
5959 Writes the 64-bit value specified by Value to the MSR specified by Index. The
5960 64-bit value written to the MSR is returned. No parameter checking is
5961 performed on Index or Value, and some of these may cause CPU exceptions. The
5962 caller must either guarantee that Index and Value are valid, or the caller
5963 must establish proper exception handlers. This function is only available on
5966 @param Index The 32-bit MSR index to write.
5967 @param Value The 64-bit value to write to the MSR.
5981 Reads a 64-bit MSR, performs a bitwise OR, and writes the result
5982 back to the 64-bit MSR.
5984 Reads the 64-bit MSR specified by Index, performs a bitwise OR
5985 between the read result and the value specified by OrData, and writes the
5986 result to the 64-bit MSR specified by Index. The value written to the MSR is
5987 returned. No parameter checking is performed on Index or OrData, and some of
5988 these may cause CPU exceptions. The caller must either guarantee that Index
5989 and OrData are valid, or the caller must establish proper exception handlers.
5990 This function is only available on IA-32 and x64.
5992 @param Index The 32-bit MSR index to write.
5993 @param OrData The value to OR with the read value from the MSR.
5995 @return The value written back to the MSR.
6007 Reads a 64-bit MSR, performs a bitwise AND, and writes the result back to the
6010 Reads the 64-bit MSR specified by Index, performs a bitwise AND between the
6011 read result and the value specified by OrData, and writes the result to the
6012 64-bit MSR specified by Index. The value written to the MSR is returned. No
6013 parameter checking is performed on Index or OrData, and some of these may
6014 cause CPU exceptions. The caller must either guarantee that Index and OrData
6015 are valid, or the caller must establish proper exception handlers. This
6016 function is only available on IA-32 and x64.
6018 @param Index The 32-bit MSR index to write.
6019 @param AndData The value to AND with the read value from the MSR.
6021 @return The value written back to the MSR.
6033 Reads a 64-bit MSR, performs a bitwise AND followed by a bitwise
6034 OR, and writes the result back to the 64-bit MSR.
6036 Reads the 64-bit MSR specified by Index, performs a bitwise AND between read
6037 result and the value specified by AndData, performs a bitwise OR
6038 between the result of the AND operation and the value specified by OrData,
6039 and writes the result to the 64-bit MSR specified by Index. The value written
6040 to the MSR is returned. No parameter checking is performed on Index, AndData,
6041 or OrData, and some of these may cause CPU exceptions. The caller must either
6042 guarantee that Index, AndData, and OrData are valid, or the caller must
6043 establish proper exception handlers. This function is only available on IA-32
6046 @param Index The 32-bit MSR index to write.
6047 @param AndData The value to AND with the read value from the MSR.
6048 @param OrData The value to OR with the result of the AND operation.
6050 @return The value written back to the MSR.
6063 Reads a bit field of an MSR.
6065 Reads the bit field in the 64-bit MSR. The bit field is specified by the
6066 StartBit and the EndBit. The value of the bit field is returned. The caller
6067 must either guarantee that Index is valid, or the caller must set up
6068 exception handlers to catch the exceptions. This function is only available
6071 If StartBit is greater than 63, then ASSERT().
6072 If EndBit is greater than 63, then ASSERT().
6073 If EndBit is less than StartBit, then ASSERT().
6075 @param Index The 32-bit MSR index to read.
6076 @param StartBit The ordinal of the least significant bit in the bit field.
6078 @param EndBit The ordinal of the most significant bit in the bit field.
6081 @return The value read from the MSR.
6086 AsmMsrBitFieldRead64 (
6094 Writes a bit field to an MSR.
6096 Writes Value to a bit field in a 64-bit MSR. The bit field is specified by
6097 the StartBit and the EndBit. All other bits in the destination MSR are
6098 preserved. The MSR written is returned. The caller must either guarantee
6099 that Index and the data written is valid, or the caller must set up exception
6100 handlers to catch the exceptions. This function is only available on IA-32 and x64.
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 Value 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 Value New value of the bit field.
6114 @return The value written back to the MSR.
6119 AsmMsrBitFieldWrite64 (
6128 Reads a bit field in a 64-bit MSR, performs a bitwise OR, and
6129 writes the result back to the bit field in the 64-bit MSR.
6131 Reads the 64-bit MSR specified by Index, performs a bitwise OR
6132 between the read result and the value specified by OrData, and writes the
6133 result to the 64-bit MSR specified by Index. The value written to the MSR is
6134 returned. Extra left bits in OrData are stripped. The caller must either
6135 guarantee that Index and the data written is valid, or the caller must set up
6136 exception handlers to catch the exceptions. This function is only available
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 OrData 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 OrData The value to OR with the read value from the bit field.
6151 @return The value written back to the MSR.
6156 AsmMsrBitFieldOr64 (
6165 Reads a bit field in a 64-bit MSR, performs a bitwise AND, and writes the
6166 result back to the bit field in the 64-bit MSR.
6168 Reads the 64-bit MSR specified by Index, performs a bitwise AND between the
6169 read result and the value specified by AndData, and writes the result to the
6170 64-bit MSR specified by Index. The value written to the MSR is returned.
6171 Extra left bits in AndData are stripped. The caller must either guarantee
6172 that Index and the data written is valid, or the caller must set up exception
6173 handlers to catch the exceptions. This function is only available on IA-32
6176 If StartBit is greater than 63, then ASSERT().
6177 If EndBit is greater than 63, then ASSERT().
6178 If EndBit is less than StartBit, then ASSERT().
6179 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
6181 @param Index The 32-bit MSR index to write.
6182 @param StartBit The ordinal of the least significant bit in the bit field.
6184 @param EndBit The ordinal of the most significant bit in the bit field.
6186 @param AndData The value to AND with the read value from the bit field.
6188 @return The value written back to the MSR.
6193 AsmMsrBitFieldAnd64 (
6202 Reads a bit field in a 64-bit MSR, performs a bitwise AND followed by a
6203 bitwise OR, and writes the result back to the bit field in the
6206 Reads the 64-bit MSR specified by Index, performs a bitwise AND followed by
6207 a bitwise OR between the read result and the value specified by
6208 AndData, and writes the result to the 64-bit MSR specified by Index. The
6209 value written to the MSR is returned. Extra left bits in both AndData and
6210 OrData are stripped. The caller must either guarantee that Index and the data
6211 written is valid, or the caller must set up exception handlers to catch the
6212 exceptions. This function is only available on IA-32 and x64.
6214 If StartBit is greater than 63, then ASSERT().
6215 If EndBit is greater than 63, then ASSERT().
6216 If EndBit is less than StartBit, then ASSERT().
6217 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
6218 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
6220 @param Index The 32-bit MSR index to write.
6221 @param StartBit The ordinal of the least significant bit in the bit field.
6223 @param EndBit The ordinal of the most significant bit in the bit field.
6225 @param AndData The value to AND with the read value from the bit field.
6226 @param OrData The value to OR with the result of the AND operation.
6228 @return The value written back to the MSR.
6233 AsmMsrBitFieldAndThenOr64 (
6243 Reads the current value of the EFLAGS register.
6245 Reads and returns the current value of the EFLAGS register. This function is
6246 only available on IA-32 and x64. This returns a 32-bit value on IA-32 and a
6247 64-bit value on x64.
6249 @return EFLAGS on IA-32 or RFLAGS on x64.
6260 Reads the current value of the Control Register 0 (CR0).
6262 Reads and returns the current value of CR0. This function is only available
6263 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
6266 @return The value of the Control Register 0 (CR0).
6277 Reads the current value of the Control Register 2 (CR2).
6279 Reads and returns the current value of CR2. This function is only available
6280 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
6283 @return The value of the Control Register 2 (CR2).
6294 Reads the current value of the Control Register 3 (CR3).
6296 Reads and returns the current value of CR3. This function is only available
6297 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
6300 @return The value of the Control Register 3 (CR3).
6311 Reads the current value of the Control Register 4 (CR4).
6313 Reads and returns the current value of CR4. This function is only available
6314 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
6317 @return The value of the Control Register 4 (CR4).
6328 Writes a value to Control Register 0 (CR0).
6330 Writes and returns a new value to CR0. This function is only available on
6331 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
6333 @param Cr0 The value to write to CR0.
6335 @return The value written to CR0.
6346 Writes a value to Control Register 2 (CR2).
6348 Writes and returns a new value to CR2. This function is only available on
6349 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
6351 @param Cr2 The value to write to CR2.
6353 @return The value written to CR2.
6364 Writes a value to Control Register 3 (CR3).
6366 Writes and returns a new value to CR3. This function is only available on
6367 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
6369 @param Cr3 The value to write to CR3.
6371 @return The value written to CR3.
6382 Writes a value to Control Register 4 (CR4).
6384 Writes and returns a new value to CR4. This function is only available on
6385 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
6387 @param Cr4 The value to write to CR4.
6389 @return The value written to CR4.
6400 Reads the current value of Debug Register 0 (DR0).
6402 Reads and returns the current value of DR0. This function is only available
6403 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
6406 @return The value of Debug Register 0 (DR0).
6417 Reads the current value of Debug Register 1 (DR1).
6419 Reads and returns the current value of DR1. This function is only available
6420 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
6423 @return The value of Debug Register 1 (DR1).
6434 Reads the current value of Debug Register 2 (DR2).
6436 Reads and returns the current value of DR2. This function is only available
6437 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
6440 @return The value of Debug Register 2 (DR2).
6451 Reads the current value of Debug Register 3 (DR3).
6453 Reads and returns the current value of DR3. This function is only available
6454 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
6457 @return The value of Debug Register 3 (DR3).
6468 Reads the current value of Debug Register 4 (DR4).
6470 Reads and returns the current value of DR4. This function is only available
6471 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
6474 @return The value of Debug Register 4 (DR4).
6485 Reads the current value of Debug Register 5 (DR5).
6487 Reads and returns the current value of DR5. This function is only available
6488 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
6491 @return The value of Debug Register 5 (DR5).
6502 Reads the current value of Debug Register 6 (DR6).
6504 Reads and returns the current value of DR6. This function is only available
6505 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
6508 @return The value of Debug Register 6 (DR6).
6519 Reads the current value of Debug Register 7 (DR7).
6521 Reads and returns the current value of DR7. This function is only available
6522 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
6525 @return The value of Debug Register 7 (DR7).
6536 Writes a value to Debug Register 0 (DR0).
6538 Writes and returns a new value to DR0. This function is only available on
6539 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
6541 @param Dr0 The value to write to Dr0.
6543 @return The value written to Debug Register 0 (DR0).
6554 Writes a value to Debug Register 1 (DR1).
6556 Writes and returns a new value to DR1. This function is only available on
6557 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
6559 @param Dr1 The value to write to Dr1.
6561 @return The value written to Debug Register 1 (DR1).
6572 Writes a value to Debug Register 2 (DR2).
6574 Writes and returns a new value to DR2. This function is only available on
6575 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
6577 @param Dr2 The value to write to Dr2.
6579 @return The value written to Debug Register 2 (DR2).
6590 Writes a value to Debug Register 3 (DR3).
6592 Writes and returns a new value to DR3. This function is only available on
6593 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
6595 @param Dr3 The value to write to Dr3.
6597 @return The value written to Debug Register 3 (DR3).
6608 Writes a value to Debug Register 4 (DR4).
6610 Writes and returns a new value to DR4. This function is only available on
6611 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
6613 @param Dr4 The value to write to Dr4.
6615 @return The value written to Debug Register 4 (DR4).
6626 Writes a value to Debug Register 5 (DR5).
6628 Writes and returns a new value to DR5. This function is only available on
6629 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
6631 @param Dr5 The value to write to Dr5.
6633 @return The value written to Debug Register 5 (DR5).
6644 Writes a value to Debug Register 6 (DR6).
6646 Writes and returns a new value to DR6. This function is only available on
6647 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
6649 @param Dr6 The value to write to Dr6.
6651 @return The value written to Debug Register 6 (DR6).
6662 Writes a value to Debug Register 7 (DR7).
6664 Writes and returns a new value to DR7. This function is only available on
6665 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
6667 @param Dr7 The value to write to Dr7.
6669 @return The value written to Debug Register 7 (DR7).
6680 Reads the current value of Code Segment Register (CS).
6682 Reads and returns the current value of CS. This function is only available on
6685 @return The current value of CS.
6696 Reads the current value of Data Segment Register (DS).
6698 Reads and returns the current value of DS. This function is only available on
6701 @return The current value of DS.
6712 Reads the current value of Extra Segment Register (ES).
6714 Reads and returns the current value of ES. This function is only available on
6717 @return The current value of ES.
6728 Reads the current value of FS Data Segment Register (FS).
6730 Reads and returns the current value of FS. This function is only available on
6733 @return The current value of FS.
6744 Reads the current value of GS Data Segment Register (GS).
6746 Reads and returns the current value of GS. This function is only available on
6749 @return The current value of GS.
6760 Reads the current value of Stack Segment Register (SS).
6762 Reads and returns the current value of SS. This function is only available on
6765 @return The current value of SS.
6776 Reads the current value of Task Register (TR).
6778 Reads and returns the current value of TR. This function is only available on
6781 @return The current value of TR.
6792 Reads the current Global Descriptor Table Register(GDTR) descriptor.
6794 Reads and returns the current GDTR descriptor and returns it in Gdtr. This
6795 function is only available on IA-32 and x64.
6797 If Gdtr is NULL, then ASSERT().
6799 @param Gdtr The pointer to a GDTR descriptor.
6805 OUT IA32_DESCRIPTOR
*Gdtr
6810 Writes the current Global Descriptor Table Register (GDTR) descriptor.
6812 Writes and the current GDTR descriptor specified by Gdtr. This function is
6813 only available on IA-32 and x64.
6815 If Gdtr is NULL, then ASSERT().
6817 @param Gdtr The pointer to a GDTR descriptor.
6823 IN CONST IA32_DESCRIPTOR
*Gdtr
6828 Reads the current Interrupt Descriptor Table Register(IDTR) descriptor.
6830 Reads and returns the current IDTR descriptor and returns it in Idtr. This
6831 function is only available on IA-32 and x64.
6833 If Idtr is NULL, then ASSERT().
6835 @param Idtr The pointer to a IDTR descriptor.
6841 OUT IA32_DESCRIPTOR
*Idtr
6846 Writes the current Interrupt Descriptor Table Register(IDTR) descriptor.
6848 Writes the current IDTR descriptor and returns it in Idtr. This function is
6849 only available on IA-32 and x64.
6851 If Idtr is NULL, then ASSERT().
6853 @param Idtr The pointer to a IDTR descriptor.
6859 IN CONST IA32_DESCRIPTOR
*Idtr
6864 Reads the current Local Descriptor Table Register(LDTR) selector.
6866 Reads and returns the current 16-bit LDTR descriptor value. This function is
6867 only available on IA-32 and x64.
6869 @return The current selector of LDT.
6880 Writes the current Local Descriptor Table Register (LDTR) selector.
6882 Writes and the current LDTR descriptor specified by Ldtr. This function is
6883 only available on IA-32 and x64.
6885 @param Ldtr 16-bit LDTR selector value.
6896 Save the current floating point/SSE/SSE2 context to a buffer.
6898 Saves the current floating point/SSE/SSE2 state to the buffer specified by
6899 Buffer. Buffer must be aligned on a 16-byte boundary. This function is only
6900 available on IA-32 and x64.
6902 If Buffer is NULL, then ASSERT().
6903 If Buffer is not aligned on a 16-byte boundary, then ASSERT().
6905 @param Buffer The pointer to a buffer to save the floating point/SSE/SSE2 context.
6911 OUT IA32_FX_BUFFER
*Buffer
6916 Restores the current floating point/SSE/SSE2 context from a buffer.
6918 Restores the current floating point/SSE/SSE2 state from the buffer specified
6919 by Buffer. Buffer must be aligned on a 16-byte boundary. This function is
6920 only available on IA-32 and x64.
6922 If Buffer is NULL, then ASSERT().
6923 If Buffer is not aligned on a 16-byte boundary, then ASSERT().
6924 If Buffer was not saved with AsmFxSave(), then ASSERT().
6926 @param Buffer The pointer to a buffer to save the floating point/SSE/SSE2 context.
6932 IN CONST IA32_FX_BUFFER
*Buffer
6937 Reads the current value of 64-bit MMX Register #0 (MM0).
6939 Reads and returns the current value of MM0. This function is only available
6942 @return The current value of MM0.
6953 Reads the current value of 64-bit MMX Register #1 (MM1).
6955 Reads and returns the current value of MM1. This function is only available
6958 @return The current value of MM1.
6969 Reads the current value of 64-bit MMX Register #2 (MM2).
6971 Reads and returns the current value of MM2. This function is only available
6974 @return The current value of MM2.
6985 Reads the current value of 64-bit MMX Register #3 (MM3).
6987 Reads and returns the current value of MM3. This function is only available
6990 @return The current value of MM3.
7001 Reads the current value of 64-bit MMX Register #4 (MM4).
7003 Reads and returns the current value of MM4. This function is only available
7006 @return The current value of MM4.
7017 Reads the current value of 64-bit MMX Register #5 (MM5).
7019 Reads and returns the current value of MM5. This function is only available
7022 @return The current value of MM5.
7033 Reads the current value of 64-bit MMX Register #6 (MM6).
7035 Reads and returns the current value of MM6. This function is only available
7038 @return The current value of MM6.
7049 Reads the current value of 64-bit MMX Register #7 (MM7).
7051 Reads and returns the current value of MM7. This function is only available
7054 @return The current value of MM7.
7065 Writes the current value of 64-bit MMX Register #0 (MM0).
7067 Writes the current value of MM0. This function is only available on IA32 and
7070 @param Value The 64-bit value to write to MM0.
7081 Writes the current value of 64-bit MMX Register #1 (MM1).
7083 Writes the current value of MM1. This function is only available on IA32 and
7086 @param Value The 64-bit value to write to MM1.
7097 Writes the current value of 64-bit MMX Register #2 (MM2).
7099 Writes the current value of MM2. This function is only available on IA32 and
7102 @param Value The 64-bit value to write to MM2.
7113 Writes the current value of 64-bit MMX Register #3 (MM3).
7115 Writes the current value of MM3. This function is only available on IA32 and
7118 @param Value The 64-bit value to write to MM3.
7129 Writes the current value of 64-bit MMX Register #4 (MM4).
7131 Writes the current value of MM4. This function is only available on IA32 and
7134 @param Value The 64-bit value to write to MM4.
7145 Writes the current value of 64-bit MMX Register #5 (MM5).
7147 Writes the current value of MM5. This function is only available on IA32 and
7150 @param Value The 64-bit value to write to MM5.
7161 Writes the current value of 64-bit MMX Register #6 (MM6).
7163 Writes the current value of MM6. This function is only available on IA32 and
7166 @param Value The 64-bit value to write to MM6.
7177 Writes the current value of 64-bit MMX Register #7 (MM7).
7179 Writes the current value of MM7. This function is only available on IA32 and
7182 @param Value The 64-bit value to write to MM7.
7193 Reads the current value of Time Stamp Counter (TSC).
7195 Reads and returns the current value of TSC. This function is only available
7198 @return The current value of TSC
7209 Reads the current value of a Performance Counter (PMC).
7211 Reads and returns the current value of performance counter specified by
7212 Index. This function is only available on IA-32 and x64.
7214 @param Index The 32-bit Performance Counter index to read.
7216 @return The value of the PMC specified by Index.
7227 Sets up a monitor buffer that is used by AsmMwait().
7229 Executes a MONITOR instruction with the register state specified by Eax, Ecx
7230 and Edx. Returns Eax. This function is only available on IA-32 and x64.
7232 @param Eax The value to load into EAX or RAX before executing the MONITOR
7234 @param Ecx The value to load into ECX or RCX before executing the MONITOR
7236 @param Edx The value to load into EDX or RDX before executing the MONITOR
7252 Executes an MWAIT instruction.
7254 Executes an MWAIT instruction with the register state specified by Eax and
7255 Ecx. Returns Eax. This function is only available on IA-32 and x64.
7257 @param Eax The value to load into EAX or RAX before executing the MONITOR
7259 @param Ecx The value to load into ECX or RCX before executing the MONITOR
7274 Executes a WBINVD instruction.
7276 Executes a WBINVD instruction. This function is only available on IA-32 and
7288 Executes a INVD instruction.
7290 Executes a INVD instruction. This function is only available on IA-32 and
7302 Flushes a cache line from all the instruction and data caches within the
7303 coherency domain of the CPU.
7305 Flushed the cache line specified by LinearAddress, and returns LinearAddress.
7306 This function is only available on IA-32 and x64.
7308 @param LinearAddress The address of the cache line to flush. If the CPU is
7309 in a physical addressing mode, then LinearAddress is a
7310 physical address. If the CPU is in a virtual
7311 addressing mode, then LinearAddress is a virtual
7314 @return LinearAddress.
7319 IN VOID
*LinearAddress
7324 Enables the 32-bit paging mode on the CPU.
7326 Enables the 32-bit paging mode on the CPU. CR0, CR3, CR4, and the page tables
7327 must be properly initialized prior to calling this service. This function
7328 assumes the current execution mode is 32-bit protected mode. This function is
7329 only available on IA-32. After the 32-bit paging mode is enabled, control is
7330 transferred to the function specified by EntryPoint using the new stack
7331 specified by NewStack and passing in the parameters specified by Context1 and
7332 Context2. Context1 and Context2 are optional and may be NULL. The function
7333 EntryPoint must never return.
7335 If the current execution mode is not 32-bit protected mode, then ASSERT().
7336 If EntryPoint is NULL, then ASSERT().
7337 If NewStack is NULL, then ASSERT().
7339 There are a number of constraints that must be followed before calling this
7341 1) Interrupts must be disabled.
7342 2) The caller must be in 32-bit protected mode with flat descriptors. This
7343 means all descriptors must have a base of 0 and a limit of 4GB.
7344 3) CR0 and CR4 must be compatible with 32-bit protected mode with flat
7346 4) CR3 must point to valid page tables that will be used once the transition
7347 is complete, and those page tables must guarantee that the pages for this
7348 function and the stack are identity mapped.
7350 @param EntryPoint A pointer to function to call with the new stack after
7352 @param Context1 A pointer to the context to pass into the EntryPoint
7353 function as the first parameter after paging is enabled.
7354 @param Context2 A pointer to the context to pass into the EntryPoint
7355 function as the second parameter after paging is enabled.
7356 @param NewStack A pointer to the new stack to use for the EntryPoint
7357 function after paging is enabled.
7363 IN SWITCH_STACK_ENTRY_POINT EntryPoint
,
7364 IN VOID
*Context1
, OPTIONAL
7365 IN VOID
*Context2
, OPTIONAL
7371 Disables the 32-bit paging mode on the CPU.
7373 Disables the 32-bit paging mode on the CPU and returns to 32-bit protected
7374 mode. This function assumes the current execution mode is 32-paged protected
7375 mode. This function is only available on IA-32. After the 32-bit paging mode
7376 is disabled, control is transferred to the function specified by EntryPoint
7377 using the new stack specified by NewStack and passing in the parameters
7378 specified by Context1 and Context2. Context1 and Context2 are optional and
7379 may be NULL. The function EntryPoint must never return.
7381 If the current execution mode is not 32-bit paged mode, then ASSERT().
7382 If EntryPoint is NULL, then ASSERT().
7383 If NewStack is NULL, then ASSERT().
7385 There are a number of constraints that must be followed before calling this
7387 1) Interrupts must be disabled.
7388 2) The caller must be in 32-bit paged mode.
7389 3) CR0, CR3, and CR4 must be compatible with 32-bit paged mode.
7390 4) CR3 must point to valid page tables that guarantee that the pages for
7391 this function and the stack are identity mapped.
7393 @param EntryPoint A pointer to function to call with the new stack after
7395 @param Context1 A pointer to the context to pass into the EntryPoint
7396 function as the first parameter after paging is disabled.
7397 @param Context2 A pointer to the context to pass into the EntryPoint
7398 function as the second parameter after paging is
7400 @param NewStack A pointer to the new stack to use for the EntryPoint
7401 function after paging is disabled.
7406 AsmDisablePaging32 (
7407 IN SWITCH_STACK_ENTRY_POINT EntryPoint
,
7408 IN VOID
*Context1
, OPTIONAL
7409 IN VOID
*Context2
, OPTIONAL
7415 Enables the 64-bit paging mode on the CPU.
7417 Enables the 64-bit paging mode on the CPU. CR0, CR3, CR4, and the page tables
7418 must be properly initialized prior to calling this service. This function
7419 assumes the current execution mode is 32-bit protected mode with flat
7420 descriptors. This function is only available on IA-32. After the 64-bit
7421 paging mode is enabled, control is transferred to the function specified by
7422 EntryPoint using the new stack specified by NewStack and passing in the
7423 parameters specified by Context1 and Context2. Context1 and Context2 are
7424 optional and may be 0. The function EntryPoint must never return.
7426 If the current execution mode is not 32-bit protected mode with flat
7427 descriptors, then ASSERT().
7428 If EntryPoint is 0, then ASSERT().
7429 If NewStack is 0, then ASSERT().
7431 @param Cs The 16-bit selector to load in the CS before EntryPoint
7432 is called. The descriptor in the GDT that this selector
7433 references must be setup for long mode.
7434 @param EntryPoint The 64-bit virtual address of the function to call with
7435 the new stack after paging is enabled.
7436 @param Context1 The 64-bit virtual address of the context to pass into
7437 the EntryPoint function as the first parameter after
7439 @param Context2 The 64-bit virtual address of the context to pass into
7440 the EntryPoint function as the second parameter after
7442 @param NewStack The 64-bit virtual address of the new stack to use for
7443 the EntryPoint function after paging is enabled.
7450 IN UINT64 EntryPoint
,
7451 IN UINT64 Context1
, OPTIONAL
7452 IN UINT64 Context2
, OPTIONAL
7458 Disables the 64-bit paging mode on the CPU.
7460 Disables the 64-bit paging mode on the CPU and returns to 32-bit protected
7461 mode. This function assumes the current execution mode is 64-paging mode.
7462 This function is only available on x64. After the 64-bit paging mode is
7463 disabled, control is transferred to the function specified by EntryPoint
7464 using the new stack specified by NewStack and passing in the parameters
7465 specified by Context1 and Context2. Context1 and Context2 are optional and
7466 may be 0. The function EntryPoint must never return.
7468 If the current execution mode is not 64-bit paged mode, then ASSERT().
7469 If EntryPoint is 0, then ASSERT().
7470 If NewStack is 0, then ASSERT().
7472 @param Cs The 16-bit selector to load in the CS before EntryPoint
7473 is called. The descriptor in the GDT that this selector
7474 references must be setup for 32-bit protected mode.
7475 @param EntryPoint The 64-bit virtual address of the function to call with
7476 the new stack after paging is disabled.
7477 @param Context1 The 64-bit virtual address of the context to pass into
7478 the EntryPoint function as the first parameter after
7480 @param Context2 The 64-bit virtual address of the context to pass into
7481 the EntryPoint function as the second parameter after
7483 @param NewStack The 64-bit virtual address of the new stack to use for
7484 the EntryPoint function after paging is disabled.
7489 AsmDisablePaging64 (
7491 IN UINT32 EntryPoint
,
7492 IN UINT32 Context1
, OPTIONAL
7493 IN UINT32 Context2
, OPTIONAL
7499 // 16-bit thunking services
7503 Retrieves the properties for 16-bit thunk functions.
7505 Computes the size of the buffer and stack below 1MB required to use the
7506 AsmPrepareThunk16(), AsmThunk16() and AsmPrepareAndThunk16() functions. This
7507 buffer size is returned in RealModeBufferSize, and the stack size is returned
7508 in ExtraStackSize. If parameters are passed to the 16-bit real mode code,
7509 then the actual minimum stack size is ExtraStackSize plus the maximum number
7510 of bytes that need to be passed to the 16-bit real mode code.
7512 If RealModeBufferSize is NULL, then ASSERT().
7513 If ExtraStackSize is NULL, then ASSERT().
7515 @param RealModeBufferSize A pointer to the size of the buffer below 1MB
7516 required to use the 16-bit thunk functions.
7517 @param ExtraStackSize A pointer to the extra size of stack below 1MB
7518 that the 16-bit thunk functions require for
7519 temporary storage in the transition to and from
7525 AsmGetThunk16Properties (
7526 OUT UINT32
*RealModeBufferSize
,
7527 OUT UINT32
*ExtraStackSize
7532 Prepares all structures a code required to use AsmThunk16().
7534 Prepares all structures and code required to use AsmThunk16().
7536 This interface is limited to be used in either physical mode or virtual modes with paging enabled where the
7537 virtual to physical mappings for ThunkContext.RealModeBuffer is mapped 1:1.
7539 If ThunkContext is NULL, then ASSERT().
7541 @param ThunkContext A pointer to the context structure that describes the
7542 16-bit real mode code to call.
7548 IN OUT THUNK_CONTEXT
*ThunkContext
7553 Transfers control to a 16-bit real mode entry point and returns the results.
7555 Transfers control to a 16-bit real mode entry point and returns the results.
7556 AsmPrepareThunk16() must be called with ThunkContext before this function is used.
7557 This function must be called with interrupts disabled.
7559 The register state from the RealModeState field of ThunkContext is restored just prior
7560 to calling the 16-bit real mode entry point. This includes the EFLAGS field of RealModeState,
7561 which is used to set the interrupt state when a 16-bit real mode entry point is called.
7562 Control is transferred to the 16-bit real mode entry point specified by the CS and Eip fields of RealModeState.
7563 The stack is initialized to the SS and ESP fields of RealModeState. Any parameters passed to
7564 the 16-bit real mode code must be populated by the caller at SS:ESP prior to calling this function.
7565 The 16-bit real mode entry point is invoked with a 16-bit CALL FAR instruction,
7566 so when accessing stack contents, the 16-bit real mode code must account for the 16-bit segment
7567 and 16-bit offset of the return address that were pushed onto the stack. The 16-bit real mode entry
7568 point must exit with a RETF instruction. The register state is captured into RealModeState immediately
7569 after the RETF instruction is executed.
7571 If EFLAGS specifies interrupts enabled, or any of the 16-bit real mode code enables interrupts,
7572 or any of the 16-bit real mode code makes a SW interrupt, then the caller is responsible for making sure
7573 the IDT at address 0 is initialized to handle any HW or SW interrupts that may occur while in 16-bit real mode.
7575 If EFLAGS specifies interrupts enabled, or any of the 16-bit real mode code enables interrupts,
7576 then the caller is responsible for making sure the 8259 PIC is in a state compatible with 16-bit real mode.
7577 This includes the base vectors, the interrupt masks, and the edge/level trigger mode.
7579 If THUNK_ATTRIBUTE_BIG_REAL_MODE is set in the ThunkAttributes field of ThunkContext, then the user code
7580 is invoked in big real mode. Otherwise, the user code is invoked in 16-bit real mode with 64KB segment limits.
7582 If neither THUNK_ATTRIBUTE_DISABLE_A20_MASK_INT_15 nor THUNK_ATTRIBUTE_DISABLE_A20_MASK_KBD_CTRL are set in
7583 ThunkAttributes, then it is assumed that the user code did not enable the A20 mask, and no attempt is made to
7584 disable the A20 mask.
7586 If THUNK_ATTRIBUTE_DISABLE_A20_MASK_INT_15 is set and THUNK_ATTRIBUTE_DISABLE_A20_MASK_KBD_CTRL is clear in
7587 ThunkAttributes, then attempt to use the INT 15 service to disable the A20 mask. If this INT 15 call fails,
7588 then attempt to disable the A20 mask by directly accessing the 8042 keyboard controller I/O ports.
7590 If THUNK_ATTRIBUTE_DISABLE_A20_MASK_INT_15 is clear and THUNK_ATTRIBUTE_DISABLE_A20_MASK_KBD_CTRL is set in
7591 ThunkAttributes, then attempt to disable the A20 mask by directly accessing the 8042 keyboard controller I/O ports.
7593 If ThunkContext is NULL, then ASSERT().
7594 If AsmPrepareThunk16() was not previously called with ThunkContext, then ASSERT().
7595 If both THUNK_ATTRIBUTE_DISABLE_A20_MASK_INT_15 and THUNK_ATTRIBUTE_DISABLE_A20_MASK_KBD_CTRL are set in
7596 ThunkAttributes, then ASSERT().
7598 This interface is limited to be used in either physical mode or virtual modes with paging enabled where the
7599 virtual to physical mappings for ThunkContext.RealModeBuffer are mapped 1:1.
7601 @param ThunkContext A pointer to the context structure that describes the
7602 16-bit real mode code to call.
7608 IN OUT THUNK_CONTEXT
*ThunkContext
7613 Prepares all structures and code for a 16-bit real mode thunk, transfers
7614 control to a 16-bit real mode entry point, and returns the results.
7616 Prepares all structures and code for a 16-bit real mode thunk, transfers
7617 control to a 16-bit real mode entry point, and returns the results. If the
7618 caller only need to perform a single 16-bit real mode thunk, then this
7619 service should be used. If the caller intends to make more than one 16-bit
7620 real mode thunk, then it is more efficient if AsmPrepareThunk16() is called
7621 once and AsmThunk16() can be called for each 16-bit real mode thunk.
7623 This interface is limited to be used in either physical mode or virtual modes with paging enabled where the
7624 virtual to physical mappings for ThunkContext.RealModeBuffer is mapped 1:1.
7626 See AsmPrepareThunk16() and AsmThunk16() for the detailed description and ASSERT() conditions.
7628 @param ThunkContext A pointer to the context structure that describes the
7629 16-bit real mode code to call.
7634 AsmPrepareAndThunk16 (
7635 IN OUT THUNK_CONTEXT
*ThunkContext