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. All rights reserved.<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 List is returned.
1392 IN CONST LIST_ENTRY
*List
,
1393 IN CONST LIST_ENTRY
*Node
1398 Retrieves the previous node of a doubly linked list.
1400 Returns the node of a doubly linked list that precedes Node.
1401 List must have been initialized with INTIALIZE_LIST_HEAD_VARIABLE()
1402 or InitializeListHead(). If List is empty, then List is returned.
1404 If List is NULL, then ASSERT().
1405 If Node is NULL, then ASSERT().
1406 If List was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or
1407 InitializeListHead(), then ASSERT().
1408 If PcdMaximumLinkedListLenth is not zero, and List contains more than
1409 PcdMaximumLinkedListLenth nodes, then ASSERT().
1410 If PcdVerifyNodeInList is TRUE and Node is not a node in List, then ASSERT().
1412 @param List A pointer to the head node of a doubly linked list.
1413 @param Node A pointer to a node in the doubly linked list.
1415 @return Pointer to the previous node if one exists. Otherwise List is returned.
1421 IN CONST LIST_ENTRY
*List
,
1422 IN CONST LIST_ENTRY
*Node
1427 Checks to see if a doubly linked list is empty or not.
1429 Checks to see if the doubly linked list is empty. If the linked list contains
1430 zero nodes, this function returns TRUE. Otherwise, it returns FALSE.
1432 If ListHead is NULL, then ASSERT().
1433 If ListHead was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or
1434 InitializeListHead(), then ASSERT().
1435 If PcdMaximumLinkedListLenth is not zero, and the number of nodes
1436 in List, including the List node, is greater than or equal to
1437 PcdMaximumLinkedListLength, then ASSERT().
1439 @param ListHead A pointer to the head node of a doubly linked list.
1441 @retval TRUE The linked list is empty.
1442 @retval FALSE The linked list is not empty.
1448 IN CONST LIST_ENTRY
*ListHead
1453 Determines if a node in a doubly linked list is the head node of a the same
1454 doubly linked list. This function is typically used to terminate a loop that
1455 traverses all the nodes in a doubly linked list starting with the head node.
1457 Returns TRUE if Node is equal to List. Returns FALSE if Node is one of the
1458 nodes in the doubly linked list specified by List. List must have been
1459 initialized with INTIALIZE_LIST_HEAD_VARIABLE() or InitializeListHead().
1461 If List is NULL, then ASSERT().
1462 If Node is NULL, then ASSERT().
1463 If List was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or InitializeListHead(),
1465 If PcdMaximumLinkedListLenth is not zero, and the number of nodes
1466 in List, including the List node, is greater than or equal to
1467 PcdMaximumLinkedListLength, then ASSERT().
1468 If PcdVerifyNodeInList is TRUE and Node is not a node in List the and Node is not equal
1469 to List, then ASSERT().
1471 @param List A pointer to the head node of a doubly linked list.
1472 @param Node A pointer to a node in the doubly linked list.
1474 @retval TRUE Node is one of the nodes in the doubly linked list.
1475 @retval FALSE Node is not one of the nodes in the doubly linked list.
1481 IN CONST LIST_ENTRY
*List
,
1482 IN CONST LIST_ENTRY
*Node
1487 Determines if a node the last node in a doubly linked list.
1489 Returns TRUE if Node is the last node in the doubly linked list specified by
1490 List. Otherwise, FALSE is returned. List must have been initialized with
1491 INTIALIZE_LIST_HEAD_VARIABLE() or InitializeListHead().
1493 If List is NULL, then ASSERT().
1494 If Node is NULL, then ASSERT().
1495 If List was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or
1496 InitializeListHead(), then ASSERT().
1497 If PcdMaximumLinkedListLenth is not zero, and the number of nodes
1498 in List, including the List node, is greater than or equal to
1499 PcdMaximumLinkedListLength, then ASSERT().
1500 If PcdVerifyNodeInList is TRUE and Node is not a node in List, then ASSERT().
1502 @param List A pointer to the head node of a doubly linked list.
1503 @param Node A pointer to a node in the doubly linked list.
1505 @retval TRUE Node is the last node in the linked list.
1506 @retval FALSE Node is not the last node in the linked list.
1512 IN CONST LIST_ENTRY
*List
,
1513 IN CONST LIST_ENTRY
*Node
1518 Swaps the location of two nodes in a doubly linked list, and returns the
1519 first node after the swap.
1521 If FirstEntry is identical to SecondEntry, then SecondEntry is returned.
1522 Otherwise, the location of the FirstEntry node is swapped with the location
1523 of the SecondEntry node in a doubly linked list. SecondEntry must be in the
1524 same double linked list as FirstEntry and that double linked list must have
1525 been initialized with INTIALIZE_LIST_HEAD_VARIABLE() or InitializeListHead().
1526 SecondEntry is returned after the nodes are swapped.
1528 If FirstEntry is NULL, then ASSERT().
1529 If SecondEntry is NULL, then ASSERT().
1530 If PcdVerifyNodeInList is TRUE and SecondEntry and FirstEntry are not in the
1531 same linked list, then ASSERT().
1532 If PcdMaximumLinkedListLength is not zero, and the number of nodes in the
1533 linked list containing the FirstEntry and SecondEntry nodes, including
1534 the FirstEntry and SecondEntry nodes, is greater than or equal to
1535 PcdMaximumLinkedListLength, then ASSERT().
1537 @param FirstEntry A pointer to a node in a linked list.
1538 @param SecondEntry A pointer to another node in the same linked list.
1540 @return SecondEntry.
1546 IN OUT LIST_ENTRY
*FirstEntry
,
1547 IN OUT LIST_ENTRY
*SecondEntry
1552 Removes a node from a doubly linked list, and returns the node that follows
1555 Removes the node Entry from a doubly linked list. It is up to the caller of
1556 this function to release the memory used by this node if that is required. On
1557 exit, the node following Entry in the doubly linked list is returned. If
1558 Entry is the only node in the linked list, then the head node of the linked
1561 If Entry is NULL, then ASSERT().
1562 If Entry is the head node of an empty list, then ASSERT().
1563 If PcdMaximumLinkedListLength is not zero, and the number of nodes in the
1564 linked list containing Entry, including the Entry node, is greater than
1565 or equal to PcdMaximumLinkedListLength, then ASSERT().
1567 @param Entry A pointer to a node in a linked list.
1575 IN CONST LIST_ENTRY
*Entry
1583 Shifts a 64-bit integer left between 0 and 63 bits. The low bits are filled
1584 with zeros. The shifted value is returned.
1586 This function shifts the 64-bit value Operand to the left by Count bits. The
1587 low Count bits are set to zero. The shifted value is returned.
1589 If Count is greater than 63, then ASSERT().
1591 @param Operand The 64-bit operand to shift left.
1592 @param Count The number of bits to shift left.
1594 @return Operand << Count.
1606 Shifts a 64-bit integer right between 0 and 63 bits. This high bits are
1607 filled with zeros. The shifted value is returned.
1609 This function shifts the 64-bit value Operand to the right by Count bits. The
1610 high Count bits are set to zero. The shifted value is returned.
1612 If Count is greater than 63, then ASSERT().
1614 @param Operand The 64-bit operand to shift right.
1615 @param Count The number of bits to shift right.
1617 @return Operand >> Count
1629 Shifts a 64-bit integer right between 0 and 63 bits. The high bits are filled
1630 with original integer's bit 63. The shifted value is returned.
1632 This function shifts the 64-bit value Operand to the right by Count bits. The
1633 high Count bits are set to bit 63 of Operand. The shifted value is returned.
1635 If Count is greater than 63, then ASSERT().
1637 @param Operand The 64-bit operand to shift right.
1638 @param Count The number of bits to shift right.
1640 @return Operand >> Count
1652 Rotates a 32-bit integer left between 0 and 31 bits, filling the low bits
1653 with the high bits that were rotated.
1655 This function rotates the 32-bit value Operand to the left by Count bits. The
1656 low Count bits are fill with the high Count bits of Operand. The rotated
1659 If Count is greater than 31, then ASSERT().
1661 @param Operand The 32-bit operand to rotate left.
1662 @param Count The number of bits to rotate left.
1664 @return Operand << Count
1676 Rotates a 32-bit integer right between 0 and 31 bits, filling the high bits
1677 with the low bits that were rotated.
1679 This function rotates the 32-bit value Operand to the right by Count bits.
1680 The high Count bits are fill with the low Count bits of Operand. The rotated
1683 If Count is greater than 31, then ASSERT().
1685 @param Operand The 32-bit operand to rotate right.
1686 @param Count The number of bits to rotate right.
1688 @return Operand >> Count
1700 Rotates a 64-bit integer left between 0 and 63 bits, filling the low bits
1701 with the high bits that were rotated.
1703 This function rotates the 64-bit value Operand to the left by Count bits. The
1704 low Count bits are fill with the high Count bits of Operand. The rotated
1707 If Count is greater than 63, then ASSERT().
1709 @param Operand The 64-bit operand to rotate left.
1710 @param Count The number of bits to rotate left.
1712 @return Operand << Count
1724 Rotates a 64-bit integer right between 0 and 63 bits, filling the high bits
1725 with the high low bits that were rotated.
1727 This function rotates the 64-bit value Operand to the right by Count bits.
1728 The high Count bits are fill with the low Count bits of Operand. The rotated
1731 If Count is greater than 63, then ASSERT().
1733 @param Operand The 64-bit operand to rotate right.
1734 @param Count The number of bits to rotate right.
1736 @return Operand >> Count
1748 Returns the bit position of the lowest bit set in a 32-bit value.
1750 This function computes the bit position of the lowest bit set in the 32-bit
1751 value specified by Operand. If Operand is zero, then -1 is returned.
1752 Otherwise, a value between 0 and 31 is returned.
1754 @param Operand The 32-bit operand to evaluate.
1756 @retval 0..31 The lowest bit set in Operand was found.
1757 @retval -1 Operand is zero.
1768 Returns the bit position of the lowest bit set in a 64-bit value.
1770 This function computes the bit position of the lowest bit set in the 64-bit
1771 value specified by Operand. If Operand is zero, then -1 is returned.
1772 Otherwise, a value between 0 and 63 is returned.
1774 @param Operand The 64-bit operand to evaluate.
1776 @retval 0..63 The lowest bit set in Operand was found.
1777 @retval -1 Operand is zero.
1789 Returns the bit position of the highest bit set in a 32-bit value. Equivalent
1792 This function computes the bit position of the highest bit set in the 32-bit
1793 value specified by Operand. If Operand is zero, then -1 is returned.
1794 Otherwise, a value between 0 and 31 is returned.
1796 @param Operand The 32-bit operand to evaluate.
1798 @retval 0..31 Position of the highest bit set in Operand if found.
1799 @retval -1 Operand is zero.
1810 Returns the bit position of the highest bit set in a 64-bit value. Equivalent
1813 This function computes the bit position of the highest bit set in the 64-bit
1814 value specified by Operand. If Operand is zero, then -1 is returned.
1815 Otherwise, a value between 0 and 63 is returned.
1817 @param Operand The 64-bit operand to evaluate.
1819 @retval 0..63 Position of the highest bit set in Operand if found.
1820 @retval -1 Operand is zero.
1831 Returns the value of the highest bit set in a 32-bit value. Equivalent to
1834 This function computes the value of the highest bit set in the 32-bit value
1835 specified by Operand. If Operand is zero, then zero is returned.
1837 @param Operand The 32-bit operand to evaluate.
1839 @return 1 << HighBitSet32(Operand)
1840 @retval 0 Operand is zero.
1851 Returns the value of the highest bit set in a 64-bit value. Equivalent to
1854 This function computes the value of the highest bit set in the 64-bit value
1855 specified by Operand. If Operand is zero, then zero is returned.
1857 @param Operand The 64-bit operand to evaluate.
1859 @return 1 << HighBitSet64(Operand)
1860 @retval 0 Operand is zero.
1871 Switches the endianess of a 16-bit integer.
1873 This function swaps the bytes in a 16-bit unsigned value to switch the value
1874 from little endian to big endian or vice versa. The byte swapped value is
1877 @param Value A 16-bit unsigned value.
1879 @return The byte swapped Value.
1890 Switches the endianess of a 32-bit integer.
1892 This function swaps the bytes in a 32-bit unsigned value to switch the value
1893 from little endian to big endian or vice versa. The byte swapped value is
1896 @param Value A 32-bit unsigned value.
1898 @return The byte swapped Value.
1909 Switches the endianess of a 64-bit integer.
1911 This function swaps the bytes in a 64-bit unsigned value to switch the value
1912 from little endian to big endian or vice versa. The byte swapped value is
1915 @param Value A 64-bit unsigned value.
1917 @return The byte swapped Value.
1928 Multiples a 64-bit unsigned integer by a 32-bit unsigned integer and
1929 generates a 64-bit unsigned result.
1931 This function multiples the 64-bit unsigned value Multiplicand by the 32-bit
1932 unsigned value Multiplier and generates a 64-bit unsigned result. This 64-
1933 bit unsigned result is returned.
1935 @param Multiplicand A 64-bit unsigned value.
1936 @param Multiplier A 32-bit unsigned value.
1938 @return Multiplicand * Multiplier
1944 IN UINT64 Multiplicand
,
1945 IN UINT32 Multiplier
1950 Multiples a 64-bit unsigned integer by a 64-bit unsigned integer and
1951 generates a 64-bit unsigned result.
1953 This function multiples the 64-bit unsigned value Multiplicand by the 64-bit
1954 unsigned value Multiplier and generates a 64-bit unsigned result. This 64-
1955 bit unsigned result is returned.
1957 @param Multiplicand A 64-bit unsigned value.
1958 @param Multiplier A 64-bit unsigned value.
1960 @return Multiplicand * Multiplier
1966 IN UINT64 Multiplicand
,
1967 IN UINT64 Multiplier
1972 Multiples a 64-bit signed integer by a 64-bit signed integer and generates a
1973 64-bit signed result.
1975 This function multiples the 64-bit signed value Multiplicand by the 64-bit
1976 signed value Multiplier and generates a 64-bit signed result. This 64-bit
1977 signed result is returned.
1979 @param Multiplicand A 64-bit signed value.
1980 @param Multiplier A 64-bit signed value.
1982 @return Multiplicand * Multiplier
1988 IN INT64 Multiplicand
,
1994 Divides a 64-bit unsigned integer by a 32-bit unsigned integer and generates
1995 a 64-bit unsigned result.
1997 This function divides the 64-bit unsigned value Dividend by the 32-bit
1998 unsigned value Divisor and generates a 64-bit unsigned quotient. This
1999 function returns the 64-bit unsigned quotient.
2001 If Divisor is 0, then ASSERT().
2003 @param Dividend A 64-bit unsigned value.
2004 @param Divisor A 32-bit unsigned value.
2006 @return Dividend / Divisor
2018 Divides a 64-bit unsigned integer by a 32-bit unsigned integer and generates
2019 a 32-bit unsigned remainder.
2021 This function divides the 64-bit unsigned value Dividend by the 32-bit
2022 unsigned value Divisor and generates a 32-bit remainder. This function
2023 returns the 32-bit unsigned remainder.
2025 If Divisor is 0, then ASSERT().
2027 @param Dividend A 64-bit unsigned value.
2028 @param Divisor A 32-bit unsigned value.
2030 @return Dividend % Divisor
2042 Divides a 64-bit unsigned integer by a 32-bit unsigned integer and generates
2043 a 64-bit unsigned result and an optional 32-bit unsigned remainder.
2045 This function divides the 64-bit unsigned value Dividend by the 32-bit
2046 unsigned value Divisor and generates a 64-bit unsigned quotient. If Remainder
2047 is not NULL, then the 32-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 32-bit unsigned value.
2054 @param Remainder A pointer to a 32-bit unsigned value. This parameter is
2055 optional and may be NULL.
2057 @return Dividend / Divisor
2062 DivU64x32Remainder (
2065 OUT UINT32
*Remainder OPTIONAL
2070 Divides a 64-bit unsigned integer by a 64-bit unsigned integer and generates
2071 a 64-bit unsigned result and an optional 64-bit unsigned remainder.
2073 This function divides the 64-bit unsigned value Dividend by the 64-bit
2074 unsigned value Divisor and generates a 64-bit unsigned quotient. If Remainder
2075 is not NULL, then the 64-bit unsigned remainder is returned in Remainder.
2076 This function returns the 64-bit unsigned quotient.
2078 If Divisor is 0, then ASSERT().
2080 @param Dividend A 64-bit unsigned value.
2081 @param Divisor A 64-bit unsigned value.
2082 @param Remainder A pointer to a 64-bit unsigned value. This parameter is
2083 optional and may be NULL.
2085 @return Dividend / Divisor
2090 DivU64x64Remainder (
2093 OUT UINT64
*Remainder OPTIONAL
2098 Divides a 64-bit signed integer by a 64-bit signed integer and generates a
2099 64-bit signed result and a optional 64-bit signed remainder.
2101 This function divides the 64-bit signed value Dividend by the 64-bit signed
2102 value Divisor and generates a 64-bit signed quotient. If Remainder is not
2103 NULL, then the 64-bit signed remainder is returned in Remainder. This
2104 function returns the 64-bit signed quotient.
2106 It is the caller's responsibility to not call this function with a Divisor of 0.
2107 If Divisor is 0, then the quotient and remainder should be assumed to be
2108 the largest negative integer.
2110 If Divisor is 0, then ASSERT().
2112 @param Dividend A 64-bit signed value.
2113 @param Divisor A 64-bit signed value.
2114 @param Remainder A pointer to a 64-bit signed value. This parameter is
2115 optional and may be NULL.
2117 @return Dividend / Divisor
2122 DivS64x64Remainder (
2125 OUT INT64
*Remainder OPTIONAL
2130 Reads a 16-bit value from memory that may be unaligned.
2132 This function returns the 16-bit value pointed to by Buffer. The function
2133 guarantees that the read operation does not produce an alignment fault.
2135 If the Buffer is NULL, then ASSERT().
2137 @param Buffer Pointer to a 16-bit value that may be unaligned.
2139 @return The 16-bit value read from Buffer.
2145 IN CONST UINT16
*Buffer
2150 Writes a 16-bit value to memory that may be unaligned.
2152 This function writes the 16-bit value specified by Value to Buffer. Value is
2153 returned. The function guarantees that the write operation does not produce
2156 If the Buffer is NULL, then ASSERT().
2158 @param Buffer Pointer to a 16-bit value that may be unaligned.
2159 @param Value 16-bit value to write to Buffer.
2161 @return The 16-bit value to write to Buffer.
2173 Reads a 24-bit value from memory that may be unaligned.
2175 This function returns the 24-bit value pointed to by Buffer. The function
2176 guarantees that the read operation does not produce an alignment fault.
2178 If the Buffer is NULL, then ASSERT().
2180 @param Buffer Pointer to a 24-bit value that may be unaligned.
2182 @return The 24-bit value read from Buffer.
2188 IN CONST UINT32
*Buffer
2193 Writes a 24-bit value to memory that may be unaligned.
2195 This function writes the 24-bit value specified by Value to Buffer. Value is
2196 returned. The function guarantees that the write operation does not produce
2199 If the Buffer is NULL, then ASSERT().
2201 @param Buffer Pointer to a 24-bit value that may be unaligned.
2202 @param Value 24-bit value to write to Buffer.
2204 @return The 24-bit value to write to Buffer.
2216 Reads a 32-bit value from memory that may be unaligned.
2218 This function returns the 32-bit value pointed to by Buffer. The function
2219 guarantees that the read operation does not produce an alignment fault.
2221 If the Buffer is NULL, then ASSERT().
2223 @param Buffer Pointer to a 32-bit value that may be unaligned.
2225 @return The 32-bit value read from Buffer.
2231 IN CONST UINT32
*Buffer
2236 Writes a 32-bit value to memory that may be unaligned.
2238 This function writes the 32-bit value specified by Value to Buffer. Value is
2239 returned. The function guarantees that the write operation does not produce
2242 If the Buffer is NULL, then ASSERT().
2244 @param Buffer Pointer to a 32-bit value that may be unaligned.
2245 @param Value 32-bit value to write to Buffer.
2247 @return The 32-bit value to write to Buffer.
2259 Reads a 64-bit value from memory that may be unaligned.
2261 This function returns the 64-bit value pointed to by Buffer. The function
2262 guarantees that the read operation does not produce an alignment fault.
2264 If the Buffer is NULL, then ASSERT().
2266 @param Buffer Pointer to a 64-bit value that may be unaligned.
2268 @return The 64-bit value read from Buffer.
2274 IN CONST UINT64
*Buffer
2279 Writes a 64-bit value to memory that may be unaligned.
2281 This function writes the 64-bit value specified by Value to Buffer. Value is
2282 returned. The function guarantees that the write operation does not produce
2285 If the Buffer is NULL, then ASSERT().
2287 @param Buffer Pointer to a 64-bit value that may be unaligned.
2288 @param Value 64-bit value to write to Buffer.
2290 @return The 64-bit value to write to Buffer.
2302 // Bit Field Functions
2306 Returns a bit field from an 8-bit value.
2308 Returns the bitfield specified by the StartBit and the EndBit from Operand.
2310 If 8-bit operations are not supported, then ASSERT().
2311 If StartBit is greater than 7, then ASSERT().
2312 If EndBit is greater than 7, then ASSERT().
2313 If EndBit is less than StartBit, then ASSERT().
2315 @param Operand Operand on which to perform the bitfield operation.
2316 @param StartBit The ordinal of the least significant bit in the bit field.
2318 @param EndBit The ordinal of the most significant bit in the bit field.
2321 @return The bit field read.
2334 Writes a bit field to an 8-bit value, and returns the result.
2336 Writes Value to the bit field specified by the StartBit and the EndBit in
2337 Operand. All other bits in Operand are preserved. The new 8-bit value is
2340 If 8-bit operations are not supported, then ASSERT().
2341 If StartBit is greater than 7, then ASSERT().
2342 If EndBit is greater than 7, then ASSERT().
2343 If EndBit is less than StartBit, then ASSERT().
2345 @param Operand Operand on which to perform the bitfield operation.
2346 @param StartBit The ordinal of the least significant bit in the bit field.
2348 @param EndBit The ordinal of the most significant bit in the bit field.
2350 @param Value New value of the bit field.
2352 @return The new 8-bit value.
2366 Reads a bit field from an 8-bit value, performs a bitwise OR, and returns the
2369 Performs a bitwise OR between the bit field specified by StartBit
2370 and EndBit in Operand and the value specified by OrData. All other bits in
2371 Operand are preserved. The new 8-bit value is returned.
2373 If 8-bit operations are not supported, then ASSERT().
2374 If StartBit is greater than 7, then ASSERT().
2375 If EndBit is greater than 7, then ASSERT().
2376 If EndBit is less than StartBit, then ASSERT().
2378 @param Operand Operand on which to perform the bitfield operation.
2379 @param StartBit The ordinal of the least significant bit in the bit field.
2381 @param EndBit The ordinal of the most significant bit in the bit field.
2383 @param OrData The value to OR with the read value from the value
2385 @return The new 8-bit value.
2399 Reads a bit field from an 8-bit value, performs a bitwise AND, and returns
2402 Performs a bitwise AND between the bit field specified by StartBit and EndBit
2403 in Operand and the value specified by AndData. All other bits in Operand are
2404 preserved. The new 8-bit value is returned.
2406 If 8-bit operations are not supported, then ASSERT().
2407 If StartBit is greater than 7, then ASSERT().
2408 If EndBit is greater than 7, then ASSERT().
2409 If EndBit is less than StartBit, then ASSERT().
2411 @param Operand Operand on which to perform the bitfield operation.
2412 @param StartBit The ordinal of the least significant bit in the bit field.
2414 @param EndBit The ordinal of the most significant bit in the bit field.
2416 @param AndData The value to AND with the read value from the value.
2418 @return The new 8-bit value.
2432 Reads a bit field from an 8-bit value, performs a bitwise AND followed by a
2433 bitwise OR, and returns the result.
2435 Performs a bitwise AND between the bit field specified by StartBit and EndBit
2436 in Operand and the value specified by AndData, followed by a bitwise
2437 OR with value specified by OrData. All other bits in Operand are
2438 preserved. The new 8-bit value is returned.
2440 If 8-bit operations are not supported, then ASSERT().
2441 If StartBit is greater than 7, then ASSERT().
2442 If EndBit is greater than 7, then ASSERT().
2443 If EndBit is less than StartBit, then ASSERT().
2445 @param Operand Operand on which to perform the bitfield operation.
2446 @param StartBit The ordinal of the least significant bit in the bit field.
2448 @param EndBit The ordinal of the most significant bit in the bit field.
2450 @param AndData The value to AND with the read value from the value.
2451 @param OrData The value to OR with the result of the AND operation.
2453 @return The new 8-bit value.
2458 BitFieldAndThenOr8 (
2468 Returns a bit field from a 16-bit value.
2470 Returns the bitfield specified by the StartBit and the EndBit from Operand.
2472 If 16-bit operations are not supported, then ASSERT().
2473 If StartBit is greater than 15, then ASSERT().
2474 If EndBit is greater than 15, then ASSERT().
2475 If EndBit is less than StartBit, then ASSERT().
2477 @param Operand Operand on which to perform the bitfield operation.
2478 @param StartBit The ordinal of the least significant bit in the bit field.
2480 @param EndBit The ordinal of the most significant bit in the bit field.
2483 @return The bit field read.
2496 Writes a bit field to a 16-bit value, and returns the result.
2498 Writes Value to the bit field specified by the StartBit and the EndBit in
2499 Operand. All other bits in Operand are preserved. The new 16-bit value is
2502 If 16-bit operations are not supported, then ASSERT().
2503 If StartBit is greater than 15, then ASSERT().
2504 If EndBit is greater than 15, then ASSERT().
2505 If EndBit is less than StartBit, then ASSERT().
2507 @param Operand Operand on which to perform the bitfield operation.
2508 @param StartBit The ordinal of the least significant bit in the bit field.
2510 @param EndBit The ordinal of the most significant bit in the bit field.
2512 @param Value New value of the bit field.
2514 @return The new 16-bit value.
2528 Reads a bit field from a 16-bit value, performs a bitwise OR, and returns the
2531 Performs a bitwise OR between the bit field specified by StartBit
2532 and EndBit in Operand and the value specified by OrData. All other bits in
2533 Operand are preserved. The new 16-bit value is returned.
2535 If 16-bit operations are not supported, then ASSERT().
2536 If StartBit is greater than 15, then ASSERT().
2537 If EndBit is greater than 15, then ASSERT().
2538 If EndBit is less than StartBit, then ASSERT().
2540 @param Operand Operand on which to perform the bitfield operation.
2541 @param StartBit The ordinal of the least significant bit in the bit field.
2543 @param EndBit The ordinal of the most significant bit in the bit field.
2545 @param OrData The value to OR with the read value from the value
2547 @return The new 16-bit value.
2561 Reads a bit field from a 16-bit value, performs a bitwise AND, and returns
2564 Performs a bitwise AND between the bit field specified by StartBit and EndBit
2565 in Operand and the value specified by AndData. All other bits in Operand are
2566 preserved. The new 16-bit value is returned.
2568 If 16-bit operations are not supported, then ASSERT().
2569 If StartBit is greater than 15, then ASSERT().
2570 If EndBit is greater than 15, then ASSERT().
2571 If EndBit is less than StartBit, then ASSERT().
2573 @param Operand Operand on which to perform the bitfield operation.
2574 @param StartBit The ordinal of the least significant bit in the bit field.
2576 @param EndBit The ordinal of the most significant bit in the bit field.
2578 @param AndData The value to AND with the read value from the value
2580 @return The new 16-bit value.
2594 Reads a bit field from a 16-bit value, performs a bitwise AND followed by a
2595 bitwise OR, and returns the result.
2597 Performs a bitwise AND between the bit field specified by StartBit and EndBit
2598 in Operand and the value specified by AndData, followed by a bitwise
2599 OR with value specified by OrData. All other bits in Operand are
2600 preserved. The new 16-bit value is returned.
2602 If 16-bit operations are not supported, then ASSERT().
2603 If StartBit is greater than 15, then ASSERT().
2604 If EndBit is greater than 15, then ASSERT().
2605 If EndBit is less than StartBit, then ASSERT().
2607 @param Operand Operand on which to perform the bitfield operation.
2608 @param StartBit The ordinal of the least significant bit in the bit field.
2610 @param EndBit The ordinal of the most significant bit in the bit field.
2612 @param AndData The value to AND with the read value from the value.
2613 @param OrData The value to OR with the result of the AND operation.
2615 @return The new 16-bit value.
2620 BitFieldAndThenOr16 (
2630 Returns a bit field from a 32-bit value.
2632 Returns the bitfield specified by the StartBit and the EndBit from Operand.
2634 If 32-bit operations are not supported, then ASSERT().
2635 If StartBit is greater than 31, then ASSERT().
2636 If EndBit is greater than 31, then ASSERT().
2637 If EndBit is less than StartBit, then ASSERT().
2639 @param Operand Operand on which to perform the bitfield operation.
2640 @param StartBit The ordinal of the least significant bit in the bit field.
2642 @param EndBit The ordinal of the most significant bit in the bit field.
2645 @return The bit field read.
2658 Writes a bit field to a 32-bit value, and returns the result.
2660 Writes Value to the bit field specified by the StartBit and the EndBit in
2661 Operand. All other bits in Operand are preserved. The new 32-bit value is
2664 If 32-bit operations are not supported, then ASSERT().
2665 If StartBit is greater than 31, then ASSERT().
2666 If EndBit is greater than 31, then ASSERT().
2667 If EndBit is less than StartBit, then ASSERT().
2669 @param Operand Operand on which to perform the bitfield operation.
2670 @param StartBit The ordinal of the least significant bit in the bit field.
2672 @param EndBit The ordinal of the most significant bit in the bit field.
2674 @param Value New value of the bit field.
2676 @return The new 32-bit value.
2690 Reads a bit field from a 32-bit value, performs a bitwise OR, and returns the
2693 Performs a bitwise OR between the bit field specified by StartBit
2694 and EndBit in Operand and the value specified by OrData. All other bits in
2695 Operand are preserved. The new 32-bit value is returned.
2697 If 32-bit operations are not supported, then ASSERT().
2698 If StartBit is greater than 31, then ASSERT().
2699 If EndBit is greater than 31, then ASSERT().
2700 If EndBit is less than StartBit, then ASSERT().
2702 @param Operand Operand on which to perform the bitfield operation.
2703 @param StartBit The ordinal of the least significant bit in the bit field.
2705 @param EndBit The ordinal of the most significant bit in the bit field.
2707 @param OrData The value to OR with the read value from the value
2709 @return The new 32-bit value.
2723 Reads a bit field from a 32-bit value, performs a bitwise AND, and returns
2726 Performs a bitwise AND between the bit field specified by StartBit and EndBit
2727 in Operand and the value specified by AndData. All other bits in Operand are
2728 preserved. The new 32-bit value is returned.
2730 If 32-bit operations are not supported, then ASSERT().
2731 If StartBit is greater than 31, then ASSERT().
2732 If EndBit is greater than 31, then ASSERT().
2733 If EndBit is less than StartBit, then ASSERT().
2735 @param Operand Operand on which to perform the bitfield operation.
2736 @param StartBit The ordinal of the least significant bit in the bit field.
2738 @param EndBit The ordinal of the most significant bit in the bit field.
2740 @param AndData The value to AND with the read value from the value
2742 @return The new 32-bit value.
2756 Reads a bit field from a 32-bit value, performs a bitwise AND followed by a
2757 bitwise OR, and returns the result.
2759 Performs a bitwise AND between the bit field specified by StartBit and EndBit
2760 in Operand and the value specified by AndData, followed by a bitwise
2761 OR with value specified by OrData. All other bits in Operand are
2762 preserved. The new 32-bit value is returned.
2764 If 32-bit operations are not supported, then ASSERT().
2765 If StartBit is greater than 31, then ASSERT().
2766 If EndBit is greater than 31, then ASSERT().
2767 If EndBit is less than StartBit, then ASSERT().
2769 @param Operand Operand on which to perform the bitfield operation.
2770 @param StartBit The ordinal of the least significant bit in the bit field.
2772 @param EndBit The ordinal of the most significant bit in the bit field.
2774 @param AndData The value to AND with the read value from the value.
2775 @param OrData The value to OR with the result of the AND operation.
2777 @return The new 32-bit value.
2782 BitFieldAndThenOr32 (
2792 Returns a bit field from a 64-bit value.
2794 Returns the bitfield specified by the StartBit and the EndBit from Operand.
2796 If 64-bit operations are not supported, then ASSERT().
2797 If StartBit is greater than 63, then ASSERT().
2798 If EndBit is greater than 63, then ASSERT().
2799 If EndBit is less than StartBit, then ASSERT().
2801 @param Operand Operand on which to perform the bitfield operation.
2802 @param StartBit The ordinal of the least significant bit in the bit field.
2804 @param EndBit The ordinal of the most significant bit in the bit field.
2807 @return The bit field read.
2820 Writes a bit field to a 64-bit value, and returns the result.
2822 Writes Value to the bit field specified by the StartBit and the EndBit in
2823 Operand. All other bits in Operand are preserved. The new 64-bit value is
2826 If 64-bit operations are not supported, then ASSERT().
2827 If StartBit is greater than 63, then ASSERT().
2828 If EndBit is greater than 63, then ASSERT().
2829 If EndBit is less than StartBit, then ASSERT().
2831 @param Operand Operand on which to perform the bitfield operation.
2832 @param StartBit The ordinal of the least significant bit in the bit field.
2834 @param EndBit The ordinal of the most significant bit in the bit field.
2836 @param Value New value of the bit field.
2838 @return The new 64-bit value.
2852 Reads a bit field from a 64-bit value, performs a bitwise OR, and returns the
2855 Performs a bitwise OR between the bit field specified by StartBit
2856 and EndBit in Operand and the value specified by OrData. All other bits in
2857 Operand are preserved. The new 64-bit value is returned.
2859 If 64-bit operations are not supported, then ASSERT().
2860 If StartBit is greater than 63, then ASSERT().
2861 If EndBit is greater than 63, then ASSERT().
2862 If EndBit is less than StartBit, then ASSERT().
2864 @param Operand Operand on which to perform the bitfield operation.
2865 @param StartBit The ordinal of the least significant bit in the bit field.
2867 @param EndBit The ordinal of the most significant bit in the bit field.
2869 @param OrData The value to OR with the read value from the value
2871 @return The new 64-bit value.
2885 Reads a bit field from a 64-bit value, performs a bitwise AND, and returns
2888 Performs a bitwise AND between the bit field specified by StartBit and EndBit
2889 in Operand and the value specified by AndData. All other bits in Operand are
2890 preserved. The new 64-bit value is returned.
2892 If 64-bit operations are not supported, then ASSERT().
2893 If StartBit is greater than 63, then ASSERT().
2894 If EndBit is greater than 63, then ASSERT().
2895 If EndBit is less than StartBit, then ASSERT().
2897 @param Operand Operand on which to perform the bitfield operation.
2898 @param StartBit The ordinal of the least significant bit in the bit field.
2900 @param EndBit The ordinal of the most significant bit in the bit field.
2902 @param AndData The value to AND with the read value from the value
2904 @return The new 64-bit value.
2918 Reads a bit field from a 64-bit value, performs a bitwise AND followed by a
2919 bitwise OR, and returns the result.
2921 Performs a bitwise AND between the bit field specified by StartBit and EndBit
2922 in Operand and the value specified by AndData, followed by a bitwise
2923 OR with value specified by OrData. All other bits in Operand are
2924 preserved. The new 64-bit value is returned.
2926 If 64-bit operations are not supported, then ASSERT().
2927 If StartBit is greater than 63, then ASSERT().
2928 If EndBit is greater than 63, then ASSERT().
2929 If EndBit is less than StartBit, then ASSERT().
2931 @param Operand Operand on which to perform the bitfield operation.
2932 @param StartBit The ordinal of the least significant bit in the bit field.
2934 @param EndBit The ordinal of the most significant bit in the bit field.
2936 @param AndData The value to AND with the read value from the value.
2937 @param OrData The value to OR with the result of the AND operation.
2939 @return The new 64-bit value.
2944 BitFieldAndThenOr64 (
2953 // Base Library Checksum Functions
2957 Returns the sum of all elements in a buffer in unit of UINT8.
2958 During calculation, the carry bits are dropped.
2960 This function calculates the sum of all elements in a buffer
2961 in unit of UINT8. The carry bits in result of addition are dropped.
2962 The result is returned as UINT8. If Length is Zero, then Zero is
2965 If Buffer is NULL, then ASSERT().
2966 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
2968 @param Buffer Pointer to the buffer to carry out the sum operation.
2969 @param Length The size, in bytes, of Buffer.
2971 @return Sum The sum of Buffer with carry bits dropped during additions.
2977 IN CONST UINT8
*Buffer
,
2983 Returns the two's complement checksum of all elements in a buffer
2986 This function first calculates the sum of the 8-bit values in the
2987 buffer specified by Buffer and Length. The carry bits in the result
2988 of addition are dropped. Then, the two's complement of the sum is
2989 returned. If Length is 0, then 0 is returned.
2991 If Buffer is NULL, then ASSERT().
2992 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
2994 @param Buffer Pointer to the buffer to carry out the checksum operation.
2995 @param Length The size, in bytes, of Buffer.
2997 @return Checksum The 2's complement checksum of Buffer.
3002 CalculateCheckSum8 (
3003 IN CONST UINT8
*Buffer
,
3009 Returns the sum of all elements in a buffer of 16-bit values. During
3010 calculation, the carry bits are dropped.
3012 This function calculates the sum of the 16-bit values in the buffer
3013 specified by Buffer and Length. The carry bits in result of addition are dropped.
3014 The 16-bit result is returned. If Length 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 sum operation.
3022 @param Length The size, in bytes, of Buffer.
3024 @return Sum The sum of Buffer with carry bits dropped during additions.
3030 IN CONST UINT16
*Buffer
,
3036 Returns the two's complement checksum of all elements in a buffer of
3039 This function first calculates the sum of the 16-bit values in the buffer
3040 specified by Buffer and Length. The carry bits in the result of addition
3041 are dropped. Then, the two's complement of the sum is returned. If Length
3042 is 0, then 0 is returned.
3044 If Buffer is NULL, then ASSERT().
3045 If Buffer is not aligned on a 16-bit boundary, then ASSERT().
3046 If Length is not aligned on a 16-bit boundary, then ASSERT().
3047 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
3049 @param Buffer Pointer to the buffer to carry out the checksum operation.
3050 @param Length The size, in bytes, of Buffer.
3052 @return Checksum The 2's complement checksum of Buffer.
3057 CalculateCheckSum16 (
3058 IN CONST UINT16
*Buffer
,
3064 Returns the sum of all elements in a buffer of 32-bit values. During
3065 calculation, the carry bits are dropped.
3067 This function calculates the sum of the 32-bit values in the buffer
3068 specified by Buffer and Length. The carry bits in result of addition are dropped.
3069 The 32-bit result is returned. If Length is 0, then 0 is returned.
3071 If Buffer is NULL, then ASSERT().
3072 If Buffer is not aligned on a 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 sum operation.
3077 @param Length The size, in bytes, of Buffer.
3079 @return Sum The sum of Buffer with carry bits dropped during additions.
3085 IN CONST UINT32
*Buffer
,
3091 Returns the two's complement checksum of all elements in a buffer of
3094 This function first calculates the sum of the 32-bit values in the buffer
3095 specified by Buffer and Length. The carry bits in the result of addition
3096 are dropped. Then, the two's complement of the sum is returned. If Length
3097 is 0, then 0 is returned.
3099 If Buffer is NULL, then ASSERT().
3100 If Buffer is not aligned on a 32-bit boundary, then ASSERT().
3101 If Length is not aligned on a 32-bit boundary, then ASSERT().
3102 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
3104 @param Buffer Pointer to the buffer to carry out the checksum operation.
3105 @param Length The size, in bytes, of Buffer.
3107 @return Checksum The 2's complement checksum of Buffer.
3112 CalculateCheckSum32 (
3113 IN CONST UINT32
*Buffer
,
3119 Returns the sum of all elements in a buffer of 64-bit values. During
3120 calculation, the carry bits are dropped.
3122 This function calculates the sum of the 64-bit values in the buffer
3123 specified by Buffer and Length. The carry bits in result of addition are dropped.
3124 The 64-bit result is returned. If Length is 0, then 0 is returned.
3126 If Buffer is NULL, then ASSERT().
3127 If Buffer is not aligned on a 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 sum operation.
3132 @param Length The size, in bytes, of Buffer.
3134 @return Sum The sum of Buffer with carry bits dropped during additions.
3140 IN CONST UINT64
*Buffer
,
3146 Returns the two's complement checksum of all elements in a buffer of
3149 This function first calculates the sum of the 64-bit values in the buffer
3150 specified by Buffer and Length. The carry bits in the result of addition
3151 are dropped. Then, the two's complement of the sum is returned. If Length
3152 is 0, then 0 is returned.
3154 If Buffer is NULL, then ASSERT().
3155 If Buffer is not aligned on a 64-bit boundary, then ASSERT().
3156 If Length is not aligned on a 64-bit boundary, then ASSERT().
3157 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
3159 @param Buffer Pointer to the buffer to carry out the checksum operation.
3160 @param Length The size, in bytes, of Buffer.
3162 @return Checksum The 2's complement checksum of Buffer.
3167 CalculateCheckSum64 (
3168 IN CONST UINT64
*Buffer
,
3174 // Base Library CPU Functions
3178 Function entry point used when a stack switch is requested with SwitchStack()
3180 @param Context1 Context1 parameter passed into SwitchStack().
3181 @param Context2 Context2 parameter passed into SwitchStack().
3186 (EFIAPI
*SWITCH_STACK_ENTRY_POINT
)(
3187 IN VOID
*Context1
, OPTIONAL
3188 IN VOID
*Context2 OPTIONAL
3193 Used to serialize load and store operations.
3195 All loads and stores that proceed calls to this function are guaranteed to be
3196 globally visible when this function returns.
3207 Saves the current CPU context that can be restored with a call to LongJump()
3210 Saves the current CPU context in the buffer specified by JumpBuffer and
3211 returns 0. The initial call to SetJump() must always return 0. Subsequent
3212 calls to LongJump() cause a non-zero value to be returned by SetJump().
3214 If JumpBuffer is NULL, then ASSERT().
3215 For Itanium processors, if JumpBuffer is not aligned on a 16-byte boundary, then ASSERT().
3217 NOTE: The structure BASE_LIBRARY_JUMP_BUFFER is CPU architecture specific.
3218 The same structure must never be used for more than one CPU architecture context.
3219 For example, a BASE_LIBRARY_JUMP_BUFFER allocated by an IA-32 module must never be used from an x64 module.
3220 SetJump()/LongJump() is not currently supported for the EBC processor type.
3222 @param JumpBuffer A pointer to CPU context buffer.
3224 @retval 0 Indicates a return from SetJump().
3230 OUT BASE_LIBRARY_JUMP_BUFFER
*JumpBuffer
3235 Restores the CPU context that was saved with SetJump().
3237 Restores the CPU context from the buffer specified by JumpBuffer. This
3238 function never returns to the caller. Instead is resumes execution based on
3239 the state of JumpBuffer.
3241 If JumpBuffer is NULL, then ASSERT().
3242 For Itanium processors, if JumpBuffer is not aligned on a 16-byte boundary, then ASSERT().
3243 If Value is 0, then ASSERT().
3245 @param JumpBuffer A pointer to CPU context buffer.
3246 @param Value The value to return when the SetJump() context is
3247 restored and must be non-zero.
3253 IN BASE_LIBRARY_JUMP_BUFFER
*JumpBuffer
,
3259 Enables CPU interrupts.
3270 Disables CPU interrupts.
3281 Disables CPU interrupts and returns the interrupt state prior to the disable
3284 @retval TRUE CPU interrupts were enabled on entry to this call.
3285 @retval FALSE CPU interrupts were disabled on entry to this call.
3290 SaveAndDisableInterrupts (
3296 Enables CPU interrupts for the smallest window required to capture any
3302 EnableDisableInterrupts (
3308 Retrieves the current CPU interrupt state.
3310 Returns TRUE is interrupts are currently enabled. Otherwise
3313 @retval TRUE CPU interrupts are enabled.
3314 @retval FALSE CPU interrupts are disabled.
3325 Set the current CPU interrupt state.
3327 Sets the current CPU interrupt state to the state specified by
3328 InterruptState. If InterruptState is TRUE, then interrupts are enabled. If
3329 InterruptState is FALSE, then interrupts are disabled. InterruptState is
3332 @param InterruptState TRUE if interrupts should enabled. FALSE if
3333 interrupts should be disabled.
3335 @return InterruptState
3341 IN BOOLEAN InterruptState
3346 Requests CPU to pause for a short period of time.
3348 Requests CPU to pause for a short period of time. Typically used in MP
3349 systems to prevent memory starvation while waiting for a spin lock.
3360 Transfers control to a function starting with a new stack.
3362 Transfers control to the function specified by EntryPoint using the
3363 new stack specified by NewStack and passing in the parameters specified
3364 by Context1 and Context2. Context1 and Context2 are optional and may
3365 be NULL. The function EntryPoint must never return. This function
3366 supports a variable number of arguments following the NewStack parameter.
3367 These additional arguments are ignored on IA-32, x64, and EBC architectures.
3368 Itanium processors expect one additional parameter of type VOID * that specifies
3369 the new backing store pointer.
3371 If EntryPoint is NULL, then ASSERT().
3372 If NewStack is NULL, then ASSERT().
3374 @param EntryPoint A pointer to function to call with the new stack.
3375 @param Context1 A pointer to the context to pass into the EntryPoint
3377 @param Context2 A pointer to the context to pass into the EntryPoint
3379 @param NewStack A pointer to the new stack to use for the EntryPoint
3381 @param ... This variable argument list is ignored for IA-32, x64, and EBC architectures.
3382 For Itanium processors, this variable argument list is expected to contain
3383 a single parameter of type VOID * that specifies the new backing
3391 IN SWITCH_STACK_ENTRY_POINT EntryPoint
,
3392 IN VOID
*Context1
, OPTIONAL
3393 IN VOID
*Context2
, OPTIONAL
3400 Generates a breakpoint on the CPU.
3402 Generates a breakpoint on the CPU. The breakpoint must be implemented such
3403 that code can resume normal execution after the breakpoint.
3414 Executes an infinite loop.
3416 Forces the CPU to execute an infinite loop. A debugger may be used to skip
3417 past the loop and the code that follows the loop must execute properly. This
3418 implies that the infinite loop must not cause the code that follow it to be
3428 #if defined (MDE_CPU_IPF)
3431 Flush a range of cache lines in the cache coherency domain of the calling
3434 Flushes the cache lines specified by Address and Length. If Address is not aligned
3435 on a cache line boundary, then entire cache line containing Address is flushed.
3436 If Address + Length is not aligned on a cache line boundary, then the entire cache
3437 line containing Address + Length - 1 is flushed. This function may choose to flush
3438 the entire cache if that is more efficient than flushing the specified range. If
3439 Length is 0, the no cache lines are flushed. Address is returned.
3440 This function is only available on Itanium processors.
3442 If Length is greater than (MAX_ADDRESS - Address + 1), then ASSERT().
3444 @param Address The base address of the instruction lines to invalidate. If
3445 the CPU is in a physical addressing mode, then Address is a
3446 physical address. If the CPU is in a virtual addressing mode,
3447 then Address is a virtual address.
3449 @param Length The number of bytes to invalidate from the instruction cache.
3456 AsmFlushCacheRange (
3463 Executes a FC instruction
3464 Executes a FC instruction on the cache line specified by Address.
3465 The cache line size affected is at least 32-bytes (aligned on a 32-byte boundary).
3466 An implementation may flush a larger region. This function is only available on Itanium processors.
3468 @param Address The Address of cache line to be flushed.
3470 @return The address of FC instruction executed.
3481 Executes a FC.I instruction.
3482 Executes a FC.I instruction on the cache line specified by Address.
3483 The cache line size affected is at least 32-bytes (aligned on a 32-byte boundary).
3484 An implementation may flush a larger region. This function is only available on Itanium processors.
3486 @param Address The Address of cache line to be flushed.
3488 @return The address of FC.I instruction executed.
3499 Reads the current value of a Processor Identifier Register (CPUID).
3501 Reads and returns the current value of Processor Identifier Register specified by Index.
3502 The Index of largest implemented CPUID (One less than the number of implemented CPUID
3503 registers) is determined by CPUID [3] bits {7:0}.
3504 No parameter checking is performed on Index. If the Index value is beyond the
3505 implemented CPUID register range, a Reserved Register/Field fault may occur. The caller
3506 must either guarantee that Index is valid, or the caller must set up fault handlers to
3507 catch the faults. This function is only available on Itanium processors.
3509 @param Index The 8-bit Processor Identifier Register index to read.
3511 @return The current value of Processor Identifier Register specified by Index.
3522 Reads the current value of 64-bit Processor Status Register (PSR).
3523 This function is only available on Itanium processors.
3525 @return The current value of PSR.
3536 Writes the current value of 64-bit Processor Status Register (PSR).
3538 No parameter checking is performed on Value. All bits of Value corresponding to
3539 reserved fields of PSR must be 0 or a Reserved Register/Field fault may occur.
3540 The caller must either guarantee that Value is valid, or the caller must set up
3541 fault handlers to catch the faults. This function is only available on Itanium processors.
3543 @param Value The 64-bit value to write to PSR.
3545 @return The 64-bit value written to the PSR.
3556 Reads the current value of 64-bit Kernel Register #0 (KR0).
3558 Reads and returns the current value of KR0.
3559 This function is only available on Itanium processors.
3561 @return The current value of KR0.
3572 Reads the current value of 64-bit Kernel Register #1 (KR1).
3574 Reads and returns the current value of KR1.
3575 This function is only available on Itanium processors.
3577 @return The current value of KR1.
3588 Reads the current value of 64-bit Kernel Register #2 (KR2).
3590 Reads and returns the current value of KR2.
3591 This function is only available on Itanium processors.
3593 @return The current value of KR2.
3604 Reads the current value of 64-bit Kernel Register #3 (KR3).
3606 Reads and returns the current value of KR3.
3607 This function is only available on Itanium processors.
3609 @return The current value of KR3.
3620 Reads the current value of 64-bit Kernel Register #4 (KR4).
3622 Reads and returns the current value of KR4.
3623 This function is only available on Itanium processors.
3625 @return The current value of KR4.
3636 Reads the current value of 64-bit Kernel Register #5 (KR5).
3638 Reads and returns the current value of KR5.
3639 This function is only available on Itanium processors.
3641 @return The current value of KR5.
3652 Reads the current value of 64-bit Kernel Register #6 (KR6).
3654 Reads and returns the current value of KR6.
3655 This function is only available on Itanium processors.
3657 @return The current value of KR6.
3668 Reads the current value of 64-bit Kernel Register #7 (KR7).
3670 Reads and returns the current value of KR7.
3671 This function is only available on Itanium processors.
3673 @return The current value of KR7.
3684 Write the current value of 64-bit Kernel Register #0 (KR0).
3686 Writes the current value of KR0. The 64-bit value written to
3687 the KR0 is returned. This function is only available on Itanium processors.
3689 @param Value The 64-bit value to write to KR0.
3691 @return The 64-bit value written to the KR0.
3702 Write the current value of 64-bit Kernel Register #1 (KR1).
3704 Writes the current value of KR1. The 64-bit value written to
3705 the KR1 is returned. This function is only available on Itanium processors.
3707 @param Value The 64-bit value to write to KR1.
3709 @return The 64-bit value written to the KR1.
3720 Write the current value of 64-bit Kernel Register #2 (KR2).
3722 Writes the current value of KR2. The 64-bit value written to
3723 the KR2 is returned. This function is only available on Itanium processors.
3725 @param Value The 64-bit value to write to KR2.
3727 @return The 64-bit value written to the KR2.
3738 Write the current value of 64-bit Kernel Register #3 (KR3).
3740 Writes the current value of KR3. The 64-bit value written to
3741 the KR3 is returned. This function is only available on Itanium processors.
3743 @param Value The 64-bit value to write to KR3.
3745 @return The 64-bit value written to the KR3.
3756 Write the current value of 64-bit Kernel Register #4 (KR4).
3758 Writes the current value of KR4. The 64-bit value written to
3759 the KR4 is returned. This function is only available on Itanium processors.
3761 @param Value The 64-bit value to write to KR4.
3763 @return The 64-bit value written to the KR4.
3774 Write the current value of 64-bit Kernel Register #5 (KR5).
3776 Writes the current value of KR5. The 64-bit value written to
3777 the KR5 is returned. This function is only available on Itanium processors.
3779 @param Value The 64-bit value to write to KR5.
3781 @return The 64-bit value written to the KR5.
3792 Write the current value of 64-bit Kernel Register #6 (KR6).
3794 Writes the current value of KR6. The 64-bit value written to
3795 the KR6 is returned. This function is only available on Itanium processors.
3797 @param Value The 64-bit value to write to KR6.
3799 @return The 64-bit value written to the KR6.
3810 Write the current value of 64-bit Kernel Register #7 (KR7).
3812 Writes the current value of KR7. The 64-bit value written to
3813 the KR7 is returned. This function is only available on Itanium processors.
3815 @param Value The 64-bit value to write to KR7.
3817 @return The 64-bit value written to the KR7.
3828 Reads the current value of Interval Timer Counter Register (ITC).
3830 Reads and returns the current value of ITC.
3831 This function is only available on Itanium processors.
3833 @return The current value of ITC.
3844 Reads the current value of Interval Timer Vector Register (ITV).
3846 Reads and returns the current value of ITV.
3847 This function is only available on Itanium processors.
3849 @return The current value of ITV.
3860 Reads the current value of Interval Timer Match Register (ITM).
3862 Reads and returns the current value of ITM.
3863 This function is only available on Itanium processors.
3865 @return The current value of ITM.
3875 Writes the current value of 64-bit Interval Timer Counter Register (ITC).
3877 Writes the current value of ITC. The 64-bit value written to the ITC is returned.
3878 This function is only available on Itanium processors.
3880 @param Value The 64-bit value to write to ITC.
3882 @return The 64-bit value written to the ITC.
3893 Writes the current value of 64-bit Interval Timer Match Register (ITM).
3895 Writes the current value of ITM. The 64-bit value written to the ITM is returned.
3896 This function is only available on Itanium processors.
3898 @param Value The 64-bit value to write to ITM.
3900 @return The 64-bit value written to the ITM.
3911 Writes the current value of 64-bit Interval Timer Vector Register (ITV).
3913 Writes the current value of ITV. The 64-bit value written to the ITV is returned.
3914 No parameter checking is performed on Value. All bits of Value corresponding to
3915 reserved fields of ITV must be 0 or a Reserved Register/Field fault may occur.
3916 The caller must either guarantee that Value is valid, or the caller must set up
3917 fault handlers to catch the faults.
3918 This function is only available on Itanium processors.
3920 @param Value The 64-bit value to write to ITV.
3922 @return The 64-bit value written to the ITV.
3933 Reads the current value of Default Control Register (DCR).
3935 Reads and returns the current value of DCR. This function is only available on Itanium processors.
3937 @return The current value of DCR.
3948 Reads the current value of Interruption Vector Address Register (IVA).
3950 Reads and returns the current value of IVA. This function is only available on Itanium processors.
3952 @return The current value of IVA.
3962 Reads the current value of Page Table Address Register (PTA).
3964 Reads and returns the current value of PTA. This function is only available on Itanium processors.
3966 @return The current value of PTA.
3977 Writes the current value of 64-bit Default Control Register (DCR).
3979 Writes the current value of DCR. The 64-bit value written to the DCR is returned.
3980 No parameter checking is performed on Value. All bits of Value corresponding to
3981 reserved fields of DCR must be 0 or a Reserved Register/Field fault may occur.
3982 The caller must either guarantee that Value is valid, or the caller must set up
3983 fault handlers to catch the faults.
3984 This function is only available on Itanium processors.
3986 @param Value The 64-bit value to write to DCR.
3988 @return The 64-bit value written to the DCR.
3999 Writes the current value of 64-bit Interruption Vector Address Register (IVA).
4001 Writes the current value of IVA. The 64-bit value written to the IVA is returned.
4002 The size of vector table is 32 K bytes and is 32 K bytes aligned
4003 the low 15 bits of Value is ignored when written.
4004 This function is only available on Itanium processors.
4006 @param Value The 64-bit value to write to IVA.
4008 @return The 64-bit value written to the IVA.
4019 Writes the current value of 64-bit Page Table Address Register (PTA).
4021 Writes the current value of PTA. The 64-bit value written to the PTA is returned.
4022 No parameter checking is performed on Value. All bits of Value corresponding to
4023 reserved fields of DCR must be 0 or a Reserved Register/Field fault may occur.
4024 The caller must either guarantee that Value is valid, or the caller must set up
4025 fault handlers to catch the faults.
4026 This function is only available on Itanium processors.
4028 @param Value The 64-bit value to write to PTA.
4030 @return The 64-bit value written to the PTA.
4040 Reads the current value of Local Interrupt ID Register (LID).
4042 Reads and returns the current value of LID. This function is only available on Itanium processors.
4044 @return The current value of LID.
4055 Reads the current value of External Interrupt Vector Register (IVR).
4057 Reads and returns the current value of IVR. This function is only available on Itanium processors.
4059 @return The current value of IVR.
4070 Reads the current value of Task Priority Register (TPR).
4072 Reads and returns the current value of TPR. This function is only available on Itanium processors.
4074 @return The current value of TPR.
4085 Reads the current value of External Interrupt Request Register #0 (IRR0).
4087 Reads and returns the current value of IRR0. This function is only available on Itanium processors.
4089 @return The current value of IRR0.
4100 Reads the current value of External Interrupt Request Register #1 (IRR1).
4102 Reads and returns the current value of IRR1. This function is only available on Itanium processors.
4104 @return The current value of IRR1.
4115 Reads the current value of External Interrupt Request Register #2 (IRR2).
4117 Reads and returns the current value of IRR2. This function is only available on Itanium processors.
4119 @return The current value of IRR2.
4130 Reads the current value of External Interrupt Request Register #3 (IRR3).
4132 Reads and returns the current value of IRR3. This function is only available on Itanium processors.
4134 @return The current value of IRR3.
4145 Reads the current value of Performance Monitor Vector Register (PMV).
4147 Reads and returns the current value of PMV. This function is only available on Itanium processors.
4149 @return The current value of PMV.
4160 Reads the current value of Corrected Machine Check Vector Register (CMCV).
4162 Reads and returns the current value of CMCV. This function is only available on Itanium processors.
4164 @return The current value of CMCV.
4175 Reads the current value of Local Redirection Register #0 (LRR0).
4177 Reads and returns the current value of LRR0. This function is only available on Itanium processors.
4179 @return The current value of LRR0.
4190 Reads the current value of Local Redirection Register #1 (LRR1).
4192 Reads and returns the current value of LRR1. This function is only available on Itanium processors.
4194 @return The current value of LRR1.
4205 Writes the current value of 64-bit Page Local Interrupt ID Register (LID).
4207 Writes the current value of LID. The 64-bit value written to the LID is returned.
4208 No parameter checking is performed on Value. All bits of Value corresponding to
4209 reserved fields of LID must be 0 or a Reserved Register/Field fault may occur.
4210 The caller must either guarantee that Value is valid, or the caller must set up
4211 fault handlers to catch the faults.
4212 This function is only available on Itanium processors.
4214 @param Value The 64-bit value to write to LID.
4216 @return The 64-bit value written to the LID.
4227 Writes the current value of 64-bit Task Priority Register (TPR).
4229 Writes the current value of TPR. The 64-bit value written to the TPR is returned.
4230 No parameter checking is performed on Value. All bits of Value corresponding to
4231 reserved fields of TPR must be 0 or a Reserved Register/Field fault may occur.
4232 The caller must either guarantee that Value is valid, or the caller must set up
4233 fault handlers to catch the faults.
4234 This function is only available on Itanium processors.
4236 @param Value The 64-bit value to write to TPR.
4238 @return The 64-bit value written to the TPR.
4249 Performs a write operation on End OF External Interrupt Register (EOI).
4251 Writes a value of 0 to the EOI Register. This function is only available on Itanium processors.
4262 Writes the current value of 64-bit Performance Monitor Vector Register (PMV).
4264 Writes the current value of PMV. The 64-bit value written to the PMV is returned.
4265 No parameter checking is performed on Value. All bits of Value corresponding
4266 to reserved fields of PMV must be 0 or a Reserved Register/Field fault may occur.
4267 The caller must either guarantee that Value is valid, or the caller must set up
4268 fault handlers to catch the faults.
4269 This function is only available on Itanium processors.
4271 @param Value The 64-bit value to write to PMV.
4273 @return The 64-bit value written to the PMV.
4284 Writes the current value of 64-bit Corrected Machine Check Vector Register (CMCV).
4286 Writes the current value of CMCV. The 64-bit value written to the CMCV is returned.
4287 No parameter checking is performed on Value. All bits of Value corresponding
4288 to reserved fields of CMCV must be 0 or a Reserved Register/Field fault may occur.
4289 The caller must either guarantee that Value is valid, or the caller must set up
4290 fault handlers to catch the faults.
4291 This function is only available on Itanium processors.
4293 @param Value The 64-bit value to write to CMCV.
4295 @return The 64-bit value written to the CMCV.
4306 Writes the current value of 64-bit Local Redirection Register #0 (LRR0).
4308 Writes the current value of LRR0. The 64-bit value written to the LRR0 is returned.
4309 No parameter checking is performed on Value. All bits of Value corresponding
4310 to reserved fields of LRR0 must be 0 or a Reserved Register/Field fault may occur.
4311 The caller must either guarantee that Value is valid, or the caller must set up
4312 fault handlers to catch the faults.
4313 This function is only available on Itanium processors.
4315 @param Value The 64-bit value to write to LRR0.
4317 @return The 64-bit value written to the LRR0.
4328 Writes the current value of 64-bit Local Redirection Register #1 (LRR1).
4330 Writes the current value of LRR1. The 64-bit value written to the LRR1 is returned.
4331 No parameter checking is performed on Value. All bits of Value corresponding
4332 to reserved fields of LRR1 must be 0 or a Reserved Register/Field fault may occur.
4333 The caller must either guarantee that Value is valid, or the caller must
4334 set up fault handlers to catch the faults.
4335 This function is only available on Itanium processors.
4337 @param Value The 64-bit value to write to LRR1.
4339 @return The 64-bit value written to the LRR1.
4350 Reads the current value of Instruction Breakpoint Register (IBR).
4352 The Instruction Breakpoint Registers are used in pairs. The even numbered
4353 registers contain breakpoint addresses, and the odd numbered registers contain
4354 breakpoint mask conditions. At least 4 instruction registers pairs are implemented
4355 on all processor models. Implemented registers are contiguous starting with
4356 register 0. No parameter checking is performed on Index, and if the Index value
4357 is beyond the implemented IBR register range, a Reserved Register/Field fault may
4358 occur. The caller must either guarantee that Index is valid, or the caller must
4359 set up fault handlers to catch the faults.
4360 This function is only available on Itanium processors.
4362 @param Index The 8-bit Instruction Breakpoint Register index to read.
4364 @return The current value of Instruction Breakpoint Register specified by Index.
4375 Reads the current value of Data Breakpoint Register (DBR).
4377 The Data Breakpoint Registers are used in pairs. The even numbered registers
4378 contain breakpoint addresses, and odd numbered registers contain breakpoint
4379 mask conditions. At least 4 data registers pairs are implemented on all processor
4380 models. Implemented registers are contiguous starting with register 0.
4381 No parameter checking is performed on Index. If the Index value is beyond
4382 the implemented DBR register range, a Reserved Register/Field fault may occur.
4383 The caller must either guarantee that Index is valid, or the caller must set up
4384 fault handlers to catch the faults.
4385 This function is only available on Itanium processors.
4387 @param Index The 8-bit Data Breakpoint Register index to read.
4389 @return The current value of Data Breakpoint Register specified by Index.
4400 Reads the current value of Performance Monitor Configuration Register (PMC).
4402 All processor implementations provide at least 4 performance counters
4403 (PMC/PMD [4]...PMC/PMD [7] pairs), and 4 performance monitor counter overflow
4404 status registers (PMC [0]... PMC [3]). Processor implementations may provide
4405 additional implementation-dependent PMC and PMD to increase the number of
4406 'generic' performance counters (PMC/PMD pairs). The remainder of PMC and PMD
4407 register set is implementation dependent. No parameter checking is performed
4408 on Index. If the Index value is beyond the implemented PMC register range,
4409 zero value will be returned.
4410 This function is only available on Itanium processors.
4412 @param Index The 8-bit Performance Monitor Configuration Register index to read.
4414 @return The current value of Performance Monitor Configuration Register
4426 Reads the current value of Performance Monitor Data Register (PMD).
4428 All processor implementations provide at least 4 performance counters
4429 (PMC/PMD [4]...PMC/PMD [7] pairs), and 4 performance monitor counter
4430 overflow status registers (PMC [0]... PMC [3]). Processor implementations may
4431 provide additional implementation-dependent PMC and PMD to increase the number
4432 of 'generic' performance counters (PMC/PMD pairs). The remainder of PMC and PMD
4433 register set is implementation dependent. No parameter checking is performed
4434 on Index. If the Index value is beyond the implemented PMD register range,
4435 zero value will be returned.
4436 This function is only available on Itanium processors.
4438 @param Index The 8-bit Performance Monitor Data Register index to read.
4440 @return The current value of Performance Monitor Data Register specified by Index.
4451 Writes the current value of 64-bit Instruction Breakpoint Register (IBR).
4453 Writes current value of Instruction Breakpoint Register specified by Index.
4454 The Instruction Breakpoint Registers are used in pairs. The even numbered
4455 registers contain breakpoint addresses, and odd numbered registers contain
4456 breakpoint mask conditions. At least 4 instruction registers pairs are implemented
4457 on all processor models. Implemented registers are contiguous starting with
4458 register 0. No parameter checking is performed on Index. If the Index value
4459 is beyond the implemented IBR register range, a Reserved Register/Field fault may
4460 occur. The caller must either guarantee that Index is valid, or the caller must
4461 set up fault handlers to catch the faults.
4462 This function is only available on Itanium processors.
4464 @param Index The 8-bit Instruction Breakpoint Register index to write.
4465 @param Value The 64-bit value to write to IBR.
4467 @return The 64-bit value written to the IBR.
4479 Writes the current value of 64-bit Data Breakpoint Register (DBR).
4481 Writes current value of Data Breakpoint Register specified by Index.
4482 The Data Breakpoint Registers are used in pairs. The even numbered registers
4483 contain breakpoint addresses, and odd numbered registers contain breakpoint
4484 mask conditions. At least 4 data registers pairs are implemented on all processor
4485 models. Implemented registers are contiguous starting with register 0. No parameter
4486 checking is performed on Index. If the Index value is beyond the implemented
4487 DBR register range, a Reserved Register/Field fault may occur. The caller must
4488 either guarantee that Index is valid, or the caller must set up fault handlers to
4490 This function is only available on Itanium processors.
4492 @param Index The 8-bit Data Breakpoint Register index to write.
4493 @param Value The 64-bit value to write to DBR.
4495 @return The 64-bit value written to the DBR.
4507 Writes the current value of 64-bit Performance Monitor Configuration Register (PMC).
4509 Writes current value of Performance Monitor Configuration Register specified by Index.
4510 All processor implementations provide at least 4 performance counters
4511 (PMC/PMD [4]...PMC/PMD [7] pairs), and 4 performance monitor counter overflow status
4512 registers (PMC [0]... PMC [3]). Processor implementations may provide additional
4513 implementation-dependent PMC and PMD to increase the number of 'generic' performance
4514 counters (PMC/PMD pairs). The remainder of PMC and PMD register set is implementation
4515 dependent. No parameter checking is performed on Index. If the Index value is
4516 beyond the implemented PMC register range, the write is ignored.
4517 This function is only available on Itanium processors.
4519 @param Index The 8-bit Performance Monitor Configuration Register index to write.
4520 @param Value The 64-bit value to write to PMC.
4522 @return The 64-bit value written to the PMC.
4534 Writes the current value of 64-bit Performance Monitor Data Register (PMD).
4536 Writes current value of Performance Monitor Data Register specified by Index.
4537 All processor implementations provide at least 4 performance counters
4538 (PMC/PMD [4]...PMC/PMD [7] pairs), and 4 performance monitor counter overflow
4539 status registers (PMC [0]... PMC [3]). Processor implementations may provide
4540 additional implementation-dependent PMC and PMD to increase the number of 'generic'
4541 performance counters (PMC/PMD pairs). The remainder of PMC and PMD register set
4542 is implementation dependent. No parameter checking is performed on Index. If the
4543 Index value is beyond the implemented PMD register range, the write is ignored.
4544 This function is only available on Itanium processors.
4546 @param Index The 8-bit Performance Monitor Data Register index to write.
4547 @param Value The 64-bit value to write to PMD.
4549 @return The 64-bit value written to the PMD.
4561 Reads the current value of 64-bit Global Pointer (GP).
4563 Reads and returns the current value of GP.
4564 This function is only available on Itanium processors.
4566 @return The current value of GP.
4577 Write the current value of 64-bit Global Pointer (GP).
4579 Writes the current value of GP. The 64-bit value written to the GP is returned.
4580 No parameter checking is performed on Value.
4581 This function is only available on Itanium processors.
4583 @param Value The 64-bit value to write to GP.
4585 @return The 64-bit value written to the GP.
4596 Reads the current value of 64-bit Stack Pointer (SP).
4598 Reads and returns the current value of SP.
4599 This function is only available on Itanium processors.
4601 @return The current value of SP.
4612 /// Valid Index value for AsmReadControlRegister()
4614 #define IPF_CONTROL_REGISTER_DCR 0
4615 #define IPF_CONTROL_REGISTER_ITM 1
4616 #define IPF_CONTROL_REGISTER_IVA 2
4617 #define IPF_CONTROL_REGISTER_PTA 8
4618 #define IPF_CONTROL_REGISTER_IPSR 16
4619 #define IPF_CONTROL_REGISTER_ISR 17
4620 #define IPF_CONTROL_REGISTER_IIP 19
4621 #define IPF_CONTROL_REGISTER_IFA 20
4622 #define IPF_CONTROL_REGISTER_ITIR 21
4623 #define IPF_CONTROL_REGISTER_IIPA 22
4624 #define IPF_CONTROL_REGISTER_IFS 23
4625 #define IPF_CONTROL_REGISTER_IIM 24
4626 #define IPF_CONTROL_REGISTER_IHA 25
4627 #define IPF_CONTROL_REGISTER_LID 64
4628 #define IPF_CONTROL_REGISTER_IVR 65
4629 #define IPF_CONTROL_REGISTER_TPR 66
4630 #define IPF_CONTROL_REGISTER_EOI 67
4631 #define IPF_CONTROL_REGISTER_IRR0 68
4632 #define IPF_CONTROL_REGISTER_IRR1 69
4633 #define IPF_CONTROL_REGISTER_IRR2 70
4634 #define IPF_CONTROL_REGISTER_IRR3 71
4635 #define IPF_CONTROL_REGISTER_ITV 72
4636 #define IPF_CONTROL_REGISTER_PMV 73
4637 #define IPF_CONTROL_REGISTER_CMCV 74
4638 #define IPF_CONTROL_REGISTER_LRR0 80
4639 #define IPF_CONTROL_REGISTER_LRR1 81
4642 Reads a 64-bit control register.
4644 Reads and returns the control register specified by Index. The valid Index valued are defined
4645 above in "Related Definitions".
4646 If Index is invalid then 0xFFFFFFFFFFFFFFFF is returned. This function is only available on Itanium processors.
4648 @param Index The index of the control register to read.
4650 @return The control register specified by Index.
4655 AsmReadControlRegister (
4661 /// Valid Index value for AsmReadApplicationRegister()
4663 #define IPF_APPLICATION_REGISTER_K0 0
4664 #define IPF_APPLICATION_REGISTER_K1 1
4665 #define IPF_APPLICATION_REGISTER_K2 2
4666 #define IPF_APPLICATION_REGISTER_K3 3
4667 #define IPF_APPLICATION_REGISTER_K4 4
4668 #define IPF_APPLICATION_REGISTER_K5 5
4669 #define IPF_APPLICATION_REGISTER_K6 6
4670 #define IPF_APPLICATION_REGISTER_K7 7
4671 #define IPF_APPLICATION_REGISTER_RSC 16
4672 #define IPF_APPLICATION_REGISTER_BSP 17
4673 #define IPF_APPLICATION_REGISTER_BSPSTORE 18
4674 #define IPF_APPLICATION_REGISTER_RNAT 19
4675 #define IPF_APPLICATION_REGISTER_FCR 21
4676 #define IPF_APPLICATION_REGISTER_EFLAG 24
4677 #define IPF_APPLICATION_REGISTER_CSD 25
4678 #define IPF_APPLICATION_REGISTER_SSD 26
4679 #define IPF_APPLICATION_REGISTER_CFLG 27
4680 #define IPF_APPLICATION_REGISTER_FSR 28
4681 #define IPF_APPLICATION_REGISTER_FIR 29
4682 #define IPF_APPLICATION_REGISTER_FDR 30
4683 #define IPF_APPLICATION_REGISTER_CCV 32
4684 #define IPF_APPLICATION_REGISTER_UNAT 36
4685 #define IPF_APPLICATION_REGISTER_FPSR 40
4686 #define IPF_APPLICATION_REGISTER_ITC 44
4687 #define IPF_APPLICATION_REGISTER_PFS 64
4688 #define IPF_APPLICATION_REGISTER_LC 65
4689 #define IPF_APPLICATION_REGISTER_EC 66
4692 Reads a 64-bit application register.
4694 Reads and returns the application register specified by Index. The valid Index valued are defined
4695 above in "Related Definitions".
4696 If Index is invalid then 0xFFFFFFFFFFFFFFFF is returned. This function is only available on Itanium processors.
4698 @param Index The index of the application register to read.
4700 @return The application register specified by Index.
4705 AsmReadApplicationRegister (
4711 Reads the current value of a Machine Specific Register (MSR).
4713 Reads and returns the current value of the Machine Specific Register specified by Index. No
4714 parameter checking is performed on Index, and if the Index value is beyond the implemented MSR
4715 register range, a Reserved Register/Field fault may occur. The caller must either guarantee that
4716 Index is valid, or the caller must set up fault handlers to catch the faults. This function is
4717 only available on Itanium processors.
4719 @param Index The 8-bit Machine Specific Register index to read.
4721 @return The current value of the Machine Specific Register specified by Index.
4732 Writes the current value of a Machine Specific Register (MSR).
4734 Writes Value to the Machine Specific Register specified by Index. Value is returned. No
4735 parameter checking is performed on Index, and if the Index value is beyond the implemented MSR
4736 register range, a Reserved Register/Field fault may occur. The caller must either guarantee that
4737 Index is valid, or the caller must set up fault handlers to catch the faults. This function is
4738 only available on Itanium processors.
4740 @param Index The 8-bit Machine Specific Register index to write.
4741 @param Value The 64-bit value to write to the Machine Specific Register.
4743 @return The 64-bit value to write to the Machine Specific Register.
4755 Determines if the CPU is currently executing in virtual, physical, or mixed mode.
4757 Determines the current execution mode of the CPU.
4758 If the CPU is in virtual mode(PSR.RT=1, PSR.DT=1, PSR.IT=1), then 1 is returned.
4759 If the CPU is in physical mode(PSR.RT=0, PSR.DT=0, PSR.IT=0), then 0 is returned.
4760 If the CPU is not in physical mode or virtual mode, then it is in mixed mode,
4762 This function is only available on Itanium processors.
4764 @retval 1 The CPU is in virtual mode.
4765 @retval 0 The CPU is in physical mode.
4766 @retval -1 The CPU is in mixed mode.
4777 Makes a PAL procedure call.
4779 This is a wrapper function to make a PAL procedure call. Based on the Index
4780 value this API will make static or stacked PAL call. The following table
4781 describes the usage of PAL Procedure Index Assignment. Architected procedures
4782 may be designated as required or optional. If a PAL procedure is specified
4783 as optional, a unique return code of 0xFFFFFFFFFFFFFFFF is returned in the
4784 Status field of the PAL_CALL_RETURN structure.
4785 This indicates that the procedure is not present in this PAL implementation.
4786 It is the caller's responsibility to check for this return code after calling
4787 any optional PAL procedure.
4788 No parameter checking is performed on the 5 input parameters, but there are
4789 some common rules that the caller should follow when making a PAL call. Any
4790 address passed to PAL as buffers for return parameters must be 8-byte aligned.
4791 Unaligned addresses may cause undefined results. For those parameters defined
4792 as reserved or some fields defined as reserved must be zero filled or the invalid
4793 argument return value may be returned or undefined result may occur during the
4794 execution of the procedure. If the PalEntryPoint does not point to a valid
4795 PAL entry point then the system behavior is undefined. This function is only
4796 available on Itanium processors.
4798 @param PalEntryPoint The PAL procedure calls entry point.
4799 @param Index The PAL procedure Index number.
4800 @param Arg2 The 2nd parameter for PAL procedure calls.
4801 @param Arg3 The 3rd parameter for PAL procedure calls.
4802 @param Arg4 The 4th parameter for PAL procedure calls.
4804 @return structure returned from the PAL Call procedure, including the status and return value.
4810 IN UINT64 PalEntryPoint
,
4818 #if defined (MDE_CPU_IA32) || defined (MDE_CPU_X64)
4820 /// IA32 and x64 Specific Functions
4821 /// Byte packed structure for 16-bit Real Mode EFLAGS
4825 UINT32 CF
:1; ///< Carry Flag
4826 UINT32 Reserved_0
:1; ///< Reserved
4827 UINT32 PF
:1; ///< Parity Flag
4828 UINT32 Reserved_1
:1; ///< Reserved
4829 UINT32 AF
:1; ///< Auxiliary Carry Flag
4830 UINT32 Reserved_2
:1; ///< Reserved
4831 UINT32 ZF
:1; ///< Zero Flag
4832 UINT32 SF
:1; ///< Sign Flag
4833 UINT32 TF
:1; ///< Trap Flag
4834 UINT32 IF
:1; ///< Interrupt Enable Flag
4835 UINT32 DF
:1; ///< Direction Flag
4836 UINT32 OF
:1; ///< Overflow Flag
4837 UINT32 IOPL
:2; ///< I/O Privilege Level
4838 UINT32 NT
:1; ///< Nested Task
4839 UINT32 Reserved_3
:1; ///< Reserved
4845 /// Byte packed structure for EFLAGS/RFLAGS
4846 /// 32-bits on IA-32
4847 /// 64-bits on x64. The upper 32-bits on x64 are reserved
4851 UINT32 CF
:1; ///< Carry Flag
4852 UINT32 Reserved_0
:1; ///< Reserved
4853 UINT32 PF
:1; ///< Parity Flag
4854 UINT32 Reserved_1
:1; ///< Reserved
4855 UINT32 AF
:1; ///< Auxiliary Carry Flag
4856 UINT32 Reserved_2
:1; ///< Reserved
4857 UINT32 ZF
:1; ///< Zero Flag
4858 UINT32 SF
:1; ///< Sign Flag
4859 UINT32 TF
:1; ///< Trap Flag
4860 UINT32 IF
:1; ///< Interrupt Enable Flag
4861 UINT32 DF
:1; ///< Direction Flag
4862 UINT32 OF
:1; ///< Overflow Flag
4863 UINT32 IOPL
:2; ///< I/O Privilege Level
4864 UINT32 NT
:1; ///< Nested Task
4865 UINT32 Reserved_3
:1; ///< Reserved
4866 UINT32 RF
:1; ///< Resume Flag
4867 UINT32 VM
:1; ///< Virtual 8086 Mode
4868 UINT32 AC
:1; ///< Alignment Check
4869 UINT32 VIF
:1; ///< Virtual Interrupt Flag
4870 UINT32 VIP
:1; ///< Virtual Interrupt Pending
4871 UINT32 ID
:1; ///< ID Flag
4872 UINT32 Reserved_4
:10; ///< Reserved
4878 /// Byte packed structure for Control Register 0 (CR0)
4879 /// 32-bits on IA-32
4880 /// 64-bits on x64. The upper 32-bits on x64 are reserved
4884 UINT32 PE
:1; ///< Protection Enable
4885 UINT32 MP
:1; ///< Monitor Coprocessor
4886 UINT32 EM
:1; ///< Emulation
4887 UINT32 TS
:1; ///< Task Switched
4888 UINT32 ET
:1; ///< Extension Type
4889 UINT32 NE
:1; ///< Numeric Error
4890 UINT32 Reserved_0
:10; ///< Reserved
4891 UINT32 WP
:1; ///< Write Protect
4892 UINT32 Reserved_1
:1; ///< Reserved
4893 UINT32 AM
:1; ///< Alignment Mask
4894 UINT32 Reserved_2
:10; ///< Reserved
4895 UINT32 NW
:1; ///< Mot Write-through
4896 UINT32 CD
:1; ///< Cache Disable
4897 UINT32 PG
:1; ///< Paging
4903 /// Byte packed structure for Control Register 4 (CR4)
4904 /// 32-bits on IA-32
4905 /// 64-bits on x64. The upper 32-bits on x64 are reserved
4909 UINT32 VME
:1; ///< Virtual-8086 Mode Extensions
4910 UINT32 PVI
:1; ///< Protected-Mode Virtual Interrupts
4911 UINT32 TSD
:1; ///< Time Stamp Disable
4912 UINT32 DE
:1; ///< Debugging Extensions
4913 UINT32 PSE
:1; ///< Page Size Extensions
4914 UINT32 PAE
:1; ///< Physical Address Extension
4915 UINT32 MCE
:1; ///< Machine Check Enable
4916 UINT32 PGE
:1; ///< Page Global Enable
4917 UINT32 PCE
:1; ///< Performance Monitoring Counter
4919 UINT32 OSFXSR
:1; ///< Operating System Support for
4920 ///< FXSAVE and FXRSTOR instructions
4921 UINT32 OSXMMEXCPT
:1; ///< Operating System Support for
4922 ///< Unmasked SIMD Floating Point
4924 UINT32 Reserved_0
:2; ///< Reserved
4925 UINT32 VMXE
:1; ///< VMX Enable
4926 UINT32 Reserved_1
:18; ///< Reserved
4932 /// Byte packed structure for an IDTR, GDTR, LDTR descriptor
4941 #define IA32_IDT_GATE_TYPE_TASK 0x85
4942 #define IA32_IDT_GATE_TYPE_INTERRUPT_16 0x86
4943 #define IA32_IDT_GATE_TYPE_TRAP_16 0x87
4944 #define IA32_IDT_GATE_TYPE_INTERRUPT_32 0x8E
4945 #define IA32_IDT_GATE_TYPE_TRAP_32 0x8F
4948 #if defined (MDE_CPU_IA32)
4950 /// Byte packed structure for an IA-32 Interrupt Gate Descriptor
4954 UINT32 OffsetLow
:16; ///< Offset bits 15..0
4955 UINT32 Selector
:16; ///< Selector
4956 UINT32 Reserved_0
:8; ///< Reserved
4957 UINT32 GateType
:8; ///< Gate Type. See #defines above
4958 UINT32 OffsetHigh
:16; ///< Offset bits 31..16
4961 } IA32_IDT_GATE_DESCRIPTOR
;
4965 #if defined (MDE_CPU_X64)
4967 /// Byte packed structure for an x64 Interrupt Gate Descriptor
4971 UINT32 OffsetLow
:16; ///< Offset bits 15..0
4972 UINT32 Selector
:16; ///< Selector
4973 UINT32 Reserved_0
:8; ///< Reserved
4974 UINT32 GateType
:8; ///< Gate Type. See #defines above
4975 UINT32 OffsetHigh
:16; ///< Offset bits 31..16
4976 UINT32 OffsetUpper
:32; ///< Offset bits 63..32
4977 UINT32 Reserved_1
:32; ///< Reserved
4983 } IA32_IDT_GATE_DESCRIPTOR
;
4988 /// Byte packed structure for an FP/SSE/SSE2 context
4995 /// Structures for the 16-bit real mode thunks
5048 IA32_EFLAGS32 EFLAGS
;
5058 } IA32_REGISTER_SET
;
5061 /// Byte packed structure for an 16-bit real mode thunks
5064 IA32_REGISTER_SET
*RealModeState
;
5065 VOID
*RealModeBuffer
;
5066 UINT32 RealModeBufferSize
;
5067 UINT32 ThunkAttributes
;
5070 #define THUNK_ATTRIBUTE_BIG_REAL_MODE 0x00000001
5071 #define THUNK_ATTRIBUTE_DISABLE_A20_MASK_INT_15 0x00000002
5072 #define THUNK_ATTRIBUTE_DISABLE_A20_MASK_KBD_CTRL 0x00000004
5075 Retrieves CPUID information.
5077 Executes the CPUID instruction with EAX set to the value specified by Index.
5078 This function always returns Index.
5079 If Eax is not NULL, then the value of EAX after CPUID is returned in Eax.
5080 If Ebx is not NULL, then the value of EBX after CPUID is returned in Ebx.
5081 If Ecx is not NULL, then the value of ECX after CPUID is returned in Ecx.
5082 If Edx is not NULL, then the value of EDX after CPUID is returned in Edx.
5083 This function is only available on IA-32 and x64.
5085 @param Index The 32-bit value to load into EAX prior to invoking the CPUID
5087 @param Eax Pointer to the 32-bit EAX value returned by the CPUID
5088 instruction. This is an optional parameter that may be NULL.
5089 @param Ebx Pointer to the 32-bit EBX value returned by the CPUID
5090 instruction. This is an optional parameter that may be NULL.
5091 @param Ecx Pointer to the 32-bit ECX value returned by the CPUID
5092 instruction. This is an optional parameter that may be NULL.
5093 @param Edx Pointer to the 32-bit EDX value returned by the CPUID
5094 instruction. This is an optional parameter that may be NULL.
5103 OUT UINT32
*Eax
, OPTIONAL
5104 OUT UINT32
*Ebx
, OPTIONAL
5105 OUT UINT32
*Ecx
, OPTIONAL
5106 OUT UINT32
*Edx OPTIONAL
5111 Retrieves CPUID information using an extended leaf identifier.
5113 Executes the CPUID instruction with EAX set to the value specified by Index
5114 and ECX set to the value specified by SubIndex. This function always returns
5115 Index. This function is only available on IA-32 and x64.
5117 If Eax is not NULL, then the value of EAX after CPUID is returned in Eax.
5118 If Ebx is not NULL, then the value of EBX after CPUID is returned in Ebx.
5119 If Ecx is not NULL, then the value of ECX after CPUID is returned in Ecx.
5120 If Edx is not NULL, then the value of EDX after CPUID is returned in Edx.
5122 @param Index The 32-bit value to load into EAX prior to invoking the
5124 @param SubIndex The 32-bit value to load into ECX prior to invoking the
5126 @param Eax Pointer to the 32-bit EAX value returned by the CPUID
5127 instruction. This is an optional parameter that may be
5129 @param Ebx Pointer to the 32-bit EBX value returned by the CPUID
5130 instruction. This is an optional parameter that may be
5132 @param Ecx Pointer to the 32-bit ECX value returned by the CPUID
5133 instruction. This is an optional parameter that may be
5135 @param Edx Pointer to the 32-bit EDX value returned by the CPUID
5136 instruction. This is an optional parameter that may be
5147 OUT UINT32
*Eax
, OPTIONAL
5148 OUT UINT32
*Ebx
, OPTIONAL
5149 OUT UINT32
*Ecx
, OPTIONAL
5150 OUT UINT32
*Edx OPTIONAL
5155 Set CD bit and clear NW bit of CR0 followed by a WBINVD.
5157 Disables the caches by setting the CD bit of CR0 to 1, clearing the NW bit of CR0 to 0,
5158 and executing a WBINVD instruction. This function is only available on IA-32 and x64.
5169 Perform a WBINVD and clear both the CD and NW bits of CR0.
5171 Enables the caches by executing a WBINVD instruction and then clear both the CD and NW
5172 bits of CR0 to 0. This function is only available on IA-32 and x64.
5183 Returns the lower 32-bits of a Machine Specific Register(MSR).
5185 Reads and returns the lower 32-bits of the MSR specified by Index.
5186 No parameter checking is performed on Index, and some Index values may cause
5187 CPU exceptions. The caller must either guarantee that Index is valid, or the
5188 caller must set up exception handlers to catch the exceptions. This function
5189 is only available on IA-32 and x64.
5191 @param Index The 32-bit MSR index to read.
5193 @return The lower 32 bits of the MSR identified by Index.
5204 Writes a 32-bit value to a Machine Specific Register(MSR), and returns the value.
5205 The upper 32-bits of the MSR are set to zero.
5207 Writes the 32-bit value specified by Value to the MSR specified by Index. The
5208 upper 32-bits of the MSR write are set to zero. The 32-bit value written to
5209 the MSR is returned. No parameter checking is performed on Index or Value,
5210 and some of these may cause CPU exceptions. The caller must either guarantee
5211 that Index and Value are valid, or the caller must establish proper exception
5212 handlers. This function is only available on IA-32 and x64.
5214 @param Index The 32-bit MSR index to write.
5215 @param Value The 32-bit value to write to the MSR.
5229 Reads a 64-bit MSR, performs a bitwise OR on the lower 32-bits, and
5230 writes the result back to the 64-bit MSR.
5232 Reads the 64-bit MSR specified by Index, performs a bitwise OR
5233 between the lower 32-bits of the read result and the value specified by
5234 OrData, and writes the result to the 64-bit MSR specified by Index. The lower
5235 32-bits of the value written to the MSR is returned. No parameter checking is
5236 performed on Index or OrData, and some of these may cause CPU exceptions. The
5237 caller must either guarantee that Index and OrData are valid, or the caller
5238 must establish proper exception handlers. This function is only available on
5241 @param Index The 32-bit MSR index to write.
5242 @param OrData The value to OR with the read value from the MSR.
5244 @return The lower 32-bit value written to the MSR.
5256 Reads a 64-bit MSR, performs a bitwise AND on the lower 32-bits, and writes
5257 the result back to the 64-bit MSR.
5259 Reads the 64-bit MSR specified by Index, performs a bitwise AND between the
5260 lower 32-bits of the read result and the value specified by AndData, and
5261 writes the result to the 64-bit MSR specified by Index. The lower 32-bits of
5262 the value written to the MSR is returned. No parameter checking is performed
5263 on Index or AndData, and some of these may cause CPU exceptions. The caller
5264 must either guarantee that Index and AndData are valid, or the caller must
5265 establish proper exception handlers. This function is only available on IA-32
5268 @param Index The 32-bit MSR index to write.
5269 @param AndData The value to AND with the read value from the MSR.
5271 @return The lower 32-bit value written to the MSR.
5283 Reads a 64-bit MSR, performs a bitwise AND followed by a bitwise OR
5284 on the lower 32-bits, and writes the result back to the 64-bit MSR.
5286 Reads the 64-bit MSR specified by Index, performs a bitwise AND between the
5287 lower 32-bits of the read result and the value specified by AndData
5288 preserving the upper 32-bits, performs a bitwise OR between the
5289 result of the AND operation and the value specified by OrData, and writes the
5290 result to the 64-bit MSR specified by Address. The lower 32-bits of the value
5291 written to the MSR is returned. No parameter checking is performed on Index,
5292 AndData, or OrData, and some of these may cause CPU exceptions. The caller
5293 must either guarantee that Index, AndData, and OrData are valid, or the
5294 caller must establish proper exception handlers. This function is only
5295 available on IA-32 and x64.
5297 @param Index The 32-bit MSR index to write.
5298 @param AndData The value to AND with the read value from the MSR.
5299 @param OrData The value to OR with the result of the AND operation.
5301 @return The lower 32-bit value written to the MSR.
5314 Reads a bit field of an MSR.
5316 Reads the bit field in the lower 32-bits of a 64-bit MSR. The bit field is
5317 specified by the StartBit and the EndBit. The value of the bit field is
5318 returned. The caller must either guarantee that Index is valid, or the caller
5319 must set up exception handlers to catch the exceptions. This function is only
5320 available on IA-32 and x64.
5322 If StartBit is greater than 31, then ASSERT().
5323 If EndBit is greater than 31, then ASSERT().
5324 If EndBit is less than StartBit, then ASSERT().
5326 @param Index The 32-bit MSR index to read.
5327 @param StartBit The ordinal of the least significant bit in the bit field.
5329 @param EndBit The ordinal of the most significant bit in the bit field.
5332 @return The bit field read from the MSR.
5337 AsmMsrBitFieldRead32 (
5345 Writes a bit field to an MSR.
5347 Writes Value to a bit field in the lower 32-bits of a 64-bit MSR. The bit
5348 field is specified by the StartBit and the EndBit. All other bits in the
5349 destination MSR are preserved. The lower 32-bits of the MSR written is
5350 returned. The caller must either guarantee that Index and the data written
5351 is valid, or the caller must set up exception handlers to catch the exceptions.
5352 This function is only available on IA-32 and x64.
5354 If StartBit is greater than 31, then ASSERT().
5355 If EndBit is greater than 31, then ASSERT().
5356 If EndBit is less than StartBit, then ASSERT().
5358 @param Index The 32-bit MSR index to write.
5359 @param StartBit The ordinal of the least significant bit in the bit field.
5361 @param EndBit The ordinal of the most significant bit in the bit field.
5363 @param Value New value of the bit field.
5365 @return The lower 32-bit of the value written to the MSR.
5370 AsmMsrBitFieldWrite32 (
5379 Reads a bit field in a 64-bit MSR, performs a bitwise OR, and writes the
5380 result back to the bit field in the 64-bit MSR.
5382 Reads the 64-bit MSR specified by Index, performs a bitwise OR
5383 between the read result and the value specified by OrData, and writes the
5384 result to the 64-bit MSR specified by Index. The lower 32-bits of the value
5385 written to the MSR are returned. Extra left bits in OrData are stripped. The
5386 caller must either guarantee that Index and the data written is valid, or
5387 the caller must set up exception handlers to catch the exceptions. This
5388 function is only available on IA-32 and x64.
5390 If StartBit is greater than 31, then ASSERT().
5391 If EndBit is greater than 31, then ASSERT().
5392 If EndBit is less than StartBit, then ASSERT().
5394 @param Index The 32-bit MSR index to write.
5395 @param StartBit The ordinal of the least significant bit in the bit field.
5397 @param EndBit The ordinal of the most significant bit in the bit field.
5399 @param OrData The value to OR with the read value from the MSR.
5401 @return The lower 32-bit of the value written to the MSR.
5406 AsmMsrBitFieldOr32 (
5415 Reads a bit field in a 64-bit MSR, performs a bitwise AND, and writes the
5416 result back to the bit field in the 64-bit MSR.
5418 Reads the 64-bit MSR specified by Index, performs a bitwise AND between the
5419 read result and the value specified by AndData, and writes the result to the
5420 64-bit MSR specified by Index. The lower 32-bits of the value written to the
5421 MSR are returned. Extra left bits in AndData are stripped. The caller must
5422 either guarantee that Index and the data written is valid, or the caller must
5423 set up exception handlers to catch the exceptions. This function is only
5424 available on IA-32 and x64.
5426 If StartBit is greater than 31, then ASSERT().
5427 If EndBit is greater than 31, then ASSERT().
5428 If EndBit is less than StartBit, then ASSERT().
5430 @param Index The 32-bit MSR index to write.
5431 @param StartBit The ordinal of the least significant bit in the bit field.
5433 @param EndBit The ordinal of the most significant bit in the bit field.
5435 @param AndData The value to AND with the read value from the MSR.
5437 @return The lower 32-bit of the value written to the MSR.
5442 AsmMsrBitFieldAnd32 (
5451 Reads a bit field in a 64-bit MSR, performs a bitwise AND followed by a
5452 bitwise OR, and writes the result back to the bit field in the
5455 Reads the 64-bit MSR specified by Index, performs a bitwise AND followed by a
5456 bitwise OR between the read result and the value specified by
5457 AndData, and writes the result to the 64-bit MSR specified by Index. The
5458 lower 32-bits of the value written to the MSR are returned. Extra left bits
5459 in both AndData and OrData are stripped. The caller must either guarantee
5460 that Index and the data written is valid, or the caller must set up exception
5461 handlers to catch the exceptions. This function is only available on IA-32
5464 If StartBit is greater than 31, then ASSERT().
5465 If EndBit is greater than 31, then ASSERT().
5466 If EndBit is less than StartBit, then ASSERT().
5468 @param Index The 32-bit MSR index to write.
5469 @param StartBit The ordinal of the least significant bit in the bit field.
5471 @param EndBit The ordinal of the most significant bit in the bit field.
5473 @param AndData The value to AND with the read value from the MSR.
5474 @param OrData The value to OR with the result of the AND operation.
5476 @return The lower 32-bit of the value written to the MSR.
5481 AsmMsrBitFieldAndThenOr32 (
5491 Returns a 64-bit Machine Specific Register(MSR).
5493 Reads and returns the 64-bit MSR specified by Index. No parameter checking is
5494 performed on Index, and some Index values may cause CPU exceptions. The
5495 caller must either guarantee that Index is valid, or the caller must set up
5496 exception handlers to catch the exceptions. This function is only available
5499 @param Index The 32-bit MSR index to read.
5501 @return The value of the MSR identified by Index.
5512 Writes a 64-bit value to a Machine Specific Register(MSR), and returns the
5515 Writes the 64-bit value specified by Value to the MSR specified by Index. The
5516 64-bit value written to the MSR is returned. No parameter checking is
5517 performed on Index or Value, and some of these may cause CPU exceptions. The
5518 caller must either guarantee that Index and Value are valid, or the caller
5519 must establish proper exception handlers. This function is only available on
5522 @param Index The 32-bit MSR index to write.
5523 @param Value The 64-bit value to write to the MSR.
5537 Reads a 64-bit MSR, performs a bitwise OR, and writes the result
5538 back to the 64-bit MSR.
5540 Reads the 64-bit MSR specified by Index, performs a bitwise OR
5541 between the read result and the value specified by OrData, and writes the
5542 result to the 64-bit MSR specified by Index. The value written to the MSR is
5543 returned. No parameter checking is performed on Index or OrData, and some of
5544 these may cause CPU exceptions. The caller must either guarantee that Index
5545 and OrData are valid, or the caller must establish proper exception handlers.
5546 This function is only available on IA-32 and x64.
5548 @param Index The 32-bit MSR index to write.
5549 @param OrData The value to OR with the read value from the MSR.
5551 @return The value written back to the MSR.
5563 Reads a 64-bit MSR, performs a bitwise AND, and writes the result back to the
5566 Reads the 64-bit MSR specified by Index, performs a bitwise AND between the
5567 read result and the value specified by OrData, and writes the result to the
5568 64-bit MSR specified by Index. The value written to the MSR is returned. No
5569 parameter checking is performed on Index or OrData, and some of these may
5570 cause CPU exceptions. The caller must either guarantee that Index and OrData
5571 are valid, or the caller must establish proper exception handlers. This
5572 function is only available on IA-32 and x64.
5574 @param Index The 32-bit MSR index to write.
5575 @param AndData The value to AND with the read value from the MSR.
5577 @return The value written back to the MSR.
5589 Reads a 64-bit MSR, performs a bitwise AND followed by a bitwise
5590 OR, and writes the result back to the 64-bit MSR.
5592 Reads the 64-bit MSR specified by Index, performs a bitwise AND between read
5593 result and the value specified by AndData, performs a bitwise OR
5594 between the result of the AND operation and the value specified by OrData,
5595 and writes the result to the 64-bit MSR specified by Index. The value written
5596 to the MSR is returned. No parameter checking is performed on Index, AndData,
5597 or OrData, and some of these may cause CPU exceptions. The caller must either
5598 guarantee that Index, AndData, and OrData are valid, or the caller must
5599 establish proper exception handlers. This function is only available on IA-32
5602 @param Index The 32-bit MSR index to write.
5603 @param AndData The value to AND with the read value from the MSR.
5604 @param OrData The value to OR with the result of the AND operation.
5606 @return The value written back to the MSR.
5619 Reads a bit field of an MSR.
5621 Reads the bit field in the 64-bit MSR. The bit field is specified by the
5622 StartBit and the EndBit. The value of the bit field is returned. The caller
5623 must either guarantee that Index is valid, or the caller must set up
5624 exception handlers to catch the exceptions. This function is only available
5627 If StartBit is greater than 63, then ASSERT().
5628 If EndBit is greater than 63, then ASSERT().
5629 If EndBit is less than StartBit, then ASSERT().
5631 @param Index The 32-bit MSR index to read.
5632 @param StartBit The ordinal of the least significant bit in the bit field.
5634 @param EndBit The ordinal of the most significant bit in the bit field.
5637 @return The value read from the MSR.
5642 AsmMsrBitFieldRead64 (
5650 Writes a bit field to an MSR.
5652 Writes Value to a bit field in a 64-bit MSR. The bit field is specified by
5653 the StartBit and the EndBit. All other bits in the destination MSR are
5654 preserved. The MSR written is returned. The caller must either guarantee
5655 that Index and the data written is valid, or the caller must set up exception
5656 handlers to catch the exceptions. This function is only available on IA-32 and x64.
5658 If StartBit is greater than 63, then ASSERT().
5659 If EndBit is greater than 63, then ASSERT().
5660 If EndBit is less than StartBit, then ASSERT().
5662 @param Index The 32-bit MSR index to write.
5663 @param StartBit The ordinal of the least significant bit in the bit field.
5665 @param EndBit The ordinal of the most significant bit in the bit field.
5667 @param Value New value of the bit field.
5669 @return The value written back to the MSR.
5674 AsmMsrBitFieldWrite64 (
5683 Reads a bit field in a 64-bit MSR, performs a bitwise OR, and
5684 writes the result back to the bit field in the 64-bit MSR.
5686 Reads the 64-bit MSR specified by Index, performs a bitwise OR
5687 between the read result and the value specified by OrData, and writes the
5688 result to the 64-bit MSR specified by Index. The value written to the MSR is
5689 returned. Extra left bits in OrData are stripped. The caller must either
5690 guarantee that Index and the data written is valid, or the caller must set up
5691 exception handlers to catch the exceptions. This function is only available
5694 If StartBit is greater than 63, then ASSERT().
5695 If EndBit is greater than 63, then ASSERT().
5696 If EndBit is less than StartBit, then ASSERT().
5698 @param Index The 32-bit MSR index to write.
5699 @param StartBit The ordinal of the least significant bit in the bit field.
5701 @param EndBit The ordinal of the most significant bit in the bit field.
5703 @param OrData The value to OR with the read value from the bit field.
5705 @return The value written back to the MSR.
5710 AsmMsrBitFieldOr64 (
5719 Reads a bit field in a 64-bit MSR, performs a bitwise AND, and writes the
5720 result back to the bit field in the 64-bit MSR.
5722 Reads the 64-bit MSR specified by Index, performs a bitwise AND between the
5723 read result and the value specified by AndData, and writes the result to the
5724 64-bit MSR specified by Index. The value written to the MSR is returned.
5725 Extra left bits in AndData are stripped. The caller must either guarantee
5726 that Index and the data written is valid, or the caller must set up exception
5727 handlers to catch the exceptions. This function is only available on IA-32
5730 If StartBit is greater than 63, then ASSERT().
5731 If EndBit is greater than 63, then ASSERT().
5732 If EndBit is less than StartBit, then ASSERT().
5734 @param Index The 32-bit MSR index to write.
5735 @param StartBit The ordinal of the least significant bit in the bit field.
5737 @param EndBit The ordinal of the most significant bit in the bit field.
5739 @param AndData The value to AND with the read value from the bit field.
5741 @return The value written back to the MSR.
5746 AsmMsrBitFieldAnd64 (
5755 Reads a bit field in a 64-bit MSR, performs a bitwise AND followed by a
5756 bitwise OR, and writes the result back to the bit field in the
5759 Reads the 64-bit MSR specified by Index, performs a bitwise AND followed by
5760 a bitwise OR between the read result and the value specified by
5761 AndData, and writes the result to the 64-bit MSR specified by Index. The
5762 value written to the MSR is returned. Extra left bits in both AndData and
5763 OrData are stripped. The caller must either guarantee that Index and the data
5764 written is valid, or the caller must set up exception handlers to catch the
5765 exceptions. This function is only available on IA-32 and x64.
5767 If StartBit is greater than 63, then ASSERT().
5768 If EndBit is greater than 63, then ASSERT().
5769 If EndBit is less than StartBit, then ASSERT().
5771 @param Index The 32-bit MSR index to write.
5772 @param StartBit The ordinal of the least significant bit in the bit field.
5774 @param EndBit The ordinal of the most significant bit in the bit field.
5776 @param AndData The value to AND with the read value from the bit field.
5777 @param OrData The value to OR with the result of the AND operation.
5779 @return The value written back to the MSR.
5784 AsmMsrBitFieldAndThenOr64 (
5794 Reads the current value of the EFLAGS register.
5796 Reads and returns the current value of the EFLAGS register. This function is
5797 only available on IA-32 and x64. This returns a 32-bit value on IA-32 and a
5798 64-bit value on x64.
5800 @return EFLAGS on IA-32 or RFLAGS on x64.
5811 Reads the current value of the Control Register 0 (CR0).
5813 Reads and returns the current value of CR0. This function is only available
5814 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
5817 @return The value of the Control Register 0 (CR0).
5828 Reads the current value of the Control Register 2 (CR2).
5830 Reads and returns the current value of CR2. This function is only available
5831 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
5834 @return The value of the Control Register 2 (CR2).
5845 Reads the current value of the Control Register 3 (CR3).
5847 Reads and returns the current value of CR3. This function is only available
5848 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
5851 @return The value of the Control Register 3 (CR3).
5862 Reads the current value of the Control Register 4 (CR4).
5864 Reads and returns the current value of CR4. This function is only available
5865 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
5868 @return The value of the Control Register 4 (CR4).
5879 Writes a value to Control Register 0 (CR0).
5881 Writes and returns a new value to CR0. This function is only available on
5882 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
5884 @param Cr0 The value to write to CR0.
5886 @return The value written to CR0.
5897 Writes a value to Control Register 2 (CR2).
5899 Writes and returns a new value to CR2. This function is only available on
5900 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
5902 @param Cr2 The value to write to CR2.
5904 @return The value written to CR2.
5915 Writes a value to Control Register 3 (CR3).
5917 Writes and returns a new value to CR3. This function is only available on
5918 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
5920 @param Cr3 The value to write to CR3.
5922 @return The value written to CR3.
5933 Writes a value to Control Register 4 (CR4).
5935 Writes and returns a new value to CR4. This function is only available on
5936 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
5938 @param Cr4 The value to write to CR4.
5940 @return The value written to CR4.
5951 Reads the current value of Debug Register 0 (DR0).
5953 Reads and returns the current value of DR0. This function is only available
5954 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
5957 @return The value of Debug Register 0 (DR0).
5968 Reads the current value of Debug Register 1 (DR1).
5970 Reads and returns the current value of DR1. This function is only available
5971 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
5974 @return The value of Debug Register 1 (DR1).
5985 Reads the current value of Debug Register 2 (DR2).
5987 Reads and returns the current value of DR2. This function is only available
5988 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
5991 @return The value of Debug Register 2 (DR2).
6002 Reads the current value of Debug Register 3 (DR3).
6004 Reads and returns the current value of DR3. This function is only available
6005 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
6008 @return The value of Debug Register 3 (DR3).
6019 Reads the current value of Debug Register 4 (DR4).
6021 Reads and returns the current value of DR4. This function is only available
6022 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
6025 @return The value of Debug Register 4 (DR4).
6036 Reads the current value of Debug Register 5 (DR5).
6038 Reads and returns the current value of DR5. This function is only available
6039 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
6042 @return The value of Debug Register 5 (DR5).
6053 Reads the current value of Debug Register 6 (DR6).
6055 Reads and returns the current value of DR6. This function is only available
6056 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
6059 @return The value of Debug Register 6 (DR6).
6070 Reads the current value of Debug Register 7 (DR7).
6072 Reads and returns the current value of DR7. This function is only available
6073 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
6076 @return The value of Debug Register 7 (DR7).
6087 Writes a value to Debug Register 0 (DR0).
6089 Writes and returns a new value to DR0. This function is only available on
6090 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
6092 @param Dr0 The value to write to Dr0.
6094 @return The value written to Debug Register 0 (DR0).
6105 Writes a value to Debug Register 1 (DR1).
6107 Writes and returns a new value to DR1. This function is only available on
6108 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
6110 @param Dr1 The value to write to Dr1.
6112 @return The value written to Debug Register 1 (DR1).
6123 Writes a value to Debug Register 2 (DR2).
6125 Writes and returns a new value to DR2. This function is only available on
6126 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
6128 @param Dr2 The value to write to Dr2.
6130 @return The value written to Debug Register 2 (DR2).
6141 Writes a value to Debug Register 3 (DR3).
6143 Writes and returns a new value to DR3. This function is only available on
6144 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
6146 @param Dr3 The value to write to Dr3.
6148 @return The value written to Debug Register 3 (DR3).
6159 Writes a value to Debug Register 4 (DR4).
6161 Writes and returns a new value to DR4. This function is only available on
6162 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
6164 @param Dr4 The value to write to Dr4.
6166 @return The value written to Debug Register 4 (DR4).
6177 Writes a value to Debug Register 5 (DR5).
6179 Writes and returns a new value to DR5. This function is only available on
6180 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
6182 @param Dr5 The value to write to Dr5.
6184 @return The value written to Debug Register 5 (DR5).
6195 Writes a value to Debug Register 6 (DR6).
6197 Writes and returns a new value to DR6. This function is only available on
6198 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
6200 @param Dr6 The value to write to Dr6.
6202 @return The value written to Debug Register 6 (DR6).
6213 Writes a value to Debug Register 7 (DR7).
6215 Writes and returns a new value to DR7. This function is only available on
6216 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
6218 @param Dr7 The value to write to Dr7.
6220 @return The value written to Debug Register 7 (DR7).
6231 Reads the current value of Code Segment Register (CS).
6233 Reads and returns the current value of CS. This function is only available on
6236 @return The current value of CS.
6247 Reads the current value of Data Segment Register (DS).
6249 Reads and returns the current value of DS. This function is only available on
6252 @return The current value of DS.
6263 Reads the current value of Extra Segment Register (ES).
6265 Reads and returns the current value of ES. This function is only available on
6268 @return The current value of ES.
6279 Reads the current value of FS Data Segment Register (FS).
6281 Reads and returns the current value of FS. This function is only available on
6284 @return The current value of FS.
6295 Reads the current value of GS Data Segment Register (GS).
6297 Reads and returns the current value of GS. This function is only available on
6300 @return The current value of GS.
6311 Reads the current value of Stack Segment Register (SS).
6313 Reads and returns the current value of SS. This function is only available on
6316 @return The current value of SS.
6327 Reads the current value of Task Register (TR).
6329 Reads and returns the current value of TR. This function is only available on
6332 @return The current value of TR.
6343 Reads the current Global Descriptor Table Register(GDTR) descriptor.
6345 Reads and returns the current GDTR descriptor and returns it in Gdtr. This
6346 function is only available on IA-32 and x64.
6348 If Gdtr is NULL, then ASSERT().
6350 @param Gdtr Pointer to a GDTR descriptor.
6356 OUT IA32_DESCRIPTOR
*Gdtr
6361 Writes the current Global Descriptor Table Register (GDTR) descriptor.
6363 Writes and the current GDTR descriptor specified by Gdtr. This function is
6364 only available on IA-32 and x64.
6366 If Gdtr is NULL, then ASSERT().
6368 @param Gdtr Pointer to a GDTR descriptor.
6374 IN CONST IA32_DESCRIPTOR
*Gdtr
6379 Reads the current Interrupt Descriptor Table Register(IDTR) descriptor.
6381 Reads and returns the current IDTR descriptor and returns it in Idtr. This
6382 function is only available on IA-32 and x64.
6384 If Idtr is NULL, then ASSERT().
6386 @param Idtr Pointer to a IDTR descriptor.
6392 OUT IA32_DESCRIPTOR
*Idtr
6397 Writes the current Interrupt Descriptor Table Register(IDTR) descriptor.
6399 Writes the current IDTR descriptor and returns it in Idtr. This function is
6400 only available on IA-32 and x64.
6402 If Idtr is NULL, then ASSERT().
6404 @param Idtr Pointer to a IDTR descriptor.
6410 IN CONST IA32_DESCRIPTOR
*Idtr
6415 Reads the current Local Descriptor Table Register(LDTR) selector.
6417 Reads and returns the current 16-bit LDTR descriptor value. This function is
6418 only available on IA-32 and x64.
6420 @return The current selector of LDT.
6431 Writes the current Local Descriptor Table Register (LDTR) selector.
6433 Writes and the current LDTR descriptor specified by Ldtr. This function is
6434 only available on IA-32 and x64.
6436 @param Ldtr 16-bit LDTR selector value.
6447 Save the current floating point/SSE/SSE2 context to a buffer.
6449 Saves the current floating point/SSE/SSE2 state to the buffer specified by
6450 Buffer. Buffer must be aligned on a 16-byte boundary. This function is only
6451 available on IA-32 and x64.
6453 If Buffer is NULL, then ASSERT().
6454 If Buffer is not aligned on a 16-byte boundary, then ASSERT().
6456 @param Buffer Pointer to a buffer to save the floating point/SSE/SSE2 context.
6462 OUT IA32_FX_BUFFER
*Buffer
6467 Restores the current floating point/SSE/SSE2 context from a buffer.
6469 Restores the current floating point/SSE/SSE2 state from the buffer specified
6470 by Buffer. Buffer must be aligned on a 16-byte boundary. This function is
6471 only available on IA-32 and x64.
6473 If Buffer is NULL, then ASSERT().
6474 If Buffer is not aligned on a 16-byte boundary, then ASSERT().
6475 If Buffer was not saved with AsmFxSave(), then ASSERT().
6477 @param Buffer Pointer to a buffer to save the floating point/SSE/SSE2 context.
6483 IN CONST IA32_FX_BUFFER
*Buffer
6488 Reads the current value of 64-bit MMX Register #0 (MM0).
6490 Reads and returns the current value of MM0. This function is only available
6493 @return The current value of MM0.
6504 Reads the current value of 64-bit MMX Register #1 (MM1).
6506 Reads and returns the current value of MM1. This function is only available
6509 @return The current value of MM1.
6520 Reads the current value of 64-bit MMX Register #2 (MM2).
6522 Reads and returns the current value of MM2. This function is only available
6525 @return The current value of MM2.
6536 Reads the current value of 64-bit MMX Register #3 (MM3).
6538 Reads and returns the current value of MM3. This function is only available
6541 @return The current value of MM3.
6552 Reads the current value of 64-bit MMX Register #4 (MM4).
6554 Reads and returns the current value of MM4. This function is only available
6557 @return The current value of MM4.
6568 Reads the current value of 64-bit MMX Register #5 (MM5).
6570 Reads and returns the current value of MM5. This function is only available
6573 @return The current value of MM5.
6584 Reads the current value of 64-bit MMX Register #6 (MM6).
6586 Reads and returns the current value of MM6. This function is only available
6589 @return The current value of MM6.
6600 Reads the current value of 64-bit MMX Register #7 (MM7).
6602 Reads and returns the current value of MM7. This function is only available
6605 @return The current value of MM7.
6616 Writes the current value of 64-bit MMX Register #0 (MM0).
6618 Writes the current value of MM0. This function is only available on IA32 and
6621 @param Value The 64-bit value to write to MM0.
6632 Writes the current value of 64-bit MMX Register #1 (MM1).
6634 Writes the current value of MM1. This function is only available on IA32 and
6637 @param Value The 64-bit value to write to MM1.
6648 Writes the current value of 64-bit MMX Register #2 (MM2).
6650 Writes the current value of MM2. This function is only available on IA32 and
6653 @param Value The 64-bit value to write to MM2.
6664 Writes the current value of 64-bit MMX Register #3 (MM3).
6666 Writes the current value of MM3. This function is only available on IA32 and
6669 @param Value The 64-bit value to write to MM3.
6680 Writes the current value of 64-bit MMX Register #4 (MM4).
6682 Writes the current value of MM4. This function is only available on IA32 and
6685 @param Value The 64-bit value to write to MM4.
6696 Writes the current value of 64-bit MMX Register #5 (MM5).
6698 Writes the current value of MM5. This function is only available on IA32 and
6701 @param Value The 64-bit value to write to MM5.
6712 Writes the current value of 64-bit MMX Register #6 (MM6).
6714 Writes the current value of MM6. This function is only available on IA32 and
6717 @param Value The 64-bit value to write to MM6.
6728 Writes the current value of 64-bit MMX Register #7 (MM7).
6730 Writes the current value of MM7. This function is only available on IA32 and
6733 @param Value The 64-bit value to write to MM7.
6744 Reads the current value of Time Stamp Counter (TSC).
6746 Reads and returns the current value of TSC. This function is only available
6749 @return The current value of TSC
6760 Reads the current value of a Performance Counter (PMC).
6762 Reads and returns the current value of performance counter specified by
6763 Index. This function is only available on IA-32 and x64.
6765 @param Index The 32-bit Performance Counter index to read.
6767 @return The value of the PMC specified by Index.
6778 Sets up a monitor buffer that is used by AsmMwait().
6780 Executes a MONITOR instruction with the register state specified by Eax, Ecx
6781 and Edx. Returns Eax. This function is only available on IA-32 and x64.
6783 @param Eax The value to load into EAX or RAX before executing the MONITOR
6785 @param Ecx The value to load into ECX or RCX before executing the MONITOR
6787 @param Edx The value to load into EDX or RDX before executing the MONITOR
6803 Executes an MWAIT instruction.
6805 Executes an MWAIT instruction with the register state specified by Eax and
6806 Ecx. Returns Eax. This function is only available on IA-32 and x64.
6808 @param Eax The value to load into EAX or RAX before executing the MONITOR
6810 @param Ecx The value to load into ECX or RCX before executing the MONITOR
6825 Executes a WBINVD instruction.
6827 Executes a WBINVD instruction. This function is only available on IA-32 and
6839 Executes a INVD instruction.
6841 Executes a INVD instruction. This function is only available on IA-32 and
6853 Flushes a cache line from all the instruction and data caches within the
6854 coherency domain of the CPU.
6856 Flushed the cache line specified by LinearAddress, and returns LinearAddress.
6857 This function is only available on IA-32 and x64.
6859 @param LinearAddress The address of the cache line to flush. If the CPU is
6860 in a physical addressing mode, then LinearAddress is a
6861 physical address. If the CPU is in a virtual
6862 addressing mode, then LinearAddress is a virtual
6865 @return LinearAddress
6870 IN VOID
*LinearAddress
6875 Enables the 32-bit paging mode on the CPU.
6877 Enables the 32-bit paging mode on the CPU. CR0, CR3, CR4, and the page tables
6878 must be properly initialized prior to calling this service. This function
6879 assumes the current execution mode is 32-bit protected mode. This function is
6880 only available on IA-32. After the 32-bit paging mode is enabled, control is
6881 transferred to the function specified by EntryPoint using the new stack
6882 specified by NewStack and passing in the parameters specified by Context1 and
6883 Context2. Context1 and Context2 are optional and may be NULL. The function
6884 EntryPoint must never return.
6886 If the current execution mode is not 32-bit protected mode, then ASSERT().
6887 If EntryPoint is NULL, then ASSERT().
6888 If NewStack is NULL, then ASSERT().
6890 There are a number of constraints that must be followed before calling this
6892 1) Interrupts must be disabled.
6893 2) The caller must be in 32-bit protected mode with flat descriptors. This
6894 means all descriptors must have a base of 0 and a limit of 4GB.
6895 3) CR0 and CR4 must be compatible with 32-bit protected mode with flat
6897 4) CR3 must point to valid page tables that will be used once the transition
6898 is complete, and those page tables must guarantee that the pages for this
6899 function and the stack are identity mapped.
6901 @param EntryPoint A pointer to function to call with the new stack after
6903 @param Context1 A pointer to the context to pass into the EntryPoint
6904 function as the first parameter after paging is enabled.
6905 @param Context2 A pointer to the context to pass into the EntryPoint
6906 function as the second parameter after paging is enabled.
6907 @param NewStack A pointer to the new stack to use for the EntryPoint
6908 function after paging is enabled.
6914 IN SWITCH_STACK_ENTRY_POINT EntryPoint
,
6915 IN VOID
*Context1
, OPTIONAL
6916 IN VOID
*Context2
, OPTIONAL
6922 Disables the 32-bit paging mode on the CPU.
6924 Disables the 32-bit paging mode on the CPU and returns to 32-bit protected
6925 mode. This function assumes the current execution mode is 32-paged protected
6926 mode. This function is only available on IA-32. After the 32-bit paging mode
6927 is disabled, control is transferred to the function specified by EntryPoint
6928 using the new stack specified by NewStack and passing in the parameters
6929 specified by Context1 and Context2. Context1 and Context2 are optional and
6930 may be NULL. The function EntryPoint must never return.
6932 If the current execution mode is not 32-bit paged mode, then ASSERT().
6933 If EntryPoint is NULL, then ASSERT().
6934 If NewStack is NULL, then ASSERT().
6936 There are a number of constraints that must be followed before calling this
6938 1) Interrupts must be disabled.
6939 2) The caller must be in 32-bit paged mode.
6940 3) CR0, CR3, and CR4 must be compatible with 32-bit paged mode.
6941 4) CR3 must point to valid page tables that guarantee that the pages for
6942 this function and the stack are identity mapped.
6944 @param EntryPoint A pointer to function to call with the new stack after
6946 @param Context1 A pointer to the context to pass into the EntryPoint
6947 function as the first parameter after paging is disabled.
6948 @param Context2 A pointer to the context to pass into the EntryPoint
6949 function as the second parameter after paging is
6951 @param NewStack A pointer to the new stack to use for the EntryPoint
6952 function after paging is disabled.
6957 AsmDisablePaging32 (
6958 IN SWITCH_STACK_ENTRY_POINT EntryPoint
,
6959 IN VOID
*Context1
, OPTIONAL
6960 IN VOID
*Context2
, OPTIONAL
6966 Enables the 64-bit paging mode on the CPU.
6968 Enables the 64-bit paging mode on the CPU. CR0, CR3, CR4, and the page tables
6969 must be properly initialized prior to calling this service. This function
6970 assumes the current execution mode is 32-bit protected mode with flat
6971 descriptors. This function is only available on IA-32. After the 64-bit
6972 paging mode is enabled, control is transferred to the function specified by
6973 EntryPoint using the new stack specified by NewStack and passing in the
6974 parameters specified by Context1 and Context2. Context1 and Context2 are
6975 optional and may be 0. The function EntryPoint must never return.
6977 If the current execution mode is not 32-bit protected mode with flat
6978 descriptors, then ASSERT().
6979 If EntryPoint is 0, then ASSERT().
6980 If NewStack is 0, then ASSERT().
6982 @param Cs The 16-bit selector to load in the CS before EntryPoint
6983 is called. The descriptor in the GDT that this selector
6984 references must be setup for long mode.
6985 @param EntryPoint The 64-bit virtual address of the function to call with
6986 the new stack after paging is enabled.
6987 @param Context1 The 64-bit virtual address of the context to pass into
6988 the EntryPoint function as the first parameter after
6990 @param Context2 The 64-bit virtual address of the context to pass into
6991 the EntryPoint function as the second parameter after
6993 @param NewStack The 64-bit virtual address of the new stack to use for
6994 the EntryPoint function after paging is enabled.
7001 IN UINT64 EntryPoint
,
7002 IN UINT64 Context1
, OPTIONAL
7003 IN UINT64 Context2
, OPTIONAL
7009 Disables the 64-bit paging mode on the CPU.
7011 Disables the 64-bit paging mode on the CPU and returns to 32-bit protected
7012 mode. This function assumes the current execution mode is 64-paging mode.
7013 This function is only available on x64. After the 64-bit paging mode is
7014 disabled, control is transferred to the function specified by EntryPoint
7015 using the new stack specified by NewStack and passing in the parameters
7016 specified by Context1 and Context2. Context1 and Context2 are optional and
7017 may be 0. The function EntryPoint must never return.
7019 If the current execution mode is not 64-bit paged mode, then ASSERT().
7020 If EntryPoint is 0, then ASSERT().
7021 If NewStack is 0, then ASSERT().
7023 @param Cs The 16-bit selector to load in the CS before EntryPoint
7024 is called. The descriptor in the GDT that this selector
7025 references must be setup for 32-bit protected mode.
7026 @param EntryPoint The 64-bit virtual address of the function to call with
7027 the new stack after paging is disabled.
7028 @param Context1 The 64-bit virtual address of the context to pass into
7029 the EntryPoint function as the first parameter after
7031 @param Context2 The 64-bit virtual address of the context to pass into
7032 the EntryPoint function as the second parameter after
7034 @param NewStack The 64-bit virtual address of the new stack to use for
7035 the EntryPoint function after paging is disabled.
7040 AsmDisablePaging64 (
7042 IN UINT32 EntryPoint
,
7043 IN UINT32 Context1
, OPTIONAL
7044 IN UINT32 Context2
, OPTIONAL
7050 // 16-bit thunking services
7054 Retrieves the properties for 16-bit thunk functions.
7056 Computes the size of the buffer and stack below 1MB required to use the
7057 AsmPrepareThunk16(), AsmThunk16() and AsmPrepareAndThunk16() functions. This
7058 buffer size is returned in RealModeBufferSize, and the stack size is returned
7059 in ExtraStackSize. If parameters are passed to the 16-bit real mode code,
7060 then the actual minimum stack size is ExtraStackSize plus the maximum number
7061 of bytes that need to be passed to the 16-bit real mode code.
7063 If RealModeBufferSize is NULL, then ASSERT().
7064 If ExtraStackSize is NULL, then ASSERT().
7066 @param RealModeBufferSize A pointer to the size of the buffer below 1MB
7067 required to use the 16-bit thunk functions.
7068 @param ExtraStackSize A pointer to the extra size of stack below 1MB
7069 that the 16-bit thunk functions require for
7070 temporary storage in the transition to and from
7076 AsmGetThunk16Properties (
7077 OUT UINT32
*RealModeBufferSize
,
7078 OUT UINT32
*ExtraStackSize
7083 Prepares all structures a code required to use AsmThunk16().
7085 Prepares all structures and code required to use AsmThunk16().
7087 This interface is limited to be used in either physical mode or virtual modes with paging enabled where the
7088 virtual to physical mappings for ThunkContext.RealModeBuffer is mapped 1:1.
7090 If ThunkContext is NULL, then ASSERT().
7092 @param ThunkContext A pointer to the context structure that describes the
7093 16-bit real mode code to call.
7099 OUT THUNK_CONTEXT
*ThunkContext
7104 Transfers control to a 16-bit real mode entry point and returns the results.
7106 Transfers control to a 16-bit real mode entry point and returns the results.
7107 AsmPrepareThunk16() must be called with ThunkContext before this function is used.
7108 This function must be called with interrupts disabled.
7110 The register state from the RealModeState field of ThunkContext is restored just prior
7111 to calling the 16-bit real mode entry point. This includes the EFLAGS field of RealModeState,
7112 which is used to set the interrupt state when a 16-bit real mode entry point is called.
7113 Control is transferred to the 16-bit real mode entry point specified by the CS and Eip fields of RealModeState.
7114 The stack is initialized to the SS and ESP fields of RealModeState. Any parameters passed to
7115 the 16-bit real mode code must be populated by the caller at SS:ESP prior to calling this function.
7116 The 16-bit real mode entry point is invoked with a 16-bit CALL FAR instruction,
7117 so when accessing stack contents, the 16-bit real mode code must account for the 16-bit segment
7118 and 16-bit offset of the return address that were pushed onto the stack. The 16-bit real mode entry
7119 point must exit with a RETF instruction. The register state is captured into RealModeState immediately
7120 after the RETF instruction is executed.
7122 If EFLAGS specifies interrupts enabled, or any of the 16-bit real mode code enables interrupts,
7123 or any of the 16-bit real mode code makes a SW interrupt, then the caller is responsible for making sure
7124 the IDT at address 0 is initialized to handle any HW or SW interrupts that may occur while in 16-bit real mode.
7126 If EFLAGS specifies interrupts enabled, or any of the 16-bit real mode code enables interrupts,
7127 then the caller is responsible for making sure the 8259 PIC is in a state compatible with 16-bit real mode.
7128 This includes the base vectors, the interrupt masks, and the edge/level trigger mode.
7130 If THUNK_ATTRIBUTE_BIG_REAL_MODE is set in the ThunkAttributes field of ThunkContext, then the user code
7131 is invoked in big real mode. Otherwise, the user code is invoked in 16-bit real mode with 64KB segment limits.
7133 If neither THUNK_ATTRIBUTE_DISABLE_A20_MASK_INT_15 nor THUNK_ATTRIBUTE_DISABLE_A20_MASK_KBD_CTRL are set in
7134 ThunkAttributes, then it is assumed that the user code did not enable the A20 mask, and no attempt is made to
7135 disable the A20 mask.
7137 If THUNK_ATTRIBUTE_DISABLE_A20_MASK_INT_15 is set and THUNK_ATTRIBUTE_DISABLE_A20_MASK_KBD_CTRL is clear in
7138 ThunkAttributes, then attempt to use the INT 15 service to disable the A20 mask. If this INT 15 call fails,
7139 then attempt to disable the A20 mask by directly accessing the 8042 keyboard controller I/O ports.
7141 If THUNK_ATTRIBUTE_DISABLE_A20_MASK_INT_15 is clear and THUNK_ATTRIBUTE_DISABLE_A20_MASK_KBD_CTRL is set in
7142 ThunkAttributes, then attempt to disable the A20 mask by directly accessing the 8042 keyboard controller I/O ports.
7144 If ThunkContext is NULL, then ASSERT().
7145 If AsmPrepareThunk16() was not previously called with ThunkContext, then ASSERT().
7146 If both THUNK_ATTRIBUTE_DISABLE_A20_MASK_INT_15 and THUNK_ATTRIBUTE_DISABLE_A20_MASK_KBD_CTRL are set in
7147 ThunkAttributes, then ASSERT().
7149 This interface is limited to be used in either physical mode or virtual modes with paging enabled where the
7150 virtual to physical mappings for ThunkContext.RealModeBuffer is mapped 1:1.
7152 @param ThunkContext A pointer to the context structure that describes the
7153 16-bit real mode code to call.
7159 IN OUT THUNK_CONTEXT
*ThunkContext
7164 Prepares all structures and code for a 16-bit real mode thunk, transfers
7165 control to a 16-bit real mode entry point, and returns the results.
7167 Prepares all structures and code for a 16-bit real mode thunk, transfers
7168 control to a 16-bit real mode entry point, and returns the results. If the
7169 caller only need to perform a single 16-bit real mode thunk, then this
7170 service should be used. If the caller intends to make more than one 16-bit
7171 real mode thunk, then it is more efficient if AsmPrepareThunk16() is called
7172 once and AsmThunk16() can be called for each 16-bit real mode thunk.
7174 This interface is limited to be used in either physical mode or virtual modes with paging enabled where the
7175 virtual to physical mappings for ThunkContext.RealModeBuffer is mapped 1:1.
7177 See AsmPrepareThunk16() and AsmThunk16() for the detailed description and ASSERT() conditions.
7179 @param ThunkContext A pointer to the context structure that describes the
7180 16-bit real mode code to call.
7185 AsmPrepareAndThunk16 (
7186 IN OUT THUNK_CONTEXT
*ThunkContext