2 Provides string functions, linked list functions, math functions, synchronization
3 functions, and CPU architecture-specific functions.
5 Copyright (c) 2006 - 2008, Intel Corporation<BR>
6 Portions Copyright (c) 2008-2009 Apple Inc.<BR>
7 All rights reserved. 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 /// 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 /// 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 /// 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 /// 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
; ///< 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 Pointer to a Null-terminated Unicode string.
171 @param Source 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 Pointer to a Null-terminated Unicode string.
208 @param Source Pointer to a Null-terminated Unicode string.
209 @param Length 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 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 Pointer to a Null-terminated Unicode string.
294 @param SecondString 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 Pointer to a Null-terminated Unicode string.
333 @param SecondString Pointer to a Null-terminated Unicode string.
334 @param Length 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 Pointer to a Null-terminated Unicode string.
376 @param Source 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 Pointer to a Null-terminated Unicode string.
420 @param Source Pointer to a Null-terminated Unicode string.
421 @param Length 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
445 If String is NULL, then ASSERT().
446 If String is not aligned on a 16-bit boundary, then ASSERT().
447 If SearchString is NULL, then ASSERT().
448 If SearchString is not aligned on a 16-bit boundary, then ASSERT().
450 If PcdMaximumUnicodeStringLength is not zero, and SearchString
451 or String contains more than PcdMaximumUnicodeStringLength Unicode
452 characters not including the Null-terminator, then ASSERT().
454 @param String Pointer to a Null-terminated Unicode string.
455 @param SearchString Pointer to a Null-terminated Unicode string to search for.
457 @retval NULL If the SearchString does not appear in String.
458 @return others If there is a match.
464 IN CONST CHAR16
*String
,
465 IN CONST CHAR16
*SearchString
469 Convert a Null-terminated Unicode decimal string to a value of
472 This function returns a value of type UINTN by interpreting the contents
473 of the Unicode string specified by String as a decimal number. The format
474 of the input Unicode string String is:
476 [spaces] [decimal digits].
478 The valid decimal digit character is in the range [0-9]. The
479 function will ignore the pad space, which includes spaces or
480 tab characters, before [decimal digits]. The running zero in the
481 beginning of [decimal digits] will be ignored. Then, the function
482 stops at the first character that is a not a valid decimal character
483 or a Null-terminator, whichever one comes first.
485 If String is NULL, then ASSERT().
486 If String is not aligned in a 16-bit boundary, then ASSERT().
487 If String has only pad spaces, then 0 is returned.
488 If String has no pad spaces or valid decimal digits,
490 If the number represented by String overflows according
491 to the range defined by UINTN, then ASSERT().
493 If PcdMaximumUnicodeStringLength is not zero, and String contains
494 more than PcdMaximumUnicodeStringLength Unicode characters not including
495 the Null-terminator, then ASSERT().
497 @param String Pointer to a Null-terminated Unicode string.
499 @retval Value translated from String.
505 IN CONST CHAR16
*String
509 Convert a Null-terminated Unicode decimal string to a value of
512 This function returns a value of type UINT64 by interpreting the contents
513 of the Unicode string specified by String as a decimal number. The format
514 of the input Unicode string String is:
516 [spaces] [decimal digits].
518 The valid decimal digit character is in the range [0-9]. The
519 function will ignore the pad space, which includes spaces or
520 tab characters, before [decimal digits]. The running zero in the
521 beginning of [decimal digits] will be ignored. Then, the function
522 stops at the first character that is a not a valid decimal character
523 or a Null-terminator, whichever one comes first.
525 If String is NULL, then ASSERT().
526 If String is not aligned in a 16-bit boundary, then ASSERT().
527 If String has only pad spaces, then 0 is returned.
528 If String has no pad spaces or valid decimal digits,
530 If the number represented by String overflows according
531 to the range defined by UINT64, then ASSERT().
533 If PcdMaximumUnicodeStringLength is not zero, and String contains
534 more than PcdMaximumUnicodeStringLength Unicode characters not including
535 the Null-terminator, then ASSERT().
537 @param String Pointer to a Null-terminated Unicode string.
539 @retval Value translated from String.
545 IN CONST CHAR16
*String
550 Convert a Null-terminated Unicode hexadecimal string to a value of type UINTN.
552 This function returns a value of type UINTN by interpreting the contents
553 of the Unicode string specified by String as a hexadecimal number.
554 The format of the input Unicode string String is:
556 [spaces][zeros][x][hexadecimal digits].
558 The valid hexadecimal digit character is in the range [0-9], [a-f] and [A-F].
559 The prefix "0x" is optional. Both "x" and "X" is allowed in "0x" prefix.
560 If "x" appears in the input string, it must be prefixed with at least one 0.
561 The function will ignore the pad space, which includes spaces or tab characters,
562 before [zeros], [x] or [hexadecimal digit]. The running zero before [x] or
563 [hexadecimal digit] will be ignored. Then, the decoding starts after [x] or the
564 first valid hexadecimal digit. Then, the function stops at the first character that is
565 a not a valid hexadecimal character or NULL, whichever one comes first.
567 If String is NULL, then ASSERT().
568 If String is not aligned in a 16-bit boundary, then ASSERT().
569 If String has only pad spaces, then zero is returned.
570 If String has no leading pad spaces, leading zeros or valid hexadecimal digits,
571 then zero is returned.
572 If the number represented by String overflows according to the range defined by
573 UINTN, then ASSERT().
575 If PcdMaximumUnicodeStringLength is not zero, and String contains more than
576 PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator,
579 @param String Pointer to a Null-terminated Unicode string.
581 @retval Value translated from String.
587 IN CONST CHAR16
*String
592 Convert a Null-terminated Unicode hexadecimal string to a value of type UINT64.
594 This function returns a value of type UINT64 by interpreting the contents
595 of the Unicode string specified by String as a hexadecimal number.
596 The format of the input Unicode string String is
598 [spaces][zeros][x][hexadecimal digits].
600 The valid hexadecimal digit character is in the range [0-9], [a-f] and [A-F].
601 The prefix "0x" is optional. Both "x" and "X" is allowed in "0x" prefix.
602 If "x" appears in the input string, it must be prefixed with at least one 0.
603 The function will ignore the pad space, which includes spaces or tab characters,
604 before [zeros], [x] or [hexadecimal digit]. The running zero before [x] or
605 [hexadecimal digit] will be ignored. Then, the decoding starts after [x] or the
606 first valid hexadecimal digit. Then, the function stops at the first character that is
607 a not a valid hexadecimal character or NULL, whichever one comes first.
609 If String is NULL, then ASSERT().
610 If String is not aligned in a 16-bit boundary, then ASSERT().
611 If String has only pad spaces, then zero is returned.
612 If String has no leading pad spaces, leading zeros or valid hexadecimal digits,
613 then zero is returned.
614 If the number represented by String overflows according to the range defined by
615 UINT64, then ASSERT().
617 If PcdMaximumUnicodeStringLength is not zero, and String contains more than
618 PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator,
621 @param String Pointer to a Null-terminated Unicode string.
623 @retval Value translated from String.
629 IN CONST CHAR16
*String
633 Convert a Null-terminated Unicode string to a Null-terminated
634 ASCII string and returns the ASCII string.
636 This function converts the content of the Unicode string Source
637 to the ASCII string Destination by copying the lower 8 bits of
638 each Unicode character. It returns Destination.
640 If any Unicode characters in Source contain non-zero value in
641 the upper 8 bits, then ASSERT().
643 If Destination is NULL, then ASSERT().
644 If Source is NULL, then ASSERT().
645 If Source is not aligned on a 16-bit boundary, then ASSERT().
646 If Source and Destination overlap, then ASSERT().
648 If PcdMaximumUnicodeStringLength is not zero, and Source contains
649 more than PcdMaximumUnicodeStringLength Unicode characters not including
650 the Null-terminator, then ASSERT().
652 If PcdMaximumAsciiStringLength is not zero, and Source contains more
653 than PcdMaximumAsciiStringLength Unicode characters not including the
654 Null-terminator, then ASSERT().
656 @param Source Pointer to a Null-terminated Unicode string.
657 @param Destination Pointer to a Null-terminated ASCII string.
664 UnicodeStrToAsciiStr (
665 IN CONST CHAR16
*Source
,
666 OUT CHAR8
*Destination
671 Copies one Null-terminated ASCII string to another Null-terminated ASCII
672 string and returns the new ASCII string.
674 This function copies the contents of the ASCII string Source to the ASCII
675 string Destination, and returns Destination. If Source and Destination
676 overlap, then the results are undefined.
678 If Destination is NULL, then ASSERT().
679 If Source is NULL, then ASSERT().
680 If Source and Destination overlap, then ASSERT().
681 If PcdMaximumAsciiStringLength is not zero and Source contains more than
682 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
685 @param Destination Pointer to a Null-terminated ASCII string.
686 @param Source Pointer to a Null-terminated ASCII string.
694 OUT CHAR8
*Destination
,
695 IN CONST CHAR8
*Source
700 Copies up to a specified length one Null-terminated ASCII string to another
701 Null-terminated ASCII string and returns the new ASCII string.
703 This function copies the contents of the ASCII string Source to the ASCII
704 string Destination, and returns Destination. At most, Length ASCII characters
705 are copied from Source to Destination. If Length is 0, then Destination is
706 returned unmodified. If Length is greater that the number of ASCII characters
707 in Source, then Destination is padded with Null ASCII characters. If Source
708 and Destination overlap, then the results are undefined.
710 If Destination is NULL, then ASSERT().
711 If Source is NULL, then ASSERT().
712 If Source and Destination overlap, then ASSERT().
713 If PcdMaximumAsciiStringLength is not zero, and Length is greater than
714 PcdMaximumAsciiStringLength, then ASSERT().
715 If PcdMaximumAsciiStringLength is not zero, and Source contains more than
716 PcdMaximumAsciiStringLength ASCII characters, not including the Null-terminator,
719 @param Destination Pointer to a Null-terminated ASCII string.
720 @param Source Pointer to a Null-terminated ASCII string.
721 @param Length Maximum number of ASCII characters to copy.
729 OUT CHAR8
*Destination
,
730 IN CONST CHAR8
*Source
,
736 Returns the length of a Null-terminated ASCII string.
738 This function returns the number of ASCII characters in the Null-terminated
739 ASCII string specified by String.
741 If Length > 0 and Destination is NULL, then ASSERT().
742 If Length > 0 and Source is NULL, then ASSERT().
743 If PcdMaximumAsciiStringLength is not zero and String contains more than
744 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
747 @param String Pointer to a Null-terminated ASCII string.
749 @return The length of String.
755 IN CONST CHAR8
*String
760 Returns the size of a Null-terminated ASCII string in bytes, including the
763 This function returns the size, in bytes, of the Null-terminated ASCII string
766 If String is NULL, then ASSERT().
767 If PcdMaximumAsciiStringLength is not zero and String contains more than
768 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
771 @param String Pointer to a Null-terminated ASCII string.
773 @return The size of String.
779 IN CONST CHAR8
*String
784 Compares two Null-terminated ASCII strings, and returns the difference
785 between the first mismatched ASCII characters.
787 This function compares the Null-terminated ASCII string FirstString to the
788 Null-terminated ASCII string SecondString. If FirstString is identical to
789 SecondString, then 0 is returned. Otherwise, the value returned is the first
790 mismatched ASCII character in SecondString subtracted from the first
791 mismatched ASCII character in FirstString.
793 If FirstString is NULL, then ASSERT().
794 If SecondString is NULL, then ASSERT().
795 If PcdMaximumAsciiStringLength is not zero and FirstString contains more than
796 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
798 If PcdMaximumAsciiStringLength is not zero and SecondString contains more
799 than PcdMaximumAsciiStringLength ASCII characters not including the
800 Null-terminator, then ASSERT().
802 @param FirstString Pointer to a Null-terminated ASCII string.
803 @param SecondString Pointer to a Null-terminated ASCII string.
805 @retval ==0 FirstString is identical to SecondString.
806 @retval !=0 FirstString is not identical to SecondString.
812 IN CONST CHAR8
*FirstString
,
813 IN CONST CHAR8
*SecondString
818 Performs a case insensitive comparison of two Null-terminated ASCII strings,
819 and returns the difference between the first mismatched ASCII characters.
821 This function performs a case insensitive comparison of the Null-terminated
822 ASCII string FirstString to the Null-terminated ASCII string SecondString. If
823 FirstString is identical to SecondString, then 0 is returned. Otherwise, the
824 value returned is the first mismatched lower case ASCII character in
825 SecondString subtracted from the first mismatched lower case ASCII character
828 If FirstString is NULL, then ASSERT().
829 If SecondString is NULL, then ASSERT().
830 If PcdMaximumAsciiStringLength is not zero and FirstString contains more than
831 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
833 If PcdMaximumAsciiStringLength is not zero and SecondString contains more
834 than PcdMaximumAsciiStringLength ASCII characters not including the
835 Null-terminator, then ASSERT().
837 @param FirstString Pointer to a Null-terminated ASCII string.
838 @param SecondString Pointer to a Null-terminated ASCII string.
840 @retval ==0 FirstString is identical to SecondString using case insensitive
842 @retval !=0 FirstString is not identical to SecondString using case
843 insensitive comparisons.
849 IN CONST CHAR8
*FirstString
,
850 IN CONST CHAR8
*SecondString
855 Compares two Null-terminated ASCII strings with maximum lengths, and returns
856 the difference between the first mismatched ASCII characters.
858 This function compares the Null-terminated ASCII string FirstString to the
859 Null-terminated ASCII string SecondString. At most, Length ASCII characters
860 will be compared. If Length is 0, then 0 is returned. If FirstString is
861 identical to SecondString, then 0 is returned. Otherwise, the value returned
862 is the first mismatched ASCII character in SecondString subtracted from the
863 first mismatched ASCII character in FirstString.
865 If Length > 0 and FirstString is NULL, then ASSERT().
866 If Length > 0 and SecondString is NULL, then ASSERT().
867 If PcdMaximumAsciiStringLength is not zero, and Length is greater than
868 PcdMaximumAsciiStringLength, then ASSERT().
869 If PcdMaximumAsciiStringLength is not zero, and FirstString contains more than
870 PcdMaximumAsciiStringLength ASCII characters, not including the Null-terminator,
872 If PcdMaximumAsciiStringLength is not zero, and SecondString contains more than
873 PcdMaximumAsciiStringLength ASCII characters, not including the Null-terminator,
876 @param FirstString Pointer to a Null-terminated ASCII string.
877 @param SecondString Pointer to a Null-terminated ASCII string.
878 @param Length Maximum number of ASCII characters for compare.
880 @retval ==0 FirstString is identical to SecondString.
881 @retval !=0 FirstString is not identical to SecondString.
887 IN CONST CHAR8
*FirstString
,
888 IN CONST CHAR8
*SecondString
,
894 Concatenates one Null-terminated ASCII string to another Null-terminated
895 ASCII string, and returns the concatenated ASCII string.
897 This function concatenates two Null-terminated ASCII strings. The contents of
898 Null-terminated ASCII string Source are concatenated to the end of Null-
899 terminated ASCII string Destination. The Null-terminated concatenated ASCII
902 If Destination is NULL, then ASSERT().
903 If Source is NULL, then ASSERT().
904 If PcdMaximumAsciiStringLength is not zero and Destination contains more than
905 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
907 If PcdMaximumAsciiStringLength is not zero and Source contains more than
908 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
910 If PcdMaximumAsciiStringLength is not zero and concatenating Destination and
911 Source results in a ASCII string with more than PcdMaximumAsciiStringLength
912 ASCII characters, then ASSERT().
914 @param Destination Pointer to a Null-terminated ASCII string.
915 @param Source Pointer to a Null-terminated ASCII string.
923 IN OUT CHAR8
*Destination
,
924 IN CONST CHAR8
*Source
929 Concatenates up to a specified length one Null-terminated ASCII string to
930 the end of another Null-terminated ASCII string, and returns the
931 concatenated ASCII string.
933 This function concatenates two Null-terminated ASCII strings. The contents
934 of Null-terminated ASCII string Source are concatenated to the end of Null-
935 terminated ASCII string Destination, and Destination is returned. At most,
936 Length ASCII characters are concatenated from Source to the end of
937 Destination, and Destination is always Null-terminated. If Length is 0, then
938 Destination is returned unmodified. If Source and Destination overlap, then
939 the results are undefined.
941 If Length > 0 and Destination is NULL, then ASSERT().
942 If Length > 0 and Source is NULL, then ASSERT().
943 If Source and Destination overlap, then ASSERT().
944 If PcdMaximumAsciiStringLength is not zero, and Length is greater than
945 PcdMaximumAsciiStringLength, then ASSERT().
946 If PcdMaximumAsciiStringLength is not zero, and Destination contains more than
947 PcdMaximumAsciiStringLength ASCII characters, not including the Null-terminator,
949 If PcdMaximumAsciiStringLength is not zero, and Source contains more than
950 PcdMaximumAsciiStringLength ASCII characters, not including the Null-terminator,
952 If PcdMaximumAsciiStringLength is not zero, and concatenating Destination and
953 Source results in a ASCII string with more than PcdMaximumAsciiStringLength
954 ASCII characters, not including the Null-terminator, then ASSERT().
956 @param Destination Pointer to a Null-terminated ASCII string.
957 @param Source Pointer to a Null-terminated ASCII string.
958 @param Length Maximum number of ASCII characters to concatenate from
967 IN OUT CHAR8
*Destination
,
968 IN CONST CHAR8
*Source
,
974 Returns the first occurrence of a Null-terminated ASCII sub-string
975 in a Null-terminated ASCII string.
977 This function scans the contents of the ASCII string specified by String
978 and returns the first occurrence of SearchString. If SearchString is not
979 found in String, then NULL is returned. If the length of SearchString is zero,
980 then String is returned.
982 If String is NULL, then ASSERT().
983 If SearchString is NULL, then ASSERT().
985 If PcdMaximumAsciiStringLength is not zero, and SearchString or
986 String contains more than PcdMaximumAsciiStringLength Unicode characters
987 not including the Null-terminator, then ASSERT().
989 @param String Pointer to a Null-terminated ASCII string.
990 @param SearchString Pointer to a Null-terminated ASCII string to search for.
992 @retval NULL If the SearchString does not appear in String.
993 @retval others If there is a match return the first occurrence of SearchingString.
994 If the length of SearchString is zero,return String.
1000 IN CONST CHAR8
*String
,
1001 IN CONST CHAR8
*SearchString
1006 Convert a Null-terminated ASCII decimal string to a value of type
1009 This function returns a value of type UINTN by interpreting the contents
1010 of the ASCII string String as a decimal number. The format of the input
1011 ASCII string String is:
1013 [spaces] [decimal digits].
1015 The valid decimal digit character is in the range [0-9]. The function will
1016 ignore the pad space, which includes spaces or tab characters, before the digits.
1017 The running zero in the beginning of [decimal digits] will be ignored. Then, the
1018 function stops at the first character that is a not a valid decimal character or
1019 Null-terminator, whichever on comes first.
1021 If String has only pad spaces, then 0 is returned.
1022 If String has no pad spaces or valid decimal digits, then 0 is returned.
1023 If the number represented by String overflows according to the range defined by
1024 UINTN, then ASSERT().
1025 If String is NULL, then ASSERT().
1026 If PcdMaximumAsciiStringLength is not zero, and String contains more than
1027 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
1030 @param String Pointer to a Null-terminated ASCII string.
1032 @retval Value translated from String.
1037 AsciiStrDecimalToUintn (
1038 IN CONST CHAR8
*String
1043 Convert a Null-terminated ASCII decimal string to a value of type
1046 This function returns a value of type UINT64 by interpreting the contents
1047 of the ASCII string String as a decimal number. The format of the input
1048 ASCII string String is:
1050 [spaces] [decimal digits].
1052 The valid decimal digit character is in the range [0-9]. The function will
1053 ignore the pad space, which includes spaces or tab characters, before the digits.
1054 The running zero in the beginning of [decimal digits] will be ignored. Then, the
1055 function stops at the first character that is a not a valid decimal character or
1056 Null-terminator, whichever on comes first.
1058 If String has only pad spaces, then 0 is returned.
1059 If String has no pad spaces or valid decimal digits, then 0 is returned.
1060 If the number represented by String overflows according to the range defined by
1061 UINT64, then ASSERT().
1062 If String is NULL, then ASSERT().
1063 If PcdMaximumAsciiStringLength is not zero, and String contains more than
1064 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
1067 @param String Pointer to a Null-terminated ASCII string.
1069 @retval Value translated from String.
1074 AsciiStrDecimalToUint64 (
1075 IN CONST CHAR8
*String
1080 Convert a Null-terminated ASCII hexadecimal string to a value of type UINTN.
1082 This function returns a value of type UINTN by interpreting the contents of
1083 the ASCII string String as a hexadecimal number. The format of the input ASCII
1086 [spaces][zeros][x][hexadecimal digits].
1088 The valid hexadecimal digit character is in the range [0-9], [a-f] and [A-F].
1089 The prefix "0x" is optional. Both "x" and "X" is allowed in "0x" prefix. If "x"
1090 appears in the input string, it must be prefixed with at least one 0. The function
1091 will ignore the pad space, which includes spaces or tab characters, before [zeros],
1092 [x] or [hexadecimal digits]. The running zero before [x] or [hexadecimal digits]
1093 will be ignored. Then, the decoding starts after [x] or the first valid hexadecimal
1094 digit. Then, the function stops at the first character that is a not a valid
1095 hexadecimal character or Null-terminator, whichever on comes first.
1097 If String has only pad spaces, then 0 is returned.
1098 If String has no leading pad spaces, leading zeros or valid hexadecimal digits, then
1101 If the number represented by String overflows according to the range defined by UINTN,
1103 If String is NULL, then ASSERT().
1104 If PcdMaximumAsciiStringLength is not zero,
1105 and String contains more than PcdMaximumAsciiStringLength ASCII characters not including
1106 the Null-terminator, then ASSERT().
1108 @param String Pointer to a Null-terminated ASCII string.
1110 @retval Value translated from String.
1115 AsciiStrHexToUintn (
1116 IN CONST CHAR8
*String
1121 Convert a Null-terminated ASCII hexadecimal string to a value of type UINT64.
1123 This function returns a value of type UINT64 by interpreting the contents of
1124 the ASCII string String as a hexadecimal number. The format of the input ASCII
1127 [spaces][zeros][x][hexadecimal digits].
1129 The valid hexadecimal digit character is in the range [0-9], [a-f] and [A-F].
1130 The prefix "0x" is optional. Both "x" and "X" is allowed in "0x" prefix. If "x"
1131 appears in the input string, it must be prefixed with at least one 0. The function
1132 will ignore the pad space, which includes spaces or tab characters, before [zeros],
1133 [x] or [hexadecimal digits]. The running zero before [x] or [hexadecimal digits]
1134 will be ignored. Then, the decoding starts after [x] or the first valid hexadecimal
1135 digit. Then, the function stops at the first character that is a not a valid
1136 hexadecimal character or Null-terminator, whichever on comes first.
1138 If String has only pad spaces, then 0 is returned.
1139 If String has no leading pad spaces, leading zeros or valid hexadecimal digits, then
1142 If the number represented by String overflows according to the range defined by UINT64,
1144 If String is NULL, then ASSERT().
1145 If PcdMaximumAsciiStringLength is not zero,
1146 and String contains more than PcdMaximumAsciiStringLength ASCII characters not including
1147 the Null-terminator, then ASSERT().
1149 @param String Pointer to a Null-terminated ASCII string.
1151 @retval Value translated from String.
1156 AsciiStrHexToUint64 (
1157 IN CONST CHAR8
*String
1162 Convert one Null-terminated ASCII string to a Null-terminated
1163 Unicode string and returns the Unicode string.
1165 This function converts the contents of the ASCII string Source to the Unicode
1166 string Destination, and returns Destination. The function terminates the
1167 Unicode string Destination by appending a Null-terminator character at the end.
1168 The caller is responsible to make sure Destination points to a buffer with size
1169 equal or greater than ((AsciiStrLen (Source) + 1) * sizeof (CHAR16)) in bytes.
1171 If Destination is NULL, then ASSERT().
1172 If Destination is not aligned on a 16-bit boundary, then ASSERT().
1173 If Source is NULL, then ASSERT().
1174 If Source and Destination overlap, then ASSERT().
1175 If PcdMaximumAsciiStringLength is not zero, and Source contains more than
1176 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
1178 If PcdMaximumUnicodeStringLength is not zero, and Source contains more than
1179 PcdMaximumUnicodeStringLength ASCII characters not including the
1180 Null-terminator, then ASSERT().
1182 @param Source Pointer to a Null-terminated ASCII string.
1183 @param Destination Pointer to a Null-terminated Unicode string.
1185 @return Destination.
1190 AsciiStrToUnicodeStr (
1191 IN CONST CHAR8
*Source
,
1192 OUT CHAR16
*Destination
1197 Converts an 8-bit value to an 8-bit BCD value.
1199 Converts the 8-bit value specified by Value to BCD. The BCD value is
1202 If Value >= 100, then ASSERT().
1204 @param Value The 8-bit value to convert to BCD. Range 0..99.
1206 @return The BCD value.
1217 Converts an 8-bit BCD value to an 8-bit value.
1219 Converts the 8-bit BCD value specified by Value to an 8-bit value. The 8-bit
1222 If Value >= 0xA0, then ASSERT().
1223 If (Value & 0x0F) >= 0x0A, then ASSERT().
1225 @param Value The 8-bit BCD value to convert to an 8-bit value.
1227 @return The 8-bit value is returned.
1238 // Linked List Functions and Macros
1242 Initializes the head node of a doubly linked list that is declared as a
1243 global variable in a module.
1245 Initializes the forward and backward links of a new linked list. After
1246 initializing a linked list with this macro, the other linked list functions
1247 may be used to add and remove nodes from the linked list. This macro results
1248 in smaller executables by initializing the linked list in the data section,
1249 instead if calling the InitializeListHead() function to perform the
1250 equivalent operation.
1252 @param ListHead The head note of a list to initialize.
1255 #define INITIALIZE_LIST_HEAD_VARIABLE(ListHead) {&(ListHead), &(ListHead)}
1259 Initializes the head node of a doubly linked list, and returns the pointer to
1260 the head node of the doubly linked list.
1262 Initializes the forward and backward links of a new linked list. After
1263 initializing a linked list with this function, the other linked list
1264 functions may be used to add and remove nodes from the linked list. It is up
1265 to the caller of this function to allocate the memory for ListHead.
1267 If ListHead is NULL, then ASSERT().
1269 @param ListHead A pointer to the head node of a new doubly linked list.
1276 InitializeListHead (
1277 IN OUT LIST_ENTRY
*ListHead
1282 Adds a node to the beginning of a doubly linked list, and returns the pointer
1283 to the head node of the doubly linked list.
1285 Adds the node Entry at the beginning of the doubly linked list denoted by
1286 ListHead, and returns ListHead.
1288 If ListHead is NULL, then ASSERT().
1289 If Entry is NULL, then ASSERT().
1290 If ListHead was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or
1291 InitializeListHead(), then ASSERT().
1292 If PcdMaximumLinkedListLenth is not zero, and prior to insertion the number
1293 of nodes in ListHead, including the ListHead node, is greater than or
1294 equal to PcdMaximumLinkedListLength, then ASSERT().
1296 @param ListHead A pointer to the head node of a doubly linked list.
1297 @param Entry A pointer to a node that is to be inserted at the beginning
1298 of a doubly linked list.
1306 IN OUT LIST_ENTRY
*ListHead
,
1307 IN OUT LIST_ENTRY
*Entry
1312 Adds a node to the end of a doubly linked list, and returns the pointer to
1313 the head node of the doubly linked list.
1315 Adds the node Entry to the end of the doubly linked list denoted by ListHead,
1316 and returns ListHead.
1318 If ListHead is NULL, then ASSERT().
1319 If Entry is NULL, then ASSERT().
1320 If ListHead was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or
1321 InitializeListHead(), then ASSERT().
1322 If PcdMaximumLinkedListLenth is not zero, and prior to insertion the number
1323 of nodes in ListHead, including the ListHead node, is greater than or
1324 equal to PcdMaximumLinkedListLength, then ASSERT().
1326 @param ListHead A pointer to the head node of a doubly linked list.
1327 @param Entry A pointer to a node that is to be added at the end of the
1336 IN OUT LIST_ENTRY
*ListHead
,
1337 IN OUT LIST_ENTRY
*Entry
1342 Retrieves the first node of a doubly linked list.
1344 Returns the first node of a doubly linked list. List must have been
1345 initialized with INTIALIZE_LIST_HEAD_VARIABLE() or InitializeListHead().
1346 If List is empty, then List is returned.
1348 If List is NULL, then ASSERT().
1349 If List was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or
1350 InitializeListHead(), then ASSERT().
1351 If PcdMaximumLinkedListLenth is not zero, and the number of nodes
1352 in List, including the List node, is greater than or equal to
1353 PcdMaximumLinkedListLength, then ASSERT().
1355 @param List A pointer to the head node of a doubly linked list.
1357 @return The first node of a doubly linked list.
1358 @retval NULL The list is empty.
1364 IN CONST LIST_ENTRY
*List
1369 Retrieves the next node of a doubly linked list.
1371 Returns the node of a doubly linked list that follows Node.
1372 List must have been initialized with INTIALIZE_LIST_HEAD_VARIABLE()
1373 or InitializeListHead(). If List is empty, then List is returned.
1375 If List is NULL, then ASSERT().
1376 If Node is NULL, then ASSERT().
1377 If List was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or
1378 InitializeListHead(), then ASSERT().
1379 If PcdMaximumLinkedListLenth is not zero, and List contains more than
1380 PcdMaximumLinkedListLenth nodes, then ASSERT().
1381 If PcdVerifyNodeInList is TRUE and Node is not a node in List, then ASSERT().
1383 @param List A pointer to the head node of a doubly linked list.
1384 @param Node A pointer to a node in the doubly linked list.
1386 @return Pointer to the next node if one exists. Otherwise a null value which
1387 is actually List is returned.
1393 IN CONST LIST_ENTRY
*List
,
1394 IN CONST LIST_ENTRY
*Node
1399 Checks to see if a doubly linked list is empty or not.
1401 Checks to see if the doubly linked list is empty. If the linked list contains
1402 zero nodes, this function returns TRUE. Otherwise, it returns FALSE.
1404 If ListHead is NULL, then ASSERT().
1405 If ListHead was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or
1406 InitializeListHead(), then ASSERT().
1407 If PcdMaximumLinkedListLenth is not zero, and the number of nodes
1408 in List, including the List node, is greater than or equal to
1409 PcdMaximumLinkedListLength, then ASSERT().
1411 @param ListHead A pointer to the head node of a doubly linked list.
1413 @retval TRUE The linked list is empty.
1414 @retval FALSE The linked list is not empty.
1420 IN CONST LIST_ENTRY
*ListHead
1425 Determines if a node in a doubly linked list is the head node of a the same
1426 doubly linked list. This function is typically used to terminate a loop that
1427 traverses all the nodes in a doubly linked list starting with the head node.
1429 Returns TRUE if Node is equal to List. Returns FALSE if Node is one of the
1430 nodes in the doubly linked list specified by List. List must have been
1431 initialized with INTIALIZE_LIST_HEAD_VARIABLE() or InitializeListHead().
1433 If List is NULL, then ASSERT().
1434 If Node is NULL, then ASSERT().
1435 If List was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or InitializeListHead(),
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().
1440 If PcdVerifyNodeInList is TRUE and Node is not a node in List the and Node is not equal
1441 to List, then ASSERT().
1443 @param List A pointer to the head node of a doubly linked list.
1444 @param Node A pointer to a node in the doubly linked list.
1446 @retval TRUE Node is one of the nodes in the doubly linked list.
1447 @retval FALSE Node is not one of the nodes in the doubly linked list.
1453 IN CONST LIST_ENTRY
*List
,
1454 IN CONST LIST_ENTRY
*Node
1459 Determines if a node the last node in a doubly linked list.
1461 Returns TRUE if Node is the last node in the doubly linked list specified by
1462 List. Otherwise, FALSE is returned. List must have been initialized with
1463 INTIALIZE_LIST_HEAD_VARIABLE() or InitializeListHead().
1465 If List is NULL, then ASSERT().
1466 If Node is NULL, then ASSERT().
1467 If List was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or
1468 InitializeListHead(), then ASSERT().
1469 If PcdMaximumLinkedListLenth is not zero, and the number of nodes
1470 in List, including the List node, is greater than or equal to
1471 PcdMaximumLinkedListLength, then ASSERT().
1472 If PcdVerifyNodeInList is TRUE and Node is not a node in List, then ASSERT().
1474 @param List A pointer to the head node of a doubly linked list.
1475 @param Node A pointer to a node in the doubly linked list.
1477 @retval TRUE Node is the last node in the linked list.
1478 @retval FALSE Node is not the last node in the linked list.
1484 IN CONST LIST_ENTRY
*List
,
1485 IN CONST LIST_ENTRY
*Node
1490 Swaps the location of two nodes in a doubly linked list, and returns the
1491 first node after the swap.
1493 If FirstEntry is identical to SecondEntry, then SecondEntry is returned.
1494 Otherwise, the location of the FirstEntry node is swapped with the location
1495 of the SecondEntry node in a doubly linked list. SecondEntry must be in the
1496 same double linked list as FirstEntry and that double linked list must have
1497 been initialized with INTIALIZE_LIST_HEAD_VARIABLE() or InitializeListHead().
1498 SecondEntry is returned after the nodes are swapped.
1500 If FirstEntry is NULL, then ASSERT().
1501 If SecondEntry is NULL, then ASSERT().
1502 If PcdVerifyNodeInList is TRUE and SecondEntry and FirstEntry are not in the
1503 same linked list, then ASSERT().
1504 If PcdMaximumLinkedListLength is not zero, and the number of nodes in the
1505 linked list containing the FirstEntry and SecondEntry nodes, including
1506 the FirstEntry and SecondEntry nodes, is greater than or equal to
1507 PcdMaximumLinkedListLength, then ASSERT().
1509 @param FirstEntry A pointer to a node in a linked list.
1510 @param SecondEntry A pointer to another node in the same linked list.
1512 @return SecondEntry.
1518 IN OUT LIST_ENTRY
*FirstEntry
,
1519 IN OUT LIST_ENTRY
*SecondEntry
1524 Removes a node from a doubly linked list, and returns the node that follows
1527 Removes the node Entry from a doubly linked list. It is up to the caller of
1528 this function to release the memory used by this node if that is required. On
1529 exit, the node following Entry in the doubly linked list is returned. If
1530 Entry is the only node in the linked list, then the head node of the linked
1533 If Entry is NULL, then ASSERT().
1534 If Entry is the head node of an empty list, then ASSERT().
1535 If PcdMaximumLinkedListLength is not zero, and the number of nodes in the
1536 linked list containing Entry, including the Entry node, is greater than
1537 or equal to PcdMaximumLinkedListLength, then ASSERT().
1539 @param Entry A pointer to a node in a linked list.
1547 IN CONST LIST_ENTRY
*Entry
1555 Shifts a 64-bit integer left between 0 and 63 bits. The low bits are filled
1556 with zeros. The shifted value is returned.
1558 This function shifts the 64-bit value Operand to the left by Count bits. The
1559 low Count bits are set to zero. The shifted value is returned.
1561 If Count is greater than 63, then ASSERT().
1563 @param Operand The 64-bit operand to shift left.
1564 @param Count The number of bits to shift left.
1566 @return Operand << Count.
1578 Shifts a 64-bit integer right between 0 and 63 bits. This high bits are
1579 filled with zeros. The shifted value is returned.
1581 This function shifts the 64-bit value Operand to the right by Count bits. The
1582 high Count bits are set to zero. The shifted value is returned.
1584 If Count is greater than 63, then ASSERT().
1586 @param Operand The 64-bit operand to shift right.
1587 @param Count The number of bits to shift right.
1589 @return Operand >> Count
1601 Shifts a 64-bit integer right between 0 and 63 bits. The high bits are filled
1602 with original integer's bit 63. The shifted value is returned.
1604 This function shifts the 64-bit value Operand to the right by Count bits. The
1605 high Count bits are set to bit 63 of Operand. The shifted value is returned.
1607 If Count is greater than 63, then ASSERT().
1609 @param Operand The 64-bit operand to shift right.
1610 @param Count The number of bits to shift right.
1612 @return Operand >> Count
1624 Rotates a 32-bit integer left between 0 and 31 bits, filling the low bits
1625 with the high bits that were rotated.
1627 This function rotates the 32-bit value Operand to the left by Count bits. The
1628 low Count bits are fill with the high Count bits of Operand. The rotated
1631 If Count is greater than 31, then ASSERT().
1633 @param Operand The 32-bit operand to rotate left.
1634 @param Count The number of bits to rotate left.
1636 @return Operand << Count
1648 Rotates a 32-bit integer right between 0 and 31 bits, filling the high bits
1649 with the low bits that were rotated.
1651 This function rotates the 32-bit value Operand to the right by Count bits.
1652 The high Count bits are fill with the low Count bits of Operand. The rotated
1655 If Count is greater than 31, then ASSERT().
1657 @param Operand The 32-bit operand to rotate right.
1658 @param Count The number of bits to rotate right.
1660 @return Operand >> Count
1672 Rotates a 64-bit integer left between 0 and 63 bits, filling the low bits
1673 with the high bits that were rotated.
1675 This function rotates the 64-bit value Operand to the left by Count bits. The
1676 low Count bits are fill with the high Count bits of Operand. The rotated
1679 If Count is greater than 63, then ASSERT().
1681 @param Operand The 64-bit operand to rotate left.
1682 @param Count The number of bits to rotate left.
1684 @return Operand << Count
1696 Rotates a 64-bit integer right between 0 and 63 bits, filling the high bits
1697 with the high low bits that were rotated.
1699 This function rotates the 64-bit value Operand to the right by Count bits.
1700 The high Count bits are fill with the low Count bits of Operand. The rotated
1703 If Count is greater than 63, then ASSERT().
1705 @param Operand The 64-bit operand to rotate right.
1706 @param Count The number of bits to rotate right.
1708 @return Operand >> Count
1720 Returns the bit position of the lowest bit set in a 32-bit value.
1722 This function computes the bit position of the lowest bit set in the 32-bit
1723 value specified by Operand. If Operand is zero, then -1 is returned.
1724 Otherwise, a value between 0 and 31 is returned.
1726 @param Operand The 32-bit operand to evaluate.
1728 @retval 0..31 The lowest bit set in Operand was found.
1729 @retval -1 Operand is zero.
1740 Returns the bit position of the lowest bit set in a 64-bit value.
1742 This function computes the bit position of the lowest bit set in the 64-bit
1743 value specified by Operand. If Operand is zero, then -1 is returned.
1744 Otherwise, a value between 0 and 63 is returned.
1746 @param Operand The 64-bit operand to evaluate.
1748 @retval 0..63 The lowest bit set in Operand was found.
1749 @retval -1 Operand is zero.
1761 Returns the bit position of the highest bit set in a 32-bit value. Equivalent
1764 This function computes the bit position of the highest bit set in the 32-bit
1765 value specified by Operand. If Operand is zero, then -1 is returned.
1766 Otherwise, a value between 0 and 31 is returned.
1768 @param Operand The 32-bit operand to evaluate.
1770 @retval 0..31 Position of the highest bit set in Operand if found.
1771 @retval -1 Operand is zero.
1782 Returns the bit position of the highest bit set in a 64-bit value. Equivalent
1785 This function computes the bit position of the highest bit set in the 64-bit
1786 value specified by Operand. If Operand is zero, then -1 is returned.
1787 Otherwise, a value between 0 and 63 is returned.
1789 @param Operand The 64-bit operand to evaluate.
1791 @retval 0..63 Position of the highest bit set in Operand if found.
1792 @retval -1 Operand is zero.
1803 Returns the value of the highest bit set in a 32-bit value. Equivalent to
1806 This function computes the value of the highest bit set in the 32-bit value
1807 specified by Operand. If Operand is zero, then zero is returned.
1809 @param Operand The 32-bit operand to evaluate.
1811 @return 1 << HighBitSet32(Operand)
1812 @retval 0 Operand is zero.
1823 Returns the value of the highest bit set in a 64-bit value. Equivalent to
1826 This function computes the value of the highest bit set in the 64-bit value
1827 specified by Operand. If Operand is zero, then zero is returned.
1829 @param Operand The 64-bit operand to evaluate.
1831 @return 1 << HighBitSet64(Operand)
1832 @retval 0 Operand is zero.
1843 Switches the endianess of a 16-bit integer.
1845 This function swaps the bytes in a 16-bit unsigned value to switch the value
1846 from little endian to big endian or vice versa. The byte swapped value is
1849 @param Value A 16-bit unsigned value.
1851 @return The byte swapped Value.
1862 Switches the endianess of a 32-bit integer.
1864 This function swaps the bytes in a 32-bit unsigned value to switch the value
1865 from little endian to big endian or vice versa. The byte swapped value is
1868 @param Value A 32-bit unsigned value.
1870 @return The byte swapped Value.
1881 Switches the endianess of a 64-bit integer.
1883 This function swaps the bytes in a 64-bit unsigned value to switch the value
1884 from little endian to big endian or vice versa. The byte swapped value is
1887 @param Value A 64-bit unsigned value.
1889 @return The byte swapped Value.
1900 Multiples a 64-bit unsigned integer by a 32-bit unsigned integer and
1901 generates a 64-bit unsigned result.
1903 This function multiples the 64-bit unsigned value Multiplicand by the 32-bit
1904 unsigned value Multiplier and generates a 64-bit unsigned result. This 64-
1905 bit unsigned result is returned.
1907 @param Multiplicand A 64-bit unsigned value.
1908 @param Multiplier A 32-bit unsigned value.
1910 @return Multiplicand * Multiplier
1916 IN UINT64 Multiplicand
,
1917 IN UINT32 Multiplier
1922 Multiples a 64-bit unsigned integer by a 64-bit unsigned integer and
1923 generates a 64-bit unsigned result.
1925 This function multiples the 64-bit unsigned value Multiplicand by the 64-bit
1926 unsigned value Multiplier and generates a 64-bit unsigned result. This 64-
1927 bit unsigned result is returned.
1929 @param Multiplicand A 64-bit unsigned value.
1930 @param Multiplier A 64-bit unsigned value.
1932 @return Multiplicand * Multiplier
1938 IN UINT64 Multiplicand
,
1939 IN UINT64 Multiplier
1944 Multiples a 64-bit signed integer by a 64-bit signed integer and generates a
1945 64-bit signed result.
1947 This function multiples the 64-bit signed value Multiplicand by the 64-bit
1948 signed value Multiplier and generates a 64-bit signed result. This 64-bit
1949 signed result is returned.
1951 @param Multiplicand A 64-bit signed value.
1952 @param Multiplier A 64-bit signed value.
1954 @return Multiplicand * Multiplier
1960 IN INT64 Multiplicand
,
1966 Divides a 64-bit unsigned integer by a 32-bit unsigned integer and generates
1967 a 64-bit unsigned result.
1969 This function divides the 64-bit unsigned value Dividend by the 32-bit
1970 unsigned value Divisor and generates a 64-bit unsigned quotient. This
1971 function returns the 64-bit unsigned quotient.
1973 If Divisor is 0, then ASSERT().
1975 @param Dividend A 64-bit unsigned value.
1976 @param Divisor A 32-bit unsigned value.
1978 @return Dividend / Divisor
1990 Divides a 64-bit unsigned integer by a 32-bit unsigned integer and generates
1991 a 32-bit unsigned remainder.
1993 This function divides the 64-bit unsigned value Dividend by the 32-bit
1994 unsigned value Divisor and generates a 32-bit remainder. This function
1995 returns the 32-bit unsigned remainder.
1997 If Divisor is 0, then ASSERT().
1999 @param Dividend A 64-bit unsigned value.
2000 @param Divisor A 32-bit unsigned value.
2002 @return Dividend % Divisor
2014 Divides a 64-bit unsigned integer by a 32-bit unsigned integer and generates
2015 a 64-bit unsigned result and an optional 32-bit unsigned remainder.
2017 This function divides the 64-bit unsigned value Dividend by the 32-bit
2018 unsigned value Divisor and generates a 64-bit unsigned quotient. If Remainder
2019 is not NULL, then the 32-bit unsigned remainder is returned in Remainder.
2020 This function returns the 64-bit unsigned quotient.
2022 If Divisor is 0, then ASSERT().
2024 @param Dividend A 64-bit unsigned value.
2025 @param Divisor A 32-bit unsigned value.
2026 @param Remainder A pointer to a 32-bit unsigned value. This parameter is
2027 optional and may be NULL.
2029 @return Dividend / Divisor
2034 DivU64x32Remainder (
2037 OUT UINT32
*Remainder OPTIONAL
2042 Divides a 64-bit unsigned integer by a 64-bit unsigned integer and generates
2043 a 64-bit unsigned result and an optional 64-bit unsigned remainder.
2045 This function divides the 64-bit unsigned value Dividend by the 64-bit
2046 unsigned value Divisor and generates a 64-bit unsigned quotient. If Remainder
2047 is not NULL, then the 64-bit unsigned remainder is returned in Remainder.
2048 This function returns the 64-bit unsigned quotient.
2050 If Divisor is 0, then ASSERT().
2052 @param Dividend A 64-bit unsigned value.
2053 @param Divisor A 64-bit unsigned value.
2054 @param Remainder A pointer to a 64-bit unsigned value. This parameter is
2055 optional and may be NULL.
2057 @return Dividend / Divisor
2062 DivU64x64Remainder (
2065 OUT UINT64
*Remainder OPTIONAL
2070 Divides a 64-bit signed integer by a 64-bit signed integer and generates a
2071 64-bit signed result and a optional 64-bit signed remainder.
2073 This function divides the 64-bit signed value Dividend by the 64-bit signed
2074 value Divisor and generates a 64-bit signed quotient. If Remainder is not
2075 NULL, then the 64-bit signed remainder is returned in Remainder. This
2076 function returns the 64-bit signed quotient.
2078 It is the caller's responsibility to not call this function with a Divisor of 0.
2079 If Divisor is 0, then the quotient and remainder should be assumed to be
2080 the largest negative integer.
2082 If Divisor is 0, then ASSERT().
2084 @param Dividend A 64-bit signed value.
2085 @param Divisor A 64-bit signed value.
2086 @param Remainder A pointer to a 64-bit signed value. This parameter is
2087 optional and may be NULL.
2089 @return Dividend / Divisor
2094 DivS64x64Remainder (
2097 OUT INT64
*Remainder OPTIONAL
2102 Reads a 16-bit value from memory that may be unaligned.
2104 This function returns the 16-bit value pointed to by Buffer. The function
2105 guarantees that the read operation does not produce an alignment fault.
2107 If the Buffer is NULL, then ASSERT().
2109 @param Buffer Pointer to a 16-bit value that may be unaligned.
2111 @return The 16-bit value read from Buffer.
2117 IN CONST UINT16
*Buffer
2122 Writes a 16-bit value to memory that may be unaligned.
2124 This function writes the 16-bit value specified by Value to Buffer. Value is
2125 returned. The function guarantees that the write operation does not produce
2128 If the Buffer is NULL, then ASSERT().
2130 @param Buffer Pointer to a 16-bit value that may be unaligned.
2131 @param Value 16-bit value to write to Buffer.
2133 @return The 16-bit value to write to Buffer.
2145 Reads a 24-bit value from memory that may be unaligned.
2147 This function returns the 24-bit value pointed to by Buffer. The function
2148 guarantees that the read operation does not produce an alignment fault.
2150 If the Buffer is NULL, then ASSERT().
2152 @param Buffer Pointer to a 24-bit value that may be unaligned.
2154 @return The 24-bit value read from Buffer.
2160 IN CONST UINT32
*Buffer
2165 Writes a 24-bit value to memory that may be unaligned.
2167 This function writes the 24-bit value specified by Value to Buffer. Value is
2168 returned. The function guarantees that the write operation does not produce
2171 If the Buffer is NULL, then ASSERT().
2173 @param Buffer Pointer to a 24-bit value that may be unaligned.
2174 @param Value 24-bit value to write to Buffer.
2176 @return The 24-bit value to write to Buffer.
2188 Reads a 32-bit value from memory that may be unaligned.
2190 This function returns the 32-bit value pointed to by Buffer. The function
2191 guarantees that the read operation does not produce an alignment fault.
2193 If the Buffer is NULL, then ASSERT().
2195 @param Buffer Pointer to a 32-bit value that may be unaligned.
2197 @return The 32-bit value read from Buffer.
2203 IN CONST UINT32
*Buffer
2208 Writes a 32-bit value to memory that may be unaligned.
2210 This function writes the 32-bit value specified by Value to Buffer. Value is
2211 returned. The function guarantees that the write operation does not produce
2214 If the Buffer is NULL, then ASSERT().
2216 @param Buffer Pointer to a 32-bit value that may be unaligned.
2217 @param Value 32-bit value to write to Buffer.
2219 @return The 32-bit value to write to Buffer.
2231 Reads a 64-bit value from memory that may be unaligned.
2233 This function returns the 64-bit value pointed to by Buffer. The function
2234 guarantees that the read operation does not produce an alignment fault.
2236 If the Buffer is NULL, then ASSERT().
2238 @param Buffer Pointer to a 64-bit value that may be unaligned.
2240 @return The 64-bit value read from Buffer.
2246 IN CONST UINT64
*Buffer
2251 Writes a 64-bit value to memory that may be unaligned.
2253 This function writes the 64-bit value specified by Value to Buffer. Value is
2254 returned. The function guarantees that the write operation does not produce
2257 If the Buffer is NULL, then ASSERT().
2259 @param Buffer Pointer to a 64-bit value that may be unaligned.
2260 @param Value 64-bit value to write to Buffer.
2262 @return The 64-bit value to write to Buffer.
2274 // Bit Field Functions
2278 Returns a bit field from an 8-bit value.
2280 Returns the bitfield specified by the StartBit and the EndBit from Operand.
2282 If 8-bit operations are not supported, then ASSERT().
2283 If StartBit is greater than 7, then ASSERT().
2284 If EndBit is greater than 7, then ASSERT().
2285 If EndBit is less than StartBit, then ASSERT().
2287 @param Operand Operand on which to perform the bitfield operation.
2288 @param StartBit The ordinal of the least significant bit in the bit field.
2290 @param EndBit The ordinal of the most significant bit in the bit field.
2293 @return The bit field read.
2306 Writes a bit field to an 8-bit value, and returns the result.
2308 Writes Value to the bit field specified by the StartBit and the EndBit in
2309 Operand. All other bits in Operand are preserved. The new 8-bit value is
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.
2322 @param Value New value of the bit field.
2324 @return The new 8-bit value.
2338 Reads a bit field from an 8-bit value, performs a bitwise OR, and returns the
2341 Performs a bitwise OR between the bit field specified by StartBit
2342 and EndBit in Operand and the value specified by OrData. All other bits in
2343 Operand are preserved. The new 8-bit value is returned.
2345 If 8-bit operations are not supported, then ASSERT().
2346 If StartBit is greater than 7, then ASSERT().
2347 If EndBit is greater than 7, then ASSERT().
2348 If EndBit is less than StartBit, then ASSERT().
2350 @param Operand Operand on which to perform the bitfield operation.
2351 @param StartBit The ordinal of the least significant bit in the bit field.
2353 @param EndBit The ordinal of the most significant bit in the bit field.
2355 @param OrData The value to OR with the read value from the value
2357 @return The new 8-bit value.
2371 Reads a bit field from an 8-bit value, performs a bitwise AND, and returns
2374 Performs a bitwise AND between the bit field specified by StartBit and EndBit
2375 in Operand and the value specified by AndData. All other bits in Operand are
2376 preserved. The new 8-bit value is returned.
2378 If 8-bit operations are not supported, then ASSERT().
2379 If StartBit is greater than 7, then ASSERT().
2380 If EndBit is greater than 7, then ASSERT().
2381 If EndBit is less than StartBit, then ASSERT().
2383 @param Operand Operand on which to perform the bitfield operation.
2384 @param StartBit The ordinal of the least significant bit in the bit field.
2386 @param EndBit The ordinal of the most significant bit in the bit field.
2388 @param AndData The value to AND with the read value from the value.
2390 @return The new 8-bit value.
2404 Reads a bit field from an 8-bit value, performs a bitwise AND followed by a
2405 bitwise OR, and returns the result.
2407 Performs a bitwise AND between the bit field specified by StartBit and EndBit
2408 in Operand and the value specified by AndData, followed by a bitwise
2409 OR with value specified by OrData. All other bits in Operand are
2410 preserved. The new 8-bit value is returned.
2412 If 8-bit operations are not supported, then ASSERT().
2413 If StartBit is greater than 7, then ASSERT().
2414 If EndBit is greater than 7, then ASSERT().
2415 If EndBit is less than StartBit, then ASSERT().
2417 @param Operand Operand on which to perform the bitfield operation.
2418 @param StartBit The ordinal of the least significant bit in the bit field.
2420 @param EndBit The ordinal of the most significant bit in the bit field.
2422 @param AndData The value to AND with the read value from the value.
2423 @param OrData The value to OR with the result of the AND operation.
2425 @return The new 8-bit value.
2430 BitFieldAndThenOr8 (
2440 Returns a bit field from a 16-bit value.
2442 Returns the bitfield specified by the StartBit and the EndBit from Operand.
2444 If 16-bit operations are not supported, then ASSERT().
2445 If StartBit is greater than 15, then ASSERT().
2446 If EndBit is greater than 15, then ASSERT().
2447 If EndBit is less than StartBit, then ASSERT().
2449 @param Operand Operand on which to perform the bitfield operation.
2450 @param StartBit The ordinal of the least significant bit in the bit field.
2452 @param EndBit The ordinal of the most significant bit in the bit field.
2455 @return The bit field read.
2468 Writes a bit field to a 16-bit value, and returns the result.
2470 Writes Value to the bit field specified by the StartBit and the EndBit in
2471 Operand. All other bits in Operand are preserved. The new 16-bit value is
2474 If 16-bit operations are not supported, then ASSERT().
2475 If StartBit is greater than 15, then ASSERT().
2476 If EndBit is greater than 15, then ASSERT().
2477 If EndBit is less than StartBit, then ASSERT().
2479 @param Operand Operand on which to perform the bitfield operation.
2480 @param StartBit The ordinal of the least significant bit in the bit field.
2482 @param EndBit The ordinal of the most significant bit in the bit field.
2484 @param Value New value of the bit field.
2486 @return The new 16-bit value.
2500 Reads a bit field from a 16-bit value, performs a bitwise OR, and returns the
2503 Performs a bitwise OR between the bit field specified by StartBit
2504 and EndBit in Operand and the value specified by OrData. All other bits in
2505 Operand are preserved. The new 16-bit value is returned.
2507 If 16-bit operations are not supported, then ASSERT().
2508 If StartBit is greater than 15, then ASSERT().
2509 If EndBit is greater than 15, then ASSERT().
2510 If EndBit is less than StartBit, then ASSERT().
2512 @param Operand Operand on which to perform the bitfield operation.
2513 @param StartBit The ordinal of the least significant bit in the bit field.
2515 @param EndBit The ordinal of the most significant bit in the bit field.
2517 @param OrData The value to OR with the read value from the value
2519 @return The new 16-bit value.
2533 Reads a bit field from a 16-bit value, performs a bitwise AND, and returns
2536 Performs a bitwise AND between the bit field specified by StartBit and EndBit
2537 in Operand and the value specified by AndData. All other bits in Operand are
2538 preserved. The new 16-bit value is returned.
2540 If 16-bit operations are not supported, then ASSERT().
2541 If StartBit is greater than 15, then ASSERT().
2542 If EndBit is greater than 15, then ASSERT().
2543 If EndBit is less than StartBit, then ASSERT().
2545 @param Operand Operand on which to perform the bitfield operation.
2546 @param StartBit The ordinal of the least significant bit in the bit field.
2548 @param EndBit The ordinal of the most significant bit in the bit field.
2550 @param AndData The value to AND with the read value from the value
2552 @return The new 16-bit value.
2566 Reads a bit field from a 16-bit value, performs a bitwise AND followed by a
2567 bitwise OR, and returns the result.
2569 Performs a bitwise AND between the bit field specified by StartBit and EndBit
2570 in Operand and the value specified by AndData, followed by a bitwise
2571 OR with value specified by OrData. All other bits in Operand are
2572 preserved. The new 16-bit value is returned.
2574 If 16-bit operations are not supported, then ASSERT().
2575 If StartBit is greater than 15, then ASSERT().
2576 If EndBit is greater than 15, then ASSERT().
2577 If EndBit is less than StartBit, then ASSERT().
2579 @param Operand Operand on which to perform the bitfield operation.
2580 @param StartBit The ordinal of the least significant bit in the bit field.
2582 @param EndBit The ordinal of the most significant bit in the bit field.
2584 @param AndData The value to AND with the read value from the value.
2585 @param OrData The value to OR with the result of the AND operation.
2587 @return The new 16-bit value.
2592 BitFieldAndThenOr16 (
2602 Returns a bit field from a 32-bit value.
2604 Returns the bitfield specified by the StartBit and the EndBit from Operand.
2606 If 32-bit operations are not supported, then ASSERT().
2607 If StartBit is greater than 31, then ASSERT().
2608 If EndBit is greater than 31, then ASSERT().
2609 If EndBit is less than StartBit, then ASSERT().
2611 @param Operand Operand on which to perform the bitfield operation.
2612 @param StartBit The ordinal of the least significant bit in the bit field.
2614 @param EndBit The ordinal of the most significant bit in the bit field.
2617 @return The bit field read.
2630 Writes a bit field to a 32-bit value, and returns the result.
2632 Writes Value to the bit field specified by the StartBit and the EndBit in
2633 Operand. All other bits in Operand are preserved. The new 32-bit value is
2636 If 32-bit operations are not supported, then ASSERT().
2637 If StartBit is greater than 31, then ASSERT().
2638 If EndBit is greater than 31, then ASSERT().
2639 If EndBit is less than StartBit, then ASSERT().
2641 @param Operand Operand on which to perform the bitfield operation.
2642 @param StartBit The ordinal of the least significant bit in the bit field.
2644 @param EndBit The ordinal of the most significant bit in the bit field.
2646 @param Value New value of the bit field.
2648 @return The new 32-bit value.
2662 Reads a bit field from a 32-bit value, performs a bitwise OR, and returns the
2665 Performs a bitwise OR between the bit field specified by StartBit
2666 and EndBit in Operand and the value specified by OrData. All other bits in
2667 Operand are preserved. The new 32-bit value is returned.
2669 If 32-bit operations are not supported, then ASSERT().
2670 If StartBit is greater than 31, then ASSERT().
2671 If EndBit is greater than 31, then ASSERT().
2672 If EndBit is less than StartBit, then ASSERT().
2674 @param Operand Operand on which to perform the bitfield operation.
2675 @param StartBit The ordinal of the least significant bit in the bit field.
2677 @param EndBit The ordinal of the most significant bit in the bit field.
2679 @param OrData The value to OR with the read value from the value
2681 @return The new 32-bit value.
2695 Reads a bit field from a 32-bit value, performs a bitwise AND, and returns
2698 Performs a bitwise AND between the bit field specified by StartBit and EndBit
2699 in Operand and the value specified by AndData. All other bits in Operand are
2700 preserved. The new 32-bit value is returned.
2702 If 32-bit operations are not supported, then ASSERT().
2703 If StartBit is greater than 31, then ASSERT().
2704 If EndBit is greater than 31, then ASSERT().
2705 If EndBit is less than StartBit, then ASSERT().
2707 @param Operand Operand on which to perform the bitfield operation.
2708 @param StartBit The ordinal of the least significant bit in the bit field.
2710 @param EndBit The ordinal of the most significant bit in the bit field.
2712 @param AndData The value to AND with the read value from the value
2714 @return The new 32-bit value.
2728 Reads a bit field from a 32-bit value, performs a bitwise AND followed by a
2729 bitwise OR, and returns the result.
2731 Performs a bitwise AND between the bit field specified by StartBit and EndBit
2732 in Operand and the value specified by AndData, followed by a bitwise
2733 OR with value specified by OrData. All other bits in Operand are
2734 preserved. The new 32-bit value is returned.
2736 If 32-bit operations are not supported, then ASSERT().
2737 If StartBit is greater than 31, then ASSERT().
2738 If EndBit is greater than 31, then ASSERT().
2739 If EndBit is less than StartBit, then ASSERT().
2741 @param Operand Operand on which to perform the bitfield operation.
2742 @param StartBit The ordinal of the least significant bit in the bit field.
2744 @param EndBit The ordinal of the most significant bit in the bit field.
2746 @param AndData The value to AND with the read value from the value.
2747 @param OrData The value to OR with the result of the AND operation.
2749 @return The new 32-bit value.
2754 BitFieldAndThenOr32 (
2764 Returns a bit field from a 64-bit value.
2766 Returns the bitfield specified by the StartBit and the EndBit from Operand.
2768 If 64-bit operations are not supported, then ASSERT().
2769 If StartBit is greater than 63, then ASSERT().
2770 If EndBit is greater than 63, then ASSERT().
2771 If EndBit is less than StartBit, then ASSERT().
2773 @param Operand Operand on which to perform the bitfield operation.
2774 @param StartBit The ordinal of the least significant bit in the bit field.
2776 @param EndBit The ordinal of the most significant bit in the bit field.
2779 @return The bit field read.
2792 Writes a bit field to a 64-bit value, and returns the result.
2794 Writes Value to the bit field specified by the StartBit and the EndBit in
2795 Operand. All other bits in Operand are preserved. The new 64-bit value is
2798 If 64-bit operations are not supported, then ASSERT().
2799 If StartBit is greater than 63, then ASSERT().
2800 If EndBit is greater than 63, then ASSERT().
2801 If EndBit is less than StartBit, then ASSERT().
2803 @param Operand Operand on which to perform the bitfield operation.
2804 @param StartBit The ordinal of the least significant bit in the bit field.
2806 @param EndBit The ordinal of the most significant bit in the bit field.
2808 @param Value New value of the bit field.
2810 @return The new 64-bit value.
2824 Reads a bit field from a 64-bit value, performs a bitwise OR, and returns the
2827 Performs a bitwise OR between the bit field specified by StartBit
2828 and EndBit in Operand and the value specified by OrData. All other bits in
2829 Operand are preserved. The new 64-bit value is returned.
2831 If 64-bit operations are not supported, then ASSERT().
2832 If StartBit is greater than 63, then ASSERT().
2833 If EndBit is greater than 63, then ASSERT().
2834 If EndBit is less than StartBit, then ASSERT().
2836 @param Operand Operand on which to perform the bitfield operation.
2837 @param StartBit The ordinal of the least significant bit in the bit field.
2839 @param EndBit The ordinal of the most significant bit in the bit field.
2841 @param OrData The value to OR with the read value from the value
2843 @return The new 64-bit value.
2857 Reads a bit field from a 64-bit value, performs a bitwise AND, and returns
2860 Performs a bitwise AND between the bit field specified by StartBit and EndBit
2861 in Operand and the value specified by AndData. All other bits in Operand are
2862 preserved. The new 64-bit value is returned.
2864 If 64-bit operations are not supported, then ASSERT().
2865 If StartBit is greater than 63, then ASSERT().
2866 If EndBit is greater than 63, then ASSERT().
2867 If EndBit is less than StartBit, then ASSERT().
2869 @param Operand Operand on which to perform the bitfield operation.
2870 @param StartBit The ordinal of the least significant bit in the bit field.
2872 @param EndBit The ordinal of the most significant bit in the bit field.
2874 @param AndData The value to AND with the read value from the value
2876 @return The new 64-bit value.
2890 Reads a bit field from a 64-bit value, performs a bitwise AND followed by a
2891 bitwise OR, and returns the result.
2893 Performs a bitwise AND between the bit field specified by StartBit and EndBit
2894 in Operand and the value specified by AndData, followed by a bitwise
2895 OR with value specified by OrData. All other bits in Operand are
2896 preserved. The new 64-bit value is returned.
2898 If 64-bit operations are not supported, then ASSERT().
2899 If StartBit is greater than 63, then ASSERT().
2900 If EndBit is greater than 63, then ASSERT().
2901 If EndBit is less than StartBit, then ASSERT().
2903 @param Operand Operand on which to perform the bitfield operation.
2904 @param StartBit The ordinal of the least significant bit in the bit field.
2906 @param EndBit The ordinal of the most significant bit in the bit field.
2908 @param AndData The value to AND with the read value from the value.
2909 @param OrData The value to OR with the result of the AND operation.
2911 @return The new 64-bit value.
2916 BitFieldAndThenOr64 (
2925 // Base Library Checksum Functions
2929 Returns the sum of all elements in a buffer in unit of UINT8.
2930 During calculation, the carry bits are dropped.
2932 This function calculates the sum of all elements in a buffer
2933 in unit of UINT8. The carry bits in result of addition are dropped.
2934 The result is returned as UINT8. If Length is Zero, then Zero is
2937 If Buffer is NULL, then ASSERT().
2938 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
2940 @param Buffer Pointer to the buffer to carry out the sum operation.
2941 @param Length The size, in bytes, of Buffer.
2943 @return Sum The sum of Buffer with carry bits dropped during additions.
2949 IN CONST UINT8
*Buffer
,
2955 Returns the two's complement checksum of all elements in a buffer
2958 This function first calculates the sum of the 8-bit values in the
2959 buffer specified by Buffer and Length. The carry bits in the result
2960 of addition are dropped. Then, the two's complement of the sum is
2961 returned. If Length is 0, then 0 is returned.
2963 If Buffer is NULL, then ASSERT().
2964 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
2966 @param Buffer Pointer to the buffer to carry out the checksum operation.
2967 @param Length The size, in bytes, of Buffer.
2969 @return Checksum The 2's complement checksum of Buffer.
2974 CalculateCheckSum8 (
2975 IN CONST UINT8
*Buffer
,
2981 Returns the sum of all elements in a buffer of 16-bit values. During
2982 calculation, the carry bits are dropped.
2984 This function calculates the sum of the 16-bit values in the buffer
2985 specified by Buffer and Length. The carry bits in result of addition are dropped.
2986 The 16-bit result is returned. If Length is 0, then 0 is returned.
2988 If Buffer is NULL, then ASSERT().
2989 If Buffer is not aligned on a 16-bit boundary, then ASSERT().
2990 If Length is not aligned on a 16-bit boundary, then ASSERT().
2991 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
2993 @param Buffer Pointer to the buffer to carry out the sum operation.
2994 @param Length The size, in bytes, of Buffer.
2996 @return Sum The sum of Buffer with carry bits dropped during additions.
3002 IN CONST UINT16
*Buffer
,
3008 Returns the two's complement checksum of all elements in a buffer of
3011 This function first calculates the sum of the 16-bit values in the buffer
3012 specified by Buffer and Length. The carry bits in the result of addition
3013 are dropped. Then, the two's complement of the sum is returned. If Length
3014 is 0, then 0 is returned.
3016 If Buffer is NULL, then ASSERT().
3017 If Buffer is not aligned on a 16-bit boundary, then ASSERT().
3018 If Length is not aligned on a 16-bit boundary, then ASSERT().
3019 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
3021 @param Buffer Pointer to the buffer to carry out the checksum operation.
3022 @param Length The size, in bytes, of Buffer.
3024 @return Checksum The 2's complement checksum of Buffer.
3029 CalculateCheckSum16 (
3030 IN CONST UINT16
*Buffer
,
3036 Returns the sum of all elements in a buffer of 32-bit values. During
3037 calculation, the carry bits are dropped.
3039 This function calculates the sum of the 32-bit values in the buffer
3040 specified by Buffer and Length. The carry bits in result of addition are dropped.
3041 The 32-bit result is returned. If Length is 0, then 0 is returned.
3043 If Buffer is NULL, then ASSERT().
3044 If Buffer is not aligned on a 32-bit boundary, then ASSERT().
3045 If Length is not aligned on a 32-bit boundary, then ASSERT().
3046 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
3048 @param Buffer Pointer to the buffer to carry out the sum operation.
3049 @param Length The size, in bytes, of Buffer.
3051 @return Sum The sum of Buffer with carry bits dropped during additions.
3057 IN CONST UINT32
*Buffer
,
3063 Returns the two's complement checksum of all elements in a buffer of
3066 This function first calculates the sum of the 32-bit values in the buffer
3067 specified by Buffer and Length. The carry bits in the result of addition
3068 are dropped. Then, the two's complement of the sum is returned. If Length
3069 is 0, then 0 is returned.
3071 If Buffer is NULL, then ASSERT().
3072 If Buffer is not aligned on a 32-bit boundary, then ASSERT().
3073 If Length is not aligned on a 32-bit boundary, then ASSERT().
3074 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
3076 @param Buffer Pointer to the buffer to carry out the checksum operation.
3077 @param Length The size, in bytes, of Buffer.
3079 @return Checksum The 2's complement checksum of Buffer.
3084 CalculateCheckSum32 (
3085 IN CONST UINT32
*Buffer
,
3091 Returns the sum of all elements in a buffer of 64-bit values. During
3092 calculation, the carry bits are dropped.
3094 This function calculates the sum of the 64-bit values in the buffer
3095 specified by Buffer and Length. The carry bits in result of addition are dropped.
3096 The 64-bit result is returned. If Length is 0, then 0 is returned.
3098 If Buffer is NULL, then ASSERT().
3099 If Buffer is not aligned on a 64-bit boundary, then ASSERT().
3100 If Length is not aligned on a 64-bit boundary, then ASSERT().
3101 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
3103 @param Buffer Pointer to the buffer to carry out the sum operation.
3104 @param Length The size, in bytes, of Buffer.
3106 @return Sum The sum of Buffer with carry bits dropped during additions.
3112 IN CONST UINT64
*Buffer
,
3118 Returns the two's complement checksum of all elements in a buffer of
3121 This function first calculates the sum of the 64-bit values in the buffer
3122 specified by Buffer and Length. The carry bits in the result of addition
3123 are dropped. Then, the two's complement of the sum is returned. If Length
3124 is 0, then 0 is returned.
3126 If Buffer is NULL, then ASSERT().
3127 If Buffer is not aligned on a 64-bit boundary, then ASSERT().
3128 If Length is not aligned on a 64-bit boundary, then ASSERT().
3129 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
3131 @param Buffer Pointer to the buffer to carry out the checksum operation.
3132 @param Length The size, in bytes, of Buffer.
3134 @return Checksum The 2's complement checksum of Buffer.
3139 CalculateCheckSum64 (
3140 IN CONST UINT64
*Buffer
,
3146 // Base Library CPU Functions
3150 Function entry point used when a stack switch is requested with SwitchStack()
3152 @param Context1 Context1 parameter passed into SwitchStack().
3153 @param Context2 Context2 parameter passed into SwitchStack().
3158 (EFIAPI
*SWITCH_STACK_ENTRY_POINT
)(
3159 IN VOID
*Context1
, OPTIONAL
3160 IN VOID
*Context2 OPTIONAL
3165 Used to serialize load and store operations.
3167 All loads and stores that proceed calls to this function are guaranteed to be
3168 globally visible when this function returns.
3179 Saves the current CPU context that can be restored with a call to LongJump()
3182 Saves the current CPU context in the buffer specified by JumpBuffer and
3183 returns 0. The initial call to SetJump() must always return 0. Subsequent
3184 calls to LongJump() cause a non-zero value to be returned by SetJump().
3186 If JumpBuffer is NULL, then ASSERT().
3187 For Itanium processors, if JumpBuffer is not aligned on a 16-byte boundary, then ASSERT().
3189 NOTE: The structure BASE_LIBRARY_JUMP_BUFFER is CPU architecture specific.
3190 The same structure must never be used for more than one CPU architecture context.
3191 For example, a BASE_LIBRARY_JUMP_BUFFER allocated by an IA-32 module must never be used from an x64 module.
3192 SetJump()/LongJump() is not currently supported for the EBC processor type.
3194 @param JumpBuffer A pointer to CPU context buffer.
3196 @retval 0 Indicates a return from SetJump().
3202 OUT BASE_LIBRARY_JUMP_BUFFER
*JumpBuffer
3207 Restores the CPU context that was saved with SetJump().
3209 Restores the CPU context from the buffer specified by JumpBuffer. This
3210 function never returns to the caller. Instead is resumes execution based on
3211 the state of JumpBuffer.
3213 If JumpBuffer is NULL, then ASSERT().
3214 For Itanium processors, if JumpBuffer is not aligned on a 16-byte boundary, then ASSERT().
3215 If Value is 0, then ASSERT().
3217 @param JumpBuffer A pointer to CPU context buffer.
3218 @param Value The value to return when the SetJump() context is
3219 restored and must be non-zero.
3225 IN BASE_LIBRARY_JUMP_BUFFER
*JumpBuffer
,
3231 Enables CPU interrupts.
3242 Disables CPU interrupts.
3253 Disables CPU interrupts and returns the interrupt state prior to the disable
3256 @retval TRUE CPU interrupts were enabled on entry to this call.
3257 @retval FALSE CPU interrupts were disabled on entry to this call.
3262 SaveAndDisableInterrupts (
3268 Enables CPU interrupts for the smallest window required to capture any
3274 EnableDisableInterrupts (
3280 Retrieves the current CPU interrupt state.
3282 Returns TRUE is interrupts are currently enabled. Otherwise
3285 @retval TRUE CPU interrupts are enabled.
3286 @retval FALSE CPU interrupts are disabled.
3297 Set the current CPU interrupt state.
3299 Sets the current CPU interrupt state to the state specified by
3300 InterruptState. If InterruptState is TRUE, then interrupts are enabled. If
3301 InterruptState is FALSE, then interrupts are disabled. InterruptState is
3304 @param InterruptState TRUE if interrupts should enabled. FALSE if
3305 interrupts should be disabled.
3307 @return InterruptState
3313 IN BOOLEAN InterruptState
3318 Requests CPU to pause for a short period of time.
3320 Requests CPU to pause for a short period of time. Typically used in MP
3321 systems to prevent memory starvation while waiting for a spin lock.
3332 Transfers control to a function starting with a new stack.
3334 Transfers control to the function specified by EntryPoint using the
3335 new stack specified by NewStack and passing in the parameters specified
3336 by Context1 and Context2. Context1 and Context2 are optional and may
3337 be NULL. The function EntryPoint must never return. This function
3338 supports a variable number of arguments following the NewStack parameter.
3339 These additional arguments are ignored on IA-32, x64, and EBC architectures.
3340 Itanium processors expect one additional parameter of type VOID * that specifies
3341 the new backing store pointer.
3343 If EntryPoint is NULL, then ASSERT().
3344 If NewStack is NULL, then ASSERT().
3346 @param EntryPoint A pointer to function to call with the new stack.
3347 @param Context1 A pointer to the context to pass into the EntryPoint
3349 @param Context2 A pointer to the context to pass into the EntryPoint
3351 @param NewStack A pointer to the new stack to use for the EntryPoint
3353 @param ... This variable argument list is ignored for IA-32, x64, and EBC architectures.
3354 For Itanium processors, this variable argument list is expected to contain
3355 a single parameter of type VOID * that specifies the new backing
3363 IN SWITCH_STACK_ENTRY_POINT EntryPoint
,
3364 IN VOID
*Context1
, OPTIONAL
3365 IN VOID
*Context2
, OPTIONAL
3372 Generates a breakpoint on the CPU.
3374 Generates a breakpoint on the CPU. The breakpoint must be implemented such
3375 that code can resume normal execution after the breakpoint.
3386 Executes an infinite loop.
3388 Forces the CPU to execute an infinite loop. A debugger may be used to skip
3389 past the loop and the code that follows the loop must execute properly. This
3390 implies that the infinite loop must not cause the code that follow it to be
3400 #if defined (MDE_CPU_IPF)
3403 Flush a range of cache lines in the cache coherency domain of the calling
3406 Flushes the cache lines specified by Address and Length. If Address is not aligned
3407 on a cache line boundary, then entire cache line containing Address is flushed.
3408 If Address + Length is not aligned on a cache line boundary, then the entire cache
3409 line containing Address + Length - 1 is flushed. This function may choose to flush
3410 the entire cache if that is more efficient than flushing the specified range. If
3411 Length is 0, the no cache lines are flushed. Address is returned.
3412 This function is only available on Itanium processors.
3414 If Length is greater than (MAX_ADDRESS - Address + 1), then ASSERT().
3416 @param Address The base address of the instruction lines to invalidate. If
3417 the CPU is in a physical addressing mode, then Address is a
3418 physical address. If the CPU is in a virtual addressing mode,
3419 then Address is a virtual address.
3421 @param Length The number of bytes to invalidate from the instruction cache.
3428 AsmFlushCacheRange (
3435 Executes a FC instruction
3436 Executes a FC instruction on the cache line specified by Address.
3437 The cache line size affected is at least 32-bytes (aligned on a 32-byte boundary).
3438 An implementation may flush a larger region. This function is only available on Itanium processors.
3440 @param Address The Address of cache line to be flushed.
3442 @return The address of FC instruction executed.
3453 Executes a FC.I instruction.
3454 Executes a FC.I instruction on the cache line specified by Address.
3455 The cache line size affected is at least 32-bytes (aligned on a 32-byte boundary).
3456 An implementation may flush a larger region. This function is only available on Itanium processors.
3458 @param Address The Address of cache line to be flushed.
3460 @return The address of FC.I instruction executed.
3471 Reads the current value of a Processor Identifier Register (CPUID).
3473 Reads and returns the current value of Processor Identifier Register specified by Index.
3474 The Index of largest implemented CPUID (One less than the number of implemented CPUID
3475 registers) is determined by CPUID [3] bits {7:0}.
3476 No parameter checking is performed on Index. If the Index value is beyond the
3477 implemented CPUID register range, a Reserved Register/Field fault may occur. The caller
3478 must either guarantee that Index is valid, or the caller must set up fault handlers to
3479 catch the faults. This function is only available on Itanium processors.
3481 @param Index The 8-bit Processor Identifier Register index to read.
3483 @return The current value of Processor Identifier Register specified by Index.
3494 Reads the current value of 64-bit Processor Status Register (PSR).
3495 This function is only available on Itanium processors.
3497 @return The current value of PSR.
3508 Writes the current value of 64-bit Processor Status Register (PSR).
3510 No parameter checking is performed on Value. All bits of Value corresponding to
3511 reserved fields of PSR must be 0 or a Reserved Register/Field fault may occur.
3512 The caller must either guarantee that Value is valid, or the caller must set up
3513 fault handlers to catch the faults. This function is only available on Itanium processors.
3515 @param Value The 64-bit value to write to PSR.
3517 @return The 64-bit value written to the PSR.
3528 Reads the current value of 64-bit Kernel Register #0 (KR0).
3530 Reads and returns the current value of KR0.
3531 This function is only available on Itanium processors.
3533 @return The current value of KR0.
3544 Reads the current value of 64-bit Kernel Register #1 (KR1).
3546 Reads and returns the current value of KR1.
3547 This function is only available on Itanium processors.
3549 @return The current value of KR1.
3560 Reads the current value of 64-bit Kernel Register #2 (KR2).
3562 Reads and returns the current value of KR2.
3563 This function is only available on Itanium processors.
3565 @return The current value of KR2.
3576 Reads the current value of 64-bit Kernel Register #3 (KR3).
3578 Reads and returns the current value of KR3.
3579 This function is only available on Itanium processors.
3581 @return The current value of KR3.
3592 Reads the current value of 64-bit Kernel Register #4 (KR4).
3594 Reads and returns the current value of KR4.
3595 This function is only available on Itanium processors.
3597 @return The current value of KR4.
3608 Reads the current value of 64-bit Kernel Register #5 (KR5).
3610 Reads and returns the current value of KR5.
3611 This function is only available on Itanium processors.
3613 @return The current value of KR5.
3624 Reads the current value of 64-bit Kernel Register #6 (KR6).
3626 Reads and returns the current value of KR6.
3627 This function is only available on Itanium processors.
3629 @return The current value of KR6.
3640 Reads the current value of 64-bit Kernel Register #7 (KR7).
3642 Reads and returns the current value of KR7.
3643 This function is only available on Itanium processors.
3645 @return The current value of KR7.
3656 Write the current value of 64-bit Kernel Register #0 (KR0).
3658 Writes the current value of KR0. The 64-bit value written to
3659 the KR0 is returned. This function is only available on Itanium processors.
3661 @param Value The 64-bit value to write to KR0.
3663 @return The 64-bit value written to the KR0.
3674 Write the current value of 64-bit Kernel Register #1 (KR1).
3676 Writes the current value of KR1. The 64-bit value written to
3677 the KR1 is returned. This function is only available on Itanium processors.
3679 @param Value The 64-bit value to write to KR1.
3681 @return The 64-bit value written to the KR1.
3692 Write the current value of 64-bit Kernel Register #2 (KR2).
3694 Writes the current value of KR2. The 64-bit value written to
3695 the KR2 is returned. This function is only available on Itanium processors.
3697 @param Value The 64-bit value to write to KR2.
3699 @return The 64-bit value written to the KR2.
3710 Write the current value of 64-bit Kernel Register #3 (KR3).
3712 Writes the current value of KR3. The 64-bit value written to
3713 the KR3 is returned. This function is only available on Itanium processors.
3715 @param Value The 64-bit value to write to KR3.
3717 @return The 64-bit value written to the KR3.
3728 Write the current value of 64-bit Kernel Register #4 (KR4).
3730 Writes the current value of KR4. The 64-bit value written to
3731 the KR4 is returned. This function is only available on Itanium processors.
3733 @param Value The 64-bit value to write to KR4.
3735 @return The 64-bit value written to the KR4.
3746 Write the current value of 64-bit Kernel Register #5 (KR5).
3748 Writes the current value of KR5. The 64-bit value written to
3749 the KR5 is returned. This function is only available on Itanium processors.
3751 @param Value The 64-bit value to write to KR5.
3753 @return The 64-bit value written to the KR5.
3764 Write the current value of 64-bit Kernel Register #6 (KR6).
3766 Writes the current value of KR6. The 64-bit value written to
3767 the KR6 is returned. This function is only available on Itanium processors.
3769 @param Value The 64-bit value to write to KR6.
3771 @return The 64-bit value written to the KR6.
3782 Write the current value of 64-bit Kernel Register #7 (KR7).
3784 Writes the current value of KR7. The 64-bit value written to
3785 the KR7 is returned. This function is only available on Itanium processors.
3787 @param Value The 64-bit value to write to KR7.
3789 @return The 64-bit value written to the KR7.
3800 Reads the current value of Interval Timer Counter Register (ITC).
3802 Reads and returns the current value of ITC.
3803 This function is only available on Itanium processors.
3805 @return The current value of ITC.
3816 Reads the current value of Interval Timer Vector Register (ITV).
3818 Reads and returns the current value of ITV.
3819 This function is only available on Itanium processors.
3821 @return The current value of ITV.
3832 Reads the current value of Interval Timer Match Register (ITM).
3834 Reads and returns the current value of ITM.
3835 This function is only available on Itanium processors.
3837 @return The current value of ITM.
3847 Writes the current value of 64-bit Interval Timer Counter Register (ITC).
3849 Writes the current value of ITC. The 64-bit value written to the ITC is returned.
3850 This function is only available on Itanium processors.
3852 @param Value The 64-bit value to write to ITC.
3854 @return The 64-bit value written to the ITC.
3865 Writes the current value of 64-bit Interval Timer Match Register (ITM).
3867 Writes the current value of ITM. The 64-bit value written to the ITM is returned.
3868 This function is only available on Itanium processors.
3870 @param Value The 64-bit value to write to ITM.
3872 @return The 64-bit value written to the ITM.
3883 Writes the current value of 64-bit Interval Timer Vector Register (ITV).
3885 Writes the current value of ITV. The 64-bit value written to the ITV is returned.
3886 No parameter checking is performed on Value. All bits of Value corresponding to
3887 reserved fields of ITV must be 0 or a Reserved Register/Field fault may occur.
3888 The caller must either guarantee that Value is valid, or the caller must set up
3889 fault handlers to catch the faults.
3890 This function is only available on Itanium processors.
3892 @param Value The 64-bit value to write to ITV.
3894 @return The 64-bit value written to the ITV.
3905 Reads the current value of Default Control Register (DCR).
3907 Reads and returns the current value of DCR. This function is only available on Itanium processors.
3909 @return The current value of DCR.
3920 Reads the current value of Interruption Vector Address Register (IVA).
3922 Reads and returns the current value of IVA. This function is only available on Itanium processors.
3924 @return The current value of IVA.
3934 Reads the current value of Page Table Address Register (PTA).
3936 Reads and returns the current value of PTA. This function is only available on Itanium processors.
3938 @return The current value of PTA.
3949 Writes the current value of 64-bit Default Control Register (DCR).
3951 Writes the current value of DCR. The 64-bit value written to the DCR is returned.
3952 No parameter checking is performed on Value. All bits of Value corresponding to
3953 reserved fields of DCR must be 0 or a Reserved Register/Field fault may occur.
3954 The caller must either guarantee that Value is valid, or the caller must set up
3955 fault handlers to catch the faults.
3956 This function is only available on Itanium processors.
3958 @param Value The 64-bit value to write to DCR.
3960 @return The 64-bit value written to the DCR.
3971 Writes the current value of 64-bit Interruption Vector Address Register (IVA).
3973 Writes the current value of IVA. The 64-bit value written to the IVA is returned.
3974 The size of vector table is 32 K bytes and is 32 K bytes aligned
3975 the low 15 bits of Value is ignored when written.
3976 This function is only available on Itanium processors.
3978 @param Value The 64-bit value to write to IVA.
3980 @return The 64-bit value written to the IVA.
3991 Writes the current value of 64-bit Page Table Address Register (PTA).
3993 Writes the current value of PTA. The 64-bit value written to the PTA is returned.
3994 No parameter checking is performed on Value. All bits of Value corresponding to
3995 reserved fields of DCR must be 0 or a Reserved Register/Field fault may occur.
3996 The caller must either guarantee that Value is valid, or the caller must set up
3997 fault handlers to catch the faults.
3998 This function is only available on Itanium processors.
4000 @param Value The 64-bit value to write to PTA.
4002 @return The 64-bit value written to the PTA.
4012 Reads the current value of Local Interrupt ID Register (LID).
4014 Reads and returns the current value of LID. This function is only available on Itanium processors.
4016 @return The current value of LID.
4027 Reads the current value of External Interrupt Vector Register (IVR).
4029 Reads and returns the current value of IVR. This function is only available on Itanium processors.
4031 @return The current value of IVR.
4042 Reads the current value of Task Priority Register (TPR).
4044 Reads and returns the current value of TPR. This function is only available on Itanium processors.
4046 @return The current value of TPR.
4057 Reads the current value of External Interrupt Request Register #0 (IRR0).
4059 Reads and returns the current value of IRR0. This function is only available on Itanium processors.
4061 @return The current value of IRR0.
4072 Reads the current value of External Interrupt Request Register #1 (IRR1).
4074 Reads and returns the current value of IRR1. This function is only available on Itanium processors.
4076 @return The current value of IRR1.
4087 Reads the current value of External Interrupt Request Register #2 (IRR2).
4089 Reads and returns the current value of IRR2. This function is only available on Itanium processors.
4091 @return The current value of IRR2.
4102 Reads the current value of External Interrupt Request Register #3 (IRR3).
4104 Reads and returns the current value of IRR3. This function is only available on Itanium processors.
4106 @return The current value of IRR3.
4117 Reads the current value of Performance Monitor Vector Register (PMV).
4119 Reads and returns the current value of PMV. This function is only available on Itanium processors.
4121 @return The current value of PMV.
4132 Reads the current value of Corrected Machine Check Vector Register (CMCV).
4134 Reads and returns the current value of CMCV. This function is only available on Itanium processors.
4136 @return The current value of CMCV.
4147 Reads the current value of Local Redirection Register #0 (LRR0).
4149 Reads and returns the current value of LRR0. This function is only available on Itanium processors.
4151 @return The current value of LRR0.
4162 Reads the current value of Local Redirection Register #1 (LRR1).
4164 Reads and returns the current value of LRR1. This function is only available on Itanium processors.
4166 @return The current value of LRR1.
4177 Writes the current value of 64-bit Page Local Interrupt ID Register (LID).
4179 Writes the current value of LID. The 64-bit value written to the LID is returned.
4180 No parameter checking is performed on Value. All bits of Value corresponding to
4181 reserved fields of LID must be 0 or a Reserved Register/Field fault may occur.
4182 The caller must either guarantee that Value is valid, or the caller must set up
4183 fault handlers to catch the faults.
4184 This function is only available on Itanium processors.
4186 @param Value The 64-bit value to write to LID.
4188 @return The 64-bit value written to the LID.
4199 Writes the current value of 64-bit Task Priority Register (TPR).
4201 Writes the current value of TPR. The 64-bit value written to the TPR is returned.
4202 No parameter checking is performed on Value. All bits of Value corresponding to
4203 reserved fields of TPR must be 0 or a Reserved Register/Field fault may occur.
4204 The caller must either guarantee that Value is valid, or the caller must set up
4205 fault handlers to catch the faults.
4206 This function is only available on Itanium processors.
4208 @param Value The 64-bit value to write to TPR.
4210 @return The 64-bit value written to the TPR.
4221 Performs a write operation on End OF External Interrupt Register (EOI).
4223 Writes a value of 0 to the EOI Register. This function is only available on Itanium processors.
4234 Writes the current value of 64-bit Performance Monitor Vector Register (PMV).
4236 Writes the current value of PMV. The 64-bit value written to the PMV is returned.
4237 No parameter checking is performed on Value. All bits of Value corresponding
4238 to reserved fields of PMV must be 0 or a Reserved Register/Field fault may occur.
4239 The caller must either guarantee that Value is valid, or the caller must set up
4240 fault handlers to catch the faults.
4241 This function is only available on Itanium processors.
4243 @param Value The 64-bit value to write to PMV.
4245 @return The 64-bit value written to the PMV.
4256 Writes the current value of 64-bit Corrected Machine Check Vector Register (CMCV).
4258 Writes the current value of CMCV. The 64-bit value written to the CMCV is returned.
4259 No parameter checking is performed on Value. All bits of Value corresponding
4260 to reserved fields of CMCV must be 0 or a Reserved Register/Field fault may occur.
4261 The caller must either guarantee that Value is valid, or the caller must set up
4262 fault handlers to catch the faults.
4263 This function is only available on Itanium processors.
4265 @param Value The 64-bit value to write to CMCV.
4267 @return The 64-bit value written to the CMCV.
4278 Writes the current value of 64-bit Local Redirection Register #0 (LRR0).
4280 Writes the current value of LRR0. The 64-bit value written to the LRR0 is returned.
4281 No parameter checking is performed on Value. All bits of Value corresponding
4282 to reserved fields of LRR0 must be 0 or a Reserved Register/Field fault may occur.
4283 The caller must either guarantee that Value is valid, or the caller must set up
4284 fault handlers to catch the faults.
4285 This function is only available on Itanium processors.
4287 @param Value The 64-bit value to write to LRR0.
4289 @return The 64-bit value written to the LRR0.
4300 Writes the current value of 64-bit Local Redirection Register #1 (LRR1).
4302 Writes the current value of LRR1. The 64-bit value written to the LRR1 is returned.
4303 No parameter checking is performed on Value. All bits of Value corresponding
4304 to reserved fields of LRR1 must be 0 or a Reserved Register/Field fault may occur.
4305 The caller must either guarantee that Value is valid, or the caller must
4306 set up fault handlers to catch the faults.
4307 This function is only available on Itanium processors.
4309 @param Value The 64-bit value to write to LRR1.
4311 @return The 64-bit value written to the LRR1.
4322 Reads the current value of Instruction Breakpoint Register (IBR).
4324 The Instruction Breakpoint Registers are used in pairs. The even numbered
4325 registers contain breakpoint addresses, and the odd numbered registers contain
4326 breakpoint mask conditions. At least 4 instruction registers pairs are implemented
4327 on all processor models. Implemented registers are contiguous starting with
4328 register 0. No parameter checking is performed on Index, and if the Index value
4329 is beyond the implemented IBR register range, a Reserved Register/Field fault may
4330 occur. The caller must either guarantee that Index is valid, or the caller must
4331 set up fault handlers to catch the faults.
4332 This function is only available on Itanium processors.
4334 @param Index The 8-bit Instruction Breakpoint Register index to read.
4336 @return The current value of Instruction Breakpoint Register specified by Index.
4347 Reads the current value of Data Breakpoint Register (DBR).
4349 The Data Breakpoint Registers are used in pairs. The even numbered registers
4350 contain breakpoint addresses, and odd numbered registers contain breakpoint
4351 mask conditions. At least 4 data registers pairs are implemented on all processor
4352 models. Implemented registers are contiguous starting with register 0.
4353 No parameter checking is performed on Index. If the Index value is beyond
4354 the implemented DBR register range, a Reserved Register/Field fault may occur.
4355 The caller must either guarantee that Index is valid, or the caller must set up
4356 fault handlers to catch the faults.
4357 This function is only available on Itanium processors.
4359 @param Index The 8-bit Data Breakpoint Register index to read.
4361 @return The current value of Data Breakpoint Register specified by Index.
4372 Reads the current value of Performance Monitor Configuration Register (PMC).
4374 All processor implementations provide at least 4 performance counters
4375 (PMC/PMD [4]...PMC/PMD [7] pairs), and 4 performance monitor counter overflow
4376 status registers (PMC [0]... PMC [3]). Processor implementations may provide
4377 additional implementation-dependent PMC and PMD to increase the number of
4378 'generic' performance counters (PMC/PMD pairs). The remainder of PMC and PMD
4379 register set is implementation dependent. No parameter checking is performed
4380 on Index. If the Index value is beyond the implemented PMC register range,
4381 zero value will be returned.
4382 This function is only available on Itanium processors.
4384 @param Index The 8-bit Performance Monitor Configuration Register index to read.
4386 @return The current value of Performance Monitor Configuration Register
4398 Reads the current value of Performance Monitor Data Register (PMD).
4400 All processor implementations provide at least 4 performance counters
4401 (PMC/PMD [4]...PMC/PMD [7] pairs), and 4 performance monitor counter
4402 overflow status registers (PMC [0]... PMC [3]). Processor implementations may
4403 provide additional implementation-dependent PMC and PMD to increase the number
4404 of 'generic' performance counters (PMC/PMD pairs). The remainder of PMC and PMD
4405 register set is implementation dependent. No parameter checking is performed
4406 on Index. If the Index value is beyond the implemented PMD register range,
4407 zero value will be returned.
4408 This function is only available on Itanium processors.
4410 @param Index The 8-bit Performance Monitor Data Register index to read.
4412 @return The current value of Performance Monitor Data Register specified by Index.
4423 Writes the current value of 64-bit Instruction Breakpoint Register (IBR).
4425 Writes current value of Instruction Breakpoint Register specified by Index.
4426 The Instruction Breakpoint Registers are used in pairs. The even numbered
4427 registers contain breakpoint addresses, and odd numbered registers contain
4428 breakpoint mask conditions. At least 4 instruction registers pairs are implemented
4429 on all processor models. Implemented registers are contiguous starting with
4430 register 0. No parameter checking is performed on Index. If the Index value
4431 is beyond the implemented IBR register range, a Reserved Register/Field fault may
4432 occur. The caller must either guarantee that Index is valid, or the caller must
4433 set up fault handlers to catch the faults.
4434 This function is only available on Itanium processors.
4436 @param Index The 8-bit Instruction Breakpoint Register index to write.
4437 @param Value The 64-bit value to write to IBR.
4439 @return The 64-bit value written to the IBR.
4451 Writes the current value of 64-bit Data Breakpoint Register (DBR).
4453 Writes current value of Data Breakpoint Register specified by Index.
4454 The Data Breakpoint Registers are used in pairs. The even numbered registers
4455 contain breakpoint addresses, and odd numbered registers contain breakpoint
4456 mask conditions. At least 4 data registers pairs are implemented on all processor
4457 models. Implemented registers are contiguous starting with register 0. No parameter
4458 checking is performed on Index. If the Index value is beyond the implemented
4459 DBR register range, a Reserved Register/Field fault may occur. The caller must
4460 either guarantee that Index is valid, or the caller must set up fault handlers to
4462 This function is only available on Itanium processors.
4464 @param Index The 8-bit Data Breakpoint Register index to write.
4465 @param Value The 64-bit value to write to DBR.
4467 @return The 64-bit value written to the DBR.
4479 Writes the current value of 64-bit Performance Monitor Configuration Register (PMC).
4481 Writes current value of Performance Monitor Configuration Register specified by Index.
4482 All processor implementations provide at least 4 performance counters
4483 (PMC/PMD [4]...PMC/PMD [7] pairs), and 4 performance monitor counter overflow status
4484 registers (PMC [0]... PMC [3]). Processor implementations may provide additional
4485 implementation-dependent PMC and PMD to increase the number of 'generic' performance
4486 counters (PMC/PMD pairs). The remainder of PMC and PMD register set is implementation
4487 dependent. No parameter checking is performed on Index. If the Index value is
4488 beyond the implemented PMC register range, the write is ignored.
4489 This function is only available on Itanium processors.
4491 @param Index The 8-bit Performance Monitor Configuration Register index to write.
4492 @param Value The 64-bit value to write to PMC.
4494 @return The 64-bit value written to the PMC.
4506 Writes the current value of 64-bit Performance Monitor Data Register (PMD).
4508 Writes current value of Performance Monitor Data Register specified by Index.
4509 All processor implementations provide at least 4 performance counters
4510 (PMC/PMD [4]...PMC/PMD [7] pairs), and 4 performance monitor counter overflow
4511 status registers (PMC [0]... PMC [3]). Processor implementations may provide
4512 additional implementation-dependent PMC and PMD to increase the number of 'generic'
4513 performance counters (PMC/PMD pairs). The remainder of PMC and PMD register set
4514 is implementation dependent. No parameter checking is performed on Index. If the
4515 Index value is beyond the implemented PMD register range, the write is ignored.
4516 This function is only available on Itanium processors.
4518 @param Index The 8-bit Performance Monitor Data Register index to write.
4519 @param Value The 64-bit value to write to PMD.
4521 @return The 64-bit value written to the PMD.
4533 Reads the current value of 64-bit Global Pointer (GP).
4535 Reads and returns the current value of GP.
4536 This function is only available on Itanium processors.
4538 @return The current value of GP.
4549 Write the current value of 64-bit Global Pointer (GP).
4551 Writes the current value of GP. The 64-bit value written to the GP is returned.
4552 No parameter checking is performed on Value.
4553 This function is only available on Itanium processors.
4555 @param Value The 64-bit value to write to GP.
4557 @return The 64-bit value written to the GP.
4568 Reads the current value of 64-bit Stack Pointer (SP).
4570 Reads and returns the current value of SP.
4571 This function is only available on Itanium processors.
4573 @return The current value of SP.
4584 /// Valid Index value for AsmReadControlRegister()
4586 #define IPF_CONTROL_REGISTER_DCR 0
4587 #define IPF_CONTROL_REGISTER_ITM 1
4588 #define IPF_CONTROL_REGISTER_IVA 2
4589 #define IPF_CONTROL_REGISTER_PTA 8
4590 #define IPF_CONTROL_REGISTER_IPSR 16
4591 #define IPF_CONTROL_REGISTER_ISR 17
4592 #define IPF_CONTROL_REGISTER_IIP 19
4593 #define IPF_CONTROL_REGISTER_IFA 20
4594 #define IPF_CONTROL_REGISTER_ITIR 21
4595 #define IPF_CONTROL_REGISTER_IIPA 22
4596 #define IPF_CONTROL_REGISTER_IFS 23
4597 #define IPF_CONTROL_REGISTER_IIM 24
4598 #define IPF_CONTROL_REGISTER_IHA 25
4599 #define IPF_CONTROL_REGISTER_LID 64
4600 #define IPF_CONTROL_REGISTER_IVR 65
4601 #define IPF_CONTROL_REGISTER_TPR 66
4602 #define IPF_CONTROL_REGISTER_EOI 67
4603 #define IPF_CONTROL_REGISTER_IRR0 68
4604 #define IPF_CONTROL_REGISTER_IRR1 69
4605 #define IPF_CONTROL_REGISTER_IRR2 70
4606 #define IPF_CONTROL_REGISTER_IRR3 71
4607 #define IPF_CONTROL_REGISTER_ITV 72
4608 #define IPF_CONTROL_REGISTER_PMV 73
4609 #define IPF_CONTROL_REGISTER_CMCV 74
4610 #define IPF_CONTROL_REGISTER_LRR0 80
4611 #define IPF_CONTROL_REGISTER_LRR1 81
4614 Reads a 64-bit control register.
4616 Reads and returns the control register specified by Index. The valid Index valued are defined
4617 above in "Related Definitions".
4618 If Index is invalid then 0xFFFFFFFFFFFFFFFF is returned. This function is only available on Itanium processors.
4620 @param Index The index of the control register to read.
4622 @return The control register specified by Index.
4627 AsmReadControlRegister (
4633 /// Valid Index value for AsmReadApplicationRegister()
4635 #define IPF_APPLICATION_REGISTER_K0 0
4636 #define IPF_APPLICATION_REGISTER_K1 1
4637 #define IPF_APPLICATION_REGISTER_K2 2
4638 #define IPF_APPLICATION_REGISTER_K3 3
4639 #define IPF_APPLICATION_REGISTER_K4 4
4640 #define IPF_APPLICATION_REGISTER_K5 5
4641 #define IPF_APPLICATION_REGISTER_K6 6
4642 #define IPF_APPLICATION_REGISTER_K7 7
4643 #define IPF_APPLICATION_REGISTER_RSC 16
4644 #define IPF_APPLICATION_REGISTER_BSP 17
4645 #define IPF_APPLICATION_REGISTER_BSPSTORE 18
4646 #define IPF_APPLICATION_REGISTER_RNAT 19
4647 #define IPF_APPLICATION_REGISTER_FCR 21
4648 #define IPF_APPLICATION_REGISTER_EFLAG 24
4649 #define IPF_APPLICATION_REGISTER_CSD 25
4650 #define IPF_APPLICATION_REGISTER_SSD 26
4651 #define IPF_APPLICATION_REGISTER_CFLG 27
4652 #define IPF_APPLICATION_REGISTER_FSR 28
4653 #define IPF_APPLICATION_REGISTER_FIR 29
4654 #define IPF_APPLICATION_REGISTER_FDR 30
4655 #define IPF_APPLICATION_REGISTER_CCV 32
4656 #define IPF_APPLICATION_REGISTER_UNAT 36
4657 #define IPF_APPLICATION_REGISTER_FPSR 40
4658 #define IPF_APPLICATION_REGISTER_ITC 44
4659 #define IPF_APPLICATION_REGISTER_PFS 64
4660 #define IPF_APPLICATION_REGISTER_LC 65
4661 #define IPF_APPLICATION_REGISTER_EC 66
4664 Reads a 64-bit application register.
4666 Reads and returns the application register specified by Index. The valid Index valued are defined
4667 above in "Related Definitions".
4668 If Index is invalid then 0xFFFFFFFFFFFFFFFF is returned. This function is only available on Itanium processors.
4670 @param Index The index of the application register to read.
4672 @return The application register specified by Index.
4677 AsmReadApplicationRegister (
4683 Reads the current value of a Machine Specific Register (MSR).
4685 Reads and returns the current value of the Machine Specific Register specified by Index. No
4686 parameter checking is performed on Index, and if the Index value is beyond the implemented MSR
4687 register range, a Reserved Register/Field fault may occur. The caller must either guarantee that
4688 Index is valid, or the caller must set up fault handlers to catch the faults. This function is
4689 only available on Itanium processors.
4691 @param Index The 8-bit Machine Specific Register index to read.
4693 @return The current value of the Machine Specific Register specified by Index.
4704 Writes the current value of a Machine Specific Register (MSR).
4706 Writes Value to the Machine Specific Register specified by Index. Value is returned. No
4707 parameter checking is performed on Index, and if the Index value is beyond the implemented MSR
4708 register range, a Reserved Register/Field fault may occur. The caller must either guarantee that
4709 Index is valid, or the caller must set up fault handlers to catch the faults. This function is
4710 only available on Itanium processors.
4712 @param Index The 8-bit Machine Specific Register index to write.
4713 @param Value The 64-bit value to write to the Machine Specific Register.
4715 @return The 64-bit value to write to the Machine Specific Register.
4727 Determines if the CPU is currently executing in virtual, physical, or mixed mode.
4729 Determines the current execution mode of the CPU.
4730 If the CPU is in virtual mode(PSR.RT=1, PSR.DT=1, PSR.IT=1), then 1 is returned.
4731 If the CPU is in physical mode(PSR.RT=0, PSR.DT=0, PSR.IT=0), then 0 is returned.
4732 If the CPU is not in physical mode or virtual mode, then it is in mixed mode,
4734 This function is only available on Itanium processors.
4736 @retval 1 The CPU is in virtual mode.
4737 @retval 0 The CPU is in physical mode.
4738 @retval -1 The CPU is in mixed mode.
4749 Makes a PAL procedure call.
4751 This is a wrapper function to make a PAL procedure call. Based on the Index
4752 value this API will make static or stacked PAL call. The following table
4753 describes the usage of PAL Procedure Index Assignment. Architected procedures
4754 may be designated as required or optional. If a PAL procedure is specified
4755 as optional, a unique return code of 0xFFFFFFFFFFFFFFFF is returned in the
4756 Status field of the PAL_CALL_RETURN structure.
4757 This indicates that the procedure is not present in this PAL implementation.
4758 It is the caller's responsibility to check for this return code after calling
4759 any optional PAL procedure.
4760 No parameter checking is performed on the 5 input parameters, but there are
4761 some common rules that the caller should follow when making a PAL call. Any
4762 address passed to PAL as buffers for return parameters must be 8-byte aligned.
4763 Unaligned addresses may cause undefined results. For those parameters defined
4764 as reserved or some fields defined as reserved must be zero filled or the invalid
4765 argument return value may be returned or undefined result may occur during the
4766 execution of the procedure. If the PalEntryPoint does not point to a valid
4767 PAL entry point then the system behavior is undefined. This function is only
4768 available on Itanium processors.
4770 @param PalEntryPoint The PAL procedure calls entry point.
4771 @param Index The PAL procedure Index number.
4772 @param Arg2 The 2nd parameter for PAL procedure calls.
4773 @param Arg3 The 3rd parameter for PAL procedure calls.
4774 @param Arg4 The 4th parameter for PAL procedure calls.
4776 @return structure returned from the PAL Call procedure, including the status and return value.
4782 IN UINT64 PalEntryPoint
,
4790 #if defined (MDE_CPU_IA32) || defined (MDE_CPU_X64)
4792 /// IA32 and x64 Specific Functions
4793 /// Byte packed structure for 16-bit Real Mode EFLAGS
4797 UINT32 CF
:1; ///< Carry Flag
4798 UINT32 Reserved_0
:1; ///< Reserved
4799 UINT32 PF
:1; ///< Parity Flag
4800 UINT32 Reserved_1
:1; ///< Reserved
4801 UINT32 AF
:1; ///< Auxiliary Carry Flag
4802 UINT32 Reserved_2
:1; ///< Reserved
4803 UINT32 ZF
:1; ///< Zero Flag
4804 UINT32 SF
:1; ///< Sign Flag
4805 UINT32 TF
:1; ///< Trap Flag
4806 UINT32 IF
:1; ///< Interrupt Enable Flag
4807 UINT32 DF
:1; ///< Direction Flag
4808 UINT32 OF
:1; ///< Overflow Flag
4809 UINT32 IOPL
:2; ///< I/O Privilege Level
4810 UINT32 NT
:1; ///< Nested Task
4811 UINT32 Reserved_3
:1; ///< Reserved
4817 /// Byte packed structure for EFLAGS/RFLAGS
4818 /// 32-bits on IA-32
4819 /// 64-bits on x64. The upper 32-bits on x64 are reserved
4823 UINT32 CF
:1; ///< Carry Flag
4824 UINT32 Reserved_0
:1; ///< Reserved
4825 UINT32 PF
:1; ///< Parity Flag
4826 UINT32 Reserved_1
:1; ///< Reserved
4827 UINT32 AF
:1; ///< Auxiliary Carry Flag
4828 UINT32 Reserved_2
:1; ///< Reserved
4829 UINT32 ZF
:1; ///< Zero Flag
4830 UINT32 SF
:1; ///< Sign Flag
4831 UINT32 TF
:1; ///< Trap Flag
4832 UINT32 IF
:1; ///< Interrupt Enable Flag
4833 UINT32 DF
:1; ///< Direction Flag
4834 UINT32 OF
:1; ///< Overflow Flag
4835 UINT32 IOPL
:2; ///< I/O Privilege Level
4836 UINT32 NT
:1; ///< Nested Task
4837 UINT32 Reserved_3
:1; ///< Reserved
4838 UINT32 RF
:1; ///< Resume Flag
4839 UINT32 VM
:1; ///< Virtual 8086 Mode
4840 UINT32 AC
:1; ///< Alignment Check
4841 UINT32 VIF
:1; ///< Virtual Interrupt Flag
4842 UINT32 VIP
:1; ///< Virtual Interrupt Pending
4843 UINT32 ID
:1; ///< ID Flag
4844 UINT32 Reserved_4
:10; ///< Reserved
4850 /// Byte packed structure for Control Register 0 (CR0)
4851 /// 32-bits on IA-32
4852 /// 64-bits on x64. The upper 32-bits on x64 are reserved
4856 UINT32 PE
:1; ///< Protection Enable
4857 UINT32 MP
:1; ///< Monitor Coprocessor
4858 UINT32 EM
:1; ///< Emulation
4859 UINT32 TS
:1; ///< Task Switched
4860 UINT32 ET
:1; ///< Extension Type
4861 UINT32 NE
:1; ///< Numeric Error
4862 UINT32 Reserved_0
:10; ///< Reserved
4863 UINT32 WP
:1; ///< Write Protect
4864 UINT32 Reserved_1
:1; ///< Reserved
4865 UINT32 AM
:1; ///< Alignment Mask
4866 UINT32 Reserved_2
:10; ///< Reserved
4867 UINT32 NW
:1; ///< Mot Write-through
4868 UINT32 CD
:1; ///< Cache Disable
4869 UINT32 PG
:1; ///< Paging
4875 /// Byte packed structure for Control Register 4 (CR4)
4876 /// 32-bits on IA-32
4877 /// 64-bits on x64. The upper 32-bits on x64 are reserved
4881 UINT32 VME
:1; ///< Virtual-8086 Mode Extensions
4882 UINT32 PVI
:1; ///< Protected-Mode Virtual Interrupts
4883 UINT32 TSD
:1; ///< Time Stamp Disable
4884 UINT32 DE
:1; ///< Debugging Extensions
4885 UINT32 PSE
:1; ///< Page Size Extensions
4886 UINT32 PAE
:1; ///< Physical Address Extension
4887 UINT32 MCE
:1; ///< Machine Check Enable
4888 UINT32 PGE
:1; ///< Page Global Enable
4889 UINT32 PCE
:1; ///< Performance Monitoring Counter
4891 UINT32 OSFXSR
:1; ///< Operating System Support for
4892 ///< FXSAVE and FXRSTOR instructions
4893 UINT32 OSXMMEXCPT
:1; ///< Operating System Support for
4894 ///< Unmasked SIMD Floating Point
4896 UINT32 Reserved_0
:2; ///< Reserved
4897 UINT32 VMXE
:1; ///< VMX Enable
4898 UINT32 Reserved_1
:18; ///< Reserved
4904 /// Byte packed structure for an IDTR, GDTR, LDTR descriptor
4913 #define IA32_IDT_GATE_TYPE_TASK 0x85
4914 #define IA32_IDT_GATE_TYPE_INTERRUPT_16 0x86
4915 #define IA32_IDT_GATE_TYPE_TRAP_16 0x87
4916 #define IA32_IDT_GATE_TYPE_INTERRUPT_32 0x8E
4917 #define IA32_IDT_GATE_TYPE_TRAP_32 0x8F
4920 #if defined (MDE_CPU_IA32)
4922 /// Byte packed structure for an IA-32 Interrupt Gate Descriptor
4926 UINT32 OffsetLow
:16; ///< Offset bits 15..0
4927 UINT32 Selector
:16; ///< Selector
4928 UINT32 Reserved_0
:8; ///< Reserved
4929 UINT32 GateType
:8; ///< Gate Type. See #defines above
4930 UINT32 OffsetHigh
:16; ///< Offset bits 31..16
4933 } IA32_IDT_GATE_DESCRIPTOR
;
4937 #if defined (MDE_CPU_X64)
4939 /// Byte packed structure for an x64 Interrupt Gate Descriptor
4943 UINT32 OffsetLow
:16; ///< Offset bits 15..0
4944 UINT32 Selector
:16; ///< Selector
4945 UINT32 Reserved_0
:8; ///< Reserved
4946 UINT32 GateType
:8; ///< Gate Type. See #defines above
4947 UINT32 OffsetHigh
:16; ///< Offset bits 31..16
4948 UINT32 OffsetUpper
:32; ///< Offset bits 63..32
4949 UINT32 Reserved_1
:32; ///< Reserved
4955 } IA32_IDT_GATE_DESCRIPTOR
;
4960 /// Byte packed structure for an FP/SSE/SSE2 context
4967 /// Structures for the 16-bit real mode thunks
5020 IA32_EFLAGS32 EFLAGS
;
5030 } IA32_REGISTER_SET
;
5033 /// Byte packed structure for an 16-bit real mode thunks
5036 IA32_REGISTER_SET
*RealModeState
;
5037 VOID
*RealModeBuffer
;
5038 UINT32 RealModeBufferSize
;
5039 UINT32 ThunkAttributes
;
5042 #define THUNK_ATTRIBUTE_BIG_REAL_MODE 0x00000001
5043 #define THUNK_ATTRIBUTE_DISABLE_A20_MASK_INT_15 0x00000002
5044 #define THUNK_ATTRIBUTE_DISABLE_A20_MASK_KBD_CTRL 0x00000004
5047 Retrieves CPUID information.
5049 Executes the CPUID instruction with EAX set to the value specified by Index.
5050 This function always returns Index.
5051 If Eax is not NULL, then the value of EAX after CPUID is returned in Eax.
5052 If Ebx is not NULL, then the value of EBX after CPUID is returned in Ebx.
5053 If Ecx is not NULL, then the value of ECX after CPUID is returned in Ecx.
5054 If Edx is not NULL, then the value of EDX after CPUID is returned in Edx.
5055 This function is only available on IA-32 and x64.
5057 @param Index The 32-bit value to load into EAX prior to invoking the CPUID
5059 @param Eax Pointer to the 32-bit EAX value returned by the CPUID
5060 instruction. This is an optional parameter that may be NULL.
5061 @param Ebx Pointer to the 32-bit EBX value returned by the CPUID
5062 instruction. This is an optional parameter that may be NULL.
5063 @param Ecx Pointer to the 32-bit ECX value returned by the CPUID
5064 instruction. This is an optional parameter that may be NULL.
5065 @param Edx Pointer to the 32-bit EDX value returned by the CPUID
5066 instruction. This is an optional parameter that may be NULL.
5075 OUT UINT32
*Eax
, OPTIONAL
5076 OUT UINT32
*Ebx
, OPTIONAL
5077 OUT UINT32
*Ecx
, OPTIONAL
5078 OUT UINT32
*Edx OPTIONAL
5083 Retrieves CPUID information using an extended leaf identifier.
5085 Executes the CPUID instruction with EAX set to the value specified by Index
5086 and ECX set to the value specified by SubIndex. This function always returns
5087 Index. This function is only available on IA-32 and x64.
5089 If Eax is not NULL, then the value of EAX after CPUID is returned in Eax.
5090 If Ebx is not NULL, then the value of EBX after CPUID is returned in Ebx.
5091 If Ecx is not NULL, then the value of ECX after CPUID is returned in Ecx.
5092 If Edx is not NULL, then the value of EDX after CPUID is returned in Edx.
5094 @param Index The 32-bit value to load into EAX prior to invoking the
5096 @param SubIndex The 32-bit value to load into ECX prior to invoking the
5098 @param Eax Pointer to the 32-bit EAX value returned by the CPUID
5099 instruction. This is an optional parameter that may be
5101 @param Ebx Pointer to the 32-bit EBX value returned by the CPUID
5102 instruction. This is an optional parameter that may be
5104 @param Ecx Pointer to the 32-bit ECX value returned by the CPUID
5105 instruction. This is an optional parameter that may be
5107 @param Edx Pointer to the 32-bit EDX value returned by the CPUID
5108 instruction. This is an optional parameter that may be
5119 OUT UINT32
*Eax
, OPTIONAL
5120 OUT UINT32
*Ebx
, OPTIONAL
5121 OUT UINT32
*Ecx
, OPTIONAL
5122 OUT UINT32
*Edx OPTIONAL
5127 Set CD bit and clear NW bit of CR0 followed by a WBINVD.
5129 Disables the caches by setting the CD bit of CR0 to 1, clearing the NW bit of CR0 to 0,
5130 and executing a WBINVD instruction. This function is only available on IA-32 and x64.
5141 Perform a WBINVD and clear both the CD and NW bits of CR0.
5143 Enables the caches by executing a WBINVD instruction and then clear both the CD and NW
5144 bits of CR0 to 0. This function is only available on IA-32 and x64.
5155 Returns the lower 32-bits of a Machine Specific Register(MSR).
5157 Reads and returns the lower 32-bits of the MSR specified by Index.
5158 No parameter checking is performed on Index, and some Index values may cause
5159 CPU exceptions. The caller must either guarantee that Index is valid, or the
5160 caller must set up exception handlers to catch the exceptions. This function
5161 is only available on IA-32 and x64.
5163 @param Index The 32-bit MSR index to read.
5165 @return The lower 32 bits of the MSR identified by Index.
5176 Writes a 32-bit value to a Machine Specific Register(MSR), and returns the value.
5177 The upper 32-bits of the MSR are set to zero.
5179 Writes the 32-bit value specified by Value to the MSR specified by Index. The
5180 upper 32-bits of the MSR write are set to zero. The 32-bit value written to
5181 the MSR is returned. No parameter checking is performed on Index or Value,
5182 and some of these may cause CPU exceptions. The caller must either guarantee
5183 that Index and Value are valid, or the caller must establish proper exception
5184 handlers. This function is only available on IA-32 and x64.
5186 @param Index The 32-bit MSR index to write.
5187 @param Value The 32-bit value to write to the MSR.
5201 Reads a 64-bit MSR, performs a bitwise OR on the lower 32-bits, and
5202 writes the result back to the 64-bit MSR.
5204 Reads the 64-bit MSR specified by Index, performs a bitwise OR
5205 between the lower 32-bits of the read result and the value specified by
5206 OrData, and writes the result to the 64-bit MSR specified by Index. The lower
5207 32-bits of the value written to the MSR is returned. No parameter checking is
5208 performed on Index or OrData, and some of these may cause CPU exceptions. The
5209 caller must either guarantee that Index and OrData are valid, or the caller
5210 must establish proper exception handlers. This function is only available on
5213 @param Index The 32-bit MSR index to write.
5214 @param OrData The value to OR with the read value from the MSR.
5216 @return The lower 32-bit value written to the MSR.
5228 Reads a 64-bit MSR, performs a bitwise AND on the lower 32-bits, and writes
5229 the result back to the 64-bit MSR.
5231 Reads the 64-bit MSR specified by Index, performs a bitwise AND between the
5232 lower 32-bits of the read result and the value specified by AndData, and
5233 writes the result to the 64-bit MSR specified by Index. The lower 32-bits of
5234 the value written to the MSR is returned. No parameter checking is performed
5235 on Index or AndData, and some of these may cause CPU exceptions. The caller
5236 must either guarantee that Index and AndData are valid, or the caller must
5237 establish proper exception handlers. This function is only available on IA-32
5240 @param Index The 32-bit MSR index to write.
5241 @param AndData The value to AND with the read value from the MSR.
5243 @return The lower 32-bit value written to the MSR.
5255 Reads a 64-bit MSR, performs a bitwise AND followed by a bitwise OR
5256 on the lower 32-bits, and writes the result back to the 64-bit MSR.
5258 Reads the 64-bit MSR specified by Index, performs a bitwise AND between the
5259 lower 32-bits of the read result and the value specified by AndData
5260 preserving the upper 32-bits, performs a bitwise OR between the
5261 result of the AND operation and the value specified by OrData, and writes the
5262 result to the 64-bit MSR specified by Address. The lower 32-bits of the value
5263 written to the MSR is returned. No parameter checking is performed on Index,
5264 AndData, or OrData, and some of these may cause CPU exceptions. The caller
5265 must either guarantee that Index, AndData, and OrData are valid, or the
5266 caller must establish proper exception handlers. This function is only
5267 available on IA-32 and x64.
5269 @param Index The 32-bit MSR index to write.
5270 @param AndData The value to AND with the read value from the MSR.
5271 @param OrData The value to OR with the result of the AND operation.
5273 @return The lower 32-bit value written to the MSR.
5286 Reads a bit field of an MSR.
5288 Reads the bit field in the lower 32-bits of a 64-bit MSR. The bit field is
5289 specified by the StartBit and the EndBit. The value of the bit field is
5290 returned. The caller must either guarantee that Index is valid, or the caller
5291 must set up exception handlers to catch the exceptions. This function is only
5292 available on IA-32 and x64.
5294 If StartBit is greater than 31, then ASSERT().
5295 If EndBit is greater than 31, then ASSERT().
5296 If EndBit is less than StartBit, then ASSERT().
5298 @param Index The 32-bit MSR index to read.
5299 @param StartBit The ordinal of the least significant bit in the bit field.
5301 @param EndBit The ordinal of the most significant bit in the bit field.
5304 @return The bit field read from the MSR.
5309 AsmMsrBitFieldRead32 (
5317 Writes a bit field to an MSR.
5319 Writes Value to a bit field in the lower 32-bits of a 64-bit MSR. The bit
5320 field is specified by the StartBit and the EndBit. All other bits in the
5321 destination MSR are preserved. The lower 32-bits of the MSR written is
5322 returned. The caller must either guarantee that Index and the data written
5323 is valid, or the caller must set up exception handlers to catch the exceptions.
5324 This function is only available on IA-32 and x64.
5326 If StartBit is greater than 31, then ASSERT().
5327 If EndBit is greater than 31, then ASSERT().
5328 If EndBit is less than StartBit, then ASSERT().
5330 @param Index The 32-bit MSR index to write.
5331 @param StartBit The ordinal of the least significant bit in the bit field.
5333 @param EndBit The ordinal of the most significant bit in the bit field.
5335 @param Value New value of the bit field.
5337 @return The lower 32-bit of the value written to the MSR.
5342 AsmMsrBitFieldWrite32 (
5351 Reads a bit field in a 64-bit MSR, performs a bitwise OR, and writes the
5352 result back to the bit field in the 64-bit MSR.
5354 Reads the 64-bit MSR specified by Index, performs a bitwise OR
5355 between the read result and the value specified by OrData, and writes the
5356 result to the 64-bit MSR specified by Index. The lower 32-bits of the value
5357 written to the MSR are returned. Extra left bits in OrData are stripped. The
5358 caller must either guarantee that Index and the data written is valid, or
5359 the caller must set up exception handlers to catch the exceptions. This
5360 function is only available on IA-32 and x64.
5362 If StartBit is greater than 31, then ASSERT().
5363 If EndBit is greater than 31, then ASSERT().
5364 If EndBit is less than StartBit, then ASSERT().
5366 @param Index The 32-bit MSR index to write.
5367 @param StartBit The ordinal of the least significant bit in the bit field.
5369 @param EndBit The ordinal of the most significant bit in the bit field.
5371 @param OrData The value to OR with the read value from the MSR.
5373 @return The lower 32-bit of the value written to the MSR.
5378 AsmMsrBitFieldOr32 (
5387 Reads a bit field in a 64-bit MSR, performs a bitwise AND, and writes the
5388 result back to the bit field in the 64-bit MSR.
5390 Reads the 64-bit MSR specified by Index, performs a bitwise AND between the
5391 read result and the value specified by AndData, and writes the result to the
5392 64-bit MSR specified by Index. The lower 32-bits of the value written to the
5393 MSR are returned. Extra left bits in AndData are stripped. The caller must
5394 either guarantee that Index and the data written is valid, or the caller must
5395 set up exception handlers to catch the exceptions. This function is only
5396 available on IA-32 and x64.
5398 If StartBit is greater than 31, then ASSERT().
5399 If EndBit is greater than 31, then ASSERT().
5400 If EndBit is less than StartBit, then ASSERT().
5402 @param Index The 32-bit MSR index to write.
5403 @param StartBit The ordinal of the least significant bit in the bit field.
5405 @param EndBit The ordinal of the most significant bit in the bit field.
5407 @param AndData The value to AND with the read value from the MSR.
5409 @return The lower 32-bit of the value written to the MSR.
5414 AsmMsrBitFieldAnd32 (
5423 Reads a bit field in a 64-bit MSR, performs a bitwise AND followed by a
5424 bitwise OR, and writes the result back to the bit field in the
5427 Reads the 64-bit MSR specified by Index, performs a bitwise AND followed by a
5428 bitwise OR between the read result and the value specified by
5429 AndData, and writes the result to the 64-bit MSR specified by Index. The
5430 lower 32-bits of the value written to the MSR are returned. Extra left bits
5431 in both AndData and OrData are stripped. The caller must either guarantee
5432 that Index and the data written is valid, or the caller must set up exception
5433 handlers to catch the exceptions. This function is only available on IA-32
5436 If StartBit is greater than 31, then ASSERT().
5437 If EndBit is greater than 31, then ASSERT().
5438 If EndBit is less than StartBit, then ASSERT().
5440 @param Index The 32-bit MSR index to write.
5441 @param StartBit The ordinal of the least significant bit in the bit field.
5443 @param EndBit The ordinal of the most significant bit in the bit field.
5445 @param AndData The value to AND with the read value from the MSR.
5446 @param OrData The value to OR with the result of the AND operation.
5448 @return The lower 32-bit of the value written to the MSR.
5453 AsmMsrBitFieldAndThenOr32 (
5463 Returns a 64-bit Machine Specific Register(MSR).
5465 Reads and returns the 64-bit MSR specified by Index. No parameter checking is
5466 performed on Index, and some Index values may cause CPU exceptions. The
5467 caller must either guarantee that Index is valid, or the caller must set up
5468 exception handlers to catch the exceptions. This function is only available
5471 @param Index The 32-bit MSR index to read.
5473 @return The value of the MSR identified by Index.
5484 Writes a 64-bit value to a Machine Specific Register(MSR), and returns the
5487 Writes the 64-bit value specified by Value to the MSR specified by Index. The
5488 64-bit value written to the MSR is returned. No parameter checking is
5489 performed on Index or Value, and some of these may cause CPU exceptions. The
5490 caller must either guarantee that Index and Value are valid, or the caller
5491 must establish proper exception handlers. This function is only available on
5494 @param Index The 32-bit MSR index to write.
5495 @param Value The 64-bit value to write to the MSR.
5509 Reads a 64-bit MSR, performs a bitwise OR, and writes the result
5510 back to the 64-bit MSR.
5512 Reads the 64-bit MSR specified by Index, performs a bitwise OR
5513 between the read result and the value specified by OrData, and writes the
5514 result to the 64-bit MSR specified by Index. The value written to the MSR is
5515 returned. No parameter checking is performed on Index or OrData, and some of
5516 these may cause CPU exceptions. The caller must either guarantee that Index
5517 and OrData are valid, or the caller must establish proper exception handlers.
5518 This function is only available on IA-32 and x64.
5520 @param Index The 32-bit MSR index to write.
5521 @param OrData The value to OR with the read value from the MSR.
5523 @return The value written back to the MSR.
5535 Reads a 64-bit MSR, performs a bitwise AND, and writes the result back to the
5538 Reads the 64-bit MSR specified by Index, performs a bitwise AND between the
5539 read result and the value specified by OrData, and writes the result to the
5540 64-bit MSR specified by Index. The value written to the MSR is returned. No
5541 parameter checking is performed on Index or OrData, and some of these may
5542 cause CPU exceptions. The caller must either guarantee that Index and OrData
5543 are valid, or the caller must establish proper exception handlers. This
5544 function is only available on IA-32 and x64.
5546 @param Index The 32-bit MSR index to write.
5547 @param AndData The value to AND with the read value from the MSR.
5549 @return The value written back to the MSR.
5561 Reads a 64-bit MSR, performs a bitwise AND followed by a bitwise
5562 OR, and writes the result back to the 64-bit MSR.
5564 Reads the 64-bit MSR specified by Index, performs a bitwise AND between read
5565 result and the value specified by AndData, performs a bitwise OR
5566 between the result of the AND operation and the value specified by OrData,
5567 and writes the result to the 64-bit MSR specified by Index. The value written
5568 to the MSR is returned. No parameter checking is performed on Index, AndData,
5569 or OrData, and some of these may cause CPU exceptions. The caller must either
5570 guarantee that Index, AndData, and OrData are valid, or the caller must
5571 establish proper exception handlers. This function is only available on IA-32
5574 @param Index The 32-bit MSR index to write.
5575 @param AndData The value to AND with the read value from the MSR.
5576 @param OrData The value to OR with the result of the AND operation.
5578 @return The value written back to the MSR.
5591 Reads a bit field of an MSR.
5593 Reads the bit field in the 64-bit MSR. The bit field is specified by the
5594 StartBit and the EndBit. The value of the bit field is returned. The caller
5595 must either guarantee that Index is valid, or the caller must set up
5596 exception handlers to catch the exceptions. This function is only available
5599 If StartBit is greater than 63, then ASSERT().
5600 If EndBit is greater than 63, then ASSERT().
5601 If EndBit is less than StartBit, then ASSERT().
5603 @param Index The 32-bit MSR index to read.
5604 @param StartBit The ordinal of the least significant bit in the bit field.
5606 @param EndBit The ordinal of the most significant bit in the bit field.
5609 @return The value read from the MSR.
5614 AsmMsrBitFieldRead64 (
5622 Writes a bit field to an MSR.
5624 Writes Value to a bit field in a 64-bit MSR. The bit field is specified by
5625 the StartBit and the EndBit. All other bits in the destination MSR are
5626 preserved. The MSR written is returned. The caller must either guarantee
5627 that Index and the data written is valid, or the caller must set up exception
5628 handlers to catch the exceptions. This function is only available on IA-32 and x64.
5630 If StartBit is greater than 63, then ASSERT().
5631 If EndBit is greater than 63, then ASSERT().
5632 If EndBit is less than StartBit, then ASSERT().
5634 @param Index The 32-bit MSR index to write.
5635 @param StartBit The ordinal of the least significant bit in the bit field.
5637 @param EndBit The ordinal of the most significant bit in the bit field.
5639 @param Value New value of the bit field.
5641 @return The value written back to the MSR.
5646 AsmMsrBitFieldWrite64 (
5655 Reads a bit field in a 64-bit MSR, performs a bitwise OR, and
5656 writes the result back to the bit field in the 64-bit MSR.
5658 Reads the 64-bit MSR specified by Index, performs a bitwise OR
5659 between the read result and the value specified by OrData, and writes the
5660 result to the 64-bit MSR specified by Index. The value written to the MSR is
5661 returned. Extra left bits in OrData are stripped. The caller must either
5662 guarantee that Index and the data written is valid, or the caller must set up
5663 exception handlers to catch the exceptions. This function is only available
5666 If StartBit is greater than 63, then ASSERT().
5667 If EndBit is greater than 63, then ASSERT().
5668 If EndBit is less than StartBit, then ASSERT().
5670 @param Index The 32-bit MSR index to write.
5671 @param StartBit The ordinal of the least significant bit in the bit field.
5673 @param EndBit The ordinal of the most significant bit in the bit field.
5675 @param OrData The value to OR with the read value from the bit field.
5677 @return The value written back to the MSR.
5682 AsmMsrBitFieldOr64 (
5691 Reads a bit field in a 64-bit MSR, performs a bitwise AND, and writes the
5692 result back to the bit field in the 64-bit MSR.
5694 Reads the 64-bit MSR specified by Index, performs a bitwise AND between the
5695 read result and the value specified by AndData, and writes the result to the
5696 64-bit MSR specified by Index. The value written to the MSR is returned.
5697 Extra left bits in AndData are stripped. The caller must either guarantee
5698 that Index and the data written is valid, or the caller must set up exception
5699 handlers to catch the exceptions. This function is only available on IA-32
5702 If StartBit is greater than 63, then ASSERT().
5703 If EndBit is greater than 63, then ASSERT().
5704 If EndBit is less than StartBit, then ASSERT().
5706 @param Index The 32-bit MSR index to write.
5707 @param StartBit The ordinal of the least significant bit in the bit field.
5709 @param EndBit The ordinal of the most significant bit in the bit field.
5711 @param AndData The value to AND with the read value from the bit field.
5713 @return The value written back to the MSR.
5718 AsmMsrBitFieldAnd64 (
5727 Reads a bit field in a 64-bit MSR, performs a bitwise AND followed by a
5728 bitwise OR, and writes the result back to the bit field in the
5731 Reads the 64-bit MSR specified by Index, performs a bitwise AND followed by
5732 a bitwise OR between the read result and the value specified by
5733 AndData, and writes the result to the 64-bit MSR specified by Index. The
5734 value written to the MSR is returned. Extra left bits in both AndData and
5735 OrData are stripped. The caller must either guarantee that Index and the data
5736 written is valid, or the caller must set up exception handlers to catch the
5737 exceptions. This function is only available on IA-32 and x64.
5739 If StartBit is greater than 63, then ASSERT().
5740 If EndBit is greater than 63, then ASSERT().
5741 If EndBit is less than StartBit, then ASSERT().
5743 @param Index The 32-bit MSR index to write.
5744 @param StartBit The ordinal of the least significant bit in the bit field.
5746 @param EndBit The ordinal of the most significant bit in the bit field.
5748 @param AndData The value to AND with the read value from the bit field.
5749 @param OrData The value to OR with the result of the AND operation.
5751 @return The value written back to the MSR.
5756 AsmMsrBitFieldAndThenOr64 (
5766 Reads the current value of the EFLAGS register.
5768 Reads and returns the current value of the EFLAGS register. This function is
5769 only available on IA-32 and x64. This returns a 32-bit value on IA-32 and a
5770 64-bit value on x64.
5772 @return EFLAGS on IA-32 or RFLAGS on x64.
5783 Reads the current value of the Control Register 0 (CR0).
5785 Reads and returns the current value of CR0. This function is only available
5786 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
5789 @return The value of the Control Register 0 (CR0).
5800 Reads the current value of the Control Register 2 (CR2).
5802 Reads and returns the current value of CR2. This function is only available
5803 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
5806 @return The value of the Control Register 2 (CR2).
5817 Reads the current value of the Control Register 3 (CR3).
5819 Reads and returns the current value of CR3. This function is only available
5820 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
5823 @return The value of the Control Register 3 (CR3).
5834 Reads the current value of the Control Register 4 (CR4).
5836 Reads and returns the current value of CR4. This function is only available
5837 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
5840 @return The value of the Control Register 4 (CR4).
5851 Writes a value to Control Register 0 (CR0).
5853 Writes and returns a new value to CR0. This function is only available on
5854 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
5856 @param Cr0 The value to write to CR0.
5858 @return The value written to CR0.
5869 Writes a value to Control Register 2 (CR2).
5871 Writes and returns a new value to CR2. This function is only available on
5872 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
5874 @param Cr2 The value to write to CR2.
5876 @return The value written to CR2.
5887 Writes a value to Control Register 3 (CR3).
5889 Writes and returns a new value to CR3. This function is only available on
5890 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
5892 @param Cr3 The value to write to CR3.
5894 @return The value written to CR3.
5905 Writes a value to Control Register 4 (CR4).
5907 Writes and returns a new value to CR4. This function is only available on
5908 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
5910 @param Cr4 The value to write to CR4.
5912 @return The value written to CR4.
5923 Reads the current value of Debug Register 0 (DR0).
5925 Reads and returns the current value of DR0. This function is only available
5926 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
5929 @return The value of Debug Register 0 (DR0).
5940 Reads the current value of Debug Register 1 (DR1).
5942 Reads and returns the current value of DR1. This function is only available
5943 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
5946 @return The value of Debug Register 1 (DR1).
5957 Reads the current value of Debug Register 2 (DR2).
5959 Reads and returns the current value of DR2. This function is only available
5960 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
5963 @return The value of Debug Register 2 (DR2).
5974 Reads the current value of Debug Register 3 (DR3).
5976 Reads and returns the current value of DR3. This function is only available
5977 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
5980 @return The value of Debug Register 3 (DR3).
5991 Reads the current value of Debug Register 4 (DR4).
5993 Reads and returns the current value of DR4. This function is only available
5994 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
5997 @return The value of Debug Register 4 (DR4).
6008 Reads the current value of Debug Register 5 (DR5).
6010 Reads and returns the current value of DR5. This function is only available
6011 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
6014 @return The value of Debug Register 5 (DR5).
6025 Reads the current value of Debug Register 6 (DR6).
6027 Reads and returns the current value of DR6. This function is only available
6028 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
6031 @return The value of Debug Register 6 (DR6).
6042 Reads the current value of Debug Register 7 (DR7).
6044 Reads and returns the current value of DR7. This function is only available
6045 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
6048 @return The value of Debug Register 7 (DR7).
6059 Writes a value to Debug Register 0 (DR0).
6061 Writes and returns a new value to DR0. This function is only available on
6062 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
6064 @param Dr0 The value to write to Dr0.
6066 @return The value written to Debug Register 0 (DR0).
6077 Writes a value to Debug Register 1 (DR1).
6079 Writes and returns a new value to DR1. This function is only available on
6080 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
6082 @param Dr1 The value to write to Dr1.
6084 @return The value written to Debug Register 1 (DR1).
6095 Writes a value to Debug Register 2 (DR2).
6097 Writes and returns a new value to DR2. This function is only available on
6098 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
6100 @param Dr2 The value to write to Dr2.
6102 @return The value written to Debug Register 2 (DR2).
6113 Writes a value to Debug Register 3 (DR3).
6115 Writes and returns a new value to DR3. This function is only available on
6116 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
6118 @param Dr3 The value to write to Dr3.
6120 @return The value written to Debug Register 3 (DR3).
6131 Writes a value to Debug Register 4 (DR4).
6133 Writes and returns a new value to DR4. This function is only available on
6134 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
6136 @param Dr4 The value to write to Dr4.
6138 @return The value written to Debug Register 4 (DR4).
6149 Writes a value to Debug Register 5 (DR5).
6151 Writes and returns a new value to DR5. This function is only available on
6152 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
6154 @param Dr5 The value to write to Dr5.
6156 @return The value written to Debug Register 5 (DR5).
6167 Writes a value to Debug Register 6 (DR6).
6169 Writes and returns a new value to DR6. This function is only available on
6170 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
6172 @param Dr6 The value to write to Dr6.
6174 @return The value written to Debug Register 6 (DR6).
6185 Writes a value to Debug Register 7 (DR7).
6187 Writes and returns a new value to DR7. This function is only available on
6188 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
6190 @param Dr7 The value to write to Dr7.
6192 @return The value written to Debug Register 7 (DR7).
6203 Reads the current value of Code Segment Register (CS).
6205 Reads and returns the current value of CS. This function is only available on
6208 @return The current value of CS.
6219 Reads the current value of Data Segment Register (DS).
6221 Reads and returns the current value of DS. This function is only available on
6224 @return The current value of DS.
6235 Reads the current value of Extra Segment Register (ES).
6237 Reads and returns the current value of ES. This function is only available on
6240 @return The current value of ES.
6251 Reads the current value of FS Data Segment Register (FS).
6253 Reads and returns the current value of FS. This function is only available on
6256 @return The current value of FS.
6267 Reads the current value of GS Data Segment Register (GS).
6269 Reads and returns the current value of GS. This function is only available on
6272 @return The current value of GS.
6283 Reads the current value of Stack Segment Register (SS).
6285 Reads and returns the current value of SS. This function is only available on
6288 @return The current value of SS.
6299 Reads the current value of Task Register (TR).
6301 Reads and returns the current value of TR. This function is only available on
6304 @return The current value of TR.
6315 Reads the current Global Descriptor Table Register(GDTR) descriptor.
6317 Reads and returns the current GDTR descriptor and returns it in Gdtr. This
6318 function is only available on IA-32 and x64.
6320 If Gdtr is NULL, then ASSERT().
6322 @param Gdtr Pointer to a GDTR descriptor.
6328 OUT IA32_DESCRIPTOR
*Gdtr
6333 Writes the current Global Descriptor Table Register (GDTR) descriptor.
6335 Writes and the current GDTR descriptor specified by Gdtr. This function is
6336 only available on IA-32 and x64.
6338 If Gdtr is NULL, then ASSERT().
6340 @param Gdtr Pointer to a GDTR descriptor.
6346 IN CONST IA32_DESCRIPTOR
*Gdtr
6351 Reads the current Interrupt Descriptor Table Register(IDTR) descriptor.
6353 Reads and returns the current IDTR descriptor and returns it in Idtr. This
6354 function is only available on IA-32 and x64.
6356 If Idtr is NULL, then ASSERT().
6358 @param Idtr Pointer to a IDTR descriptor.
6364 OUT IA32_DESCRIPTOR
*Idtr
6369 Writes the current Interrupt Descriptor Table Register(IDTR) descriptor.
6371 Writes the current IDTR descriptor and returns it in Idtr. This function is
6372 only available on IA-32 and x64.
6374 If Idtr is NULL, then ASSERT().
6376 @param Idtr Pointer to a IDTR descriptor.
6382 IN CONST IA32_DESCRIPTOR
*Idtr
6387 Reads the current Local Descriptor Table Register(LDTR) selector.
6389 Reads and returns the current 16-bit LDTR descriptor value. This function is
6390 only available on IA-32 and x64.
6392 @return The current selector of LDT.
6403 Writes the current Local Descriptor Table Register (LDTR) selector.
6405 Writes and the current LDTR descriptor specified by Ldtr. This function is
6406 only available on IA-32 and x64.
6408 @param Ldtr 16-bit LDTR selector value.
6419 Save the current floating point/SSE/SSE2 context to a buffer.
6421 Saves the current floating point/SSE/SSE2 state to the buffer specified by
6422 Buffer. Buffer must be aligned on a 16-byte boundary. This function is only
6423 available on IA-32 and x64.
6425 If Buffer is NULL, then ASSERT().
6426 If Buffer is not aligned on a 16-byte boundary, then ASSERT().
6428 @param Buffer Pointer to a buffer to save the floating point/SSE/SSE2 context.
6434 OUT IA32_FX_BUFFER
*Buffer
6439 Restores the current floating point/SSE/SSE2 context from a buffer.
6441 Restores the current floating point/SSE/SSE2 state from the buffer specified
6442 by Buffer. Buffer must be aligned on a 16-byte boundary. This function is
6443 only available on IA-32 and x64.
6445 If Buffer is NULL, then ASSERT().
6446 If Buffer is not aligned on a 16-byte boundary, then ASSERT().
6447 If Buffer was not saved with AsmFxSave(), then ASSERT().
6449 @param Buffer Pointer to a buffer to save the floating point/SSE/SSE2 context.
6455 IN CONST IA32_FX_BUFFER
*Buffer
6460 Reads the current value of 64-bit MMX Register #0 (MM0).
6462 Reads and returns the current value of MM0. This function is only available
6465 @return The current value of MM0.
6476 Reads the current value of 64-bit MMX Register #1 (MM1).
6478 Reads and returns the current value of MM1. This function is only available
6481 @return The current value of MM1.
6492 Reads the current value of 64-bit MMX Register #2 (MM2).
6494 Reads and returns the current value of MM2. This function is only available
6497 @return The current value of MM2.
6508 Reads the current value of 64-bit MMX Register #3 (MM3).
6510 Reads and returns the current value of MM3. This function is only available
6513 @return The current value of MM3.
6524 Reads the current value of 64-bit MMX Register #4 (MM4).
6526 Reads and returns the current value of MM4. This function is only available
6529 @return The current value of MM4.
6540 Reads the current value of 64-bit MMX Register #5 (MM5).
6542 Reads and returns the current value of MM5. This function is only available
6545 @return The current value of MM5.
6556 Reads the current value of 64-bit MMX Register #6 (MM6).
6558 Reads and returns the current value of MM6. This function is only available
6561 @return The current value of MM6.
6572 Reads the current value of 64-bit MMX Register #7 (MM7).
6574 Reads and returns the current value of MM7. This function is only available
6577 @return The current value of MM7.
6588 Writes the current value of 64-bit MMX Register #0 (MM0).
6590 Writes the current value of MM0. This function is only available on IA32 and
6593 @param Value The 64-bit value to write to MM0.
6604 Writes the current value of 64-bit MMX Register #1 (MM1).
6606 Writes the current value of MM1. This function is only available on IA32 and
6609 @param Value The 64-bit value to write to MM1.
6620 Writes the current value of 64-bit MMX Register #2 (MM2).
6622 Writes the current value of MM2. This function is only available on IA32 and
6625 @param Value The 64-bit value to write to MM2.
6636 Writes the current value of 64-bit MMX Register #3 (MM3).
6638 Writes the current value of MM3. This function is only available on IA32 and
6641 @param Value The 64-bit value to write to MM3.
6652 Writes the current value of 64-bit MMX Register #4 (MM4).
6654 Writes the current value of MM4. This function is only available on IA32 and
6657 @param Value The 64-bit value to write to MM4.
6668 Writes the current value of 64-bit MMX Register #5 (MM5).
6670 Writes the current value of MM5. This function is only available on IA32 and
6673 @param Value The 64-bit value to write to MM5.
6684 Writes the current value of 64-bit MMX Register #6 (MM6).
6686 Writes the current value of MM6. This function is only available on IA32 and
6689 @param Value The 64-bit value to write to MM6.
6700 Writes the current value of 64-bit MMX Register #7 (MM7).
6702 Writes the current value of MM7. This function is only available on IA32 and
6705 @param Value The 64-bit value to write to MM7.
6716 Reads the current value of Time Stamp Counter (TSC).
6718 Reads and returns the current value of TSC. This function is only available
6721 @return The current value of TSC
6732 Reads the current value of a Performance Counter (PMC).
6734 Reads and returns the current value of performance counter specified by
6735 Index. This function is only available on IA-32 and x64.
6737 @param Index The 32-bit Performance Counter index to read.
6739 @return The value of the PMC specified by Index.
6750 Sets up a monitor buffer that is used by AsmMwait().
6752 Executes a MONITOR instruction with the register state specified by Eax, Ecx
6753 and Edx. Returns Eax. This function is only available on IA-32 and x64.
6755 @param Eax The value to load into EAX or RAX before executing the MONITOR
6757 @param Ecx The value to load into ECX or RCX before executing the MONITOR
6759 @param Edx The value to load into EDX or RDX before executing the MONITOR
6775 Executes an MWAIT instruction.
6777 Executes an MWAIT instruction with the register state specified by Eax and
6778 Ecx. Returns Eax. This function is only available on IA-32 and x64.
6780 @param Eax The value to load into EAX or RAX before executing the MONITOR
6782 @param Ecx The value to load into ECX or RCX before executing the MONITOR
6797 Executes a WBINVD instruction.
6799 Executes a WBINVD instruction. This function is only available on IA-32 and
6811 Executes a INVD instruction.
6813 Executes a INVD instruction. This function is only available on IA-32 and
6825 Flushes a cache line from all the instruction and data caches within the
6826 coherency domain of the CPU.
6828 Flushed the cache line specified by LinearAddress, and returns LinearAddress.
6829 This function is only available on IA-32 and x64.
6831 @param LinearAddress The address of the cache line to flush. If the CPU is
6832 in a physical addressing mode, then LinearAddress is a
6833 physical address. If the CPU is in a virtual
6834 addressing mode, then LinearAddress is a virtual
6837 @return LinearAddress
6842 IN VOID
*LinearAddress
6847 Enables the 32-bit paging mode on the CPU.
6849 Enables the 32-bit paging mode on the CPU. CR0, CR3, CR4, and the page tables
6850 must be properly initialized prior to calling this service. This function
6851 assumes the current execution mode is 32-bit protected mode. This function is
6852 only available on IA-32. After the 32-bit paging mode is enabled, control is
6853 transferred to the function specified by EntryPoint using the new stack
6854 specified by NewStack and passing in the parameters specified by Context1 and
6855 Context2. Context1 and Context2 are optional and may be NULL. The function
6856 EntryPoint must never return.
6858 If the current execution mode is not 32-bit protected mode, then ASSERT().
6859 If EntryPoint is NULL, then ASSERT().
6860 If NewStack is NULL, then ASSERT().
6862 There are a number of constraints that must be followed before calling this
6864 1) Interrupts must be disabled.
6865 2) The caller must be in 32-bit protected mode with flat descriptors. This
6866 means all descriptors must have a base of 0 and a limit of 4GB.
6867 3) CR0 and CR4 must be compatible with 32-bit protected mode with flat
6869 4) CR3 must point to valid page tables that will be used once the transition
6870 is complete, and those page tables must guarantee that the pages for this
6871 function and the stack are identity mapped.
6873 @param EntryPoint A pointer to function to call with the new stack after
6875 @param Context1 A pointer to the context to pass into the EntryPoint
6876 function as the first parameter after paging is enabled.
6877 @param Context2 A pointer to the context to pass into the EntryPoint
6878 function as the second parameter after paging is enabled.
6879 @param NewStack A pointer to the new stack to use for the EntryPoint
6880 function after paging is enabled.
6886 IN SWITCH_STACK_ENTRY_POINT EntryPoint
,
6887 IN VOID
*Context1
, OPTIONAL
6888 IN VOID
*Context2
, OPTIONAL
6894 Disables the 32-bit paging mode on the CPU.
6896 Disables the 32-bit paging mode on the CPU and returns to 32-bit protected
6897 mode. This function assumes the current execution mode is 32-paged protected
6898 mode. This function is only available on IA-32. After the 32-bit paging mode
6899 is disabled, control is transferred to the function specified by EntryPoint
6900 using the new stack specified by NewStack and passing in the parameters
6901 specified by Context1 and Context2. Context1 and Context2 are optional and
6902 may be NULL. The function EntryPoint must never return.
6904 If the current execution mode is not 32-bit paged mode, then ASSERT().
6905 If EntryPoint is NULL, then ASSERT().
6906 If NewStack is NULL, then ASSERT().
6908 There are a number of constraints that must be followed before calling this
6910 1) Interrupts must be disabled.
6911 2) The caller must be in 32-bit paged mode.
6912 3) CR0, CR3, and CR4 must be compatible with 32-bit paged mode.
6913 4) CR3 must point to valid page tables that guarantee that the pages for
6914 this function and the stack are identity mapped.
6916 @param EntryPoint A pointer to function to call with the new stack after
6918 @param Context1 A pointer to the context to pass into the EntryPoint
6919 function as the first parameter after paging is disabled.
6920 @param Context2 A pointer to the context to pass into the EntryPoint
6921 function as the second parameter after paging is
6923 @param NewStack A pointer to the new stack to use for the EntryPoint
6924 function after paging is disabled.
6929 AsmDisablePaging32 (
6930 IN SWITCH_STACK_ENTRY_POINT EntryPoint
,
6931 IN VOID
*Context1
, OPTIONAL
6932 IN VOID
*Context2
, OPTIONAL
6938 Enables the 64-bit paging mode on the CPU.
6940 Enables the 64-bit paging mode on the CPU. CR0, CR3, CR4, and the page tables
6941 must be properly initialized prior to calling this service. This function
6942 assumes the current execution mode is 32-bit protected mode with flat
6943 descriptors. This function is only available on IA-32. After the 64-bit
6944 paging mode is enabled, control is transferred to the function specified by
6945 EntryPoint using the new stack specified by NewStack and passing in the
6946 parameters specified by Context1 and Context2. Context1 and Context2 are
6947 optional and may be 0. The function EntryPoint must never return.
6949 If the current execution mode is not 32-bit protected mode with flat
6950 descriptors, then ASSERT().
6951 If EntryPoint is 0, then ASSERT().
6952 If NewStack is 0, then ASSERT().
6954 @param Cs The 16-bit selector to load in the CS before EntryPoint
6955 is called. The descriptor in the GDT that this selector
6956 references must be setup for long mode.
6957 @param EntryPoint The 64-bit virtual address of the function to call with
6958 the new stack after paging is enabled.
6959 @param Context1 The 64-bit virtual address of the context to pass into
6960 the EntryPoint function as the first parameter after
6962 @param Context2 The 64-bit virtual address of the context to pass into
6963 the EntryPoint function as the second parameter after
6965 @param NewStack The 64-bit virtual address of the new stack to use for
6966 the EntryPoint function after paging is enabled.
6973 IN UINT64 EntryPoint
,
6974 IN UINT64 Context1
, OPTIONAL
6975 IN UINT64 Context2
, OPTIONAL
6981 Disables the 64-bit paging mode on the CPU.
6983 Disables the 64-bit paging mode on the CPU and returns to 32-bit protected
6984 mode. This function assumes the current execution mode is 64-paging mode.
6985 This function is only available on x64. After the 64-bit paging mode is
6986 disabled, control is transferred to the function specified by EntryPoint
6987 using the new stack specified by NewStack and passing in the parameters
6988 specified by Context1 and Context2. Context1 and Context2 are optional and
6989 may be 0. The function EntryPoint must never return.
6991 If the current execution mode is not 64-bit paged mode, then ASSERT().
6992 If EntryPoint is 0, then ASSERT().
6993 If NewStack is 0, then ASSERT().
6995 @param Cs The 16-bit selector to load in the CS before EntryPoint
6996 is called. The descriptor in the GDT that this selector
6997 references must be setup for 32-bit protected mode.
6998 @param EntryPoint The 64-bit virtual address of the function to call with
6999 the new stack after paging is disabled.
7000 @param Context1 The 64-bit virtual address of the context to pass into
7001 the EntryPoint function as the first parameter after
7003 @param Context2 The 64-bit virtual address of the context to pass into
7004 the EntryPoint function as the second parameter after
7006 @param NewStack The 64-bit virtual address of the new stack to use for
7007 the EntryPoint function after paging is disabled.
7012 AsmDisablePaging64 (
7014 IN UINT32 EntryPoint
,
7015 IN UINT32 Context1
, OPTIONAL
7016 IN UINT32 Context2
, OPTIONAL
7022 // 16-bit thunking services
7026 Retrieves the properties for 16-bit thunk functions.
7028 Computes the size of the buffer and stack below 1MB required to use the
7029 AsmPrepareThunk16(), AsmThunk16() and AsmPrepareAndThunk16() functions. This
7030 buffer size is returned in RealModeBufferSize, and the stack size is returned
7031 in ExtraStackSize. If parameters are passed to the 16-bit real mode code,
7032 then the actual minimum stack size is ExtraStackSize plus the maximum number
7033 of bytes that need to be passed to the 16-bit real mode code.
7035 If RealModeBufferSize is NULL, then ASSERT().
7036 If ExtraStackSize is NULL, then ASSERT().
7038 @param RealModeBufferSize A pointer to the size of the buffer below 1MB
7039 required to use the 16-bit thunk functions.
7040 @param ExtraStackSize A pointer to the extra size of stack below 1MB
7041 that the 16-bit thunk functions require for
7042 temporary storage in the transition to and from
7048 AsmGetThunk16Properties (
7049 OUT UINT32
*RealModeBufferSize
,
7050 OUT UINT32
*ExtraStackSize
7055 Prepares all structures a code required to use AsmThunk16().
7057 Prepares all structures and code required to use AsmThunk16().
7059 This interface is limited to be used in either physical mode or virtual modes with paging enabled where the
7060 virtual to physical mappings for ThunkContext.RealModeBuffer is mapped 1:1.
7062 If ThunkContext is NULL, then ASSERT().
7064 @param ThunkContext A pointer to the context structure that describes the
7065 16-bit real mode code to call.
7071 OUT THUNK_CONTEXT
*ThunkContext
7076 Transfers control to a 16-bit real mode entry point and returns the results.
7078 Transfers control to a 16-bit real mode entry point and returns the results.
7079 AsmPrepareThunk16() must be called with ThunkContext before this function is used.
7080 This function must be called with interrupts disabled.
7082 The register state from the RealModeState field of ThunkContext is restored just prior
7083 to calling the 16-bit real mode entry point. This includes the EFLAGS field of RealModeState,
7084 which is used to set the interrupt state when a 16-bit real mode entry point is called.
7085 Control is transferred to the 16-bit real mode entry point specified by the CS and Eip fields of RealModeState.
7086 The stack is initialized to the SS and ESP fields of RealModeState. Any parameters passed to
7087 the 16-bit real mode code must be populated by the caller at SS:ESP prior to calling this function.
7088 The 16-bit real mode entry point is invoked with a 16-bit CALL FAR instruction,
7089 so when accessing stack contents, the 16-bit real mode code must account for the 16-bit segment
7090 and 16-bit offset of the return address that were pushed onto the stack. The 16-bit real mode entry
7091 point must exit with a RETF instruction. The register state is captured into RealModeState immediately
7092 after the RETF instruction is executed.
7094 If EFLAGS specifies interrupts enabled, or any of the 16-bit real mode code enables interrupts,
7095 or any of the 16-bit real mode code makes a SW interrupt, then the caller is responsible for making sure
7096 the IDT at address 0 is initialized to handle any HW or SW interrupts that may occur while in 16-bit real mode.
7098 If EFLAGS specifies interrupts enabled, or any of the 16-bit real mode code enables interrupts,
7099 then the caller is responsible for making sure the 8259 PIC is in a state compatible with 16-bit real mode.
7100 This includes the base vectors, the interrupt masks, and the edge/level trigger mode.
7102 If THUNK_ATTRIBUTE_BIG_REAL_MODE is set in the ThunkAttributes field of ThunkContext, then the user code
7103 is invoked in big real mode. Otherwise, the user code is invoked in 16-bit real mode with 64KB segment limits.
7105 If neither THUNK_ATTRIBUTE_DISABLE_A20_MASK_INT_15 nor THUNK_ATTRIBUTE_DISABLE_A20_MASK_KBD_CTRL are set in
7106 ThunkAttributes, then it is assumed that the user code did not enable the A20 mask, and no attempt is made to
7107 disable the A20 mask.
7109 If THUNK_ATTRIBUTE_DISABLE_A20_MASK_INT_15 is set and THUNK_ATTRIBUTE_DISABLE_A20_MASK_KBD_CTRL is clear in
7110 ThunkAttributes, then attempt to use the INT 15 service to disable the A20 mask. If this INT 15 call fails,
7111 then attempt to disable the A20 mask by directly accessing the 8042 keyboard controller I/O ports.
7113 If THUNK_ATTRIBUTE_DISABLE_A20_MASK_INT_15 is clear and THUNK_ATTRIBUTE_DISABLE_A20_MASK_KBD_CTRL is set in
7114 ThunkAttributes, then attempt to disable the A20 mask by directly accessing the 8042 keyboard controller I/O ports.
7116 If ThunkContext is NULL, then ASSERT().
7117 If AsmPrepareThunk16() was not previously called with ThunkContext, then ASSERT().
7118 If both THUNK_ATTRIBUTE_DISABLE_A20_MASK_INT_15 and THUNK_ATTRIBUTE_DISABLE_A20_MASK_KBD_CTRL are set in
7119 ThunkAttributes, then ASSERT().
7121 This interface is limited to be used in either physical mode or virtual modes with paging enabled where the
7122 virtual to physical mappings for ThunkContext.RealModeBuffer is mapped 1:1.
7124 @param ThunkContext A pointer to the context structure that describes the
7125 16-bit real mode code to call.
7131 IN OUT THUNK_CONTEXT
*ThunkContext
7136 Prepares all structures and code for a 16-bit real mode thunk, transfers
7137 control to a 16-bit real mode entry point, and returns the results.
7139 Prepares all structures and code for a 16-bit real mode thunk, transfers
7140 control to a 16-bit real mode entry point, and returns the results. If the
7141 caller only need to perform a single 16-bit real mode thunk, then this
7142 service should be used. If the caller intends to make more than one 16-bit
7143 real mode thunk, then it is more efficient if AsmPrepareThunk16() is called
7144 once and AsmThunk16() can be called for each 16-bit real mode thunk.
7146 This interface is limited to be used in either physical mode or virtual modes with paging enabled where the
7147 virtual to physical mappings for ThunkContext.RealModeBuffer is mapped 1:1.
7149 See AsmPrepareThunk16() and AsmThunk16() for the detailed description and ASSERT() conditions.
7151 @param ThunkContext A pointer to the context structure that describes the
7152 16-bit real mode code to call.
7157 AsmPrepareAndThunk16 (
7158 IN OUT THUNK_CONTEXT
*ThunkContext