2 Provides string functions, linked list functions, math functions, synchronization
3 functions, and CPU architecture-specific functions.
5 Copyright (c) 2006 - 2012, 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)
154 Copies one Null-terminated Unicode string to another Null-terminated Unicode
155 string and returns the new Unicode string.
157 This function copies the contents of the Unicode string Source to the Unicode
158 string Destination, and returns Destination. If Source and Destination
159 overlap, then the results are undefined.
161 If Destination is NULL, then ASSERT().
162 If Destination is not aligned on a 16-bit boundary, then ASSERT().
163 If Source is NULL, then ASSERT().
164 If Source is not aligned on a 16-bit boundary, then ASSERT().
165 If Source and Destination overlap, then ASSERT().
166 If PcdMaximumUnicodeStringLength is not zero, and Source contains more than
167 PcdMaximumUnicodeStringLength Unicode characters not including the
168 Null-terminator, then ASSERT().
170 @param Destination The pointer to a Null-terminated Unicode string.
171 @param Source The pointer to a Null-terminated Unicode string.
179 OUT CHAR16
*Destination
,
180 IN CONST CHAR16
*Source
185 Copies up to a specified length from one Null-terminated Unicode string to
186 another Null-terminated Unicode string and returns the new Unicode string.
188 This function copies the contents of the Unicode string Source to the Unicode
189 string Destination, and returns Destination. At most, Length Unicode
190 characters are copied from Source to Destination. If Length is 0, then
191 Destination is returned unmodified. If Length is greater that the number of
192 Unicode characters in Source, then Destination is padded with Null Unicode
193 characters. If Source and Destination overlap, then the results are
196 If Length > 0 and Destination is NULL, then ASSERT().
197 If Length > 0 and Destination is not aligned on a 16-bit boundary, then ASSERT().
198 If Length > 0 and Source is NULL, then ASSERT().
199 If Length > 0 and Source is not aligned on a 16-bit boundary, then ASSERT().
200 If Source and Destination overlap, then ASSERT().
201 If PcdMaximumUnicodeStringLength is not zero, and Length is greater than
202 PcdMaximumUnicodeStringLength, then ASSERT().
203 If PcdMaximumUnicodeStringLength is not zero, and Source contains more than
204 PcdMaximumUnicodeStringLength Unicode characters, not including the Null-terminator,
207 @param Destination The pointer to a Null-terminated Unicode string.
208 @param Source The pointer to a Null-terminated Unicode string.
209 @param Length The maximum number of Unicode characters to copy.
217 OUT CHAR16
*Destination
,
218 IN CONST CHAR16
*Source
,
224 Returns the length of a Null-terminated Unicode string.
226 This function returns the number of Unicode characters in the Null-terminated
227 Unicode string specified by String.
229 If String is NULL, then ASSERT().
230 If String is not aligned on a 16-bit boundary, then ASSERT().
231 If PcdMaximumUnicodeStringLength is not zero, and String contains more than
232 PcdMaximumUnicodeStringLength Unicode characters not including the
233 Null-terminator, then ASSERT().
235 @param String Pointer to a Null-terminated Unicode string.
237 @return The length of String.
243 IN CONST CHAR16
*String
248 Returns the size of a Null-terminated Unicode string in bytes, including the
251 This function returns the size, in bytes, of the Null-terminated Unicode string
254 If String is NULL, then ASSERT().
255 If String is not aligned on a 16-bit boundary, then ASSERT().
256 If PcdMaximumUnicodeStringLength is not zero, and String contains more than
257 PcdMaximumUnicodeStringLength Unicode characters not including the
258 Null-terminator, then ASSERT().
260 @param String The pointer to a Null-terminated Unicode string.
262 @return The size of String.
268 IN CONST CHAR16
*String
273 Compares two Null-terminated Unicode strings, and returns the difference
274 between the first mismatched Unicode characters.
276 This function compares the Null-terminated Unicode string FirstString to the
277 Null-terminated Unicode string SecondString. If FirstString is identical to
278 SecondString, then 0 is returned. Otherwise, the value returned is the first
279 mismatched Unicode character in SecondString subtracted from the first
280 mismatched Unicode character in FirstString.
282 If FirstString is NULL, then ASSERT().
283 If FirstString is not aligned on a 16-bit boundary, then ASSERT().
284 If SecondString is NULL, then ASSERT().
285 If SecondString is not aligned on a 16-bit boundary, then ASSERT().
286 If PcdMaximumUnicodeStringLength is not zero, and FirstString contains more
287 than PcdMaximumUnicodeStringLength Unicode characters not including the
288 Null-terminator, then ASSERT().
289 If PcdMaximumUnicodeStringLength is not zero, and SecondString contains more
290 than PcdMaximumUnicodeStringLength Unicode characters, not including the
291 Null-terminator, then ASSERT().
293 @param FirstString The pointer to a Null-terminated Unicode string.
294 @param SecondString The pointer to a Null-terminated Unicode string.
296 @retval 0 FirstString is identical to SecondString.
297 @return others FirstString is not identical to SecondString.
303 IN CONST CHAR16
*FirstString
,
304 IN CONST CHAR16
*SecondString
309 Compares up to a specified length the contents of two Null-terminated Unicode strings,
310 and returns the difference between the first mismatched Unicode characters.
312 This function compares the Null-terminated Unicode string FirstString to the
313 Null-terminated Unicode string SecondString. At most, Length Unicode
314 characters will be compared. If Length is 0, then 0 is returned. If
315 FirstString is identical to SecondString, then 0 is returned. Otherwise, the
316 value returned is the first mismatched Unicode character in SecondString
317 subtracted from the first mismatched Unicode character in FirstString.
319 If Length > 0 and FirstString is NULL, then ASSERT().
320 If Length > 0 and FirstString is not aligned on a 16-bit boundary, then ASSERT().
321 If Length > 0 and SecondString is NULL, then ASSERT().
322 If Length > 0 and SecondString is not aligned on a 16-bit boundary, then ASSERT().
323 If PcdMaximumUnicodeStringLength is not zero, and Length is greater than
324 PcdMaximumUnicodeStringLength, then ASSERT().
325 If PcdMaximumUnicodeStringLength is not zero, and FirstString contains more than
326 PcdMaximumUnicodeStringLength Unicode characters, not including the Null-terminator,
328 If PcdMaximumUnicodeStringLength is not zero, and SecondString contains more than
329 PcdMaximumUnicodeStringLength Unicode characters, not including the Null-terminator,
332 @param FirstString The pointer to a Null-terminated Unicode string.
333 @param SecondString The pointer to a Null-terminated Unicode string.
334 @param Length The maximum number of Unicode characters to compare.
336 @retval 0 FirstString is identical to SecondString.
337 @return others FirstString is not identical to SecondString.
343 IN CONST CHAR16
*FirstString
,
344 IN CONST CHAR16
*SecondString
,
350 Concatenates one Null-terminated Unicode string to another Null-terminated
351 Unicode string, and returns the concatenated Unicode string.
353 This function concatenates two Null-terminated Unicode strings. The contents
354 of Null-terminated Unicode string Source are concatenated to the end of
355 Null-terminated Unicode string Destination. The Null-terminated concatenated
356 Unicode String is returned. If Source and Destination overlap, then the
357 results are undefined.
359 If Destination is NULL, then ASSERT().
360 If Destination is not aligned on a 16-bit boundary, then ASSERT().
361 If Source is NULL, then ASSERT().
362 If Source is not aligned on a 16-bit boundary, then ASSERT().
363 If Source and Destination overlap, then ASSERT().
364 If PcdMaximumUnicodeStringLength is not zero, and Destination contains more
365 than PcdMaximumUnicodeStringLength Unicode characters, not including the
366 Null-terminator, then ASSERT().
367 If PcdMaximumUnicodeStringLength is not zero, and Source contains more than
368 PcdMaximumUnicodeStringLength Unicode characters, not including the
369 Null-terminator, then ASSERT().
370 If PcdMaximumUnicodeStringLength is not zero, and concatenating Destination
371 and Source results in a Unicode string with more than
372 PcdMaximumUnicodeStringLength Unicode characters, not including the
373 Null-terminator, then ASSERT().
375 @param Destination The pointer to a Null-terminated Unicode string.
376 @param Source The pointer to a Null-terminated Unicode string.
384 IN OUT CHAR16
*Destination
,
385 IN CONST CHAR16
*Source
390 Concatenates up to a specified length one Null-terminated Unicode to the end
391 of another Null-terminated Unicode string, and returns the concatenated
394 This function concatenates two Null-terminated Unicode strings. The contents
395 of Null-terminated Unicode string Source are concatenated to the end of
396 Null-terminated Unicode string Destination, and Destination is returned. At
397 most, Length Unicode characters are concatenated from Source to the end of
398 Destination, and Destination is always Null-terminated. If Length is 0, then
399 Destination is returned unmodified. If Source and Destination overlap, then
400 the results are undefined.
402 If Destination is NULL, then ASSERT().
403 If Length > 0 and Destination is not aligned on a 16-bit boundary, then ASSERT().
404 If Length > 0 and Source is NULL, then ASSERT().
405 If Length > 0 and Source is not aligned on a 16-bit boundary, then ASSERT().
406 If Source and Destination overlap, then ASSERT().
407 If PcdMaximumUnicodeStringLength is not zero, and Length is greater than
408 PcdMaximumUnicodeStringLength, then ASSERT().
409 If PcdMaximumUnicodeStringLength is not zero, and Destination contains more
410 than PcdMaximumUnicodeStringLength Unicode characters, not including the
411 Null-terminator, then ASSERT().
412 If PcdMaximumUnicodeStringLength is not zero, and Source contains more than
413 PcdMaximumUnicodeStringLength Unicode characters, not including the
414 Null-terminator, then ASSERT().
415 If PcdMaximumUnicodeStringLength is not zero, and concatenating Destination
416 and Source results in a Unicode string with more than PcdMaximumUnicodeStringLength
417 Unicode characters, not including the Null-terminator, then ASSERT().
419 @param Destination The pointer to a Null-terminated Unicode string.
420 @param Source The pointer to a Null-terminated Unicode string.
421 @param Length The maximum number of Unicode characters to concatenate from
430 IN OUT CHAR16
*Destination
,
431 IN CONST CHAR16
*Source
,
436 Returns the first occurrence of a Null-terminated Unicode sub-string
437 in a Null-terminated Unicode string.
439 This function scans the contents of the Null-terminated Unicode string
440 specified by String and returns the first occurrence of SearchString.
441 If SearchString is not found in String, then NULL is returned. If
442 the length of SearchString is zero, then String is returned.
444 If String is NULL, then ASSERT().
445 If String is not aligned on a 16-bit boundary, then ASSERT().
446 If SearchString is NULL, then ASSERT().
447 If SearchString is not aligned on a 16-bit boundary, then ASSERT().
449 If PcdMaximumUnicodeStringLength is not zero, and SearchString
450 or String contains more than PcdMaximumUnicodeStringLength Unicode
451 characters, not including the Null-terminator, then ASSERT().
453 @param String The pointer to a Null-terminated Unicode string.
454 @param SearchString The pointer to a Null-terminated Unicode string to search for.
456 @retval NULL If the SearchString does not appear in String.
457 @return others If there is a match.
463 IN CONST CHAR16
*String
,
464 IN CONST CHAR16
*SearchString
468 Convert a Null-terminated Unicode decimal string to a value of
471 This function returns a value of type UINTN by interpreting the contents
472 of the Unicode string specified by String as a decimal number. The format
473 of the input Unicode string String is:
475 [spaces] [decimal digits].
477 The valid decimal digit character is in the range [0-9]. The
478 function will ignore the pad space, which includes spaces or
479 tab characters, before [decimal digits]. The running zero in the
480 beginning of [decimal digits] will be ignored. Then, the function
481 stops at the first character that is a not a valid decimal character
482 or a Null-terminator, whichever one comes first.
484 If String is NULL, then ASSERT().
485 If String is not aligned in a 16-bit boundary, then ASSERT().
486 If String has only pad spaces, then 0 is returned.
487 If String has no pad spaces or valid decimal digits,
489 If the number represented by String overflows according
490 to the range defined by UINTN, then ASSERT().
492 If PcdMaximumUnicodeStringLength is not zero, and String contains
493 more than PcdMaximumUnicodeStringLength Unicode characters not including
494 the Null-terminator, then ASSERT().
496 @param String The pointer to a Null-terminated Unicode string.
498 @retval Value translated from String.
504 IN CONST CHAR16
*String
508 Convert a Null-terminated Unicode decimal string to a value of
511 This function returns a value of type UINT64 by interpreting the contents
512 of the Unicode string specified by String as a decimal number. The format
513 of the input Unicode string String is:
515 [spaces] [decimal digits].
517 The valid decimal digit character is in the range [0-9]. The
518 function will ignore the pad space, which includes spaces or
519 tab characters, before [decimal digits]. The running zero in the
520 beginning of [decimal digits] will be ignored. Then, the function
521 stops at the first character that is a not a valid decimal character
522 or a Null-terminator, whichever one comes first.
524 If String is NULL, then ASSERT().
525 If String is not aligned in a 16-bit boundary, then ASSERT().
526 If String has only pad spaces, then 0 is returned.
527 If String has no pad spaces or valid decimal digits,
529 If the number represented by String overflows according
530 to the range defined by UINT64, then ASSERT().
532 If PcdMaximumUnicodeStringLength is not zero, and String contains
533 more than PcdMaximumUnicodeStringLength Unicode characters not including
534 the Null-terminator, then ASSERT().
536 @param String The pointer to a Null-terminated Unicode string.
538 @retval Value translated from String.
544 IN CONST CHAR16
*String
549 Convert a Null-terminated Unicode hexadecimal string to a value of type UINTN.
551 This function returns a value of type UINTN by interpreting the contents
552 of the Unicode string specified by String as a hexadecimal number.
553 The format of the input Unicode string String is:
555 [spaces][zeros][x][hexadecimal digits].
557 The valid hexadecimal digit character is in the range [0-9], [a-f] and [A-F].
558 The prefix "0x" is optional. Both "x" and "X" is allowed in "0x" prefix.
559 If "x" appears in the input string, it must be prefixed with at least one 0.
560 The function will ignore the pad space, which includes spaces or tab characters,
561 before [zeros], [x] or [hexadecimal digit]. The running zero before [x] or
562 [hexadecimal digit] will be ignored. Then, the decoding starts after [x] or the
563 first valid hexadecimal digit. Then, the function stops at the first character
564 that is a not a valid hexadecimal character or NULL, whichever one comes first.
566 If String is NULL, then ASSERT().
567 If String is not aligned in a 16-bit boundary, then ASSERT().
568 If String has only pad spaces, then zero is returned.
569 If String has no leading pad spaces, leading zeros or valid hexadecimal digits,
570 then zero is returned.
571 If the number represented by String overflows according to the range defined by
572 UINTN, then ASSERT().
574 If PcdMaximumUnicodeStringLength is not zero, and String contains more than
575 PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator,
578 @param String The pointer to a Null-terminated Unicode string.
580 @retval Value translated from String.
586 IN CONST CHAR16
*String
591 Convert a Null-terminated Unicode hexadecimal string to a value of type UINT64.
593 This function returns a value of type UINT64 by interpreting the contents
594 of the Unicode string specified by String as a hexadecimal number.
595 The format of the input Unicode string String is
597 [spaces][zeros][x][hexadecimal digits].
599 The valid hexadecimal digit character is in the range [0-9], [a-f] and [A-F].
600 The prefix "0x" is optional. Both "x" and "X" is allowed in "0x" prefix.
601 If "x" appears in the input string, it must be prefixed with at least one 0.
602 The function will ignore the pad space, which includes spaces or tab characters,
603 before [zeros], [x] or [hexadecimal digit]. The running zero before [x] or
604 [hexadecimal digit] will be ignored. Then, the decoding starts after [x] or the
605 first valid hexadecimal digit. Then, the function stops at the first character that is
606 a not a valid hexadecimal character or NULL, whichever one comes first.
608 If String is NULL, then ASSERT().
609 If String is not aligned in a 16-bit boundary, then ASSERT().
610 If String has only pad spaces, then zero is returned.
611 If String has no leading pad spaces, leading zeros or valid hexadecimal digits,
612 then zero is returned.
613 If the number represented by String overflows according to the range defined by
614 UINT64, then ASSERT().
616 If PcdMaximumUnicodeStringLength is not zero, and String contains more than
617 PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator,
620 @param String The pointer to a Null-terminated Unicode string.
622 @retval Value translated from String.
628 IN CONST CHAR16
*String
632 Convert a Null-terminated Unicode string to a Null-terminated
633 ASCII string and returns the ASCII string.
635 This function converts the content of the Unicode string Source
636 to the ASCII string Destination by copying the lower 8 bits of
637 each Unicode character. It returns Destination.
639 The caller is responsible to make sure Destination points to a buffer with size
640 equal or greater than ((StrLen (Source) + 1) * sizeof (CHAR8)) in bytes.
642 If any Unicode characters in Source contain non-zero value in
643 the upper 8 bits, then ASSERT().
645 If Destination is NULL, then ASSERT().
646 If Source is NULL, then ASSERT().
647 If Source is not aligned on a 16-bit boundary, then ASSERT().
648 If Source and Destination overlap, then ASSERT().
650 If PcdMaximumUnicodeStringLength is not zero, and Source contains
651 more than PcdMaximumUnicodeStringLength Unicode characters not including
652 the Null-terminator, then ASSERT().
654 If PcdMaximumAsciiStringLength is not zero, and Source contains more
655 than PcdMaximumAsciiStringLength Unicode characters not including the
656 Null-terminator, then ASSERT().
658 @param Source The pointer to a Null-terminated Unicode string.
659 @param Destination The pointer to a Null-terminated ASCII string.
666 UnicodeStrToAsciiStr (
667 IN CONST CHAR16
*Source
,
668 OUT CHAR8
*Destination
673 Copies one Null-terminated ASCII string to another Null-terminated ASCII
674 string and returns the new ASCII string.
676 This function copies the contents of the ASCII string Source to the ASCII
677 string Destination, and returns Destination. If Source and Destination
678 overlap, then the results are undefined.
680 If Destination is NULL, then ASSERT().
681 If Source is NULL, then ASSERT().
682 If Source and Destination overlap, then ASSERT().
683 If PcdMaximumAsciiStringLength is not zero and Source contains more than
684 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
687 @param Destination The pointer to a Null-terminated ASCII string.
688 @param Source The pointer to a Null-terminated ASCII string.
696 OUT CHAR8
*Destination
,
697 IN CONST CHAR8
*Source
702 Copies up to a specified length one Null-terminated ASCII string to another
703 Null-terminated ASCII string and returns the new ASCII string.
705 This function copies the contents of the ASCII string Source to the ASCII
706 string Destination, and returns Destination. At most, Length ASCII characters
707 are copied from Source to Destination. If Length is 0, then Destination is
708 returned unmodified. If Length is greater that the number of ASCII characters
709 in Source, then Destination is padded with Null ASCII characters. If Source
710 and Destination overlap, then the results are undefined.
712 If Destination is NULL, then ASSERT().
713 If Source is NULL, then ASSERT().
714 If Source and Destination overlap, then ASSERT().
715 If PcdMaximumAsciiStringLength is not zero, and Length is greater than
716 PcdMaximumAsciiStringLength, then ASSERT().
717 If PcdMaximumAsciiStringLength is not zero, and Source contains more than
718 PcdMaximumAsciiStringLength ASCII characters, not including the Null-terminator,
721 @param Destination The pointer to a Null-terminated ASCII string.
722 @param Source The pointer to a Null-terminated ASCII string.
723 @param Length The maximum number of ASCII characters to copy.
731 OUT CHAR8
*Destination
,
732 IN CONST CHAR8
*Source
,
738 Returns the length of a Null-terminated ASCII string.
740 This function returns the number of ASCII characters in the Null-terminated
741 ASCII string specified by String.
743 If Length > 0 and Destination is NULL, then ASSERT().
744 If Length > 0 and Source is NULL, then ASSERT().
745 If PcdMaximumAsciiStringLength is not zero and String contains more than
746 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
749 @param String The pointer to a Null-terminated ASCII string.
751 @return The length of String.
757 IN CONST CHAR8
*String
762 Returns the size of a Null-terminated ASCII string in bytes, including the
765 This function returns the size, in bytes, of the Null-terminated ASCII string
768 If String is NULL, then ASSERT().
769 If PcdMaximumAsciiStringLength is not zero and String contains more than
770 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
773 @param String The pointer to a Null-terminated ASCII string.
775 @return The size of String.
781 IN CONST CHAR8
*String
786 Compares two Null-terminated ASCII strings, and returns the difference
787 between the first mismatched ASCII characters.
789 This function compares the Null-terminated ASCII string FirstString to the
790 Null-terminated ASCII string SecondString. If FirstString is identical to
791 SecondString, then 0 is returned. Otherwise, the value returned is the first
792 mismatched ASCII character in SecondString subtracted from the first
793 mismatched ASCII character in FirstString.
795 If FirstString is NULL, then ASSERT().
796 If SecondString is NULL, then ASSERT().
797 If PcdMaximumAsciiStringLength is not zero and FirstString contains more than
798 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
800 If PcdMaximumAsciiStringLength is not zero and SecondString contains more
801 than PcdMaximumAsciiStringLength ASCII characters not including the
802 Null-terminator, then ASSERT().
804 @param FirstString The pointer to a Null-terminated ASCII string.
805 @param SecondString The pointer to a Null-terminated ASCII string.
807 @retval ==0 FirstString is identical to SecondString.
808 @retval !=0 FirstString is not identical to SecondString.
814 IN CONST CHAR8
*FirstString
,
815 IN CONST CHAR8
*SecondString
820 Performs a case insensitive comparison of two Null-terminated ASCII strings,
821 and returns the difference between the first mismatched ASCII characters.
823 This function performs a case insensitive comparison of the Null-terminated
824 ASCII string FirstString to the Null-terminated ASCII string SecondString. If
825 FirstString is identical to SecondString, then 0 is returned. Otherwise, the
826 value returned is the first mismatched lower case ASCII character in
827 SecondString subtracted from the first mismatched lower case ASCII character
830 If FirstString is NULL, then ASSERT().
831 If SecondString is NULL, then ASSERT().
832 If PcdMaximumAsciiStringLength is not zero and FirstString contains more than
833 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
835 If PcdMaximumAsciiStringLength is not zero and SecondString contains more
836 than PcdMaximumAsciiStringLength ASCII characters not including the
837 Null-terminator, then ASSERT().
839 @param FirstString The pointer to a Null-terminated ASCII string.
840 @param SecondString The pointer to a Null-terminated ASCII string.
842 @retval ==0 FirstString is identical to SecondString using case insensitive
844 @retval !=0 FirstString is not identical to SecondString using case
845 insensitive comparisons.
851 IN CONST CHAR8
*FirstString
,
852 IN CONST CHAR8
*SecondString
857 Compares two Null-terminated ASCII strings with maximum lengths, and returns
858 the difference between the first mismatched ASCII characters.
860 This function compares the Null-terminated ASCII string FirstString to the
861 Null-terminated ASCII string SecondString. At most, Length ASCII characters
862 will be compared. If Length is 0, then 0 is returned. If FirstString is
863 identical to SecondString, then 0 is returned. Otherwise, the value returned
864 is the first mismatched ASCII character in SecondString subtracted from the
865 first mismatched ASCII character in FirstString.
867 If Length > 0 and FirstString is NULL, then ASSERT().
868 If Length > 0 and SecondString is NULL, then ASSERT().
869 If PcdMaximumAsciiStringLength is not zero, and Length is greater than
870 PcdMaximumAsciiStringLength, then ASSERT().
871 If PcdMaximumAsciiStringLength is not zero, and FirstString contains more than
872 PcdMaximumAsciiStringLength ASCII characters, not including the Null-terminator,
874 If PcdMaximumAsciiStringLength is not zero, and SecondString contains more than
875 PcdMaximumAsciiStringLength ASCII characters, not including the Null-terminator,
878 @param FirstString The pointer to a Null-terminated ASCII string.
879 @param SecondString The pointer to a Null-terminated ASCII string.
880 @param Length The maximum number of ASCII characters for compare.
882 @retval ==0 FirstString is identical to SecondString.
883 @retval !=0 FirstString is not identical to SecondString.
889 IN CONST CHAR8
*FirstString
,
890 IN CONST CHAR8
*SecondString
,
896 Concatenates one Null-terminated ASCII string to another Null-terminated
897 ASCII string, and returns the concatenated ASCII string.
899 This function concatenates two Null-terminated ASCII strings. The contents of
900 Null-terminated ASCII string Source are concatenated to the end of Null-
901 terminated ASCII string Destination. The Null-terminated concatenated ASCII
904 If Destination is NULL, then ASSERT().
905 If Source is NULL, then ASSERT().
906 If PcdMaximumAsciiStringLength is not zero and Destination contains more than
907 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
909 If PcdMaximumAsciiStringLength is not zero and Source contains more than
910 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
912 If PcdMaximumAsciiStringLength is not zero and concatenating Destination and
913 Source results in a ASCII string with more than PcdMaximumAsciiStringLength
914 ASCII characters, then ASSERT().
916 @param Destination The pointer to a Null-terminated ASCII string.
917 @param Source The pointer to a Null-terminated ASCII string.
925 IN OUT CHAR8
*Destination
,
926 IN CONST CHAR8
*Source
931 Concatenates up to a specified length one Null-terminated ASCII string to
932 the end of another Null-terminated ASCII string, and returns the
933 concatenated ASCII string.
935 This function concatenates two Null-terminated ASCII strings. The contents
936 of Null-terminated ASCII string Source are concatenated to the end of Null-
937 terminated ASCII string Destination, and Destination is returned. At most,
938 Length ASCII characters are concatenated from Source to the end of
939 Destination, and Destination is always Null-terminated. If Length is 0, then
940 Destination is returned unmodified. If Source and Destination overlap, then
941 the results are undefined.
943 If Length > 0 and Destination is NULL, then ASSERT().
944 If Length > 0 and Source is NULL, then ASSERT().
945 If Source and Destination overlap, then ASSERT().
946 If PcdMaximumAsciiStringLength is not zero, and Length is greater than
947 PcdMaximumAsciiStringLength, then ASSERT().
948 If PcdMaximumAsciiStringLength is not zero, and Destination contains more than
949 PcdMaximumAsciiStringLength ASCII characters, not including the Null-terminator,
951 If PcdMaximumAsciiStringLength is not zero, and Source contains more than
952 PcdMaximumAsciiStringLength ASCII characters, not including the Null-terminator,
954 If PcdMaximumAsciiStringLength is not zero, and concatenating Destination and
955 Source results in a ASCII string with more than PcdMaximumAsciiStringLength
956 ASCII characters, not including the Null-terminator, then ASSERT().
958 @param Destination The pointer to a Null-terminated ASCII string.
959 @param Source The pointer to a Null-terminated ASCII string.
960 @param Length The maximum number of ASCII characters to concatenate from
969 IN OUT CHAR8
*Destination
,
970 IN CONST CHAR8
*Source
,
976 Returns the first occurrence of a Null-terminated ASCII sub-string
977 in a Null-terminated ASCII string.
979 This function scans the contents of the ASCII string specified by String
980 and returns the first occurrence of SearchString. If SearchString is not
981 found in String, then NULL is returned. If the length of SearchString is zero,
982 then String is returned.
984 If String is NULL, then ASSERT().
985 If SearchString is NULL, then ASSERT().
987 If PcdMaximumAsciiStringLength is not zero, and SearchString or
988 String contains more than PcdMaximumAsciiStringLength Unicode characters
989 not including the Null-terminator, then ASSERT().
991 @param String The pointer to a Null-terminated ASCII string.
992 @param SearchString The pointer to a Null-terminated ASCII string to search for.
994 @retval NULL If the SearchString does not appear in String.
995 @retval others If there is a match return the first occurrence of SearchingString.
996 If the length of SearchString is zero,return String.
1002 IN CONST CHAR8
*String
,
1003 IN CONST CHAR8
*SearchString
1008 Convert a Null-terminated ASCII decimal string to a value of type
1011 This function returns a value of type UINTN by interpreting the contents
1012 of the ASCII string String as a decimal number. The format of the input
1013 ASCII string String is:
1015 [spaces] [decimal digits].
1017 The valid decimal digit character is in the range [0-9]. The function will
1018 ignore the pad space, which includes spaces or tab characters, before the digits.
1019 The running zero in the beginning of [decimal digits] will be ignored. Then, the
1020 function stops at the first character that is a not a valid decimal character or
1021 Null-terminator, whichever on comes first.
1023 If String has only pad spaces, then 0 is returned.
1024 If String has no pad spaces or valid decimal digits, then 0 is returned.
1025 If the number represented by String overflows according to the range defined by
1026 UINTN, then ASSERT().
1027 If String is NULL, then ASSERT().
1028 If PcdMaximumAsciiStringLength is not zero, and String contains more than
1029 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
1032 @param String The pointer to a Null-terminated ASCII string.
1034 @retval The value translated from String.
1039 AsciiStrDecimalToUintn (
1040 IN CONST CHAR8
*String
1045 Convert a Null-terminated ASCII decimal string to a value of type
1048 This function returns a value of type UINT64 by interpreting the contents
1049 of the ASCII string String as a decimal number. The format of the input
1050 ASCII string String is:
1052 [spaces] [decimal digits].
1054 The valid decimal digit character is in the range [0-9]. The function will
1055 ignore the pad space, which includes spaces or tab characters, before the digits.
1056 The running zero in the beginning of [decimal digits] will be ignored. Then, the
1057 function stops at the first character that is a not a valid decimal character or
1058 Null-terminator, whichever on comes first.
1060 If String has only pad spaces, then 0 is returned.
1061 If String has no pad spaces or valid decimal digits, then 0 is returned.
1062 If the number represented by String overflows according to the range defined by
1063 UINT64, then ASSERT().
1064 If String is NULL, then ASSERT().
1065 If PcdMaximumAsciiStringLength is not zero, and String contains more than
1066 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
1069 @param String The pointer to a Null-terminated ASCII string.
1071 @retval Value translated from String.
1076 AsciiStrDecimalToUint64 (
1077 IN CONST CHAR8
*String
1082 Convert a Null-terminated ASCII hexadecimal string to a value of type UINTN.
1084 This function returns a value of type UINTN by interpreting the contents of
1085 the ASCII string String as a hexadecimal number. The format of the input ASCII
1088 [spaces][zeros][x][hexadecimal digits].
1090 The valid hexadecimal digit character is in the range [0-9], [a-f] and [A-F].
1091 The prefix "0x" is optional. Both "x" and "X" is allowed in "0x" prefix. If "x"
1092 appears in the input string, it must be prefixed with at least one 0. The function
1093 will ignore the pad space, which includes spaces or tab characters, before [zeros],
1094 [x] or [hexadecimal digits]. The running zero before [x] or [hexadecimal digits]
1095 will be ignored. Then, the decoding starts after [x] or the first valid hexadecimal
1096 digit. Then, the function stops at the first character that is a not a valid
1097 hexadecimal character or Null-terminator, whichever on comes first.
1099 If String has only pad spaces, then 0 is returned.
1100 If String has no leading pad spaces, leading zeros or valid hexadecimal digits, then
1103 If the number represented by String overflows according to the range defined by UINTN,
1105 If String is NULL, then ASSERT().
1106 If PcdMaximumAsciiStringLength is not zero,
1107 and String contains more than PcdMaximumAsciiStringLength ASCII characters not including
1108 the Null-terminator, then ASSERT().
1110 @param String The pointer to a Null-terminated ASCII string.
1112 @retval Value translated from String.
1117 AsciiStrHexToUintn (
1118 IN CONST CHAR8
*String
1123 Convert a Null-terminated ASCII hexadecimal string to a value of type UINT64.
1125 This function returns a value of type UINT64 by interpreting the contents of
1126 the ASCII string String as a hexadecimal number. The format of the input ASCII
1129 [spaces][zeros][x][hexadecimal digits].
1131 The valid hexadecimal digit character is in the range [0-9], [a-f] and [A-F].
1132 The prefix "0x" is optional. Both "x" and "X" is allowed in "0x" prefix. If "x"
1133 appears in the input string, it must be prefixed with at least one 0. The function
1134 will ignore the pad space, which includes spaces or tab characters, before [zeros],
1135 [x] or [hexadecimal digits]. The running zero before [x] or [hexadecimal digits]
1136 will be ignored. Then, the decoding starts after [x] or the first valid hexadecimal
1137 digit. Then, the function stops at the first character that is a not a valid
1138 hexadecimal character or Null-terminator, whichever on comes first.
1140 If String has only pad spaces, then 0 is returned.
1141 If String has no leading pad spaces, leading zeros or valid hexadecimal digits, then
1144 If the number represented by String overflows according to the range defined by UINT64,
1146 If String is NULL, then ASSERT().
1147 If PcdMaximumAsciiStringLength is not zero,
1148 and String contains more than PcdMaximumAsciiStringLength ASCII characters not including
1149 the Null-terminator, then ASSERT().
1151 @param String The pointer to a Null-terminated ASCII string.
1153 @retval Value translated from String.
1158 AsciiStrHexToUint64 (
1159 IN CONST CHAR8
*String
1164 Convert one Null-terminated ASCII string to a Null-terminated
1165 Unicode string and returns the Unicode string.
1167 This function converts the contents of the ASCII string Source to the Unicode
1168 string Destination, and returns Destination. The function terminates the
1169 Unicode string Destination by appending a Null-terminator character at the end.
1170 The caller is responsible to make sure Destination points to a buffer with size
1171 equal or greater than ((AsciiStrLen (Source) + 1) * sizeof (CHAR16)) in bytes.
1173 If Destination is NULL, then ASSERT().
1174 If Destination is not aligned on a 16-bit boundary, then ASSERT().
1175 If Source is NULL, then ASSERT().
1176 If Source and Destination overlap, then ASSERT().
1177 If PcdMaximumAsciiStringLength is not zero, and Source contains more than
1178 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
1180 If PcdMaximumUnicodeStringLength is not zero, and Source contains more than
1181 PcdMaximumUnicodeStringLength ASCII characters not including the
1182 Null-terminator, then ASSERT().
1184 @param Source The pointer to a Null-terminated ASCII string.
1185 @param Destination The pointer to a Null-terminated Unicode string.
1187 @return Destination.
1192 AsciiStrToUnicodeStr (
1193 IN CONST CHAR8
*Source
,
1194 OUT CHAR16
*Destination
1199 Converts an 8-bit value to an 8-bit BCD value.
1201 Converts the 8-bit value specified by Value to BCD. The BCD value is
1204 If Value >= 100, then ASSERT().
1206 @param Value The 8-bit value to convert to BCD. Range 0..99.
1208 @return The BCD value.
1219 Converts an 8-bit BCD value to an 8-bit value.
1221 Converts the 8-bit BCD value specified by Value to an 8-bit value. The 8-bit
1224 If Value >= 0xA0, then ASSERT().
1225 If (Value & 0x0F) >= 0x0A, then ASSERT().
1227 @param Value The 8-bit BCD value to convert to an 8-bit value.
1229 @return The 8-bit value is returned.
1240 // Linked List Functions and Macros
1244 Initializes the head node of a doubly linked list that is declared as a
1245 global variable in a module.
1247 Initializes the forward and backward links of a new linked list. After
1248 initializing a linked list with this macro, the other linked list functions
1249 may be used to add and remove nodes from the linked list. This macro results
1250 in smaller executables by initializing the linked list in the data section,
1251 instead if calling the InitializeListHead() function to perform the
1252 equivalent operation.
1254 @param ListHead The head note of a list to initialize.
1257 #define INITIALIZE_LIST_HEAD_VARIABLE(ListHead) {&(ListHead), &(ListHead)}
1261 Initializes the head node of a doubly linked list, and returns the pointer to
1262 the head node of the doubly linked list.
1264 Initializes the forward and backward links of a new linked list. After
1265 initializing a linked list with this function, the other linked list
1266 functions may be used to add and remove nodes from the linked list. It is up
1267 to the caller of this function to allocate the memory for ListHead.
1269 If ListHead is NULL, then ASSERT().
1271 @param ListHead A pointer to the head node of a new doubly linked list.
1278 InitializeListHead (
1279 IN OUT LIST_ENTRY
*ListHead
1284 Adds a node to the beginning of a doubly linked list, and returns the pointer
1285 to the head node of the doubly linked list.
1287 Adds the node Entry at the beginning of the doubly linked list denoted by
1288 ListHead, and returns ListHead.
1290 If ListHead is NULL, then ASSERT().
1291 If Entry is NULL, then ASSERT().
1292 If ListHead was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or
1293 InitializeListHead(), then ASSERT().
1294 If PcdMaximumLinkedListLenth is not zero, and prior to insertion the number
1295 of nodes in ListHead, including the ListHead node, is greater than or
1296 equal to PcdMaximumLinkedListLength, then ASSERT().
1298 @param ListHead A pointer to the head node of a doubly linked list.
1299 @param Entry A pointer to a node that is to be inserted at the beginning
1300 of a doubly linked list.
1308 IN OUT LIST_ENTRY
*ListHead
,
1309 IN OUT LIST_ENTRY
*Entry
1314 Adds a node to the end of a doubly linked list, and returns the pointer to
1315 the head node of the doubly linked list.
1317 Adds the node Entry to the end of the doubly linked list denoted by ListHead,
1318 and returns ListHead.
1320 If ListHead is NULL, then ASSERT().
1321 If Entry is NULL, then ASSERT().
1322 If ListHead was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or
1323 InitializeListHead(), then ASSERT().
1324 If PcdMaximumLinkedListLenth is not zero, and prior to insertion the number
1325 of nodes in ListHead, including the ListHead node, is greater than or
1326 equal to PcdMaximumLinkedListLength, then ASSERT().
1328 @param ListHead A pointer to the head node of a doubly linked list.
1329 @param Entry A pointer to a node that is to be added at the end of the
1338 IN OUT LIST_ENTRY
*ListHead
,
1339 IN OUT LIST_ENTRY
*Entry
1344 Retrieves the first node of a doubly linked list.
1346 Returns the first node of a doubly linked list. List must have been
1347 initialized with INTIALIZE_LIST_HEAD_VARIABLE() or InitializeListHead().
1348 If List is empty, then List is returned.
1350 If List is NULL, then ASSERT().
1351 If List was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or
1352 InitializeListHead(), then ASSERT().
1353 If PcdMaximumLinkedListLenth is not zero, and the number of nodes
1354 in List, including the List node, is greater than or equal to
1355 PcdMaximumLinkedListLength, then ASSERT().
1357 @param List A pointer to the head node of a doubly linked list.
1359 @return The first node of a doubly linked list.
1360 @retval NULL The list is empty.
1366 IN CONST LIST_ENTRY
*List
1371 Retrieves the next node of a doubly linked list.
1373 Returns the node of a doubly linked list that follows Node.
1374 List must have been initialized with INTIALIZE_LIST_HEAD_VARIABLE()
1375 or InitializeListHead(). If List is empty, then List is returned.
1377 If List is NULL, then ASSERT().
1378 If Node is NULL, then ASSERT().
1379 If List was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or
1380 InitializeListHead(), then ASSERT().
1381 If PcdMaximumLinkedListLenth is not zero, and List contains more than
1382 PcdMaximumLinkedListLenth nodes, then ASSERT().
1383 If PcdVerifyNodeInList is TRUE and Node is not a node in List, then ASSERT().
1385 @param List A pointer to the head node of a doubly linked list.
1386 @param Node A pointer to a node in the doubly linked list.
1388 @return The pointer to the next node if one exists. Otherwise List is returned.
1394 IN CONST LIST_ENTRY
*List
,
1395 IN CONST LIST_ENTRY
*Node
1400 Retrieves the previous node of a doubly linked list.
1402 Returns the node of a doubly linked list that precedes Node.
1403 List must have been initialized with INTIALIZE_LIST_HEAD_VARIABLE()
1404 or InitializeListHead(). If List is empty, then List is returned.
1406 If List is NULL, then ASSERT().
1407 If Node is NULL, then ASSERT().
1408 If List was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or
1409 InitializeListHead(), then ASSERT().
1410 If PcdMaximumLinkedListLenth is not zero, and List contains more than
1411 PcdMaximumLinkedListLenth nodes, then ASSERT().
1412 If PcdVerifyNodeInList is TRUE and Node is not a node in List, then ASSERT().
1414 @param List A pointer to the head node of a doubly linked list.
1415 @param Node A pointer to a node in the doubly linked list.
1417 @return The pointer to the previous node if one exists. Otherwise List is returned.
1423 IN CONST LIST_ENTRY
*List
,
1424 IN CONST LIST_ENTRY
*Node
1429 Checks to see if a doubly linked list is empty or not.
1431 Checks to see if the doubly linked list is empty. If the linked list contains
1432 zero nodes, this function returns TRUE. Otherwise, it returns FALSE.
1434 If ListHead is NULL, then ASSERT().
1435 If ListHead was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or
1436 InitializeListHead(), then ASSERT().
1437 If PcdMaximumLinkedListLenth is not zero, and the number of nodes
1438 in List, including the List node, is greater than or equal to
1439 PcdMaximumLinkedListLength, then ASSERT().
1441 @param ListHead A pointer to the head node of a doubly linked list.
1443 @retval TRUE The linked list is empty.
1444 @retval FALSE The linked list is not empty.
1450 IN CONST LIST_ENTRY
*ListHead
1455 Determines if a node in a doubly linked list is the head node of a the same
1456 doubly linked list. This function is typically used to terminate a loop that
1457 traverses all the nodes in a doubly linked list starting with the head node.
1459 Returns TRUE if Node is equal to List. Returns FALSE if Node is one of the
1460 nodes in the doubly linked list specified by List. List must have been
1461 initialized with INTIALIZE_LIST_HEAD_VARIABLE() or InitializeListHead().
1463 If List is NULL, then ASSERT().
1464 If Node is NULL, then ASSERT().
1465 If List was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or InitializeListHead(),
1467 If PcdMaximumLinkedListLenth is not zero, and the number of nodes
1468 in List, including the List node, is greater than or equal to
1469 PcdMaximumLinkedListLength, then ASSERT().
1470 If PcdVerifyNodeInList is TRUE and Node is not a node in List the and Node is not equal
1471 to List, then ASSERT().
1473 @param List A pointer to the head node of a doubly linked list.
1474 @param Node A pointer to a node in the doubly linked list.
1476 @retval TRUE Node is the head of the doubly-linked list pointed by List.
1477 @retval FALSE Node is not the head of the doubly-linked list pointed by List.
1483 IN CONST LIST_ENTRY
*List
,
1484 IN CONST LIST_ENTRY
*Node
1489 Determines if a node the last node in a doubly linked list.
1491 Returns TRUE if Node is the last node in the doubly linked list specified by
1492 List. Otherwise, FALSE is returned. List must have been initialized with
1493 INTIALIZE_LIST_HEAD_VARIABLE() or InitializeListHead().
1495 If List is NULL, then ASSERT().
1496 If Node is NULL, then ASSERT().
1497 If List was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or
1498 InitializeListHead(), then ASSERT().
1499 If PcdMaximumLinkedListLenth is not zero, and the number of nodes
1500 in List, including the List node, is greater than or equal to
1501 PcdMaximumLinkedListLength, then ASSERT().
1502 If PcdVerifyNodeInList is TRUE and Node is not a node in List, then ASSERT().
1504 @param List A pointer to the head node of a doubly linked list.
1505 @param Node A pointer to a node in the doubly linked list.
1507 @retval TRUE Node is the last node in the linked list.
1508 @retval FALSE Node is not the last node in the linked list.
1514 IN CONST LIST_ENTRY
*List
,
1515 IN CONST LIST_ENTRY
*Node
1520 Swaps the location of two nodes in a doubly linked list, and returns the
1521 first node after the swap.
1523 If FirstEntry is identical to SecondEntry, then SecondEntry is returned.
1524 Otherwise, the location of the FirstEntry node is swapped with the location
1525 of the SecondEntry node in a doubly linked list. SecondEntry must be in the
1526 same double linked list as FirstEntry and that double linked list must have
1527 been initialized with INTIALIZE_LIST_HEAD_VARIABLE() or InitializeListHead().
1528 SecondEntry is returned after the nodes are swapped.
1530 If FirstEntry is NULL, then ASSERT().
1531 If SecondEntry is NULL, then ASSERT().
1532 If PcdVerifyNodeInList is TRUE and SecondEntry and FirstEntry are not in the
1533 same linked list, then ASSERT().
1534 If PcdMaximumLinkedListLength is not zero, and the number of nodes in the
1535 linked list containing the FirstEntry and SecondEntry nodes, including
1536 the FirstEntry and SecondEntry nodes, is greater than or equal to
1537 PcdMaximumLinkedListLength, then ASSERT().
1539 @param FirstEntry A pointer to a node in a linked list.
1540 @param SecondEntry A pointer to another node in the same linked list.
1542 @return SecondEntry.
1548 IN OUT LIST_ENTRY
*FirstEntry
,
1549 IN OUT LIST_ENTRY
*SecondEntry
1554 Removes a node from a doubly linked list, and returns the node that follows
1557 Removes the node Entry from a doubly linked list. It is up to the caller of
1558 this function to release the memory used by this node if that is required. On
1559 exit, the node following Entry in the doubly linked list is returned. If
1560 Entry is the only node in the linked list, then the head node of the linked
1563 If Entry is NULL, then ASSERT().
1564 If Entry is the head node of an empty list, then ASSERT().
1565 If PcdMaximumLinkedListLength is not zero, and the number of nodes in the
1566 linked list containing Entry, including the Entry node, is greater than
1567 or equal to PcdMaximumLinkedListLength, then ASSERT().
1569 @param Entry A pointer to a node in a linked list.
1577 IN CONST LIST_ENTRY
*Entry
1585 Shifts a 64-bit integer left between 0 and 63 bits. The low bits are filled
1586 with zeros. The shifted value is returned.
1588 This function shifts the 64-bit value Operand to the left by Count bits. The
1589 low Count bits are set to zero. The shifted value is returned.
1591 If Count is greater than 63, then ASSERT().
1593 @param Operand The 64-bit operand to shift left.
1594 @param Count The number of bits to shift left.
1596 @return Operand << Count.
1608 Shifts a 64-bit integer right between 0 and 63 bits. This high bits are
1609 filled with zeros. The shifted value is returned.
1611 This function shifts the 64-bit value Operand to the right by Count bits. The
1612 high Count bits are set to zero. The shifted value is returned.
1614 If Count is greater than 63, then ASSERT().
1616 @param Operand The 64-bit operand to shift right.
1617 @param Count The number of bits to shift right.
1619 @return Operand >> Count
1631 Shifts a 64-bit integer right between 0 and 63 bits. The high bits are filled
1632 with original integer's bit 63. The shifted value is returned.
1634 This function shifts the 64-bit value Operand to the right by Count bits. The
1635 high Count bits are set to bit 63 of Operand. The shifted value is returned.
1637 If Count is greater than 63, then ASSERT().
1639 @param Operand The 64-bit operand to shift right.
1640 @param Count The number of bits to shift right.
1642 @return Operand >> Count
1654 Rotates a 32-bit integer left between 0 and 31 bits, filling the low bits
1655 with the high bits that were rotated.
1657 This function rotates the 32-bit value Operand to the left by Count bits. The
1658 low Count bits are fill with the high Count bits of Operand. The rotated
1661 If Count is greater than 31, then ASSERT().
1663 @param Operand The 32-bit operand to rotate left.
1664 @param Count The number of bits to rotate left.
1666 @return Operand << Count
1678 Rotates a 32-bit integer right between 0 and 31 bits, filling the high bits
1679 with the low bits that were rotated.
1681 This function rotates the 32-bit value Operand to the right by Count bits.
1682 The high Count bits are fill with the low Count bits of Operand. The rotated
1685 If Count is greater than 31, then ASSERT().
1687 @param Operand The 32-bit operand to rotate right.
1688 @param Count The number of bits to rotate right.
1690 @return Operand >> Count
1702 Rotates a 64-bit integer left between 0 and 63 bits, filling the low bits
1703 with the high bits that were rotated.
1705 This function rotates the 64-bit value Operand to the left by Count bits. The
1706 low Count bits are fill with the high Count bits of Operand. The rotated
1709 If Count is greater than 63, then ASSERT().
1711 @param Operand The 64-bit operand to rotate left.
1712 @param Count The number of bits to rotate left.
1714 @return Operand << Count
1726 Rotates a 64-bit integer right between 0 and 63 bits, filling the high bits
1727 with the high low bits that were rotated.
1729 This function rotates the 64-bit value Operand to the right by Count bits.
1730 The high Count bits are fill with the low Count bits of Operand. The rotated
1733 If Count is greater than 63, then ASSERT().
1735 @param Operand The 64-bit operand to rotate right.
1736 @param Count The number of bits to rotate right.
1738 @return Operand >> Count
1750 Returns the bit position of the lowest bit set in a 32-bit value.
1752 This function computes the bit position of the lowest bit set in the 32-bit
1753 value specified by Operand. If Operand is zero, then -1 is returned.
1754 Otherwise, a value between 0 and 31 is returned.
1756 @param Operand The 32-bit operand to evaluate.
1758 @retval 0..31 The lowest bit set in Operand was found.
1759 @retval -1 Operand is zero.
1770 Returns the bit position of the lowest bit set in a 64-bit value.
1772 This function computes the bit position of the lowest bit set in the 64-bit
1773 value specified by Operand. If Operand is zero, then -1 is returned.
1774 Otherwise, a value between 0 and 63 is returned.
1776 @param Operand The 64-bit operand to evaluate.
1778 @retval 0..63 The lowest bit set in Operand was found.
1779 @retval -1 Operand is zero.
1791 Returns the bit position of the highest bit set in a 32-bit value. Equivalent
1794 This function computes the bit position of the highest bit set in the 32-bit
1795 value specified by Operand. If Operand is zero, then -1 is returned.
1796 Otherwise, a value between 0 and 31 is returned.
1798 @param Operand The 32-bit operand to evaluate.
1800 @retval 0..31 Position of the highest bit set in Operand if found.
1801 @retval -1 Operand is zero.
1812 Returns the bit position of the highest bit set in a 64-bit value. Equivalent
1815 This function computes the bit position of the highest bit set in the 64-bit
1816 value specified by Operand. If Operand is zero, then -1 is returned.
1817 Otherwise, a value between 0 and 63 is returned.
1819 @param Operand The 64-bit operand to evaluate.
1821 @retval 0..63 Position of the highest bit set in Operand if found.
1822 @retval -1 Operand is zero.
1833 Returns the value of the highest bit set in a 32-bit value. Equivalent to
1836 This function computes the value of the highest bit set in the 32-bit value
1837 specified by Operand. If Operand is zero, then zero is returned.
1839 @param Operand The 32-bit operand to evaluate.
1841 @return 1 << HighBitSet32(Operand)
1842 @retval 0 Operand is zero.
1853 Returns the value of the highest bit set in a 64-bit value. Equivalent to
1856 This function computes the value of the highest bit set in the 64-bit value
1857 specified by Operand. If Operand is zero, then zero is returned.
1859 @param Operand The 64-bit operand to evaluate.
1861 @return 1 << HighBitSet64(Operand)
1862 @retval 0 Operand is zero.
1873 Switches the endianness of a 16-bit integer.
1875 This function swaps the bytes in a 16-bit unsigned value to switch the value
1876 from little endian to big endian or vice versa. The byte swapped value is
1879 @param Value A 16-bit unsigned value.
1881 @return The byte swapped Value.
1892 Switches the endianness of a 32-bit integer.
1894 This function swaps the bytes in a 32-bit unsigned value to switch the value
1895 from little endian to big endian or vice versa. The byte swapped value is
1898 @param Value A 32-bit unsigned value.
1900 @return The byte swapped Value.
1911 Switches the endianness of a 64-bit integer.
1913 This function swaps the bytes in a 64-bit unsigned value to switch the value
1914 from little endian to big endian or vice versa. The byte swapped value is
1917 @param Value A 64-bit unsigned value.
1919 @return The byte swapped Value.
1930 Multiples a 64-bit unsigned integer by a 32-bit unsigned integer and
1931 generates a 64-bit unsigned result.
1933 This function multiples the 64-bit unsigned value Multiplicand by the 32-bit
1934 unsigned value Multiplier and generates a 64-bit unsigned result. This 64-
1935 bit unsigned result is returned.
1937 @param Multiplicand A 64-bit unsigned value.
1938 @param Multiplier A 32-bit unsigned value.
1940 @return Multiplicand * Multiplier
1946 IN UINT64 Multiplicand
,
1947 IN UINT32 Multiplier
1952 Multiples a 64-bit unsigned integer by a 64-bit unsigned integer and
1953 generates a 64-bit unsigned result.
1955 This function multiples the 64-bit unsigned value Multiplicand by the 64-bit
1956 unsigned value Multiplier and generates a 64-bit unsigned result. This 64-
1957 bit unsigned result is returned.
1959 @param Multiplicand A 64-bit unsigned value.
1960 @param Multiplier A 64-bit unsigned value.
1962 @return Multiplicand * Multiplier.
1968 IN UINT64 Multiplicand
,
1969 IN UINT64 Multiplier
1974 Multiples a 64-bit signed integer by a 64-bit signed integer and generates a
1975 64-bit signed result.
1977 This function multiples the 64-bit signed value Multiplicand by the 64-bit
1978 signed value Multiplier and generates a 64-bit signed result. This 64-bit
1979 signed result is returned.
1981 @param Multiplicand A 64-bit signed value.
1982 @param Multiplier A 64-bit signed value.
1984 @return Multiplicand * Multiplier
1990 IN INT64 Multiplicand
,
1996 Divides a 64-bit unsigned integer by a 32-bit unsigned integer and generates
1997 a 64-bit unsigned result.
1999 This function divides the 64-bit unsigned value Dividend by the 32-bit
2000 unsigned value Divisor and generates a 64-bit unsigned quotient. This
2001 function returns the 64-bit unsigned quotient.
2003 If Divisor is 0, then ASSERT().
2005 @param Dividend A 64-bit unsigned value.
2006 @param Divisor A 32-bit unsigned value.
2008 @return Dividend / Divisor.
2020 Divides a 64-bit unsigned integer by a 32-bit unsigned integer and generates
2021 a 32-bit unsigned remainder.
2023 This function divides the 64-bit unsigned value Dividend by the 32-bit
2024 unsigned value Divisor and generates a 32-bit remainder. This function
2025 returns the 32-bit unsigned remainder.
2027 If Divisor is 0, then ASSERT().
2029 @param Dividend A 64-bit unsigned value.
2030 @param Divisor A 32-bit unsigned value.
2032 @return Dividend % Divisor.
2044 Divides a 64-bit unsigned integer by a 32-bit unsigned integer and generates
2045 a 64-bit unsigned result and an optional 32-bit unsigned remainder.
2047 This function divides the 64-bit unsigned value Dividend by the 32-bit
2048 unsigned value Divisor and generates a 64-bit unsigned quotient. If Remainder
2049 is not NULL, then the 32-bit unsigned remainder is returned in Remainder.
2050 This function returns the 64-bit unsigned quotient.
2052 If Divisor is 0, then ASSERT().
2054 @param Dividend A 64-bit unsigned value.
2055 @param Divisor A 32-bit unsigned value.
2056 @param Remainder A pointer to a 32-bit unsigned value. This parameter is
2057 optional and may be NULL.
2059 @return Dividend / Divisor.
2064 DivU64x32Remainder (
2067 OUT UINT32
*Remainder OPTIONAL
2072 Divides a 64-bit unsigned integer by a 64-bit unsigned integer and generates
2073 a 64-bit unsigned result and an optional 64-bit unsigned remainder.
2075 This function divides the 64-bit unsigned value Dividend by the 64-bit
2076 unsigned value Divisor and generates a 64-bit unsigned quotient. If Remainder
2077 is not NULL, then the 64-bit unsigned remainder is returned in Remainder.
2078 This function returns the 64-bit unsigned quotient.
2080 If Divisor is 0, then ASSERT().
2082 @param Dividend A 64-bit unsigned value.
2083 @param Divisor A 64-bit unsigned value.
2084 @param Remainder A pointer to a 64-bit unsigned value. This parameter is
2085 optional and may be NULL.
2087 @return Dividend / Divisor.
2092 DivU64x64Remainder (
2095 OUT UINT64
*Remainder OPTIONAL
2100 Divides a 64-bit signed integer by a 64-bit signed integer and generates a
2101 64-bit signed result and a optional 64-bit signed remainder.
2103 This function divides the 64-bit signed value Dividend by the 64-bit signed
2104 value Divisor and generates a 64-bit signed quotient. If Remainder is not
2105 NULL, then the 64-bit signed remainder is returned in Remainder. This
2106 function returns the 64-bit signed quotient.
2108 It is the caller's responsibility to not call this function with a Divisor of 0.
2109 If Divisor is 0, then the quotient and remainder should be assumed to be
2110 the largest negative integer.
2112 If Divisor is 0, then ASSERT().
2114 @param Dividend A 64-bit signed value.
2115 @param Divisor A 64-bit signed value.
2116 @param Remainder A pointer to a 64-bit signed value. This parameter is
2117 optional and may be NULL.
2119 @return Dividend / Divisor.
2124 DivS64x64Remainder (
2127 OUT INT64
*Remainder OPTIONAL
2132 Reads a 16-bit value from memory that may be unaligned.
2134 This function returns the 16-bit value pointed to by Buffer. The function
2135 guarantees that the read operation does not produce an alignment fault.
2137 If the Buffer is NULL, then ASSERT().
2139 @param Buffer The pointer to a 16-bit value that may be unaligned.
2141 @return The 16-bit value read from Buffer.
2147 IN CONST UINT16
*Buffer
2152 Writes a 16-bit value to memory that may be unaligned.
2154 This function writes the 16-bit value specified by Value to Buffer. Value is
2155 returned. The function guarantees that the write operation does not produce
2158 If the Buffer is NULL, then ASSERT().
2160 @param Buffer The pointer to a 16-bit value that may be unaligned.
2161 @param Value 16-bit value to write to Buffer.
2163 @return The 16-bit value to write to Buffer.
2175 Reads a 24-bit value from memory that may be unaligned.
2177 This function returns the 24-bit value pointed to by Buffer. The function
2178 guarantees that the read operation does not produce an alignment fault.
2180 If the Buffer is NULL, then ASSERT().
2182 @param Buffer The pointer to a 24-bit value that may be unaligned.
2184 @return The 24-bit value read from Buffer.
2190 IN CONST UINT32
*Buffer
2195 Writes a 24-bit value to memory that may be unaligned.
2197 This function writes the 24-bit value specified by Value to Buffer. Value is
2198 returned. The function guarantees that the write operation does not produce
2201 If the Buffer is NULL, then ASSERT().
2203 @param Buffer The pointer to a 24-bit value that may be unaligned.
2204 @param Value 24-bit value to write to Buffer.
2206 @return The 24-bit value to write to Buffer.
2218 Reads a 32-bit value from memory that may be unaligned.
2220 This function returns the 32-bit value pointed to by Buffer. The function
2221 guarantees that the read operation does not produce an alignment fault.
2223 If the Buffer is NULL, then ASSERT().
2225 @param Buffer The pointer to a 32-bit value that may be unaligned.
2227 @return The 32-bit value read from Buffer.
2233 IN CONST UINT32
*Buffer
2238 Writes a 32-bit value to memory that may be unaligned.
2240 This function writes the 32-bit value specified by Value to Buffer. Value is
2241 returned. The function guarantees that the write operation does not produce
2244 If the Buffer is NULL, then ASSERT().
2246 @param Buffer The pointer to a 32-bit value that may be unaligned.
2247 @param Value 32-bit value to write to Buffer.
2249 @return The 32-bit value to write to Buffer.
2261 Reads a 64-bit value from memory that may be unaligned.
2263 This function returns the 64-bit value pointed to by Buffer. The function
2264 guarantees that the read operation does not produce an alignment fault.
2266 If the Buffer is NULL, then ASSERT().
2268 @param Buffer The pointer to a 64-bit value that may be unaligned.
2270 @return The 64-bit value read from Buffer.
2276 IN CONST UINT64
*Buffer
2281 Writes a 64-bit value to memory that may be unaligned.
2283 This function writes the 64-bit value specified by Value to Buffer. Value is
2284 returned. The function guarantees that the write operation does not produce
2287 If the Buffer is NULL, then ASSERT().
2289 @param Buffer The pointer to a 64-bit value that may be unaligned.
2290 @param Value 64-bit value to write to Buffer.
2292 @return The 64-bit value to write to Buffer.
2304 // Bit Field Functions
2308 Returns a bit field from an 8-bit value.
2310 Returns the bitfield specified by the StartBit and the EndBit from Operand.
2312 If 8-bit operations are not supported, then ASSERT().
2313 If StartBit is greater than 7, then ASSERT().
2314 If EndBit is greater than 7, then ASSERT().
2315 If EndBit is less than StartBit, then ASSERT().
2317 @param Operand Operand on which to perform the bitfield operation.
2318 @param StartBit The ordinal of the least significant bit in the bit field.
2320 @param EndBit The ordinal of the most significant bit in the bit field.
2323 @return The bit field read.
2336 Writes a bit field to an 8-bit value, and returns the result.
2338 Writes Value to the bit field specified by the StartBit and the EndBit in
2339 Operand. All other bits in Operand are preserved. The new 8-bit value is
2342 If 8-bit operations are not supported, then ASSERT().
2343 If StartBit is greater than 7, then ASSERT().
2344 If EndBit is greater than 7, then ASSERT().
2345 If EndBit is less than StartBit, then ASSERT().
2346 If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
2348 @param Operand Operand on which to perform the bitfield operation.
2349 @param StartBit The ordinal of the least significant bit in the bit field.
2351 @param EndBit The ordinal of the most significant bit in the bit field.
2353 @param Value New value of the bit field.
2355 @return The new 8-bit value.
2369 Reads a bit field from an 8-bit value, performs a bitwise OR, and returns the
2372 Performs a bitwise OR between the bit field specified by StartBit
2373 and EndBit in Operand and the value specified by OrData. All other bits in
2374 Operand are preserved. The new 8-bit value is returned.
2376 If 8-bit operations are not supported, then ASSERT().
2377 If StartBit is greater than 7, then ASSERT().
2378 If EndBit is greater than 7, then ASSERT().
2379 If EndBit is less than StartBit, then ASSERT().
2380 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
2382 @param Operand Operand on which to perform the bitfield operation.
2383 @param StartBit The ordinal of the least significant bit in the bit field.
2385 @param EndBit The ordinal of the most significant bit in the bit field.
2387 @param OrData The value to OR with the read value from the value
2389 @return The new 8-bit value.
2403 Reads a bit field from an 8-bit value, performs a bitwise AND, and returns
2406 Performs a bitwise AND between the bit field specified by StartBit and EndBit
2407 in Operand and the value specified by AndData. All other bits in Operand are
2408 preserved. The new 8-bit value is returned.
2410 If 8-bit operations are not supported, then ASSERT().
2411 If StartBit is greater than 7, then ASSERT().
2412 If EndBit is greater than 7, then ASSERT().
2413 If EndBit is less than StartBit, then ASSERT().
2414 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
2416 @param Operand Operand on which to perform the bitfield operation.
2417 @param StartBit The ordinal of the least significant bit in the bit field.
2419 @param EndBit The ordinal of the most significant bit in the bit field.
2421 @param AndData The value to AND with the read value from the value.
2423 @return The new 8-bit value.
2437 Reads a bit field from an 8-bit value, performs a bitwise AND followed by a
2438 bitwise OR, and returns the result.
2440 Performs a bitwise AND between the bit field specified by StartBit and EndBit
2441 in Operand and the value specified by AndData, followed by a bitwise
2442 OR with value specified by OrData. All other bits in Operand are
2443 preserved. The new 8-bit value is returned.
2445 If 8-bit operations are not supported, then ASSERT().
2446 If StartBit is greater than 7, then ASSERT().
2447 If EndBit is greater than 7, then ASSERT().
2448 If EndBit is less than StartBit, then ASSERT().
2449 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
2450 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
2452 @param Operand Operand on which to perform the bitfield operation.
2453 @param StartBit The ordinal of the least significant bit in the bit field.
2455 @param EndBit The ordinal of the most significant bit in the bit field.
2457 @param AndData The value to AND with the read value from the value.
2458 @param OrData The value to OR with the result of the AND operation.
2460 @return The new 8-bit value.
2465 BitFieldAndThenOr8 (
2475 Returns a bit field from a 16-bit value.
2477 Returns the bitfield specified by the StartBit and the EndBit from Operand.
2479 If 16-bit operations are not supported, then ASSERT().
2480 If StartBit is greater than 15, then ASSERT().
2481 If EndBit is greater than 15, then ASSERT().
2482 If EndBit is less than StartBit, then ASSERT().
2484 @param Operand Operand on which to perform the bitfield operation.
2485 @param StartBit The ordinal of the least significant bit in the bit field.
2487 @param EndBit The ordinal of the most significant bit in the bit field.
2490 @return The bit field read.
2503 Writes a bit field to a 16-bit value, and returns the result.
2505 Writes Value to the bit field specified by the StartBit and the EndBit in
2506 Operand. All other bits in Operand are preserved. The new 16-bit value is
2509 If 16-bit operations are not supported, then ASSERT().
2510 If StartBit is greater than 15, then ASSERT().
2511 If EndBit is greater than 15, then ASSERT().
2512 If EndBit is less than StartBit, then ASSERT().
2513 If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
2515 @param Operand Operand on which to perform the bitfield operation.
2516 @param StartBit The ordinal of the least significant bit in the bit field.
2518 @param EndBit The ordinal of the most significant bit in the bit field.
2520 @param Value New value of the bit field.
2522 @return The new 16-bit value.
2536 Reads a bit field from a 16-bit value, performs a bitwise OR, and returns the
2539 Performs a bitwise OR between the bit field specified by StartBit
2540 and EndBit in Operand and the value specified by OrData. All other bits in
2541 Operand are preserved. The new 16-bit value is returned.
2543 If 16-bit operations are not supported, then ASSERT().
2544 If StartBit is greater than 15, then ASSERT().
2545 If EndBit is greater than 15, then ASSERT().
2546 If EndBit is less than StartBit, then ASSERT().
2547 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
2549 @param Operand Operand on which to perform the bitfield operation.
2550 @param StartBit The ordinal of the least significant bit in the bit field.
2552 @param EndBit The ordinal of the most significant bit in the bit field.
2554 @param OrData The value to OR with the read value from the value
2556 @return The new 16-bit value.
2570 Reads a bit field from a 16-bit value, performs a bitwise AND, and returns
2573 Performs a bitwise AND between the bit field specified by StartBit and EndBit
2574 in Operand and the value specified by AndData. All other bits in Operand are
2575 preserved. The new 16-bit value is returned.
2577 If 16-bit operations are not supported, then ASSERT().
2578 If StartBit is greater than 15, then ASSERT().
2579 If EndBit is greater than 15, then ASSERT().
2580 If EndBit is less than StartBit, then ASSERT().
2581 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
2583 @param Operand Operand on which to perform the bitfield operation.
2584 @param StartBit The ordinal of the least significant bit in the bit field.
2586 @param EndBit The ordinal of the most significant bit in the bit field.
2588 @param AndData The value to AND with the read value from the value
2590 @return The new 16-bit value.
2604 Reads a bit field from a 16-bit value, performs a bitwise AND followed by a
2605 bitwise OR, and returns the result.
2607 Performs a bitwise AND between the bit field specified by StartBit and EndBit
2608 in Operand and the value specified by AndData, followed by a bitwise
2609 OR with value specified by OrData. All other bits in Operand are
2610 preserved. The new 16-bit value is returned.
2612 If 16-bit operations are not supported, then ASSERT().
2613 If StartBit is greater than 15, then ASSERT().
2614 If EndBit is greater than 15, then ASSERT().
2615 If EndBit is less than StartBit, then ASSERT().
2616 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
2617 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
2619 @param Operand Operand on which to perform the bitfield operation.
2620 @param StartBit The ordinal of the least significant bit in the bit field.
2622 @param EndBit The ordinal of the most significant bit in the bit field.
2624 @param AndData The value to AND with the read value from the value.
2625 @param OrData The value to OR with the result of the AND operation.
2627 @return The new 16-bit value.
2632 BitFieldAndThenOr16 (
2642 Returns a bit field from a 32-bit value.
2644 Returns the bitfield specified by the StartBit and the EndBit from Operand.
2646 If 32-bit operations are not supported, then ASSERT().
2647 If StartBit is greater than 31, then ASSERT().
2648 If EndBit is greater than 31, then ASSERT().
2649 If EndBit is less than StartBit, then ASSERT().
2651 @param Operand Operand on which to perform the bitfield operation.
2652 @param StartBit The ordinal of the least significant bit in the bit field.
2654 @param EndBit The ordinal of the most significant bit in the bit field.
2657 @return The bit field read.
2670 Writes a bit field to a 32-bit value, and returns the result.
2672 Writes Value to the bit field specified by the StartBit and the EndBit in
2673 Operand. All other bits in Operand are preserved. The new 32-bit value is
2676 If 32-bit operations are not supported, then ASSERT().
2677 If StartBit is greater than 31, then ASSERT().
2678 If EndBit is greater than 31, then ASSERT().
2679 If EndBit is less than StartBit, then ASSERT().
2680 If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
2682 @param Operand Operand on which to perform the bitfield operation.
2683 @param StartBit The ordinal of the least significant bit in the bit field.
2685 @param EndBit The ordinal of the most significant bit in the bit field.
2687 @param Value New value of the bit field.
2689 @return The new 32-bit value.
2703 Reads a bit field from a 32-bit value, performs a bitwise OR, and returns the
2706 Performs a bitwise OR between the bit field specified by StartBit
2707 and EndBit in Operand and the value specified by OrData. All other bits in
2708 Operand are preserved. The new 32-bit value is returned.
2710 If 32-bit operations are not supported, then ASSERT().
2711 If StartBit is greater than 31, then ASSERT().
2712 If EndBit is greater than 31, then ASSERT().
2713 If EndBit is less than StartBit, then ASSERT().
2714 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
2716 @param Operand Operand on which to perform the bitfield operation.
2717 @param StartBit The ordinal of the least significant bit in the bit field.
2719 @param EndBit The ordinal of the most significant bit in the bit field.
2721 @param OrData The value to OR with the read value from the value.
2723 @return The new 32-bit value.
2737 Reads a bit field from a 32-bit value, performs a bitwise AND, and returns
2740 Performs a bitwise AND between the bit field specified by StartBit and EndBit
2741 in Operand and the value specified by AndData. All other bits in Operand are
2742 preserved. The new 32-bit value is returned.
2744 If 32-bit operations are not supported, then ASSERT().
2745 If StartBit is greater than 31, then ASSERT().
2746 If EndBit is greater than 31, then ASSERT().
2747 If EndBit is less than StartBit, then ASSERT().
2748 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
2750 @param Operand Operand on which to perform the bitfield operation.
2751 @param StartBit The ordinal of the least significant bit in the bit field.
2753 @param EndBit The ordinal of the most significant bit in the bit field.
2755 @param AndData The value to AND with the read value from the value
2757 @return The new 32-bit value.
2771 Reads a bit field from a 32-bit value, performs a bitwise AND followed by a
2772 bitwise OR, and returns the result.
2774 Performs a bitwise AND between the bit field specified by StartBit and EndBit
2775 in Operand and the value specified by AndData, followed by a bitwise
2776 OR with value specified by OrData. All other bits in Operand are
2777 preserved. The new 32-bit value is returned.
2779 If 32-bit operations are not supported, then ASSERT().
2780 If StartBit is greater than 31, then ASSERT().
2781 If EndBit is greater than 31, then ASSERT().
2782 If EndBit is less than StartBit, then ASSERT().
2783 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
2784 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
2786 @param Operand Operand on which to perform the bitfield operation.
2787 @param StartBit The ordinal of the least significant bit in the bit field.
2789 @param EndBit The ordinal of the most significant bit in the bit field.
2791 @param AndData The value to AND with the read value from the value.
2792 @param OrData The value to OR with the result of the AND operation.
2794 @return The new 32-bit value.
2799 BitFieldAndThenOr32 (
2809 Returns a bit field from a 64-bit value.
2811 Returns the bitfield specified by the StartBit and the EndBit from Operand.
2813 If 64-bit operations are not supported, then ASSERT().
2814 If StartBit is greater than 63, then ASSERT().
2815 If EndBit is greater than 63, then ASSERT().
2816 If EndBit is less than StartBit, then ASSERT().
2818 @param Operand Operand on which to perform the bitfield operation.
2819 @param StartBit The ordinal of the least significant bit in the bit field.
2821 @param EndBit The ordinal of the most significant bit in the bit field.
2824 @return The bit field read.
2837 Writes a bit field to a 64-bit value, and returns the result.
2839 Writes Value to the bit field specified by the StartBit and the EndBit in
2840 Operand. All other bits in Operand are preserved. The new 64-bit value is
2843 If 64-bit operations are not supported, then ASSERT().
2844 If StartBit is greater than 63, then ASSERT().
2845 If EndBit is greater than 63, then ASSERT().
2846 If EndBit is less than StartBit, then ASSERT().
2847 If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
2849 @param Operand Operand on which to perform the bitfield operation.
2850 @param StartBit The ordinal of the least significant bit in the bit field.
2852 @param EndBit The ordinal of the most significant bit in the bit field.
2854 @param Value New value of the bit field.
2856 @return The new 64-bit value.
2870 Reads a bit field from a 64-bit value, performs a bitwise OR, and returns the
2873 Performs a bitwise OR between the bit field specified by StartBit
2874 and EndBit in Operand and the value specified by OrData. All other bits in
2875 Operand are preserved. The new 64-bit value is returned.
2877 If 64-bit operations are not supported, then ASSERT().
2878 If StartBit is greater than 63, then ASSERT().
2879 If EndBit is greater than 63, then ASSERT().
2880 If EndBit is less than StartBit, then ASSERT().
2881 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
2883 @param Operand Operand on which to perform the bitfield operation.
2884 @param StartBit The ordinal of the least significant bit in the bit field.
2886 @param EndBit The ordinal of the most significant bit in the bit field.
2888 @param OrData The value to OR with the read value from the value
2890 @return The new 64-bit value.
2904 Reads a bit field from a 64-bit value, performs a bitwise AND, and returns
2907 Performs a bitwise AND between the bit field specified by StartBit and EndBit
2908 in Operand and the value specified by AndData. All other bits in Operand are
2909 preserved. The new 64-bit value is returned.
2911 If 64-bit operations are not supported, then ASSERT().
2912 If StartBit is greater than 63, then ASSERT().
2913 If EndBit is greater than 63, then ASSERT().
2914 If EndBit is less than StartBit, then ASSERT().
2915 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
2917 @param Operand Operand on which to perform the bitfield operation.
2918 @param StartBit The ordinal of the least significant bit in the bit field.
2920 @param EndBit The ordinal of the most significant bit in the bit field.
2922 @param AndData The value to AND with the read value from the value
2924 @return The new 64-bit value.
2938 Reads a bit field from a 64-bit value, performs a bitwise AND followed by a
2939 bitwise OR, and returns the result.
2941 Performs a bitwise AND between the bit field specified by StartBit and EndBit
2942 in Operand and the value specified by AndData, followed by a bitwise
2943 OR with value specified by OrData. All other bits in Operand are
2944 preserved. The new 64-bit value is returned.
2946 If 64-bit operations are not supported, then ASSERT().
2947 If StartBit is greater than 63, then ASSERT().
2948 If EndBit is greater than 63, then ASSERT().
2949 If EndBit is less than StartBit, then ASSERT().
2950 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
2951 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
2953 @param Operand Operand on which to perform the bitfield operation.
2954 @param StartBit The ordinal of the least significant bit in the bit field.
2956 @param EndBit The ordinal of the most significant bit in the bit field.
2958 @param AndData The value to AND with the read value from the value.
2959 @param OrData The value to OR with the result of the AND operation.
2961 @return The new 64-bit value.
2966 BitFieldAndThenOr64 (
2975 // Base Library Checksum Functions
2979 Returns the sum of all elements in a buffer in unit of UINT8.
2980 During calculation, the carry bits are dropped.
2982 This function calculates the sum of all elements in a buffer
2983 in unit of UINT8. The carry bits in result of addition are dropped.
2984 The result is returned as UINT8. If Length is Zero, then Zero is
2987 If Buffer is NULL, then ASSERT().
2988 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
2990 @param Buffer The pointer to the buffer to carry out the sum operation.
2991 @param Length The size, in bytes, of Buffer.
2993 @return Sum The sum of Buffer with carry bits dropped during additions.
2999 IN CONST UINT8
*Buffer
,
3005 Returns the two's complement checksum of all elements in a buffer
3008 This function first calculates the sum of the 8-bit values in the
3009 buffer specified by Buffer and Length. The carry bits in the result
3010 of addition are dropped. Then, the two's complement of the sum is
3011 returned. If Length is 0, then 0 is returned.
3013 If Buffer is NULL, then ASSERT().
3014 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
3016 @param Buffer The pointer to the buffer to carry out the checksum operation.
3017 @param Length The size, in bytes, of Buffer.
3019 @return Checksum The two's complement checksum of Buffer.
3024 CalculateCheckSum8 (
3025 IN CONST UINT8
*Buffer
,
3031 Returns the sum of all elements in a buffer of 16-bit values. During
3032 calculation, the carry bits are dropped.
3034 This function calculates the sum of the 16-bit values in the buffer
3035 specified by Buffer and Length. The carry bits in result of addition are dropped.
3036 The 16-bit result is returned. If Length is 0, then 0 is returned.
3038 If Buffer is NULL, then ASSERT().
3039 If Buffer is not aligned on a 16-bit boundary, then ASSERT().
3040 If Length is not aligned on a 16-bit boundary, then ASSERT().
3041 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
3043 @param Buffer The pointer to the buffer to carry out the sum operation.
3044 @param Length The size, in bytes, of Buffer.
3046 @return Sum The sum of Buffer with carry bits dropped during additions.
3052 IN CONST UINT16
*Buffer
,
3058 Returns the two's complement checksum of all elements in a buffer of
3061 This function first calculates the sum of the 16-bit values in the buffer
3062 specified by Buffer and Length. The carry bits in the result of addition
3063 are dropped. Then, the two's complement of the sum is returned. If Length
3064 is 0, then 0 is returned.
3066 If Buffer is NULL, then ASSERT().
3067 If Buffer is not aligned on a 16-bit boundary, then ASSERT().
3068 If Length is not aligned on a 16-bit boundary, then ASSERT().
3069 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
3071 @param Buffer The pointer to the buffer to carry out the checksum operation.
3072 @param Length The size, in bytes, of Buffer.
3074 @return Checksum The two's complement checksum of Buffer.
3079 CalculateCheckSum16 (
3080 IN CONST UINT16
*Buffer
,
3086 Returns the sum of all elements in a buffer of 32-bit values. During
3087 calculation, the carry bits are dropped.
3089 This function calculates the sum of the 32-bit values in the buffer
3090 specified by Buffer and Length. The carry bits in result of addition are dropped.
3091 The 32-bit result is returned. If Length is 0, then 0 is returned.
3093 If Buffer is NULL, then ASSERT().
3094 If Buffer is not aligned on a 32-bit boundary, then ASSERT().
3095 If Length is not aligned on a 32-bit boundary, then ASSERT().
3096 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
3098 @param Buffer The pointer to the buffer to carry out the sum operation.
3099 @param Length The size, in bytes, of Buffer.
3101 @return Sum The sum of Buffer with carry bits dropped during additions.
3107 IN CONST UINT32
*Buffer
,
3113 Returns the two's complement checksum of all elements in a buffer of
3116 This function first calculates the sum of the 32-bit values in the buffer
3117 specified by Buffer and Length. The carry bits in the result of addition
3118 are dropped. Then, the two's complement of the sum is returned. If Length
3119 is 0, then 0 is returned.
3121 If Buffer is NULL, then ASSERT().
3122 If Buffer is not aligned on a 32-bit boundary, then ASSERT().
3123 If Length is not aligned on a 32-bit boundary, then ASSERT().
3124 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
3126 @param Buffer The pointer to the buffer to carry out the checksum operation.
3127 @param Length The size, in bytes, of Buffer.
3129 @return Checksum The two's complement checksum of Buffer.
3134 CalculateCheckSum32 (
3135 IN CONST UINT32
*Buffer
,
3141 Returns the sum of all elements in a buffer of 64-bit values. During
3142 calculation, the carry bits are dropped.
3144 This function calculates the sum of the 64-bit values in the buffer
3145 specified by Buffer and Length. The carry bits in result of addition are dropped.
3146 The 64-bit result is returned. If Length is 0, then 0 is returned.
3148 If Buffer is NULL, then ASSERT().
3149 If Buffer is not aligned on a 64-bit boundary, then ASSERT().
3150 If Length is not aligned on a 64-bit boundary, then ASSERT().
3151 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
3153 @param Buffer The pointer to the buffer to carry out the sum operation.
3154 @param Length The size, in bytes, of Buffer.
3156 @return Sum The sum of Buffer with carry bits dropped during additions.
3162 IN CONST UINT64
*Buffer
,
3168 Returns the two's complement checksum of all elements in a buffer of
3171 This function first calculates the sum of the 64-bit values in the buffer
3172 specified by Buffer and Length. The carry bits in the result of addition
3173 are dropped. Then, the two's complement of the sum is returned. If Length
3174 is 0, then 0 is returned.
3176 If Buffer is NULL, then ASSERT().
3177 If Buffer is not aligned on a 64-bit boundary, then ASSERT().
3178 If Length is not aligned on a 64-bit boundary, then ASSERT().
3179 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
3181 @param Buffer The pointer to the buffer to carry out the checksum operation.
3182 @param Length The size, in bytes, of Buffer.
3184 @return Checksum The two's complement checksum of Buffer.
3189 CalculateCheckSum64 (
3190 IN CONST UINT64
*Buffer
,
3196 // Base Library CPU Functions
3200 Function entry point used when a stack switch is requested with SwitchStack()
3202 @param Context1 Context1 parameter passed into SwitchStack().
3203 @param Context2 Context2 parameter passed into SwitchStack().
3208 (EFIAPI
*SWITCH_STACK_ENTRY_POINT
)(
3209 IN VOID
*Context1
, OPTIONAL
3210 IN VOID
*Context2 OPTIONAL
3215 Used to serialize load and store operations.
3217 All loads and stores that proceed calls to this function are guaranteed to be
3218 globally visible when this function returns.
3229 Saves the current CPU context that can be restored with a call to LongJump()
3232 Saves the current CPU context in the buffer specified by JumpBuffer and
3233 returns 0. The initial call to SetJump() must always return 0. Subsequent
3234 calls to LongJump() cause a non-zero value to be returned by SetJump().
3236 If JumpBuffer is NULL, then ASSERT().
3237 For Itanium processors, if JumpBuffer is not aligned on a 16-byte boundary, then ASSERT().
3239 NOTE: The structure BASE_LIBRARY_JUMP_BUFFER is CPU architecture specific.
3240 The same structure must never be used for more than one CPU architecture context.
3241 For example, a BASE_LIBRARY_JUMP_BUFFER allocated by an IA-32 module must never be used from an x64 module.
3242 SetJump()/LongJump() is not currently supported for the EBC processor type.
3244 @param JumpBuffer A pointer to CPU context buffer.
3246 @retval 0 Indicates a return from SetJump().
3252 OUT BASE_LIBRARY_JUMP_BUFFER
*JumpBuffer
3257 Restores the CPU context that was saved with SetJump().
3259 Restores the CPU context from the buffer specified by JumpBuffer. This
3260 function never returns to the caller. Instead is resumes execution based on
3261 the state of JumpBuffer.
3263 If JumpBuffer is NULL, then ASSERT().
3264 For Itanium processors, if JumpBuffer is not aligned on a 16-byte boundary, then ASSERT().
3265 If Value is 0, then ASSERT().
3267 @param JumpBuffer A pointer to CPU context buffer.
3268 @param Value The value to return when the SetJump() context is
3269 restored and must be non-zero.
3275 IN BASE_LIBRARY_JUMP_BUFFER
*JumpBuffer
,
3281 Enables CPU interrupts.
3292 Disables CPU interrupts.
3303 Disables CPU interrupts and returns the interrupt state prior to the disable
3306 @retval TRUE CPU interrupts were enabled on entry to this call.
3307 @retval FALSE CPU interrupts were disabled on entry to this call.
3312 SaveAndDisableInterrupts (
3318 Enables CPU interrupts for the smallest window required to capture any
3324 EnableDisableInterrupts (
3330 Retrieves the current CPU interrupt state.
3332 Returns TRUE if interrupts are currently enabled. Otherwise
3335 @retval TRUE CPU interrupts are enabled.
3336 @retval FALSE CPU interrupts are disabled.
3347 Set the current CPU interrupt state.
3349 Sets the current CPU interrupt state to the state specified by
3350 InterruptState. If InterruptState is TRUE, then interrupts are enabled. If
3351 InterruptState is FALSE, then interrupts are disabled. InterruptState is
3354 @param InterruptState TRUE if interrupts should enabled. FALSE if
3355 interrupts should be disabled.
3357 @return InterruptState
3363 IN BOOLEAN InterruptState
3368 Requests CPU to pause for a short period of time.
3370 Requests CPU to pause for a short period of time. Typically used in MP
3371 systems to prevent memory starvation while waiting for a spin lock.
3382 Transfers control to a function starting with a new stack.
3384 Transfers control to the function specified by EntryPoint using the
3385 new stack specified by NewStack and passing in the parameters specified
3386 by Context1 and Context2. Context1 and Context2 are optional and may
3387 be NULL. The function EntryPoint must never return. This function
3388 supports a variable number of arguments following the NewStack parameter.
3389 These additional arguments are ignored on IA-32, x64, and EBC architectures.
3390 Itanium processors expect one additional parameter of type VOID * that specifies
3391 the new backing store pointer.
3393 If EntryPoint is NULL, then ASSERT().
3394 If NewStack is NULL, then ASSERT().
3396 @param EntryPoint A pointer to function to call with the new stack.
3397 @param Context1 A pointer to the context to pass into the EntryPoint
3399 @param Context2 A pointer to the context to pass into the EntryPoint
3401 @param NewStack A pointer to the new stack to use for the EntryPoint
3403 @param ... This variable argument list is ignored for IA-32, x64, and
3404 EBC architectures. For Itanium processors, this variable
3405 argument list is expected to contain a single parameter of
3406 type VOID * that specifies the new backing store pointer.
3413 IN SWITCH_STACK_ENTRY_POINT EntryPoint
,
3414 IN VOID
*Context1
, OPTIONAL
3415 IN VOID
*Context2
, OPTIONAL
3422 Generates a breakpoint on the CPU.
3424 Generates a breakpoint on the CPU. The breakpoint must be implemented such
3425 that code can resume normal execution after the breakpoint.
3436 Executes an infinite loop.
3438 Forces the CPU to execute an infinite loop. A debugger may be used to skip
3439 past the loop and the code that follows the loop must execute properly. This
3440 implies that the infinite loop must not cause the code that follow it to be
3450 #if defined (MDE_CPU_IPF)
3453 Flush a range of cache lines in the cache coherency domain of the calling
3456 Flushes the cache lines specified by Address and Length. If Address is not aligned
3457 on a cache line boundary, then entire cache line containing Address is flushed.
3458 If Address + Length is not aligned on a cache line boundary, then the entire cache
3459 line containing Address + Length - 1 is flushed. This function may choose to flush
3460 the entire cache if that is more efficient than flushing the specified range. If
3461 Length is 0, the no cache lines are flushed. Address is returned.
3462 This function is only available on Itanium processors.
3464 If Length is greater than (MAX_ADDRESS - Address + 1), then ASSERT().
3466 @param Address The base address of the instruction lines to invalidate. If
3467 the CPU is in a physical addressing mode, then Address is a
3468 physical address. If the CPU is in a virtual addressing mode,
3469 then Address is a virtual address.
3471 @param Length The number of bytes to invalidate from the instruction cache.
3478 AsmFlushCacheRange (
3485 Executes an FC instruction.
3486 Executes an FC instruction on the cache line specified by Address.
3487 The cache line size affected is at least 32-bytes (aligned on a 32-byte boundary).
3488 An implementation may flush a larger region. This function is only available on Itanium processors.
3490 @param Address The Address of cache line to be flushed.
3492 @return The address of FC instruction executed.
3503 Executes an FC.I instruction.
3504 Executes an FC.I instruction on the cache line specified by Address.
3505 The cache line size affected is at least 32-bytes (aligned on a 32-byte boundary).
3506 An implementation may flush a larger region. This function is only available on Itanium processors.
3508 @param Address The Address of cache line to be flushed.
3510 @return The address of the FC.I instruction executed.
3521 Reads the current value of a Processor Identifier Register (CPUID).
3523 Reads and returns the current value of Processor Identifier Register specified by Index.
3524 The Index of largest implemented CPUID (One less than the number of implemented CPUID
3525 registers) is determined by CPUID [3] bits {7:0}.
3526 No parameter checking is performed on Index. If the Index value is beyond the
3527 implemented CPUID register range, a Reserved Register/Field fault may occur. The caller
3528 must either guarantee that Index is valid, or the caller must set up fault handlers to
3529 catch the faults. This function is only available on Itanium processors.
3531 @param Index The 8-bit Processor Identifier Register index to read.
3533 @return The current value of Processor Identifier Register specified by Index.
3544 Reads the current value of 64-bit Processor Status Register (PSR).
3545 This function is only available on Itanium processors.
3547 @return The current value of PSR.
3558 Writes the current value of 64-bit Processor Status Register (PSR).
3560 No parameter checking is performed on Value. All bits of Value corresponding to
3561 reserved fields of PSR must be 0 or a Reserved Register/Field fault may occur.
3562 The caller must either guarantee that Value is valid, or the caller must set up
3563 fault handlers to catch the faults. This function is only available on Itanium processors.
3565 @param Value The 64-bit value to write to PSR.
3567 @return The 64-bit value written to the PSR.
3578 Reads the current value of 64-bit Kernel Register #0 (KR0).
3580 Reads and returns the current value of KR0.
3581 This function is only available on Itanium processors.
3583 @return The current value of KR0.
3594 Reads the current value of 64-bit Kernel Register #1 (KR1).
3596 Reads and returns the current value of KR1.
3597 This function is only available on Itanium processors.
3599 @return The current value of KR1.
3610 Reads the current value of 64-bit Kernel Register #2 (KR2).
3612 Reads and returns the current value of KR2.
3613 This function is only available on Itanium processors.
3615 @return The current value of KR2.
3626 Reads the current value of 64-bit Kernel Register #3 (KR3).
3628 Reads and returns the current value of KR3.
3629 This function is only available on Itanium processors.
3631 @return The current value of KR3.
3642 Reads the current value of 64-bit Kernel Register #4 (KR4).
3644 Reads and returns the current value of KR4.
3645 This function is only available on Itanium processors.
3647 @return The current value of KR4.
3658 Reads the current value of 64-bit Kernel Register #5 (KR5).
3660 Reads and returns the current value of KR5.
3661 This function is only available on Itanium processors.
3663 @return The current value of KR5.
3674 Reads the current value of 64-bit Kernel Register #6 (KR6).
3676 Reads and returns the current value of KR6.
3677 This function is only available on Itanium processors.
3679 @return The current value of KR6.
3690 Reads the current value of 64-bit Kernel Register #7 (KR7).
3692 Reads and returns the current value of KR7.
3693 This function is only available on Itanium processors.
3695 @return The current value of KR7.
3706 Write the current value of 64-bit Kernel Register #0 (KR0).
3708 Writes the current value of KR0. The 64-bit value written to
3709 the KR0 is returned. This function is only available on Itanium processors.
3711 @param Value The 64-bit value to write to KR0.
3713 @return The 64-bit value written to the KR0.
3724 Write the current value of 64-bit Kernel Register #1 (KR1).
3726 Writes the current value of KR1. The 64-bit value written to
3727 the KR1 is returned. This function is only available on Itanium processors.
3729 @param Value The 64-bit value to write to KR1.
3731 @return The 64-bit value written to the KR1.
3742 Write the current value of 64-bit Kernel Register #2 (KR2).
3744 Writes the current value of KR2. The 64-bit value written to
3745 the KR2 is returned. This function is only available on Itanium processors.
3747 @param Value The 64-bit value to write to KR2.
3749 @return The 64-bit value written to the KR2.
3760 Write the current value of 64-bit Kernel Register #3 (KR3).
3762 Writes the current value of KR3. The 64-bit value written to
3763 the KR3 is returned. This function is only available on Itanium processors.
3765 @param Value The 64-bit value to write to KR3.
3767 @return The 64-bit value written to the KR3.
3778 Write the current value of 64-bit Kernel Register #4 (KR4).
3780 Writes the current value of KR4. The 64-bit value written to
3781 the KR4 is returned. This function is only available on Itanium processors.
3783 @param Value The 64-bit value to write to KR4.
3785 @return The 64-bit value written to the KR4.
3796 Write the current value of 64-bit Kernel Register #5 (KR5).
3798 Writes the current value of KR5. The 64-bit value written to
3799 the KR5 is returned. This function is only available on Itanium processors.
3801 @param Value The 64-bit value to write to KR5.
3803 @return The 64-bit value written to the KR5.
3814 Write the current value of 64-bit Kernel Register #6 (KR6).
3816 Writes the current value of KR6. The 64-bit value written to
3817 the KR6 is returned. This function is only available on Itanium processors.
3819 @param Value The 64-bit value to write to KR6.
3821 @return The 64-bit value written to the KR6.
3832 Write the current value of 64-bit Kernel Register #7 (KR7).
3834 Writes the current value of KR7. The 64-bit value written to
3835 the KR7 is returned. This function is only available on Itanium processors.
3837 @param Value The 64-bit value to write to KR7.
3839 @return The 64-bit value written to the KR7.
3850 Reads the current value of Interval Timer Counter Register (ITC).
3852 Reads and returns the current value of ITC.
3853 This function is only available on Itanium processors.
3855 @return The current value of ITC.
3866 Reads the current value of Interval Timer Vector Register (ITV).
3868 Reads and returns the current value of ITV.
3869 This function is only available on Itanium processors.
3871 @return The current value of ITV.
3882 Reads the current value of Interval Timer Match Register (ITM).
3884 Reads and returns the current value of ITM.
3885 This function is only available on Itanium processors.
3887 @return The current value of ITM.
3897 Writes the current value of 64-bit Interval Timer Counter Register (ITC).
3899 Writes the current value of ITC. The 64-bit value written to the ITC is returned.
3900 This function is only available on Itanium processors.
3902 @param Value The 64-bit value to write to ITC.
3904 @return The 64-bit value written to the ITC.
3915 Writes the current value of 64-bit Interval Timer Match Register (ITM).
3917 Writes the current value of ITM. The 64-bit value written to the ITM is returned.
3918 This function is only available on Itanium processors.
3920 @param Value The 64-bit value to write to ITM.
3922 @return The 64-bit value written to the ITM.
3933 Writes the current value of 64-bit Interval Timer Vector Register (ITV).
3935 Writes the current value of ITV. The 64-bit value written to the ITV is returned.
3936 No parameter checking is performed on Value. All bits of Value corresponding to
3937 reserved fields of ITV must be 0 or a Reserved Register/Field fault may occur.
3938 The caller must either guarantee that Value is valid, or the caller must set up
3939 fault handlers to catch the faults.
3940 This function is only available on Itanium processors.
3942 @param Value The 64-bit value to write to ITV.
3944 @return The 64-bit value written to the ITV.
3955 Reads the current value of Default Control Register (DCR).
3957 Reads and returns the current value of DCR. This function is only available on Itanium processors.
3959 @return The current value of DCR.
3970 Reads the current value of Interruption Vector Address Register (IVA).
3972 Reads and returns the current value of IVA. This function is only available on Itanium processors.
3974 @return The current value of IVA.
3984 Reads the current value of Page Table Address Register (PTA).
3986 Reads and returns the current value of PTA. This function is only available on Itanium processors.
3988 @return The current value of PTA.
3999 Writes the current value of 64-bit Default Control Register (DCR).
4001 Writes the current value of DCR. The 64-bit value written to the DCR is returned.
4002 No parameter checking is performed on Value. All bits of Value corresponding to
4003 reserved fields of DCR must be 0 or a Reserved Register/Field fault may occur.
4004 The caller must either guarantee that Value is valid, or the caller must set up
4005 fault handlers to catch the faults.
4006 This function is only available on Itanium processors.
4008 @param Value The 64-bit value to write to DCR.
4010 @return The 64-bit value written to the DCR.
4021 Writes the current value of 64-bit Interruption Vector Address Register (IVA).
4023 Writes the current value of IVA. The 64-bit value written to the IVA is returned.
4024 The size of vector table is 32 K bytes and is 32 K bytes aligned
4025 the low 15 bits of Value is ignored when written.
4026 This function is only available on Itanium processors.
4028 @param Value The 64-bit value to write to IVA.
4030 @return The 64-bit value written to the IVA.
4041 Writes the current value of 64-bit Page Table Address Register (PTA).
4043 Writes the current value of PTA. The 64-bit value written to the PTA is returned.
4044 No parameter checking is performed on Value. All bits of Value corresponding to
4045 reserved fields of DCR must be 0 or a Reserved Register/Field fault may occur.
4046 The caller must either guarantee that Value is valid, or the caller must set up
4047 fault handlers to catch the faults.
4048 This function is only available on Itanium processors.
4050 @param Value The 64-bit value to write to PTA.
4052 @return The 64-bit value written to the PTA.
4062 Reads the current value of Local Interrupt ID Register (LID).
4064 Reads and returns the current value of LID. This function is only available on Itanium processors.
4066 @return The current value of LID.
4077 Reads the current value of External Interrupt Vector Register (IVR).
4079 Reads and returns the current value of IVR. This function is only available on Itanium processors.
4081 @return The current value of IVR.
4092 Reads the current value of Task Priority Register (TPR).
4094 Reads and returns the current value of TPR. This function is only available on Itanium processors.
4096 @return The current value of TPR.
4107 Reads the current value of External Interrupt Request Register #0 (IRR0).
4109 Reads and returns the current value of IRR0. This function is only available on Itanium processors.
4111 @return The current value of IRR0.
4122 Reads the current value of External Interrupt Request Register #1 (IRR1).
4124 Reads and returns the current value of IRR1. This function is only available on Itanium processors.
4126 @return The current value of IRR1.
4137 Reads the current value of External Interrupt Request Register #2 (IRR2).
4139 Reads and returns the current value of IRR2. This function is only available on Itanium processors.
4141 @return The current value of IRR2.
4152 Reads the current value of External Interrupt Request Register #3 (IRR3).
4154 Reads and returns the current value of IRR3. This function is only available on Itanium processors.
4156 @return The current value of IRR3.
4167 Reads the current value of Performance Monitor Vector Register (PMV).
4169 Reads and returns the current value of PMV. This function is only available on Itanium processors.
4171 @return The current value of PMV.
4182 Reads the current value of Corrected Machine Check Vector Register (CMCV).
4184 Reads and returns the current value of CMCV. This function is only available on Itanium processors.
4186 @return The current value of CMCV.
4197 Reads the current value of Local Redirection Register #0 (LRR0).
4199 Reads and returns the current value of LRR0. This function is only available on Itanium processors.
4201 @return The current value of LRR0.
4212 Reads the current value of Local Redirection Register #1 (LRR1).
4214 Reads and returns the current value of LRR1. This function is only available on Itanium processors.
4216 @return The current value of LRR1.
4227 Writes the current value of 64-bit Page Local Interrupt ID Register (LID).
4229 Writes the current value of LID. The 64-bit value written to the LID is returned.
4230 No parameter checking is performed on Value. All bits of Value corresponding to
4231 reserved fields of LID must be 0 or a Reserved Register/Field fault may occur.
4232 The caller must either guarantee that Value is valid, or the caller must set up
4233 fault handlers to catch the faults.
4234 This function is only available on Itanium processors.
4236 @param Value The 64-bit value to write to LID.
4238 @return The 64-bit value written to the LID.
4249 Writes the current value of 64-bit Task Priority Register (TPR).
4251 Writes the current value of TPR. The 64-bit value written to the TPR is returned.
4252 No parameter checking is performed on Value. All bits of Value corresponding to
4253 reserved fields of TPR must be 0 or a Reserved Register/Field fault may occur.
4254 The caller must either guarantee that Value is valid, or the caller must set up
4255 fault handlers to catch the faults.
4256 This function is only available on Itanium processors.
4258 @param Value The 64-bit value to write to TPR.
4260 @return The 64-bit value written to the TPR.
4271 Performs a write operation on End OF External Interrupt Register (EOI).
4273 Writes a value of 0 to the EOI Register. This function is only available on Itanium processors.
4284 Writes the current value of 64-bit Performance Monitor Vector Register (PMV).
4286 Writes the current value of PMV. The 64-bit value written to the PMV is returned.
4287 No parameter checking is performed on Value. All bits of Value corresponding
4288 to reserved fields of PMV must be 0 or a Reserved Register/Field fault may occur.
4289 The caller must either guarantee that Value is valid, or the caller must set up
4290 fault handlers to catch the faults.
4291 This function is only available on Itanium processors.
4293 @param Value The 64-bit value to write to PMV.
4295 @return The 64-bit value written to the PMV.
4306 Writes the current value of 64-bit Corrected Machine Check Vector Register (CMCV).
4308 Writes the current value of CMCV. The 64-bit value written to the CMCV is returned.
4309 No parameter checking is performed on Value. All bits of Value corresponding
4310 to reserved fields of CMCV must be 0 or a Reserved Register/Field fault may occur.
4311 The caller must either guarantee that Value is valid, or the caller must set up
4312 fault handlers to catch the faults.
4313 This function is only available on Itanium processors.
4315 @param Value The 64-bit value to write to CMCV.
4317 @return The 64-bit value written to the CMCV.
4328 Writes the current value of 64-bit Local Redirection Register #0 (LRR0).
4330 Writes the current value of LRR0. The 64-bit value written to the LRR0 is returned.
4331 No parameter checking is performed on Value. All bits of Value corresponding
4332 to reserved fields of LRR0 must be 0 or a Reserved Register/Field fault may occur.
4333 The caller must either guarantee that Value is valid, or the caller must set up
4334 fault handlers to catch the faults.
4335 This function is only available on Itanium processors.
4337 @param Value The 64-bit value to write to LRR0.
4339 @return The 64-bit value written to the LRR0.
4350 Writes the current value of 64-bit Local Redirection Register #1 (LRR1).
4352 Writes the current value of LRR1. The 64-bit value written to the LRR1 is returned.
4353 No parameter checking is performed on Value. All bits of Value corresponding
4354 to reserved fields of LRR1 must be 0 or a Reserved Register/Field fault may occur.
4355 The caller must either guarantee that Value is valid, or the caller must
4356 set up fault handlers to catch the faults.
4357 This function is only available on Itanium processors.
4359 @param Value The 64-bit value to write to LRR1.
4361 @return The 64-bit value written to the LRR1.
4372 Reads the current value of Instruction Breakpoint Register (IBR).
4374 The Instruction Breakpoint Registers are used in pairs. The even numbered
4375 registers contain breakpoint addresses, and the odd numbered registers contain
4376 breakpoint mask conditions. At least four instruction registers pairs are implemented
4377 on all processor models. Implemented registers are contiguous starting with
4378 register 0. No parameter checking is performed on Index, and if the Index value
4379 is beyond the implemented IBR register range, a Reserved Register/Field fault may
4380 occur. The caller must either guarantee that Index is valid, or the caller must
4381 set up fault handlers to catch the faults.
4382 This function is only available on Itanium processors.
4384 @param Index The 8-bit Instruction Breakpoint Register index to read.
4386 @return The current value of Instruction Breakpoint Register specified by Index.
4397 Reads the current value of Data Breakpoint Register (DBR).
4399 The Data Breakpoint Registers are used in pairs. The even numbered registers
4400 contain breakpoint addresses, and odd numbered registers contain breakpoint
4401 mask conditions. At least four data registers pairs are implemented on all processor
4402 models. Implemented registers are contiguous starting with register 0.
4403 No parameter checking is performed on Index. If the Index value is beyond
4404 the implemented DBR register range, a Reserved Register/Field fault may occur.
4405 The caller must either guarantee that Index is valid, or the caller must set up
4406 fault handlers to catch the faults.
4407 This function is only available on Itanium processors.
4409 @param Index The 8-bit Data Breakpoint Register index to read.
4411 @return The current value of Data Breakpoint Register specified by Index.
4422 Reads the current value of Performance Monitor Configuration Register (PMC).
4424 All processor implementations provide at least four performance counters
4425 (PMC/PMD [4]...PMC/PMD [7] pairs), and four performance monitor counter overflow
4426 status registers (PMC [0]... PMC [3]). Processor implementations may provide
4427 additional implementation-dependent PMC and PMD to increase the number of
4428 'generic' performance counters (PMC/PMD pairs). The remainder of PMC and PMD
4429 register set is implementation dependent. No parameter checking is performed
4430 on Index. If the Index value is beyond the implemented PMC register range,
4431 zero value will be returned.
4432 This function is only available on Itanium processors.
4434 @param Index The 8-bit Performance Monitor Configuration Register index to read.
4436 @return The current value of Performance Monitor Configuration Register
4448 Reads the current value of Performance Monitor Data Register (PMD).
4450 All processor implementations provide at least 4 performance counters
4451 (PMC/PMD [4]...PMC/PMD [7] pairs), and 4 performance monitor counter
4452 overflow status registers (PMC [0]... PMC [3]). Processor implementations may
4453 provide additional implementation-dependent PMC and PMD to increase the number
4454 of 'generic' performance counters (PMC/PMD pairs). The remainder of PMC and PMD
4455 register set is implementation dependent. No parameter checking is performed
4456 on Index. If the Index value is beyond the implemented PMD register range,
4457 zero value will be returned.
4458 This function is only available on Itanium processors.
4460 @param Index The 8-bit Performance Monitor Data Register index to read.
4462 @return The current value of Performance Monitor Data Register specified by Index.
4473 Writes the current value of 64-bit Instruction Breakpoint Register (IBR).
4475 Writes current value of Instruction Breakpoint Register specified by Index.
4476 The Instruction Breakpoint Registers are used in pairs. The even numbered
4477 registers contain breakpoint addresses, and odd numbered registers contain
4478 breakpoint mask conditions. At least four instruction registers pairs are implemented
4479 on all processor models. Implemented registers are contiguous starting with
4480 register 0. No parameter checking is performed on Index. If the Index value
4481 is beyond the implemented IBR register range, a Reserved Register/Field fault may
4482 occur. The caller must either guarantee that Index is valid, or the caller must
4483 set up fault handlers to catch the faults.
4484 This function is only available on Itanium processors.
4486 @param Index The 8-bit Instruction Breakpoint Register index to write.
4487 @param Value The 64-bit value to write to IBR.
4489 @return The 64-bit value written to the IBR.
4501 Writes the current value of 64-bit Data Breakpoint Register (DBR).
4503 Writes current value of Data Breakpoint Register specified by Index.
4504 The Data Breakpoint Registers are used in pairs. The even numbered registers
4505 contain breakpoint addresses, and odd numbered registers contain breakpoint
4506 mask conditions. At least four data registers pairs are implemented on all processor
4507 models. Implemented registers are contiguous starting with register 0. No parameter
4508 checking is performed on Index. If the Index value is beyond the implemented
4509 DBR register range, a Reserved Register/Field fault may occur. The caller must
4510 either guarantee that Index is valid, or the caller must set up fault handlers to
4512 This function is only available on Itanium processors.
4514 @param Index The 8-bit Data Breakpoint Register index to write.
4515 @param Value The 64-bit value to write to DBR.
4517 @return The 64-bit value written to the DBR.
4529 Writes the current value of 64-bit Performance Monitor Configuration Register (PMC).
4531 Writes current value of Performance Monitor Configuration Register specified by Index.
4532 All processor implementations provide at least four performance counters
4533 (PMC/PMD [4]...PMC/PMD [7] pairs), and four performance monitor counter overflow status
4534 registers (PMC [0]... PMC [3]). Processor implementations may provide additional
4535 implementation-dependent PMC and PMD to increase the number of 'generic' performance
4536 counters (PMC/PMD pairs). The remainder of PMC and PMD register set is implementation
4537 dependent. No parameter checking is performed on Index. If the Index value is
4538 beyond the implemented PMC register range, the write is ignored.
4539 This function is only available on Itanium processors.
4541 @param Index The 8-bit Performance Monitor Configuration Register index to write.
4542 @param Value The 64-bit value to write to PMC.
4544 @return The 64-bit value written to the PMC.
4556 Writes the current value of 64-bit Performance Monitor Data Register (PMD).
4558 Writes current value of Performance Monitor Data Register specified by Index.
4559 All processor implementations provide at least four performance counters
4560 (PMC/PMD [4]...PMC/PMD [7] pairs), and four performance monitor counter overflow
4561 status registers (PMC [0]... PMC [3]). Processor implementations may provide
4562 additional implementation-dependent PMC and PMD to increase the number of 'generic'
4563 performance counters (PMC/PMD pairs). The remainder of PMC and PMD register set
4564 is implementation dependent. No parameter checking is performed on Index. If the
4565 Index value is beyond the implemented PMD register range, the write is ignored.
4566 This function is only available on Itanium processors.
4568 @param Index The 8-bit Performance Monitor Data Register index to write.
4569 @param Value The 64-bit value to write to PMD.
4571 @return The 64-bit value written to the PMD.
4583 Reads the current value of 64-bit Global Pointer (GP).
4585 Reads and returns the current value of GP.
4586 This function is only available on Itanium processors.
4588 @return The current value of GP.
4599 Write the current value of 64-bit Global Pointer (GP).
4601 Writes the current value of GP. The 64-bit value written to the GP is returned.
4602 No parameter checking is performed on Value.
4603 This function is only available on Itanium processors.
4605 @param Value The 64-bit value to write to GP.
4607 @return The 64-bit value written to the GP.
4618 Reads the current value of 64-bit Stack Pointer (SP).
4620 Reads and returns the current value of SP.
4621 This function is only available on Itanium processors.
4623 @return The current value of SP.
4634 /// Valid Index value for AsmReadControlRegister().
4636 #define IPF_CONTROL_REGISTER_DCR 0
4637 #define IPF_CONTROL_REGISTER_ITM 1
4638 #define IPF_CONTROL_REGISTER_IVA 2
4639 #define IPF_CONTROL_REGISTER_PTA 8
4640 #define IPF_CONTROL_REGISTER_IPSR 16
4641 #define IPF_CONTROL_REGISTER_ISR 17
4642 #define IPF_CONTROL_REGISTER_IIP 19
4643 #define IPF_CONTROL_REGISTER_IFA 20
4644 #define IPF_CONTROL_REGISTER_ITIR 21
4645 #define IPF_CONTROL_REGISTER_IIPA 22
4646 #define IPF_CONTROL_REGISTER_IFS 23
4647 #define IPF_CONTROL_REGISTER_IIM 24
4648 #define IPF_CONTROL_REGISTER_IHA 25
4649 #define IPF_CONTROL_REGISTER_LID 64
4650 #define IPF_CONTROL_REGISTER_IVR 65
4651 #define IPF_CONTROL_REGISTER_TPR 66
4652 #define IPF_CONTROL_REGISTER_EOI 67
4653 #define IPF_CONTROL_REGISTER_IRR0 68
4654 #define IPF_CONTROL_REGISTER_IRR1 69
4655 #define IPF_CONTROL_REGISTER_IRR2 70
4656 #define IPF_CONTROL_REGISTER_IRR3 71
4657 #define IPF_CONTROL_REGISTER_ITV 72
4658 #define IPF_CONTROL_REGISTER_PMV 73
4659 #define IPF_CONTROL_REGISTER_CMCV 74
4660 #define IPF_CONTROL_REGISTER_LRR0 80
4661 #define IPF_CONTROL_REGISTER_LRR1 81
4664 Reads a 64-bit control register.
4666 Reads and returns the control register specified by Index. The valid Index valued
4667 are defined above in "Related Definitions".
4668 If Index is invalid then 0xFFFFFFFFFFFFFFFF is returned. This function is only
4669 available on Itanium processors.
4671 @param Index The index of the control register to read.
4673 @return The control register specified by Index.
4678 AsmReadControlRegister (
4684 /// Valid Index value for AsmReadApplicationRegister().
4686 #define IPF_APPLICATION_REGISTER_K0 0
4687 #define IPF_APPLICATION_REGISTER_K1 1
4688 #define IPF_APPLICATION_REGISTER_K2 2
4689 #define IPF_APPLICATION_REGISTER_K3 3
4690 #define IPF_APPLICATION_REGISTER_K4 4
4691 #define IPF_APPLICATION_REGISTER_K5 5
4692 #define IPF_APPLICATION_REGISTER_K6 6
4693 #define IPF_APPLICATION_REGISTER_K7 7
4694 #define IPF_APPLICATION_REGISTER_RSC 16
4695 #define IPF_APPLICATION_REGISTER_BSP 17
4696 #define IPF_APPLICATION_REGISTER_BSPSTORE 18
4697 #define IPF_APPLICATION_REGISTER_RNAT 19
4698 #define IPF_APPLICATION_REGISTER_FCR 21
4699 #define IPF_APPLICATION_REGISTER_EFLAG 24
4700 #define IPF_APPLICATION_REGISTER_CSD 25
4701 #define IPF_APPLICATION_REGISTER_SSD 26
4702 #define IPF_APPLICATION_REGISTER_CFLG 27
4703 #define IPF_APPLICATION_REGISTER_FSR 28
4704 #define IPF_APPLICATION_REGISTER_FIR 29
4705 #define IPF_APPLICATION_REGISTER_FDR 30
4706 #define IPF_APPLICATION_REGISTER_CCV 32
4707 #define IPF_APPLICATION_REGISTER_UNAT 36
4708 #define IPF_APPLICATION_REGISTER_FPSR 40
4709 #define IPF_APPLICATION_REGISTER_ITC 44
4710 #define IPF_APPLICATION_REGISTER_PFS 64
4711 #define IPF_APPLICATION_REGISTER_LC 65
4712 #define IPF_APPLICATION_REGISTER_EC 66
4715 Reads a 64-bit application register.
4717 Reads and returns the application register specified by Index. The valid Index
4718 valued are defined above in "Related Definitions".
4719 If Index is invalid then 0xFFFFFFFFFFFFFFFF is returned. This function is only
4720 available on Itanium processors.
4722 @param Index The index of the application register to read.
4724 @return The application register specified by Index.
4729 AsmReadApplicationRegister (
4735 Reads the current value of a Machine Specific Register (MSR).
4737 Reads and returns the current value of the Machine Specific Register specified by Index. No
4738 parameter checking is performed on Index, and if the Index value is beyond the implemented MSR
4739 register range, a Reserved Register/Field fault may occur. The caller must either guarantee that
4740 Index is valid, or the caller must set up fault handlers to catch the faults. This function is
4741 only available on Itanium processors.
4743 @param Index The 8-bit Machine Specific Register index to read.
4745 @return The current value of the Machine Specific Register specified by Index.
4756 Writes the current value of a Machine Specific Register (MSR).
4758 Writes Value to the Machine Specific Register specified by Index. Value is returned. No
4759 parameter checking is performed on Index, and if the Index value is beyond the implemented MSR
4760 register range, a Reserved Register/Field fault may occur. The caller must either guarantee that
4761 Index is valid, or the caller must set up fault handlers to catch the faults. This function is
4762 only available on Itanium processors.
4764 @param Index The 8-bit Machine Specific Register index to write.
4765 @param Value The 64-bit value to write to the Machine Specific Register.
4767 @return The 64-bit value to write to the Machine Specific Register.
4779 Determines if the CPU is currently executing in virtual, physical, or mixed mode.
4781 Determines the current execution mode of the CPU.
4782 If the CPU is in virtual mode(PSR.RT=1, PSR.DT=1, PSR.IT=1), then 1 is returned.
4783 If the CPU is in physical mode(PSR.RT=0, PSR.DT=0, PSR.IT=0), then 0 is returned.
4784 If the CPU is not in physical mode or virtual mode, then it is in mixed mode,
4786 This function is only available on Itanium processors.
4788 @retval 1 The CPU is in virtual mode.
4789 @retval 0 The CPU is in physical mode.
4790 @retval -1 The CPU is in mixed mode.
4801 Makes a PAL procedure call.
4803 This is a wrapper function to make a PAL procedure call. Based on the Index
4804 value this API will make static or stacked PAL call. The following table
4805 describes the usage of PAL Procedure Index Assignment. Architected procedures
4806 may be designated as required or optional. If a PAL procedure is specified
4807 as optional, a unique return code of 0xFFFFFFFFFFFFFFFF is returned in the
4808 Status field of the PAL_CALL_RETURN structure.
4809 This indicates that the procedure is not present in this PAL implementation.
4810 It is the caller's responsibility to check for this return code after calling
4811 any optional PAL procedure.
4812 No parameter checking is performed on the 5 input parameters, but there are
4813 some common rules that the caller should follow when making a PAL call. Any
4814 address passed to PAL as buffers for return parameters must be 8-byte aligned.
4815 Unaligned addresses may cause undefined results. For those parameters defined
4816 as reserved or some fields defined as reserved must be zero filled or the invalid
4817 argument return value may be returned or undefined result may occur during the
4818 execution of the procedure. If the PalEntryPoint does not point to a valid
4819 PAL entry point then the system behavior is undefined. This function is only
4820 available on Itanium processors.
4822 @param PalEntryPoint The PAL procedure calls entry point.
4823 @param Index The PAL procedure Index number.
4824 @param Arg2 The 2nd parameter for PAL procedure calls.
4825 @param Arg3 The 3rd parameter for PAL procedure calls.
4826 @param Arg4 The 4th parameter for PAL procedure calls.
4828 @return structure returned from the PAL Call procedure, including the status and return value.
4834 IN UINT64 PalEntryPoint
,
4842 #if defined (MDE_CPU_IA32) || defined (MDE_CPU_X64)
4844 /// IA32 and x64 Specific Functions.
4845 /// Byte packed structure for 16-bit Real Mode EFLAGS.
4849 UINT32 CF
:1; ///< Carry Flag.
4850 UINT32 Reserved_0
:1; ///< Reserved.
4851 UINT32 PF
:1; ///< Parity Flag.
4852 UINT32 Reserved_1
:1; ///< Reserved.
4853 UINT32 AF
:1; ///< Auxiliary Carry Flag.
4854 UINT32 Reserved_2
:1; ///< Reserved.
4855 UINT32 ZF
:1; ///< Zero Flag.
4856 UINT32 SF
:1; ///< Sign Flag.
4857 UINT32 TF
:1; ///< Trap Flag.
4858 UINT32 IF
:1; ///< Interrupt Enable Flag.
4859 UINT32 DF
:1; ///< Direction Flag.
4860 UINT32 OF
:1; ///< Overflow Flag.
4861 UINT32 IOPL
:2; ///< I/O Privilege Level.
4862 UINT32 NT
:1; ///< Nested Task.
4863 UINT32 Reserved_3
:1; ///< Reserved.
4869 /// Byte packed structure for EFLAGS/RFLAGS.
4870 /// 32-bits on IA-32.
4871 /// 64-bits on x64. The upper 32-bits on x64 are reserved.
4875 UINT32 CF
:1; ///< Carry Flag.
4876 UINT32 Reserved_0
:1; ///< Reserved.
4877 UINT32 PF
:1; ///< Parity Flag.
4878 UINT32 Reserved_1
:1; ///< Reserved.
4879 UINT32 AF
:1; ///< Auxiliary Carry Flag.
4880 UINT32 Reserved_2
:1; ///< Reserved.
4881 UINT32 ZF
:1; ///< Zero Flag.
4882 UINT32 SF
:1; ///< Sign Flag.
4883 UINT32 TF
:1; ///< Trap Flag.
4884 UINT32 IF
:1; ///< Interrupt Enable Flag.
4885 UINT32 DF
:1; ///< Direction Flag.
4886 UINT32 OF
:1; ///< Overflow Flag.
4887 UINT32 IOPL
:2; ///< I/O Privilege Level.
4888 UINT32 NT
:1; ///< Nested Task.
4889 UINT32 Reserved_3
:1; ///< Reserved.
4890 UINT32 RF
:1; ///< Resume Flag.
4891 UINT32 VM
:1; ///< Virtual 8086 Mode.
4892 UINT32 AC
:1; ///< Alignment Check.
4893 UINT32 VIF
:1; ///< Virtual Interrupt Flag.
4894 UINT32 VIP
:1; ///< Virtual Interrupt Pending.
4895 UINT32 ID
:1; ///< ID Flag.
4896 UINT32 Reserved_4
:10; ///< Reserved.
4902 /// Byte packed structure for Control Register 0 (CR0).
4903 /// 32-bits on IA-32.
4904 /// 64-bits on x64. The upper 32-bits on x64 are reserved.
4908 UINT32 PE
:1; ///< Protection Enable.
4909 UINT32 MP
:1; ///< Monitor Coprocessor.
4910 UINT32 EM
:1; ///< Emulation.
4911 UINT32 TS
:1; ///< Task Switched.
4912 UINT32 ET
:1; ///< Extension Type.
4913 UINT32 NE
:1; ///< Numeric Error.
4914 UINT32 Reserved_0
:10; ///< Reserved.
4915 UINT32 WP
:1; ///< Write Protect.
4916 UINT32 Reserved_1
:1; ///< Reserved.
4917 UINT32 AM
:1; ///< Alignment Mask.
4918 UINT32 Reserved_2
:10; ///< Reserved.
4919 UINT32 NW
:1; ///< Mot Write-through.
4920 UINT32 CD
:1; ///< Cache Disable.
4921 UINT32 PG
:1; ///< Paging.
4927 /// Byte packed structure for Control Register 4 (CR4).
4928 /// 32-bits on IA-32.
4929 /// 64-bits on x64. The upper 32-bits on x64 are reserved.
4933 UINT32 VME
:1; ///< Virtual-8086 Mode Extensions.
4934 UINT32 PVI
:1; ///< Protected-Mode Virtual Interrupts.
4935 UINT32 TSD
:1; ///< Time Stamp Disable.
4936 UINT32 DE
:1; ///< Debugging Extensions.
4937 UINT32 PSE
:1; ///< Page Size Extensions.
4938 UINT32 PAE
:1; ///< Physical Address Extension.
4939 UINT32 MCE
:1; ///< Machine Check Enable.
4940 UINT32 PGE
:1; ///< Page Global Enable.
4941 UINT32 PCE
:1; ///< Performance Monitoring Counter
4943 UINT32 OSFXSR
:1; ///< Operating System Support for
4944 ///< FXSAVE and FXRSTOR instructions
4945 UINT32 OSXMMEXCPT
:1; ///< Operating System Support for
4946 ///< Unmasked SIMD Floating Point
4948 UINT32 Reserved_0
:2; ///< Reserved.
4949 UINT32 VMXE
:1; ///< VMX Enable
4950 UINT32 Reserved_1
:18; ///< Reserved.
4956 /// Byte packed structure for a segment descriptor in a GDT/LDT.
4975 } IA32_SEGMENT_DESCRIPTOR
;
4978 /// Byte packed structure for an IDTR, GDTR, LDTR descriptor.
4987 #define IA32_IDT_GATE_TYPE_TASK 0x85
4988 #define IA32_IDT_GATE_TYPE_INTERRUPT_16 0x86
4989 #define IA32_IDT_GATE_TYPE_TRAP_16 0x87
4990 #define IA32_IDT_GATE_TYPE_INTERRUPT_32 0x8E
4991 #define IA32_IDT_GATE_TYPE_TRAP_32 0x8F
4994 #if defined (MDE_CPU_IA32)
4996 /// Byte packed structure for an IA-32 Interrupt Gate Descriptor.
5000 UINT32 OffsetLow
:16; ///< Offset bits 15..0.
5001 UINT32 Selector
:16; ///< Selector.
5002 UINT32 Reserved_0
:8; ///< Reserved.
5003 UINT32 GateType
:8; ///< Gate Type. See #defines above.
5004 UINT32 OffsetHigh
:16; ///< Offset bits 31..16.
5007 } IA32_IDT_GATE_DESCRIPTOR
;
5011 #if defined (MDE_CPU_X64)
5013 /// Byte packed structure for an x64 Interrupt Gate Descriptor.
5017 UINT32 OffsetLow
:16; ///< Offset bits 15..0.
5018 UINT32 Selector
:16; ///< Selector.
5019 UINT32 Reserved_0
:8; ///< Reserved.
5020 UINT32 GateType
:8; ///< Gate Type. See #defines above.
5021 UINT32 OffsetHigh
:16; ///< Offset bits 31..16.
5022 UINT32 OffsetUpper
:32; ///< Offset bits 63..32.
5023 UINT32 Reserved_1
:32; ///< Reserved.
5029 } IA32_IDT_GATE_DESCRIPTOR
;
5034 /// Byte packed structure for an FP/SSE/SSE2 context.
5041 /// Structures for the 16-bit real mode thunks.
5094 IA32_EFLAGS32 EFLAGS
;
5104 } IA32_REGISTER_SET
;
5107 /// Byte packed structure for an 16-bit real mode thunks.
5110 IA32_REGISTER_SET
*RealModeState
;
5111 VOID
*RealModeBuffer
;
5112 UINT32 RealModeBufferSize
;
5113 UINT32 ThunkAttributes
;
5116 #define THUNK_ATTRIBUTE_BIG_REAL_MODE 0x00000001
5117 #define THUNK_ATTRIBUTE_DISABLE_A20_MASK_INT_15 0x00000002
5118 #define THUNK_ATTRIBUTE_DISABLE_A20_MASK_KBD_CTRL 0x00000004
5121 Retrieves CPUID information.
5123 Executes the CPUID instruction with EAX set to the value specified by Index.
5124 This function always returns Index.
5125 If Eax is not NULL, then the value of EAX after CPUID is returned in Eax.
5126 If Ebx is not NULL, then the value of EBX after CPUID is returned in Ebx.
5127 If Ecx is not NULL, then the value of ECX after CPUID is returned in Ecx.
5128 If Edx is not NULL, then the value of EDX after CPUID is returned in Edx.
5129 This function is only available on IA-32 and x64.
5131 @param Index The 32-bit value to load into EAX prior to invoking the CPUID
5133 @param Eax The pointer to the 32-bit EAX value returned by the CPUID
5134 instruction. This is an optional parameter that may be NULL.
5135 @param Ebx The pointer to the 32-bit EBX value returned by the CPUID
5136 instruction. This is an optional parameter that may be NULL.
5137 @param Ecx The pointer to the 32-bit ECX value returned by the CPUID
5138 instruction. This is an optional parameter that may be NULL.
5139 @param Edx The pointer to the 32-bit EDX value returned by the CPUID
5140 instruction. This is an optional parameter that may be NULL.
5149 OUT UINT32
*Eax
, OPTIONAL
5150 OUT UINT32
*Ebx
, OPTIONAL
5151 OUT UINT32
*Ecx
, OPTIONAL
5152 OUT UINT32
*Edx OPTIONAL
5157 Retrieves CPUID information using an extended leaf identifier.
5159 Executes the CPUID instruction with EAX set to the value specified by Index
5160 and ECX set to the value specified by SubIndex. This function always returns
5161 Index. This function is only available on IA-32 and x64.
5163 If Eax is not NULL, then the value of EAX after CPUID is returned in Eax.
5164 If Ebx is not NULL, then the value of EBX after CPUID is returned in Ebx.
5165 If Ecx is not NULL, then the value of ECX after CPUID is returned in Ecx.
5166 If Edx is not NULL, then the value of EDX after CPUID is returned in Edx.
5168 @param Index The 32-bit value to load into EAX prior to invoking the
5170 @param SubIndex The 32-bit value to load into ECX prior to invoking the
5172 @param Eax The pointer to the 32-bit EAX value returned by the CPUID
5173 instruction. This is an optional parameter that may be
5175 @param Ebx The pointer to the 32-bit EBX value returned by the CPUID
5176 instruction. This is an optional parameter that may be
5178 @param Ecx The pointer to the 32-bit ECX value returned by the CPUID
5179 instruction. This is an optional parameter that may be
5181 @param Edx The pointer to the 32-bit EDX value returned by the CPUID
5182 instruction. This is an optional parameter that may be
5193 OUT UINT32
*Eax
, OPTIONAL
5194 OUT UINT32
*Ebx
, OPTIONAL
5195 OUT UINT32
*Ecx
, OPTIONAL
5196 OUT UINT32
*Edx OPTIONAL
5201 Set CD bit and clear NW bit of CR0 followed by a WBINVD.
5203 Disables the caches by setting the CD bit of CR0 to 1, clearing the NW bit of CR0 to 0,
5204 and executing a WBINVD instruction. This function is only available on IA-32 and x64.
5215 Perform a WBINVD and clear both the CD and NW bits of CR0.
5217 Enables the caches by executing a WBINVD instruction and then clear both the CD and NW
5218 bits of CR0 to 0. This function is only available on IA-32 and x64.
5229 Returns the lower 32-bits of a Machine Specific Register(MSR).
5231 Reads and returns the lower 32-bits of the MSR specified by Index.
5232 No parameter checking is performed on Index, and some Index values may cause
5233 CPU exceptions. The caller must either guarantee that Index is valid, or the
5234 caller must set up exception handlers to catch the exceptions. This function
5235 is only available on IA-32 and x64.
5237 @param Index The 32-bit MSR index to read.
5239 @return The lower 32 bits of the MSR identified by Index.
5250 Writes a 32-bit value to a Machine Specific Register(MSR), and returns the value.
5251 The upper 32-bits of the MSR are set to zero.
5253 Writes the 32-bit value specified by Value to the MSR specified by Index. The
5254 upper 32-bits of the MSR write are set to zero. The 32-bit value written to
5255 the MSR is returned. No parameter checking is performed on Index or Value,
5256 and some of these may cause CPU exceptions. The caller must either guarantee
5257 that Index and Value are valid, or the caller must establish proper exception
5258 handlers. This function is only available on IA-32 and x64.
5260 @param Index The 32-bit MSR index to write.
5261 @param Value The 32-bit value to write to the MSR.
5275 Reads a 64-bit MSR, performs a bitwise OR on the lower 32-bits, and
5276 writes the result back to the 64-bit MSR.
5278 Reads the 64-bit MSR specified by Index, performs a bitwise OR
5279 between the lower 32-bits of the read result and the value specified by
5280 OrData, and writes the result to the 64-bit MSR specified by Index. The lower
5281 32-bits of the value written to the MSR is returned. No parameter checking is
5282 performed on Index or OrData, and some of these may cause CPU exceptions. The
5283 caller must either guarantee that Index and OrData are valid, or the caller
5284 must establish proper exception handlers. This function is only available on
5287 @param Index The 32-bit MSR index to write.
5288 @param OrData The value to OR with the read value from the MSR.
5290 @return The lower 32-bit value written to the MSR.
5302 Reads a 64-bit MSR, performs a bitwise AND on the lower 32-bits, and writes
5303 the result back to the 64-bit MSR.
5305 Reads the 64-bit MSR specified by Index, performs a bitwise AND between the
5306 lower 32-bits of the read result and the value specified by AndData, and
5307 writes the result to the 64-bit MSR specified by Index. The lower 32-bits of
5308 the value written to the MSR is returned. No parameter checking is performed
5309 on Index or AndData, and some of these may cause CPU exceptions. The caller
5310 must either guarantee that Index and AndData are valid, or the caller must
5311 establish proper exception handlers. This function is only available on IA-32
5314 @param Index The 32-bit MSR index to write.
5315 @param AndData The value to AND with the read value from the MSR.
5317 @return The lower 32-bit value written to the MSR.
5329 Reads a 64-bit MSR, performs a bitwise AND followed by a bitwise OR
5330 on the lower 32-bits, and writes the result back to the 64-bit MSR.
5332 Reads the 64-bit MSR specified by Index, performs a bitwise AND between the
5333 lower 32-bits of the read result and the value specified by AndData
5334 preserving the upper 32-bits, performs a bitwise OR between the
5335 result of the AND operation and the value specified by OrData, and writes the
5336 result to the 64-bit MSR specified by Address. The lower 32-bits of the value
5337 written to the MSR is returned. No parameter checking is performed on Index,
5338 AndData, or OrData, and some of these may cause CPU exceptions. The caller
5339 must either guarantee that Index, AndData, and OrData are valid, or the
5340 caller must establish proper exception handlers. This function is only
5341 available on IA-32 and x64.
5343 @param Index The 32-bit MSR index to write.
5344 @param AndData The value to AND with the read value from the MSR.
5345 @param OrData The value to OR with the result of the AND operation.
5347 @return The lower 32-bit value written to the MSR.
5360 Reads a bit field of an MSR.
5362 Reads the bit field in the lower 32-bits of a 64-bit MSR. The bit field is
5363 specified by the StartBit and the EndBit. The value of the bit field is
5364 returned. The caller must either guarantee that Index is valid, or the caller
5365 must set up exception handlers to catch the exceptions. This function is only
5366 available on IA-32 and x64.
5368 If StartBit is greater than 31, then ASSERT().
5369 If EndBit is greater than 31, then ASSERT().
5370 If EndBit is less than StartBit, then ASSERT().
5372 @param Index The 32-bit MSR index to read.
5373 @param StartBit The ordinal of the least significant bit in the bit field.
5375 @param EndBit The ordinal of the most significant bit in the bit field.
5378 @return The bit field read from the MSR.
5383 AsmMsrBitFieldRead32 (
5391 Writes a bit field to an MSR.
5393 Writes Value to a bit field in the lower 32-bits of a 64-bit MSR. The bit
5394 field is specified by the StartBit and the EndBit. All other bits in the
5395 destination MSR are preserved. The lower 32-bits of the MSR written is
5396 returned. The caller must either guarantee that Index and the data written
5397 is valid, or the caller must set up exception handlers to catch the exceptions.
5398 This function is only available on IA-32 and x64.
5400 If StartBit is greater than 31, then ASSERT().
5401 If EndBit is greater than 31, then ASSERT().
5402 If EndBit is less than StartBit, then ASSERT().
5403 If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
5405 @param Index The 32-bit MSR index to write.
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.
5410 @param Value New value of the bit field.
5412 @return The lower 32-bit of the value written to the MSR.
5417 AsmMsrBitFieldWrite32 (
5426 Reads a bit field in a 64-bit MSR, performs a bitwise OR, and writes the
5427 result back to the bit field in the 64-bit MSR.
5429 Reads the 64-bit MSR specified by Index, performs a bitwise OR
5430 between the read result and the value specified by OrData, and writes the
5431 result to the 64-bit MSR specified by Index. The lower 32-bits of the value
5432 written to the MSR are returned. Extra left bits in OrData are stripped. The
5433 caller must either guarantee that Index and the data written is valid, or
5434 the caller must set up exception handlers to catch the exceptions. This
5435 function is only available on IA-32 and x64.
5437 If StartBit is greater than 31, then ASSERT().
5438 If EndBit is greater than 31, then ASSERT().
5439 If EndBit is less than StartBit, then ASSERT().
5440 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
5442 @param Index The 32-bit MSR index to write.
5443 @param StartBit The ordinal of the least significant bit in the bit field.
5445 @param EndBit The ordinal of the most significant bit in the bit field.
5447 @param OrData The value to OR with the read value from the MSR.
5449 @return The lower 32-bit of the value written to the MSR.
5454 AsmMsrBitFieldOr32 (
5463 Reads a bit field in a 64-bit MSR, performs a bitwise AND, and writes the
5464 result back to the bit field in the 64-bit MSR.
5466 Reads the 64-bit MSR specified by Index, performs a bitwise AND between the
5467 read result and the value specified by AndData, and writes the result to the
5468 64-bit MSR specified by Index. The lower 32-bits of the value written to the
5469 MSR are returned. Extra left bits in AndData are stripped. The caller must
5470 either guarantee that Index and the data written is valid, or the caller must
5471 set up exception handlers to catch the exceptions. This function is only
5472 available on IA-32 and x64.
5474 If StartBit is greater than 31, then ASSERT().
5475 If EndBit is greater than 31, then ASSERT().
5476 If EndBit is less than StartBit, then ASSERT().
5477 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
5479 @param Index The 32-bit MSR index to write.
5480 @param StartBit The ordinal of the least significant bit in the bit field.
5482 @param EndBit The ordinal of the most significant bit in the bit field.
5484 @param AndData The value to AND with the read value from the MSR.
5486 @return The lower 32-bit of the value written to the MSR.
5491 AsmMsrBitFieldAnd32 (
5500 Reads a bit field in a 64-bit MSR, performs a bitwise AND followed by a
5501 bitwise OR, and writes the result back to the bit field in the
5504 Reads the 64-bit MSR specified by Index, performs a bitwise AND followed by a
5505 bitwise OR between the read result and the value specified by
5506 AndData, and writes the result to the 64-bit MSR specified by Index. The
5507 lower 32-bits of the value written to the MSR are returned. Extra left bits
5508 in both AndData and OrData are stripped. The caller must either guarantee
5509 that Index and the data written is valid, or the caller must set up exception
5510 handlers to catch the exceptions. This function is only available on IA-32
5513 If StartBit is greater than 31, then ASSERT().
5514 If EndBit is greater than 31, then ASSERT().
5515 If EndBit is less than StartBit, then ASSERT().
5516 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
5517 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
5519 @param Index The 32-bit MSR index to write.
5520 @param StartBit The ordinal of the least significant bit in the bit field.
5522 @param EndBit The ordinal of the most significant bit in the bit field.
5524 @param AndData The value to AND with the read value from the MSR.
5525 @param OrData The value to OR with the result of the AND operation.
5527 @return The lower 32-bit of the value written to the MSR.
5532 AsmMsrBitFieldAndThenOr32 (
5542 Returns a 64-bit Machine Specific Register(MSR).
5544 Reads and returns the 64-bit MSR specified by Index. No parameter checking is
5545 performed on Index, and some Index values may cause CPU exceptions. The
5546 caller must either guarantee that Index is valid, or the caller must set up
5547 exception handlers to catch the exceptions. This function is only available
5550 @param Index The 32-bit MSR index to read.
5552 @return The value of the MSR identified by Index.
5563 Writes a 64-bit value to a Machine Specific Register(MSR), and returns the
5566 Writes the 64-bit value specified by Value to the MSR specified by Index. The
5567 64-bit value written to the MSR is returned. No parameter checking is
5568 performed on Index or Value, and some of these may cause CPU exceptions. The
5569 caller must either guarantee that Index and Value are valid, or the caller
5570 must establish proper exception handlers. This function is only available on
5573 @param Index The 32-bit MSR index to write.
5574 @param Value The 64-bit value to write to the MSR.
5588 Reads a 64-bit MSR, performs a bitwise OR, and writes the result
5589 back to the 64-bit MSR.
5591 Reads the 64-bit MSR specified by Index, performs a bitwise OR
5592 between the read result and the value specified by OrData, and writes the
5593 result to the 64-bit MSR specified by Index. The value written to the MSR is
5594 returned. No parameter checking is performed on Index or OrData, and some of
5595 these may cause CPU exceptions. The caller must either guarantee that Index
5596 and OrData are valid, or the caller must establish proper exception handlers.
5597 This function is only available on IA-32 and x64.
5599 @param Index The 32-bit MSR index to write.
5600 @param OrData The value to OR with the read value from the MSR.
5602 @return The value written back to the MSR.
5614 Reads a 64-bit MSR, performs a bitwise AND, and writes the result back to the
5617 Reads the 64-bit MSR specified by Index, performs a bitwise AND between the
5618 read result and the value specified by OrData, and writes the result to the
5619 64-bit MSR specified by Index. The value written to the MSR is returned. No
5620 parameter checking is performed on Index or OrData, and some of these may
5621 cause CPU exceptions. The caller must either guarantee that Index and OrData
5622 are valid, or the caller must establish proper exception handlers. This
5623 function is only available on IA-32 and x64.
5625 @param Index The 32-bit MSR index to write.
5626 @param AndData The value to AND with the read value from the MSR.
5628 @return The value written back to the MSR.
5640 Reads a 64-bit MSR, performs a bitwise AND followed by a bitwise
5641 OR, and writes the result back to the 64-bit MSR.
5643 Reads the 64-bit MSR specified by Index, performs a bitwise AND between read
5644 result and the value specified by AndData, performs a bitwise OR
5645 between the result of the AND operation and the value specified by OrData,
5646 and writes the result to the 64-bit MSR specified by Index. The value written
5647 to the MSR is returned. No parameter checking is performed on Index, AndData,
5648 or OrData, and some of these may cause CPU exceptions. The caller must either
5649 guarantee that Index, AndData, and OrData are valid, or the caller must
5650 establish proper exception handlers. This function is only available on IA-32
5653 @param Index The 32-bit MSR index to write.
5654 @param AndData The value to AND with the read value from the MSR.
5655 @param OrData The value to OR with the result of the AND operation.
5657 @return The value written back to the MSR.
5670 Reads a bit field of an MSR.
5672 Reads the bit field in the 64-bit MSR. The bit field is specified by the
5673 StartBit and the EndBit. The value of the bit field is returned. The caller
5674 must either guarantee that Index is valid, or the caller must set up
5675 exception handlers to catch the exceptions. This function is only available
5678 If StartBit is greater than 63, then ASSERT().
5679 If EndBit is greater than 63, then ASSERT().
5680 If EndBit is less than StartBit, then ASSERT().
5682 @param Index The 32-bit MSR index to read.
5683 @param StartBit The ordinal of the least significant bit in the bit field.
5685 @param EndBit The ordinal of the most significant bit in the bit field.
5688 @return The value read from the MSR.
5693 AsmMsrBitFieldRead64 (
5701 Writes a bit field to an MSR.
5703 Writes Value to a bit field in a 64-bit MSR. The bit field is specified by
5704 the StartBit and the EndBit. All other bits in the destination MSR are
5705 preserved. The MSR written is returned. The caller must either guarantee
5706 that Index and the data written is valid, or the caller must set up exception
5707 handlers to catch the exceptions. This function is only available on IA-32 and x64.
5709 If StartBit is greater than 63, then ASSERT().
5710 If EndBit is greater than 63, then ASSERT().
5711 If EndBit is less than StartBit, then ASSERT().
5712 If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
5714 @param Index The 32-bit MSR index to write.
5715 @param StartBit The ordinal of the least significant bit in the bit field.
5717 @param EndBit The ordinal of the most significant bit in the bit field.
5719 @param Value New value of the bit field.
5721 @return The value written back to the MSR.
5726 AsmMsrBitFieldWrite64 (
5735 Reads a bit field in a 64-bit MSR, performs a bitwise OR, and
5736 writes the result back to the bit field in the 64-bit MSR.
5738 Reads the 64-bit MSR specified by Index, performs a bitwise OR
5739 between the read result and the value specified by OrData, and writes the
5740 result to the 64-bit MSR specified by Index. The value written to the MSR is
5741 returned. Extra left bits in OrData are stripped. The caller must either
5742 guarantee that Index and the data written is valid, or the caller must set up
5743 exception handlers to catch the exceptions. This function is only available
5746 If StartBit is greater than 63, then ASSERT().
5747 If EndBit is greater than 63, then ASSERT().
5748 If EndBit is less than StartBit, then ASSERT().
5749 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
5751 @param Index The 32-bit MSR index to write.
5752 @param StartBit The ordinal of the least significant bit in the bit field.
5754 @param EndBit The ordinal of the most significant bit in the bit field.
5756 @param OrData The value to OR with the read value from the bit field.
5758 @return The value written back to the MSR.
5763 AsmMsrBitFieldOr64 (
5772 Reads a bit field in a 64-bit MSR, performs a bitwise AND, and writes the
5773 result back to the bit field in the 64-bit MSR.
5775 Reads the 64-bit MSR specified by Index, performs a bitwise AND between the
5776 read result and the value specified by AndData, and writes the result to the
5777 64-bit MSR specified by Index. The value written to the MSR is returned.
5778 Extra left bits in AndData are stripped. The caller must either guarantee
5779 that Index and the data written is valid, or the caller must set up exception
5780 handlers to catch the exceptions. This function is only available on IA-32
5783 If StartBit is greater than 63, then ASSERT().
5784 If EndBit is greater than 63, then ASSERT().
5785 If EndBit is less than StartBit, then ASSERT().
5786 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
5788 @param Index The 32-bit MSR index to write.
5789 @param StartBit The ordinal of the least significant bit in the bit field.
5791 @param EndBit The ordinal of the most significant bit in the bit field.
5793 @param AndData The value to AND with the read value from the bit field.
5795 @return The value written back to the MSR.
5800 AsmMsrBitFieldAnd64 (
5809 Reads a bit field in a 64-bit MSR, performs a bitwise AND followed by a
5810 bitwise OR, and writes the result back to the bit field in the
5813 Reads the 64-bit MSR specified by Index, performs a bitwise AND followed by
5814 a bitwise OR between the read result and the value specified by
5815 AndData, and writes the result to the 64-bit MSR specified by Index. The
5816 value written to the MSR is returned. Extra left bits in both AndData and
5817 OrData are stripped. The caller must either guarantee that Index and the data
5818 written is valid, or the caller must set up exception handlers to catch the
5819 exceptions. This function is only available on IA-32 and x64.
5821 If StartBit is greater than 63, then ASSERT().
5822 If EndBit is greater than 63, then ASSERT().
5823 If EndBit is less than StartBit, then ASSERT().
5824 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
5825 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
5827 @param Index The 32-bit MSR index to write.
5828 @param StartBit The ordinal of the least significant bit in the bit field.
5830 @param EndBit The ordinal of the most significant bit in the bit field.
5832 @param AndData The value to AND with the read value from the bit field.
5833 @param OrData The value to OR with the result of the AND operation.
5835 @return The value written back to the MSR.
5840 AsmMsrBitFieldAndThenOr64 (
5850 Reads the current value of the EFLAGS register.
5852 Reads and returns the current value of the EFLAGS register. This function is
5853 only available on IA-32 and x64. This returns a 32-bit value on IA-32 and a
5854 64-bit value on x64.
5856 @return EFLAGS on IA-32 or RFLAGS on x64.
5867 Reads the current value of the Control Register 0 (CR0).
5869 Reads and returns the current value of CR0. This function is only available
5870 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
5873 @return The value of the Control Register 0 (CR0).
5884 Reads the current value of the Control Register 2 (CR2).
5886 Reads and returns the current value of CR2. This function is only available
5887 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
5890 @return The value of the Control Register 2 (CR2).
5901 Reads the current value of the Control Register 3 (CR3).
5903 Reads and returns the current value of CR3. This function is only available
5904 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
5907 @return The value of the Control Register 3 (CR3).
5918 Reads the current value of the Control Register 4 (CR4).
5920 Reads and returns the current value of CR4. This function is only available
5921 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
5924 @return The value of the Control Register 4 (CR4).
5935 Writes a value to Control Register 0 (CR0).
5937 Writes and returns a new value to CR0. This function is only available on
5938 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
5940 @param Cr0 The value to write to CR0.
5942 @return The value written to CR0.
5953 Writes a value to Control Register 2 (CR2).
5955 Writes and returns a new value to CR2. This function is only available on
5956 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
5958 @param Cr2 The value to write to CR2.
5960 @return The value written to CR2.
5971 Writes a value to Control Register 3 (CR3).
5973 Writes and returns a new value to CR3. This function is only available on
5974 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
5976 @param Cr3 The value to write to CR3.
5978 @return The value written to CR3.
5989 Writes a value to Control Register 4 (CR4).
5991 Writes and returns a new value to CR4. This function is only available on
5992 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
5994 @param Cr4 The value to write to CR4.
5996 @return The value written to CR4.
6007 Reads the current value of Debug Register 0 (DR0).
6009 Reads and returns the current value of DR0. This function is only available
6010 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
6013 @return The value of Debug Register 0 (DR0).
6024 Reads the current value of Debug Register 1 (DR1).
6026 Reads and returns the current value of DR1. This function is only available
6027 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
6030 @return The value of Debug Register 1 (DR1).
6041 Reads the current value of Debug Register 2 (DR2).
6043 Reads and returns the current value of DR2. This function is only available
6044 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
6047 @return The value of Debug Register 2 (DR2).
6058 Reads the current value of Debug Register 3 (DR3).
6060 Reads and returns the current value of DR3. This function is only available
6061 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
6064 @return The value of Debug Register 3 (DR3).
6075 Reads the current value of Debug Register 4 (DR4).
6077 Reads and returns the current value of DR4. This function is only available
6078 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
6081 @return The value of Debug Register 4 (DR4).
6092 Reads the current value of Debug Register 5 (DR5).
6094 Reads and returns the current value of DR5. This function is only available
6095 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
6098 @return The value of Debug Register 5 (DR5).
6109 Reads the current value of Debug Register 6 (DR6).
6111 Reads and returns the current value of DR6. This function is only available
6112 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
6115 @return The value of Debug Register 6 (DR6).
6126 Reads the current value of Debug Register 7 (DR7).
6128 Reads and returns the current value of DR7. This function is only available
6129 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
6132 @return The value of Debug Register 7 (DR7).
6143 Writes a value to Debug Register 0 (DR0).
6145 Writes and returns a new value to DR0. This function is only available on
6146 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
6148 @param Dr0 The value to write to Dr0.
6150 @return The value written to Debug Register 0 (DR0).
6161 Writes a value to Debug Register 1 (DR1).
6163 Writes and returns a new value to DR1. This function is only available on
6164 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
6166 @param Dr1 The value to write to Dr1.
6168 @return The value written to Debug Register 1 (DR1).
6179 Writes a value to Debug Register 2 (DR2).
6181 Writes and returns a new value to DR2. This function is only available on
6182 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
6184 @param Dr2 The value to write to Dr2.
6186 @return The value written to Debug Register 2 (DR2).
6197 Writes a value to Debug Register 3 (DR3).
6199 Writes and returns a new value to DR3. This function is only available on
6200 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
6202 @param Dr3 The value to write to Dr3.
6204 @return The value written to Debug Register 3 (DR3).
6215 Writes a value to Debug Register 4 (DR4).
6217 Writes and returns a new value to DR4. This function is only available on
6218 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
6220 @param Dr4 The value to write to Dr4.
6222 @return The value written to Debug Register 4 (DR4).
6233 Writes a value to Debug Register 5 (DR5).
6235 Writes and returns a new value to DR5. This function is only available on
6236 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
6238 @param Dr5 The value to write to Dr5.
6240 @return The value written to Debug Register 5 (DR5).
6251 Writes a value to Debug Register 6 (DR6).
6253 Writes and returns a new value to DR6. This function is only available on
6254 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
6256 @param Dr6 The value to write to Dr6.
6258 @return The value written to Debug Register 6 (DR6).
6269 Writes a value to Debug Register 7 (DR7).
6271 Writes and returns a new value to DR7. This function is only available on
6272 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
6274 @param Dr7 The value to write to Dr7.
6276 @return The value written to Debug Register 7 (DR7).
6287 Reads the current value of Code Segment Register (CS).
6289 Reads and returns the current value of CS. This function is only available on
6292 @return The current value of CS.
6303 Reads the current value of Data Segment Register (DS).
6305 Reads and returns the current value of DS. This function is only available on
6308 @return The current value of DS.
6319 Reads the current value of Extra Segment Register (ES).
6321 Reads and returns the current value of ES. This function is only available on
6324 @return The current value of ES.
6335 Reads the current value of FS Data Segment Register (FS).
6337 Reads and returns the current value of FS. This function is only available on
6340 @return The current value of FS.
6351 Reads the current value of GS Data Segment Register (GS).
6353 Reads and returns the current value of GS. This function is only available on
6356 @return The current value of GS.
6367 Reads the current value of Stack Segment Register (SS).
6369 Reads and returns the current value of SS. This function is only available on
6372 @return The current value of SS.
6383 Reads the current value of Task Register (TR).
6385 Reads and returns the current value of TR. This function is only available on
6388 @return The current value of TR.
6399 Reads the current Global Descriptor Table Register(GDTR) descriptor.
6401 Reads and returns the current GDTR descriptor and returns it in Gdtr. This
6402 function is only available on IA-32 and x64.
6404 If Gdtr is NULL, then ASSERT().
6406 @param Gdtr The pointer to a GDTR descriptor.
6412 OUT IA32_DESCRIPTOR
*Gdtr
6417 Writes the current Global Descriptor Table Register (GDTR) descriptor.
6419 Writes and the current GDTR descriptor specified by Gdtr. This function is
6420 only available on IA-32 and x64.
6422 If Gdtr is NULL, then ASSERT().
6424 @param Gdtr The pointer to a GDTR descriptor.
6430 IN CONST IA32_DESCRIPTOR
*Gdtr
6435 Reads the current Interrupt Descriptor Table Register(IDTR) descriptor.
6437 Reads and returns the current IDTR descriptor and returns it in Idtr. This
6438 function is only available on IA-32 and x64.
6440 If Idtr is NULL, then ASSERT().
6442 @param Idtr The pointer to a IDTR descriptor.
6448 OUT IA32_DESCRIPTOR
*Idtr
6453 Writes the current Interrupt Descriptor Table Register(IDTR) descriptor.
6455 Writes the current IDTR descriptor and returns it in Idtr. This function is
6456 only available on IA-32 and x64.
6458 If Idtr is NULL, then ASSERT().
6460 @param Idtr The pointer to a IDTR descriptor.
6466 IN CONST IA32_DESCRIPTOR
*Idtr
6471 Reads the current Local Descriptor Table Register(LDTR) selector.
6473 Reads and returns the current 16-bit LDTR descriptor value. This function is
6474 only available on IA-32 and x64.
6476 @return The current selector of LDT.
6487 Writes the current Local Descriptor Table Register (LDTR) selector.
6489 Writes and the current LDTR descriptor specified by Ldtr. This function is
6490 only available on IA-32 and x64.
6492 @param Ldtr 16-bit LDTR selector value.
6503 Save the current floating point/SSE/SSE2 context to a buffer.
6505 Saves the current floating point/SSE/SSE2 state to the buffer specified by
6506 Buffer. Buffer must be aligned on a 16-byte boundary. This function is only
6507 available on IA-32 and x64.
6509 If Buffer is NULL, then ASSERT().
6510 If Buffer is not aligned on a 16-byte boundary, then ASSERT().
6512 @param Buffer The pointer to a buffer to save the floating point/SSE/SSE2 context.
6518 OUT IA32_FX_BUFFER
*Buffer
6523 Restores the current floating point/SSE/SSE2 context from a buffer.
6525 Restores the current floating point/SSE/SSE2 state from the buffer specified
6526 by Buffer. Buffer must be aligned on a 16-byte boundary. This function is
6527 only available on IA-32 and x64.
6529 If Buffer is NULL, then ASSERT().
6530 If Buffer is not aligned on a 16-byte boundary, then ASSERT().
6531 If Buffer was not saved with AsmFxSave(), then ASSERT().
6533 @param Buffer The pointer to a buffer to save the floating point/SSE/SSE2 context.
6539 IN CONST IA32_FX_BUFFER
*Buffer
6544 Reads the current value of 64-bit MMX Register #0 (MM0).
6546 Reads and returns the current value of MM0. This function is only available
6549 @return The current value of MM0.
6560 Reads the current value of 64-bit MMX Register #1 (MM1).
6562 Reads and returns the current value of MM1. This function is only available
6565 @return The current value of MM1.
6576 Reads the current value of 64-bit MMX Register #2 (MM2).
6578 Reads and returns the current value of MM2. This function is only available
6581 @return The current value of MM2.
6592 Reads the current value of 64-bit MMX Register #3 (MM3).
6594 Reads and returns the current value of MM3. This function is only available
6597 @return The current value of MM3.
6608 Reads the current value of 64-bit MMX Register #4 (MM4).
6610 Reads and returns the current value of MM4. This function is only available
6613 @return The current value of MM4.
6624 Reads the current value of 64-bit MMX Register #5 (MM5).
6626 Reads and returns the current value of MM5. This function is only available
6629 @return The current value of MM5.
6640 Reads the current value of 64-bit MMX Register #6 (MM6).
6642 Reads and returns the current value of MM6. This function is only available
6645 @return The current value of MM6.
6656 Reads the current value of 64-bit MMX Register #7 (MM7).
6658 Reads and returns the current value of MM7. This function is only available
6661 @return The current value of MM7.
6672 Writes the current value of 64-bit MMX Register #0 (MM0).
6674 Writes the current value of MM0. This function is only available on IA32 and
6677 @param Value The 64-bit value to write to MM0.
6688 Writes the current value of 64-bit MMX Register #1 (MM1).
6690 Writes the current value of MM1. This function is only available on IA32 and
6693 @param Value The 64-bit value to write to MM1.
6704 Writes the current value of 64-bit MMX Register #2 (MM2).
6706 Writes the current value of MM2. This function is only available on IA32 and
6709 @param Value The 64-bit value to write to MM2.
6720 Writes the current value of 64-bit MMX Register #3 (MM3).
6722 Writes the current value of MM3. This function is only available on IA32 and
6725 @param Value The 64-bit value to write to MM3.
6736 Writes the current value of 64-bit MMX Register #4 (MM4).
6738 Writes the current value of MM4. This function is only available on IA32 and
6741 @param Value The 64-bit value to write to MM4.
6752 Writes the current value of 64-bit MMX Register #5 (MM5).
6754 Writes the current value of MM5. This function is only available on IA32 and
6757 @param Value The 64-bit value to write to MM5.
6768 Writes the current value of 64-bit MMX Register #6 (MM6).
6770 Writes the current value of MM6. This function is only available on IA32 and
6773 @param Value The 64-bit value to write to MM6.
6784 Writes the current value of 64-bit MMX Register #7 (MM7).
6786 Writes the current value of MM7. This function is only available on IA32 and
6789 @param Value The 64-bit value to write to MM7.
6800 Reads the current value of Time Stamp Counter (TSC).
6802 Reads and returns the current value of TSC. This function is only available
6805 @return The current value of TSC
6816 Reads the current value of a Performance Counter (PMC).
6818 Reads and returns the current value of performance counter specified by
6819 Index. This function is only available on IA-32 and x64.
6821 @param Index The 32-bit Performance Counter index to read.
6823 @return The value of the PMC specified by Index.
6834 Sets up a monitor buffer that is used by AsmMwait().
6836 Executes a MONITOR instruction with the register state specified by Eax, Ecx
6837 and Edx. Returns Eax. This function is only available on IA-32 and x64.
6839 @param Eax The value to load into EAX or RAX before executing the MONITOR
6841 @param Ecx The value to load into ECX or RCX before executing the MONITOR
6843 @param Edx The value to load into EDX or RDX before executing the MONITOR
6859 Executes an MWAIT instruction.
6861 Executes an MWAIT instruction with the register state specified by Eax and
6862 Ecx. Returns Eax. This function is only available on IA-32 and x64.
6864 @param Eax The value to load into EAX or RAX before executing the MONITOR
6866 @param Ecx The value to load into ECX or RCX before executing the MONITOR
6881 Executes a WBINVD instruction.
6883 Executes a WBINVD instruction. This function is only available on IA-32 and
6895 Executes a INVD instruction.
6897 Executes a INVD instruction. This function is only available on IA-32 and
6909 Flushes a cache line from all the instruction and data caches within the
6910 coherency domain of the CPU.
6912 Flushed the cache line specified by LinearAddress, and returns LinearAddress.
6913 This function is only available on IA-32 and x64.
6915 @param LinearAddress The address of the cache line to flush. If the CPU is
6916 in a physical addressing mode, then LinearAddress is a
6917 physical address. If the CPU is in a virtual
6918 addressing mode, then LinearAddress is a virtual
6921 @return LinearAddress.
6926 IN VOID
*LinearAddress
6931 Enables the 32-bit paging mode on the CPU.
6933 Enables the 32-bit paging mode on the CPU. CR0, CR3, CR4, and the page tables
6934 must be properly initialized prior to calling this service. This function
6935 assumes the current execution mode is 32-bit protected mode. This function is
6936 only available on IA-32. After the 32-bit paging mode is enabled, control is
6937 transferred to the function specified by EntryPoint using the new stack
6938 specified by NewStack and passing in the parameters specified by Context1 and
6939 Context2. Context1 and Context2 are optional and may be NULL. The function
6940 EntryPoint must never return.
6942 If the current execution mode is not 32-bit protected mode, then ASSERT().
6943 If EntryPoint is NULL, then ASSERT().
6944 If NewStack is NULL, then ASSERT().
6946 There are a number of constraints that must be followed before calling this
6948 1) Interrupts must be disabled.
6949 2) The caller must be in 32-bit protected mode with flat descriptors. This
6950 means all descriptors must have a base of 0 and a limit of 4GB.
6951 3) CR0 and CR4 must be compatible with 32-bit protected mode with flat
6953 4) CR3 must point to valid page tables that will be used once the transition
6954 is complete, and those page tables must guarantee that the pages for this
6955 function and the stack are identity mapped.
6957 @param EntryPoint A pointer to function to call with the new stack after
6959 @param Context1 A pointer to the context to pass into the EntryPoint
6960 function as the first parameter after paging is enabled.
6961 @param Context2 A pointer to the context to pass into the EntryPoint
6962 function as the second parameter after paging is enabled.
6963 @param NewStack A pointer to the new stack to use for the EntryPoint
6964 function after paging is enabled.
6970 IN SWITCH_STACK_ENTRY_POINT EntryPoint
,
6971 IN VOID
*Context1
, OPTIONAL
6972 IN VOID
*Context2
, OPTIONAL
6978 Disables the 32-bit paging mode on the CPU.
6980 Disables the 32-bit paging mode on the CPU and returns to 32-bit protected
6981 mode. This function assumes the current execution mode is 32-paged protected
6982 mode. This function is only available on IA-32. After the 32-bit paging mode
6983 is disabled, control is transferred to the function specified by EntryPoint
6984 using the new stack specified by NewStack and passing in the parameters
6985 specified by Context1 and Context2. Context1 and Context2 are optional and
6986 may be NULL. The function EntryPoint must never return.
6988 If the current execution mode is not 32-bit paged mode, then ASSERT().
6989 If EntryPoint is NULL, then ASSERT().
6990 If NewStack is NULL, then ASSERT().
6992 There are a number of constraints that must be followed before calling this
6994 1) Interrupts must be disabled.
6995 2) The caller must be in 32-bit paged mode.
6996 3) CR0, CR3, and CR4 must be compatible with 32-bit paged mode.
6997 4) CR3 must point to valid page tables that guarantee that the pages for
6998 this function and the stack are identity mapped.
7000 @param EntryPoint A pointer to function to call with the new stack after
7002 @param Context1 A pointer to the context to pass into the EntryPoint
7003 function as the first parameter after paging is disabled.
7004 @param Context2 A pointer to the context to pass into the EntryPoint
7005 function as the second parameter after paging is
7007 @param NewStack A pointer to the new stack to use for the EntryPoint
7008 function after paging is disabled.
7013 AsmDisablePaging32 (
7014 IN SWITCH_STACK_ENTRY_POINT EntryPoint
,
7015 IN VOID
*Context1
, OPTIONAL
7016 IN VOID
*Context2
, OPTIONAL
7022 Enables the 64-bit paging mode on the CPU.
7024 Enables the 64-bit paging mode on the CPU. CR0, CR3, CR4, and the page tables
7025 must be properly initialized prior to calling this service. This function
7026 assumes the current execution mode is 32-bit protected mode with flat
7027 descriptors. This function is only available on IA-32. After the 64-bit
7028 paging mode is enabled, control is transferred to the function specified by
7029 EntryPoint using the new stack specified by NewStack and passing in the
7030 parameters specified by Context1 and Context2. Context1 and Context2 are
7031 optional and may be 0. The function EntryPoint must never return.
7033 If the current execution mode is not 32-bit protected mode with flat
7034 descriptors, then ASSERT().
7035 If EntryPoint is 0, then ASSERT().
7036 If NewStack is 0, then ASSERT().
7038 @param Cs The 16-bit selector to load in the CS before EntryPoint
7039 is called. The descriptor in the GDT that this selector
7040 references must be setup for long mode.
7041 @param EntryPoint The 64-bit virtual address of the function to call with
7042 the new stack after paging is enabled.
7043 @param Context1 The 64-bit virtual address of the context to pass into
7044 the EntryPoint function as the first parameter after
7046 @param Context2 The 64-bit virtual address of the context to pass into
7047 the EntryPoint function as the second parameter after
7049 @param NewStack The 64-bit virtual address of the new stack to use for
7050 the EntryPoint function after paging is enabled.
7057 IN UINT64 EntryPoint
,
7058 IN UINT64 Context1
, OPTIONAL
7059 IN UINT64 Context2
, OPTIONAL
7065 Disables the 64-bit paging mode on the CPU.
7067 Disables the 64-bit paging mode on the CPU and returns to 32-bit protected
7068 mode. This function assumes the current execution mode is 64-paging mode.
7069 This function is only available on x64. After the 64-bit paging mode is
7070 disabled, control is transferred to the function specified by EntryPoint
7071 using the new stack specified by NewStack and passing in the parameters
7072 specified by Context1 and Context2. Context1 and Context2 are optional and
7073 may be 0. The function EntryPoint must never return.
7075 If the current execution mode is not 64-bit paged mode, then ASSERT().
7076 If EntryPoint is 0, then ASSERT().
7077 If NewStack is 0, then ASSERT().
7079 @param Cs The 16-bit selector to load in the CS before EntryPoint
7080 is called. The descriptor in the GDT that this selector
7081 references must be setup for 32-bit protected mode.
7082 @param EntryPoint The 64-bit virtual address of the function to call with
7083 the new stack after paging is disabled.
7084 @param Context1 The 64-bit virtual address of the context to pass into
7085 the EntryPoint function as the first parameter after
7087 @param Context2 The 64-bit virtual address of the context to pass into
7088 the EntryPoint function as the second parameter after
7090 @param NewStack The 64-bit virtual address of the new stack to use for
7091 the EntryPoint function after paging is disabled.
7096 AsmDisablePaging64 (
7098 IN UINT32 EntryPoint
,
7099 IN UINT32 Context1
, OPTIONAL
7100 IN UINT32 Context2
, OPTIONAL
7106 // 16-bit thunking services
7110 Retrieves the properties for 16-bit thunk functions.
7112 Computes the size of the buffer and stack below 1MB required to use the
7113 AsmPrepareThunk16(), AsmThunk16() and AsmPrepareAndThunk16() functions. This
7114 buffer size is returned in RealModeBufferSize, and the stack size is returned
7115 in ExtraStackSize. If parameters are passed to the 16-bit real mode code,
7116 then the actual minimum stack size is ExtraStackSize plus the maximum number
7117 of bytes that need to be passed to the 16-bit real mode code.
7119 If RealModeBufferSize is NULL, then ASSERT().
7120 If ExtraStackSize is NULL, then ASSERT().
7122 @param RealModeBufferSize A pointer to the size of the buffer below 1MB
7123 required to use the 16-bit thunk functions.
7124 @param ExtraStackSize A pointer to the extra size of stack below 1MB
7125 that the 16-bit thunk functions require for
7126 temporary storage in the transition to and from
7132 AsmGetThunk16Properties (
7133 OUT UINT32
*RealModeBufferSize
,
7134 OUT UINT32
*ExtraStackSize
7139 Prepares all structures a code required to use AsmThunk16().
7141 Prepares all structures and code required to use AsmThunk16().
7143 This interface is limited to be used in either physical mode or virtual modes with paging enabled where the
7144 virtual to physical mappings for ThunkContext.RealModeBuffer is mapped 1:1.
7146 If ThunkContext is NULL, then ASSERT().
7148 @param ThunkContext A pointer to the context structure that describes the
7149 16-bit real mode code to call.
7155 IN OUT THUNK_CONTEXT
*ThunkContext
7160 Transfers control to a 16-bit real mode entry point and returns the results.
7162 Transfers control to a 16-bit real mode entry point and returns the results.
7163 AsmPrepareThunk16() must be called with ThunkContext before this function is used.
7164 This function must be called with interrupts disabled.
7166 The register state from the RealModeState field of ThunkContext is restored just prior
7167 to calling the 16-bit real mode entry point. This includes the EFLAGS field of RealModeState,
7168 which is used to set the interrupt state when a 16-bit real mode entry point is called.
7169 Control is transferred to the 16-bit real mode entry point specified by the CS and Eip fields of RealModeState.
7170 The stack is initialized to the SS and ESP fields of RealModeState. Any parameters passed to
7171 the 16-bit real mode code must be populated by the caller at SS:ESP prior to calling this function.
7172 The 16-bit real mode entry point is invoked with a 16-bit CALL FAR instruction,
7173 so when accessing stack contents, the 16-bit real mode code must account for the 16-bit segment
7174 and 16-bit offset of the return address that were pushed onto the stack. The 16-bit real mode entry
7175 point must exit with a RETF instruction. The register state is captured into RealModeState immediately
7176 after the RETF instruction is executed.
7178 If EFLAGS specifies interrupts enabled, or any of the 16-bit real mode code enables interrupts,
7179 or any of the 16-bit real mode code makes a SW interrupt, then the caller is responsible for making sure
7180 the IDT at address 0 is initialized to handle any HW or SW interrupts that may occur while in 16-bit real mode.
7182 If EFLAGS specifies interrupts enabled, or any of the 16-bit real mode code enables interrupts,
7183 then the caller is responsible for making sure the 8259 PIC is in a state compatible with 16-bit real mode.
7184 This includes the base vectors, the interrupt masks, and the edge/level trigger mode.
7186 If THUNK_ATTRIBUTE_BIG_REAL_MODE is set in the ThunkAttributes field of ThunkContext, then the user code
7187 is invoked in big real mode. Otherwise, the user code is invoked in 16-bit real mode with 64KB segment limits.
7189 If neither THUNK_ATTRIBUTE_DISABLE_A20_MASK_INT_15 nor THUNK_ATTRIBUTE_DISABLE_A20_MASK_KBD_CTRL are set in
7190 ThunkAttributes, then it is assumed that the user code did not enable the A20 mask, and no attempt is made to
7191 disable the A20 mask.
7193 If THUNK_ATTRIBUTE_DISABLE_A20_MASK_INT_15 is set and THUNK_ATTRIBUTE_DISABLE_A20_MASK_KBD_CTRL is clear in
7194 ThunkAttributes, then attempt to use the INT 15 service to disable the A20 mask. If this INT 15 call fails,
7195 then attempt to disable the A20 mask by directly accessing the 8042 keyboard controller I/O ports.
7197 If THUNK_ATTRIBUTE_DISABLE_A20_MASK_INT_15 is clear and THUNK_ATTRIBUTE_DISABLE_A20_MASK_KBD_CTRL is set in
7198 ThunkAttributes, then attempt to disable the A20 mask by directly accessing the 8042 keyboard controller I/O ports.
7200 If ThunkContext is NULL, then ASSERT().
7201 If AsmPrepareThunk16() was not previously called with ThunkContext, then ASSERT().
7202 If both THUNK_ATTRIBUTE_DISABLE_A20_MASK_INT_15 and THUNK_ATTRIBUTE_DISABLE_A20_MASK_KBD_CTRL are set in
7203 ThunkAttributes, then ASSERT().
7205 This interface is limited to be used in either physical mode or virtual modes with paging enabled where the
7206 virtual to physical mappings for ThunkContext.RealModeBuffer are mapped 1:1.
7208 @param ThunkContext A pointer to the context structure that describes the
7209 16-bit real mode code to call.
7215 IN OUT THUNK_CONTEXT
*ThunkContext
7220 Prepares all structures and code for a 16-bit real mode thunk, transfers
7221 control to a 16-bit real mode entry point, and returns the results.
7223 Prepares all structures and code for a 16-bit real mode thunk, transfers
7224 control to a 16-bit real mode entry point, and returns the results. If the
7225 caller only need to perform a single 16-bit real mode thunk, then this
7226 service should be used. If the caller intends to make more than one 16-bit
7227 real mode thunk, then it is more efficient if AsmPrepareThunk16() is called
7228 once and AsmThunk16() can be called for each 16-bit real mode thunk.
7230 This interface is limited to be used in either physical mode or virtual modes with paging enabled where the
7231 virtual to physical mappings for ThunkContext.RealModeBuffer is mapped 1:1.
7233 See AsmPrepareThunk16() and AsmThunk16() for the detailed description and ASSERT() conditions.
7235 @param ThunkContext A pointer to the context structure that describes the
7236 16-bit real mode code to call.
7241 AsmPrepareAndThunk16 (
7242 IN OUT THUNK_CONTEXT
*ThunkContext