2 Provides string functions, linked list functions, math functions, synchronization
3 functions, and CPU architecture-specific functions.
5 Copyright (c) 2006 - 2013, 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)
187 Copies one Null-terminated Unicode string to another Null-terminated Unicode
188 string and returns the new Unicode string.
190 This function copies the contents of the Unicode string Source to the Unicode
191 string Destination, and returns Destination. If Source and Destination
192 overlap, then the results are undefined.
194 If Destination is NULL, then ASSERT().
195 If Destination is not aligned on a 16-bit boundary, then ASSERT().
196 If Source is NULL, then ASSERT().
197 If Source is not aligned on a 16-bit boundary, then ASSERT().
198 If Source and Destination overlap, then ASSERT().
199 If PcdMaximumUnicodeStringLength is not zero, and Source contains more than
200 PcdMaximumUnicodeStringLength Unicode characters not including the
201 Null-terminator, then ASSERT().
203 @param Destination The pointer to a Null-terminated Unicode string.
204 @param Source The pointer to a Null-terminated Unicode string.
212 OUT CHAR16
*Destination
,
213 IN CONST CHAR16
*Source
218 Copies up to a specified length from one Null-terminated Unicode string to
219 another Null-terminated Unicode string and returns the new Unicode string.
221 This function copies the contents of the Unicode string Source to the Unicode
222 string Destination, and returns Destination. At most, Length Unicode
223 characters are copied from Source to Destination. If Length is 0, then
224 Destination is returned unmodified. If Length is greater that the number of
225 Unicode characters in Source, then Destination is padded with Null Unicode
226 characters. If Source and Destination overlap, then the results are
229 If Length > 0 and Destination is NULL, then ASSERT().
230 If Length > 0 and Destination is not aligned on a 16-bit boundary, then ASSERT().
231 If Length > 0 and Source is NULL, then ASSERT().
232 If Length > 0 and Source is not aligned on a 16-bit boundary, then ASSERT().
233 If Source and Destination overlap, then ASSERT().
234 If PcdMaximumUnicodeStringLength is not zero, and Length is greater than
235 PcdMaximumUnicodeStringLength, then ASSERT().
236 If PcdMaximumUnicodeStringLength is not zero, and Source contains more than
237 PcdMaximumUnicodeStringLength Unicode characters, not including the Null-terminator,
240 @param Destination The pointer to a Null-terminated Unicode string.
241 @param Source The pointer to a Null-terminated Unicode string.
242 @param Length The maximum number of Unicode characters to copy.
250 OUT CHAR16
*Destination
,
251 IN CONST CHAR16
*Source
,
257 Returns the length of a Null-terminated Unicode string.
259 This function returns the number of Unicode characters in the Null-terminated
260 Unicode string specified by String.
262 If String is NULL, then ASSERT().
263 If String is not aligned on a 16-bit boundary, then ASSERT().
264 If PcdMaximumUnicodeStringLength is not zero, and String contains more than
265 PcdMaximumUnicodeStringLength Unicode characters not including the
266 Null-terminator, then ASSERT().
268 @param String Pointer to a Null-terminated Unicode string.
270 @return The length of String.
276 IN CONST CHAR16
*String
281 Returns the size of a Null-terminated Unicode string in bytes, including the
284 This function returns the size, in bytes, of the Null-terminated Unicode string
287 If String is NULL, then ASSERT().
288 If String is not aligned on a 16-bit boundary, then ASSERT().
289 If PcdMaximumUnicodeStringLength is not zero, and String contains more than
290 PcdMaximumUnicodeStringLength Unicode characters not including the
291 Null-terminator, then ASSERT().
293 @param String The pointer to a Null-terminated Unicode string.
295 @return The size of String.
301 IN CONST CHAR16
*String
306 Compares two Null-terminated Unicode strings, and returns the difference
307 between the first mismatched Unicode characters.
309 This function compares the Null-terminated Unicode string FirstString to the
310 Null-terminated Unicode string SecondString. If FirstString is identical to
311 SecondString, then 0 is returned. Otherwise, the value returned is the first
312 mismatched Unicode character in SecondString subtracted from the first
313 mismatched Unicode character in FirstString.
315 If FirstString is NULL, then ASSERT().
316 If FirstString is not aligned on a 16-bit boundary, then ASSERT().
317 If SecondString is NULL, then ASSERT().
318 If SecondString is not aligned on a 16-bit boundary, then ASSERT().
319 If PcdMaximumUnicodeStringLength is not zero, and FirstString contains more
320 than PcdMaximumUnicodeStringLength Unicode characters not including the
321 Null-terminator, then ASSERT().
322 If PcdMaximumUnicodeStringLength is not zero, and SecondString contains more
323 than PcdMaximumUnicodeStringLength Unicode characters, not including the
324 Null-terminator, then ASSERT().
326 @param FirstString The pointer to a Null-terminated Unicode string.
327 @param SecondString The pointer to a Null-terminated Unicode string.
329 @retval 0 FirstString is identical to SecondString.
330 @return others FirstString is not identical to SecondString.
336 IN CONST CHAR16
*FirstString
,
337 IN CONST CHAR16
*SecondString
342 Compares up to a specified length the contents of two Null-terminated Unicode strings,
343 and returns the difference between the first mismatched Unicode characters.
345 This function compares the Null-terminated Unicode string FirstString to the
346 Null-terminated Unicode string SecondString. At most, Length Unicode
347 characters will be compared. If Length is 0, then 0 is returned. If
348 FirstString is identical to SecondString, then 0 is returned. Otherwise, the
349 value returned is the first mismatched Unicode character in SecondString
350 subtracted from the first mismatched Unicode character in FirstString.
352 If Length > 0 and FirstString is NULL, then ASSERT().
353 If Length > 0 and FirstString is not aligned on a 16-bit boundary, then ASSERT().
354 If Length > 0 and SecondString is NULL, then ASSERT().
355 If Length > 0 and SecondString is not aligned on a 16-bit boundary, then ASSERT().
356 If PcdMaximumUnicodeStringLength is not zero, and Length is greater than
357 PcdMaximumUnicodeStringLength, then ASSERT().
358 If PcdMaximumUnicodeStringLength is not zero, and FirstString contains more than
359 PcdMaximumUnicodeStringLength Unicode characters, not including the Null-terminator,
361 If PcdMaximumUnicodeStringLength is not zero, and SecondString contains more than
362 PcdMaximumUnicodeStringLength Unicode characters, not including the Null-terminator,
365 @param FirstString The pointer to a Null-terminated Unicode string.
366 @param SecondString The pointer to a Null-terminated Unicode string.
367 @param Length The maximum number of Unicode characters to compare.
369 @retval 0 FirstString is identical to SecondString.
370 @return others FirstString is not identical to SecondString.
376 IN CONST CHAR16
*FirstString
,
377 IN CONST CHAR16
*SecondString
,
383 Concatenates one Null-terminated Unicode string to another Null-terminated
384 Unicode string, and returns the concatenated Unicode string.
386 This function concatenates two Null-terminated Unicode strings. The contents
387 of Null-terminated Unicode string Source are concatenated to the end of
388 Null-terminated Unicode string Destination. The Null-terminated concatenated
389 Unicode String is returned. If Source and Destination overlap, then the
390 results are undefined.
392 If Destination is NULL, then ASSERT().
393 If Destination is not aligned on a 16-bit boundary, then ASSERT().
394 If Source is NULL, then ASSERT().
395 If Source is not aligned on a 16-bit boundary, then ASSERT().
396 If Source and Destination overlap, then ASSERT().
397 If PcdMaximumUnicodeStringLength is not zero, and Destination contains more
398 than PcdMaximumUnicodeStringLength Unicode characters, not including the
399 Null-terminator, then ASSERT().
400 If PcdMaximumUnicodeStringLength is not zero, and Source contains more than
401 PcdMaximumUnicodeStringLength Unicode characters, not including the
402 Null-terminator, then ASSERT().
403 If PcdMaximumUnicodeStringLength is not zero, and concatenating Destination
404 and Source results in a Unicode string with more than
405 PcdMaximumUnicodeStringLength Unicode characters, not including the
406 Null-terminator, then ASSERT().
408 @param Destination The pointer to a Null-terminated Unicode string.
409 @param Source The pointer to a Null-terminated Unicode string.
417 IN OUT CHAR16
*Destination
,
418 IN CONST CHAR16
*Source
423 Concatenates up to a specified length one Null-terminated Unicode to the end
424 of another Null-terminated Unicode string, and returns the concatenated
427 This function concatenates two Null-terminated Unicode strings. The contents
428 of Null-terminated Unicode string Source are concatenated to the end of
429 Null-terminated Unicode string Destination, and Destination is returned. At
430 most, Length Unicode characters are concatenated from Source to the end of
431 Destination, and Destination is always Null-terminated. If Length is 0, then
432 Destination is returned unmodified. If Source and Destination overlap, then
433 the results are undefined.
435 If Destination is NULL, then ASSERT().
436 If Length > 0 and Destination is not aligned on a 16-bit boundary, then ASSERT().
437 If Length > 0 and Source is NULL, then ASSERT().
438 If Length > 0 and Source is not aligned on a 16-bit boundary, then ASSERT().
439 If Source and Destination overlap, then ASSERT().
440 If PcdMaximumUnicodeStringLength is not zero, and Length is greater than
441 PcdMaximumUnicodeStringLength, then ASSERT().
442 If PcdMaximumUnicodeStringLength is not zero, and Destination contains more
443 than PcdMaximumUnicodeStringLength Unicode characters, not including the
444 Null-terminator, then ASSERT().
445 If PcdMaximumUnicodeStringLength is not zero, and Source contains more than
446 PcdMaximumUnicodeStringLength Unicode characters, not including the
447 Null-terminator, then ASSERT().
448 If PcdMaximumUnicodeStringLength is not zero, and concatenating Destination
449 and Source results in a Unicode string with more than PcdMaximumUnicodeStringLength
450 Unicode characters, not including the Null-terminator, then ASSERT().
452 @param Destination The pointer to a Null-terminated Unicode string.
453 @param Source The pointer to a Null-terminated Unicode string.
454 @param Length The maximum number of Unicode characters to concatenate from
463 IN OUT CHAR16
*Destination
,
464 IN CONST CHAR16
*Source
,
469 Returns the first occurrence of a Null-terminated Unicode sub-string
470 in a Null-terminated Unicode string.
472 This function scans the contents of the Null-terminated Unicode string
473 specified by String and returns the first occurrence of SearchString.
474 If SearchString is not found in String, then NULL is returned. If
475 the length of SearchString is zero, then String is returned.
477 If String is NULL, then ASSERT().
478 If String is not aligned on a 16-bit boundary, then ASSERT().
479 If SearchString is NULL, then ASSERT().
480 If SearchString is not aligned on a 16-bit boundary, then ASSERT().
482 If PcdMaximumUnicodeStringLength is not zero, and SearchString
483 or String contains more than PcdMaximumUnicodeStringLength Unicode
484 characters, not including the Null-terminator, then ASSERT().
486 @param String The pointer to a Null-terminated Unicode string.
487 @param SearchString The pointer to a Null-terminated Unicode string to search for.
489 @retval NULL If the SearchString does not appear in String.
490 @return others If there is a match.
496 IN CONST CHAR16
*String
,
497 IN CONST CHAR16
*SearchString
501 Convert a Null-terminated Unicode decimal string to a value of
504 This function returns a value of type UINTN by interpreting the contents
505 of the Unicode string specified by String as a decimal number. The format
506 of the input Unicode string String is:
508 [spaces] [decimal digits].
510 The valid decimal digit character is in the range [0-9]. The
511 function will ignore the pad space, which includes spaces or
512 tab characters, before [decimal digits]. The running zero in the
513 beginning of [decimal digits] will be ignored. Then, the function
514 stops at the first character that is a not a valid decimal character
515 or a Null-terminator, whichever one comes first.
517 If String is NULL, then ASSERT().
518 If String is not aligned in a 16-bit boundary, then ASSERT().
519 If String has only pad spaces, then 0 is returned.
520 If String has no pad spaces or valid decimal digits,
522 If the number represented by String overflows according
523 to the range defined by UINTN, then ASSERT().
525 If PcdMaximumUnicodeStringLength is not zero, and String contains
526 more than PcdMaximumUnicodeStringLength Unicode characters not including
527 the Null-terminator, then ASSERT().
529 @param String The pointer to a Null-terminated Unicode string.
531 @retval Value translated from String.
537 IN CONST CHAR16
*String
541 Convert a Null-terminated Unicode decimal string to a value of
544 This function returns a value of type UINT64 by interpreting the contents
545 of the Unicode string specified by String as a decimal number. The format
546 of the input Unicode string String is:
548 [spaces] [decimal digits].
550 The valid decimal digit character is in the range [0-9]. The
551 function will ignore the pad space, which includes spaces or
552 tab characters, before [decimal digits]. The running zero in the
553 beginning of [decimal digits] will be ignored. Then, the function
554 stops at the first character that is a not a valid decimal character
555 or a Null-terminator, whichever one comes first.
557 If String is NULL, then ASSERT().
558 If String is not aligned in a 16-bit boundary, then ASSERT().
559 If String has only pad spaces, then 0 is returned.
560 If String has no pad spaces or valid decimal digits,
562 If the number represented by String overflows according
563 to the range defined by UINT64, then ASSERT().
565 If PcdMaximumUnicodeStringLength is not zero, and String contains
566 more than PcdMaximumUnicodeStringLength Unicode characters not including
567 the Null-terminator, then ASSERT().
569 @param String The pointer to a Null-terminated Unicode string.
571 @retval Value translated from String.
577 IN CONST CHAR16
*String
582 Convert a Null-terminated Unicode hexadecimal string to a value of type UINTN.
584 This function returns a value of type UINTN by interpreting the contents
585 of the Unicode string specified by String as a hexadecimal number.
586 The format of the input Unicode string String is:
588 [spaces][zeros][x][hexadecimal digits].
590 The valid hexadecimal digit character is in the range [0-9], [a-f] and [A-F].
591 The prefix "0x" is optional. Both "x" and "X" is allowed in "0x" prefix.
592 If "x" appears in the input string, it must be prefixed with at least one 0.
593 The function will ignore the pad space, which includes spaces or tab characters,
594 before [zeros], [x] or [hexadecimal digit]. The running zero before [x] or
595 [hexadecimal digit] will be ignored. Then, the decoding starts after [x] or the
596 first valid hexadecimal digit. Then, the function stops at the first character
597 that is a not a valid hexadecimal character or NULL, whichever one comes first.
599 If String is NULL, then ASSERT().
600 If String is not aligned in a 16-bit boundary, then ASSERT().
601 If String has only pad spaces, then zero is returned.
602 If String has no leading pad spaces, leading zeros or valid hexadecimal digits,
603 then zero is returned.
604 If the number represented by String overflows according to the range defined by
605 UINTN, then ASSERT().
607 If PcdMaximumUnicodeStringLength is not zero, and String contains more than
608 PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator,
611 @param String The pointer to a Null-terminated Unicode string.
613 @retval Value translated from String.
619 IN CONST CHAR16
*String
624 Convert a Null-terminated Unicode hexadecimal string to a value of type UINT64.
626 This function returns a value of type UINT64 by interpreting the contents
627 of the Unicode string specified by String as a hexadecimal number.
628 The format of the input Unicode string String is
630 [spaces][zeros][x][hexadecimal digits].
632 The valid hexadecimal digit character is in the range [0-9], [a-f] and [A-F].
633 The prefix "0x" is optional. Both "x" and "X" is allowed in "0x" prefix.
634 If "x" appears in the input string, it must be prefixed with at least one 0.
635 The function will ignore the pad space, which includes spaces or tab characters,
636 before [zeros], [x] or [hexadecimal digit]. The running zero before [x] or
637 [hexadecimal digit] will be ignored. Then, the decoding starts after [x] or the
638 first valid hexadecimal digit. Then, the function stops at the first character that is
639 a not a valid hexadecimal character or NULL, whichever one comes first.
641 If String is NULL, then ASSERT().
642 If String is not aligned in a 16-bit boundary, then ASSERT().
643 If String has only pad spaces, then zero is returned.
644 If String has no leading pad spaces, leading zeros or valid hexadecimal digits,
645 then zero is returned.
646 If the number represented by String overflows according to the range defined by
647 UINT64, then ASSERT().
649 If PcdMaximumUnicodeStringLength is not zero, and String contains more than
650 PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator,
653 @param String The pointer to a Null-terminated Unicode string.
655 @retval Value translated from String.
661 IN CONST CHAR16
*String
665 Convert a Null-terminated Unicode string to a Null-terminated
666 ASCII string and returns the ASCII string.
668 This function converts the content of the Unicode string Source
669 to the ASCII string Destination by copying the lower 8 bits of
670 each Unicode character. It returns Destination.
672 The caller is responsible to make sure Destination points to a buffer with size
673 equal or greater than ((StrLen (Source) + 1) * sizeof (CHAR8)) in bytes.
675 If any Unicode characters in Source contain non-zero value in
676 the upper 8 bits, then ASSERT().
678 If Destination is NULL, then ASSERT().
679 If Source is NULL, then ASSERT().
680 If Source is not aligned on a 16-bit boundary, then ASSERT().
681 If Source and Destination overlap, then ASSERT().
683 If PcdMaximumUnicodeStringLength is not zero, and Source contains
684 more than PcdMaximumUnicodeStringLength Unicode characters not including
685 the Null-terminator, then ASSERT().
687 If PcdMaximumAsciiStringLength is not zero, and Source contains more
688 than PcdMaximumAsciiStringLength Unicode characters not including the
689 Null-terminator, then ASSERT().
691 @param Source The pointer to a Null-terminated Unicode string.
692 @param Destination The pointer to a Null-terminated ASCII string.
699 UnicodeStrToAsciiStr (
700 IN CONST CHAR16
*Source
,
701 OUT CHAR8
*Destination
706 Copies one Null-terminated ASCII string to another Null-terminated ASCII
707 string and returns the new ASCII string.
709 This function copies the contents of the ASCII string Source to the ASCII
710 string Destination, and returns Destination. If Source and Destination
711 overlap, then the results are undefined.
713 If Destination is NULL, then ASSERT().
714 If Source is NULL, then ASSERT().
715 If Source and Destination overlap, then ASSERT().
716 If PcdMaximumAsciiStringLength is not zero and Source contains more than
717 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
720 @param Destination The pointer to a Null-terminated ASCII string.
721 @param Source The pointer to a Null-terminated ASCII string.
729 OUT CHAR8
*Destination
,
730 IN CONST CHAR8
*Source
735 Copies up to a specified length one Null-terminated ASCII string to another
736 Null-terminated ASCII string and returns the new ASCII string.
738 This function copies the contents of the ASCII string Source to the ASCII
739 string Destination, and returns Destination. At most, Length ASCII characters
740 are copied from Source to Destination. If Length is 0, then Destination is
741 returned unmodified. If Length is greater that the number of ASCII characters
742 in Source, then Destination is padded with Null ASCII characters. If Source
743 and Destination overlap, then the results are undefined.
745 If Destination is NULL, then ASSERT().
746 If Source is NULL, then ASSERT().
747 If Source and Destination overlap, then ASSERT().
748 If PcdMaximumAsciiStringLength is not zero, and Length is greater than
749 PcdMaximumAsciiStringLength, then ASSERT().
750 If PcdMaximumAsciiStringLength is not zero, and Source contains more than
751 PcdMaximumAsciiStringLength ASCII characters, not including the Null-terminator,
754 @param Destination The pointer to a Null-terminated ASCII string.
755 @param Source The pointer to a Null-terminated ASCII string.
756 @param Length The maximum number of ASCII characters to copy.
764 OUT CHAR8
*Destination
,
765 IN CONST CHAR8
*Source
,
771 Returns the length of a Null-terminated ASCII string.
773 This function returns the number of ASCII characters in the Null-terminated
774 ASCII string specified by String.
776 If Length > 0 and Destination is NULL, then ASSERT().
777 If Length > 0 and Source is NULL, then ASSERT().
778 If PcdMaximumAsciiStringLength is not zero and String contains more than
779 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
782 @param String The pointer to a Null-terminated ASCII string.
784 @return The length of String.
790 IN CONST CHAR8
*String
795 Returns the size of a Null-terminated ASCII string in bytes, including the
798 This function returns the size, in bytes, of the Null-terminated ASCII string
801 If String is NULL, then ASSERT().
802 If PcdMaximumAsciiStringLength is not zero and String contains more than
803 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
806 @param String The pointer to a Null-terminated ASCII string.
808 @return The size of String.
814 IN CONST CHAR8
*String
819 Compares two Null-terminated ASCII strings, and returns the difference
820 between the first mismatched ASCII characters.
822 This function compares the Null-terminated ASCII string FirstString to the
823 Null-terminated ASCII string SecondString. If FirstString is identical to
824 SecondString, then 0 is returned. Otherwise, the value returned is the first
825 mismatched ASCII character in SecondString subtracted from the first
826 mismatched ASCII character in FirstString.
828 If FirstString is NULL, then ASSERT().
829 If SecondString is NULL, then ASSERT().
830 If PcdMaximumAsciiStringLength is not zero and FirstString contains more than
831 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
833 If PcdMaximumAsciiStringLength is not zero and SecondString contains more
834 than PcdMaximumAsciiStringLength ASCII characters not including the
835 Null-terminator, then ASSERT().
837 @param FirstString The pointer to a Null-terminated ASCII string.
838 @param SecondString The pointer to a Null-terminated ASCII string.
840 @retval ==0 FirstString is identical to SecondString.
841 @retval !=0 FirstString is not identical to SecondString.
847 IN CONST CHAR8
*FirstString
,
848 IN CONST CHAR8
*SecondString
853 Performs a case insensitive comparison of two Null-terminated ASCII strings,
854 and returns the difference between the first mismatched ASCII characters.
856 This function performs a case insensitive comparison of the Null-terminated
857 ASCII string FirstString to the Null-terminated ASCII string SecondString. If
858 FirstString is identical to SecondString, then 0 is returned. Otherwise, the
859 value returned is the first mismatched lower case ASCII character in
860 SecondString subtracted from the first mismatched lower case ASCII character
863 If FirstString is NULL, then ASSERT().
864 If SecondString is NULL, then ASSERT().
865 If PcdMaximumAsciiStringLength is not zero and FirstString contains more than
866 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
868 If PcdMaximumAsciiStringLength is not zero and SecondString contains more
869 than PcdMaximumAsciiStringLength ASCII characters not including the
870 Null-terminator, then ASSERT().
872 @param FirstString The pointer to a Null-terminated ASCII string.
873 @param SecondString The pointer to a Null-terminated ASCII string.
875 @retval ==0 FirstString is identical to SecondString using case insensitive
877 @retval !=0 FirstString is not identical to SecondString using case
878 insensitive comparisons.
884 IN CONST CHAR8
*FirstString
,
885 IN CONST CHAR8
*SecondString
890 Compares two Null-terminated ASCII strings with maximum lengths, and returns
891 the difference between the first mismatched ASCII characters.
893 This function compares the Null-terminated ASCII string FirstString to the
894 Null-terminated ASCII string SecondString. At most, Length ASCII characters
895 will be compared. If Length is 0, then 0 is returned. If FirstString is
896 identical to SecondString, then 0 is returned. Otherwise, the value returned
897 is the first mismatched ASCII character in SecondString subtracted from the
898 first mismatched ASCII character in FirstString.
900 If Length > 0 and FirstString is NULL, then ASSERT().
901 If Length > 0 and SecondString is NULL, then ASSERT().
902 If PcdMaximumAsciiStringLength is not zero, and Length is greater than
903 PcdMaximumAsciiStringLength, then ASSERT().
904 If PcdMaximumAsciiStringLength is not zero, and FirstString contains more than
905 PcdMaximumAsciiStringLength ASCII characters, not including the Null-terminator,
907 If PcdMaximumAsciiStringLength is not zero, and SecondString contains more than
908 PcdMaximumAsciiStringLength ASCII characters, not including the Null-terminator,
911 @param FirstString The pointer to a Null-terminated ASCII string.
912 @param SecondString The pointer to a Null-terminated ASCII string.
913 @param Length The maximum number of ASCII characters for compare.
915 @retval ==0 FirstString is identical to SecondString.
916 @retval !=0 FirstString is not identical to SecondString.
922 IN CONST CHAR8
*FirstString
,
923 IN CONST CHAR8
*SecondString
,
929 Concatenates one Null-terminated ASCII string to another Null-terminated
930 ASCII string, and returns the concatenated ASCII string.
932 This function concatenates two Null-terminated ASCII strings. The contents of
933 Null-terminated ASCII string Source are concatenated to the end of Null-
934 terminated ASCII string Destination. The Null-terminated concatenated ASCII
937 If Destination is NULL, then ASSERT().
938 If Source is NULL, then ASSERT().
939 If PcdMaximumAsciiStringLength is not zero and Destination contains more than
940 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
942 If PcdMaximumAsciiStringLength is not zero and Source contains more than
943 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
945 If PcdMaximumAsciiStringLength is not zero and concatenating Destination and
946 Source results in a ASCII string with more than PcdMaximumAsciiStringLength
947 ASCII characters, then ASSERT().
949 @param Destination The pointer to a Null-terminated ASCII string.
950 @param Source The pointer to a Null-terminated ASCII string.
958 IN OUT CHAR8
*Destination
,
959 IN CONST CHAR8
*Source
964 Concatenates up to a specified length one Null-terminated ASCII string to
965 the end of another Null-terminated ASCII string, and returns the
966 concatenated ASCII string.
968 This function concatenates two Null-terminated ASCII strings. The contents
969 of Null-terminated ASCII string Source are concatenated to the end of Null-
970 terminated ASCII string Destination, and Destination is returned. At most,
971 Length ASCII characters are concatenated from Source to the end of
972 Destination, and Destination is always Null-terminated. If Length is 0, then
973 Destination is returned unmodified. If Source and Destination overlap, then
974 the results are undefined.
976 If Length > 0 and Destination is NULL, then ASSERT().
977 If Length > 0 and Source is NULL, then ASSERT().
978 If Source and Destination overlap, then ASSERT().
979 If PcdMaximumAsciiStringLength is not zero, and Length is greater than
980 PcdMaximumAsciiStringLength, then ASSERT().
981 If PcdMaximumAsciiStringLength is not zero, and Destination contains more than
982 PcdMaximumAsciiStringLength ASCII characters, not including the Null-terminator,
984 If PcdMaximumAsciiStringLength is not zero, and Source contains more than
985 PcdMaximumAsciiStringLength ASCII characters, not including the Null-terminator,
987 If PcdMaximumAsciiStringLength is not zero, and concatenating Destination and
988 Source results in a ASCII string with more than PcdMaximumAsciiStringLength
989 ASCII characters, not including the Null-terminator, then ASSERT().
991 @param Destination The pointer to a Null-terminated ASCII string.
992 @param Source The pointer to a Null-terminated ASCII string.
993 @param Length The maximum number of ASCII characters to concatenate from
1002 IN OUT CHAR8
*Destination
,
1003 IN CONST CHAR8
*Source
,
1009 Returns the first occurrence of a Null-terminated ASCII sub-string
1010 in a Null-terminated ASCII string.
1012 This function scans the contents of the ASCII string specified by String
1013 and returns the first occurrence of SearchString. If SearchString is not
1014 found in String, then NULL is returned. If the length of SearchString is zero,
1015 then String is returned.
1017 If String is NULL, then ASSERT().
1018 If SearchString is NULL, then ASSERT().
1020 If PcdMaximumAsciiStringLength is not zero, and SearchString or
1021 String contains more than PcdMaximumAsciiStringLength Unicode characters
1022 not including the Null-terminator, then ASSERT().
1024 @param String The pointer to a Null-terminated ASCII string.
1025 @param SearchString The pointer to a Null-terminated ASCII string to search for.
1027 @retval NULL If the SearchString does not appear in String.
1028 @retval others If there is a match return the first occurrence of SearchingString.
1029 If the length of SearchString is zero,return String.
1035 IN CONST CHAR8
*String
,
1036 IN CONST CHAR8
*SearchString
1041 Convert a Null-terminated ASCII decimal string to a value of type
1044 This function returns a value of type UINTN by interpreting the contents
1045 of the ASCII string String as a decimal number. The format of the input
1046 ASCII string String is:
1048 [spaces] [decimal digits].
1050 The valid decimal digit character is in the range [0-9]. The function will
1051 ignore the pad space, which includes spaces or tab characters, before the digits.
1052 The running zero in the beginning of [decimal digits] will be ignored. Then, the
1053 function stops at the first character that is a not a valid decimal character or
1054 Null-terminator, whichever on comes first.
1056 If String has only pad spaces, then 0 is returned.
1057 If String has no pad spaces or valid decimal digits, then 0 is returned.
1058 If the number represented by String overflows according to the range defined by
1059 UINTN, then ASSERT().
1060 If String is NULL, then ASSERT().
1061 If PcdMaximumAsciiStringLength is not zero, and String contains more than
1062 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
1065 @param String The pointer to a Null-terminated ASCII string.
1067 @retval The value translated from String.
1072 AsciiStrDecimalToUintn (
1073 IN CONST CHAR8
*String
1078 Convert a Null-terminated ASCII decimal string to a value of type
1081 This function returns a value of type UINT64 by interpreting the contents
1082 of the ASCII string String as a decimal number. The format of the input
1083 ASCII string String is:
1085 [spaces] [decimal digits].
1087 The valid decimal digit character is in the range [0-9]. The function will
1088 ignore the pad space, which includes spaces or tab characters, before the digits.
1089 The running zero in the beginning of [decimal digits] will be ignored. Then, the
1090 function stops at the first character that is a not a valid decimal character or
1091 Null-terminator, whichever on comes first.
1093 If String has only pad spaces, then 0 is returned.
1094 If String has no pad spaces or valid decimal digits, then 0 is returned.
1095 If the number represented by String overflows according to the range defined by
1096 UINT64, then ASSERT().
1097 If String is NULL, then ASSERT().
1098 If PcdMaximumAsciiStringLength is not zero, and String contains more than
1099 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
1102 @param String The pointer to a Null-terminated ASCII string.
1104 @retval Value translated from String.
1109 AsciiStrDecimalToUint64 (
1110 IN CONST CHAR8
*String
1115 Convert a Null-terminated ASCII hexadecimal string to a value of type UINTN.
1117 This function returns a value of type UINTN by interpreting the contents of
1118 the ASCII string String as a hexadecimal number. The format of the input ASCII
1121 [spaces][zeros][x][hexadecimal digits].
1123 The valid hexadecimal digit character is in the range [0-9], [a-f] and [A-F].
1124 The prefix "0x" is optional. Both "x" and "X" is allowed in "0x" prefix. If "x"
1125 appears in the input string, it must be prefixed with at least one 0. The function
1126 will ignore the pad space, which includes spaces or tab characters, before [zeros],
1127 [x] or [hexadecimal digits]. The running zero before [x] or [hexadecimal digits]
1128 will be ignored. Then, the decoding starts after [x] or the first valid hexadecimal
1129 digit. Then, the function stops at the first character that is a not a valid
1130 hexadecimal character or Null-terminator, whichever on comes first.
1132 If String has only pad spaces, then 0 is returned.
1133 If String has no leading pad spaces, leading zeros or valid hexadecimal digits, then
1136 If the number represented by String overflows according to the range defined by UINTN,
1138 If String is NULL, then ASSERT().
1139 If PcdMaximumAsciiStringLength is not zero,
1140 and String contains more than PcdMaximumAsciiStringLength ASCII characters not including
1141 the Null-terminator, then ASSERT().
1143 @param String The pointer to a Null-terminated ASCII string.
1145 @retval Value translated from String.
1150 AsciiStrHexToUintn (
1151 IN CONST CHAR8
*String
1156 Convert a Null-terminated ASCII hexadecimal string to a value of type UINT64.
1158 This function returns a value of type UINT64 by interpreting the contents of
1159 the ASCII string String as a hexadecimal number. The format of the input ASCII
1162 [spaces][zeros][x][hexadecimal digits].
1164 The valid hexadecimal digit character is in the range [0-9], [a-f] and [A-F].
1165 The prefix "0x" is optional. Both "x" and "X" is allowed in "0x" prefix. If "x"
1166 appears in the input string, it must be prefixed with at least one 0. The function
1167 will ignore the pad space, which includes spaces or tab characters, before [zeros],
1168 [x] or [hexadecimal digits]. The running zero before [x] or [hexadecimal digits]
1169 will be ignored. Then, the decoding starts after [x] or the first valid hexadecimal
1170 digit. Then, the function stops at the first character that is a not a valid
1171 hexadecimal character or Null-terminator, whichever on comes first.
1173 If String has only pad spaces, then 0 is returned.
1174 If String has no leading pad spaces, leading zeros or valid hexadecimal digits, then
1177 If the number represented by String overflows according to the range defined by UINT64,
1179 If String is NULL, then ASSERT().
1180 If PcdMaximumAsciiStringLength is not zero,
1181 and String contains more than PcdMaximumAsciiStringLength ASCII characters not including
1182 the Null-terminator, then ASSERT().
1184 @param String The pointer to a Null-terminated ASCII string.
1186 @retval Value translated from String.
1191 AsciiStrHexToUint64 (
1192 IN CONST CHAR8
*String
1197 Convert one Null-terminated ASCII string to a Null-terminated
1198 Unicode string and returns the Unicode string.
1200 This function converts the contents of the ASCII string Source to the Unicode
1201 string Destination, and returns Destination. The function terminates the
1202 Unicode string Destination by appending a Null-terminator character at the end.
1203 The caller is responsible to make sure Destination points to a buffer with size
1204 equal or greater than ((AsciiStrLen (Source) + 1) * sizeof (CHAR16)) in bytes.
1206 If Destination is NULL, then ASSERT().
1207 If Destination is not aligned on a 16-bit boundary, then ASSERT().
1208 If Source is NULL, then ASSERT().
1209 If Source and Destination overlap, then ASSERT().
1210 If PcdMaximumAsciiStringLength is not zero, and Source contains more than
1211 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
1213 If PcdMaximumUnicodeStringLength is not zero, and Source contains more than
1214 PcdMaximumUnicodeStringLength ASCII characters not including the
1215 Null-terminator, then ASSERT().
1217 @param Source The pointer to a Null-terminated ASCII string.
1218 @param Destination The pointer to a Null-terminated Unicode string.
1220 @return Destination.
1225 AsciiStrToUnicodeStr (
1226 IN CONST CHAR8
*Source
,
1227 OUT CHAR16
*Destination
1232 Converts an 8-bit value to an 8-bit BCD value.
1234 Converts the 8-bit value specified by Value to BCD. The BCD value is
1237 If Value >= 100, then ASSERT().
1239 @param Value The 8-bit value to convert to BCD. Range 0..99.
1241 @return The BCD value.
1252 Converts an 8-bit BCD value to an 8-bit value.
1254 Converts the 8-bit BCD value specified by Value to an 8-bit value. The 8-bit
1257 If Value >= 0xA0, then ASSERT().
1258 If (Value & 0x0F) >= 0x0A, then ASSERT().
1260 @param Value The 8-bit BCD value to convert to an 8-bit value.
1262 @return The 8-bit value is returned.
1273 // Linked List Functions and Macros
1277 Initializes the head node of a doubly linked list that is declared as a
1278 global variable in a module.
1280 Initializes the forward and backward links of a new linked list. After
1281 initializing a linked list with this macro, the other linked list functions
1282 may be used to add and remove nodes from the linked list. This macro results
1283 in smaller executables by initializing the linked list in the data section,
1284 instead if calling the InitializeListHead() function to perform the
1285 equivalent operation.
1287 @param ListHead The head note of a list to initialize.
1290 #define INITIALIZE_LIST_HEAD_VARIABLE(ListHead) {&(ListHead), &(ListHead)}
1294 Initializes the head node of a doubly linked list, and returns the pointer to
1295 the head node of the doubly linked list.
1297 Initializes the forward and backward links of a new linked list. After
1298 initializing a linked list with this function, the other linked list
1299 functions may be used to add and remove nodes from the linked list. It is up
1300 to the caller of this function to allocate the memory for ListHead.
1302 If ListHead is NULL, then ASSERT().
1304 @param ListHead A pointer to the head node of a new doubly linked list.
1311 InitializeListHead (
1312 IN OUT LIST_ENTRY
*ListHead
1317 Adds a node to the beginning of a doubly linked list, and returns the pointer
1318 to the head node of the doubly linked list.
1320 Adds the node Entry at the beginning of the doubly linked list denoted by
1321 ListHead, and returns ListHead.
1323 If ListHead is NULL, then ASSERT().
1324 If Entry is NULL, then ASSERT().
1325 If ListHead was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or
1326 InitializeListHead(), then ASSERT().
1327 If PcdMaximumLinkedListLength is not zero, and prior to insertion the number
1328 of nodes in ListHead, including the ListHead node, is greater than or
1329 equal to PcdMaximumLinkedListLength, then ASSERT().
1331 @param ListHead A pointer to the head node of a doubly linked list.
1332 @param Entry A pointer to a node that is to be inserted at the beginning
1333 of a doubly linked list.
1341 IN OUT LIST_ENTRY
*ListHead
,
1342 IN OUT LIST_ENTRY
*Entry
1347 Adds a node to the end of a doubly linked list, and returns the pointer to
1348 the head node of the doubly linked list.
1350 Adds the node Entry to the end of the doubly linked list denoted by ListHead,
1351 and returns ListHead.
1353 If ListHead is NULL, then ASSERT().
1354 If Entry is NULL, then ASSERT().
1355 If ListHead was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or
1356 InitializeListHead(), then ASSERT().
1357 If PcdMaximumLinkedListLength is not zero, and prior to insertion the number
1358 of nodes in ListHead, including the ListHead node, is greater than or
1359 equal to PcdMaximumLinkedListLength, then ASSERT().
1361 @param ListHead A pointer to the head node of a doubly linked list.
1362 @param Entry A pointer to a node that is to be added at the end of the
1371 IN OUT LIST_ENTRY
*ListHead
,
1372 IN OUT LIST_ENTRY
*Entry
1377 Retrieves the first node of a doubly linked list.
1379 Returns the first node of a doubly linked list. List must have been
1380 initialized with INTIALIZE_LIST_HEAD_VARIABLE() or InitializeListHead().
1381 If List is empty, then List is returned.
1383 If List is NULL, then ASSERT().
1384 If List was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or
1385 InitializeListHead(), then ASSERT().
1386 If PcdMaximumLinkedListLength is not zero, and the number of nodes
1387 in List, including the List node, is greater than or equal to
1388 PcdMaximumLinkedListLength, then ASSERT().
1390 @param List A pointer to the head node of a doubly linked list.
1392 @return The first node of a doubly linked list.
1393 @retval List The list is empty.
1399 IN CONST LIST_ENTRY
*List
1404 Retrieves the next node of a doubly linked list.
1406 Returns the node of a doubly linked list that follows Node.
1407 List must have been initialized with INTIALIZE_LIST_HEAD_VARIABLE()
1408 or InitializeListHead(). If List is empty, then List is returned.
1410 If List is NULL, then ASSERT().
1411 If Node is NULL, then ASSERT().
1412 If List was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or
1413 InitializeListHead(), then ASSERT().
1414 If PcdMaximumLinkedListLength is not zero, and List contains more than
1415 PcdMaximumLinkedListLength nodes, then ASSERT().
1416 If PcdVerifyNodeInList is TRUE and Node is not a node in List, then ASSERT().
1418 @param List A pointer to the head node of a doubly linked list.
1419 @param Node A pointer to a node in the doubly linked list.
1421 @return The pointer to the next node if one exists. Otherwise List is returned.
1427 IN CONST LIST_ENTRY
*List
,
1428 IN CONST LIST_ENTRY
*Node
1433 Retrieves the previous node of a doubly linked list.
1435 Returns the node of a doubly linked list that precedes Node.
1436 List must have been initialized with INTIALIZE_LIST_HEAD_VARIABLE()
1437 or InitializeListHead(). If List is empty, then List is returned.
1439 If List is NULL, then ASSERT().
1440 If Node is NULL, then ASSERT().
1441 If List was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or
1442 InitializeListHead(), then ASSERT().
1443 If PcdMaximumLinkedListLength is not zero, and List contains more than
1444 PcdMaximumLinkedListLength nodes, then ASSERT().
1445 If PcdVerifyNodeInList is TRUE and Node is not a node in List, then ASSERT().
1447 @param List A pointer to the head node of a doubly linked list.
1448 @param Node A pointer to a node in the doubly linked list.
1450 @return The pointer to the previous node if one exists. Otherwise List is returned.
1456 IN CONST LIST_ENTRY
*List
,
1457 IN CONST LIST_ENTRY
*Node
1462 Checks to see if a doubly linked list is empty or not.
1464 Checks to see if the doubly linked list is empty. If the linked list contains
1465 zero nodes, this function returns TRUE. Otherwise, it returns FALSE.
1467 If ListHead is NULL, then ASSERT().
1468 If ListHead was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or
1469 InitializeListHead(), then ASSERT().
1470 If PcdMaximumLinkedListLength is not zero, and the number of nodes
1471 in List, including the List node, is greater than or equal to
1472 PcdMaximumLinkedListLength, then ASSERT().
1474 @param ListHead A pointer to the head node of a doubly linked list.
1476 @retval TRUE The linked list is empty.
1477 @retval FALSE The linked list is not empty.
1483 IN CONST LIST_ENTRY
*ListHead
1488 Determines if a node in a doubly linked list is the head node of a the same
1489 doubly linked list. This function is typically used to terminate a loop that
1490 traverses all the nodes in a doubly linked list starting with the head node.
1492 Returns TRUE if Node is equal to List. Returns FALSE if Node is one of the
1493 nodes in the doubly linked list specified by List. List must have been
1494 initialized with INTIALIZE_LIST_HEAD_VARIABLE() or InitializeListHead().
1496 If List is NULL, then ASSERT().
1497 If Node is NULL, then ASSERT().
1498 If List was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or InitializeListHead(),
1500 If PcdMaximumLinkedListLength is not zero, and the number of nodes
1501 in List, including the List node, is greater than or equal to
1502 PcdMaximumLinkedListLength, then ASSERT().
1503 If PcdVerifyNodeInList is TRUE and Node is not a node in List the and Node is not equal
1504 to List, then ASSERT().
1506 @param List A pointer to the head node of a doubly linked list.
1507 @param Node A pointer to a node in the doubly linked list.
1509 @retval TRUE Node is the head of the doubly-linked list pointed by List.
1510 @retval FALSE Node is not the head of the doubly-linked list pointed by List.
1516 IN CONST LIST_ENTRY
*List
,
1517 IN CONST LIST_ENTRY
*Node
1522 Determines if a node the last node in a doubly linked list.
1524 Returns TRUE if Node is the last node in the doubly linked list specified by
1525 List. Otherwise, FALSE is returned. List must have been initialized with
1526 INTIALIZE_LIST_HEAD_VARIABLE() or InitializeListHead().
1528 If List is NULL, then ASSERT().
1529 If Node is NULL, then ASSERT().
1530 If List was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or
1531 InitializeListHead(), then ASSERT().
1532 If PcdMaximumLinkedListLength is not zero, and the number of nodes
1533 in List, including the List node, is greater than or equal to
1534 PcdMaximumLinkedListLength, then ASSERT().
1535 If PcdVerifyNodeInList is TRUE and Node is not a node in List, then ASSERT().
1537 @param List A pointer to the head node of a doubly linked list.
1538 @param Node A pointer to a node in the doubly linked list.
1540 @retval TRUE Node is the last node in the linked list.
1541 @retval FALSE Node is not the last node in the linked list.
1547 IN CONST LIST_ENTRY
*List
,
1548 IN CONST LIST_ENTRY
*Node
1553 Swaps the location of two nodes in a doubly linked list, and returns the
1554 first node after the swap.
1556 If FirstEntry is identical to SecondEntry, then SecondEntry is returned.
1557 Otherwise, the location of the FirstEntry node is swapped with the location
1558 of the SecondEntry node in a doubly linked list. SecondEntry must be in the
1559 same double linked list as FirstEntry and that double linked list must have
1560 been initialized with INTIALIZE_LIST_HEAD_VARIABLE() or InitializeListHead().
1561 SecondEntry is returned after the nodes are swapped.
1563 If FirstEntry is NULL, then ASSERT().
1564 If SecondEntry is NULL, then ASSERT().
1565 If PcdVerifyNodeInList is TRUE and SecondEntry and FirstEntry are not in the
1566 same linked list, then ASSERT().
1567 If PcdMaximumLinkedListLength is not zero, and the number of nodes in the
1568 linked list containing the FirstEntry and SecondEntry nodes, including
1569 the FirstEntry and SecondEntry nodes, is greater than or equal to
1570 PcdMaximumLinkedListLength, then ASSERT().
1572 @param FirstEntry A pointer to a node in a linked list.
1573 @param SecondEntry A pointer to another node in the same linked list.
1575 @return SecondEntry.
1581 IN OUT LIST_ENTRY
*FirstEntry
,
1582 IN OUT LIST_ENTRY
*SecondEntry
1587 Removes a node from a doubly linked list, and returns the node that follows
1590 Removes the node Entry from a doubly linked list. It is up to the caller of
1591 this function to release the memory used by this node if that is required. On
1592 exit, the node following Entry in the doubly linked list is returned. If
1593 Entry is the only node in the linked list, then the head node of the linked
1596 If Entry is NULL, then ASSERT().
1597 If Entry is the head node of an empty list, then ASSERT().
1598 If PcdMaximumLinkedListLength is not zero, and the number of nodes in the
1599 linked list containing Entry, including the Entry node, is greater than
1600 or equal to PcdMaximumLinkedListLength, then ASSERT().
1602 @param Entry A pointer to a node in a linked list.
1610 IN CONST LIST_ENTRY
*Entry
1618 Shifts a 64-bit integer left between 0 and 63 bits. The low bits are filled
1619 with zeros. The shifted value is returned.
1621 This function shifts the 64-bit value Operand to the left by Count bits. The
1622 low Count bits are set to zero. The shifted value is returned.
1624 If Count is greater than 63, then ASSERT().
1626 @param Operand The 64-bit operand to shift left.
1627 @param Count The number of bits to shift left.
1629 @return Operand << Count.
1641 Shifts a 64-bit integer right between 0 and 63 bits. This high bits are
1642 filled with zeros. The shifted value is returned.
1644 This function shifts the 64-bit value Operand to the right by Count bits. The
1645 high Count bits are set to zero. The shifted value is returned.
1647 If Count is greater than 63, then ASSERT().
1649 @param Operand The 64-bit operand to shift right.
1650 @param Count The number of bits to shift right.
1652 @return Operand >> Count
1664 Shifts a 64-bit integer right between 0 and 63 bits. The high bits are filled
1665 with original integer's bit 63. The shifted value is returned.
1667 This function shifts the 64-bit value Operand to the right by Count bits. The
1668 high Count bits are set to bit 63 of Operand. The shifted value is returned.
1670 If Count is greater than 63, then ASSERT().
1672 @param Operand The 64-bit operand to shift right.
1673 @param Count The number of bits to shift right.
1675 @return Operand >> Count
1687 Rotates a 32-bit integer left between 0 and 31 bits, filling the low bits
1688 with the high bits that were rotated.
1690 This function rotates the 32-bit value Operand to the left by Count bits. The
1691 low Count bits are fill with the high Count bits of Operand. The rotated
1694 If Count is greater than 31, then ASSERT().
1696 @param Operand The 32-bit operand to rotate left.
1697 @param Count The number of bits to rotate left.
1699 @return Operand << Count
1711 Rotates a 32-bit integer right between 0 and 31 bits, filling the high bits
1712 with the low bits that were rotated.
1714 This function rotates the 32-bit value Operand to the right by Count bits.
1715 The high Count bits are fill with the low Count bits of Operand. The rotated
1718 If Count is greater than 31, then ASSERT().
1720 @param Operand The 32-bit operand to rotate right.
1721 @param Count The number of bits to rotate right.
1723 @return Operand >> Count
1735 Rotates a 64-bit integer left between 0 and 63 bits, filling the low bits
1736 with the high bits that were rotated.
1738 This function rotates the 64-bit value Operand to the left by Count bits. The
1739 low Count bits are fill with the high Count bits of Operand. The rotated
1742 If Count is greater than 63, then ASSERT().
1744 @param Operand The 64-bit operand to rotate left.
1745 @param Count The number of bits to rotate left.
1747 @return Operand << Count
1759 Rotates a 64-bit integer right between 0 and 63 bits, filling the high bits
1760 with the high low bits that were rotated.
1762 This function rotates the 64-bit value Operand to the right by Count bits.
1763 The high Count bits are fill with the low Count bits of Operand. The rotated
1766 If Count is greater than 63, then ASSERT().
1768 @param Operand The 64-bit operand to rotate right.
1769 @param Count The number of bits to rotate right.
1771 @return Operand >> Count
1783 Returns the bit position of the lowest bit set in a 32-bit value.
1785 This function computes the bit position of the lowest bit set in the 32-bit
1786 value specified by Operand. If Operand is zero, then -1 is returned.
1787 Otherwise, a value between 0 and 31 is returned.
1789 @param Operand The 32-bit operand to evaluate.
1791 @retval 0..31 The lowest bit set in Operand was found.
1792 @retval -1 Operand is zero.
1803 Returns the bit position of the lowest bit set in a 64-bit value.
1805 This function computes the bit position of the lowest bit set in the 64-bit
1806 value specified by Operand. If Operand is zero, then -1 is returned.
1807 Otherwise, a value between 0 and 63 is returned.
1809 @param Operand The 64-bit operand to evaluate.
1811 @retval 0..63 The lowest bit set in Operand was found.
1812 @retval -1 Operand is zero.
1824 Returns the bit position of the highest bit set in a 32-bit value. Equivalent
1827 This function computes the bit position of the highest bit set in the 32-bit
1828 value specified by Operand. If Operand is zero, then -1 is returned.
1829 Otherwise, a value between 0 and 31 is returned.
1831 @param Operand The 32-bit operand to evaluate.
1833 @retval 0..31 Position of the highest bit set in Operand if found.
1834 @retval -1 Operand is zero.
1845 Returns the bit position of the highest bit set in a 64-bit value. Equivalent
1848 This function computes the bit position of the highest bit set in the 64-bit
1849 value specified by Operand. If Operand is zero, then -1 is returned.
1850 Otherwise, a value between 0 and 63 is returned.
1852 @param Operand The 64-bit operand to evaluate.
1854 @retval 0..63 Position of the highest bit set in Operand if found.
1855 @retval -1 Operand is zero.
1866 Returns the value of the highest bit set in a 32-bit value. Equivalent to
1869 This function computes the value of the highest bit set in the 32-bit value
1870 specified by Operand. If Operand is zero, then zero is returned.
1872 @param Operand The 32-bit operand to evaluate.
1874 @return 1 << HighBitSet32(Operand)
1875 @retval 0 Operand is zero.
1886 Returns the value of the highest bit set in a 64-bit value. Equivalent to
1889 This function computes the value of the highest bit set in the 64-bit value
1890 specified by Operand. If Operand is zero, then zero is returned.
1892 @param Operand The 64-bit operand to evaluate.
1894 @return 1 << HighBitSet64(Operand)
1895 @retval 0 Operand is zero.
1906 Switches the endianness of a 16-bit integer.
1908 This function swaps the bytes in a 16-bit unsigned value to switch the value
1909 from little endian to big endian or vice versa. The byte swapped value is
1912 @param Value A 16-bit unsigned value.
1914 @return The byte swapped Value.
1925 Switches the endianness of a 32-bit integer.
1927 This function swaps the bytes in a 32-bit unsigned value to switch the value
1928 from little endian to big endian or vice versa. The byte swapped value is
1931 @param Value A 32-bit unsigned value.
1933 @return The byte swapped Value.
1944 Switches the endianness of a 64-bit integer.
1946 This function swaps the bytes in a 64-bit unsigned value to switch the value
1947 from little endian to big endian or vice versa. The byte swapped value is
1950 @param Value A 64-bit unsigned value.
1952 @return The byte swapped Value.
1963 Multiples a 64-bit unsigned integer by a 32-bit unsigned integer and
1964 generates a 64-bit unsigned result.
1966 This function multiples the 64-bit unsigned value Multiplicand by the 32-bit
1967 unsigned value Multiplier and generates a 64-bit unsigned result. This 64-
1968 bit unsigned result is returned.
1970 @param Multiplicand A 64-bit unsigned value.
1971 @param Multiplier A 32-bit unsigned value.
1973 @return Multiplicand * Multiplier
1979 IN UINT64 Multiplicand
,
1980 IN UINT32 Multiplier
1985 Multiples a 64-bit unsigned integer by a 64-bit unsigned integer and
1986 generates a 64-bit unsigned result.
1988 This function multiples the 64-bit unsigned value Multiplicand by the 64-bit
1989 unsigned value Multiplier and generates a 64-bit unsigned result. This 64-
1990 bit unsigned result is returned.
1992 @param Multiplicand A 64-bit unsigned value.
1993 @param Multiplier A 64-bit unsigned value.
1995 @return Multiplicand * Multiplier.
2001 IN UINT64 Multiplicand
,
2002 IN UINT64 Multiplier
2007 Multiples a 64-bit signed integer by a 64-bit signed integer and generates a
2008 64-bit signed result.
2010 This function multiples the 64-bit signed value Multiplicand by the 64-bit
2011 signed value Multiplier and generates a 64-bit signed result. This 64-bit
2012 signed result is returned.
2014 @param Multiplicand A 64-bit signed value.
2015 @param Multiplier A 64-bit signed value.
2017 @return Multiplicand * Multiplier
2023 IN INT64 Multiplicand
,
2029 Divides a 64-bit unsigned integer by a 32-bit unsigned integer and generates
2030 a 64-bit unsigned result.
2032 This function divides the 64-bit unsigned value Dividend by the 32-bit
2033 unsigned value Divisor and generates a 64-bit unsigned quotient. This
2034 function returns the 64-bit unsigned quotient.
2036 If Divisor is 0, then ASSERT().
2038 @param Dividend A 64-bit unsigned value.
2039 @param Divisor A 32-bit unsigned value.
2041 @return Dividend / Divisor.
2053 Divides a 64-bit unsigned integer by a 32-bit unsigned integer and generates
2054 a 32-bit unsigned remainder.
2056 This function divides the 64-bit unsigned value Dividend by the 32-bit
2057 unsigned value Divisor and generates a 32-bit remainder. This function
2058 returns the 32-bit unsigned remainder.
2060 If Divisor is 0, then ASSERT().
2062 @param Dividend A 64-bit unsigned value.
2063 @param Divisor A 32-bit unsigned value.
2065 @return Dividend % Divisor.
2077 Divides a 64-bit unsigned integer by a 32-bit unsigned integer and generates
2078 a 64-bit unsigned result and an optional 32-bit unsigned remainder.
2080 This function divides the 64-bit unsigned value Dividend by the 32-bit
2081 unsigned value Divisor and generates a 64-bit unsigned quotient. If Remainder
2082 is not NULL, then the 32-bit unsigned remainder is returned in Remainder.
2083 This function returns the 64-bit unsigned quotient.
2085 If Divisor is 0, then ASSERT().
2087 @param Dividend A 64-bit unsigned value.
2088 @param Divisor A 32-bit unsigned value.
2089 @param Remainder A pointer to a 32-bit unsigned value. This parameter is
2090 optional and may be NULL.
2092 @return Dividend / Divisor.
2097 DivU64x32Remainder (
2100 OUT UINT32
*Remainder OPTIONAL
2105 Divides a 64-bit unsigned integer by a 64-bit unsigned integer and generates
2106 a 64-bit unsigned result and an optional 64-bit unsigned remainder.
2108 This function divides the 64-bit unsigned value Dividend by the 64-bit
2109 unsigned value Divisor and generates a 64-bit unsigned quotient. If Remainder
2110 is not NULL, then the 64-bit unsigned remainder is returned in Remainder.
2111 This function returns the 64-bit unsigned quotient.
2113 If Divisor is 0, then ASSERT().
2115 @param Dividend A 64-bit unsigned value.
2116 @param Divisor A 64-bit unsigned value.
2117 @param Remainder A pointer to a 64-bit unsigned value. This parameter is
2118 optional and may be NULL.
2120 @return Dividend / Divisor.
2125 DivU64x64Remainder (
2128 OUT UINT64
*Remainder OPTIONAL
2133 Divides a 64-bit signed integer by a 64-bit signed integer and generates a
2134 64-bit signed result and a optional 64-bit signed remainder.
2136 This function divides the 64-bit signed value Dividend by the 64-bit signed
2137 value Divisor and generates a 64-bit signed quotient. If Remainder is not
2138 NULL, then the 64-bit signed remainder is returned in Remainder. This
2139 function returns the 64-bit signed quotient.
2141 It is the caller's responsibility to not call this function with a Divisor of 0.
2142 If Divisor is 0, then the quotient and remainder should be assumed to be
2143 the largest negative integer.
2145 If Divisor is 0, then ASSERT().
2147 @param Dividend A 64-bit signed value.
2148 @param Divisor A 64-bit signed value.
2149 @param Remainder A pointer to a 64-bit signed value. This parameter is
2150 optional and may be NULL.
2152 @return Dividend / Divisor.
2157 DivS64x64Remainder (
2160 OUT INT64
*Remainder OPTIONAL
2165 Reads a 16-bit value from memory that may be unaligned.
2167 This function returns the 16-bit value pointed to by Buffer. The function
2168 guarantees that the read operation does not produce an alignment fault.
2170 If the Buffer is NULL, then ASSERT().
2172 @param Buffer The pointer to a 16-bit value that may be unaligned.
2174 @return The 16-bit value read from Buffer.
2180 IN CONST UINT16
*Buffer
2185 Writes a 16-bit value to memory that may be unaligned.
2187 This function writes the 16-bit value specified by Value to Buffer. Value is
2188 returned. The function guarantees that the write operation does not produce
2191 If the Buffer is NULL, then ASSERT().
2193 @param Buffer The pointer to a 16-bit value that may be unaligned.
2194 @param Value 16-bit value to write to Buffer.
2196 @return The 16-bit value to write to Buffer.
2208 Reads a 24-bit value from memory that may be unaligned.
2210 This function returns the 24-bit value pointed to by Buffer. The function
2211 guarantees that the read operation does not produce an alignment fault.
2213 If the Buffer is NULL, then ASSERT().
2215 @param Buffer The pointer to a 24-bit value that may be unaligned.
2217 @return The 24-bit value read from Buffer.
2223 IN CONST UINT32
*Buffer
2228 Writes a 24-bit value to memory that may be unaligned.
2230 This function writes the 24-bit value specified by Value to Buffer. Value is
2231 returned. The function guarantees that the write operation does not produce
2234 If the Buffer is NULL, then ASSERT().
2236 @param Buffer The pointer to a 24-bit value that may be unaligned.
2237 @param Value 24-bit value to write to Buffer.
2239 @return The 24-bit value to write to Buffer.
2251 Reads a 32-bit value from memory that may be unaligned.
2253 This function returns the 32-bit value pointed to by Buffer. The function
2254 guarantees that the read operation does not produce an alignment fault.
2256 If the Buffer is NULL, then ASSERT().
2258 @param Buffer The pointer to a 32-bit value that may be unaligned.
2260 @return The 32-bit value read from Buffer.
2266 IN CONST UINT32
*Buffer
2271 Writes a 32-bit value to memory that may be unaligned.
2273 This function writes the 32-bit value specified by Value to Buffer. Value is
2274 returned. The function guarantees that the write operation does not produce
2277 If the Buffer is NULL, then ASSERT().
2279 @param Buffer The pointer to a 32-bit value that may be unaligned.
2280 @param Value 32-bit value to write to Buffer.
2282 @return The 32-bit value to write to Buffer.
2294 Reads a 64-bit value from memory that may be unaligned.
2296 This function returns the 64-bit value pointed to by Buffer. The function
2297 guarantees that the read operation does not produce an alignment fault.
2299 If the Buffer is NULL, then ASSERT().
2301 @param Buffer The pointer to a 64-bit value that may be unaligned.
2303 @return The 64-bit value read from Buffer.
2309 IN CONST UINT64
*Buffer
2314 Writes a 64-bit value to memory that may be unaligned.
2316 This function writes the 64-bit value specified by Value to Buffer. Value is
2317 returned. The function guarantees that the write operation does not produce
2320 If the Buffer is NULL, then ASSERT().
2322 @param Buffer The pointer to a 64-bit value that may be unaligned.
2323 @param Value 64-bit value to write to Buffer.
2325 @return The 64-bit value to write to Buffer.
2337 // Bit Field Functions
2341 Returns a bit field from an 8-bit value.
2343 Returns the bitfield specified by the StartBit and the EndBit from Operand.
2345 If 8-bit operations are not supported, then ASSERT().
2346 If StartBit is greater than 7, then ASSERT().
2347 If EndBit is greater than 7, then ASSERT().
2348 If EndBit is less than StartBit, then ASSERT().
2350 @param Operand Operand on which to perform the bitfield operation.
2351 @param StartBit The ordinal of the least significant bit in the bit field.
2353 @param EndBit The ordinal of the most significant bit in the bit field.
2356 @return The bit field read.
2369 Writes a bit field to an 8-bit value, and returns the result.
2371 Writes Value to the bit field specified by the StartBit and the EndBit in
2372 Operand. All other bits in Operand are preserved. The new 8-bit value is
2375 If 8-bit operations are not supported, then ASSERT().
2376 If StartBit is greater than 7, then ASSERT().
2377 If EndBit is greater than 7, then ASSERT().
2378 If EndBit is less than StartBit, then ASSERT().
2379 If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
2381 @param Operand Operand on which to perform the bitfield operation.
2382 @param StartBit The ordinal of the least significant bit in the bit field.
2384 @param EndBit The ordinal of the most significant bit in the bit field.
2386 @param Value New value of the bit field.
2388 @return The new 8-bit value.
2402 Reads a bit field from an 8-bit value, performs a bitwise OR, and returns the
2405 Performs a bitwise OR between the bit field specified by StartBit
2406 and EndBit in Operand and the value specified by OrData. All other bits in
2407 Operand are preserved. The new 8-bit value is returned.
2409 If 8-bit operations are not supported, then ASSERT().
2410 If StartBit is greater than 7, then ASSERT().
2411 If EndBit is greater than 7, then ASSERT().
2412 If EndBit is less than StartBit, then ASSERT().
2413 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
2415 @param Operand Operand on which to perform the bitfield operation.
2416 @param StartBit The ordinal of the least significant bit in the bit field.
2418 @param EndBit The ordinal of the most significant bit in the bit field.
2420 @param OrData The value to OR with the read value from the value
2422 @return The new 8-bit value.
2436 Reads a bit field from an 8-bit value, performs a bitwise AND, and returns
2439 Performs a bitwise AND between the bit field specified by StartBit and EndBit
2440 in Operand and the value specified by AndData. All other bits in Operand are
2441 preserved. The new 8-bit value is returned.
2443 If 8-bit operations are not supported, then ASSERT().
2444 If StartBit is greater than 7, then ASSERT().
2445 If EndBit is greater than 7, then ASSERT().
2446 If EndBit is less than StartBit, then ASSERT().
2447 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
2449 @param Operand Operand on which to perform the bitfield operation.
2450 @param StartBit The ordinal of the least significant bit in the bit field.
2452 @param EndBit The ordinal of the most significant bit in the bit field.
2454 @param AndData The value to AND with the read value from the value.
2456 @return The new 8-bit value.
2470 Reads a bit field from an 8-bit value, performs a bitwise AND followed by a
2471 bitwise OR, and returns the result.
2473 Performs a bitwise AND between the bit field specified by StartBit and EndBit
2474 in Operand and the value specified by AndData, followed by a bitwise
2475 OR with value specified by OrData. All other bits in Operand are
2476 preserved. The new 8-bit value is returned.
2478 If 8-bit operations are not supported, then ASSERT().
2479 If StartBit is greater than 7, then ASSERT().
2480 If EndBit is greater than 7, then ASSERT().
2481 If EndBit is less than StartBit, then ASSERT().
2482 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
2483 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
2485 @param Operand Operand on which to perform the bitfield operation.
2486 @param StartBit The ordinal of the least significant bit in the bit field.
2488 @param EndBit The ordinal of the most significant bit in the bit field.
2490 @param AndData The value to AND with the read value from the value.
2491 @param OrData The value to OR with the result of the AND operation.
2493 @return The new 8-bit value.
2498 BitFieldAndThenOr8 (
2508 Returns a bit field from a 16-bit value.
2510 Returns the bitfield specified by the StartBit and the EndBit from Operand.
2512 If 16-bit operations are not supported, then ASSERT().
2513 If StartBit is greater than 15, then ASSERT().
2514 If EndBit is greater than 15, then ASSERT().
2515 If EndBit is less than StartBit, then ASSERT().
2517 @param Operand Operand on which to perform the bitfield operation.
2518 @param StartBit The ordinal of the least significant bit in the bit field.
2520 @param EndBit The ordinal of the most significant bit in the bit field.
2523 @return The bit field read.
2536 Writes a bit field to a 16-bit value, and returns the result.
2538 Writes Value to the bit field specified by the StartBit and the EndBit in
2539 Operand. All other bits in Operand are preserved. The new 16-bit value is
2542 If 16-bit operations are not supported, then ASSERT().
2543 If StartBit is greater than 15, then ASSERT().
2544 If EndBit is greater than 15, then ASSERT().
2545 If EndBit is less than StartBit, then ASSERT().
2546 If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
2548 @param Operand Operand on which to perform the bitfield operation.
2549 @param StartBit The ordinal of the least significant bit in the bit field.
2551 @param EndBit The ordinal of the most significant bit in the bit field.
2553 @param Value New value of the bit field.
2555 @return The new 16-bit value.
2569 Reads a bit field from a 16-bit value, performs a bitwise OR, and returns the
2572 Performs a bitwise OR between the bit field specified by StartBit
2573 and EndBit in Operand and the value specified by OrData. All other bits in
2574 Operand are preserved. The new 16-bit value is returned.
2576 If 16-bit operations are not supported, then ASSERT().
2577 If StartBit is greater than 15, then ASSERT().
2578 If EndBit is greater than 15, then ASSERT().
2579 If EndBit is less than StartBit, then ASSERT().
2580 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
2582 @param Operand Operand on which to perform the bitfield operation.
2583 @param StartBit The ordinal of the least significant bit in the bit field.
2585 @param EndBit The ordinal of the most significant bit in the bit field.
2587 @param OrData The value to OR with the read value from the value
2589 @return The new 16-bit value.
2603 Reads a bit field from a 16-bit value, performs a bitwise AND, and returns
2606 Performs a bitwise AND between the bit field specified by StartBit and EndBit
2607 in Operand and the value specified by AndData. All other bits in Operand are
2608 preserved. The new 16-bit value is returned.
2610 If 16-bit operations are not supported, then ASSERT().
2611 If StartBit is greater than 15, then ASSERT().
2612 If EndBit is greater than 15, then ASSERT().
2613 If EndBit is less than StartBit, then ASSERT().
2614 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
2616 @param Operand Operand on which to perform the bitfield operation.
2617 @param StartBit The ordinal of the least significant bit in the bit field.
2619 @param EndBit The ordinal of the most significant bit in the bit field.
2621 @param AndData The value to AND with the read value from the value
2623 @return The new 16-bit value.
2637 Reads a bit field from a 16-bit value, performs a bitwise AND followed by a
2638 bitwise OR, and returns the result.
2640 Performs a bitwise AND between the bit field specified by StartBit and EndBit
2641 in Operand and the value specified by AndData, followed by a bitwise
2642 OR with value specified by OrData. All other bits in Operand are
2643 preserved. The new 16-bit value is returned.
2645 If 16-bit operations are not supported, then ASSERT().
2646 If StartBit is greater than 15, then ASSERT().
2647 If EndBit is greater than 15, then ASSERT().
2648 If EndBit is less than StartBit, then ASSERT().
2649 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
2650 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
2652 @param Operand Operand on which to perform the bitfield operation.
2653 @param StartBit The ordinal of the least significant bit in the bit field.
2655 @param EndBit The ordinal of the most significant bit in the bit field.
2657 @param AndData The value to AND with the read value from the value.
2658 @param OrData The value to OR with the result of the AND operation.
2660 @return The new 16-bit value.
2665 BitFieldAndThenOr16 (
2675 Returns a bit field from a 32-bit value.
2677 Returns the bitfield specified by the StartBit and the EndBit from Operand.
2679 If 32-bit operations are not supported, then ASSERT().
2680 If StartBit is greater than 31, then ASSERT().
2681 If EndBit is greater than 31, then ASSERT().
2682 If EndBit is less than StartBit, then ASSERT().
2684 @param Operand Operand on which to perform the bitfield operation.
2685 @param StartBit The ordinal of the least significant bit in the bit field.
2687 @param EndBit The ordinal of the most significant bit in the bit field.
2690 @return The bit field read.
2703 Writes a bit field to a 32-bit value, and returns the result.
2705 Writes Value to the bit field specified by the StartBit and the EndBit in
2706 Operand. All other bits in Operand are preserved. The new 32-bit value is
2709 If 32-bit operations are not supported, then ASSERT().
2710 If StartBit is greater than 31, then ASSERT().
2711 If EndBit is greater than 31, then ASSERT().
2712 If EndBit is less than StartBit, then ASSERT().
2713 If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
2715 @param Operand Operand on which to perform the bitfield operation.
2716 @param StartBit The ordinal of the least significant bit in the bit field.
2718 @param EndBit The ordinal of the most significant bit in the bit field.
2720 @param Value New value of the bit field.
2722 @return The new 32-bit value.
2736 Reads a bit field from a 32-bit value, performs a bitwise OR, and returns the
2739 Performs a bitwise OR between the bit field specified by StartBit
2740 and EndBit in Operand and the value specified by OrData. All other bits in
2741 Operand are preserved. The new 32-bit value is returned.
2743 If 32-bit operations are not supported, then ASSERT().
2744 If StartBit is greater than 31, then ASSERT().
2745 If EndBit is greater than 31, then ASSERT().
2746 If EndBit is less than StartBit, then ASSERT().
2747 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
2749 @param Operand Operand on which to perform the bitfield operation.
2750 @param StartBit The ordinal of the least significant bit in the bit field.
2752 @param EndBit The ordinal of the most significant bit in the bit field.
2754 @param OrData The value to OR with the read value from the value.
2756 @return The new 32-bit value.
2770 Reads a bit field from a 32-bit value, performs a bitwise AND, and returns
2773 Performs a bitwise AND between the bit field specified by StartBit and EndBit
2774 in Operand and the value specified by AndData. All other bits in Operand are
2775 preserved. The new 32-bit value is returned.
2777 If 32-bit operations are not supported, then ASSERT().
2778 If StartBit is greater than 31, then ASSERT().
2779 If EndBit is greater than 31, then ASSERT().
2780 If EndBit is less than StartBit, then ASSERT().
2781 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
2783 @param Operand Operand on which to perform the bitfield operation.
2784 @param StartBit The ordinal of the least significant bit in the bit field.
2786 @param EndBit The ordinal of the most significant bit in the bit field.
2788 @param AndData The value to AND with the read value from the value
2790 @return The new 32-bit value.
2804 Reads a bit field from a 32-bit value, performs a bitwise AND followed by a
2805 bitwise OR, and returns the result.
2807 Performs a bitwise AND between the bit field specified by StartBit and EndBit
2808 in Operand and the value specified by AndData, followed by a bitwise
2809 OR with value specified by OrData. All other bits in Operand are
2810 preserved. The new 32-bit value is returned.
2812 If 32-bit operations are not supported, then ASSERT().
2813 If StartBit is greater than 31, then ASSERT().
2814 If EndBit is greater than 31, then ASSERT().
2815 If EndBit is less than StartBit, then ASSERT().
2816 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
2817 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
2819 @param Operand Operand on which to perform the bitfield operation.
2820 @param StartBit The ordinal of the least significant bit in the bit field.
2822 @param EndBit The ordinal of the most significant bit in the bit field.
2824 @param AndData The value to AND with the read value from the value.
2825 @param OrData The value to OR with the result of the AND operation.
2827 @return The new 32-bit value.
2832 BitFieldAndThenOr32 (
2842 Returns a bit field from a 64-bit value.
2844 Returns the bitfield specified by the StartBit and the EndBit from Operand.
2846 If 64-bit operations are not supported, then ASSERT().
2847 If StartBit is greater than 63, then ASSERT().
2848 If EndBit is greater than 63, then ASSERT().
2849 If EndBit is less than StartBit, then ASSERT().
2851 @param Operand Operand on which to perform the bitfield operation.
2852 @param StartBit The ordinal of the least significant bit in the bit field.
2854 @param EndBit The ordinal of the most significant bit in the bit field.
2857 @return The bit field read.
2870 Writes a bit field to a 64-bit value, and returns the result.
2872 Writes Value to the bit field specified by the StartBit and the EndBit in
2873 Operand. All other bits in Operand are preserved. The new 64-bit value is
2876 If 64-bit operations are not supported, then ASSERT().
2877 If StartBit is greater than 63, then ASSERT().
2878 If EndBit is greater than 63, then ASSERT().
2879 If EndBit is less than StartBit, then ASSERT().
2880 If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
2882 @param Operand Operand on which to perform the bitfield operation.
2883 @param StartBit The ordinal of the least significant bit in the bit field.
2885 @param EndBit The ordinal of the most significant bit in the bit field.
2887 @param Value New value of the bit field.
2889 @return The new 64-bit value.
2903 Reads a bit field from a 64-bit value, performs a bitwise OR, and returns the
2906 Performs a bitwise OR between the bit field specified by StartBit
2907 and EndBit in Operand and the value specified by OrData. All other bits in
2908 Operand are preserved. The new 64-bit value is returned.
2910 If 64-bit operations are not supported, then ASSERT().
2911 If StartBit is greater than 63, then ASSERT().
2912 If EndBit is greater than 63, then ASSERT().
2913 If EndBit is less than StartBit, then ASSERT().
2914 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
2916 @param Operand Operand on which to perform the bitfield operation.
2917 @param StartBit The ordinal of the least significant bit in the bit field.
2919 @param EndBit The ordinal of the most significant bit in the bit field.
2921 @param OrData The value to OR with the read value from the value
2923 @return The new 64-bit value.
2937 Reads a bit field from a 64-bit value, performs a bitwise AND, and returns
2940 Performs a bitwise AND between the bit field specified by StartBit and EndBit
2941 in Operand and the value specified by AndData. All other bits in Operand are
2942 preserved. The new 64-bit value is returned.
2944 If 64-bit operations are not supported, then ASSERT().
2945 If StartBit is greater than 63, then ASSERT().
2946 If EndBit is greater than 63, then ASSERT().
2947 If EndBit is less than StartBit, then ASSERT().
2948 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
2950 @param Operand Operand on which to perform the bitfield operation.
2951 @param StartBit The ordinal of the least significant bit in the bit field.
2953 @param EndBit The ordinal of the most significant bit in the bit field.
2955 @param AndData The value to AND with the read value from the value
2957 @return The new 64-bit value.
2971 Reads a bit field from a 64-bit value, performs a bitwise AND followed by a
2972 bitwise OR, and returns the result.
2974 Performs a bitwise AND between the bit field specified by StartBit and EndBit
2975 in Operand and the value specified by AndData, followed by a bitwise
2976 OR with value specified by OrData. All other bits in Operand are
2977 preserved. The new 64-bit value is returned.
2979 If 64-bit operations are not supported, then ASSERT().
2980 If StartBit is greater than 63, then ASSERT().
2981 If EndBit is greater than 63, then ASSERT().
2982 If EndBit is less than StartBit, then ASSERT().
2983 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
2984 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
2986 @param Operand Operand on which to perform the bitfield operation.
2987 @param StartBit The ordinal of the least significant bit in the bit field.
2989 @param EndBit The ordinal of the most significant bit in the bit field.
2991 @param AndData The value to AND with the read value from the value.
2992 @param OrData The value to OR with the result of the AND operation.
2994 @return The new 64-bit value.
2999 BitFieldAndThenOr64 (
3008 // Base Library Checksum Functions
3012 Returns the sum of all elements in a buffer in unit of UINT8.
3013 During calculation, the carry bits are dropped.
3015 This function calculates the sum of all elements in a buffer
3016 in unit of UINT8. The carry bits in result of addition are dropped.
3017 The result is returned as UINT8. If Length is Zero, then Zero is
3020 If Buffer is NULL, then ASSERT().
3021 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
3023 @param Buffer The pointer to the buffer to carry out the sum operation.
3024 @param Length The size, in bytes, of Buffer.
3026 @return Sum The sum of Buffer with carry bits dropped during additions.
3032 IN CONST UINT8
*Buffer
,
3038 Returns the two's complement checksum of all elements in a buffer
3041 This function first calculates the sum of the 8-bit values in the
3042 buffer specified by Buffer and Length. The carry bits in the result
3043 of addition are dropped. Then, the two's complement of the sum is
3044 returned. If Length is 0, then 0 is returned.
3046 If Buffer is NULL, then ASSERT().
3047 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
3049 @param Buffer The pointer to the buffer to carry out the checksum operation.
3050 @param Length The size, in bytes, of Buffer.
3052 @return Checksum The two's complement checksum of Buffer.
3057 CalculateCheckSum8 (
3058 IN CONST UINT8
*Buffer
,
3064 Returns the sum of all elements in a buffer of 16-bit values. During
3065 calculation, the carry bits are dropped.
3067 This function calculates the sum of the 16-bit values in the buffer
3068 specified by Buffer and Length. The carry bits in result of addition are dropped.
3069 The 16-bit result is returned. If Length is 0, then 0 is returned.
3071 If Buffer is NULL, then ASSERT().
3072 If Buffer is not aligned on a 16-bit boundary, then ASSERT().
3073 If Length is not aligned on a 16-bit boundary, then ASSERT().
3074 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
3076 @param Buffer The pointer to the buffer to carry out the sum operation.
3077 @param Length The size, in bytes, of Buffer.
3079 @return Sum The sum of Buffer with carry bits dropped during additions.
3085 IN CONST UINT16
*Buffer
,
3091 Returns the two's complement checksum of all elements in a buffer of
3094 This function first calculates the sum of the 16-bit values in the buffer
3095 specified by Buffer and Length. The carry bits in the result of addition
3096 are dropped. Then, the two's complement of the sum is returned. If Length
3097 is 0, then 0 is returned.
3099 If Buffer is NULL, then ASSERT().
3100 If Buffer is not aligned on a 16-bit boundary, then ASSERT().
3101 If Length is not aligned on a 16-bit boundary, then ASSERT().
3102 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
3104 @param Buffer The pointer to the buffer to carry out the checksum operation.
3105 @param Length The size, in bytes, of Buffer.
3107 @return Checksum The two's complement checksum of Buffer.
3112 CalculateCheckSum16 (
3113 IN CONST UINT16
*Buffer
,
3119 Returns the sum of all elements in a buffer of 32-bit values. During
3120 calculation, the carry bits are dropped.
3122 This function calculates the sum of the 32-bit values in the buffer
3123 specified by Buffer and Length. The carry bits in result of addition are dropped.
3124 The 32-bit result is returned. If Length is 0, then 0 is returned.
3126 If Buffer is NULL, then ASSERT().
3127 If Buffer is not aligned on a 32-bit boundary, then ASSERT().
3128 If Length is not aligned on a 32-bit boundary, then ASSERT().
3129 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
3131 @param Buffer The pointer to the buffer to carry out the sum operation.
3132 @param Length The size, in bytes, of Buffer.
3134 @return Sum The sum of Buffer with carry bits dropped during additions.
3140 IN CONST UINT32
*Buffer
,
3146 Returns the two's complement checksum of all elements in a buffer of
3149 This function first calculates the sum of the 32-bit values in the buffer
3150 specified by Buffer and Length. The carry bits in the result of addition
3151 are dropped. Then, the two's complement of the sum is returned. If Length
3152 is 0, then 0 is returned.
3154 If Buffer is NULL, then ASSERT().
3155 If Buffer is not aligned on a 32-bit boundary, then ASSERT().
3156 If Length is not aligned on a 32-bit boundary, then ASSERT().
3157 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
3159 @param Buffer The pointer to the buffer to carry out the checksum operation.
3160 @param Length The size, in bytes, of Buffer.
3162 @return Checksum The two's complement checksum of Buffer.
3167 CalculateCheckSum32 (
3168 IN CONST UINT32
*Buffer
,
3174 Returns the sum of all elements in a buffer of 64-bit values. During
3175 calculation, the carry bits are dropped.
3177 This function calculates the sum of the 64-bit values in the buffer
3178 specified by Buffer and Length. The carry bits in result of addition are dropped.
3179 The 64-bit result is returned. If Length is 0, then 0 is returned.
3181 If Buffer is NULL, then ASSERT().
3182 If Buffer is not aligned on a 64-bit boundary, then ASSERT().
3183 If Length is not aligned on a 64-bit boundary, then ASSERT().
3184 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
3186 @param Buffer The pointer to the buffer to carry out the sum operation.
3187 @param Length The size, in bytes, of Buffer.
3189 @return Sum The sum of Buffer with carry bits dropped during additions.
3195 IN CONST UINT64
*Buffer
,
3201 Returns the two's complement checksum of all elements in a buffer of
3204 This function first calculates the sum of the 64-bit values in the buffer
3205 specified by Buffer and Length. The carry bits in the result of addition
3206 are dropped. Then, the two's complement of the sum is returned. If Length
3207 is 0, then 0 is returned.
3209 If Buffer is NULL, then ASSERT().
3210 If Buffer is not aligned on a 64-bit boundary, then ASSERT().
3211 If Length is not aligned on a 64-bit boundary, then ASSERT().
3212 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
3214 @param Buffer The pointer to the buffer to carry out the checksum operation.
3215 @param Length The size, in bytes, of Buffer.
3217 @return Checksum The two's complement checksum of Buffer.
3222 CalculateCheckSum64 (
3223 IN CONST UINT64
*Buffer
,
3229 // Base Library CPU Functions
3233 Function entry point used when a stack switch is requested with SwitchStack()
3235 @param Context1 Context1 parameter passed into SwitchStack().
3236 @param Context2 Context2 parameter passed into SwitchStack().
3241 (EFIAPI
*SWITCH_STACK_ENTRY_POINT
)(
3242 IN VOID
*Context1
, OPTIONAL
3243 IN VOID
*Context2 OPTIONAL
3248 Used to serialize load and store operations.
3250 All loads and stores that proceed calls to this function are guaranteed to be
3251 globally visible when this function returns.
3262 Saves the current CPU context that can be restored with a call to LongJump()
3265 Saves the current CPU context in the buffer specified by JumpBuffer and
3266 returns 0. The initial call to SetJump() must always return 0. Subsequent
3267 calls to LongJump() cause a non-zero value to be returned by SetJump().
3269 If JumpBuffer is NULL, then ASSERT().
3270 For Itanium processors, if JumpBuffer is not aligned on a 16-byte boundary, then ASSERT().
3272 NOTE: The structure BASE_LIBRARY_JUMP_BUFFER is CPU architecture specific.
3273 The same structure must never be used for more than one CPU architecture context.
3274 For example, a BASE_LIBRARY_JUMP_BUFFER allocated by an IA-32 module must never be used from an x64 module.
3275 SetJump()/LongJump() is not currently supported for the EBC processor type.
3277 @param JumpBuffer A pointer to CPU context buffer.
3279 @retval 0 Indicates a return from SetJump().
3285 OUT BASE_LIBRARY_JUMP_BUFFER
*JumpBuffer
3290 Restores the CPU context that was saved with SetJump().
3292 Restores the CPU context from the buffer specified by JumpBuffer. This
3293 function never returns to the caller. Instead is resumes execution based on
3294 the state of JumpBuffer.
3296 If JumpBuffer is NULL, then ASSERT().
3297 For Itanium processors, if JumpBuffer is not aligned on a 16-byte boundary, then ASSERT().
3298 If Value is 0, then ASSERT().
3300 @param JumpBuffer A pointer to CPU context buffer.
3301 @param Value The value to return when the SetJump() context is
3302 restored and must be non-zero.
3308 IN BASE_LIBRARY_JUMP_BUFFER
*JumpBuffer
,
3314 Enables CPU interrupts.
3325 Disables CPU interrupts.
3336 Disables CPU interrupts and returns the interrupt state prior to the disable
3339 @retval TRUE CPU interrupts were enabled on entry to this call.
3340 @retval FALSE CPU interrupts were disabled on entry to this call.
3345 SaveAndDisableInterrupts (
3351 Enables CPU interrupts for the smallest window required to capture any
3357 EnableDisableInterrupts (
3363 Retrieves the current CPU interrupt state.
3365 Returns TRUE if interrupts are currently enabled. Otherwise
3368 @retval TRUE CPU interrupts are enabled.
3369 @retval FALSE CPU interrupts are disabled.
3380 Set the current CPU interrupt state.
3382 Sets the current CPU interrupt state to the state specified by
3383 InterruptState. If InterruptState is TRUE, then interrupts are enabled. If
3384 InterruptState is FALSE, then interrupts are disabled. InterruptState is
3387 @param InterruptState TRUE if interrupts should enabled. FALSE if
3388 interrupts should be disabled.
3390 @return InterruptState
3396 IN BOOLEAN InterruptState
3401 Requests CPU to pause for a short period of time.
3403 Requests CPU to pause for a short period of time. Typically used in MP
3404 systems to prevent memory starvation while waiting for a spin lock.
3415 Transfers control to a function starting with a new stack.
3417 Transfers control to the function specified by EntryPoint using the
3418 new stack specified by NewStack and passing in the parameters specified
3419 by Context1 and Context2. Context1 and Context2 are optional and may
3420 be NULL. The function EntryPoint must never return. This function
3421 supports a variable number of arguments following the NewStack parameter.
3422 These additional arguments are ignored on IA-32, x64, and EBC architectures.
3423 Itanium processors expect one additional parameter of type VOID * that specifies
3424 the new backing store pointer.
3426 If EntryPoint is NULL, then ASSERT().
3427 If NewStack is NULL, then ASSERT().
3429 @param EntryPoint A pointer to function to call with the new stack.
3430 @param Context1 A pointer to the context to pass into the EntryPoint
3432 @param Context2 A pointer to the context to pass into the EntryPoint
3434 @param NewStack A pointer to the new stack to use for the EntryPoint
3436 @param ... This variable argument list is ignored for IA-32, x64, and
3437 EBC architectures. For Itanium processors, this variable
3438 argument list is expected to contain a single parameter of
3439 type VOID * that specifies the new backing store pointer.
3446 IN SWITCH_STACK_ENTRY_POINT EntryPoint
,
3447 IN VOID
*Context1
, OPTIONAL
3448 IN VOID
*Context2
, OPTIONAL
3455 Generates a breakpoint on the CPU.
3457 Generates a breakpoint on the CPU. The breakpoint must be implemented such
3458 that code can resume normal execution after the breakpoint.
3469 Executes an infinite loop.
3471 Forces the CPU to execute an infinite loop. A debugger may be used to skip
3472 past the loop and the code that follows the loop must execute properly. This
3473 implies that the infinite loop must not cause the code that follow it to be
3483 #if defined (MDE_CPU_IPF)
3486 Flush a range of cache lines in the cache coherency domain of the calling
3489 Flushes the cache lines specified by Address and Length. If Address is not aligned
3490 on a cache line boundary, then entire cache line containing Address is flushed.
3491 If Address + Length is not aligned on a cache line boundary, then the entire cache
3492 line containing Address + Length - 1 is flushed. This function may choose to flush
3493 the entire cache if that is more efficient than flushing the specified range. If
3494 Length is 0, the no cache lines are flushed. Address is returned.
3495 This function is only available on Itanium processors.
3497 If Length is greater than (MAX_ADDRESS - Address + 1), then ASSERT().
3499 @param Address The base address of the instruction lines to invalidate. If
3500 the CPU is in a physical addressing mode, then Address is a
3501 physical address. If the CPU is in a virtual addressing mode,
3502 then Address is a virtual address.
3504 @param Length The number of bytes to invalidate from the instruction cache.
3511 AsmFlushCacheRange (
3518 Executes an FC instruction.
3519 Executes an FC instruction on the cache line specified by Address.
3520 The cache line size affected is at least 32-bytes (aligned on a 32-byte boundary).
3521 An implementation may flush a larger region. This function is only available on Itanium processors.
3523 @param Address The Address of cache line to be flushed.
3525 @return The address of FC instruction executed.
3536 Executes an FC.I instruction.
3537 Executes an FC.I instruction on the cache line specified by Address.
3538 The cache line size affected is at least 32-bytes (aligned on a 32-byte boundary).
3539 An implementation may flush a larger region. This function is only available on Itanium processors.
3541 @param Address The Address of cache line to be flushed.
3543 @return The address of the FC.I instruction executed.
3554 Reads the current value of a Processor Identifier Register (CPUID).
3556 Reads and returns the current value of Processor Identifier Register specified by Index.
3557 The Index of largest implemented CPUID (One less than the number of implemented CPUID
3558 registers) is determined by CPUID [3] bits {7:0}.
3559 No parameter checking is performed on Index. If the Index value is beyond the
3560 implemented CPUID register range, a Reserved Register/Field fault may occur. The caller
3561 must either guarantee that Index is valid, or the caller must set up fault handlers to
3562 catch the faults. This function is only available on Itanium processors.
3564 @param Index The 8-bit Processor Identifier Register index to read.
3566 @return The current value of Processor Identifier Register specified by Index.
3577 Reads the current value of 64-bit Processor Status Register (PSR).
3578 This function is only available on Itanium processors.
3580 @return The current value of PSR.
3591 Writes the current value of 64-bit Processor Status Register (PSR).
3593 No parameter checking is performed on Value. All bits of Value corresponding to
3594 reserved fields of PSR must be 0 or a Reserved Register/Field fault may occur.
3595 The caller must either guarantee that Value is valid, or the caller must set up
3596 fault handlers to catch the faults. This function is only available on Itanium processors.
3598 @param Value The 64-bit value to write to PSR.
3600 @return The 64-bit value written to the PSR.
3611 Reads the current value of 64-bit Kernel Register #0 (KR0).
3613 Reads and returns the current value of KR0.
3614 This function is only available on Itanium processors.
3616 @return The current value of KR0.
3627 Reads the current value of 64-bit Kernel Register #1 (KR1).
3629 Reads and returns the current value of KR1.
3630 This function is only available on Itanium processors.
3632 @return The current value of KR1.
3643 Reads the current value of 64-bit Kernel Register #2 (KR2).
3645 Reads and returns the current value of KR2.
3646 This function is only available on Itanium processors.
3648 @return The current value of KR2.
3659 Reads the current value of 64-bit Kernel Register #3 (KR3).
3661 Reads and returns the current value of KR3.
3662 This function is only available on Itanium processors.
3664 @return The current value of KR3.
3675 Reads the current value of 64-bit Kernel Register #4 (KR4).
3677 Reads and returns the current value of KR4.
3678 This function is only available on Itanium processors.
3680 @return The current value of KR4.
3691 Reads the current value of 64-bit Kernel Register #5 (KR5).
3693 Reads and returns the current value of KR5.
3694 This function is only available on Itanium processors.
3696 @return The current value of KR5.
3707 Reads the current value of 64-bit Kernel Register #6 (KR6).
3709 Reads and returns the current value of KR6.
3710 This function is only available on Itanium processors.
3712 @return The current value of KR6.
3723 Reads the current value of 64-bit Kernel Register #7 (KR7).
3725 Reads and returns the current value of KR7.
3726 This function is only available on Itanium processors.
3728 @return The current value of KR7.
3739 Write the current value of 64-bit Kernel Register #0 (KR0).
3741 Writes the current value of KR0. The 64-bit value written to
3742 the KR0 is returned. This function is only available on Itanium processors.
3744 @param Value The 64-bit value to write to KR0.
3746 @return The 64-bit value written to the KR0.
3757 Write the current value of 64-bit Kernel Register #1 (KR1).
3759 Writes the current value of KR1. The 64-bit value written to
3760 the KR1 is returned. This function is only available on Itanium processors.
3762 @param Value The 64-bit value to write to KR1.
3764 @return The 64-bit value written to the KR1.
3775 Write the current value of 64-bit Kernel Register #2 (KR2).
3777 Writes the current value of KR2. The 64-bit value written to
3778 the KR2 is returned. This function is only available on Itanium processors.
3780 @param Value The 64-bit value to write to KR2.
3782 @return The 64-bit value written to the KR2.
3793 Write the current value of 64-bit Kernel Register #3 (KR3).
3795 Writes the current value of KR3. The 64-bit value written to
3796 the KR3 is returned. This function is only available on Itanium processors.
3798 @param Value The 64-bit value to write to KR3.
3800 @return The 64-bit value written to the KR3.
3811 Write the current value of 64-bit Kernel Register #4 (KR4).
3813 Writes the current value of KR4. The 64-bit value written to
3814 the KR4 is returned. This function is only available on Itanium processors.
3816 @param Value The 64-bit value to write to KR4.
3818 @return The 64-bit value written to the KR4.
3829 Write the current value of 64-bit Kernel Register #5 (KR5).
3831 Writes the current value of KR5. The 64-bit value written to
3832 the KR5 is returned. This function is only available on Itanium processors.
3834 @param Value The 64-bit value to write to KR5.
3836 @return The 64-bit value written to the KR5.
3847 Write the current value of 64-bit Kernel Register #6 (KR6).
3849 Writes the current value of KR6. The 64-bit value written to
3850 the KR6 is returned. This function is only available on Itanium processors.
3852 @param Value The 64-bit value to write to KR6.
3854 @return The 64-bit value written to the KR6.
3865 Write the current value of 64-bit Kernel Register #7 (KR7).
3867 Writes the current value of KR7. The 64-bit value written to
3868 the KR7 is returned. This function is only available on Itanium processors.
3870 @param Value The 64-bit value to write to KR7.
3872 @return The 64-bit value written to the KR7.
3883 Reads the current value of Interval Timer Counter Register (ITC).
3885 Reads and returns the current value of ITC.
3886 This function is only available on Itanium processors.
3888 @return The current value of ITC.
3899 Reads the current value of Interval Timer Vector Register (ITV).
3901 Reads and returns the current value of ITV.
3902 This function is only available on Itanium processors.
3904 @return The current value of ITV.
3915 Reads the current value of Interval Timer Match Register (ITM).
3917 Reads and returns the current value of ITM.
3918 This function is only available on Itanium processors.
3920 @return The current value of ITM.
3930 Writes the current value of 64-bit Interval Timer Counter Register (ITC).
3932 Writes the current value of ITC. The 64-bit value written to the ITC is returned.
3933 This function is only available on Itanium processors.
3935 @param Value The 64-bit value to write to ITC.
3937 @return The 64-bit value written to the ITC.
3948 Writes the current value of 64-bit Interval Timer Match Register (ITM).
3950 Writes the current value of ITM. The 64-bit value written to the ITM is returned.
3951 This function is only available on Itanium processors.
3953 @param Value The 64-bit value to write to ITM.
3955 @return The 64-bit value written to the ITM.
3966 Writes the current value of 64-bit Interval Timer Vector Register (ITV).
3968 Writes the current value of ITV. The 64-bit value written to the ITV is returned.
3969 No parameter checking is performed on Value. All bits of Value corresponding to
3970 reserved fields of ITV must be 0 or a Reserved Register/Field fault may occur.
3971 The caller must either guarantee that Value is valid, or the caller must set up
3972 fault handlers to catch the faults.
3973 This function is only available on Itanium processors.
3975 @param Value The 64-bit value to write to ITV.
3977 @return The 64-bit value written to the ITV.
3988 Reads the current value of Default Control Register (DCR).
3990 Reads and returns the current value of DCR. This function is only available on Itanium processors.
3992 @return The current value of DCR.
4003 Reads the current value of Interruption Vector Address Register (IVA).
4005 Reads and returns the current value of IVA. This function is only available on Itanium processors.
4007 @return The current value of IVA.
4017 Reads the current value of Page Table Address Register (PTA).
4019 Reads and returns the current value of PTA. This function is only available on Itanium processors.
4021 @return The current value of PTA.
4032 Writes the current value of 64-bit Default Control Register (DCR).
4034 Writes the current value of DCR. The 64-bit value written to the DCR is returned.
4035 No parameter checking is performed on Value. All bits of Value corresponding to
4036 reserved fields of DCR must be 0 or a Reserved Register/Field fault may occur.
4037 The caller must either guarantee that Value is valid, or the caller must set up
4038 fault handlers to catch the faults.
4039 This function is only available on Itanium processors.
4041 @param Value The 64-bit value to write to DCR.
4043 @return The 64-bit value written to the DCR.
4054 Writes the current value of 64-bit Interruption Vector Address Register (IVA).
4056 Writes the current value of IVA. The 64-bit value written to the IVA is returned.
4057 The size of vector table is 32 K bytes and is 32 K bytes aligned
4058 the low 15 bits of Value is ignored when written.
4059 This function is only available on Itanium processors.
4061 @param Value The 64-bit value to write to IVA.
4063 @return The 64-bit value written to the IVA.
4074 Writes the current value of 64-bit Page Table Address Register (PTA).
4076 Writes the current value of PTA. The 64-bit value written to the PTA is returned.
4077 No parameter checking is performed on Value. All bits of Value corresponding to
4078 reserved fields of DCR must be 0 or a Reserved Register/Field fault may occur.
4079 The caller must either guarantee that Value is valid, or the caller must set up
4080 fault handlers to catch the faults.
4081 This function is only available on Itanium processors.
4083 @param Value The 64-bit value to write to PTA.
4085 @return The 64-bit value written to the PTA.
4095 Reads the current value of Local Interrupt ID Register (LID).
4097 Reads and returns the current value of LID. This function is only available on Itanium processors.
4099 @return The current value of LID.
4110 Reads the current value of External Interrupt Vector Register (IVR).
4112 Reads and returns the current value of IVR. This function is only available on Itanium processors.
4114 @return The current value of IVR.
4125 Reads the current value of Task Priority Register (TPR).
4127 Reads and returns the current value of TPR. This function is only available on Itanium processors.
4129 @return The current value of TPR.
4140 Reads the current value of External Interrupt Request Register #0 (IRR0).
4142 Reads and returns the current value of IRR0. This function is only available on Itanium processors.
4144 @return The current value of IRR0.
4155 Reads the current value of External Interrupt Request Register #1 (IRR1).
4157 Reads and returns the current value of IRR1. This function is only available on Itanium processors.
4159 @return The current value of IRR1.
4170 Reads the current value of External Interrupt Request Register #2 (IRR2).
4172 Reads and returns the current value of IRR2. This function is only available on Itanium processors.
4174 @return The current value of IRR2.
4185 Reads the current value of External Interrupt Request Register #3 (IRR3).
4187 Reads and returns the current value of IRR3. This function is only available on Itanium processors.
4189 @return The current value of IRR3.
4200 Reads the current value of Performance Monitor Vector Register (PMV).
4202 Reads and returns the current value of PMV. This function is only available on Itanium processors.
4204 @return The current value of PMV.
4215 Reads the current value of Corrected Machine Check Vector Register (CMCV).
4217 Reads and returns the current value of CMCV. This function is only available on Itanium processors.
4219 @return The current value of CMCV.
4230 Reads the current value of Local Redirection Register #0 (LRR0).
4232 Reads and returns the current value of LRR0. This function is only available on Itanium processors.
4234 @return The current value of LRR0.
4245 Reads the current value of Local Redirection Register #1 (LRR1).
4247 Reads and returns the current value of LRR1. This function is only available on Itanium processors.
4249 @return The current value of LRR1.
4260 Writes the current value of 64-bit Page Local Interrupt ID Register (LID).
4262 Writes the current value of LID. The 64-bit value written to the LID is returned.
4263 No parameter checking is performed on Value. All bits of Value corresponding to
4264 reserved fields of LID must be 0 or a Reserved Register/Field fault may occur.
4265 The caller must either guarantee that Value is valid, or the caller must set up
4266 fault handlers to catch the faults.
4267 This function is only available on Itanium processors.
4269 @param Value The 64-bit value to write to LID.
4271 @return The 64-bit value written to the LID.
4282 Writes the current value of 64-bit Task Priority Register (TPR).
4284 Writes the current value of TPR. The 64-bit value written to the TPR is returned.
4285 No parameter checking is performed on Value. All bits of Value corresponding to
4286 reserved fields of TPR must be 0 or a Reserved Register/Field fault may occur.
4287 The caller must either guarantee that Value is valid, or the caller must set up
4288 fault handlers to catch the faults.
4289 This function is only available on Itanium processors.
4291 @param Value The 64-bit value to write to TPR.
4293 @return The 64-bit value written to the TPR.
4304 Performs a write operation on End OF External Interrupt Register (EOI).
4306 Writes a value of 0 to the EOI Register. This function is only available on Itanium processors.
4317 Writes the current value of 64-bit Performance Monitor Vector Register (PMV).
4319 Writes the current value of PMV. The 64-bit value written to the PMV is returned.
4320 No parameter checking is performed on Value. All bits of Value corresponding
4321 to reserved fields of PMV must be 0 or a Reserved Register/Field fault may occur.
4322 The caller must either guarantee that Value is valid, or the caller must set up
4323 fault handlers to catch the faults.
4324 This function is only available on Itanium processors.
4326 @param Value The 64-bit value to write to PMV.
4328 @return The 64-bit value written to the PMV.
4339 Writes the current value of 64-bit Corrected Machine Check Vector Register (CMCV).
4341 Writes the current value of CMCV. The 64-bit value written to the CMCV is returned.
4342 No parameter checking is performed on Value. All bits of Value corresponding
4343 to reserved fields of CMCV must be 0 or a Reserved Register/Field fault may occur.
4344 The caller must either guarantee that Value is valid, or the caller must set up
4345 fault handlers to catch the faults.
4346 This function is only available on Itanium processors.
4348 @param Value The 64-bit value to write to CMCV.
4350 @return The 64-bit value written to the CMCV.
4361 Writes the current value of 64-bit Local Redirection Register #0 (LRR0).
4363 Writes the current value of LRR0. The 64-bit value written to the LRR0 is returned.
4364 No parameter checking is performed on Value. All bits of Value corresponding
4365 to reserved fields of LRR0 must be 0 or a Reserved Register/Field fault may occur.
4366 The caller must either guarantee that Value is valid, or the caller must set up
4367 fault handlers to catch the faults.
4368 This function is only available on Itanium processors.
4370 @param Value The 64-bit value to write to LRR0.
4372 @return The 64-bit value written to the LRR0.
4383 Writes the current value of 64-bit Local Redirection Register #1 (LRR1).
4385 Writes the current value of LRR1. The 64-bit value written to the LRR1 is returned.
4386 No parameter checking is performed on Value. All bits of Value corresponding
4387 to reserved fields of LRR1 must be 0 or a Reserved Register/Field fault may occur.
4388 The caller must either guarantee that Value is valid, or the caller must
4389 set up fault handlers to catch the faults.
4390 This function is only available on Itanium processors.
4392 @param Value The 64-bit value to write to LRR1.
4394 @return The 64-bit value written to the LRR1.
4405 Reads the current value of Instruction Breakpoint Register (IBR).
4407 The Instruction Breakpoint Registers are used in pairs. The even numbered
4408 registers contain breakpoint addresses, and the odd numbered registers contain
4409 breakpoint mask conditions. At least four instruction registers pairs are implemented
4410 on all processor models. Implemented registers are contiguous starting with
4411 register 0. No parameter checking is performed on Index, and if the Index value
4412 is beyond the implemented IBR register range, a Reserved Register/Field fault may
4413 occur. The caller must either guarantee that Index is valid, or the caller must
4414 set up fault handlers to catch the faults.
4415 This function is only available on Itanium processors.
4417 @param Index The 8-bit Instruction Breakpoint Register index to read.
4419 @return The current value of Instruction Breakpoint Register specified by Index.
4430 Reads the current value of Data Breakpoint Register (DBR).
4432 The Data Breakpoint Registers are used in pairs. The even numbered registers
4433 contain breakpoint addresses, and odd numbered registers contain breakpoint
4434 mask conditions. At least four data registers pairs are implemented on all processor
4435 models. Implemented registers are contiguous starting with register 0.
4436 No parameter checking is performed on Index. If the Index value is beyond
4437 the implemented DBR register range, a Reserved Register/Field fault may occur.
4438 The caller must either guarantee that Index is valid, or the caller must set up
4439 fault handlers to catch the faults.
4440 This function is only available on Itanium processors.
4442 @param Index The 8-bit Data Breakpoint Register index to read.
4444 @return The current value of Data Breakpoint Register specified by Index.
4455 Reads the current value of Performance Monitor Configuration Register (PMC).
4457 All processor implementations provide at least four performance counters
4458 (PMC/PMD [4]...PMC/PMD [7] pairs), and four performance monitor counter overflow
4459 status registers (PMC [0]... PMC [3]). Processor implementations may provide
4460 additional implementation-dependent PMC and PMD to increase the number of
4461 'generic' performance counters (PMC/PMD pairs). The remainder of PMC and PMD
4462 register set is implementation dependent. No parameter checking is performed
4463 on Index. If the Index value is beyond the implemented PMC register range,
4464 zero value will be returned.
4465 This function is only available on Itanium processors.
4467 @param Index The 8-bit Performance Monitor Configuration Register index to read.
4469 @return The current value of Performance Monitor Configuration Register
4481 Reads the current value of Performance Monitor Data Register (PMD).
4483 All processor implementations provide at least 4 performance counters
4484 (PMC/PMD [4]...PMC/PMD [7] pairs), and 4 performance monitor counter
4485 overflow status registers (PMC [0]... PMC [3]). Processor implementations may
4486 provide additional implementation-dependent PMC and PMD to increase the number
4487 of 'generic' performance counters (PMC/PMD pairs). The remainder of PMC and PMD
4488 register set is implementation dependent. No parameter checking is performed
4489 on Index. If the Index value is beyond the implemented PMD register range,
4490 zero value will be returned.
4491 This function is only available on Itanium processors.
4493 @param Index The 8-bit Performance Monitor Data Register index to read.
4495 @return The current value of Performance Monitor Data Register specified by Index.
4506 Writes the current value of 64-bit Instruction Breakpoint Register (IBR).
4508 Writes current value of Instruction Breakpoint Register specified by Index.
4509 The Instruction Breakpoint Registers are used in pairs. The even numbered
4510 registers contain breakpoint addresses, and odd numbered registers contain
4511 breakpoint mask conditions. At least four instruction registers pairs are implemented
4512 on all processor models. Implemented registers are contiguous starting with
4513 register 0. No parameter checking is performed on Index. If the Index value
4514 is beyond the implemented IBR register range, a Reserved Register/Field fault may
4515 occur. The caller must either guarantee that Index is valid, or the caller must
4516 set up fault handlers to catch the faults.
4517 This function is only available on Itanium processors.
4519 @param Index The 8-bit Instruction Breakpoint Register index to write.
4520 @param Value The 64-bit value to write to IBR.
4522 @return The 64-bit value written to the IBR.
4534 Writes the current value of 64-bit Data Breakpoint Register (DBR).
4536 Writes current value of Data Breakpoint Register specified by Index.
4537 The Data Breakpoint Registers are used in pairs. The even numbered registers
4538 contain breakpoint addresses, and odd numbered registers contain breakpoint
4539 mask conditions. At least four data registers pairs are implemented on all processor
4540 models. Implemented registers are contiguous starting with register 0. No parameter
4541 checking is performed on Index. If the Index value is beyond the implemented
4542 DBR register range, a Reserved Register/Field fault may occur. The caller must
4543 either guarantee that Index is valid, or the caller must set up fault handlers to
4545 This function is only available on Itanium processors.
4547 @param Index The 8-bit Data Breakpoint Register index to write.
4548 @param Value The 64-bit value to write to DBR.
4550 @return The 64-bit value written to the DBR.
4562 Writes the current value of 64-bit Performance Monitor Configuration Register (PMC).
4564 Writes current value of Performance Monitor Configuration Register specified by Index.
4565 All processor implementations provide at least four performance counters
4566 (PMC/PMD [4]...PMC/PMD [7] pairs), and four performance monitor counter overflow status
4567 registers (PMC [0]... PMC [3]). Processor implementations may provide additional
4568 implementation-dependent PMC and PMD to increase the number of 'generic' performance
4569 counters (PMC/PMD pairs). The remainder of PMC and PMD register set is implementation
4570 dependent. No parameter checking is performed on Index. If the Index value is
4571 beyond the implemented PMC register range, the write is ignored.
4572 This function is only available on Itanium processors.
4574 @param Index The 8-bit Performance Monitor Configuration Register index to write.
4575 @param Value The 64-bit value to write to PMC.
4577 @return The 64-bit value written to the PMC.
4589 Writes the current value of 64-bit Performance Monitor Data Register (PMD).
4591 Writes current value of Performance Monitor Data Register specified by Index.
4592 All processor implementations provide at least four performance counters
4593 (PMC/PMD [4]...PMC/PMD [7] pairs), and four performance monitor counter overflow
4594 status registers (PMC [0]... PMC [3]). Processor implementations may provide
4595 additional implementation-dependent PMC and PMD to increase the number of 'generic'
4596 performance counters (PMC/PMD pairs). The remainder of PMC and PMD register set
4597 is implementation dependent. No parameter checking is performed on Index. If the
4598 Index value is beyond the implemented PMD register range, the write is ignored.
4599 This function is only available on Itanium processors.
4601 @param Index The 8-bit Performance Monitor Data Register index to write.
4602 @param Value The 64-bit value to write to PMD.
4604 @return The 64-bit value written to the PMD.
4616 Reads the current value of 64-bit Global Pointer (GP).
4618 Reads and returns the current value of GP.
4619 This function is only available on Itanium processors.
4621 @return The current value of GP.
4632 Write the current value of 64-bit Global Pointer (GP).
4634 Writes the current value of GP. The 64-bit value written to the GP is returned.
4635 No parameter checking is performed on Value.
4636 This function is only available on Itanium processors.
4638 @param Value The 64-bit value to write to GP.
4640 @return The 64-bit value written to the GP.
4651 Reads the current value of 64-bit Stack Pointer (SP).
4653 Reads and returns the current value of SP.
4654 This function is only available on Itanium processors.
4656 @return The current value of SP.
4667 /// Valid Index value for AsmReadControlRegister().
4669 #define IPF_CONTROL_REGISTER_DCR 0
4670 #define IPF_CONTROL_REGISTER_ITM 1
4671 #define IPF_CONTROL_REGISTER_IVA 2
4672 #define IPF_CONTROL_REGISTER_PTA 8
4673 #define IPF_CONTROL_REGISTER_IPSR 16
4674 #define IPF_CONTROL_REGISTER_ISR 17
4675 #define IPF_CONTROL_REGISTER_IIP 19
4676 #define IPF_CONTROL_REGISTER_IFA 20
4677 #define IPF_CONTROL_REGISTER_ITIR 21
4678 #define IPF_CONTROL_REGISTER_IIPA 22
4679 #define IPF_CONTROL_REGISTER_IFS 23
4680 #define IPF_CONTROL_REGISTER_IIM 24
4681 #define IPF_CONTROL_REGISTER_IHA 25
4682 #define IPF_CONTROL_REGISTER_LID 64
4683 #define IPF_CONTROL_REGISTER_IVR 65
4684 #define IPF_CONTROL_REGISTER_TPR 66
4685 #define IPF_CONTROL_REGISTER_EOI 67
4686 #define IPF_CONTROL_REGISTER_IRR0 68
4687 #define IPF_CONTROL_REGISTER_IRR1 69
4688 #define IPF_CONTROL_REGISTER_IRR2 70
4689 #define IPF_CONTROL_REGISTER_IRR3 71
4690 #define IPF_CONTROL_REGISTER_ITV 72
4691 #define IPF_CONTROL_REGISTER_PMV 73
4692 #define IPF_CONTROL_REGISTER_CMCV 74
4693 #define IPF_CONTROL_REGISTER_LRR0 80
4694 #define IPF_CONTROL_REGISTER_LRR1 81
4697 Reads a 64-bit control register.
4699 Reads and returns the control register specified by Index. The valid Index valued
4700 are defined above in "Related Definitions".
4701 If Index is invalid then 0xFFFFFFFFFFFFFFFF is returned. This function is only
4702 available on Itanium processors.
4704 @param Index The index of the control register to read.
4706 @return The control register specified by Index.
4711 AsmReadControlRegister (
4717 /// Valid Index value for AsmReadApplicationRegister().
4719 #define IPF_APPLICATION_REGISTER_K0 0
4720 #define IPF_APPLICATION_REGISTER_K1 1
4721 #define IPF_APPLICATION_REGISTER_K2 2
4722 #define IPF_APPLICATION_REGISTER_K3 3
4723 #define IPF_APPLICATION_REGISTER_K4 4
4724 #define IPF_APPLICATION_REGISTER_K5 5
4725 #define IPF_APPLICATION_REGISTER_K6 6
4726 #define IPF_APPLICATION_REGISTER_K7 7
4727 #define IPF_APPLICATION_REGISTER_RSC 16
4728 #define IPF_APPLICATION_REGISTER_BSP 17
4729 #define IPF_APPLICATION_REGISTER_BSPSTORE 18
4730 #define IPF_APPLICATION_REGISTER_RNAT 19
4731 #define IPF_APPLICATION_REGISTER_FCR 21
4732 #define IPF_APPLICATION_REGISTER_EFLAG 24
4733 #define IPF_APPLICATION_REGISTER_CSD 25
4734 #define IPF_APPLICATION_REGISTER_SSD 26
4735 #define IPF_APPLICATION_REGISTER_CFLG 27
4736 #define IPF_APPLICATION_REGISTER_FSR 28
4737 #define IPF_APPLICATION_REGISTER_FIR 29
4738 #define IPF_APPLICATION_REGISTER_FDR 30
4739 #define IPF_APPLICATION_REGISTER_CCV 32
4740 #define IPF_APPLICATION_REGISTER_UNAT 36
4741 #define IPF_APPLICATION_REGISTER_FPSR 40
4742 #define IPF_APPLICATION_REGISTER_ITC 44
4743 #define IPF_APPLICATION_REGISTER_PFS 64
4744 #define IPF_APPLICATION_REGISTER_LC 65
4745 #define IPF_APPLICATION_REGISTER_EC 66
4748 Reads a 64-bit application register.
4750 Reads and returns the application register specified by Index. The valid Index
4751 valued are defined above in "Related Definitions".
4752 If Index is invalid then 0xFFFFFFFFFFFFFFFF is returned. This function is only
4753 available on Itanium processors.
4755 @param Index The index of the application register to read.
4757 @return The application register specified by Index.
4762 AsmReadApplicationRegister (
4768 Reads the current value of a Machine Specific Register (MSR).
4770 Reads and returns the current value of the Machine Specific Register specified by Index. No
4771 parameter checking is performed on Index, and if the Index value is beyond the implemented MSR
4772 register range, a Reserved Register/Field fault may occur. The caller must either guarantee that
4773 Index is valid, or the caller must set up fault handlers to catch the faults. This function is
4774 only available on Itanium processors.
4776 @param Index The 8-bit Machine Specific Register index to read.
4778 @return The current value of the Machine Specific Register specified by Index.
4789 Writes the current value of a Machine Specific Register (MSR).
4791 Writes Value to the Machine Specific Register specified by Index. Value is returned. No
4792 parameter checking is performed on Index, and if the Index value is beyond the implemented MSR
4793 register range, a Reserved Register/Field fault may occur. The caller must either guarantee that
4794 Index is valid, or the caller must set up fault handlers to catch the faults. This function is
4795 only available on Itanium processors.
4797 @param Index The 8-bit Machine Specific Register index to write.
4798 @param Value The 64-bit value to write to the Machine Specific Register.
4800 @return The 64-bit value to write to the Machine Specific Register.
4812 Determines if the CPU is currently executing in virtual, physical, or mixed mode.
4814 Determines the current execution mode of the CPU.
4815 If the CPU is in virtual mode(PSR.RT=1, PSR.DT=1, PSR.IT=1), then 1 is returned.
4816 If the CPU is in physical mode(PSR.RT=0, PSR.DT=0, PSR.IT=0), then 0 is returned.
4817 If the CPU is not in physical mode or virtual mode, then it is in mixed mode,
4819 This function is only available on Itanium processors.
4821 @retval 1 The CPU is in virtual mode.
4822 @retval 0 The CPU is in physical mode.
4823 @retval -1 The CPU is in mixed mode.
4834 Makes a PAL procedure call.
4836 This is a wrapper function to make a PAL procedure call. Based on the Index
4837 value this API will make static or stacked PAL call. The following table
4838 describes the usage of PAL Procedure Index Assignment. Architected procedures
4839 may be designated as required or optional. If a PAL procedure is specified
4840 as optional, a unique return code of 0xFFFFFFFFFFFFFFFF is returned in the
4841 Status field of the PAL_CALL_RETURN structure.
4842 This indicates that the procedure is not present in this PAL implementation.
4843 It is the caller's responsibility to check for this return code after calling
4844 any optional PAL procedure.
4845 No parameter checking is performed on the 5 input parameters, but there are
4846 some common rules that the caller should follow when making a PAL call. Any
4847 address passed to PAL as buffers for return parameters must be 8-byte aligned.
4848 Unaligned addresses may cause undefined results. For those parameters defined
4849 as reserved or some fields defined as reserved must be zero filled or the invalid
4850 argument return value may be returned or undefined result may occur during the
4851 execution of the procedure. If the PalEntryPoint does not point to a valid
4852 PAL entry point then the system behavior is undefined. This function is only
4853 available on Itanium processors.
4855 @param PalEntryPoint The PAL procedure calls entry point.
4856 @param Index The PAL procedure Index number.
4857 @param Arg2 The 2nd parameter for PAL procedure calls.
4858 @param Arg3 The 3rd parameter for PAL procedure calls.
4859 @param Arg4 The 4th parameter for PAL procedure calls.
4861 @return structure returned from the PAL Call procedure, including the status and return value.
4867 IN UINT64 PalEntryPoint
,
4875 #if defined (MDE_CPU_IA32) || defined (MDE_CPU_X64)
4877 /// IA32 and x64 Specific Functions.
4878 /// Byte packed structure for 16-bit Real Mode EFLAGS.
4882 UINT32 CF
:1; ///< Carry Flag.
4883 UINT32 Reserved_0
:1; ///< Reserved.
4884 UINT32 PF
:1; ///< Parity Flag.
4885 UINT32 Reserved_1
:1; ///< Reserved.
4886 UINT32 AF
:1; ///< Auxiliary Carry Flag.
4887 UINT32 Reserved_2
:1; ///< Reserved.
4888 UINT32 ZF
:1; ///< Zero Flag.
4889 UINT32 SF
:1; ///< Sign Flag.
4890 UINT32 TF
:1; ///< Trap Flag.
4891 UINT32 IF
:1; ///< Interrupt Enable Flag.
4892 UINT32 DF
:1; ///< Direction Flag.
4893 UINT32 OF
:1; ///< Overflow Flag.
4894 UINT32 IOPL
:2; ///< I/O Privilege Level.
4895 UINT32 NT
:1; ///< Nested Task.
4896 UINT32 Reserved_3
:1; ///< Reserved.
4902 /// Byte packed structure for EFLAGS/RFLAGS.
4903 /// 32-bits on IA-32.
4904 /// 64-bits on x64. The upper 32-bits on x64 are reserved.
4908 UINT32 CF
:1; ///< Carry Flag.
4909 UINT32 Reserved_0
:1; ///< Reserved.
4910 UINT32 PF
:1; ///< Parity Flag.
4911 UINT32 Reserved_1
:1; ///< Reserved.
4912 UINT32 AF
:1; ///< Auxiliary Carry Flag.
4913 UINT32 Reserved_2
:1; ///< Reserved.
4914 UINT32 ZF
:1; ///< Zero Flag.
4915 UINT32 SF
:1; ///< Sign Flag.
4916 UINT32 TF
:1; ///< Trap Flag.
4917 UINT32 IF
:1; ///< Interrupt Enable Flag.
4918 UINT32 DF
:1; ///< Direction Flag.
4919 UINT32 OF
:1; ///< Overflow Flag.
4920 UINT32 IOPL
:2; ///< I/O Privilege Level.
4921 UINT32 NT
:1; ///< Nested Task.
4922 UINT32 Reserved_3
:1; ///< Reserved.
4923 UINT32 RF
:1; ///< Resume Flag.
4924 UINT32 VM
:1; ///< Virtual 8086 Mode.
4925 UINT32 AC
:1; ///< Alignment Check.
4926 UINT32 VIF
:1; ///< Virtual Interrupt Flag.
4927 UINT32 VIP
:1; ///< Virtual Interrupt Pending.
4928 UINT32 ID
:1; ///< ID Flag.
4929 UINT32 Reserved_4
:10; ///< Reserved.
4935 /// Byte packed structure for Control Register 0 (CR0).
4936 /// 32-bits on IA-32.
4937 /// 64-bits on x64. The upper 32-bits on x64 are reserved.
4941 UINT32 PE
:1; ///< Protection Enable.
4942 UINT32 MP
:1; ///< Monitor Coprocessor.
4943 UINT32 EM
:1; ///< Emulation.
4944 UINT32 TS
:1; ///< Task Switched.
4945 UINT32 ET
:1; ///< Extension Type.
4946 UINT32 NE
:1; ///< Numeric Error.
4947 UINT32 Reserved_0
:10; ///< Reserved.
4948 UINT32 WP
:1; ///< Write Protect.
4949 UINT32 Reserved_1
:1; ///< Reserved.
4950 UINT32 AM
:1; ///< Alignment Mask.
4951 UINT32 Reserved_2
:10; ///< Reserved.
4952 UINT32 NW
:1; ///< Mot Write-through.
4953 UINT32 CD
:1; ///< Cache Disable.
4954 UINT32 PG
:1; ///< Paging.
4960 /// Byte packed structure for Control Register 4 (CR4).
4961 /// 32-bits on IA-32.
4962 /// 64-bits on x64. The upper 32-bits on x64 are reserved.
4966 UINT32 VME
:1; ///< Virtual-8086 Mode Extensions.
4967 UINT32 PVI
:1; ///< Protected-Mode Virtual Interrupts.
4968 UINT32 TSD
:1; ///< Time Stamp Disable.
4969 UINT32 DE
:1; ///< Debugging Extensions.
4970 UINT32 PSE
:1; ///< Page Size Extensions.
4971 UINT32 PAE
:1; ///< Physical Address Extension.
4972 UINT32 MCE
:1; ///< Machine Check Enable.
4973 UINT32 PGE
:1; ///< Page Global Enable.
4974 UINT32 PCE
:1; ///< Performance Monitoring Counter
4976 UINT32 OSFXSR
:1; ///< Operating System Support for
4977 ///< FXSAVE and FXRSTOR instructions
4978 UINT32 OSXMMEXCPT
:1; ///< Operating System Support for
4979 ///< Unmasked SIMD Floating Point
4981 UINT32 Reserved_0
:2; ///< Reserved.
4982 UINT32 VMXE
:1; ///< VMX Enable
4983 UINT32 Reserved_1
:18; ///< Reserved.
4989 /// Byte packed structure for a segment descriptor in a GDT/LDT.
5008 } IA32_SEGMENT_DESCRIPTOR
;
5011 /// Byte packed structure for an IDTR, GDTR, LDTR descriptor.
5020 #define IA32_IDT_GATE_TYPE_TASK 0x85
5021 #define IA32_IDT_GATE_TYPE_INTERRUPT_16 0x86
5022 #define IA32_IDT_GATE_TYPE_TRAP_16 0x87
5023 #define IA32_IDT_GATE_TYPE_INTERRUPT_32 0x8E
5024 #define IA32_IDT_GATE_TYPE_TRAP_32 0x8F
5027 #if defined (MDE_CPU_IA32)
5029 /// Byte packed structure for an IA-32 Interrupt Gate Descriptor.
5033 UINT32 OffsetLow
:16; ///< Offset bits 15..0.
5034 UINT32 Selector
:16; ///< Selector.
5035 UINT32 Reserved_0
:8; ///< Reserved.
5036 UINT32 GateType
:8; ///< Gate Type. See #defines above.
5037 UINT32 OffsetHigh
:16; ///< Offset bits 31..16.
5040 } IA32_IDT_GATE_DESCRIPTOR
;
5044 #if defined (MDE_CPU_X64)
5046 /// Byte packed structure for an x64 Interrupt Gate Descriptor.
5050 UINT32 OffsetLow
:16; ///< Offset bits 15..0.
5051 UINT32 Selector
:16; ///< Selector.
5052 UINT32 Reserved_0
:8; ///< Reserved.
5053 UINT32 GateType
:8; ///< Gate Type. See #defines above.
5054 UINT32 OffsetHigh
:16; ///< Offset bits 31..16.
5055 UINT32 OffsetUpper
:32; ///< Offset bits 63..32.
5056 UINT32 Reserved_1
:32; ///< Reserved.
5062 } IA32_IDT_GATE_DESCRIPTOR
;
5067 /// Byte packed structure for an FP/SSE/SSE2 context.
5074 /// Structures for the 16-bit real mode thunks.
5127 IA32_EFLAGS32 EFLAGS
;
5137 } IA32_REGISTER_SET
;
5140 /// Byte packed structure for an 16-bit real mode thunks.
5143 IA32_REGISTER_SET
*RealModeState
;
5144 VOID
*RealModeBuffer
;
5145 UINT32 RealModeBufferSize
;
5146 UINT32 ThunkAttributes
;
5149 #define THUNK_ATTRIBUTE_BIG_REAL_MODE 0x00000001
5150 #define THUNK_ATTRIBUTE_DISABLE_A20_MASK_INT_15 0x00000002
5151 #define THUNK_ATTRIBUTE_DISABLE_A20_MASK_KBD_CTRL 0x00000004
5154 Retrieves CPUID information.
5156 Executes the CPUID instruction with EAX set to the value specified by Index.
5157 This function always returns Index.
5158 If Eax is not NULL, then the value of EAX after CPUID is returned in Eax.
5159 If Ebx is not NULL, then the value of EBX after CPUID is returned in Ebx.
5160 If Ecx is not NULL, then the value of ECX after CPUID is returned in Ecx.
5161 If Edx is not NULL, then the value of EDX after CPUID is returned in Edx.
5162 This function is only available on IA-32 and x64.
5164 @param Index The 32-bit value to load into EAX prior to invoking the CPUID
5166 @param Eax The pointer to the 32-bit EAX value returned by the CPUID
5167 instruction. This is an optional parameter that may be NULL.
5168 @param Ebx The pointer to the 32-bit EBX value returned by the CPUID
5169 instruction. This is an optional parameter that may be NULL.
5170 @param Ecx The pointer to the 32-bit ECX value returned by the CPUID
5171 instruction. This is an optional parameter that may be NULL.
5172 @param Edx The pointer to the 32-bit EDX value returned by the CPUID
5173 instruction. This is an optional parameter that may be NULL.
5182 OUT UINT32
*Eax
, OPTIONAL
5183 OUT UINT32
*Ebx
, OPTIONAL
5184 OUT UINT32
*Ecx
, OPTIONAL
5185 OUT UINT32
*Edx OPTIONAL
5190 Retrieves CPUID information using an extended leaf identifier.
5192 Executes the CPUID instruction with EAX set to the value specified by Index
5193 and ECX set to the value specified by SubIndex. This function always returns
5194 Index. This function is only available on IA-32 and x64.
5196 If Eax is not NULL, then the value of EAX after CPUID is returned in Eax.
5197 If Ebx is not NULL, then the value of EBX after CPUID is returned in Ebx.
5198 If Ecx is not NULL, then the value of ECX after CPUID is returned in Ecx.
5199 If Edx is not NULL, then the value of EDX after CPUID is returned in Edx.
5201 @param Index The 32-bit value to load into EAX prior to invoking the
5203 @param SubIndex The 32-bit value to load into ECX prior to invoking the
5205 @param Eax The pointer to the 32-bit EAX value returned by the CPUID
5206 instruction. This is an optional parameter that may be
5208 @param Ebx The pointer to the 32-bit EBX value returned by the CPUID
5209 instruction. This is an optional parameter that may be
5211 @param Ecx The pointer to the 32-bit ECX value returned by the CPUID
5212 instruction. This is an optional parameter that may be
5214 @param Edx The pointer to the 32-bit EDX value returned by the CPUID
5215 instruction. This is an optional parameter that may be
5226 OUT UINT32
*Eax
, OPTIONAL
5227 OUT UINT32
*Ebx
, OPTIONAL
5228 OUT UINT32
*Ecx
, OPTIONAL
5229 OUT UINT32
*Edx OPTIONAL
5234 Set CD bit and clear NW bit of CR0 followed by a WBINVD.
5236 Disables the caches by setting the CD bit of CR0 to 1, clearing the NW bit of CR0 to 0,
5237 and executing a WBINVD instruction. This function is only available on IA-32 and x64.
5248 Perform a WBINVD and clear both the CD and NW bits of CR0.
5250 Enables the caches by executing a WBINVD instruction and then clear both the CD and NW
5251 bits of CR0 to 0. This function is only available on IA-32 and x64.
5262 Returns the lower 32-bits of a Machine Specific Register(MSR).
5264 Reads and returns the lower 32-bits of the MSR specified by Index.
5265 No parameter checking is performed on Index, and some Index values may cause
5266 CPU exceptions. The caller must either guarantee that Index is valid, or the
5267 caller must set up exception handlers to catch the exceptions. This function
5268 is only available on IA-32 and x64.
5270 @param Index The 32-bit MSR index to read.
5272 @return The lower 32 bits of the MSR identified by Index.
5283 Writes a 32-bit value to a Machine Specific Register(MSR), and returns the value.
5284 The upper 32-bits of the MSR are set to zero.
5286 Writes the 32-bit value specified by Value to the MSR specified by Index. The
5287 upper 32-bits of the MSR write are set to zero. The 32-bit value written to
5288 the MSR is returned. No parameter checking is performed on Index or Value,
5289 and some of these may cause CPU exceptions. The caller must either guarantee
5290 that Index and Value are valid, or the caller must establish proper exception
5291 handlers. This function is only available on IA-32 and x64.
5293 @param Index The 32-bit MSR index to write.
5294 @param Value The 32-bit value to write to the MSR.
5308 Reads a 64-bit MSR, performs a bitwise OR on the lower 32-bits, and
5309 writes the result back to the 64-bit MSR.
5311 Reads the 64-bit MSR specified by Index, performs a bitwise OR
5312 between the lower 32-bits of the read result and the value specified by
5313 OrData, and writes the result to the 64-bit MSR specified by Index. The lower
5314 32-bits of the value written to the MSR is returned. No parameter checking is
5315 performed on Index or OrData, and some of these may cause CPU exceptions. The
5316 caller must either guarantee that Index and OrData are valid, or the caller
5317 must establish proper exception handlers. This function is only available on
5320 @param Index The 32-bit MSR index to write.
5321 @param OrData The value to OR with the read value from the MSR.
5323 @return The lower 32-bit value written to the MSR.
5335 Reads a 64-bit MSR, performs a bitwise AND on the lower 32-bits, and writes
5336 the result back to the 64-bit MSR.
5338 Reads the 64-bit MSR specified by Index, performs a bitwise AND between the
5339 lower 32-bits of the read result and the value specified by AndData, and
5340 writes the result to the 64-bit MSR specified by Index. The lower 32-bits of
5341 the value written to the MSR is returned. No parameter checking is performed
5342 on Index or AndData, and some of these may cause CPU exceptions. The caller
5343 must either guarantee that Index and AndData are valid, or the caller must
5344 establish proper exception handlers. This function is only available on IA-32
5347 @param Index The 32-bit MSR index to write.
5348 @param AndData The value to AND with the read value from the MSR.
5350 @return The lower 32-bit value written to the MSR.
5362 Reads a 64-bit MSR, performs a bitwise AND followed by a bitwise OR
5363 on the lower 32-bits, and writes the result back to the 64-bit MSR.
5365 Reads the 64-bit MSR specified by Index, performs a bitwise AND between the
5366 lower 32-bits of the read result and the value specified by AndData
5367 preserving the upper 32-bits, performs a bitwise OR between the
5368 result of the AND operation and the value specified by OrData, and writes the
5369 result to the 64-bit MSR specified by Address. The lower 32-bits of the value
5370 written to the MSR is returned. No parameter checking is performed on Index,
5371 AndData, or OrData, and some of these may cause CPU exceptions. The caller
5372 must either guarantee that Index, AndData, and OrData are valid, or the
5373 caller must establish proper exception handlers. This function is only
5374 available on IA-32 and x64.
5376 @param Index The 32-bit MSR index to write.
5377 @param AndData The value to AND with the read value from the MSR.
5378 @param OrData The value to OR with the result of the AND operation.
5380 @return The lower 32-bit value written to the MSR.
5393 Reads a bit field of an MSR.
5395 Reads the bit field in the lower 32-bits of a 64-bit MSR. The bit field is
5396 specified by the StartBit and the EndBit. The value of the bit field is
5397 returned. The caller must either guarantee that Index is valid, or the caller
5398 must set up exception handlers to catch the exceptions. This function is only
5399 available on IA-32 and x64.
5401 If StartBit is greater than 31, then ASSERT().
5402 If EndBit is greater than 31, then ASSERT().
5403 If EndBit is less than StartBit, then ASSERT().
5405 @param Index The 32-bit MSR index to read.
5406 @param StartBit The ordinal of the least significant bit in the bit field.
5408 @param EndBit The ordinal of the most significant bit in the bit field.
5411 @return The bit field read from the MSR.
5416 AsmMsrBitFieldRead32 (
5424 Writes a bit field to an MSR.
5426 Writes Value to a bit field in the lower 32-bits of a 64-bit MSR. The bit
5427 field is specified by the StartBit and the EndBit. All other bits in the
5428 destination MSR are preserved. The lower 32-bits of the MSR written is
5429 returned. The caller must either guarantee that Index and the data written
5430 is valid, or the caller must set up exception handlers to catch the exceptions.
5431 This function is only available on IA-32 and x64.
5433 If StartBit is greater than 31, then ASSERT().
5434 If EndBit is greater than 31, then ASSERT().
5435 If EndBit is less than StartBit, then ASSERT().
5436 If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
5438 @param Index The 32-bit MSR index to write.
5439 @param StartBit The ordinal of the least significant bit in the bit field.
5441 @param EndBit The ordinal of the most significant bit in the bit field.
5443 @param Value New value of the bit field.
5445 @return The lower 32-bit of the value written to the MSR.
5450 AsmMsrBitFieldWrite32 (
5459 Reads a bit field in a 64-bit MSR, performs a bitwise OR, and writes the
5460 result back to the bit field in the 64-bit MSR.
5462 Reads the 64-bit MSR specified by Index, performs a bitwise OR
5463 between the read result and the value specified by OrData, and writes the
5464 result to the 64-bit MSR specified by Index. The lower 32-bits of the value
5465 written to the MSR are returned. Extra left bits in OrData are stripped. The
5466 caller must either guarantee that Index and the data written is valid, or
5467 the caller must set up exception handlers to catch the exceptions. This
5468 function is only available on IA-32 and x64.
5470 If StartBit is greater than 31, then ASSERT().
5471 If EndBit is greater than 31, then ASSERT().
5472 If EndBit is less than StartBit, then ASSERT().
5473 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
5475 @param Index The 32-bit MSR index to write.
5476 @param StartBit The ordinal of the least significant bit in the bit field.
5478 @param EndBit The ordinal of the most significant bit in the bit field.
5480 @param OrData The value to OR with the read value from the MSR.
5482 @return The lower 32-bit of the value written to the MSR.
5487 AsmMsrBitFieldOr32 (
5496 Reads a bit field in a 64-bit MSR, performs a bitwise AND, and writes the
5497 result back to the bit field in the 64-bit MSR.
5499 Reads the 64-bit MSR specified by Index, performs a bitwise AND between the
5500 read result and the value specified by AndData, and writes the result to the
5501 64-bit MSR specified by Index. The lower 32-bits of the value written to the
5502 MSR are returned. Extra left bits in AndData are stripped. The caller must
5503 either guarantee that Index and the data written is valid, or the caller must
5504 set up exception handlers to catch the exceptions. This function is only
5505 available on IA-32 and x64.
5507 If StartBit is greater than 31, then ASSERT().
5508 If EndBit is greater than 31, then ASSERT().
5509 If EndBit is less than StartBit, then ASSERT().
5510 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
5512 @param Index The 32-bit MSR index to write.
5513 @param StartBit The ordinal of the least significant bit in the bit field.
5515 @param EndBit The ordinal of the most significant bit in the bit field.
5517 @param AndData The value to AND with the read value from the MSR.
5519 @return The lower 32-bit of the value written to the MSR.
5524 AsmMsrBitFieldAnd32 (
5533 Reads a bit field in a 64-bit MSR, performs a bitwise AND followed by a
5534 bitwise OR, and writes the result back to the bit field in the
5537 Reads the 64-bit MSR specified by Index, performs a bitwise AND followed by a
5538 bitwise OR between the read result and the value specified by
5539 AndData, and writes the result to the 64-bit MSR specified by Index. The
5540 lower 32-bits of the value written to the MSR are returned. Extra left bits
5541 in both AndData and OrData are stripped. The caller must either guarantee
5542 that Index and the data written is valid, or the caller must set up exception
5543 handlers to catch the exceptions. This function is only available on IA-32
5546 If StartBit is greater than 31, then ASSERT().
5547 If EndBit is greater than 31, then ASSERT().
5548 If EndBit is less than StartBit, then ASSERT().
5549 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
5550 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
5552 @param Index The 32-bit MSR index to write.
5553 @param StartBit The ordinal of the least significant bit in the bit field.
5555 @param EndBit The ordinal of the most significant bit in the bit field.
5557 @param AndData The value to AND with the read value from the MSR.
5558 @param OrData The value to OR with the result of the AND operation.
5560 @return The lower 32-bit of the value written to the MSR.
5565 AsmMsrBitFieldAndThenOr32 (
5575 Returns a 64-bit Machine Specific Register(MSR).
5577 Reads and returns the 64-bit MSR specified by Index. No parameter checking is
5578 performed on Index, and some Index values may cause CPU exceptions. The
5579 caller must either guarantee that Index is valid, or the caller must set up
5580 exception handlers to catch the exceptions. This function is only available
5583 @param Index The 32-bit MSR index to read.
5585 @return The value of the MSR identified by Index.
5596 Writes a 64-bit value to a Machine Specific Register(MSR), and returns the
5599 Writes the 64-bit value specified by Value to the MSR specified by Index. The
5600 64-bit value written to the MSR is returned. No parameter checking is
5601 performed on Index or Value, and some of these may cause CPU exceptions. The
5602 caller must either guarantee that Index and Value are valid, or the caller
5603 must establish proper exception handlers. This function is only available on
5606 @param Index The 32-bit MSR index to write.
5607 @param Value The 64-bit value to write to the MSR.
5621 Reads a 64-bit MSR, performs a bitwise OR, and writes the result
5622 back to the 64-bit MSR.
5624 Reads the 64-bit MSR specified by Index, performs a bitwise OR
5625 between the read result and the value specified by OrData, and writes the
5626 result to the 64-bit MSR specified by Index. The value written to the MSR is
5627 returned. No parameter checking is performed on Index or OrData, and some of
5628 these may cause CPU exceptions. The caller must either guarantee that Index
5629 and OrData are valid, or the caller must establish proper exception handlers.
5630 This function is only available on IA-32 and x64.
5632 @param Index The 32-bit MSR index to write.
5633 @param OrData The value to OR with the read value from the MSR.
5635 @return The value written back to the MSR.
5647 Reads a 64-bit MSR, performs a bitwise AND, and writes the result back to the
5650 Reads the 64-bit MSR specified by Index, performs a bitwise AND between the
5651 read result and the value specified by OrData, and writes the result to the
5652 64-bit MSR specified by Index. The value written to the MSR is returned. No
5653 parameter checking is performed on Index or OrData, and some of these may
5654 cause CPU exceptions. The caller must either guarantee that Index and OrData
5655 are valid, or the caller must establish proper exception handlers. This
5656 function is only available on IA-32 and x64.
5658 @param Index The 32-bit MSR index to write.
5659 @param AndData The value to AND with the read value from the MSR.
5661 @return The value written back to the MSR.
5673 Reads a 64-bit MSR, performs a bitwise AND followed by a bitwise
5674 OR, and writes the result back to the 64-bit MSR.
5676 Reads the 64-bit MSR specified by Index, performs a bitwise AND between read
5677 result and the value specified by AndData, performs a bitwise OR
5678 between the result of the AND operation and the value specified by OrData,
5679 and writes the result to the 64-bit MSR specified by Index. The value written
5680 to the MSR is returned. No parameter checking is performed on Index, AndData,
5681 or OrData, and some of these may cause CPU exceptions. The caller must either
5682 guarantee that Index, AndData, and OrData are valid, or the caller must
5683 establish proper exception handlers. This function is only available on IA-32
5686 @param Index The 32-bit MSR index to write.
5687 @param AndData The value to AND with the read value from the MSR.
5688 @param OrData The value to OR with the result of the AND operation.
5690 @return The value written back to the MSR.
5703 Reads a bit field of an MSR.
5705 Reads the bit field in the 64-bit MSR. The bit field is specified by the
5706 StartBit and the EndBit. The value of the bit field is returned. The caller
5707 must either guarantee that Index is valid, or the caller must set up
5708 exception handlers to catch the exceptions. This function is only available
5711 If StartBit is greater than 63, then ASSERT().
5712 If EndBit is greater than 63, then ASSERT().
5713 If EndBit is less than StartBit, then ASSERT().
5715 @param Index The 32-bit MSR index to read.
5716 @param StartBit The ordinal of the least significant bit in the bit field.
5718 @param EndBit The ordinal of the most significant bit in the bit field.
5721 @return The value read from the MSR.
5726 AsmMsrBitFieldRead64 (
5734 Writes a bit field to an MSR.
5736 Writes Value to a bit field in a 64-bit MSR. The bit field is specified by
5737 the StartBit and the EndBit. All other bits in the destination MSR are
5738 preserved. The MSR written is returned. The caller must either guarantee
5739 that Index and the data written is valid, or the caller must set up exception
5740 handlers to catch the exceptions. This function is only available on IA-32 and x64.
5742 If StartBit is greater than 63, then ASSERT().
5743 If EndBit is greater than 63, then ASSERT().
5744 If EndBit is less than StartBit, then ASSERT().
5745 If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
5747 @param Index The 32-bit MSR index to write.
5748 @param StartBit The ordinal of the least significant bit in the bit field.
5750 @param EndBit The ordinal of the most significant bit in the bit field.
5752 @param Value New value of the bit field.
5754 @return The value written back to the MSR.
5759 AsmMsrBitFieldWrite64 (
5768 Reads a bit field in a 64-bit MSR, performs a bitwise OR, and
5769 writes the result back to the bit field in the 64-bit MSR.
5771 Reads the 64-bit MSR specified by Index, performs a bitwise OR
5772 between the read result and the value specified by OrData, and writes the
5773 result to the 64-bit MSR specified by Index. The value written to the MSR is
5774 returned. Extra left bits in OrData are stripped. The caller must either
5775 guarantee that Index and the data written is valid, or the caller must set up
5776 exception handlers to catch the exceptions. This function is only available
5779 If StartBit is greater than 63, then ASSERT().
5780 If EndBit is greater than 63, then ASSERT().
5781 If EndBit is less than StartBit, then ASSERT().
5782 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
5784 @param Index The 32-bit MSR index to write.
5785 @param StartBit The ordinal of the least significant bit in the bit field.
5787 @param EndBit The ordinal of the most significant bit in the bit field.
5789 @param OrData The value to OR with the read value from the bit field.
5791 @return The value written back to the MSR.
5796 AsmMsrBitFieldOr64 (
5805 Reads a bit field in a 64-bit MSR, performs a bitwise AND, and writes the
5806 result back to the bit field in the 64-bit MSR.
5808 Reads the 64-bit MSR specified by Index, performs a bitwise AND between the
5809 read result and the value specified by AndData, and writes the result to the
5810 64-bit MSR specified by Index. The value written to the MSR is returned.
5811 Extra left bits in AndData are stripped. The caller must either guarantee
5812 that Index and the data written is valid, or the caller must set up exception
5813 handlers to catch the exceptions. This function is only available on IA-32
5816 If StartBit is greater than 63, then ASSERT().
5817 If EndBit is greater than 63, then ASSERT().
5818 If EndBit is less than StartBit, then ASSERT().
5819 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
5821 @param Index The 32-bit MSR index to write.
5822 @param StartBit The ordinal of the least significant bit in the bit field.
5824 @param EndBit The ordinal of the most significant bit in the bit field.
5826 @param AndData The value to AND with the read value from the bit field.
5828 @return The value written back to the MSR.
5833 AsmMsrBitFieldAnd64 (
5842 Reads a bit field in a 64-bit MSR, performs a bitwise AND followed by a
5843 bitwise OR, and writes the result back to the bit field in the
5846 Reads the 64-bit MSR specified by Index, performs a bitwise AND followed by
5847 a bitwise OR between the read result and the value specified by
5848 AndData, and writes the result to the 64-bit MSR specified by Index. The
5849 value written to the MSR is returned. Extra left bits in both AndData and
5850 OrData are stripped. The caller must either guarantee that Index and the data
5851 written is valid, or the caller must set up exception handlers to catch the
5852 exceptions. This function is only available on IA-32 and x64.
5854 If StartBit is greater than 63, then ASSERT().
5855 If EndBit is greater than 63, then ASSERT().
5856 If EndBit is less than StartBit, then ASSERT().
5857 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
5858 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
5860 @param Index The 32-bit MSR index to write.
5861 @param StartBit The ordinal of the least significant bit in the bit field.
5863 @param EndBit The ordinal of the most significant bit in the bit field.
5865 @param AndData The value to AND with the read value from the bit field.
5866 @param OrData The value to OR with the result of the AND operation.
5868 @return The value written back to the MSR.
5873 AsmMsrBitFieldAndThenOr64 (
5883 Reads the current value of the EFLAGS register.
5885 Reads and returns the current value of the EFLAGS register. This function is
5886 only available on IA-32 and x64. This returns a 32-bit value on IA-32 and a
5887 64-bit value on x64.
5889 @return EFLAGS on IA-32 or RFLAGS on x64.
5900 Reads the current value of the Control Register 0 (CR0).
5902 Reads and returns the current value of CR0. This function is only available
5903 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
5906 @return The value of the Control Register 0 (CR0).
5917 Reads the current value of the Control Register 2 (CR2).
5919 Reads and returns the current value of CR2. This function is only available
5920 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
5923 @return The value of the Control Register 2 (CR2).
5934 Reads the current value of the Control Register 3 (CR3).
5936 Reads and returns the current value of CR3. This function is only available
5937 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
5940 @return The value of the Control Register 3 (CR3).
5951 Reads the current value of the Control Register 4 (CR4).
5953 Reads and returns the current value of CR4. This function is only available
5954 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
5957 @return The value of the Control Register 4 (CR4).
5968 Writes a value to Control Register 0 (CR0).
5970 Writes and returns a new value to CR0. This function is only available on
5971 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
5973 @param Cr0 The value to write to CR0.
5975 @return The value written to CR0.
5986 Writes a value to Control Register 2 (CR2).
5988 Writes and returns a new value to CR2. This function is only available on
5989 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
5991 @param Cr2 The value to write to CR2.
5993 @return The value written to CR2.
6004 Writes a value to Control Register 3 (CR3).
6006 Writes and returns a new value to CR3. This function is only available on
6007 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
6009 @param Cr3 The value to write to CR3.
6011 @return The value written to CR3.
6022 Writes a value to Control Register 4 (CR4).
6024 Writes and returns a new value to CR4. This function is only available on
6025 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
6027 @param Cr4 The value to write to CR4.
6029 @return The value written to CR4.
6040 Reads the current value of Debug Register 0 (DR0).
6042 Reads and returns the current value of DR0. This function is only available
6043 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
6046 @return The value of Debug Register 0 (DR0).
6057 Reads the current value of Debug Register 1 (DR1).
6059 Reads and returns the current value of DR1. This function is only available
6060 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
6063 @return The value of Debug Register 1 (DR1).
6074 Reads the current value of Debug Register 2 (DR2).
6076 Reads and returns the current value of DR2. This function is only available
6077 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
6080 @return The value of Debug Register 2 (DR2).
6091 Reads the current value of Debug Register 3 (DR3).
6093 Reads and returns the current value of DR3. This function is only available
6094 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
6097 @return The value of Debug Register 3 (DR3).
6108 Reads the current value of Debug Register 4 (DR4).
6110 Reads and returns the current value of DR4. This function is only available
6111 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
6114 @return The value of Debug Register 4 (DR4).
6125 Reads the current value of Debug Register 5 (DR5).
6127 Reads and returns the current value of DR5. This function is only available
6128 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
6131 @return The value of Debug Register 5 (DR5).
6142 Reads the current value of Debug Register 6 (DR6).
6144 Reads and returns the current value of DR6. This function is only available
6145 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
6148 @return The value of Debug Register 6 (DR6).
6159 Reads the current value of Debug Register 7 (DR7).
6161 Reads and returns the current value of DR7. This function is only available
6162 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
6165 @return The value of Debug Register 7 (DR7).
6176 Writes a value to Debug Register 0 (DR0).
6178 Writes and returns a new value to DR0. This function is only available on
6179 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
6181 @param Dr0 The value to write to Dr0.
6183 @return The value written to Debug Register 0 (DR0).
6194 Writes a value to Debug Register 1 (DR1).
6196 Writes and returns a new value to DR1. This function is only available on
6197 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
6199 @param Dr1 The value to write to Dr1.
6201 @return The value written to Debug Register 1 (DR1).
6212 Writes a value to Debug Register 2 (DR2).
6214 Writes and returns a new value to DR2. This function is only available on
6215 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
6217 @param Dr2 The value to write to Dr2.
6219 @return The value written to Debug Register 2 (DR2).
6230 Writes a value to Debug Register 3 (DR3).
6232 Writes and returns a new value to DR3. This function is only available on
6233 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
6235 @param Dr3 The value to write to Dr3.
6237 @return The value written to Debug Register 3 (DR3).
6248 Writes a value to Debug Register 4 (DR4).
6250 Writes and returns a new value to DR4. This function is only available on
6251 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
6253 @param Dr4 The value to write to Dr4.
6255 @return The value written to Debug Register 4 (DR4).
6266 Writes a value to Debug Register 5 (DR5).
6268 Writes and returns a new value to DR5. This function is only available on
6269 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
6271 @param Dr5 The value to write to Dr5.
6273 @return The value written to Debug Register 5 (DR5).
6284 Writes a value to Debug Register 6 (DR6).
6286 Writes and returns a new value to DR6. This function is only available on
6287 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
6289 @param Dr6 The value to write to Dr6.
6291 @return The value written to Debug Register 6 (DR6).
6302 Writes a value to Debug Register 7 (DR7).
6304 Writes and returns a new value to DR7. This function is only available on
6305 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
6307 @param Dr7 The value to write to Dr7.
6309 @return The value written to Debug Register 7 (DR7).
6320 Reads the current value of Code Segment Register (CS).
6322 Reads and returns the current value of CS. This function is only available on
6325 @return The current value of CS.
6336 Reads the current value of Data Segment Register (DS).
6338 Reads and returns the current value of DS. This function is only available on
6341 @return The current value of DS.
6352 Reads the current value of Extra Segment Register (ES).
6354 Reads and returns the current value of ES. This function is only available on
6357 @return The current value of ES.
6368 Reads the current value of FS Data Segment Register (FS).
6370 Reads and returns the current value of FS. This function is only available on
6373 @return The current value of FS.
6384 Reads the current value of GS Data Segment Register (GS).
6386 Reads and returns the current value of GS. This function is only available on
6389 @return The current value of GS.
6400 Reads the current value of Stack Segment Register (SS).
6402 Reads and returns the current value of SS. This function is only available on
6405 @return The current value of SS.
6416 Reads the current value of Task Register (TR).
6418 Reads and returns the current value of TR. This function is only available on
6421 @return The current value of TR.
6432 Reads the current Global Descriptor Table Register(GDTR) descriptor.
6434 Reads and returns the current GDTR descriptor and returns it in Gdtr. This
6435 function is only available on IA-32 and x64.
6437 If Gdtr is NULL, then ASSERT().
6439 @param Gdtr The pointer to a GDTR descriptor.
6445 OUT IA32_DESCRIPTOR
*Gdtr
6450 Writes the current Global Descriptor Table Register (GDTR) descriptor.
6452 Writes and the current GDTR descriptor specified by Gdtr. This function is
6453 only available on IA-32 and x64.
6455 If Gdtr is NULL, then ASSERT().
6457 @param Gdtr The pointer to a GDTR descriptor.
6463 IN CONST IA32_DESCRIPTOR
*Gdtr
6468 Reads the current Interrupt Descriptor Table Register(IDTR) descriptor.
6470 Reads and returns the current IDTR descriptor and returns it in Idtr. This
6471 function is only available on IA-32 and x64.
6473 If Idtr is NULL, then ASSERT().
6475 @param Idtr The pointer to a IDTR descriptor.
6481 OUT IA32_DESCRIPTOR
*Idtr
6486 Writes the current Interrupt Descriptor Table Register(IDTR) descriptor.
6488 Writes the current IDTR descriptor and returns it in Idtr. This function is
6489 only available on IA-32 and x64.
6491 If Idtr is NULL, then ASSERT().
6493 @param Idtr The pointer to a IDTR descriptor.
6499 IN CONST IA32_DESCRIPTOR
*Idtr
6504 Reads the current Local Descriptor Table Register(LDTR) selector.
6506 Reads and returns the current 16-bit LDTR descriptor value. This function is
6507 only available on IA-32 and x64.
6509 @return The current selector of LDT.
6520 Writes the current Local Descriptor Table Register (LDTR) selector.
6522 Writes and the current LDTR descriptor specified by Ldtr. This function is
6523 only available on IA-32 and x64.
6525 @param Ldtr 16-bit LDTR selector value.
6536 Save the current floating point/SSE/SSE2 context to a buffer.
6538 Saves the current floating point/SSE/SSE2 state to the buffer specified by
6539 Buffer. Buffer must be aligned on a 16-byte boundary. This function is only
6540 available on IA-32 and x64.
6542 If Buffer is NULL, then ASSERT().
6543 If Buffer is not aligned on a 16-byte boundary, then ASSERT().
6545 @param Buffer The pointer to a buffer to save the floating point/SSE/SSE2 context.
6551 OUT IA32_FX_BUFFER
*Buffer
6556 Restores the current floating point/SSE/SSE2 context from a buffer.
6558 Restores the current floating point/SSE/SSE2 state from the buffer specified
6559 by Buffer. Buffer must be aligned on a 16-byte boundary. This function is
6560 only available on IA-32 and x64.
6562 If Buffer is NULL, then ASSERT().
6563 If Buffer is not aligned on a 16-byte boundary, then ASSERT().
6564 If Buffer was not saved with AsmFxSave(), then ASSERT().
6566 @param Buffer The pointer to a buffer to save the floating point/SSE/SSE2 context.
6572 IN CONST IA32_FX_BUFFER
*Buffer
6577 Reads the current value of 64-bit MMX Register #0 (MM0).
6579 Reads and returns the current value of MM0. This function is only available
6582 @return The current value of MM0.
6593 Reads the current value of 64-bit MMX Register #1 (MM1).
6595 Reads and returns the current value of MM1. This function is only available
6598 @return The current value of MM1.
6609 Reads the current value of 64-bit MMX Register #2 (MM2).
6611 Reads and returns the current value of MM2. This function is only available
6614 @return The current value of MM2.
6625 Reads the current value of 64-bit MMX Register #3 (MM3).
6627 Reads and returns the current value of MM3. This function is only available
6630 @return The current value of MM3.
6641 Reads the current value of 64-bit MMX Register #4 (MM4).
6643 Reads and returns the current value of MM4. This function is only available
6646 @return The current value of MM4.
6657 Reads the current value of 64-bit MMX Register #5 (MM5).
6659 Reads and returns the current value of MM5. This function is only available
6662 @return The current value of MM5.
6673 Reads the current value of 64-bit MMX Register #6 (MM6).
6675 Reads and returns the current value of MM6. This function is only available
6678 @return The current value of MM6.
6689 Reads the current value of 64-bit MMX Register #7 (MM7).
6691 Reads and returns the current value of MM7. This function is only available
6694 @return The current value of MM7.
6705 Writes the current value of 64-bit MMX Register #0 (MM0).
6707 Writes the current value of MM0. This function is only available on IA32 and
6710 @param Value The 64-bit value to write to MM0.
6721 Writes the current value of 64-bit MMX Register #1 (MM1).
6723 Writes the current value of MM1. This function is only available on IA32 and
6726 @param Value The 64-bit value to write to MM1.
6737 Writes the current value of 64-bit MMX Register #2 (MM2).
6739 Writes the current value of MM2. This function is only available on IA32 and
6742 @param Value The 64-bit value to write to MM2.
6753 Writes the current value of 64-bit MMX Register #3 (MM3).
6755 Writes the current value of MM3. This function is only available on IA32 and
6758 @param Value The 64-bit value to write to MM3.
6769 Writes the current value of 64-bit MMX Register #4 (MM4).
6771 Writes the current value of MM4. This function is only available on IA32 and
6774 @param Value The 64-bit value to write to MM4.
6785 Writes the current value of 64-bit MMX Register #5 (MM5).
6787 Writes the current value of MM5. This function is only available on IA32 and
6790 @param Value The 64-bit value to write to MM5.
6801 Writes the current value of 64-bit MMX Register #6 (MM6).
6803 Writes the current value of MM6. This function is only available on IA32 and
6806 @param Value The 64-bit value to write to MM6.
6817 Writes the current value of 64-bit MMX Register #7 (MM7).
6819 Writes the current value of MM7. This function is only available on IA32 and
6822 @param Value The 64-bit value to write to MM7.
6833 Reads the current value of Time Stamp Counter (TSC).
6835 Reads and returns the current value of TSC. This function is only available
6838 @return The current value of TSC
6849 Reads the current value of a Performance Counter (PMC).
6851 Reads and returns the current value of performance counter specified by
6852 Index. This function is only available on IA-32 and x64.
6854 @param Index The 32-bit Performance Counter index to read.
6856 @return The value of the PMC specified by Index.
6867 Sets up a monitor buffer that is used by AsmMwait().
6869 Executes a MONITOR instruction with the register state specified by Eax, Ecx
6870 and Edx. Returns Eax. This function is only available on IA-32 and x64.
6872 @param Eax The value to load into EAX or RAX before executing the MONITOR
6874 @param Ecx The value to load into ECX or RCX before executing the MONITOR
6876 @param Edx The value to load into EDX or RDX before executing the MONITOR
6892 Executes an MWAIT instruction.
6894 Executes an MWAIT instruction with the register state specified by Eax and
6895 Ecx. Returns Eax. This function is only available on IA-32 and x64.
6897 @param Eax The value to load into EAX or RAX before executing the MONITOR
6899 @param Ecx The value to load into ECX or RCX before executing the MONITOR
6914 Executes a WBINVD instruction.
6916 Executes a WBINVD instruction. This function is only available on IA-32 and
6928 Executes a INVD instruction.
6930 Executes a INVD instruction. This function is only available on IA-32 and
6942 Flushes a cache line from all the instruction and data caches within the
6943 coherency domain of the CPU.
6945 Flushed the cache line specified by LinearAddress, and returns LinearAddress.
6946 This function is only available on IA-32 and x64.
6948 @param LinearAddress The address of the cache line to flush. If the CPU is
6949 in a physical addressing mode, then LinearAddress is a
6950 physical address. If the CPU is in a virtual
6951 addressing mode, then LinearAddress is a virtual
6954 @return LinearAddress.
6959 IN VOID
*LinearAddress
6964 Enables the 32-bit paging mode on the CPU.
6966 Enables the 32-bit paging mode on the CPU. CR0, CR3, CR4, and the page tables
6967 must be properly initialized prior to calling this service. This function
6968 assumes the current execution mode is 32-bit protected mode. This function is
6969 only available on IA-32. After the 32-bit paging mode is enabled, control is
6970 transferred to the function specified by EntryPoint using the new stack
6971 specified by NewStack and passing in the parameters specified by Context1 and
6972 Context2. Context1 and Context2 are optional and may be NULL. The function
6973 EntryPoint must never return.
6975 If the current execution mode is not 32-bit protected mode, then ASSERT().
6976 If EntryPoint is NULL, then ASSERT().
6977 If NewStack is NULL, then ASSERT().
6979 There are a number of constraints that must be followed before calling this
6981 1) Interrupts must be disabled.
6982 2) The caller must be in 32-bit protected mode with flat descriptors. This
6983 means all descriptors must have a base of 0 and a limit of 4GB.
6984 3) CR0 and CR4 must be compatible with 32-bit protected mode with flat
6986 4) CR3 must point to valid page tables that will be used once the transition
6987 is complete, and those page tables must guarantee that the pages for this
6988 function and the stack are identity mapped.
6990 @param EntryPoint A pointer to function to call with the new stack after
6992 @param Context1 A pointer to the context to pass into the EntryPoint
6993 function as the first parameter after paging is enabled.
6994 @param Context2 A pointer to the context to pass into the EntryPoint
6995 function as the second parameter after paging is enabled.
6996 @param NewStack A pointer to the new stack to use for the EntryPoint
6997 function after paging is enabled.
7003 IN SWITCH_STACK_ENTRY_POINT EntryPoint
,
7004 IN VOID
*Context1
, OPTIONAL
7005 IN VOID
*Context2
, OPTIONAL
7011 Disables the 32-bit paging mode on the CPU.
7013 Disables the 32-bit paging mode on the CPU and returns to 32-bit protected
7014 mode. This function assumes the current execution mode is 32-paged protected
7015 mode. This function is only available on IA-32. After the 32-bit paging mode
7016 is disabled, control is transferred to the function specified by EntryPoint
7017 using the new stack specified by NewStack and passing in the parameters
7018 specified by Context1 and Context2. Context1 and Context2 are optional and
7019 may be NULL. The function EntryPoint must never return.
7021 If the current execution mode is not 32-bit paged mode, then ASSERT().
7022 If EntryPoint is NULL, then ASSERT().
7023 If NewStack is NULL, then ASSERT().
7025 There are a number of constraints that must be followed before calling this
7027 1) Interrupts must be disabled.
7028 2) The caller must be in 32-bit paged mode.
7029 3) CR0, CR3, and CR4 must be compatible with 32-bit paged mode.
7030 4) CR3 must point to valid page tables that guarantee that the pages for
7031 this function and the stack are identity mapped.
7033 @param EntryPoint A pointer to function to call with the new stack after
7035 @param Context1 A pointer to the context to pass into the EntryPoint
7036 function as the first parameter after paging is disabled.
7037 @param Context2 A pointer to the context to pass into the EntryPoint
7038 function as the second parameter after paging is
7040 @param NewStack A pointer to the new stack to use for the EntryPoint
7041 function after paging is disabled.
7046 AsmDisablePaging32 (
7047 IN SWITCH_STACK_ENTRY_POINT EntryPoint
,
7048 IN VOID
*Context1
, OPTIONAL
7049 IN VOID
*Context2
, OPTIONAL
7055 Enables the 64-bit paging mode on the CPU.
7057 Enables the 64-bit paging mode on the CPU. CR0, CR3, CR4, and the page tables
7058 must be properly initialized prior to calling this service. This function
7059 assumes the current execution mode is 32-bit protected mode with flat
7060 descriptors. This function is only available on IA-32. After the 64-bit
7061 paging mode is enabled, control is transferred to the function specified by
7062 EntryPoint using the new stack specified by NewStack and passing in the
7063 parameters specified by Context1 and Context2. Context1 and Context2 are
7064 optional and may be 0. The function EntryPoint must never return.
7066 If the current execution mode is not 32-bit protected mode with flat
7067 descriptors, then ASSERT().
7068 If EntryPoint is 0, then ASSERT().
7069 If NewStack is 0, then ASSERT().
7071 @param Cs The 16-bit selector to load in the CS before EntryPoint
7072 is called. The descriptor in the GDT that this selector
7073 references must be setup for long mode.
7074 @param EntryPoint The 64-bit virtual address of the function to call with
7075 the new stack after paging is enabled.
7076 @param Context1 The 64-bit virtual address of the context to pass into
7077 the EntryPoint function as the first parameter after
7079 @param Context2 The 64-bit virtual address of the context to pass into
7080 the EntryPoint function as the second parameter after
7082 @param NewStack The 64-bit virtual address of the new stack to use for
7083 the EntryPoint function after paging is enabled.
7090 IN UINT64 EntryPoint
,
7091 IN UINT64 Context1
, OPTIONAL
7092 IN UINT64 Context2
, OPTIONAL
7098 Disables the 64-bit paging mode on the CPU.
7100 Disables the 64-bit paging mode on the CPU and returns to 32-bit protected
7101 mode. This function assumes the current execution mode is 64-paging mode.
7102 This function is only available on x64. After the 64-bit paging mode is
7103 disabled, control is transferred to the function specified by EntryPoint
7104 using the new stack specified by NewStack and passing in the parameters
7105 specified by Context1 and Context2. Context1 and Context2 are optional and
7106 may be 0. The function EntryPoint must never return.
7108 If the current execution mode is not 64-bit paged mode, then ASSERT().
7109 If EntryPoint is 0, then ASSERT().
7110 If NewStack is 0, then ASSERT().
7112 @param Cs The 16-bit selector to load in the CS before EntryPoint
7113 is called. The descriptor in the GDT that this selector
7114 references must be setup for 32-bit protected mode.
7115 @param EntryPoint The 64-bit virtual address of the function to call with
7116 the new stack after paging is disabled.
7117 @param Context1 The 64-bit virtual address of the context to pass into
7118 the EntryPoint function as the first parameter after
7120 @param Context2 The 64-bit virtual address of the context to pass into
7121 the EntryPoint function as the second parameter after
7123 @param NewStack The 64-bit virtual address of the new stack to use for
7124 the EntryPoint function after paging is disabled.
7129 AsmDisablePaging64 (
7131 IN UINT32 EntryPoint
,
7132 IN UINT32 Context1
, OPTIONAL
7133 IN UINT32 Context2
, OPTIONAL
7139 // 16-bit thunking services
7143 Retrieves the properties for 16-bit thunk functions.
7145 Computes the size of the buffer and stack below 1MB required to use the
7146 AsmPrepareThunk16(), AsmThunk16() and AsmPrepareAndThunk16() functions. This
7147 buffer size is returned in RealModeBufferSize, and the stack size is returned
7148 in ExtraStackSize. If parameters are passed to the 16-bit real mode code,
7149 then the actual minimum stack size is ExtraStackSize plus the maximum number
7150 of bytes that need to be passed to the 16-bit real mode code.
7152 If RealModeBufferSize is NULL, then ASSERT().
7153 If ExtraStackSize is NULL, then ASSERT().
7155 @param RealModeBufferSize A pointer to the size of the buffer below 1MB
7156 required to use the 16-bit thunk functions.
7157 @param ExtraStackSize A pointer to the extra size of stack below 1MB
7158 that the 16-bit thunk functions require for
7159 temporary storage in the transition to and from
7165 AsmGetThunk16Properties (
7166 OUT UINT32
*RealModeBufferSize
,
7167 OUT UINT32
*ExtraStackSize
7172 Prepares all structures a code required to use AsmThunk16().
7174 Prepares all structures and code required to use AsmThunk16().
7176 This interface is limited to be used in either physical mode or virtual modes with paging enabled where the
7177 virtual to physical mappings for ThunkContext.RealModeBuffer is mapped 1:1.
7179 If ThunkContext is NULL, then ASSERT().
7181 @param ThunkContext A pointer to the context structure that describes the
7182 16-bit real mode code to call.
7188 IN OUT THUNK_CONTEXT
*ThunkContext
7193 Transfers control to a 16-bit real mode entry point and returns the results.
7195 Transfers control to a 16-bit real mode entry point and returns the results.
7196 AsmPrepareThunk16() must be called with ThunkContext before this function is used.
7197 This function must be called with interrupts disabled.
7199 The register state from the RealModeState field of ThunkContext is restored just prior
7200 to calling the 16-bit real mode entry point. This includes the EFLAGS field of RealModeState,
7201 which is used to set the interrupt state when a 16-bit real mode entry point is called.
7202 Control is transferred to the 16-bit real mode entry point specified by the CS and Eip fields of RealModeState.
7203 The stack is initialized to the SS and ESP fields of RealModeState. Any parameters passed to
7204 the 16-bit real mode code must be populated by the caller at SS:ESP prior to calling this function.
7205 The 16-bit real mode entry point is invoked with a 16-bit CALL FAR instruction,
7206 so when accessing stack contents, the 16-bit real mode code must account for the 16-bit segment
7207 and 16-bit offset of the return address that were pushed onto the stack. The 16-bit real mode entry
7208 point must exit with a RETF instruction. The register state is captured into RealModeState immediately
7209 after the RETF instruction is executed.
7211 If EFLAGS specifies interrupts enabled, or any of the 16-bit real mode code enables interrupts,
7212 or any of the 16-bit real mode code makes a SW interrupt, then the caller is responsible for making sure
7213 the IDT at address 0 is initialized to handle any HW or SW interrupts that may occur while in 16-bit real mode.
7215 If EFLAGS specifies interrupts enabled, or any of the 16-bit real mode code enables interrupts,
7216 then the caller is responsible for making sure the 8259 PIC is in a state compatible with 16-bit real mode.
7217 This includes the base vectors, the interrupt masks, and the edge/level trigger mode.
7219 If THUNK_ATTRIBUTE_BIG_REAL_MODE is set in the ThunkAttributes field of ThunkContext, then the user code
7220 is invoked in big real mode. Otherwise, the user code is invoked in 16-bit real mode with 64KB segment limits.
7222 If neither THUNK_ATTRIBUTE_DISABLE_A20_MASK_INT_15 nor THUNK_ATTRIBUTE_DISABLE_A20_MASK_KBD_CTRL are set in
7223 ThunkAttributes, then it is assumed that the user code did not enable the A20 mask, and no attempt is made to
7224 disable the A20 mask.
7226 If THUNK_ATTRIBUTE_DISABLE_A20_MASK_INT_15 is set and THUNK_ATTRIBUTE_DISABLE_A20_MASK_KBD_CTRL is clear in
7227 ThunkAttributes, then attempt to use the INT 15 service to disable the A20 mask. If this INT 15 call fails,
7228 then attempt to disable the A20 mask by directly accessing the 8042 keyboard controller I/O ports.
7230 If THUNK_ATTRIBUTE_DISABLE_A20_MASK_INT_15 is clear and THUNK_ATTRIBUTE_DISABLE_A20_MASK_KBD_CTRL is set in
7231 ThunkAttributes, then attempt to disable the A20 mask by directly accessing the 8042 keyboard controller I/O ports.
7233 If ThunkContext is NULL, then ASSERT().
7234 If AsmPrepareThunk16() was not previously called with ThunkContext, then ASSERT().
7235 If both THUNK_ATTRIBUTE_DISABLE_A20_MASK_INT_15 and THUNK_ATTRIBUTE_DISABLE_A20_MASK_KBD_CTRL are set in
7236 ThunkAttributes, then ASSERT().
7238 This interface is limited to be used in either physical mode or virtual modes with paging enabled where the
7239 virtual to physical mappings for ThunkContext.RealModeBuffer are mapped 1:1.
7241 @param ThunkContext A pointer to the context structure that describes the
7242 16-bit real mode code to call.
7248 IN OUT THUNK_CONTEXT
*ThunkContext
7253 Prepares all structures and code for a 16-bit real mode thunk, transfers
7254 control to a 16-bit real mode entry point, and returns the results.
7256 Prepares all structures and code for a 16-bit real mode thunk, transfers
7257 control to a 16-bit real mode entry point, and returns the results. If the
7258 caller only need to perform a single 16-bit real mode thunk, then this
7259 service should be used. If the caller intends to make more than one 16-bit
7260 real mode thunk, then it is more efficient if AsmPrepareThunk16() is called
7261 once and AsmThunk16() can be called for each 16-bit real mode thunk.
7263 This interface is limited to be used in either physical mode or virtual modes with paging enabled where the
7264 virtual to physical mappings for ThunkContext.RealModeBuffer is mapped 1:1.
7266 See AsmPrepareThunk16() and AsmThunk16() for the detailed description and ASSERT() conditions.
7268 @param ThunkContext A pointer to the context structure that describes the
7269 16-bit real mode code to call.
7274 AsmPrepareAndThunk16 (
7275 IN OUT THUNK_CONTEXT
*ThunkContext