2 Provides string functions, linked list functions, math functions, synchronization
3 functions, and CPU architecture-specific functions.
5 Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>
6 Portions copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>
7 This program and the accompanying materials
8 are licensed and made available under the terms and conditions of the BSD License
9 which accompanies this distribution. The full text of the license may be found at
10 http://opensource.org/licenses/bsd-license.php.
12 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
13 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
21 // Definitions for architecture-specific types
23 #if defined (MDE_CPU_IA32)
25 /// The IA-32 architecture context buffer used by SetJump() and LongJump().
34 } BASE_LIBRARY_JUMP_BUFFER
;
36 #define BASE_LIBRARY_JUMP_BUFFER_ALIGNMENT 4
38 #endif // defined (MDE_CPU_IA32)
40 #if defined (MDE_CPU_IPF)
43 /// The Itanium architecture context buffer used by SetJump() and LongJump().
78 UINT64 AfterSpillUNAT
;
84 } BASE_LIBRARY_JUMP_BUFFER
;
86 #define BASE_LIBRARY_JUMP_BUFFER_ALIGNMENT 0x10
88 #endif // defined (MDE_CPU_IPF)
90 #if defined (MDE_CPU_X64)
92 /// The x64 architecture context buffer used by SetJump() and LongJump().
106 UINT8 XmmBuffer
[160]; ///< XMM6-XMM15.
107 } BASE_LIBRARY_JUMP_BUFFER
;
109 #define BASE_LIBRARY_JUMP_BUFFER_ALIGNMENT 8
111 #endif // defined (MDE_CPU_X64)
113 #if defined (MDE_CPU_EBC)
115 /// The EBC context buffer used by SetJump() and LongJump().
123 } BASE_LIBRARY_JUMP_BUFFER
;
125 #define BASE_LIBRARY_JUMP_BUFFER_ALIGNMENT 8
127 #endif // defined (MDE_CPU_EBC)
129 #if defined (MDE_CPU_ARM)
132 UINT32 R3
; ///< A copy of R13.
143 } BASE_LIBRARY_JUMP_BUFFER
;
145 #define BASE_LIBRARY_JUMP_BUFFER_ALIGNMENT 4
147 #endif // defined (MDE_CPU_ARM)
154 Copies one Null-terminated Unicode string to another Null-terminated Unicode
155 string and returns the new Unicode string.
157 This function copies the contents of the Unicode string Source to the Unicode
158 string Destination, and returns Destination. If Source and Destination
159 overlap, then the results are undefined.
161 If Destination is NULL, then ASSERT().
162 If Destination is not aligned on a 16-bit boundary, then ASSERT().
163 If Source is NULL, then ASSERT().
164 If Source is not aligned on a 16-bit boundary, then ASSERT().
165 If Source and Destination overlap, then ASSERT().
166 If PcdMaximumUnicodeStringLength is not zero, and Source contains more than
167 PcdMaximumUnicodeStringLength Unicode characters not including the
168 Null-terminator, then ASSERT().
170 @param Destination The pointer to a Null-terminated Unicode string.
171 @param Source The pointer to a Null-terminated Unicode string.
179 OUT CHAR16
*Destination
,
180 IN CONST CHAR16
*Source
185 Copies up to a specified length from one Null-terminated Unicode string to
186 another Null-terminated Unicode string and returns the new Unicode string.
188 This function copies the contents of the Unicode string Source to the Unicode
189 string Destination, and returns Destination. At most, Length Unicode
190 characters are copied from Source to Destination. If Length is 0, then
191 Destination is returned unmodified. If Length is greater that the number of
192 Unicode characters in Source, then Destination is padded with Null Unicode
193 characters. If Source and Destination overlap, then the results are
196 If Length > 0 and Destination is NULL, then ASSERT().
197 If Length > 0 and Destination is not aligned on a 16-bit boundary, then ASSERT().
198 If Length > 0 and Source is NULL, then ASSERT().
199 If Length > 0 and Source is not aligned on a 16-bit boundary, then ASSERT().
200 If Source and Destination overlap, then ASSERT().
201 If PcdMaximumUnicodeStringLength is not zero, and Length is greater than
202 PcdMaximumUnicodeStringLength, then ASSERT().
203 If PcdMaximumUnicodeStringLength is not zero, and Source contains more than
204 PcdMaximumUnicodeStringLength Unicode characters, not including the Null-terminator,
207 @param Destination The pointer to a Null-terminated Unicode string.
208 @param Source The pointer to a Null-terminated Unicode string.
209 @param Length The maximum number of Unicode characters to copy.
217 OUT CHAR16
*Destination
,
218 IN CONST CHAR16
*Source
,
224 Returns the length of a Null-terminated Unicode string.
226 This function returns the number of Unicode characters in the Null-terminated
227 Unicode string specified by String.
229 If String is NULL, then ASSERT().
230 If String is not aligned on a 16-bit boundary, then ASSERT().
231 If PcdMaximumUnicodeStringLength is not zero, and String contains more than
232 PcdMaximumUnicodeStringLength Unicode characters not including the
233 Null-terminator, then ASSERT().
235 @param String Pointer to a Null-terminated Unicode string.
237 @return The length of String.
243 IN CONST CHAR16
*String
248 Returns the size of a Null-terminated Unicode string in bytes, including the
251 This function returns the size, in bytes, of the Null-terminated Unicode string
254 If String is NULL, then ASSERT().
255 If String is not aligned on a 16-bit boundary, then ASSERT().
256 If PcdMaximumUnicodeStringLength is not zero, and String contains more than
257 PcdMaximumUnicodeStringLength Unicode characters not including the
258 Null-terminator, then ASSERT().
260 @param String The pointer to a Null-terminated Unicode string.
262 @return The size of String.
268 IN CONST CHAR16
*String
273 Compares two Null-terminated Unicode strings, and returns the difference
274 between the first mismatched Unicode characters.
276 This function compares the Null-terminated Unicode string FirstString to the
277 Null-terminated Unicode string SecondString. If FirstString is identical to
278 SecondString, then 0 is returned. Otherwise, the value returned is the first
279 mismatched Unicode character in SecondString subtracted from the first
280 mismatched Unicode character in FirstString.
282 If FirstString is NULL, then ASSERT().
283 If FirstString is not aligned on a 16-bit boundary, then ASSERT().
284 If SecondString is NULL, then ASSERT().
285 If SecondString is not aligned on a 16-bit boundary, then ASSERT().
286 If PcdMaximumUnicodeStringLength is not zero, and FirstString contains more
287 than PcdMaximumUnicodeStringLength Unicode characters not including the
288 Null-terminator, then ASSERT().
289 If PcdMaximumUnicodeStringLength is not zero, and SecondString contains more
290 than PcdMaximumUnicodeStringLength Unicode characters, not including the
291 Null-terminator, then ASSERT().
293 @param FirstString The pointer to a Null-terminated Unicode string.
294 @param SecondString The pointer to a Null-terminated Unicode string.
296 @retval 0 FirstString is identical to SecondString.
297 @return others FirstString is not identical to SecondString.
303 IN CONST CHAR16
*FirstString
,
304 IN CONST CHAR16
*SecondString
309 Compares up to a specified length the contents of two Null-terminated Unicode strings,
310 and returns the difference between the first mismatched Unicode characters.
312 This function compares the Null-terminated Unicode string FirstString to the
313 Null-terminated Unicode string SecondString. At most, Length Unicode
314 characters will be compared. If Length is 0, then 0 is returned. If
315 FirstString is identical to SecondString, then 0 is returned. Otherwise, the
316 value returned is the first mismatched Unicode character in SecondString
317 subtracted from the first mismatched Unicode character in FirstString.
319 If Length > 0 and FirstString is NULL, then ASSERT().
320 If Length > 0 and FirstString is not aligned on a 16-bit boundary, then ASSERT().
321 If Length > 0 and SecondString is NULL, then ASSERT().
322 If Length > 0 and SecondString is not aligned on a 16-bit boundary, then ASSERT().
323 If PcdMaximumUnicodeStringLength is not zero, and Length is greater than
324 PcdMaximumUnicodeStringLength, then ASSERT().
325 If PcdMaximumUnicodeStringLength is not zero, and FirstString contains more than
326 PcdMaximumUnicodeStringLength Unicode characters, not including the Null-terminator,
328 If PcdMaximumUnicodeStringLength is not zero, and SecondString contains more than
329 PcdMaximumUnicodeStringLength Unicode characters, not including the Null-terminator,
332 @param FirstString The pointer to a Null-terminated Unicode string.
333 @param SecondString The pointer to a Null-terminated Unicode string.
334 @param Length The maximum number of Unicode characters to compare.
336 @retval 0 FirstString is identical to SecondString.
337 @return others FirstString is not identical to SecondString.
343 IN CONST CHAR16
*FirstString
,
344 IN CONST CHAR16
*SecondString
,
350 Concatenates one Null-terminated Unicode string to another Null-terminated
351 Unicode string, and returns the concatenated Unicode string.
353 This function concatenates two Null-terminated Unicode strings. The contents
354 of Null-terminated Unicode string Source are concatenated to the end of
355 Null-terminated Unicode string Destination. The Null-terminated concatenated
356 Unicode String is returned. If Source and Destination overlap, then the
357 results are undefined.
359 If Destination is NULL, then ASSERT().
360 If Destination is not aligned on a 16-bit boundary, then ASSERT().
361 If Source is NULL, then ASSERT().
362 If Source is not aligned on a 16-bit boundary, then ASSERT().
363 If Source and Destination overlap, then ASSERT().
364 If PcdMaximumUnicodeStringLength is not zero, and Destination contains more
365 than PcdMaximumUnicodeStringLength Unicode characters, not including the
366 Null-terminator, then ASSERT().
367 If PcdMaximumUnicodeStringLength is not zero, and Source contains more than
368 PcdMaximumUnicodeStringLength Unicode characters, not including the
369 Null-terminator, then ASSERT().
370 If PcdMaximumUnicodeStringLength is not zero, and concatenating Destination
371 and Source results in a Unicode string with more than
372 PcdMaximumUnicodeStringLength Unicode characters, not including the
373 Null-terminator, then ASSERT().
375 @param Destination The pointer to a Null-terminated Unicode string.
376 @param Source The pointer to a Null-terminated Unicode string.
384 IN OUT CHAR16
*Destination
,
385 IN CONST CHAR16
*Source
390 Concatenates up to a specified length one Null-terminated Unicode to the end
391 of another Null-terminated Unicode string, and returns the concatenated
394 This function concatenates two Null-terminated Unicode strings. The contents
395 of Null-terminated Unicode string Source are concatenated to the end of
396 Null-terminated Unicode string Destination, and Destination is returned. At
397 most, Length Unicode characters are concatenated from Source to the end of
398 Destination, and Destination is always Null-terminated. If Length is 0, then
399 Destination is returned unmodified. If Source and Destination overlap, then
400 the results are undefined.
402 If Destination is NULL, then ASSERT().
403 If Length > 0 and Destination is not aligned on a 16-bit boundary, then ASSERT().
404 If Length > 0 and Source is NULL, then ASSERT().
405 If Length > 0 and Source is not aligned on a 16-bit boundary, then ASSERT().
406 If Source and Destination overlap, then ASSERT().
407 If PcdMaximumUnicodeStringLength is not zero, and Length is greater than
408 PcdMaximumUnicodeStringLength, then ASSERT().
409 If PcdMaximumUnicodeStringLength is not zero, and Destination contains more
410 than PcdMaximumUnicodeStringLength Unicode characters, not including the
411 Null-terminator, then ASSERT().
412 If PcdMaximumUnicodeStringLength is not zero, and Source contains more than
413 PcdMaximumUnicodeStringLength Unicode characters, not including the
414 Null-terminator, then ASSERT().
415 If PcdMaximumUnicodeStringLength is not zero, and concatenating Destination
416 and Source results in a Unicode string with more than PcdMaximumUnicodeStringLength
417 Unicode characters, not including the Null-terminator, then ASSERT().
419 @param Destination The pointer to a Null-terminated Unicode string.
420 @param Source The pointer to a Null-terminated Unicode string.
421 @param Length The maximum number of Unicode characters to concatenate from
430 IN OUT CHAR16
*Destination
,
431 IN CONST CHAR16
*Source
,
436 Returns the first occurrence of a Null-terminated Unicode sub-string
437 in a Null-terminated Unicode string.
439 This function scans the contents of the Null-terminated Unicode string
440 specified by String and returns the first occurrence of SearchString.
441 If SearchString is not found in String, then NULL is returned. If
442 the length of SearchString is zero, then String is returned.
444 If String is NULL, then ASSERT().
445 If String is not aligned on a 16-bit boundary, then ASSERT().
446 If SearchString is NULL, then ASSERT().
447 If SearchString is not aligned on a 16-bit boundary, then ASSERT().
449 If PcdMaximumUnicodeStringLength is not zero, and SearchString
450 or String contains more than PcdMaximumUnicodeStringLength Unicode
451 characters, not including the Null-terminator, then ASSERT().
453 @param String The pointer to a Null-terminated Unicode string.
454 @param SearchString The pointer to a Null-terminated Unicode string to search for.
456 @retval NULL If the SearchString does not appear in String.
457 @return others If there is a match.
463 IN CONST CHAR16
*String
,
464 IN CONST CHAR16
*SearchString
468 Convert a Null-terminated Unicode decimal string to a value of
471 This function returns a value of type UINTN by interpreting the contents
472 of the Unicode string specified by String as a decimal number. The format
473 of the input Unicode string String is:
475 [spaces] [decimal digits].
477 The valid decimal digit character is in the range [0-9]. The
478 function will ignore the pad space, which includes spaces or
479 tab characters, before [decimal digits]. The running zero in the
480 beginning of [decimal digits] will be ignored. Then, the function
481 stops at the first character that is a not a valid decimal character
482 or a Null-terminator, whichever one comes first.
484 If String is NULL, then ASSERT().
485 If String is not aligned in a 16-bit boundary, then ASSERT().
486 If String has only pad spaces, then 0 is returned.
487 If String has no pad spaces or valid decimal digits,
489 If the number represented by String overflows according
490 to the range defined by UINTN, then ASSERT().
492 If PcdMaximumUnicodeStringLength is not zero, and String contains
493 more than PcdMaximumUnicodeStringLength Unicode characters not including
494 the Null-terminator, then ASSERT().
496 @param String The pointer to a Null-terminated Unicode string.
498 @retval Value translated from String.
504 IN CONST CHAR16
*String
508 Convert a Null-terminated Unicode decimal string to a value of
511 This function returns a value of type UINT64 by interpreting the contents
512 of the Unicode string specified by String as a decimal number. The format
513 of the input Unicode string String is:
515 [spaces] [decimal digits].
517 The valid decimal digit character is in the range [0-9]. The
518 function will ignore the pad space, which includes spaces or
519 tab characters, before [decimal digits]. The running zero in the
520 beginning of [decimal digits] will be ignored. Then, the function
521 stops at the first character that is a not a valid decimal character
522 or a Null-terminator, whichever one comes first.
524 If String is NULL, then ASSERT().
525 If String is not aligned in a 16-bit boundary, then ASSERT().
526 If String has only pad spaces, then 0 is returned.
527 If String has no pad spaces or valid decimal digits,
529 If the number represented by String overflows according
530 to the range defined by UINT64, then ASSERT().
532 If PcdMaximumUnicodeStringLength is not zero, and String contains
533 more than PcdMaximumUnicodeStringLength Unicode characters not including
534 the Null-terminator, then ASSERT().
536 @param String The pointer to a Null-terminated Unicode string.
538 @retval Value translated from String.
544 IN CONST CHAR16
*String
549 Convert a Null-terminated Unicode hexadecimal string to a value of type UINTN.
551 This function returns a value of type UINTN by interpreting the contents
552 of the Unicode string specified by String as a hexadecimal number.
553 The format of the input Unicode string String is:
555 [spaces][zeros][x][hexadecimal digits].
557 The valid hexadecimal digit character is in the range [0-9], [a-f] and [A-F].
558 The prefix "0x" is optional. Both "x" and "X" is allowed in "0x" prefix.
559 If "x" appears in the input string, it must be prefixed with at least one 0.
560 The function will ignore the pad space, which includes spaces or tab characters,
561 before [zeros], [x] or [hexadecimal digit]. The running zero before [x] or
562 [hexadecimal digit] will be ignored. Then, the decoding starts after [x] or the
563 first valid hexadecimal digit. Then, the function stops at the first character
564 that is a not a valid hexadecimal character or NULL, whichever one comes first.
566 If String is NULL, then ASSERT().
567 If String is not aligned in a 16-bit boundary, then ASSERT().
568 If String has only pad spaces, then zero is returned.
569 If String has no leading pad spaces, leading zeros or valid hexadecimal digits,
570 then zero is returned.
571 If the number represented by String overflows according to the range defined by
572 UINTN, then ASSERT().
574 If PcdMaximumUnicodeStringLength is not zero, and String contains more than
575 PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator,
578 @param String The pointer to a Null-terminated Unicode string.
580 @retval Value translated from String.
586 IN CONST CHAR16
*String
591 Convert a Null-terminated Unicode hexadecimal string to a value of type UINT64.
593 This function returns a value of type UINT64 by interpreting the contents
594 of the Unicode string specified by String as a hexadecimal number.
595 The format of the input Unicode string String is
597 [spaces][zeros][x][hexadecimal digits].
599 The valid hexadecimal digit character is in the range [0-9], [a-f] and [A-F].
600 The prefix "0x" is optional. Both "x" and "X" is allowed in "0x" prefix.
601 If "x" appears in the input string, it must be prefixed with at least one 0.
602 The function will ignore the pad space, which includes spaces or tab characters,
603 before [zeros], [x] or [hexadecimal digit]. The running zero before [x] or
604 [hexadecimal digit] will be ignored. Then, the decoding starts after [x] or the
605 first valid hexadecimal digit. Then, the function stops at the first character that is
606 a not a valid hexadecimal character or NULL, whichever one comes first.
608 If String is NULL, then ASSERT().
609 If String is not aligned in a 16-bit boundary, then ASSERT().
610 If String has only pad spaces, then zero is returned.
611 If String has no leading pad spaces, leading zeros or valid hexadecimal digits,
612 then zero is returned.
613 If the number represented by String overflows according to the range defined by
614 UINT64, then ASSERT().
616 If PcdMaximumUnicodeStringLength is not zero, and String contains more than
617 PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator,
620 @param String The pointer to a Null-terminated Unicode string.
622 @retval Value translated from String.
628 IN CONST CHAR16
*String
632 Convert a Null-terminated Unicode string to a Null-terminated
633 ASCII string and returns the ASCII string.
635 This function converts the content of the Unicode string Source
636 to the ASCII string Destination by copying the lower 8 bits of
637 each Unicode character. It returns Destination.
639 The caller is responsible to make sure Destination points to a buffer with size
640 equal or greater than ((StrLen (Source) + 1) * sizeof (CHAR8)) in bytes.
642 If any Unicode characters in Source contain non-zero value in
643 the upper 8 bits, then ASSERT().
645 If Destination is NULL, then ASSERT().
646 If Source is NULL, then ASSERT().
647 If Source is not aligned on a 16-bit boundary, then ASSERT().
648 If Source and Destination overlap, then ASSERT().
650 If PcdMaximumUnicodeStringLength is not zero, and Source contains
651 more than PcdMaximumUnicodeStringLength Unicode characters not including
652 the Null-terminator, then ASSERT().
654 If PcdMaximumAsciiStringLength is not zero, and Source contains more
655 than PcdMaximumAsciiStringLength Unicode characters not including the
656 Null-terminator, then ASSERT().
658 @param Source The pointer to a Null-terminated Unicode string.
659 @param Destination The pointer to a Null-terminated ASCII string.
666 UnicodeStrToAsciiStr (
667 IN CONST CHAR16
*Source
,
668 OUT CHAR8
*Destination
673 Copies one Null-terminated ASCII string to another Null-terminated ASCII
674 string and returns the new ASCII string.
676 This function copies the contents of the ASCII string Source to the ASCII
677 string Destination, and returns Destination. If Source and Destination
678 overlap, then the results are undefined.
680 If Destination is NULL, then ASSERT().
681 If Source is NULL, then ASSERT().
682 If Source and Destination overlap, then ASSERT().
683 If PcdMaximumAsciiStringLength is not zero and Source contains more than
684 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
687 @param Destination The pointer to a Null-terminated ASCII string.
688 @param Source The pointer to a Null-terminated ASCII string.
696 OUT CHAR8
*Destination
,
697 IN CONST CHAR8
*Source
702 Copies up to a specified length one Null-terminated ASCII string to another
703 Null-terminated ASCII string and returns the new ASCII string.
705 This function copies the contents of the ASCII string Source to the ASCII
706 string Destination, and returns Destination. At most, Length ASCII characters
707 are copied from Source to Destination. If Length is 0, then Destination is
708 returned unmodified. If Length is greater that the number of ASCII characters
709 in Source, then Destination is padded with Null ASCII characters. If Source
710 and Destination overlap, then the results are undefined.
712 If Destination is NULL, then ASSERT().
713 If Source is NULL, then ASSERT().
714 If Source and Destination overlap, then ASSERT().
715 If PcdMaximumAsciiStringLength is not zero, and Length is greater than
716 PcdMaximumAsciiStringLength, then ASSERT().
717 If PcdMaximumAsciiStringLength is not zero, and Source contains more than
718 PcdMaximumAsciiStringLength ASCII characters, not including the Null-terminator,
721 @param Destination The pointer to a Null-terminated ASCII string.
722 @param Source The pointer to a Null-terminated ASCII string.
723 @param Length The maximum number of ASCII characters to copy.
731 OUT CHAR8
*Destination
,
732 IN CONST CHAR8
*Source
,
738 Returns the length of a Null-terminated ASCII string.
740 This function returns the number of ASCII characters in the Null-terminated
741 ASCII string specified by String.
743 If Length > 0 and Destination is NULL, then ASSERT().
744 If Length > 0 and Source is NULL, then ASSERT().
745 If PcdMaximumAsciiStringLength is not zero and String contains more than
746 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
749 @param String The pointer to a Null-terminated ASCII string.
751 @return The length of String.
757 IN CONST CHAR8
*String
762 Returns the size of a Null-terminated ASCII string in bytes, including the
765 This function returns the size, in bytes, of the Null-terminated ASCII string
768 If String is NULL, then ASSERT().
769 If PcdMaximumAsciiStringLength is not zero and String contains more than
770 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
773 @param String The pointer to a Null-terminated ASCII string.
775 @return The size of String.
781 IN CONST CHAR8
*String
786 Compares two Null-terminated ASCII strings, and returns the difference
787 between the first mismatched ASCII characters.
789 This function compares the Null-terminated ASCII string FirstString to the
790 Null-terminated ASCII string SecondString. If FirstString is identical to
791 SecondString, then 0 is returned. Otherwise, the value returned is the first
792 mismatched ASCII character in SecondString subtracted from the first
793 mismatched ASCII character in FirstString.
795 If FirstString is NULL, then ASSERT().
796 If SecondString is NULL, then ASSERT().
797 If PcdMaximumAsciiStringLength is not zero and FirstString contains more than
798 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
800 If PcdMaximumAsciiStringLength is not zero and SecondString contains more
801 than PcdMaximumAsciiStringLength ASCII characters not including the
802 Null-terminator, then ASSERT().
804 @param FirstString The pointer to a Null-terminated ASCII string.
805 @param SecondString The pointer to a Null-terminated ASCII string.
807 @retval ==0 FirstString is identical to SecondString.
808 @retval !=0 FirstString is not identical to SecondString.
814 IN CONST CHAR8
*FirstString
,
815 IN CONST CHAR8
*SecondString
820 Performs a case insensitive comparison of two Null-terminated ASCII strings,
821 and returns the difference between the first mismatched ASCII characters.
823 This function performs a case insensitive comparison of the Null-terminated
824 ASCII string FirstString to the Null-terminated ASCII string SecondString. If
825 FirstString is identical to SecondString, then 0 is returned. Otherwise, the
826 value returned is the first mismatched lower case ASCII character in
827 SecondString subtracted from the first mismatched lower case ASCII character
830 If FirstString is NULL, then ASSERT().
831 If SecondString is NULL, then ASSERT().
832 If PcdMaximumAsciiStringLength is not zero and FirstString contains more than
833 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
835 If PcdMaximumAsciiStringLength is not zero and SecondString contains more
836 than PcdMaximumAsciiStringLength ASCII characters not including the
837 Null-terminator, then ASSERT().
839 @param FirstString The pointer to a Null-terminated ASCII string.
840 @param SecondString The pointer to a Null-terminated ASCII string.
842 @retval ==0 FirstString is identical to SecondString using case insensitive
844 @retval !=0 FirstString is not identical to SecondString using case
845 insensitive comparisons.
851 IN CONST CHAR8
*FirstString
,
852 IN CONST CHAR8
*SecondString
857 Compares two Null-terminated ASCII strings with maximum lengths, and returns
858 the difference between the first mismatched ASCII characters.
860 This function compares the Null-terminated ASCII string FirstString to the
861 Null-terminated ASCII string SecondString. At most, Length ASCII characters
862 will be compared. If Length is 0, then 0 is returned. If FirstString is
863 identical to SecondString, then 0 is returned. Otherwise, the value returned
864 is the first mismatched ASCII character in SecondString subtracted from the
865 first mismatched ASCII character in FirstString.
867 If Length > 0 and FirstString is NULL, then ASSERT().
868 If Length > 0 and SecondString is NULL, then ASSERT().
869 If PcdMaximumAsciiStringLength is not zero, and Length is greater than
870 PcdMaximumAsciiStringLength, then ASSERT().
871 If PcdMaximumAsciiStringLength is not zero, and FirstString contains more than
872 PcdMaximumAsciiStringLength ASCII characters, not including the Null-terminator,
874 If PcdMaximumAsciiStringLength is not zero, and SecondString contains more than
875 PcdMaximumAsciiStringLength ASCII characters, not including the Null-terminator,
878 @param FirstString The pointer to a Null-terminated ASCII string.
879 @param SecondString The pointer to a Null-terminated ASCII string.
880 @param Length The maximum number of ASCII characters for compare.
882 @retval ==0 FirstString is identical to SecondString.
883 @retval !=0 FirstString is not identical to SecondString.
889 IN CONST CHAR8
*FirstString
,
890 IN CONST CHAR8
*SecondString
,
896 Concatenates one Null-terminated ASCII string to another Null-terminated
897 ASCII string, and returns the concatenated ASCII string.
899 This function concatenates two Null-terminated ASCII strings. The contents of
900 Null-terminated ASCII string Source are concatenated to the end of Null-
901 terminated ASCII string Destination. The Null-terminated concatenated ASCII
904 If Destination is NULL, then ASSERT().
905 If Source is NULL, then ASSERT().
906 If PcdMaximumAsciiStringLength is not zero and Destination contains more than
907 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
909 If PcdMaximumAsciiStringLength is not zero and Source contains more than
910 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
912 If PcdMaximumAsciiStringLength is not zero and concatenating Destination and
913 Source results in a ASCII string with more than PcdMaximumAsciiStringLength
914 ASCII characters, then ASSERT().
916 @param Destination The pointer to a Null-terminated ASCII string.
917 @param Source The pointer to a Null-terminated ASCII string.
925 IN OUT CHAR8
*Destination
,
926 IN CONST CHAR8
*Source
931 Concatenates up to a specified length one Null-terminated ASCII string to
932 the end of another Null-terminated ASCII string, and returns the
933 concatenated ASCII string.
935 This function concatenates two Null-terminated ASCII strings. The contents
936 of Null-terminated ASCII string Source are concatenated to the end of Null-
937 terminated ASCII string Destination, and Destination is returned. At most,
938 Length ASCII characters are concatenated from Source to the end of
939 Destination, and Destination is always Null-terminated. If Length is 0, then
940 Destination is returned unmodified. If Source and Destination overlap, then
941 the results are undefined.
943 If Length > 0 and Destination is NULL, then ASSERT().
944 If Length > 0 and Source is NULL, then ASSERT().
945 If Source and Destination overlap, then ASSERT().
946 If PcdMaximumAsciiStringLength is not zero, and Length is greater than
947 PcdMaximumAsciiStringLength, then ASSERT().
948 If PcdMaximumAsciiStringLength is not zero, and Destination contains more than
949 PcdMaximumAsciiStringLength ASCII characters, not including the Null-terminator,
951 If PcdMaximumAsciiStringLength is not zero, and Source contains more than
952 PcdMaximumAsciiStringLength ASCII characters, not including the Null-terminator,
954 If PcdMaximumAsciiStringLength is not zero, and concatenating Destination and
955 Source results in a ASCII string with more than PcdMaximumAsciiStringLength
956 ASCII characters, not including the Null-terminator, then ASSERT().
958 @param Destination The pointer to a Null-terminated ASCII string.
959 @param Source The pointer to a Null-terminated ASCII string.
960 @param Length The maximum number of ASCII characters to concatenate from
969 IN OUT CHAR8
*Destination
,
970 IN CONST CHAR8
*Source
,
976 Returns the first occurrence of a Null-terminated ASCII sub-string
977 in a Null-terminated ASCII string.
979 This function scans the contents of the ASCII string specified by String
980 and returns the first occurrence of SearchString. If SearchString is not
981 found in String, then NULL is returned. If the length of SearchString is zero,
982 then String is returned.
984 If String is NULL, then ASSERT().
985 If SearchString is NULL, then ASSERT().
987 If PcdMaximumAsciiStringLength is not zero, and SearchString or
988 String contains more than PcdMaximumAsciiStringLength Unicode characters
989 not including the Null-terminator, then ASSERT().
991 @param String The pointer to a Null-terminated ASCII string.
992 @param SearchString The pointer to a Null-terminated ASCII string to search for.
994 @retval NULL If the SearchString does not appear in String.
995 @retval others If there is a match return the first occurrence of SearchingString.
996 If the length of SearchString is zero,return String.
1002 IN CONST CHAR8
*String
,
1003 IN CONST CHAR8
*SearchString
1008 Convert a Null-terminated ASCII decimal string to a value of type
1011 This function returns a value of type UINTN by interpreting the contents
1012 of the ASCII string String as a decimal number. The format of the input
1013 ASCII string String is:
1015 [spaces] [decimal digits].
1017 The valid decimal digit character is in the range [0-9]. The function will
1018 ignore the pad space, which includes spaces or tab characters, before the digits.
1019 The running zero in the beginning of [decimal digits] will be ignored. Then, the
1020 function stops at the first character that is a not a valid decimal character or
1021 Null-terminator, whichever on comes first.
1023 If String has only pad spaces, then 0 is returned.
1024 If String has no pad spaces or valid decimal digits, then 0 is returned.
1025 If the number represented by String overflows according to the range defined by
1026 UINTN, then ASSERT().
1027 If String is NULL, then ASSERT().
1028 If PcdMaximumAsciiStringLength is not zero, and String contains more than
1029 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
1032 @param String The pointer to a Null-terminated ASCII string.
1034 @retval The value translated from String.
1039 AsciiStrDecimalToUintn (
1040 IN CONST CHAR8
*String
1045 Convert a Null-terminated ASCII decimal string to a value of type
1048 This function returns a value of type UINT64 by interpreting the contents
1049 of the ASCII string String as a decimal number. The format of the input
1050 ASCII string String is:
1052 [spaces] [decimal digits].
1054 The valid decimal digit character is in the range [0-9]. The function will
1055 ignore the pad space, which includes spaces or tab characters, before the digits.
1056 The running zero in the beginning of [decimal digits] will be ignored. Then, the
1057 function stops at the first character that is a not a valid decimal character or
1058 Null-terminator, whichever on comes first.
1060 If String has only pad spaces, then 0 is returned.
1061 If String has no pad spaces or valid decimal digits, then 0 is returned.
1062 If the number represented by String overflows according to the range defined by
1063 UINT64, then ASSERT().
1064 If String is NULL, then ASSERT().
1065 If PcdMaximumAsciiStringLength is not zero, and String contains more than
1066 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
1069 @param String The pointer to a Null-terminated ASCII string.
1071 @retval Value translated from String.
1076 AsciiStrDecimalToUint64 (
1077 IN CONST CHAR8
*String
1082 Convert a Null-terminated ASCII hexadecimal string to a value of type UINTN.
1084 This function returns a value of type UINTN by interpreting the contents of
1085 the ASCII string String as a hexadecimal number. The format of the input ASCII
1088 [spaces][zeros][x][hexadecimal digits].
1090 The valid hexadecimal digit character is in the range [0-9], [a-f] and [A-F].
1091 The prefix "0x" is optional. Both "x" and "X" is allowed in "0x" prefix. If "x"
1092 appears in the input string, it must be prefixed with at least one 0. The function
1093 will ignore the pad space, which includes spaces or tab characters, before [zeros],
1094 [x] or [hexadecimal digits]. The running zero before [x] or [hexadecimal digits]
1095 will be ignored. Then, the decoding starts after [x] or the first valid hexadecimal
1096 digit. Then, the function stops at the first character that is a not a valid
1097 hexadecimal character or Null-terminator, whichever on comes first.
1099 If String has only pad spaces, then 0 is returned.
1100 If String has no leading pad spaces, leading zeros or valid hexadecimal digits, then
1103 If the number represented by String overflows according to the range defined by UINTN,
1105 If String is NULL, then ASSERT().
1106 If PcdMaximumAsciiStringLength is not zero,
1107 and String contains more than PcdMaximumAsciiStringLength ASCII characters not including
1108 the Null-terminator, then ASSERT().
1110 @param String The pointer to a Null-terminated ASCII string.
1112 @retval Value translated from String.
1117 AsciiStrHexToUintn (
1118 IN CONST CHAR8
*String
1123 Convert a Null-terminated ASCII hexadecimal string to a value of type UINT64.
1125 This function returns a value of type UINT64 by interpreting the contents of
1126 the ASCII string String as a hexadecimal number. The format of the input ASCII
1129 [spaces][zeros][x][hexadecimal digits].
1131 The valid hexadecimal digit character is in the range [0-9], [a-f] and [A-F].
1132 The prefix "0x" is optional. Both "x" and "X" is allowed in "0x" prefix. If "x"
1133 appears in the input string, it must be prefixed with at least one 0. The function
1134 will ignore the pad space, which includes spaces or tab characters, before [zeros],
1135 [x] or [hexadecimal digits]. The running zero before [x] or [hexadecimal digits]
1136 will be ignored. Then, the decoding starts after [x] or the first valid hexadecimal
1137 digit. Then, the function stops at the first character that is a not a valid
1138 hexadecimal character or Null-terminator, whichever on comes first.
1140 If String has only pad spaces, then 0 is returned.
1141 If String has no leading pad spaces, leading zeros or valid hexadecimal digits, then
1144 If the number represented by String overflows according to the range defined by UINT64,
1146 If String is NULL, then ASSERT().
1147 If PcdMaximumAsciiStringLength is not zero,
1148 and String contains more than PcdMaximumAsciiStringLength ASCII characters not including
1149 the Null-terminator, then ASSERT().
1151 @param String The pointer to a Null-terminated ASCII string.
1153 @retval Value translated from String.
1158 AsciiStrHexToUint64 (
1159 IN CONST CHAR8
*String
1164 Convert one Null-terminated ASCII string to a Null-terminated
1165 Unicode string and returns the Unicode string.
1167 This function converts the contents of the ASCII string Source to the Unicode
1168 string Destination, and returns Destination. The function terminates the
1169 Unicode string Destination by appending a Null-terminator character at the end.
1170 The caller is responsible to make sure Destination points to a buffer with size
1171 equal or greater than ((AsciiStrLen (Source) + 1) * sizeof (CHAR16)) in bytes.
1173 If Destination is NULL, then ASSERT().
1174 If Destination is not aligned on a 16-bit boundary, then ASSERT().
1175 If Source is NULL, then ASSERT().
1176 If Source and Destination overlap, then ASSERT().
1177 If PcdMaximumAsciiStringLength is not zero, and Source contains more than
1178 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
1180 If PcdMaximumUnicodeStringLength is not zero, and Source contains more than
1181 PcdMaximumUnicodeStringLength ASCII characters not including the
1182 Null-terminator, then ASSERT().
1184 @param Source The pointer to a Null-terminated ASCII string.
1185 @param Destination The pointer to a Null-terminated Unicode string.
1187 @return Destination.
1192 AsciiStrToUnicodeStr (
1193 IN CONST CHAR8
*Source
,
1194 OUT CHAR16
*Destination
1199 Converts an 8-bit value to an 8-bit BCD value.
1201 Converts the 8-bit value specified by Value to BCD. The BCD value is
1204 If Value >= 100, then ASSERT().
1206 @param Value The 8-bit value to convert to BCD. Range 0..99.
1208 @return The BCD value.
1219 Converts an 8-bit BCD value to an 8-bit value.
1221 Converts the 8-bit BCD value specified by Value to an 8-bit value. The 8-bit
1224 If Value >= 0xA0, then ASSERT().
1225 If (Value & 0x0F) >= 0x0A, then ASSERT().
1227 @param Value The 8-bit BCD value to convert to an 8-bit value.
1229 @return The 8-bit value is returned.
1240 // Linked List Functions and Macros
1244 Initializes the head node of a doubly linked list that is declared as a
1245 global variable in a module.
1247 Initializes the forward and backward links of a new linked list. After
1248 initializing a linked list with this macro, the other linked list functions
1249 may be used to add and remove nodes from the linked list. This macro results
1250 in smaller executables by initializing the linked list in the data section,
1251 instead if calling the InitializeListHead() function to perform the
1252 equivalent operation.
1254 @param ListHead The head note of a list to initialize.
1257 #define INITIALIZE_LIST_HEAD_VARIABLE(ListHead) {&(ListHead), &(ListHead)}
1261 Initializes the head node of a doubly linked list, and returns the pointer to
1262 the head node of the doubly linked list.
1264 Initializes the forward and backward links of a new linked list. After
1265 initializing a linked list with this function, the other linked list
1266 functions may be used to add and remove nodes from the linked list. It is up
1267 to the caller of this function to allocate the memory for ListHead.
1269 If ListHead is NULL, then ASSERT().
1271 @param ListHead A pointer to the head node of a new doubly linked list.
1278 InitializeListHead (
1279 IN OUT LIST_ENTRY
*ListHead
1284 Adds a node to the beginning of a doubly linked list, and returns the pointer
1285 to the head node of the doubly linked list.
1287 Adds the node Entry at the beginning of the doubly linked list denoted by
1288 ListHead, and returns ListHead.
1290 If ListHead is NULL, then ASSERT().
1291 If Entry is NULL, then ASSERT().
1292 If ListHead was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or
1293 InitializeListHead(), then ASSERT().
1294 If PcdMaximumLinkedListLenth is not zero, and prior to insertion the number
1295 of nodes in ListHead, including the ListHead node, is greater than or
1296 equal to PcdMaximumLinkedListLength, then ASSERT().
1298 @param ListHead A pointer to the head node of a doubly linked list.
1299 @param Entry A pointer to a node that is to be inserted at the beginning
1300 of a doubly linked list.
1308 IN OUT LIST_ENTRY
*ListHead
,
1309 IN OUT LIST_ENTRY
*Entry
1314 Adds a node to the end of a doubly linked list, and returns the pointer to
1315 the head node of the doubly linked list.
1317 Adds the node Entry to the end of the doubly linked list denoted by ListHead,
1318 and returns ListHead.
1320 If ListHead is NULL, then ASSERT().
1321 If Entry is NULL, then ASSERT().
1322 If ListHead was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or
1323 InitializeListHead(), then ASSERT().
1324 If PcdMaximumLinkedListLenth is not zero, and prior to insertion the number
1325 of nodes in ListHead, including the ListHead node, is greater than or
1326 equal to PcdMaximumLinkedListLength, then ASSERT().
1328 @param ListHead A pointer to the head node of a doubly linked list.
1329 @param Entry A pointer to a node that is to be added at the end of the
1338 IN OUT LIST_ENTRY
*ListHead
,
1339 IN OUT LIST_ENTRY
*Entry
1344 Retrieves the first node of a doubly linked list.
1346 Returns the first node of a doubly linked list. List must have been
1347 initialized with INTIALIZE_LIST_HEAD_VARIABLE() or InitializeListHead().
1348 If List is empty, then List is returned.
1350 If List is NULL, then ASSERT().
1351 If List was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or
1352 InitializeListHead(), then ASSERT().
1353 If PcdMaximumLinkedListLenth is not zero, and the number of nodes
1354 in List, including the List node, is greater than or equal to
1355 PcdMaximumLinkedListLength, then ASSERT().
1357 @param List A pointer to the head node of a doubly linked list.
1359 @return The first node of a doubly linked list.
1360 @retval NULL The list is empty.
1366 IN CONST LIST_ENTRY
*List
1371 Retrieves the next node of a doubly linked list.
1373 Returns the node of a doubly linked list that follows Node.
1374 List must have been initialized with INTIALIZE_LIST_HEAD_VARIABLE()
1375 or InitializeListHead(). If List is empty, then List is returned.
1377 If List is NULL, then ASSERT().
1378 If Node is NULL, then ASSERT().
1379 If List was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or
1380 InitializeListHead(), then ASSERT().
1381 If PcdMaximumLinkedListLenth is not zero, and List contains more than
1382 PcdMaximumLinkedListLenth nodes, then ASSERT().
1383 If PcdVerifyNodeInList is TRUE and Node is not a node in List, then ASSERT().
1385 @param List A pointer to the head node of a doubly linked list.
1386 @param Node A pointer to a node in the doubly linked list.
1388 @return The pointer to the next node if one exists. Otherwise List is returned.
1394 IN CONST LIST_ENTRY
*List
,
1395 IN CONST LIST_ENTRY
*Node
1400 Retrieves the previous node of a doubly linked list.
1402 Returns the node of a doubly linked list that precedes Node.
1403 List must have been initialized with INTIALIZE_LIST_HEAD_VARIABLE()
1404 or InitializeListHead(). If List is empty, then List is returned.
1406 If List is NULL, then ASSERT().
1407 If Node is NULL, then ASSERT().
1408 If List was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or
1409 InitializeListHead(), then ASSERT().
1410 If PcdMaximumLinkedListLenth is not zero, and List contains more than
1411 PcdMaximumLinkedListLenth nodes, then ASSERT().
1412 If PcdVerifyNodeInList is TRUE and Node is not a node in List, then ASSERT().
1414 @param List A pointer to the head node of a doubly linked list.
1415 @param Node A pointer to a node in the doubly linked list.
1417 @return The pointer to the previous node if one exists. Otherwise List is returned.
1423 IN CONST LIST_ENTRY
*List
,
1424 IN CONST LIST_ENTRY
*Node
1429 Checks to see if a doubly linked list is empty or not.
1431 Checks to see if the doubly linked list is empty. If the linked list contains
1432 zero nodes, this function returns TRUE. Otherwise, it returns FALSE.
1434 If ListHead is NULL, then ASSERT().
1435 If ListHead was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or
1436 InitializeListHead(), then ASSERT().
1437 If PcdMaximumLinkedListLenth is not zero, and the number of nodes
1438 in List, including the List node, is greater than or equal to
1439 PcdMaximumLinkedListLength, then ASSERT().
1441 @param ListHead A pointer to the head node of a doubly linked list.
1443 @retval TRUE The linked list is empty.
1444 @retval FALSE The linked list is not empty.
1450 IN CONST LIST_ENTRY
*ListHead
1455 Determines if a node in a doubly linked list is the head node of a the same
1456 doubly linked list. This function is typically used to terminate a loop that
1457 traverses all the nodes in a doubly linked list starting with the head node.
1459 Returns TRUE if Node is equal to List. Returns FALSE if Node is one of the
1460 nodes in the doubly linked list specified by List. List must have been
1461 initialized with INTIALIZE_LIST_HEAD_VARIABLE() or InitializeListHead().
1463 If List is NULL, then ASSERT().
1464 If Node is NULL, then ASSERT().
1465 If List was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or InitializeListHead(),
1467 If PcdMaximumLinkedListLenth is not zero, and the number of nodes
1468 in List, including the List node, is greater than or equal to
1469 PcdMaximumLinkedListLength, then ASSERT().
1470 If PcdVerifyNodeInList is TRUE and Node is not a node in List the and Node is not equal
1471 to List, then ASSERT().
1473 @param List A pointer to the head node of a doubly linked list.
1474 @param Node A pointer to a node in the doubly linked list.
1476 @retval TRUE Node is the head of the doubly-linked list pointed by List.
1477 @retval FALSE Node is not the head of the doubly-linked list pointed by List.
1483 IN CONST LIST_ENTRY
*List
,
1484 IN CONST LIST_ENTRY
*Node
1489 Determines if a node the last node in a doubly linked list.
1491 Returns TRUE if Node is the last node in the doubly linked list specified by
1492 List. Otherwise, FALSE is returned. List must have been initialized with
1493 INTIALIZE_LIST_HEAD_VARIABLE() or InitializeListHead().
1495 If List is NULL, then ASSERT().
1496 If Node is NULL, then ASSERT().
1497 If List was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or
1498 InitializeListHead(), then ASSERT().
1499 If PcdMaximumLinkedListLenth is not zero, and the number of nodes
1500 in List, including the List node, is greater than or equal to
1501 PcdMaximumLinkedListLength, then ASSERT().
1502 If PcdVerifyNodeInList is TRUE and Node is not a node in List, then ASSERT().
1504 @param List A pointer to the head node of a doubly linked list.
1505 @param Node A pointer to a node in the doubly linked list.
1507 @retval TRUE Node is the last node in the linked list.
1508 @retval FALSE Node is not the last node in the linked list.
1514 IN CONST LIST_ENTRY
*List
,
1515 IN CONST LIST_ENTRY
*Node
1520 Swaps the location of two nodes in a doubly linked list, and returns the
1521 first node after the swap.
1523 If FirstEntry is identical to SecondEntry, then SecondEntry is returned.
1524 Otherwise, the location of the FirstEntry node is swapped with the location
1525 of the SecondEntry node in a doubly linked list. SecondEntry must be in the
1526 same double linked list as FirstEntry and that double linked list must have
1527 been initialized with INTIALIZE_LIST_HEAD_VARIABLE() or InitializeListHead().
1528 SecondEntry is returned after the nodes are swapped.
1530 If FirstEntry is NULL, then ASSERT().
1531 If SecondEntry is NULL, then ASSERT().
1532 If PcdVerifyNodeInList is TRUE and SecondEntry and FirstEntry are not in the
1533 same linked list, then ASSERT().
1534 If PcdMaximumLinkedListLength is not zero, and the number of nodes in the
1535 linked list containing the FirstEntry and SecondEntry nodes, including
1536 the FirstEntry and SecondEntry nodes, is greater than or equal to
1537 PcdMaximumLinkedListLength, then ASSERT().
1539 @param FirstEntry A pointer to a node in a linked list.
1540 @param SecondEntry A pointer to another node in the same linked list.
1542 @return SecondEntry.
1548 IN OUT LIST_ENTRY
*FirstEntry
,
1549 IN OUT LIST_ENTRY
*SecondEntry
1554 Removes a node from a doubly linked list, and returns the node that follows
1557 Removes the node Entry from a doubly linked list. It is up to the caller of
1558 this function to release the memory used by this node if that is required. On
1559 exit, the node following Entry in the doubly linked list is returned. If
1560 Entry is the only node in the linked list, then the head node of the linked
1563 If Entry is NULL, then ASSERT().
1564 If Entry is the head node of an empty list, then ASSERT().
1565 If PcdMaximumLinkedListLength is not zero, and the number of nodes in the
1566 linked list containing Entry, including the Entry node, is greater than
1567 or equal to PcdMaximumLinkedListLength, then ASSERT().
1569 @param Entry A pointer to a node in a linked list.
1577 IN CONST LIST_ENTRY
*Entry
1585 Shifts a 64-bit integer left between 0 and 63 bits. The low bits are filled
1586 with zeros. The shifted value is returned.
1588 This function shifts the 64-bit value Operand to the left by Count bits. The
1589 low Count bits are set to zero. The shifted value is returned.
1591 If Count is greater than 63, then ASSERT().
1593 @param Operand The 64-bit operand to shift left.
1594 @param Count The number of bits to shift left.
1596 @return Operand << Count.
1608 Shifts a 64-bit integer right between 0 and 63 bits. This high bits are
1609 filled with zeros. The shifted value is returned.
1611 This function shifts the 64-bit value Operand to the right by Count bits. The
1612 high Count bits are set to zero. The shifted value is returned.
1614 If Count is greater than 63, then ASSERT().
1616 @param Operand The 64-bit operand to shift right.
1617 @param Count The number of bits to shift right.
1619 @return Operand >> Count
1631 Shifts a 64-bit integer right between 0 and 63 bits. The high bits are filled
1632 with original integer's bit 63. The shifted value is returned.
1634 This function shifts the 64-bit value Operand to the right by Count bits. The
1635 high Count bits are set to bit 63 of Operand. The shifted value is returned.
1637 If Count is greater than 63, then ASSERT().
1639 @param Operand The 64-bit operand to shift right.
1640 @param Count The number of bits to shift right.
1642 @return Operand >> Count
1654 Rotates a 32-bit integer left between 0 and 31 bits, filling the low bits
1655 with the high bits that were rotated.
1657 This function rotates the 32-bit value Operand to the left by Count bits. The
1658 low Count bits are fill with the high Count bits of Operand. The rotated
1661 If Count is greater than 31, then ASSERT().
1663 @param Operand The 32-bit operand to rotate left.
1664 @param Count The number of bits to rotate left.
1666 @return Operand << Count
1678 Rotates a 32-bit integer right between 0 and 31 bits, filling the high bits
1679 with the low bits that were rotated.
1681 This function rotates the 32-bit value Operand to the right by Count bits.
1682 The high Count bits are fill with the low Count bits of Operand. The rotated
1685 If Count is greater than 31, then ASSERT().
1687 @param Operand The 32-bit operand to rotate right.
1688 @param Count The number of bits to rotate right.
1690 @return Operand >> Count
1702 Rotates a 64-bit integer left between 0 and 63 bits, filling the low bits
1703 with the high bits that were rotated.
1705 This function rotates the 64-bit value Operand to the left by Count bits. The
1706 low Count bits are fill with the high Count bits of Operand. The rotated
1709 If Count is greater than 63, then ASSERT().
1711 @param Operand The 64-bit operand to rotate left.
1712 @param Count The number of bits to rotate left.
1714 @return Operand << Count
1726 Rotates a 64-bit integer right between 0 and 63 bits, filling the high bits
1727 with the high low bits that were rotated.
1729 This function rotates the 64-bit value Operand to the right by Count bits.
1730 The high Count bits are fill with the low Count bits of Operand. The rotated
1733 If Count is greater than 63, then ASSERT().
1735 @param Operand The 64-bit operand to rotate right.
1736 @param Count The number of bits to rotate right.
1738 @return Operand >> Count
1750 Returns the bit position of the lowest bit set in a 32-bit value.
1752 This function computes the bit position of the lowest bit set in the 32-bit
1753 value specified by Operand. If Operand is zero, then -1 is returned.
1754 Otherwise, a value between 0 and 31 is returned.
1756 @param Operand The 32-bit operand to evaluate.
1758 @retval 0..31 The lowest bit set in Operand was found.
1759 @retval -1 Operand is zero.
1770 Returns the bit position of the lowest bit set in a 64-bit value.
1772 This function computes the bit position of the lowest bit set in the 64-bit
1773 value specified by Operand. If Operand is zero, then -1 is returned.
1774 Otherwise, a value between 0 and 63 is returned.
1776 @param Operand The 64-bit operand to evaluate.
1778 @retval 0..63 The lowest bit set in Operand was found.
1779 @retval -1 Operand is zero.
1791 Returns the bit position of the highest bit set in a 32-bit value. Equivalent
1794 This function computes the bit position of the highest bit set in the 32-bit
1795 value specified by Operand. If Operand is zero, then -1 is returned.
1796 Otherwise, a value between 0 and 31 is returned.
1798 @param Operand The 32-bit operand to evaluate.
1800 @retval 0..31 Position of the highest bit set in Operand if found.
1801 @retval -1 Operand is zero.
1812 Returns the bit position of the highest bit set in a 64-bit value. Equivalent
1815 This function computes the bit position of the highest bit set in the 64-bit
1816 value specified by Operand. If Operand is zero, then -1 is returned.
1817 Otherwise, a value between 0 and 63 is returned.
1819 @param Operand The 64-bit operand to evaluate.
1821 @retval 0..63 Position of the highest bit set in Operand if found.
1822 @retval -1 Operand is zero.
1833 Returns the value of the highest bit set in a 32-bit value. Equivalent to
1836 This function computes the value of the highest bit set in the 32-bit value
1837 specified by Operand. If Operand is zero, then zero is returned.
1839 @param Operand The 32-bit operand to evaluate.
1841 @return 1 << HighBitSet32(Operand)
1842 @retval 0 Operand is zero.
1853 Returns the value of the highest bit set in a 64-bit value. Equivalent to
1856 This function computes the value of the highest bit set in the 64-bit value
1857 specified by Operand. If Operand is zero, then zero is returned.
1859 @param Operand The 64-bit operand to evaluate.
1861 @return 1 << HighBitSet64(Operand)
1862 @retval 0 Operand is zero.
1873 Switches the endianness of a 16-bit integer.
1875 This function swaps the bytes in a 16-bit unsigned value to switch the value
1876 from little endian to big endian or vice versa. The byte swapped value is
1879 @param Value A 16-bit unsigned value.
1881 @return The byte swapped Value.
1892 Switches the endianness of a 32-bit integer.
1894 This function swaps the bytes in a 32-bit unsigned value to switch the value
1895 from little endian to big endian or vice versa. The byte swapped value is
1898 @param Value A 32-bit unsigned value.
1900 @return The byte swapped Value.
1911 Switches the endianness of a 64-bit integer.
1913 This function swaps the bytes in a 64-bit unsigned value to switch the value
1914 from little endian to big endian or vice versa. The byte swapped value is
1917 @param Value A 64-bit unsigned value.
1919 @return The byte swapped Value.
1930 Multiples a 64-bit unsigned integer by a 32-bit unsigned integer and
1931 generates a 64-bit unsigned result.
1933 This function multiples the 64-bit unsigned value Multiplicand by the 32-bit
1934 unsigned value Multiplier and generates a 64-bit unsigned result. This 64-
1935 bit unsigned result is returned.
1937 @param Multiplicand A 64-bit unsigned value.
1938 @param Multiplier A 32-bit unsigned value.
1940 @return Multiplicand * Multiplier
1946 IN UINT64 Multiplicand
,
1947 IN UINT32 Multiplier
1952 Multiples a 64-bit unsigned integer by a 64-bit unsigned integer and
1953 generates a 64-bit unsigned result.
1955 This function multiples the 64-bit unsigned value Multiplicand by the 64-bit
1956 unsigned value Multiplier and generates a 64-bit unsigned result. This 64-
1957 bit unsigned result is returned.
1959 @param Multiplicand A 64-bit unsigned value.
1960 @param Multiplier A 64-bit unsigned value.
1962 @return Multiplicand * Multiplier.
1968 IN UINT64 Multiplicand
,
1969 IN UINT64 Multiplier
1974 Multiples a 64-bit signed integer by a 64-bit signed integer and generates a
1975 64-bit signed result.
1977 This function multiples the 64-bit signed value Multiplicand by the 64-bit
1978 signed value Multiplier and generates a 64-bit signed result. This 64-bit
1979 signed result is returned.
1981 @param Multiplicand A 64-bit signed value.
1982 @param Multiplier A 64-bit signed value.
1984 @return Multiplicand * Multiplier
1990 IN INT64 Multiplicand
,
1996 Divides a 64-bit unsigned integer by a 32-bit unsigned integer and generates
1997 a 64-bit unsigned result.
1999 This function divides the 64-bit unsigned value Dividend by the 32-bit
2000 unsigned value Divisor and generates a 64-bit unsigned quotient. This
2001 function returns the 64-bit unsigned quotient.
2003 If Divisor is 0, then ASSERT().
2005 @param Dividend A 64-bit unsigned value.
2006 @param Divisor A 32-bit unsigned value.
2008 @return Dividend / Divisor.
2020 Divides a 64-bit unsigned integer by a 32-bit unsigned integer and generates
2021 a 32-bit unsigned remainder.
2023 This function divides the 64-bit unsigned value Dividend by the 32-bit
2024 unsigned value Divisor and generates a 32-bit remainder. This function
2025 returns the 32-bit unsigned remainder.
2027 If Divisor is 0, then ASSERT().
2029 @param Dividend A 64-bit unsigned value.
2030 @param Divisor A 32-bit unsigned value.
2032 @return Dividend % Divisor.
2044 Divides a 64-bit unsigned integer by a 32-bit unsigned integer and generates
2045 a 64-bit unsigned result and an optional 32-bit unsigned remainder.
2047 This function divides the 64-bit unsigned value Dividend by the 32-bit
2048 unsigned value Divisor and generates a 64-bit unsigned quotient. If Remainder
2049 is not NULL, then the 32-bit unsigned remainder is returned in Remainder.
2050 This function returns the 64-bit unsigned quotient.
2052 If Divisor is 0, then ASSERT().
2054 @param Dividend A 64-bit unsigned value.
2055 @param Divisor A 32-bit unsigned value.
2056 @param Remainder A pointer to a 32-bit unsigned value. This parameter is
2057 optional and may be NULL.
2059 @return Dividend / Divisor.
2064 DivU64x32Remainder (
2067 OUT UINT32
*Remainder OPTIONAL
2072 Divides a 64-bit unsigned integer by a 64-bit unsigned integer and generates
2073 a 64-bit unsigned result and an optional 64-bit unsigned remainder.
2075 This function divides the 64-bit unsigned value Dividend by the 64-bit
2076 unsigned value Divisor and generates a 64-bit unsigned quotient. If Remainder
2077 is not NULL, then the 64-bit unsigned remainder is returned in Remainder.
2078 This function returns the 64-bit unsigned quotient.
2080 If Divisor is 0, then ASSERT().
2082 @param Dividend A 64-bit unsigned value.
2083 @param Divisor A 64-bit unsigned value.
2084 @param Remainder A pointer to a 64-bit unsigned value. This parameter is
2085 optional and may be NULL.
2087 @return Dividend / Divisor.
2092 DivU64x64Remainder (
2095 OUT UINT64
*Remainder OPTIONAL
2100 Divides a 64-bit signed integer by a 64-bit signed integer and generates a
2101 64-bit signed result and a optional 64-bit signed remainder.
2103 This function divides the 64-bit signed value Dividend by the 64-bit signed
2104 value Divisor and generates a 64-bit signed quotient. If Remainder is not
2105 NULL, then the 64-bit signed remainder is returned in Remainder. This
2106 function returns the 64-bit signed quotient.
2108 It is the caller's responsibility to not call this function with a Divisor of 0.
2109 If Divisor is 0, then the quotient and remainder should be assumed to be
2110 the largest negative integer.
2112 If Divisor is 0, then ASSERT().
2114 @param Dividend A 64-bit signed value.
2115 @param Divisor A 64-bit signed value.
2116 @param Remainder A pointer to a 64-bit signed value. This parameter is
2117 optional and may be NULL.
2119 @return Dividend / Divisor.
2124 DivS64x64Remainder (
2127 OUT INT64
*Remainder OPTIONAL
2132 Reads a 16-bit value from memory that may be unaligned.
2134 This function returns the 16-bit value pointed to by Buffer. The function
2135 guarantees that the read operation does not produce an alignment fault.
2137 If the Buffer is NULL, then ASSERT().
2139 @param Buffer The pointer to a 16-bit value that may be unaligned.
2141 @return The 16-bit value read from Buffer.
2147 IN CONST UINT16
*Buffer
2152 Writes a 16-bit value to memory that may be unaligned.
2154 This function writes the 16-bit value specified by Value to Buffer. Value is
2155 returned. The function guarantees that the write operation does not produce
2158 If the Buffer is NULL, then ASSERT().
2160 @param Buffer The pointer to a 16-bit value that may be unaligned.
2161 @param Value 16-bit value to write to Buffer.
2163 @return The 16-bit value to write to Buffer.
2175 Reads a 24-bit value from memory that may be unaligned.
2177 This function returns the 24-bit value pointed to by Buffer. The function
2178 guarantees that the read operation does not produce an alignment fault.
2180 If the Buffer is NULL, then ASSERT().
2182 @param Buffer The pointer to a 24-bit value that may be unaligned.
2184 @return The 24-bit value read from Buffer.
2190 IN CONST UINT32
*Buffer
2195 Writes a 24-bit value to memory that may be unaligned.
2197 This function writes the 24-bit value specified by Value to Buffer. Value is
2198 returned. The function guarantees that the write operation does not produce
2201 If the Buffer is NULL, then ASSERT().
2203 @param Buffer The pointer to a 24-bit value that may be unaligned.
2204 @param Value 24-bit value to write to Buffer.
2206 @return The 24-bit value to write to Buffer.
2218 Reads a 32-bit value from memory that may be unaligned.
2220 This function returns the 32-bit value pointed to by Buffer. The function
2221 guarantees that the read operation does not produce an alignment fault.
2223 If the Buffer is NULL, then ASSERT().
2225 @param Buffer The pointer to a 32-bit value that may be unaligned.
2227 @return The 32-bit value read from Buffer.
2233 IN CONST UINT32
*Buffer
2238 Writes a 32-bit value to memory that may be unaligned.
2240 This function writes the 32-bit value specified by Value to Buffer. Value is
2241 returned. The function guarantees that the write operation does not produce
2244 If the Buffer is NULL, then ASSERT().
2246 @param Buffer The pointer to a 32-bit value that may be unaligned.
2247 @param Value 32-bit value to write to Buffer.
2249 @return The 32-bit value to write to Buffer.
2261 Reads a 64-bit value from memory that may be unaligned.
2263 This function returns the 64-bit value pointed to by Buffer. The function
2264 guarantees that the read operation does not produce an alignment fault.
2266 If the Buffer is NULL, then ASSERT().
2268 @param Buffer The pointer to a 64-bit value that may be unaligned.
2270 @return The 64-bit value read from Buffer.
2276 IN CONST UINT64
*Buffer
2281 Writes a 64-bit value to memory that may be unaligned.
2283 This function writes the 64-bit value specified by Value to Buffer. Value is
2284 returned. The function guarantees that the write operation does not produce
2287 If the Buffer is NULL, then ASSERT().
2289 @param Buffer The pointer to a 64-bit value that may be unaligned.
2290 @param Value 64-bit value to write to Buffer.
2292 @return The 64-bit value to write to Buffer.
2304 // Bit Field Functions
2308 Returns a bit field from an 8-bit value.
2310 Returns the bitfield specified by the StartBit and the EndBit from Operand.
2312 If 8-bit operations are not supported, then ASSERT().
2313 If StartBit is greater than 7, then ASSERT().
2314 If EndBit is greater than 7, then ASSERT().
2315 If EndBit is less than StartBit, then ASSERT().
2317 @param Operand Operand on which to perform the bitfield operation.
2318 @param StartBit The ordinal of the least significant bit in the bit field.
2320 @param EndBit The ordinal of the most significant bit in the bit field.
2323 @return The bit field read.
2336 Writes a bit field to an 8-bit value, and returns the result.
2338 Writes Value to the bit field specified by the StartBit and the EndBit in
2339 Operand. All other bits in Operand are preserved. The new 8-bit value is
2342 If 8-bit operations are not supported, then ASSERT().
2343 If StartBit is greater than 7, then ASSERT().
2344 If EndBit is greater than 7, then ASSERT().
2345 If EndBit is less than StartBit, then ASSERT().
2347 @param Operand Operand on which to perform the bitfield operation.
2348 @param StartBit The ordinal of the least significant bit in the bit field.
2350 @param EndBit The ordinal of the most significant bit in the bit field.
2352 @param Value New value of the bit field.
2354 @return The new 8-bit value.
2368 Reads a bit field from an 8-bit value, performs a bitwise OR, and returns the
2371 Performs a bitwise OR between the bit field specified by StartBit
2372 and EndBit in Operand and the value specified by OrData. All other bits in
2373 Operand are preserved. The new 8-bit value is returned.
2375 If 8-bit operations are not supported, then ASSERT().
2376 If StartBit is greater than 7, then ASSERT().
2377 If EndBit is greater than 7, then ASSERT().
2378 If EndBit is less than StartBit, then ASSERT().
2380 @param Operand Operand on which to perform the bitfield operation.
2381 @param StartBit The ordinal of the least significant bit in the bit field.
2383 @param EndBit The ordinal of the most significant bit in the bit field.
2385 @param OrData The value to OR with the read value from the value
2387 @return The new 8-bit value.
2401 Reads a bit field from an 8-bit value, performs a bitwise AND, and returns
2404 Performs a bitwise AND between the bit field specified by StartBit and EndBit
2405 in Operand and the value specified by AndData. All other bits in Operand are
2406 preserved. The new 8-bit value is returned.
2408 If 8-bit operations are not supported, then ASSERT().
2409 If StartBit is greater than 7, then ASSERT().
2410 If EndBit is greater than 7, then ASSERT().
2411 If EndBit is less than StartBit, then ASSERT().
2413 @param Operand Operand on which to perform the bitfield operation.
2414 @param StartBit The ordinal of the least significant bit in the bit field.
2416 @param EndBit The ordinal of the most significant bit in the bit field.
2418 @param AndData The value to AND with the read value from the value.
2420 @return The new 8-bit value.
2434 Reads a bit field from an 8-bit value, performs a bitwise AND followed by a
2435 bitwise OR, and returns the result.
2437 Performs a bitwise AND between the bit field specified by StartBit and EndBit
2438 in Operand and the value specified by AndData, followed by a bitwise
2439 OR with value specified by OrData. All other bits in Operand are
2440 preserved. The new 8-bit value is returned.
2442 If 8-bit operations are not supported, then ASSERT().
2443 If StartBit is greater than 7, then ASSERT().
2444 If EndBit is greater than 7, then ASSERT().
2445 If EndBit is less than StartBit, then ASSERT().
2447 @param Operand Operand on which to perform the bitfield operation.
2448 @param StartBit The ordinal of the least significant bit in the bit field.
2450 @param EndBit The ordinal of the most significant bit in the bit field.
2452 @param AndData The value to AND with the read value from the value.
2453 @param OrData The value to OR with the result of the AND operation.
2455 @return The new 8-bit value.
2460 BitFieldAndThenOr8 (
2470 Returns a bit field from a 16-bit value.
2472 Returns the bitfield specified by the StartBit and the EndBit from Operand.
2474 If 16-bit operations are not supported, then ASSERT().
2475 If StartBit is greater than 15, then ASSERT().
2476 If EndBit is greater than 15, then ASSERT().
2477 If EndBit is less than StartBit, then ASSERT().
2479 @param Operand Operand on which to perform the bitfield operation.
2480 @param StartBit The ordinal of the least significant bit in the bit field.
2482 @param EndBit The ordinal of the most significant bit in the bit field.
2485 @return The bit field read.
2498 Writes a bit field to a 16-bit value, and returns the result.
2500 Writes Value to the bit field specified by the StartBit and the EndBit in
2501 Operand. All other bits in Operand are preserved. The new 16-bit value is
2504 If 16-bit operations are not supported, then ASSERT().
2505 If StartBit is greater than 15, then ASSERT().
2506 If EndBit is greater than 15, then ASSERT().
2507 If EndBit is less than StartBit, then ASSERT().
2509 @param Operand Operand on which to perform the bitfield operation.
2510 @param StartBit The ordinal of the least significant bit in the bit field.
2512 @param EndBit The ordinal of the most significant bit in the bit field.
2514 @param Value New value of the bit field.
2516 @return The new 16-bit value.
2530 Reads a bit field from a 16-bit value, performs a bitwise OR, and returns the
2533 Performs a bitwise OR between the bit field specified by StartBit
2534 and EndBit in Operand and the value specified by OrData. All other bits in
2535 Operand are preserved. The new 16-bit value is returned.
2537 If 16-bit operations are not supported, then ASSERT().
2538 If StartBit is greater than 15, then ASSERT().
2539 If EndBit is greater than 15, then ASSERT().
2540 If EndBit is less than StartBit, then ASSERT().
2542 @param Operand Operand on which to perform the bitfield operation.
2543 @param StartBit The ordinal of the least significant bit in the bit field.
2545 @param EndBit The ordinal of the most significant bit in the bit field.
2547 @param OrData The value to OR with the read value from the value
2549 @return The new 16-bit value.
2563 Reads a bit field from a 16-bit value, performs a bitwise AND, and returns
2566 Performs a bitwise AND between the bit field specified by StartBit and EndBit
2567 in Operand and the value specified by AndData. All other bits in Operand are
2568 preserved. The new 16-bit value is returned.
2570 If 16-bit operations are not supported, then ASSERT().
2571 If StartBit is greater than 15, then ASSERT().
2572 If EndBit is greater than 15, then ASSERT().
2573 If EndBit is less than StartBit, then ASSERT().
2575 @param Operand Operand on which to perform the bitfield operation.
2576 @param StartBit The ordinal of the least significant bit in the bit field.
2578 @param EndBit The ordinal of the most significant bit in the bit field.
2580 @param AndData The value to AND with the read value from the value
2582 @return The new 16-bit value.
2596 Reads a bit field from a 16-bit value, performs a bitwise AND followed by a
2597 bitwise OR, and returns the result.
2599 Performs a bitwise AND between the bit field specified by StartBit and EndBit
2600 in Operand and the value specified by AndData, followed by a bitwise
2601 OR with value specified by OrData. All other bits in Operand are
2602 preserved. The new 16-bit value is returned.
2604 If 16-bit operations are not supported, then ASSERT().
2605 If StartBit is greater than 15, then ASSERT().
2606 If EndBit is greater than 15, then ASSERT().
2607 If EndBit is less than StartBit, then ASSERT().
2609 @param Operand Operand on which to perform the bitfield operation.
2610 @param StartBit The ordinal of the least significant bit in the bit field.
2612 @param EndBit The ordinal of the most significant bit in the bit field.
2614 @param AndData The value to AND with the read value from the value.
2615 @param OrData The value to OR with the result of the AND operation.
2617 @return The new 16-bit value.
2622 BitFieldAndThenOr16 (
2632 Returns a bit field from a 32-bit value.
2634 Returns the bitfield specified by the StartBit and the EndBit from Operand.
2636 If 32-bit operations are not supported, then ASSERT().
2637 If StartBit is greater than 31, then ASSERT().
2638 If EndBit is greater than 31, then ASSERT().
2639 If EndBit is less than StartBit, then ASSERT().
2641 @param Operand Operand on which to perform the bitfield operation.
2642 @param StartBit The ordinal of the least significant bit in the bit field.
2644 @param EndBit The ordinal of the most significant bit in the bit field.
2647 @return The bit field read.
2660 Writes a bit field to a 32-bit value, and returns the result.
2662 Writes Value to the bit field specified by the StartBit and the EndBit in
2663 Operand. All other bits in Operand are preserved. The new 32-bit value is
2666 If 32-bit operations are not supported, then ASSERT().
2667 If StartBit is greater than 31, then ASSERT().
2668 If EndBit is greater than 31, then ASSERT().
2669 If EndBit is less than StartBit, then ASSERT().
2671 @param Operand Operand on which to perform the bitfield operation.
2672 @param StartBit The ordinal of the least significant bit in the bit field.
2674 @param EndBit The ordinal of the most significant bit in the bit field.
2676 @param Value New value of the bit field.
2678 @return The new 32-bit value.
2692 Reads a bit field from a 32-bit value, performs a bitwise OR, and returns the
2695 Performs a bitwise OR between the bit field specified by StartBit
2696 and EndBit in Operand and the value specified by OrData. All other bits in
2697 Operand are preserved. The new 32-bit value is returned.
2699 If 32-bit operations are not supported, then ASSERT().
2700 If StartBit is greater than 31, then ASSERT().
2701 If EndBit is greater than 31, then ASSERT().
2702 If EndBit is less than StartBit, then ASSERT().
2704 @param Operand Operand on which to perform the bitfield operation.
2705 @param StartBit The ordinal of the least significant bit in the bit field.
2707 @param EndBit The ordinal of the most significant bit in the bit field.
2709 @param OrData The value to OR with the read value from the value.
2711 @return The new 32-bit value.
2725 Reads a bit field from a 32-bit value, performs a bitwise AND, and returns
2728 Performs a bitwise AND between the bit field specified by StartBit and EndBit
2729 in Operand and the value specified by AndData. All other bits in Operand are
2730 preserved. The new 32-bit value is returned.
2732 If 32-bit operations are not supported, then ASSERT().
2733 If StartBit is greater than 31, then ASSERT().
2734 If EndBit is greater than 31, then ASSERT().
2735 If EndBit is less than StartBit, then ASSERT().
2737 @param Operand Operand on which to perform the bitfield operation.
2738 @param StartBit The ordinal of the least significant bit in the bit field.
2740 @param EndBit The ordinal of the most significant bit in the bit field.
2742 @param AndData The value to AND with the read value from the value
2744 @return The new 32-bit value.
2758 Reads a bit field from a 32-bit value, performs a bitwise AND followed by a
2759 bitwise OR, and returns the result.
2761 Performs a bitwise AND between the bit field specified by StartBit and EndBit
2762 in Operand and the value specified by AndData, followed by a bitwise
2763 OR with value specified by OrData. All other bits in Operand are
2764 preserved. The new 32-bit value is returned.
2766 If 32-bit operations are not supported, then ASSERT().
2767 If StartBit is greater than 31, then ASSERT().
2768 If EndBit is greater than 31, then ASSERT().
2769 If EndBit is less than StartBit, then ASSERT().
2771 @param Operand Operand on which to perform the bitfield operation.
2772 @param StartBit The ordinal of the least significant bit in the bit field.
2774 @param EndBit The ordinal of the most significant bit in the bit field.
2776 @param AndData The value to AND with the read value from the value.
2777 @param OrData The value to OR with the result of the AND operation.
2779 @return The new 32-bit value.
2784 BitFieldAndThenOr32 (
2794 Returns a bit field from a 64-bit value.
2796 Returns the bitfield specified by the StartBit and the EndBit from Operand.
2798 If 64-bit operations are not supported, then ASSERT().
2799 If StartBit is greater than 63, then ASSERT().
2800 If EndBit is greater than 63, then ASSERT().
2801 If EndBit is less than StartBit, then ASSERT().
2803 @param Operand Operand on which to perform the bitfield operation.
2804 @param StartBit The ordinal of the least significant bit in the bit field.
2806 @param EndBit The ordinal of the most significant bit in the bit field.
2809 @return The bit field read.
2822 Writes a bit field to a 64-bit value, and returns the result.
2824 Writes Value to the bit field specified by the StartBit and the EndBit in
2825 Operand. All other bits in Operand are preserved. The new 64-bit value is
2828 If 64-bit operations are not supported, then ASSERT().
2829 If StartBit is greater than 63, then ASSERT().
2830 If EndBit is greater than 63, then ASSERT().
2831 If EndBit is less than StartBit, then ASSERT().
2833 @param Operand Operand on which to perform the bitfield operation.
2834 @param StartBit The ordinal of the least significant bit in the bit field.
2836 @param EndBit The ordinal of the most significant bit in the bit field.
2838 @param Value New value of the bit field.
2840 @return The new 64-bit value.
2854 Reads a bit field from a 64-bit value, performs a bitwise OR, and returns the
2857 Performs a bitwise OR between the bit field specified by StartBit
2858 and EndBit in Operand and the value specified by OrData. All other bits in
2859 Operand are preserved. The new 64-bit value is returned.
2861 If 64-bit operations are not supported, then ASSERT().
2862 If StartBit is greater than 63, then ASSERT().
2863 If EndBit is greater than 63, then ASSERT().
2864 If EndBit is less than StartBit, then ASSERT().
2866 @param Operand Operand on which to perform the bitfield operation.
2867 @param StartBit The ordinal of the least significant bit in the bit field.
2869 @param EndBit The ordinal of the most significant bit in the bit field.
2871 @param OrData The value to OR with the read value from the value
2873 @return The new 64-bit value.
2887 Reads a bit field from a 64-bit value, performs a bitwise AND, and returns
2890 Performs a bitwise AND between the bit field specified by StartBit and EndBit
2891 in Operand and the value specified by AndData. All other bits in Operand are
2892 preserved. The new 64-bit value is returned.
2894 If 64-bit operations are not supported, then ASSERT().
2895 If StartBit is greater than 63, then ASSERT().
2896 If EndBit is greater than 63, then ASSERT().
2897 If EndBit is less than StartBit, then ASSERT().
2899 @param Operand Operand on which to perform the bitfield operation.
2900 @param StartBit The ordinal of the least significant bit in the bit field.
2902 @param EndBit The ordinal of the most significant bit in the bit field.
2904 @param AndData The value to AND with the read value from the value
2906 @return The new 64-bit value.
2920 Reads a bit field from a 64-bit value, performs a bitwise AND followed by a
2921 bitwise OR, and returns the result.
2923 Performs a bitwise AND between the bit field specified by StartBit and EndBit
2924 in Operand and the value specified by AndData, followed by a bitwise
2925 OR with value specified by OrData. All other bits in Operand are
2926 preserved. The new 64-bit value is returned.
2928 If 64-bit operations are not supported, then ASSERT().
2929 If StartBit is greater than 63, then ASSERT().
2930 If EndBit is greater than 63, then ASSERT().
2931 If EndBit is less than StartBit, then ASSERT().
2933 @param Operand Operand on which to perform the bitfield operation.
2934 @param StartBit The ordinal of the least significant bit in the bit field.
2936 @param EndBit The ordinal of the most significant bit in the bit field.
2938 @param AndData The value to AND with the read value from the value.
2939 @param OrData The value to OR with the result of the AND operation.
2941 @return The new 64-bit value.
2946 BitFieldAndThenOr64 (
2955 // Base Library Checksum Functions
2959 Returns the sum of all elements in a buffer in unit of UINT8.
2960 During calculation, the carry bits are dropped.
2962 This function calculates the sum of all elements in a buffer
2963 in unit of UINT8. The carry bits in result of addition are dropped.
2964 The result is returned as UINT8. If Length is Zero, then Zero is
2967 If Buffer is NULL, then ASSERT().
2968 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
2970 @param Buffer The pointer to the buffer to carry out the sum operation.
2971 @param Length The size, in bytes, of Buffer.
2973 @return Sum The sum of Buffer with carry bits dropped during additions.
2979 IN CONST UINT8
*Buffer
,
2985 Returns the two's complement checksum of all elements in a buffer
2988 This function first calculates the sum of the 8-bit values in the
2989 buffer specified by Buffer and Length. The carry bits in the result
2990 of addition are dropped. Then, the two's complement of the sum is
2991 returned. If Length is 0, then 0 is returned.
2993 If Buffer is NULL, then ASSERT().
2994 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
2996 @param Buffer The pointer to the buffer to carry out the checksum operation.
2997 @param Length The size, in bytes, of Buffer.
2999 @return Checksum The two's complement checksum of Buffer.
3004 CalculateCheckSum8 (
3005 IN CONST UINT8
*Buffer
,
3011 Returns the sum of all elements in a buffer of 16-bit values. During
3012 calculation, the carry bits are dropped.
3014 This function calculates the sum of the 16-bit values in the buffer
3015 specified by Buffer and Length. The carry bits in result of addition are dropped.
3016 The 16-bit result is returned. If Length is 0, then 0 is returned.
3018 If Buffer is NULL, then ASSERT().
3019 If Buffer is not aligned on a 16-bit boundary, then ASSERT().
3020 If Length is not aligned on a 16-bit boundary, then ASSERT().
3021 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
3023 @param Buffer The pointer to the buffer to carry out the sum operation.
3024 @param Length The size, in bytes, of Buffer.
3026 @return Sum The sum of Buffer with carry bits dropped during additions.
3032 IN CONST UINT16
*Buffer
,
3038 Returns the two's complement checksum of all elements in a buffer of
3041 This function first calculates the sum of the 16-bit values in the buffer
3042 specified by Buffer and Length. The carry bits in the result of addition
3043 are dropped. Then, the two's complement of the sum is returned. If Length
3044 is 0, then 0 is returned.
3046 If Buffer is NULL, then ASSERT().
3047 If Buffer is not aligned on a 16-bit boundary, then ASSERT().
3048 If Length is not aligned on a 16-bit boundary, then ASSERT().
3049 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
3051 @param Buffer The pointer to the buffer to carry out the checksum operation.
3052 @param Length The size, in bytes, of Buffer.
3054 @return Checksum The two's complement checksum of Buffer.
3059 CalculateCheckSum16 (
3060 IN CONST UINT16
*Buffer
,
3066 Returns the sum of all elements in a buffer of 32-bit values. During
3067 calculation, the carry bits are dropped.
3069 This function calculates the sum of the 32-bit values in the buffer
3070 specified by Buffer and Length. The carry bits in result of addition are dropped.
3071 The 32-bit result is returned. If Length is 0, then 0 is returned.
3073 If Buffer is NULL, then ASSERT().
3074 If Buffer is not aligned on a 32-bit boundary, then ASSERT().
3075 If Length is not aligned on a 32-bit boundary, then ASSERT().
3076 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
3078 @param Buffer The pointer to the buffer to carry out the sum operation.
3079 @param Length The size, in bytes, of Buffer.
3081 @return Sum The sum of Buffer with carry bits dropped during additions.
3087 IN CONST UINT32
*Buffer
,
3093 Returns the two's complement checksum of all elements in a buffer of
3096 This function first calculates the sum of the 32-bit values in the buffer
3097 specified by Buffer and Length. The carry bits in the result of addition
3098 are dropped. Then, the two's complement of the sum is returned. If Length
3099 is 0, then 0 is returned.
3101 If Buffer is NULL, then ASSERT().
3102 If Buffer is not aligned on a 32-bit boundary, then ASSERT().
3103 If Length is not aligned on a 32-bit boundary, then ASSERT().
3104 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
3106 @param Buffer The pointer to the buffer to carry out the checksum operation.
3107 @param Length The size, in bytes, of Buffer.
3109 @return Checksum The two's complement checksum of Buffer.
3114 CalculateCheckSum32 (
3115 IN CONST UINT32
*Buffer
,
3121 Returns the sum of all elements in a buffer of 64-bit values. During
3122 calculation, the carry bits are dropped.
3124 This function calculates the sum of the 64-bit values in the buffer
3125 specified by Buffer and Length. The carry bits in result of addition are dropped.
3126 The 64-bit result is returned. If Length is 0, then 0 is returned.
3128 If Buffer is NULL, then ASSERT().
3129 If Buffer is not aligned on a 64-bit boundary, then ASSERT().
3130 If Length is not aligned on a 64-bit boundary, then ASSERT().
3131 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
3133 @param Buffer The pointer to the buffer to carry out the sum operation.
3134 @param Length The size, in bytes, of Buffer.
3136 @return Sum The sum of Buffer with carry bits dropped during additions.
3142 IN CONST UINT64
*Buffer
,
3148 Returns the two's complement checksum of all elements in a buffer of
3151 This function first calculates the sum of the 64-bit values in the buffer
3152 specified by Buffer and Length. The carry bits in the result of addition
3153 are dropped. Then, the two's complement of the sum is returned. If Length
3154 is 0, then 0 is returned.
3156 If Buffer is NULL, then ASSERT().
3157 If Buffer is not aligned on a 64-bit boundary, then ASSERT().
3158 If Length is not aligned on a 64-bit boundary, then ASSERT().
3159 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
3161 @param Buffer The pointer to the buffer to carry out the checksum operation.
3162 @param Length The size, in bytes, of Buffer.
3164 @return Checksum The two's complement checksum of Buffer.
3169 CalculateCheckSum64 (
3170 IN CONST UINT64
*Buffer
,
3176 // Base Library CPU Functions
3180 Function entry point used when a stack switch is requested with SwitchStack()
3182 @param Context1 Context1 parameter passed into SwitchStack().
3183 @param Context2 Context2 parameter passed into SwitchStack().
3188 (EFIAPI
*SWITCH_STACK_ENTRY_POINT
)(
3189 IN VOID
*Context1
, OPTIONAL
3190 IN VOID
*Context2 OPTIONAL
3195 Used to serialize load and store operations.
3197 All loads and stores that proceed calls to this function are guaranteed to be
3198 globally visible when this function returns.
3209 Saves the current CPU context that can be restored with a call to LongJump()
3212 Saves the current CPU context in the buffer specified by JumpBuffer and
3213 returns 0. The initial call to SetJump() must always return 0. Subsequent
3214 calls to LongJump() cause a non-zero value to be returned by SetJump().
3216 If JumpBuffer is NULL, then ASSERT().
3217 For Itanium processors, if JumpBuffer is not aligned on a 16-byte boundary, then ASSERT().
3219 NOTE: The structure BASE_LIBRARY_JUMP_BUFFER is CPU architecture specific.
3220 The same structure must never be used for more than one CPU architecture context.
3221 For example, a BASE_LIBRARY_JUMP_BUFFER allocated by an IA-32 module must never be used from an x64 module.
3222 SetJump()/LongJump() is not currently supported for the EBC processor type.
3224 @param JumpBuffer A pointer to CPU context buffer.
3226 @retval 0 Indicates a return from SetJump().
3232 OUT BASE_LIBRARY_JUMP_BUFFER
*JumpBuffer
3237 Restores the CPU context that was saved with SetJump().
3239 Restores the CPU context from the buffer specified by JumpBuffer. This
3240 function never returns to the caller. Instead is resumes execution based on
3241 the state of JumpBuffer.
3243 If JumpBuffer is NULL, then ASSERT().
3244 For Itanium processors, if JumpBuffer is not aligned on a 16-byte boundary, then ASSERT().
3245 If Value is 0, then ASSERT().
3247 @param JumpBuffer A pointer to CPU context buffer.
3248 @param Value The value to return when the SetJump() context is
3249 restored and must be non-zero.
3255 IN BASE_LIBRARY_JUMP_BUFFER
*JumpBuffer
,
3261 Enables CPU interrupts.
3272 Disables CPU interrupts.
3283 Disables CPU interrupts and returns the interrupt state prior to the disable
3286 @retval TRUE CPU interrupts were enabled on entry to this call.
3287 @retval FALSE CPU interrupts were disabled on entry to this call.
3292 SaveAndDisableInterrupts (
3298 Enables CPU interrupts for the smallest window required to capture any
3304 EnableDisableInterrupts (
3310 Retrieves the current CPU interrupt state.
3312 Returns TRUE if interrupts are currently enabled. Otherwise
3315 @retval TRUE CPU interrupts are enabled.
3316 @retval FALSE CPU interrupts are disabled.
3327 Set the current CPU interrupt state.
3329 Sets the current CPU interrupt state to the state specified by
3330 InterruptState. If InterruptState is TRUE, then interrupts are enabled. If
3331 InterruptState is FALSE, then interrupts are disabled. InterruptState is
3334 @param InterruptState TRUE if interrupts should enabled. FALSE if
3335 interrupts should be disabled.
3337 @return InterruptState
3343 IN BOOLEAN InterruptState
3348 Requests CPU to pause for a short period of time.
3350 Requests CPU to pause for a short period of time. Typically used in MP
3351 systems to prevent memory starvation while waiting for a spin lock.
3362 Transfers control to a function starting with a new stack.
3364 Transfers control to the function specified by EntryPoint using the
3365 new stack specified by NewStack and passing in the parameters specified
3366 by Context1 and Context2. Context1 and Context2 are optional and may
3367 be NULL. The function EntryPoint must never return. This function
3368 supports a variable number of arguments following the NewStack parameter.
3369 These additional arguments are ignored on IA-32, x64, and EBC architectures.
3370 Itanium processors expect one additional parameter of type VOID * that specifies
3371 the new backing store pointer.
3373 If EntryPoint is NULL, then ASSERT().
3374 If NewStack is NULL, then ASSERT().
3376 @param EntryPoint A pointer to function to call with the new stack.
3377 @param Context1 A pointer to the context to pass into the EntryPoint
3379 @param Context2 A pointer to the context to pass into the EntryPoint
3381 @param NewStack A pointer to the new stack to use for the EntryPoint
3383 @param ... This variable argument list is ignored for IA-32, x64, and
3384 EBC architectures. For Itanium processors, this variable
3385 argument list is expected to contain a single parameter of
3386 type VOID * that specifies the new backing store pointer.
3393 IN SWITCH_STACK_ENTRY_POINT EntryPoint
,
3394 IN VOID
*Context1
, OPTIONAL
3395 IN VOID
*Context2
, OPTIONAL
3402 Generates a breakpoint on the CPU.
3404 Generates a breakpoint on the CPU. The breakpoint must be implemented such
3405 that code can resume normal execution after the breakpoint.
3416 Executes an infinite loop.
3418 Forces the CPU to execute an infinite loop. A debugger may be used to skip
3419 past the loop and the code that follows the loop must execute properly. This
3420 implies that the infinite loop must not cause the code that follow it to be
3430 #if defined (MDE_CPU_IPF)
3433 Flush a range of cache lines in the cache coherency domain of the calling
3436 Flushes the cache lines specified by Address and Length. If Address is not aligned
3437 on a cache line boundary, then entire cache line containing Address is flushed.
3438 If Address + Length is not aligned on a cache line boundary, then the entire cache
3439 line containing Address + Length - 1 is flushed. This function may choose to flush
3440 the entire cache if that is more efficient than flushing the specified range. If
3441 Length is 0, the no cache lines are flushed. Address is returned.
3442 This function is only available on Itanium processors.
3444 If Length is greater than (MAX_ADDRESS - Address + 1), then ASSERT().
3446 @param Address The base address of the instruction lines to invalidate. If
3447 the CPU is in a physical addressing mode, then Address is a
3448 physical address. If the CPU is in a virtual addressing mode,
3449 then Address is a virtual address.
3451 @param Length The number of bytes to invalidate from the instruction cache.
3458 AsmFlushCacheRange (
3465 Executes an FC instruction.
3466 Executes an FC instruction on the cache line specified by Address.
3467 The cache line size affected is at least 32-bytes (aligned on a 32-byte boundary).
3468 An implementation may flush a larger region. This function is only available on Itanium processors.
3470 @param Address The Address of cache line to be flushed.
3472 @return The address of FC instruction executed.
3483 Executes an FC.I instruction.
3484 Executes an FC.I instruction on the cache line specified by Address.
3485 The cache line size affected is at least 32-bytes (aligned on a 32-byte boundary).
3486 An implementation may flush a larger region. This function is only available on Itanium processors.
3488 @param Address The Address of cache line to be flushed.
3490 @return The address of the FC.I instruction executed.
3501 Reads the current value of a Processor Identifier Register (CPUID).
3503 Reads and returns the current value of Processor Identifier Register specified by Index.
3504 The Index of largest implemented CPUID (One less than the number of implemented CPUID
3505 registers) is determined by CPUID [3] bits {7:0}.
3506 No parameter checking is performed on Index. If the Index value is beyond the
3507 implemented CPUID register range, a Reserved Register/Field fault may occur. The caller
3508 must either guarantee that Index is valid, or the caller must set up fault handlers to
3509 catch the faults. This function is only available on Itanium processors.
3511 @param Index The 8-bit Processor Identifier Register index to read.
3513 @return The current value of Processor Identifier Register specified by Index.
3524 Reads the current value of 64-bit Processor Status Register (PSR).
3525 This function is only available on Itanium processors.
3527 @return The current value of PSR.
3538 Writes the current value of 64-bit Processor Status Register (PSR).
3540 No parameter checking is performed on Value. All bits of Value corresponding to
3541 reserved fields of PSR must be 0 or a Reserved Register/Field fault may occur.
3542 The caller must either guarantee that Value is valid, or the caller must set up
3543 fault handlers to catch the faults. This function is only available on Itanium processors.
3545 @param Value The 64-bit value to write to PSR.
3547 @return The 64-bit value written to the PSR.
3558 Reads the current value of 64-bit Kernel Register #0 (KR0).
3560 Reads and returns the current value of KR0.
3561 This function is only available on Itanium processors.
3563 @return The current value of KR0.
3574 Reads the current value of 64-bit Kernel Register #1 (KR1).
3576 Reads and returns the current value of KR1.
3577 This function is only available on Itanium processors.
3579 @return The current value of KR1.
3590 Reads the current value of 64-bit Kernel Register #2 (KR2).
3592 Reads and returns the current value of KR2.
3593 This function is only available on Itanium processors.
3595 @return The current value of KR2.
3606 Reads the current value of 64-bit Kernel Register #3 (KR3).
3608 Reads and returns the current value of KR3.
3609 This function is only available on Itanium processors.
3611 @return The current value of KR3.
3622 Reads the current value of 64-bit Kernel Register #4 (KR4).
3624 Reads and returns the current value of KR4.
3625 This function is only available on Itanium processors.
3627 @return The current value of KR4.
3638 Reads the current value of 64-bit Kernel Register #5 (KR5).
3640 Reads and returns the current value of KR5.
3641 This function is only available on Itanium processors.
3643 @return The current value of KR5.
3654 Reads the current value of 64-bit Kernel Register #6 (KR6).
3656 Reads and returns the current value of KR6.
3657 This function is only available on Itanium processors.
3659 @return The current value of KR6.
3670 Reads the current value of 64-bit Kernel Register #7 (KR7).
3672 Reads and returns the current value of KR7.
3673 This function is only available on Itanium processors.
3675 @return The current value of KR7.
3686 Write the current value of 64-bit Kernel Register #0 (KR0).
3688 Writes the current value of KR0. The 64-bit value written to
3689 the KR0 is returned. This function is only available on Itanium processors.
3691 @param Value The 64-bit value to write to KR0.
3693 @return The 64-bit value written to the KR0.
3704 Write the current value of 64-bit Kernel Register #1 (KR1).
3706 Writes the current value of KR1. The 64-bit value written to
3707 the KR1 is returned. This function is only available on Itanium processors.
3709 @param Value The 64-bit value to write to KR1.
3711 @return The 64-bit value written to the KR1.
3722 Write the current value of 64-bit Kernel Register #2 (KR2).
3724 Writes the current value of KR2. The 64-bit value written to
3725 the KR2 is returned. This function is only available on Itanium processors.
3727 @param Value The 64-bit value to write to KR2.
3729 @return The 64-bit value written to the KR2.
3740 Write the current value of 64-bit Kernel Register #3 (KR3).
3742 Writes the current value of KR3. The 64-bit value written to
3743 the KR3 is returned. This function is only available on Itanium processors.
3745 @param Value The 64-bit value to write to KR3.
3747 @return The 64-bit value written to the KR3.
3758 Write the current value of 64-bit Kernel Register #4 (KR4).
3760 Writes the current value of KR4. The 64-bit value written to
3761 the KR4 is returned. This function is only available on Itanium processors.
3763 @param Value The 64-bit value to write to KR4.
3765 @return The 64-bit value written to the KR4.
3776 Write the current value of 64-bit Kernel Register #5 (KR5).
3778 Writes the current value of KR5. The 64-bit value written to
3779 the KR5 is returned. This function is only available on Itanium processors.
3781 @param Value The 64-bit value to write to KR5.
3783 @return The 64-bit value written to the KR5.
3794 Write the current value of 64-bit Kernel Register #6 (KR6).
3796 Writes the current value of KR6. The 64-bit value written to
3797 the KR6 is returned. This function is only available on Itanium processors.
3799 @param Value The 64-bit value to write to KR6.
3801 @return The 64-bit value written to the KR6.
3812 Write the current value of 64-bit Kernel Register #7 (KR7).
3814 Writes the current value of KR7. The 64-bit value written to
3815 the KR7 is returned. This function is only available on Itanium processors.
3817 @param Value The 64-bit value to write to KR7.
3819 @return The 64-bit value written to the KR7.
3830 Reads the current value of Interval Timer Counter Register (ITC).
3832 Reads and returns the current value of ITC.
3833 This function is only available on Itanium processors.
3835 @return The current value of ITC.
3846 Reads the current value of Interval Timer Vector Register (ITV).
3848 Reads and returns the current value of ITV.
3849 This function is only available on Itanium processors.
3851 @return The current value of ITV.
3862 Reads the current value of Interval Timer Match Register (ITM).
3864 Reads and returns the current value of ITM.
3865 This function is only available on Itanium processors.
3867 @return The current value of ITM.
3877 Writes the current value of 64-bit Interval Timer Counter Register (ITC).
3879 Writes the current value of ITC. The 64-bit value written to the ITC is returned.
3880 This function is only available on Itanium processors.
3882 @param Value The 64-bit value to write to ITC.
3884 @return The 64-bit value written to the ITC.
3895 Writes the current value of 64-bit Interval Timer Match Register (ITM).
3897 Writes the current value of ITM. The 64-bit value written to the ITM is returned.
3898 This function is only available on Itanium processors.
3900 @param Value The 64-bit value to write to ITM.
3902 @return The 64-bit value written to the ITM.
3913 Writes the current value of 64-bit Interval Timer Vector Register (ITV).
3915 Writes the current value of ITV. The 64-bit value written to the ITV is returned.
3916 No parameter checking is performed on Value. All bits of Value corresponding to
3917 reserved fields of ITV must be 0 or a Reserved Register/Field fault may occur.
3918 The caller must either guarantee that Value is valid, or the caller must set up
3919 fault handlers to catch the faults.
3920 This function is only available on Itanium processors.
3922 @param Value The 64-bit value to write to ITV.
3924 @return The 64-bit value written to the ITV.
3935 Reads the current value of Default Control Register (DCR).
3937 Reads and returns the current value of DCR. This function is only available on Itanium processors.
3939 @return The current value of DCR.
3950 Reads the current value of Interruption Vector Address Register (IVA).
3952 Reads and returns the current value of IVA. This function is only available on Itanium processors.
3954 @return The current value of IVA.
3964 Reads the current value of Page Table Address Register (PTA).
3966 Reads and returns the current value of PTA. This function is only available on Itanium processors.
3968 @return The current value of PTA.
3979 Writes the current value of 64-bit Default Control Register (DCR).
3981 Writes the current value of DCR. The 64-bit value written to the DCR is returned.
3982 No parameter checking is performed on Value. All bits of Value corresponding to
3983 reserved fields of DCR must be 0 or a Reserved Register/Field fault may occur.
3984 The caller must either guarantee that Value is valid, or the caller must set up
3985 fault handlers to catch the faults.
3986 This function is only available on Itanium processors.
3988 @param Value The 64-bit value to write to DCR.
3990 @return The 64-bit value written to the DCR.
4001 Writes the current value of 64-bit Interruption Vector Address Register (IVA).
4003 Writes the current value of IVA. The 64-bit value written to the IVA is returned.
4004 The size of vector table is 32 K bytes and is 32 K bytes aligned
4005 the low 15 bits of Value is ignored when written.
4006 This function is only available on Itanium processors.
4008 @param Value The 64-bit value to write to IVA.
4010 @return The 64-bit value written to the IVA.
4021 Writes the current value of 64-bit Page Table Address Register (PTA).
4023 Writes the current value of PTA. The 64-bit value written to the PTA is returned.
4024 No parameter checking is performed on Value. All bits of Value corresponding to
4025 reserved fields of DCR must be 0 or a Reserved Register/Field fault may occur.
4026 The caller must either guarantee that Value is valid, or the caller must set up
4027 fault handlers to catch the faults.
4028 This function is only available on Itanium processors.
4030 @param Value The 64-bit value to write to PTA.
4032 @return The 64-bit value written to the PTA.
4042 Reads the current value of Local Interrupt ID Register (LID).
4044 Reads and returns the current value of LID. This function is only available on Itanium processors.
4046 @return The current value of LID.
4057 Reads the current value of External Interrupt Vector Register (IVR).
4059 Reads and returns the current value of IVR. This function is only available on Itanium processors.
4061 @return The current value of IVR.
4072 Reads the current value of Task Priority Register (TPR).
4074 Reads and returns the current value of TPR. This function is only available on Itanium processors.
4076 @return The current value of TPR.
4087 Reads the current value of External Interrupt Request Register #0 (IRR0).
4089 Reads and returns the current value of IRR0. This function is only available on Itanium processors.
4091 @return The current value of IRR0.
4102 Reads the current value of External Interrupt Request Register #1 (IRR1).
4104 Reads and returns the current value of IRR1. This function is only available on Itanium processors.
4106 @return The current value of IRR1.
4117 Reads the current value of External Interrupt Request Register #2 (IRR2).
4119 Reads and returns the current value of IRR2. This function is only available on Itanium processors.
4121 @return The current value of IRR2.
4132 Reads the current value of External Interrupt Request Register #3 (IRR3).
4134 Reads and returns the current value of IRR3. This function is only available on Itanium processors.
4136 @return The current value of IRR3.
4147 Reads the current value of Performance Monitor Vector Register (PMV).
4149 Reads and returns the current value of PMV. This function is only available on Itanium processors.
4151 @return The current value of PMV.
4162 Reads the current value of Corrected Machine Check Vector Register (CMCV).
4164 Reads and returns the current value of CMCV. This function is only available on Itanium processors.
4166 @return The current value of CMCV.
4177 Reads the current value of Local Redirection Register #0 (LRR0).
4179 Reads and returns the current value of LRR0. This function is only available on Itanium processors.
4181 @return The current value of LRR0.
4192 Reads the current value of Local Redirection Register #1 (LRR1).
4194 Reads and returns the current value of LRR1. This function is only available on Itanium processors.
4196 @return The current value of LRR1.
4207 Writes the current value of 64-bit Page Local Interrupt ID Register (LID).
4209 Writes the current value of LID. The 64-bit value written to the LID is returned.
4210 No parameter checking is performed on Value. All bits of Value corresponding to
4211 reserved fields of LID must be 0 or a Reserved Register/Field fault may occur.
4212 The caller must either guarantee that Value is valid, or the caller must set up
4213 fault handlers to catch the faults.
4214 This function is only available on Itanium processors.
4216 @param Value The 64-bit value to write to LID.
4218 @return The 64-bit value written to the LID.
4229 Writes the current value of 64-bit Task Priority Register (TPR).
4231 Writes the current value of TPR. The 64-bit value written to the TPR is returned.
4232 No parameter checking is performed on Value. All bits of Value corresponding to
4233 reserved fields of TPR must be 0 or a Reserved Register/Field fault may occur.
4234 The caller must either guarantee that Value is valid, or the caller must set up
4235 fault handlers to catch the faults.
4236 This function is only available on Itanium processors.
4238 @param Value The 64-bit value to write to TPR.
4240 @return The 64-bit value written to the TPR.
4251 Performs a write operation on End OF External Interrupt Register (EOI).
4253 Writes a value of 0 to the EOI Register. This function is only available on Itanium processors.
4264 Writes the current value of 64-bit Performance Monitor Vector Register (PMV).
4266 Writes the current value of PMV. The 64-bit value written to the PMV is returned.
4267 No parameter checking is performed on Value. All bits of Value corresponding
4268 to reserved fields of PMV must be 0 or a Reserved Register/Field fault may occur.
4269 The caller must either guarantee that Value is valid, or the caller must set up
4270 fault handlers to catch the faults.
4271 This function is only available on Itanium processors.
4273 @param Value The 64-bit value to write to PMV.
4275 @return The 64-bit value written to the PMV.
4286 Writes the current value of 64-bit Corrected Machine Check Vector Register (CMCV).
4288 Writes the current value of CMCV. The 64-bit value written to the CMCV is returned.
4289 No parameter checking is performed on Value. All bits of Value corresponding
4290 to reserved fields of CMCV must be 0 or a Reserved Register/Field fault may occur.
4291 The caller must either guarantee that Value is valid, or the caller must set up
4292 fault handlers to catch the faults.
4293 This function is only available on Itanium processors.
4295 @param Value The 64-bit value to write to CMCV.
4297 @return The 64-bit value written to the CMCV.
4308 Writes the current value of 64-bit Local Redirection Register #0 (LRR0).
4310 Writes the current value of LRR0. The 64-bit value written to the LRR0 is returned.
4311 No parameter checking is performed on Value. All bits of Value corresponding
4312 to reserved fields of LRR0 must be 0 or a Reserved Register/Field fault may occur.
4313 The caller must either guarantee that Value is valid, or the caller must set up
4314 fault handlers to catch the faults.
4315 This function is only available on Itanium processors.
4317 @param Value The 64-bit value to write to LRR0.
4319 @return The 64-bit value written to the LRR0.
4330 Writes the current value of 64-bit Local Redirection Register #1 (LRR1).
4332 Writes the current value of LRR1. The 64-bit value written to the LRR1 is returned.
4333 No parameter checking is performed on Value. All bits of Value corresponding
4334 to reserved fields of LRR1 must be 0 or a Reserved Register/Field fault may occur.
4335 The caller must either guarantee that Value is valid, or the caller must
4336 set up fault handlers to catch the faults.
4337 This function is only available on Itanium processors.
4339 @param Value The 64-bit value to write to LRR1.
4341 @return The 64-bit value written to the LRR1.
4352 Reads the current value of Instruction Breakpoint Register (IBR).
4354 The Instruction Breakpoint Registers are used in pairs. The even numbered
4355 registers contain breakpoint addresses, and the odd numbered registers contain
4356 breakpoint mask conditions. At least four instruction registers pairs are implemented
4357 on all processor models. Implemented registers are contiguous starting with
4358 register 0. No parameter checking is performed on Index, and if the Index value
4359 is beyond the implemented IBR register range, a Reserved Register/Field fault may
4360 occur. The caller must either guarantee that Index is valid, or the caller must
4361 set up fault handlers to catch the faults.
4362 This function is only available on Itanium processors.
4364 @param Index The 8-bit Instruction Breakpoint Register index to read.
4366 @return The current value of Instruction Breakpoint Register specified by Index.
4377 Reads the current value of Data Breakpoint Register (DBR).
4379 The Data Breakpoint Registers are used in pairs. The even numbered registers
4380 contain breakpoint addresses, and odd numbered registers contain breakpoint
4381 mask conditions. At least four data registers pairs are implemented on all processor
4382 models. Implemented registers are contiguous starting with register 0.
4383 No parameter checking is performed on Index. If the Index value is beyond
4384 the implemented DBR register range, a Reserved Register/Field fault may occur.
4385 The caller must either guarantee that Index is valid, or the caller must set up
4386 fault handlers to catch the faults.
4387 This function is only available on Itanium processors.
4389 @param Index The 8-bit Data Breakpoint Register index to read.
4391 @return The current value of Data Breakpoint Register specified by Index.
4402 Reads the current value of Performance Monitor Configuration Register (PMC).
4404 All processor implementations provide at least four performance counters
4405 (PMC/PMD [4]...PMC/PMD [7] pairs), and four performance monitor counter overflow
4406 status registers (PMC [0]... PMC [3]). Processor implementations may provide
4407 additional implementation-dependent PMC and PMD to increase the number of
4408 'generic' performance counters (PMC/PMD pairs). The remainder of PMC and PMD
4409 register set is implementation dependent. No parameter checking is performed
4410 on Index. If the Index value is beyond the implemented PMC register range,
4411 zero value will be returned.
4412 This function is only available on Itanium processors.
4414 @param Index The 8-bit Performance Monitor Configuration Register index to read.
4416 @return The current value of Performance Monitor Configuration Register
4428 Reads the current value of Performance Monitor Data Register (PMD).
4430 All processor implementations provide at least 4 performance counters
4431 (PMC/PMD [4]...PMC/PMD [7] pairs), and 4 performance monitor counter
4432 overflow status registers (PMC [0]... PMC [3]). Processor implementations may
4433 provide additional implementation-dependent PMC and PMD to increase the number
4434 of 'generic' performance counters (PMC/PMD pairs). The remainder of PMC and PMD
4435 register set is implementation dependent. No parameter checking is performed
4436 on Index. If the Index value is beyond the implemented PMD register range,
4437 zero value will be returned.
4438 This function is only available on Itanium processors.
4440 @param Index The 8-bit Performance Monitor Data Register index to read.
4442 @return The current value of Performance Monitor Data Register specified by Index.
4453 Writes the current value of 64-bit Instruction Breakpoint Register (IBR).
4455 Writes current value of Instruction Breakpoint Register specified by Index.
4456 The Instruction Breakpoint Registers are used in pairs. The even numbered
4457 registers contain breakpoint addresses, and odd numbered registers contain
4458 breakpoint mask conditions. At least four instruction registers pairs are implemented
4459 on all processor models. Implemented registers are contiguous starting with
4460 register 0. No parameter checking is performed on Index. If the Index value
4461 is beyond the implemented IBR register range, a Reserved Register/Field fault may
4462 occur. The caller must either guarantee that Index is valid, or the caller must
4463 set up fault handlers to catch the faults.
4464 This function is only available on Itanium processors.
4466 @param Index The 8-bit Instruction Breakpoint Register index to write.
4467 @param Value The 64-bit value to write to IBR.
4469 @return The 64-bit value written to the IBR.
4481 Writes the current value of 64-bit Data Breakpoint Register (DBR).
4483 Writes current value of Data Breakpoint Register specified by Index.
4484 The Data Breakpoint Registers are used in pairs. The even numbered registers
4485 contain breakpoint addresses, and odd numbered registers contain breakpoint
4486 mask conditions. At least four data registers pairs are implemented on all processor
4487 models. Implemented registers are contiguous starting with register 0. No parameter
4488 checking is performed on Index. If the Index value is beyond the implemented
4489 DBR register range, a Reserved Register/Field fault may occur. The caller must
4490 either guarantee that Index is valid, or the caller must set up fault handlers to
4492 This function is only available on Itanium processors.
4494 @param Index The 8-bit Data Breakpoint Register index to write.
4495 @param Value The 64-bit value to write to DBR.
4497 @return The 64-bit value written to the DBR.
4509 Writes the current value of 64-bit Performance Monitor Configuration Register (PMC).
4511 Writes current value of Performance Monitor Configuration Register specified by Index.
4512 All processor implementations provide at least four performance counters
4513 (PMC/PMD [4]...PMC/PMD [7] pairs), and four performance monitor counter overflow status
4514 registers (PMC [0]... PMC [3]). Processor implementations may provide additional
4515 implementation-dependent PMC and PMD to increase the number of 'generic' performance
4516 counters (PMC/PMD pairs). The remainder of PMC and PMD register set is implementation
4517 dependent. No parameter checking is performed on Index. If the Index value is
4518 beyond the implemented PMC register range, the write is ignored.
4519 This function is only available on Itanium processors.
4521 @param Index The 8-bit Performance Monitor Configuration Register index to write.
4522 @param Value The 64-bit value to write to PMC.
4524 @return The 64-bit value written to the PMC.
4536 Writes the current value of 64-bit Performance Monitor Data Register (PMD).
4538 Writes current value of Performance Monitor Data Register specified by Index.
4539 All processor implementations provide at least four performance counters
4540 (PMC/PMD [4]...PMC/PMD [7] pairs), and four performance monitor counter overflow
4541 status registers (PMC [0]... PMC [3]). Processor implementations may provide
4542 additional implementation-dependent PMC and PMD to increase the number of 'generic'
4543 performance counters (PMC/PMD pairs). The remainder of PMC and PMD register set
4544 is implementation dependent. No parameter checking is performed on Index. If the
4545 Index value is beyond the implemented PMD register range, the write is ignored.
4546 This function is only available on Itanium processors.
4548 @param Index The 8-bit Performance Monitor Data Register index to write.
4549 @param Value The 64-bit value to write to PMD.
4551 @return The 64-bit value written to the PMD.
4563 Reads the current value of 64-bit Global Pointer (GP).
4565 Reads and returns the current value of GP.
4566 This function is only available on Itanium processors.
4568 @return The current value of GP.
4579 Write the current value of 64-bit Global Pointer (GP).
4581 Writes the current value of GP. The 64-bit value written to the GP is returned.
4582 No parameter checking is performed on Value.
4583 This function is only available on Itanium processors.
4585 @param Value The 64-bit value to write to GP.
4587 @return The 64-bit value written to the GP.
4598 Reads the current value of 64-bit Stack Pointer (SP).
4600 Reads and returns the current value of SP.
4601 This function is only available on Itanium processors.
4603 @return The current value of SP.
4614 /// Valid Index value for AsmReadControlRegister().
4616 #define IPF_CONTROL_REGISTER_DCR 0
4617 #define IPF_CONTROL_REGISTER_ITM 1
4618 #define IPF_CONTROL_REGISTER_IVA 2
4619 #define IPF_CONTROL_REGISTER_PTA 8
4620 #define IPF_CONTROL_REGISTER_IPSR 16
4621 #define IPF_CONTROL_REGISTER_ISR 17
4622 #define IPF_CONTROL_REGISTER_IIP 19
4623 #define IPF_CONTROL_REGISTER_IFA 20
4624 #define IPF_CONTROL_REGISTER_ITIR 21
4625 #define IPF_CONTROL_REGISTER_IIPA 22
4626 #define IPF_CONTROL_REGISTER_IFS 23
4627 #define IPF_CONTROL_REGISTER_IIM 24
4628 #define IPF_CONTROL_REGISTER_IHA 25
4629 #define IPF_CONTROL_REGISTER_LID 64
4630 #define IPF_CONTROL_REGISTER_IVR 65
4631 #define IPF_CONTROL_REGISTER_TPR 66
4632 #define IPF_CONTROL_REGISTER_EOI 67
4633 #define IPF_CONTROL_REGISTER_IRR0 68
4634 #define IPF_CONTROL_REGISTER_IRR1 69
4635 #define IPF_CONTROL_REGISTER_IRR2 70
4636 #define IPF_CONTROL_REGISTER_IRR3 71
4637 #define IPF_CONTROL_REGISTER_ITV 72
4638 #define IPF_CONTROL_REGISTER_PMV 73
4639 #define IPF_CONTROL_REGISTER_CMCV 74
4640 #define IPF_CONTROL_REGISTER_LRR0 80
4641 #define IPF_CONTROL_REGISTER_LRR1 81
4644 Reads a 64-bit control register.
4646 Reads and returns the control register specified by Index. The valid Index valued
4647 are defined above in "Related Definitions".
4648 If Index is invalid then 0xFFFFFFFFFFFFFFFF is returned. This function is only
4649 available on Itanium processors.
4651 @param Index The index of the control register to read.
4653 @return The control register specified by Index.
4658 AsmReadControlRegister (
4664 /// Valid Index value for AsmReadApplicationRegister().
4666 #define IPF_APPLICATION_REGISTER_K0 0
4667 #define IPF_APPLICATION_REGISTER_K1 1
4668 #define IPF_APPLICATION_REGISTER_K2 2
4669 #define IPF_APPLICATION_REGISTER_K3 3
4670 #define IPF_APPLICATION_REGISTER_K4 4
4671 #define IPF_APPLICATION_REGISTER_K5 5
4672 #define IPF_APPLICATION_REGISTER_K6 6
4673 #define IPF_APPLICATION_REGISTER_K7 7
4674 #define IPF_APPLICATION_REGISTER_RSC 16
4675 #define IPF_APPLICATION_REGISTER_BSP 17
4676 #define IPF_APPLICATION_REGISTER_BSPSTORE 18
4677 #define IPF_APPLICATION_REGISTER_RNAT 19
4678 #define IPF_APPLICATION_REGISTER_FCR 21
4679 #define IPF_APPLICATION_REGISTER_EFLAG 24
4680 #define IPF_APPLICATION_REGISTER_CSD 25
4681 #define IPF_APPLICATION_REGISTER_SSD 26
4682 #define IPF_APPLICATION_REGISTER_CFLG 27
4683 #define IPF_APPLICATION_REGISTER_FSR 28
4684 #define IPF_APPLICATION_REGISTER_FIR 29
4685 #define IPF_APPLICATION_REGISTER_FDR 30
4686 #define IPF_APPLICATION_REGISTER_CCV 32
4687 #define IPF_APPLICATION_REGISTER_UNAT 36
4688 #define IPF_APPLICATION_REGISTER_FPSR 40
4689 #define IPF_APPLICATION_REGISTER_ITC 44
4690 #define IPF_APPLICATION_REGISTER_PFS 64
4691 #define IPF_APPLICATION_REGISTER_LC 65
4692 #define IPF_APPLICATION_REGISTER_EC 66
4695 Reads a 64-bit application register.
4697 Reads and returns the application register specified by Index. The valid Index
4698 valued are defined above in "Related Definitions".
4699 If Index is invalid then 0xFFFFFFFFFFFFFFFF is returned. This function is only
4700 available on Itanium processors.
4702 @param Index The index of the application register to read.
4704 @return The application register specified by Index.
4709 AsmReadApplicationRegister (
4715 Reads the current value of a Machine Specific Register (MSR).
4717 Reads and returns the current value of the Machine Specific Register specified by Index. No
4718 parameter checking is performed on Index, and if the Index value is beyond the implemented MSR
4719 register range, a Reserved Register/Field fault may occur. The caller must either guarantee that
4720 Index is valid, or the caller must set up fault handlers to catch the faults. This function is
4721 only available on Itanium processors.
4723 @param Index The 8-bit Machine Specific Register index to read.
4725 @return The current value of the Machine Specific Register specified by Index.
4736 Writes the current value of a Machine Specific Register (MSR).
4738 Writes Value to the Machine Specific Register specified by Index. Value is returned. No
4739 parameter checking is performed on Index, and if the Index value is beyond the implemented MSR
4740 register range, a Reserved Register/Field fault may occur. The caller must either guarantee that
4741 Index is valid, or the caller must set up fault handlers to catch the faults. This function is
4742 only available on Itanium processors.
4744 @param Index The 8-bit Machine Specific Register index to write.
4745 @param Value The 64-bit value to write to the Machine Specific Register.
4747 @return The 64-bit value to write to the Machine Specific Register.
4759 Determines if the CPU is currently executing in virtual, physical, or mixed mode.
4761 Determines the current execution mode of the CPU.
4762 If the CPU is in virtual mode(PSR.RT=1, PSR.DT=1, PSR.IT=1), then 1 is returned.
4763 If the CPU is in physical mode(PSR.RT=0, PSR.DT=0, PSR.IT=0), then 0 is returned.
4764 If the CPU is not in physical mode or virtual mode, then it is in mixed mode,
4766 This function is only available on Itanium processors.
4768 @retval 1 The CPU is in virtual mode.
4769 @retval 0 The CPU is in physical mode.
4770 @retval -1 The CPU is in mixed mode.
4781 Makes a PAL procedure call.
4783 This is a wrapper function to make a PAL procedure call. Based on the Index
4784 value this API will make static or stacked PAL call. The following table
4785 describes the usage of PAL Procedure Index Assignment. Architected procedures
4786 may be designated as required or optional. If a PAL procedure is specified
4787 as optional, a unique return code of 0xFFFFFFFFFFFFFFFF is returned in the
4788 Status field of the PAL_CALL_RETURN structure.
4789 This indicates that the procedure is not present in this PAL implementation.
4790 It is the caller's responsibility to check for this return code after calling
4791 any optional PAL procedure.
4792 No parameter checking is performed on the 5 input parameters, but there are
4793 some common rules that the caller should follow when making a PAL call. Any
4794 address passed to PAL as buffers for return parameters must be 8-byte aligned.
4795 Unaligned addresses may cause undefined results. For those parameters defined
4796 as reserved or some fields defined as reserved must be zero filled or the invalid
4797 argument return value may be returned or undefined result may occur during the
4798 execution of the procedure. If the PalEntryPoint does not point to a valid
4799 PAL entry point then the system behavior is undefined. This function is only
4800 available on Itanium processors.
4802 @param PalEntryPoint The PAL procedure calls entry point.
4803 @param Index The PAL procedure Index number.
4804 @param Arg2 The 2nd parameter for PAL procedure calls.
4805 @param Arg3 The 3rd parameter for PAL procedure calls.
4806 @param Arg4 The 4th parameter for PAL procedure calls.
4808 @return structure returned from the PAL Call procedure, including the status and return value.
4814 IN UINT64 PalEntryPoint
,
4822 #if defined (MDE_CPU_IA32) || defined (MDE_CPU_X64)
4824 /// IA32 and x64 Specific Functions.
4825 /// Byte packed structure for 16-bit Real Mode EFLAGS.
4829 UINT32 CF
:1; ///< Carry Flag.
4830 UINT32 Reserved_0
:1; ///< Reserved.
4831 UINT32 PF
:1; ///< Parity Flag.
4832 UINT32 Reserved_1
:1; ///< Reserved.
4833 UINT32 AF
:1; ///< Auxiliary Carry Flag.
4834 UINT32 Reserved_2
:1; ///< Reserved.
4835 UINT32 ZF
:1; ///< Zero Flag.
4836 UINT32 SF
:1; ///< Sign Flag.
4837 UINT32 TF
:1; ///< Trap Flag.
4838 UINT32 IF
:1; ///< Interrupt Enable Flag.
4839 UINT32 DF
:1; ///< Direction Flag.
4840 UINT32 OF
:1; ///< Overflow Flag.
4841 UINT32 IOPL
:2; ///< I/O Privilege Level.
4842 UINT32 NT
:1; ///< Nested Task.
4843 UINT32 Reserved_3
:1; ///< Reserved.
4849 /// Byte packed structure for EFLAGS/RFLAGS.
4850 /// 32-bits on IA-32.
4851 /// 64-bits on x64. The upper 32-bits on x64 are reserved.
4855 UINT32 CF
:1; ///< Carry Flag.
4856 UINT32 Reserved_0
:1; ///< Reserved.
4857 UINT32 PF
:1; ///< Parity Flag.
4858 UINT32 Reserved_1
:1; ///< Reserved.
4859 UINT32 AF
:1; ///< Auxiliary Carry Flag.
4860 UINT32 Reserved_2
:1; ///< Reserved.
4861 UINT32 ZF
:1; ///< Zero Flag.
4862 UINT32 SF
:1; ///< Sign Flag.
4863 UINT32 TF
:1; ///< Trap Flag.
4864 UINT32 IF
:1; ///< Interrupt Enable Flag.
4865 UINT32 DF
:1; ///< Direction Flag.
4866 UINT32 OF
:1; ///< Overflow Flag.
4867 UINT32 IOPL
:2; ///< I/O Privilege Level.
4868 UINT32 NT
:1; ///< Nested Task.
4869 UINT32 Reserved_3
:1; ///< Reserved.
4870 UINT32 RF
:1; ///< Resume Flag.
4871 UINT32 VM
:1; ///< Virtual 8086 Mode.
4872 UINT32 AC
:1; ///< Alignment Check.
4873 UINT32 VIF
:1; ///< Virtual Interrupt Flag.
4874 UINT32 VIP
:1; ///< Virtual Interrupt Pending.
4875 UINT32 ID
:1; ///< ID Flag.
4876 UINT32 Reserved_4
:10; ///< Reserved.
4882 /// Byte packed structure for Control Register 0 (CR0).
4883 /// 32-bits on IA-32.
4884 /// 64-bits on x64. The upper 32-bits on x64 are reserved.
4888 UINT32 PE
:1; ///< Protection Enable.
4889 UINT32 MP
:1; ///< Monitor Coprocessor.
4890 UINT32 EM
:1; ///< Emulation.
4891 UINT32 TS
:1; ///< Task Switched.
4892 UINT32 ET
:1; ///< Extension Type.
4893 UINT32 NE
:1; ///< Numeric Error.
4894 UINT32 Reserved_0
:10; ///< Reserved.
4895 UINT32 WP
:1; ///< Write Protect.
4896 UINT32 Reserved_1
:1; ///< Reserved.
4897 UINT32 AM
:1; ///< Alignment Mask.
4898 UINT32 Reserved_2
:10; ///< Reserved.
4899 UINT32 NW
:1; ///< Mot Write-through.
4900 UINT32 CD
:1; ///< Cache Disable.
4901 UINT32 PG
:1; ///< Paging.
4907 /// Byte packed structure for Control Register 4 (CR4).
4908 /// 32-bits on IA-32.
4909 /// 64-bits on x64. The upper 32-bits on x64 are reserved.
4913 UINT32 VME
:1; ///< Virtual-8086 Mode Extensions.
4914 UINT32 PVI
:1; ///< Protected-Mode Virtual Interrupts.
4915 UINT32 TSD
:1; ///< Time Stamp Disable.
4916 UINT32 DE
:1; ///< Debugging Extensions.
4917 UINT32 PSE
:1; ///< Page Size Extensions.
4918 UINT32 PAE
:1; ///< Physical Address Extension.
4919 UINT32 MCE
:1; ///< Machine Check Enable.
4920 UINT32 PGE
:1; ///< Page Global Enable.
4921 UINT32 PCE
:1; ///< Performance Monitoring Counter
4923 UINT32 OSFXSR
:1; ///< Operating System Support for
4924 ///< FXSAVE and FXRSTOR instructions
4925 UINT32 OSXMMEXCPT
:1; ///< Operating System Support for
4926 ///< Unmasked SIMD Floating Point
4928 UINT32 Reserved_0
:2; ///< Reserved.
4929 UINT32 VMXE
:1; ///< VMX Enable
4930 UINT32 Reserved_1
:18; ///< Reserved.
4936 /// Byte packed structure for an IDTR, GDTR, LDTR descriptor.
4945 #define IA32_IDT_GATE_TYPE_TASK 0x85
4946 #define IA32_IDT_GATE_TYPE_INTERRUPT_16 0x86
4947 #define IA32_IDT_GATE_TYPE_TRAP_16 0x87
4948 #define IA32_IDT_GATE_TYPE_INTERRUPT_32 0x8E
4949 #define IA32_IDT_GATE_TYPE_TRAP_32 0x8F
4952 #if defined (MDE_CPU_IA32)
4954 /// Byte packed structure for an IA-32 Interrupt Gate Descriptor.
4958 UINT32 OffsetLow
:16; ///< Offset bits 15..0.
4959 UINT32 Selector
:16; ///< Selector.
4960 UINT32 Reserved_0
:8; ///< Reserved.
4961 UINT32 GateType
:8; ///< Gate Type. See #defines above.
4962 UINT32 OffsetHigh
:16; ///< Offset bits 31..16.
4965 } IA32_IDT_GATE_DESCRIPTOR
;
4969 #if defined (MDE_CPU_X64)
4971 /// Byte packed structure for an x64 Interrupt Gate Descriptor.
4975 UINT32 OffsetLow
:16; ///< Offset bits 15..0.
4976 UINT32 Selector
:16; ///< Selector.
4977 UINT32 Reserved_0
:8; ///< Reserved.
4978 UINT32 GateType
:8; ///< Gate Type. See #defines above.
4979 UINT32 OffsetHigh
:16; ///< Offset bits 31..16.
4980 UINT32 OffsetUpper
:32; ///< Offset bits 63..32.
4981 UINT32 Reserved_1
:32; ///< Reserved.
4987 } IA32_IDT_GATE_DESCRIPTOR
;
4992 /// Byte packed structure for an FP/SSE/SSE2 context.
4999 /// Structures for the 16-bit real mode thunks.
5052 IA32_EFLAGS32 EFLAGS
;
5062 } IA32_REGISTER_SET
;
5065 /// Byte packed structure for an 16-bit real mode thunks.
5068 IA32_REGISTER_SET
*RealModeState
;
5069 VOID
*RealModeBuffer
;
5070 UINT32 RealModeBufferSize
;
5071 UINT32 ThunkAttributes
;
5074 #define THUNK_ATTRIBUTE_BIG_REAL_MODE 0x00000001
5075 #define THUNK_ATTRIBUTE_DISABLE_A20_MASK_INT_15 0x00000002
5076 #define THUNK_ATTRIBUTE_DISABLE_A20_MASK_KBD_CTRL 0x00000004
5079 Retrieves CPUID information.
5081 Executes the CPUID instruction with EAX set to the value specified by Index.
5082 This function always returns Index.
5083 If Eax is not NULL, then the value of EAX after CPUID is returned in Eax.
5084 If Ebx is not NULL, then the value of EBX after CPUID is returned in Ebx.
5085 If Ecx is not NULL, then the value of ECX after CPUID is returned in Ecx.
5086 If Edx is not NULL, then the value of EDX after CPUID is returned in Edx.
5087 This function is only available on IA-32 and x64.
5089 @param Index The 32-bit value to load into EAX prior to invoking the CPUID
5091 @param Eax The pointer to the 32-bit EAX value returned by the CPUID
5092 instruction. This is an optional parameter that may be NULL.
5093 @param Ebx The pointer to the 32-bit EBX value returned by the CPUID
5094 instruction. This is an optional parameter that may be NULL.
5095 @param Ecx The pointer to the 32-bit ECX value returned by the CPUID
5096 instruction. This is an optional parameter that may be NULL.
5097 @param Edx The pointer to the 32-bit EDX value returned by the CPUID
5098 instruction. This is an optional parameter that may be NULL.
5107 OUT UINT32
*Eax
, OPTIONAL
5108 OUT UINT32
*Ebx
, OPTIONAL
5109 OUT UINT32
*Ecx
, OPTIONAL
5110 OUT UINT32
*Edx OPTIONAL
5115 Retrieves CPUID information using an extended leaf identifier.
5117 Executes the CPUID instruction with EAX set to the value specified by Index
5118 and ECX set to the value specified by SubIndex. This function always returns
5119 Index. This function is only available on IA-32 and x64.
5121 If Eax is not NULL, then the value of EAX after CPUID is returned in Eax.
5122 If Ebx is not NULL, then the value of EBX after CPUID is returned in Ebx.
5123 If Ecx is not NULL, then the value of ECX after CPUID is returned in Ecx.
5124 If Edx is not NULL, then the value of EDX after CPUID is returned in Edx.
5126 @param Index The 32-bit value to load into EAX prior to invoking the
5128 @param SubIndex The 32-bit value to load into ECX prior to invoking the
5130 @param Eax The pointer to the 32-bit EAX value returned by the CPUID
5131 instruction. This is an optional parameter that may be
5133 @param Ebx The pointer to the 32-bit EBX value returned by the CPUID
5134 instruction. This is an optional parameter that may be
5136 @param Ecx The pointer to the 32-bit ECX value returned by the CPUID
5137 instruction. This is an optional parameter that may be
5139 @param Edx The pointer to the 32-bit EDX value returned by the CPUID
5140 instruction. This is an optional parameter that may be
5151 OUT UINT32
*Eax
, OPTIONAL
5152 OUT UINT32
*Ebx
, OPTIONAL
5153 OUT UINT32
*Ecx
, OPTIONAL
5154 OUT UINT32
*Edx OPTIONAL
5159 Set CD bit and clear NW bit of CR0 followed by a WBINVD.
5161 Disables the caches by setting the CD bit of CR0 to 1, clearing the NW bit of CR0 to 0,
5162 and executing a WBINVD instruction. This function is only available on IA-32 and x64.
5173 Perform a WBINVD and clear both the CD and NW bits of CR0.
5175 Enables the caches by executing a WBINVD instruction and then clear both the CD and NW
5176 bits of CR0 to 0. This function is only available on IA-32 and x64.
5187 Returns the lower 32-bits of a Machine Specific Register(MSR).
5189 Reads and returns the lower 32-bits of the MSR specified by Index.
5190 No parameter checking is performed on Index, and some Index values may cause
5191 CPU exceptions. The caller must either guarantee that Index is valid, or the
5192 caller must set up exception handlers to catch the exceptions. This function
5193 is only available on IA-32 and x64.
5195 @param Index The 32-bit MSR index to read.
5197 @return The lower 32 bits of the MSR identified by Index.
5208 Writes a 32-bit value to a Machine Specific Register(MSR), and returns the value.
5209 The upper 32-bits of the MSR are set to zero.
5211 Writes the 32-bit value specified by Value to the MSR specified by Index. The
5212 upper 32-bits of the MSR write are set to zero. The 32-bit value written to
5213 the MSR is returned. No parameter checking is performed on Index or Value,
5214 and some of these may cause CPU exceptions. The caller must either guarantee
5215 that Index and Value are valid, or the caller must establish proper exception
5216 handlers. This function is only available on IA-32 and x64.
5218 @param Index The 32-bit MSR index to write.
5219 @param Value The 32-bit value to write to the MSR.
5233 Reads a 64-bit MSR, performs a bitwise OR on the lower 32-bits, and
5234 writes the result back to the 64-bit MSR.
5236 Reads the 64-bit MSR specified by Index, performs a bitwise OR
5237 between the lower 32-bits of the read result and the value specified by
5238 OrData, and writes the result to the 64-bit MSR specified by Index. The lower
5239 32-bits of the value written to the MSR is returned. No parameter checking is
5240 performed on Index or OrData, and some of these may cause CPU exceptions. The
5241 caller must either guarantee that Index and OrData are valid, or the caller
5242 must establish proper exception handlers. This function is only available on
5245 @param Index The 32-bit MSR index to write.
5246 @param OrData The value to OR with the read value from the MSR.
5248 @return The lower 32-bit value written to the MSR.
5260 Reads a 64-bit MSR, performs a bitwise AND on the lower 32-bits, and writes
5261 the result back to the 64-bit MSR.
5263 Reads the 64-bit MSR specified by Index, performs a bitwise AND between the
5264 lower 32-bits of the read result and the value specified by AndData, and
5265 writes the result to the 64-bit MSR specified by Index. The lower 32-bits of
5266 the value written to the MSR is returned. No parameter checking is performed
5267 on Index or AndData, and some of these may cause CPU exceptions. The caller
5268 must either guarantee that Index and AndData are valid, or the caller must
5269 establish proper exception handlers. This function is only available on IA-32
5272 @param Index The 32-bit MSR index to write.
5273 @param AndData The value to AND with the read value from the MSR.
5275 @return The lower 32-bit value written to the MSR.
5287 Reads a 64-bit MSR, performs a bitwise AND followed by a bitwise OR
5288 on the lower 32-bits, and writes the result back to the 64-bit MSR.
5290 Reads the 64-bit MSR specified by Index, performs a bitwise AND between the
5291 lower 32-bits of the read result and the value specified by AndData
5292 preserving the upper 32-bits, performs a bitwise OR between the
5293 result of the AND operation and the value specified by OrData, and writes the
5294 result to the 64-bit MSR specified by Address. The lower 32-bits of the value
5295 written to the MSR is returned. No parameter checking is performed on Index,
5296 AndData, or OrData, and some of these may cause CPU exceptions. The caller
5297 must either guarantee that Index, AndData, and OrData are valid, or the
5298 caller must establish proper exception handlers. This function is only
5299 available on IA-32 and x64.
5301 @param Index The 32-bit MSR index to write.
5302 @param AndData The value to AND with the read value from the MSR.
5303 @param OrData The value to OR with the result of the AND operation.
5305 @return The lower 32-bit value written to the MSR.
5318 Reads a bit field of an MSR.
5320 Reads the bit field in the lower 32-bits of a 64-bit MSR. The bit field is
5321 specified by the StartBit and the EndBit. The value of the bit field is
5322 returned. The caller must either guarantee that Index is valid, or the caller
5323 must set up exception handlers to catch the exceptions. This function is only
5324 available on IA-32 and x64.
5326 If StartBit is greater than 31, then ASSERT().
5327 If EndBit is greater than 31, then ASSERT().
5328 If EndBit is less than StartBit, then ASSERT().
5330 @param Index The 32-bit MSR index to read.
5331 @param StartBit The ordinal of the least significant bit in the bit field.
5333 @param EndBit The ordinal of the most significant bit in the bit field.
5336 @return The bit field read from the MSR.
5341 AsmMsrBitFieldRead32 (
5349 Writes a bit field to an MSR.
5351 Writes Value to a bit field in the lower 32-bits of a 64-bit MSR. The bit
5352 field is specified by the StartBit and the EndBit. All other bits in the
5353 destination MSR are preserved. The lower 32-bits of the MSR written is
5354 returned. The caller must either guarantee that Index and the data written
5355 is valid, or the caller must set up exception handlers to catch the exceptions.
5356 This function is only available on IA-32 and x64.
5358 If StartBit is greater than 31, then ASSERT().
5359 If EndBit is greater than 31, then ASSERT().
5360 If EndBit is less than StartBit, then ASSERT().
5362 @param Index The 32-bit MSR index to write.
5363 @param StartBit The ordinal of the least significant bit in the bit field.
5365 @param EndBit The ordinal of the most significant bit in the bit field.
5367 @param Value New value of the bit field.
5369 @return The lower 32-bit of the value written to the MSR.
5374 AsmMsrBitFieldWrite32 (
5383 Reads a bit field in a 64-bit MSR, performs a bitwise OR, and writes the
5384 result back to the bit field in the 64-bit MSR.
5386 Reads the 64-bit MSR specified by Index, performs a bitwise OR
5387 between the read result and the value specified by OrData, and writes the
5388 result to the 64-bit MSR specified by Index. The lower 32-bits of the value
5389 written to the MSR are returned. Extra left bits in OrData are stripped. The
5390 caller must either guarantee that Index and the data written is valid, or
5391 the caller must set up exception handlers to catch the exceptions. This
5392 function is only available on IA-32 and x64.
5394 If StartBit is greater than 31, then ASSERT().
5395 If EndBit is greater than 31, then ASSERT().
5396 If EndBit is less than StartBit, then ASSERT().
5398 @param Index The 32-bit MSR index to write.
5399 @param StartBit The ordinal of the least significant bit in the bit field.
5401 @param EndBit The ordinal of the most significant bit in the bit field.
5403 @param OrData The value to OR with the read value from the MSR.
5405 @return The lower 32-bit of the value written to the MSR.
5410 AsmMsrBitFieldOr32 (
5419 Reads a bit field in a 64-bit MSR, performs a bitwise AND, and writes the
5420 result back to the bit field in the 64-bit MSR.
5422 Reads the 64-bit MSR specified by Index, performs a bitwise AND between the
5423 read result and the value specified by AndData, and writes the result to the
5424 64-bit MSR specified by Index. The lower 32-bits of the value written to the
5425 MSR are returned. Extra left bits in AndData are stripped. The caller must
5426 either guarantee that Index and the data written is valid, or the caller must
5427 set up exception handlers to catch the exceptions. This function is only
5428 available on IA-32 and x64.
5430 If StartBit is greater than 31, then ASSERT().
5431 If EndBit is greater than 31, then ASSERT().
5432 If EndBit is less than StartBit, then ASSERT().
5434 @param Index The 32-bit MSR index to write.
5435 @param StartBit The ordinal of the least significant bit in the bit field.
5437 @param EndBit The ordinal of the most significant bit in the bit field.
5439 @param AndData The value to AND with the read value from the MSR.
5441 @return The lower 32-bit of the value written to the MSR.
5446 AsmMsrBitFieldAnd32 (
5455 Reads a bit field in a 64-bit MSR, performs a bitwise AND followed by a
5456 bitwise OR, and writes the result back to the bit field in the
5459 Reads the 64-bit MSR specified by Index, performs a bitwise AND followed by a
5460 bitwise OR between the read result and the value specified by
5461 AndData, and writes the result to the 64-bit MSR specified by Index. The
5462 lower 32-bits of the value written to the MSR are returned. Extra left bits
5463 in both AndData and OrData are stripped. The caller must either guarantee
5464 that Index and the data written is valid, or the caller must set up exception
5465 handlers to catch the exceptions. This function is only available on IA-32
5468 If StartBit is greater than 31, then ASSERT().
5469 If EndBit is greater than 31, then ASSERT().
5470 If EndBit is less than StartBit, then ASSERT().
5472 @param Index The 32-bit MSR index to write.
5473 @param StartBit The ordinal of the least significant bit in the bit field.
5475 @param EndBit The ordinal of the most significant bit in the bit field.
5477 @param AndData The value to AND with the read value from the MSR.
5478 @param OrData The value to OR with the result of the AND operation.
5480 @return The lower 32-bit of the value written to the MSR.
5485 AsmMsrBitFieldAndThenOr32 (
5495 Returns a 64-bit Machine Specific Register(MSR).
5497 Reads and returns the 64-bit MSR specified by Index. No parameter checking is
5498 performed on Index, and some Index values may cause CPU exceptions. The
5499 caller must either guarantee that Index is valid, or the caller must set up
5500 exception handlers to catch the exceptions. This function is only available
5503 @param Index The 32-bit MSR index to read.
5505 @return The value of the MSR identified by Index.
5516 Writes a 64-bit value to a Machine Specific Register(MSR), and returns the
5519 Writes the 64-bit value specified by Value to the MSR specified by Index. The
5520 64-bit value written to the MSR is returned. No parameter checking is
5521 performed on Index or Value, and some of these may cause CPU exceptions. The
5522 caller must either guarantee that Index and Value are valid, or the caller
5523 must establish proper exception handlers. This function is only available on
5526 @param Index The 32-bit MSR index to write.
5527 @param Value The 64-bit value to write to the MSR.
5541 Reads a 64-bit MSR, performs a bitwise OR, and writes the result
5542 back to the 64-bit MSR.
5544 Reads the 64-bit MSR specified by Index, performs a bitwise OR
5545 between the read result and the value specified by OrData, and writes the
5546 result to the 64-bit MSR specified by Index. The value written to the MSR is
5547 returned. No parameter checking is performed on Index or OrData, and some of
5548 these may cause CPU exceptions. The caller must either guarantee that Index
5549 and OrData are valid, or the caller must establish proper exception handlers.
5550 This function is only available on IA-32 and x64.
5552 @param Index The 32-bit MSR index to write.
5553 @param OrData The value to OR with the read value from the MSR.
5555 @return The value written back to the MSR.
5567 Reads a 64-bit MSR, performs a bitwise AND, and writes the result back to the
5570 Reads the 64-bit MSR specified by Index, performs a bitwise AND between the
5571 read result and the value specified by OrData, and writes the result to the
5572 64-bit MSR specified by Index. The value written to the MSR is returned. No
5573 parameter checking is performed on Index or OrData, and some of these may
5574 cause CPU exceptions. The caller must either guarantee that Index and OrData
5575 are valid, or the caller must establish proper exception handlers. This
5576 function is only available on IA-32 and x64.
5578 @param Index The 32-bit MSR index to write.
5579 @param AndData The value to AND with the read value from the MSR.
5581 @return The value written back to the MSR.
5593 Reads a 64-bit MSR, performs a bitwise AND followed by a bitwise
5594 OR, and writes the result back to the 64-bit MSR.
5596 Reads the 64-bit MSR specified by Index, performs a bitwise AND between read
5597 result and the value specified by AndData, performs a bitwise OR
5598 between the result of the AND operation and the value specified by OrData,
5599 and writes the result to the 64-bit MSR specified by Index. The value written
5600 to the MSR is returned. No parameter checking is performed on Index, AndData,
5601 or OrData, and some of these may cause CPU exceptions. The caller must either
5602 guarantee that Index, AndData, and OrData are valid, or the caller must
5603 establish proper exception handlers. This function is only available on IA-32
5606 @param Index The 32-bit MSR index to write.
5607 @param AndData The value to AND with the read value from the MSR.
5608 @param OrData The value to OR with the result of the AND operation.
5610 @return The value written back to the MSR.
5623 Reads a bit field of an MSR.
5625 Reads the bit field in the 64-bit MSR. The bit field is specified by the
5626 StartBit and the EndBit. The value of the bit field is returned. The caller
5627 must either guarantee that Index is valid, or the caller must set up
5628 exception handlers to catch the exceptions. This function is only available
5631 If StartBit is greater than 63, then ASSERT().
5632 If EndBit is greater than 63, then ASSERT().
5633 If EndBit is less than StartBit, then ASSERT().
5635 @param Index The 32-bit MSR index to read.
5636 @param StartBit The ordinal of the least significant bit in the bit field.
5638 @param EndBit The ordinal of the most significant bit in the bit field.
5641 @return The value read from the MSR.
5646 AsmMsrBitFieldRead64 (
5654 Writes a bit field to an MSR.
5656 Writes Value to a bit field in a 64-bit MSR. The bit field is specified by
5657 the StartBit and the EndBit. All other bits in the destination MSR are
5658 preserved. The MSR written is returned. The caller must either guarantee
5659 that Index and the data written is valid, or the caller must set up exception
5660 handlers to catch the exceptions. This function is only available on IA-32 and x64.
5662 If StartBit is greater than 63, then ASSERT().
5663 If EndBit is greater than 63, then ASSERT().
5664 If EndBit is less than StartBit, then ASSERT().
5666 @param Index The 32-bit MSR index to write.
5667 @param StartBit The ordinal of the least significant bit in the bit field.
5669 @param EndBit The ordinal of the most significant bit in the bit field.
5671 @param Value New value of the bit field.
5673 @return The value written back to the MSR.
5678 AsmMsrBitFieldWrite64 (
5687 Reads a bit field in a 64-bit MSR, performs a bitwise OR, and
5688 writes the result back to the bit field in the 64-bit MSR.
5690 Reads the 64-bit MSR specified by Index, performs a bitwise OR
5691 between the read result and the value specified by OrData, and writes the
5692 result to the 64-bit MSR specified by Index. The value written to the MSR is
5693 returned. Extra left bits in OrData are stripped. The caller must either
5694 guarantee that Index and the data written is valid, or the caller must set up
5695 exception handlers to catch the exceptions. This function is only available
5698 If StartBit is greater than 63, then ASSERT().
5699 If EndBit is greater than 63, then ASSERT().
5700 If EndBit is less than StartBit, then ASSERT().
5702 @param Index The 32-bit MSR index to write.
5703 @param StartBit The ordinal of the least significant bit in the bit field.
5705 @param EndBit The ordinal of the most significant bit in the bit field.
5707 @param OrData The value to OR with the read value from the bit field.
5709 @return The value written back to the MSR.
5714 AsmMsrBitFieldOr64 (
5723 Reads a bit field in a 64-bit MSR, performs a bitwise AND, and writes the
5724 result back to the bit field in the 64-bit MSR.
5726 Reads the 64-bit MSR specified by Index, performs a bitwise AND between the
5727 read result and the value specified by AndData, and writes the result to the
5728 64-bit MSR specified by Index. The value written to the MSR is returned.
5729 Extra left bits in AndData are stripped. The caller must either guarantee
5730 that Index and the data written is valid, or the caller must set up exception
5731 handlers to catch the exceptions. This function is only available on IA-32
5734 If StartBit is greater than 63, then ASSERT().
5735 If EndBit is greater than 63, then ASSERT().
5736 If EndBit is less than StartBit, then ASSERT().
5738 @param Index The 32-bit MSR index to write.
5739 @param StartBit The ordinal of the least significant bit in the bit field.
5741 @param EndBit The ordinal of the most significant bit in the bit field.
5743 @param AndData The value to AND with the read value from the bit field.
5745 @return The value written back to the MSR.
5750 AsmMsrBitFieldAnd64 (
5759 Reads a bit field in a 64-bit MSR, performs a bitwise AND followed by a
5760 bitwise OR, and writes the result back to the bit field in the
5763 Reads the 64-bit MSR specified by Index, performs a bitwise AND followed by
5764 a bitwise OR between the read result and the value specified by
5765 AndData, and writes the result to the 64-bit MSR specified by Index. The
5766 value written to the MSR is returned. Extra left bits in both AndData and
5767 OrData are stripped. The caller must either guarantee that Index and the data
5768 written is valid, or the caller must set up exception handlers to catch the
5769 exceptions. This function is only available on IA-32 and x64.
5771 If StartBit is greater than 63, then ASSERT().
5772 If EndBit is greater than 63, then ASSERT().
5773 If EndBit is less than StartBit, then ASSERT().
5775 @param Index The 32-bit MSR index to write.
5776 @param StartBit The ordinal of the least significant bit in the bit field.
5778 @param EndBit The ordinal of the most significant bit in the bit field.
5780 @param AndData The value to AND with the read value from the bit field.
5781 @param OrData The value to OR with the result of the AND operation.
5783 @return The value written back to the MSR.
5788 AsmMsrBitFieldAndThenOr64 (
5798 Reads the current value of the EFLAGS register.
5800 Reads and returns the current value of the EFLAGS register. This function is
5801 only available on IA-32 and x64. This returns a 32-bit value on IA-32 and a
5802 64-bit value on x64.
5804 @return EFLAGS on IA-32 or RFLAGS on x64.
5815 Reads the current value of the Control Register 0 (CR0).
5817 Reads and returns the current value of CR0. This function is only available
5818 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
5821 @return The value of the Control Register 0 (CR0).
5832 Reads the current value of the Control Register 2 (CR2).
5834 Reads and returns the current value of CR2. This function is only available
5835 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
5838 @return The value of the Control Register 2 (CR2).
5849 Reads the current value of the Control Register 3 (CR3).
5851 Reads and returns the current value of CR3. This function is only available
5852 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
5855 @return The value of the Control Register 3 (CR3).
5866 Reads the current value of the Control Register 4 (CR4).
5868 Reads and returns the current value of CR4. This function is only available
5869 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
5872 @return The value of the Control Register 4 (CR4).
5883 Writes a value to Control Register 0 (CR0).
5885 Writes and returns a new value to CR0. This function is only available on
5886 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
5888 @param Cr0 The value to write to CR0.
5890 @return The value written to CR0.
5901 Writes a value to Control Register 2 (CR2).
5903 Writes and returns a new value to CR2. This function is only available on
5904 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
5906 @param Cr2 The value to write to CR2.
5908 @return The value written to CR2.
5919 Writes a value to Control Register 3 (CR3).
5921 Writes and returns a new value to CR3. This function is only available on
5922 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
5924 @param Cr3 The value to write to CR3.
5926 @return The value written to CR3.
5937 Writes a value to Control Register 4 (CR4).
5939 Writes and returns a new value to CR4. This function is only available on
5940 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
5942 @param Cr4 The value to write to CR4.
5944 @return The value written to CR4.
5955 Reads the current value of Debug Register 0 (DR0).
5957 Reads and returns the current value of DR0. This function is only available
5958 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
5961 @return The value of Debug Register 0 (DR0).
5972 Reads the current value of Debug Register 1 (DR1).
5974 Reads and returns the current value of DR1. This function is only available
5975 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
5978 @return The value of Debug Register 1 (DR1).
5989 Reads the current value of Debug Register 2 (DR2).
5991 Reads and returns the current value of DR2. This function is only available
5992 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
5995 @return The value of Debug Register 2 (DR2).
6006 Reads the current value of Debug Register 3 (DR3).
6008 Reads and returns the current value of DR3. This function is only available
6009 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
6012 @return The value of Debug Register 3 (DR3).
6023 Reads the current value of Debug Register 4 (DR4).
6025 Reads and returns the current value of DR4. This function is only available
6026 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
6029 @return The value of Debug Register 4 (DR4).
6040 Reads the current value of Debug Register 5 (DR5).
6042 Reads and returns the current value of DR5. This function is only available
6043 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
6046 @return The value of Debug Register 5 (DR5).
6057 Reads the current value of Debug Register 6 (DR6).
6059 Reads and returns the current value of DR6. This function is only available
6060 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
6063 @return The value of Debug Register 6 (DR6).
6074 Reads the current value of Debug Register 7 (DR7).
6076 Reads and returns the current value of DR7. This function is only available
6077 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
6080 @return The value of Debug Register 7 (DR7).
6091 Writes a value to Debug Register 0 (DR0).
6093 Writes and returns a new value to DR0. This function is only available on
6094 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
6096 @param Dr0 The value to write to Dr0.
6098 @return The value written to Debug Register 0 (DR0).
6109 Writes a value to Debug Register 1 (DR1).
6111 Writes and returns a new value to DR1. This function is only available on
6112 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
6114 @param Dr1 The value to write to Dr1.
6116 @return The value written to Debug Register 1 (DR1).
6127 Writes a value to Debug Register 2 (DR2).
6129 Writes and returns a new value to DR2. This function is only available on
6130 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
6132 @param Dr2 The value to write to Dr2.
6134 @return The value written to Debug Register 2 (DR2).
6145 Writes a value to Debug Register 3 (DR3).
6147 Writes and returns a new value to DR3. This function is only available on
6148 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
6150 @param Dr3 The value to write to Dr3.
6152 @return The value written to Debug Register 3 (DR3).
6163 Writes a value to Debug Register 4 (DR4).
6165 Writes and returns a new value to DR4. This function is only available on
6166 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
6168 @param Dr4 The value to write to Dr4.
6170 @return The value written to Debug Register 4 (DR4).
6181 Writes a value to Debug Register 5 (DR5).
6183 Writes and returns a new value to DR5. This function is only available on
6184 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
6186 @param Dr5 The value to write to Dr5.
6188 @return The value written to Debug Register 5 (DR5).
6199 Writes a value to Debug Register 6 (DR6).
6201 Writes and returns a new value to DR6. This function is only available on
6202 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
6204 @param Dr6 The value to write to Dr6.
6206 @return The value written to Debug Register 6 (DR6).
6217 Writes a value to Debug Register 7 (DR7).
6219 Writes and returns a new value to DR7. This function is only available on
6220 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
6222 @param Dr7 The value to write to Dr7.
6224 @return The value written to Debug Register 7 (DR7).
6235 Reads the current value of Code Segment Register (CS).
6237 Reads and returns the current value of CS. This function is only available on
6240 @return The current value of CS.
6251 Reads the current value of Data Segment Register (DS).
6253 Reads and returns the current value of DS. This function is only available on
6256 @return The current value of DS.
6267 Reads the current value of Extra Segment Register (ES).
6269 Reads and returns the current value of ES. This function is only available on
6272 @return The current value of ES.
6283 Reads the current value of FS Data Segment Register (FS).
6285 Reads and returns the current value of FS. This function is only available on
6288 @return The current value of FS.
6299 Reads the current value of GS Data Segment Register (GS).
6301 Reads and returns the current value of GS. This function is only available on
6304 @return The current value of GS.
6315 Reads the current value of Stack Segment Register (SS).
6317 Reads and returns the current value of SS. This function is only available on
6320 @return The current value of SS.
6331 Reads the current value of Task Register (TR).
6333 Reads and returns the current value of TR. This function is only available on
6336 @return The current value of TR.
6347 Reads the current Global Descriptor Table Register(GDTR) descriptor.
6349 Reads and returns the current GDTR descriptor and returns it in Gdtr. This
6350 function is only available on IA-32 and x64.
6352 If Gdtr is NULL, then ASSERT().
6354 @param Gdtr The pointer to a GDTR descriptor.
6360 OUT IA32_DESCRIPTOR
*Gdtr
6365 Writes the current Global Descriptor Table Register (GDTR) descriptor.
6367 Writes and the current GDTR descriptor specified by Gdtr. This function is
6368 only available on IA-32 and x64.
6370 If Gdtr is NULL, then ASSERT().
6372 @param Gdtr The pointer to a GDTR descriptor.
6378 IN CONST IA32_DESCRIPTOR
*Gdtr
6383 Reads the current Interrupt Descriptor Table Register(IDTR) descriptor.
6385 Reads and returns the current IDTR descriptor and returns it in Idtr. This
6386 function is only available on IA-32 and x64.
6388 If Idtr is NULL, then ASSERT().
6390 @param Idtr The pointer to a IDTR descriptor.
6396 OUT IA32_DESCRIPTOR
*Idtr
6401 Writes the current Interrupt Descriptor Table Register(IDTR) descriptor.
6403 Writes the current IDTR descriptor and returns it in Idtr. This function is
6404 only available on IA-32 and x64.
6406 If Idtr is NULL, then ASSERT().
6408 @param Idtr The pointer to a IDTR descriptor.
6414 IN CONST IA32_DESCRIPTOR
*Idtr
6419 Reads the current Local Descriptor Table Register(LDTR) selector.
6421 Reads and returns the current 16-bit LDTR descriptor value. This function is
6422 only available on IA-32 and x64.
6424 @return The current selector of LDT.
6435 Writes the current Local Descriptor Table Register (LDTR) selector.
6437 Writes and the current LDTR descriptor specified by Ldtr. This function is
6438 only available on IA-32 and x64.
6440 @param Ldtr 16-bit LDTR selector value.
6451 Save the current floating point/SSE/SSE2 context to a buffer.
6453 Saves the current floating point/SSE/SSE2 state to the buffer specified by
6454 Buffer. Buffer must be aligned on a 16-byte boundary. This function is only
6455 available on IA-32 and x64.
6457 If Buffer is NULL, then ASSERT().
6458 If Buffer is not aligned on a 16-byte boundary, then ASSERT().
6460 @param Buffer The pointer to a buffer to save the floating point/SSE/SSE2 context.
6466 OUT IA32_FX_BUFFER
*Buffer
6471 Restores the current floating point/SSE/SSE2 context from a buffer.
6473 Restores the current floating point/SSE/SSE2 state from the buffer specified
6474 by Buffer. Buffer must be aligned on a 16-byte boundary. This function is
6475 only available on IA-32 and x64.
6477 If Buffer is NULL, then ASSERT().
6478 If Buffer is not aligned on a 16-byte boundary, then ASSERT().
6479 If Buffer was not saved with AsmFxSave(), then ASSERT().
6481 @param Buffer The pointer to a buffer to save the floating point/SSE/SSE2 context.
6487 IN CONST IA32_FX_BUFFER
*Buffer
6492 Reads the current value of 64-bit MMX Register #0 (MM0).
6494 Reads and returns the current value of MM0. This function is only available
6497 @return The current value of MM0.
6508 Reads the current value of 64-bit MMX Register #1 (MM1).
6510 Reads and returns the current value of MM1. This function is only available
6513 @return The current value of MM1.
6524 Reads the current value of 64-bit MMX Register #2 (MM2).
6526 Reads and returns the current value of MM2. This function is only available
6529 @return The current value of MM2.
6540 Reads the current value of 64-bit MMX Register #3 (MM3).
6542 Reads and returns the current value of MM3. This function is only available
6545 @return The current value of MM3.
6556 Reads the current value of 64-bit MMX Register #4 (MM4).
6558 Reads and returns the current value of MM4. This function is only available
6561 @return The current value of MM4.
6572 Reads the current value of 64-bit MMX Register #5 (MM5).
6574 Reads and returns the current value of MM5. This function is only available
6577 @return The current value of MM5.
6588 Reads the current value of 64-bit MMX Register #6 (MM6).
6590 Reads and returns the current value of MM6. This function is only available
6593 @return The current value of MM6.
6604 Reads the current value of 64-bit MMX Register #7 (MM7).
6606 Reads and returns the current value of MM7. This function is only available
6609 @return The current value of MM7.
6620 Writes the current value of 64-bit MMX Register #0 (MM0).
6622 Writes the current value of MM0. This function is only available on IA32 and
6625 @param Value The 64-bit value to write to MM0.
6636 Writes the current value of 64-bit MMX Register #1 (MM1).
6638 Writes the current value of MM1. This function is only available on IA32 and
6641 @param Value The 64-bit value to write to MM1.
6652 Writes the current value of 64-bit MMX Register #2 (MM2).
6654 Writes the current value of MM2. This function is only available on IA32 and
6657 @param Value The 64-bit value to write to MM2.
6668 Writes the current value of 64-bit MMX Register #3 (MM3).
6670 Writes the current value of MM3. This function is only available on IA32 and
6673 @param Value The 64-bit value to write to MM3.
6684 Writes the current value of 64-bit MMX Register #4 (MM4).
6686 Writes the current value of MM4. This function is only available on IA32 and
6689 @param Value The 64-bit value to write to MM4.
6700 Writes the current value of 64-bit MMX Register #5 (MM5).
6702 Writes the current value of MM5. This function is only available on IA32 and
6705 @param Value The 64-bit value to write to MM5.
6716 Writes the current value of 64-bit MMX Register #6 (MM6).
6718 Writes the current value of MM6. This function is only available on IA32 and
6721 @param Value The 64-bit value to write to MM6.
6732 Writes the current value of 64-bit MMX Register #7 (MM7).
6734 Writes the current value of MM7. This function is only available on IA32 and
6737 @param Value The 64-bit value to write to MM7.
6748 Reads the current value of Time Stamp Counter (TSC).
6750 Reads and returns the current value of TSC. This function is only available
6753 @return The current value of TSC
6764 Reads the current value of a Performance Counter (PMC).
6766 Reads and returns the current value of performance counter specified by
6767 Index. This function is only available on IA-32 and x64.
6769 @param Index The 32-bit Performance Counter index to read.
6771 @return The value of the PMC specified by Index.
6782 Sets up a monitor buffer that is used by AsmMwait().
6784 Executes a MONITOR instruction with the register state specified by Eax, Ecx
6785 and Edx. Returns Eax. This function is only available on IA-32 and x64.
6787 @param Eax The value to load into EAX or RAX before executing the MONITOR
6789 @param Ecx The value to load into ECX or RCX before executing the MONITOR
6791 @param Edx The value to load into EDX or RDX before executing the MONITOR
6807 Executes an MWAIT instruction.
6809 Executes an MWAIT instruction with the register state specified by Eax and
6810 Ecx. Returns Eax. This function is only available on IA-32 and x64.
6812 @param Eax The value to load into EAX or RAX before executing the MONITOR
6814 @param Ecx The value to load into ECX or RCX before executing the MONITOR
6829 Executes a WBINVD instruction.
6831 Executes a WBINVD instruction. This function is only available on IA-32 and
6843 Executes a INVD instruction.
6845 Executes a INVD instruction. This function is only available on IA-32 and
6857 Flushes a cache line from all the instruction and data caches within the
6858 coherency domain of the CPU.
6860 Flushed the cache line specified by LinearAddress, and returns LinearAddress.
6861 This function is only available on IA-32 and x64.
6863 @param LinearAddress The address of the cache line to flush. If the CPU is
6864 in a physical addressing mode, then LinearAddress is a
6865 physical address. If the CPU is in a virtual
6866 addressing mode, then LinearAddress is a virtual
6869 @return LinearAddress.
6874 IN VOID
*LinearAddress
6879 Enables the 32-bit paging mode on the CPU.
6881 Enables the 32-bit paging mode on the CPU. CR0, CR3, CR4, and the page tables
6882 must be properly initialized prior to calling this service. This function
6883 assumes the current execution mode is 32-bit protected mode. This function is
6884 only available on IA-32. After the 32-bit paging mode is enabled, control is
6885 transferred to the function specified by EntryPoint using the new stack
6886 specified by NewStack and passing in the parameters specified by Context1 and
6887 Context2. Context1 and Context2 are optional and may be NULL. The function
6888 EntryPoint must never return.
6890 If the current execution mode is not 32-bit protected mode, then ASSERT().
6891 If EntryPoint is NULL, then ASSERT().
6892 If NewStack is NULL, then ASSERT().
6894 There are a number of constraints that must be followed before calling this
6896 1) Interrupts must be disabled.
6897 2) The caller must be in 32-bit protected mode with flat descriptors. This
6898 means all descriptors must have a base of 0 and a limit of 4GB.
6899 3) CR0 and CR4 must be compatible with 32-bit protected mode with flat
6901 4) CR3 must point to valid page tables that will be used once the transition
6902 is complete, and those page tables must guarantee that the pages for this
6903 function and the stack are identity mapped.
6905 @param EntryPoint A pointer to function to call with the new stack after
6907 @param Context1 A pointer to the context to pass into the EntryPoint
6908 function as the first parameter after paging is enabled.
6909 @param Context2 A pointer to the context to pass into the EntryPoint
6910 function as the second parameter after paging is enabled.
6911 @param NewStack A pointer to the new stack to use for the EntryPoint
6912 function after paging is enabled.
6918 IN SWITCH_STACK_ENTRY_POINT EntryPoint
,
6919 IN VOID
*Context1
, OPTIONAL
6920 IN VOID
*Context2
, OPTIONAL
6926 Disables the 32-bit paging mode on the CPU.
6928 Disables the 32-bit paging mode on the CPU and returns to 32-bit protected
6929 mode. This function assumes the current execution mode is 32-paged protected
6930 mode. This function is only available on IA-32. After the 32-bit paging mode
6931 is disabled, control is transferred to the function specified by EntryPoint
6932 using the new stack specified by NewStack and passing in the parameters
6933 specified by Context1 and Context2. Context1 and Context2 are optional and
6934 may be NULL. The function EntryPoint must never return.
6936 If the current execution mode is not 32-bit paged mode, then ASSERT().
6937 If EntryPoint is NULL, then ASSERT().
6938 If NewStack is NULL, then ASSERT().
6940 There are a number of constraints that must be followed before calling this
6942 1) Interrupts must be disabled.
6943 2) The caller must be in 32-bit paged mode.
6944 3) CR0, CR3, and CR4 must be compatible with 32-bit paged mode.
6945 4) CR3 must point to valid page tables that guarantee that the pages for
6946 this function and the stack are identity mapped.
6948 @param EntryPoint A pointer to function to call with the new stack after
6950 @param Context1 A pointer to the context to pass into the EntryPoint
6951 function as the first parameter after paging is disabled.
6952 @param Context2 A pointer to the context to pass into the EntryPoint
6953 function as the second parameter after paging is
6955 @param NewStack A pointer to the new stack to use for the EntryPoint
6956 function after paging is disabled.
6961 AsmDisablePaging32 (
6962 IN SWITCH_STACK_ENTRY_POINT EntryPoint
,
6963 IN VOID
*Context1
, OPTIONAL
6964 IN VOID
*Context2
, OPTIONAL
6970 Enables the 64-bit paging mode on the CPU.
6972 Enables the 64-bit paging mode on the CPU. CR0, CR3, CR4, and the page tables
6973 must be properly initialized prior to calling this service. This function
6974 assumes the current execution mode is 32-bit protected mode with flat
6975 descriptors. This function is only available on IA-32. After the 64-bit
6976 paging mode is enabled, control is transferred to the function specified by
6977 EntryPoint using the new stack specified by NewStack and passing in the
6978 parameters specified by Context1 and Context2. Context1 and Context2 are
6979 optional and may be 0. The function EntryPoint must never return.
6981 If the current execution mode is not 32-bit protected mode with flat
6982 descriptors, then ASSERT().
6983 If EntryPoint is 0, then ASSERT().
6984 If NewStack is 0, then ASSERT().
6986 @param Cs The 16-bit selector to load in the CS before EntryPoint
6987 is called. The descriptor in the GDT that this selector
6988 references must be setup for long mode.
6989 @param EntryPoint The 64-bit virtual address of the function to call with
6990 the new stack after paging is enabled.
6991 @param Context1 The 64-bit virtual address of the context to pass into
6992 the EntryPoint function as the first parameter after
6994 @param Context2 The 64-bit virtual address of the context to pass into
6995 the EntryPoint function as the second parameter after
6997 @param NewStack The 64-bit virtual address of the new stack to use for
6998 the EntryPoint function after paging is enabled.
7005 IN UINT64 EntryPoint
,
7006 IN UINT64 Context1
, OPTIONAL
7007 IN UINT64 Context2
, OPTIONAL
7013 Disables the 64-bit paging mode on the CPU.
7015 Disables the 64-bit paging mode on the CPU and returns to 32-bit protected
7016 mode. This function assumes the current execution mode is 64-paging mode.
7017 This function is only available on x64. After the 64-bit paging mode is
7018 disabled, control is transferred to the function specified by EntryPoint
7019 using the new stack specified by NewStack and passing in the parameters
7020 specified by Context1 and Context2. Context1 and Context2 are optional and
7021 may be 0. The function EntryPoint must never return.
7023 If the current execution mode is not 64-bit paged mode, then ASSERT().
7024 If EntryPoint is 0, then ASSERT().
7025 If NewStack is 0, then ASSERT().
7027 @param Cs The 16-bit selector to load in the CS before EntryPoint
7028 is called. The descriptor in the GDT that this selector
7029 references must be setup for 32-bit protected mode.
7030 @param EntryPoint The 64-bit virtual address of the function to call with
7031 the new stack after paging is disabled.
7032 @param Context1 The 64-bit virtual address of the context to pass into
7033 the EntryPoint function as the first parameter after
7035 @param Context2 The 64-bit virtual address of the context to pass into
7036 the EntryPoint function as the second parameter after
7038 @param NewStack The 64-bit virtual address of the new stack to use for
7039 the EntryPoint function after paging is disabled.
7044 AsmDisablePaging64 (
7046 IN UINT32 EntryPoint
,
7047 IN UINT32 Context1
, OPTIONAL
7048 IN UINT32 Context2
, OPTIONAL
7054 // 16-bit thunking services
7058 Retrieves the properties for 16-bit thunk functions.
7060 Computes the size of the buffer and stack below 1MB required to use the
7061 AsmPrepareThunk16(), AsmThunk16() and AsmPrepareAndThunk16() functions. This
7062 buffer size is returned in RealModeBufferSize, and the stack size is returned
7063 in ExtraStackSize. If parameters are passed to the 16-bit real mode code,
7064 then the actual minimum stack size is ExtraStackSize plus the maximum number
7065 of bytes that need to be passed to the 16-bit real mode code.
7067 If RealModeBufferSize is NULL, then ASSERT().
7068 If ExtraStackSize is NULL, then ASSERT().
7070 @param RealModeBufferSize A pointer to the size of the buffer below 1MB
7071 required to use the 16-bit thunk functions.
7072 @param ExtraStackSize A pointer to the extra size of stack below 1MB
7073 that the 16-bit thunk functions require for
7074 temporary storage in the transition to and from
7080 AsmGetThunk16Properties (
7081 OUT UINT32
*RealModeBufferSize
,
7082 OUT UINT32
*ExtraStackSize
7087 Prepares all structures a code required to use AsmThunk16().
7089 Prepares all structures and code required to use AsmThunk16().
7091 This interface is limited to be used in either physical mode or virtual modes with paging enabled where the
7092 virtual to physical mappings for ThunkContext.RealModeBuffer is mapped 1:1.
7094 If ThunkContext is NULL, then ASSERT().
7096 @param ThunkContext A pointer to the context structure that describes the
7097 16-bit real mode code to call.
7103 OUT THUNK_CONTEXT
*ThunkContext
7108 Transfers control to a 16-bit real mode entry point and returns the results.
7110 Transfers control to a 16-bit real mode entry point and returns the results.
7111 AsmPrepareThunk16() must be called with ThunkContext before this function is used.
7112 This function must be called with interrupts disabled.
7114 The register state from the RealModeState field of ThunkContext is restored just prior
7115 to calling the 16-bit real mode entry point. This includes the EFLAGS field of RealModeState,
7116 which is used to set the interrupt state when a 16-bit real mode entry point is called.
7117 Control is transferred to the 16-bit real mode entry point specified by the CS and Eip fields of RealModeState.
7118 The stack is initialized to the SS and ESP fields of RealModeState. Any parameters passed to
7119 the 16-bit real mode code must be populated by the caller at SS:ESP prior to calling this function.
7120 The 16-bit real mode entry point is invoked with a 16-bit CALL FAR instruction,
7121 so when accessing stack contents, the 16-bit real mode code must account for the 16-bit segment
7122 and 16-bit offset of the return address that were pushed onto the stack. The 16-bit real mode entry
7123 point must exit with a RETF instruction. The register state is captured into RealModeState immediately
7124 after the RETF instruction is executed.
7126 If EFLAGS specifies interrupts enabled, or any of the 16-bit real mode code enables interrupts,
7127 or any of the 16-bit real mode code makes a SW interrupt, then the caller is responsible for making sure
7128 the IDT at address 0 is initialized to handle any HW or SW interrupts that may occur while in 16-bit real mode.
7130 If EFLAGS specifies interrupts enabled, or any of the 16-bit real mode code enables interrupts,
7131 then the caller is responsible for making sure the 8259 PIC is in a state compatible with 16-bit real mode.
7132 This includes the base vectors, the interrupt masks, and the edge/level trigger mode.
7134 If THUNK_ATTRIBUTE_BIG_REAL_MODE is set in the ThunkAttributes field of ThunkContext, then the user code
7135 is invoked in big real mode. Otherwise, the user code is invoked in 16-bit real mode with 64KB segment limits.
7137 If neither THUNK_ATTRIBUTE_DISABLE_A20_MASK_INT_15 nor THUNK_ATTRIBUTE_DISABLE_A20_MASK_KBD_CTRL are set in
7138 ThunkAttributes, then it is assumed that the user code did not enable the A20 mask, and no attempt is made to
7139 disable the A20 mask.
7141 If THUNK_ATTRIBUTE_DISABLE_A20_MASK_INT_15 is set and THUNK_ATTRIBUTE_DISABLE_A20_MASK_KBD_CTRL is clear in
7142 ThunkAttributes, then attempt to use the INT 15 service to disable the A20 mask. If this INT 15 call fails,
7143 then attempt to disable the A20 mask by directly accessing the 8042 keyboard controller I/O ports.
7145 If THUNK_ATTRIBUTE_DISABLE_A20_MASK_INT_15 is clear and THUNK_ATTRIBUTE_DISABLE_A20_MASK_KBD_CTRL is set in
7146 ThunkAttributes, then attempt to disable the A20 mask by directly accessing the 8042 keyboard controller I/O ports.
7148 If ThunkContext is NULL, then ASSERT().
7149 If AsmPrepareThunk16() was not previously called with ThunkContext, then ASSERT().
7150 If both THUNK_ATTRIBUTE_DISABLE_A20_MASK_INT_15 and THUNK_ATTRIBUTE_DISABLE_A20_MASK_KBD_CTRL are set in
7151 ThunkAttributes, then ASSERT().
7153 This interface is limited to be used in either physical mode or virtual modes with paging enabled where the
7154 virtual to physical mappings for ThunkContext.RealModeBuffer are mapped 1:1.
7156 @param ThunkContext A pointer to the context structure that describes the
7157 16-bit real mode code to call.
7163 IN OUT THUNK_CONTEXT
*ThunkContext
7168 Prepares all structures and code for a 16-bit real mode thunk, transfers
7169 control to a 16-bit real mode entry point, and returns the results.
7171 Prepares all structures and code for a 16-bit real mode thunk, transfers
7172 control to a 16-bit real mode entry point, and returns the results. If the
7173 caller only need to perform a single 16-bit real mode thunk, then this
7174 service should be used. If the caller intends to make more than one 16-bit
7175 real mode thunk, then it is more efficient if AsmPrepareThunk16() is called
7176 once and AsmThunk16() can be called for each 16-bit real mode thunk.
7178 This interface is limited to be used in either physical mode or virtual modes with paging enabled where the
7179 virtual to physical mappings for ThunkContext.RealModeBuffer is mapped 1:1.
7181 See AsmPrepareThunk16() and AsmThunk16() for the detailed description and ASSERT() conditions.
7183 @param ThunkContext A pointer to the context structure that describes the
7184 16-bit real mode code to call.
7189 AsmPrepareAndThunk16 (
7190 IN OUT THUNK_CONTEXT
*ThunkContext