2 Provides string functions, linked list functions, math functions, synchronization
3 functions, and CPU architecture-specific functions.
5 Copyright (c) 2006 - 2008, Intel Corporation<BR>
6 All rights reserved. This program and the accompanying materials
7 are licensed and made available under the terms and conditions of the BSD License
8 which accompanies this distribution. The full text of the license may be found at
9 http://opensource.org/licenses/bsd-license.php
11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
20 // Definitions for architecture-specific types
22 #if defined (MDE_CPU_IA32)
24 /// IA-32 architecture context buffer used by SetJump() and LongJump()
33 } BASE_LIBRARY_JUMP_BUFFER
;
35 #define BASE_LIBRARY_JUMP_BUFFER_ALIGNMENT 4
37 #endif // defined (MDE_CPU_IA32)
39 #if defined (MDE_CPU_IPF)
42 /// Itanium architecture context buffer used by SetJump() and LongJump()
77 UINT64 AfterSpillUNAT
;
83 } BASE_LIBRARY_JUMP_BUFFER
;
85 #define BASE_LIBRARY_JUMP_BUFFER_ALIGNMENT 0x10
87 #endif // defined (MDE_CPU_IPF)
89 #if defined (MDE_CPU_X64)
91 /// x64 architecture context buffer used by SetJump() and LongJump()
105 UINT8 XmmBuffer
[160]; ///< XMM6-XMM15
106 } BASE_LIBRARY_JUMP_BUFFER
;
108 #define BASE_LIBRARY_JUMP_BUFFER_ALIGNMENT 8
110 #endif // defined (MDE_CPU_X64)
112 #if defined (MDE_CPU_EBC)
114 /// EBC context buffer used by SetJump() and LongJump()
122 } BASE_LIBRARY_JUMP_BUFFER
;
124 #define BASE_LIBRARY_JUMP_BUFFER_ALIGNMENT 8
126 #endif // defined (MDE_CPU_EBC)
133 Copies one Null-terminated Unicode string to another Null-terminated Unicode
134 string and returns the new Unicode string.
136 This function copies the contents of the Unicode string Source to the Unicode
137 string Destination, and returns Destination. If Source and Destination
138 overlap, then the results are undefined.
140 If Destination is NULL, then ASSERT().
141 If Destination is not aligned on a 16-bit boundary, then ASSERT().
142 If Source is NULL, then ASSERT().
143 If Source is not aligned on a 16-bit boundary, then ASSERT().
144 If Source and Destination overlap, then ASSERT().
145 If PcdMaximumUnicodeStringLength is not zero, and Source contains more than
146 PcdMaximumUnicodeStringLength Unicode characters not including the
147 Null-terminator, then ASSERT().
149 @param Destination Pointer to a Null-terminated Unicode string.
150 @param Source Pointer to a Null-terminated Unicode string.
158 OUT CHAR16
*Destination
,
159 IN CONST CHAR16
*Source
164 Copies up to a specified length from one Null-terminated Unicode string to
165 another Null-terminated Unicode string and returns the new Unicode string.
167 This function copies the contents of the Unicode string Source to the Unicode
168 string Destination, and returns Destination. At most, Length Unicode
169 characters are copied from Source to Destination. If Length is 0, then
170 Destination is returned unmodified. If Length is greater that the number of
171 Unicode characters in Source, then Destination is padded with Null Unicode
172 characters. If Source and Destination overlap, then the results are
175 If Length > 0 and Destination is NULL, then ASSERT().
176 If Length > 0 and Destination is not aligned on a 16-bit boundary, then ASSERT().
177 If Length > 0 and Source is NULL, then ASSERT().
178 If Length > 0 and Source is not aligned on a 16-bit boundary, then ASSERT().
179 If Source and Destination overlap, then ASSERT().
180 If PcdMaximumUnicodeStringLength is not zero, and Length is greater than
181 PcdMaximumUnicodeStringLength, then ASSERT().
182 If PcdMaximumUnicodeStringLength is not zero, and Source contains more than
183 PcdMaximumUnicodeStringLength Unicode characters, not including the Null-terminator,
186 @param Destination Pointer to a Null-terminated Unicode string.
187 @param Source Pointer to a Null-terminated Unicode string.
188 @param Length Maximum number of Unicode characters to copy.
196 OUT CHAR16
*Destination
,
197 IN CONST CHAR16
*Source
,
203 Returns the length of a Null-terminated Unicode string.
205 This function returns the number of Unicode characters in the Null-terminated
206 Unicode string specified by String.
208 If String is NULL, then ASSERT().
209 If String is not aligned on a 16-bit boundary, then ASSERT().
210 If PcdMaximumUnicodeStringLength is not zero, and String contains more than
211 PcdMaximumUnicodeStringLength Unicode characters not including the
212 Null-terminator, then ASSERT().
214 @param String Pointer to a Null-terminated Unicode string.
216 @return The length of String.
222 IN CONST CHAR16
*String
227 Returns the size of a Null-terminated Unicode string in bytes, including the
230 This function returns the size, in bytes, of the Null-terminated Unicode string
233 If String is NULL, then ASSERT().
234 If String is not aligned on a 16-bit boundary, then ASSERT().
235 If PcdMaximumUnicodeStringLength is not zero, and String contains more than
236 PcdMaximumUnicodeStringLength Unicode characters not including the
237 Null-terminator, then ASSERT().
239 @param String Pointer to a Null-terminated Unicode string.
241 @return The size of String.
247 IN CONST CHAR16
*String
252 Compares two Null-terminated Unicode strings, and returns the difference
253 between the first mismatched Unicode characters.
255 This function compares the Null-terminated Unicode string FirstString to the
256 Null-terminated Unicode string SecondString. If FirstString is identical to
257 SecondString, then 0 is returned. Otherwise, the value returned is the first
258 mismatched Unicode character in SecondString subtracted from the first
259 mismatched Unicode character in FirstString.
261 If FirstString is NULL, then ASSERT().
262 If FirstString is not aligned on a 16-bit boundary, then ASSERT().
263 If SecondString is NULL, then ASSERT().
264 If SecondString is not aligned on a 16-bit boundary, then ASSERT().
265 If PcdMaximumUnicodeStringLength is not zero, and FirstString contains more
266 than PcdMaximumUnicodeStringLength Unicode characters not including the
267 Null-terminator, then ASSERT().
268 If PcdMaximumUnicodeStringLength is not zero, and SecondString contains more
269 than PcdMaximumUnicodeStringLength Unicode characters not including the
270 Null-terminator, then ASSERT().
272 @param FirstString Pointer to a Null-terminated Unicode string.
273 @param SecondString Pointer to a Null-terminated Unicode string.
275 @retval 0 FirstString is identical to SecondString.
276 @return others FirstString is not identical to SecondString.
282 IN CONST CHAR16
*FirstString
,
283 IN CONST CHAR16
*SecondString
288 Compares up to a specified length the contents of two Null-terminated Unicode strings,
289 and returns the difference between the first mismatched Unicode characters.
291 This function compares the Null-terminated Unicode string FirstString to the
292 Null-terminated Unicode string SecondString. At most, Length Unicode
293 characters will be compared. If Length is 0, then 0 is returned. If
294 FirstString is identical to SecondString, then 0 is returned. Otherwise, the
295 value returned is the first mismatched Unicode character in SecondString
296 subtracted from the first mismatched Unicode character in FirstString.
298 If Length > 0 and FirstString is NULL, then ASSERT().
299 If Length > 0 and FirstString is not aligned on a 16-bit boundary, then ASSERT().
300 If Length > 0 and SecondString is NULL, then ASSERT().
301 If Length > 0 and SecondString is not aligned on a 16-bit boundary, then ASSERT().
302 If PcdMaximumUnicodeStringLength is not zero, and Length is greater than
303 PcdMaximumUnicodeStringLength, then ASSERT().
304 If PcdMaximumUnicodeStringLength is not zero, and FirstString contains more than
305 PcdMaximumUnicodeStringLength Unicode characters, not including the Null-terminator,
307 If PcdMaximumUnicodeStringLength is not zero, and SecondString contains more than
308 PcdMaximumUnicodeStringLength Unicode characters, not including the Null-terminator,
311 @param FirstString Pointer to a Null-terminated Unicode string.
312 @param SecondString Pointer to a Null-terminated Unicode string.
313 @param Length Maximum number of Unicode characters to compare.
315 @retval 0 FirstString is identical to SecondString.
316 @return others FirstString is not identical to SecondString.
322 IN CONST CHAR16
*FirstString
,
323 IN CONST CHAR16
*SecondString
,
329 Concatenates one Null-terminated Unicode string to another Null-terminated
330 Unicode string, and returns the concatenated Unicode string.
332 This function concatenates two Null-terminated Unicode strings. The contents
333 of Null-terminated Unicode string Source are concatenated to the end of
334 Null-terminated Unicode string Destination. The Null-terminated concatenated
335 Unicode String is returned. If Source and Destination overlap, then the
336 results are undefined.
338 If Destination is NULL, then ASSERT().
339 If Destination is not aligned on a 16-bit boundary, then ASSERT().
340 If Source is NULL, then ASSERT().
341 If Source is not aligned on a 16-bit boundary, then ASSERT().
342 If Source and Destination overlap, then ASSERT().
343 If PcdMaximumUnicodeStringLength is not zero, and Destination contains more
344 than PcdMaximumUnicodeStringLength Unicode characters not including the
345 Null-terminator, then ASSERT().
346 If PcdMaximumUnicodeStringLength is not zero, and Source contains more than
347 PcdMaximumUnicodeStringLength Unicode characters not including the
348 Null-terminator, then ASSERT().
349 If PcdMaximumUnicodeStringLength is not zero, and concatenating Destination
350 and Source results in a Unicode string with more than
351 PcdMaximumUnicodeStringLength Unicode characters not including the
352 Null-terminator, then ASSERT().
354 @param Destination Pointer to a Null-terminated Unicode string.
355 @param Source Pointer to a Null-terminated Unicode string.
363 IN OUT CHAR16
*Destination
,
364 IN CONST CHAR16
*Source
369 Concatenates up to a specified length one Null-terminated Unicode to the end
370 of another Null-terminated Unicode string, and returns the concatenated
373 This function concatenates two Null-terminated Unicode strings. The contents
374 of Null-terminated Unicode string Source are concatenated to the end of
375 Null-terminated Unicode string Destination, and Destination is returned. At
376 most, Length Unicode characters are concatenated from Source to the end of
377 Destination, and Destination is always Null-terminated. If Length is 0, then
378 Destination is returned unmodified. If Source and Destination overlap, then
379 the results are undefined.
381 If Destination is NULL, then ASSERT().
382 If Length > 0 and Destination is not aligned on a 16-bit boundary, then ASSERT().
383 If Length > 0 and Source is NULL, then ASSERT().
384 If Length > 0 and Source is not aligned on a 16-bit boundary, then ASSERT().
385 If Source and Destination overlap, then ASSERT().
386 If PcdMaximumUnicodeStringLength is not zero, and Length is greater than
387 PcdMaximumUnicodeStringLength, then ASSERT().
388 If PcdMaximumUnicodeStringLength is not zero, and Destination contains more
389 than PcdMaximumUnicodeStringLength Unicode characters, not including the
390 Null-terminator, then ASSERT().
391 If PcdMaximumUnicodeStringLength is not zero, and Source contains more than
392 PcdMaximumUnicodeStringLength Unicode characters, not including the
393 Null-terminator, then ASSERT().
394 If PcdMaximumUnicodeStringLength is not zero, and concatenating Destination
395 and Source results in a Unicode string with more than PcdMaximumUnicodeStringLength
396 Unicode characters, not including the Null-terminator, then ASSERT().
398 @param Destination Pointer to a Null-terminated Unicode string.
399 @param Source Pointer to a Null-terminated Unicode string.
400 @param Length Maximum number of Unicode characters to concatenate from
409 IN OUT CHAR16
*Destination
,
410 IN CONST CHAR16
*Source
,
415 Returns the first occurrence of a Null-terminated Unicode sub-string
416 in a Null-terminated Unicode string.
418 This function scans the contents of the Null-terminated Unicode string
419 specified by String and returns the first occurrence of SearchString.
420 If SearchString is not found in String, then NULL is returned. If
421 the length of SearchString is zero, then String is
424 If String is NULL, then ASSERT().
425 If String is not aligned on a 16-bit boundary, then ASSERT().
426 If SearchString is NULL, then ASSERT().
427 If SearchString is not aligned on a 16-bit boundary, then ASSERT().
429 If PcdMaximumUnicodeStringLength is not zero, and SearchString
430 or String contains more than PcdMaximumUnicodeStringLength Unicode
431 characters not including the Null-terminator, then ASSERT().
433 @param String Pointer to a Null-terminated Unicode string.
434 @param SearchString Pointer to a Null-terminated Unicode string to search for.
436 @retval NULL If the SearchString does not appear in String.
437 @return others If there is a match.
443 IN CONST CHAR16
*String
,
444 IN CONST CHAR16
*SearchString
448 Convert a Null-terminated Unicode decimal string to a value of
451 This function returns a value of type UINTN by interpreting the contents
452 of the Unicode string specified by String as a decimal number. The format
453 of the input Unicode string String is:
455 [spaces] [decimal digits].
457 The valid decimal digit character is in the range [0-9]. The
458 function will ignore the pad space, which includes spaces or
459 tab characters, before [decimal digits]. The running zero in the
460 beginning of [decimal digits] will be ignored. Then, the function
461 stops at the first character that is a not a valid decimal character
462 or a Null-terminator, whichever one comes first.
464 If String is NULL, then ASSERT().
465 If String is not aligned in a 16-bit boundary, then ASSERT().
466 If String has only pad spaces, then 0 is returned.
467 If String has no pad spaces or valid decimal digits,
469 If the number represented by String overflows according
470 to the range defined by UINTN, then ASSERT().
472 If PcdMaximumUnicodeStringLength is not zero, and String contains
473 more than PcdMaximumUnicodeStringLength Unicode characters not including
474 the Null-terminator, then ASSERT().
476 @param String Pointer to a Null-terminated Unicode string.
478 @retval Value translated from String.
484 IN CONST CHAR16
*String
488 Convert a Null-terminated Unicode decimal string to a value of
491 This function returns a value of type UINT64 by interpreting the contents
492 of the Unicode string specified by String as a decimal number. The format
493 of the input Unicode string String is:
495 [spaces] [decimal digits].
497 The valid decimal digit character is in the range [0-9]. The
498 function will ignore the pad space, which includes spaces or
499 tab characters, before [decimal digits]. The running zero in the
500 beginning of [decimal digits] will be ignored. Then, the function
501 stops at the first character that is a not a valid decimal character
502 or a Null-terminator, whichever one comes first.
504 If String is NULL, then ASSERT().
505 If String is not aligned in a 16-bit boundary, then ASSERT().
506 If String has only pad spaces, then 0 is returned.
507 If String has no pad spaces or valid decimal digits,
509 If the number represented by String overflows according
510 to the range defined by UINT64, then ASSERT().
512 If PcdMaximumUnicodeStringLength is not zero, and String contains
513 more than PcdMaximumUnicodeStringLength Unicode characters not including
514 the Null-terminator, then ASSERT().
516 @param String Pointer to a Null-terminated Unicode string.
518 @retval Value translated from String.
524 IN CONST CHAR16
*String
529 Convert a Null-terminated Unicode hexadecimal string to a value of type UINTN.
531 This function returns a value of type UINTN by interpreting the contents
532 of the Unicode string specified by String as a hexadecimal number.
533 The format of the input Unicode string String is:
535 [spaces][zeros][x][hexadecimal digits].
537 The valid hexadecimal digit character is in the range [0-9], [a-f] and [A-F].
538 The prefix "0x" is optional. Both "x" and "X" is allowed in "0x" prefix.
539 If "x" appears in the input string, it must be prefixed with at least one 0.
540 The function will ignore the pad space, which includes spaces or tab characters,
541 before [zeros], [x] or [hexadecimal digit]. The running zero before [x] or
542 [hexadecimal digit] will be ignored. Then, the decoding starts after [x] or the
543 first valid hexadecimal digit. Then, the function stops at the first character that is
544 a not a valid hexadecimal character or NULL, whichever one comes first.
546 If String is NULL, then ASSERT().
547 If String is not aligned in a 16-bit boundary, then ASSERT().
548 If String has only pad spaces, then zero is returned.
549 If String has no leading pad spaces, leading zeros or valid hexadecimal digits,
550 then zero is returned.
551 If the number represented by String overflows according to the range defined by
552 UINTN, then ASSERT().
554 If PcdMaximumUnicodeStringLength is not zero, and String contains more than
555 PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator,
558 @param String Pointer to a Null-terminated Unicode string.
560 @retval Value translated from String.
566 IN CONST CHAR16
*String
571 Convert a Null-terminated Unicode hexadecimal string to a value of type UINT64.
573 This function returns a value of type UINT64 by interpreting the contents
574 of the Unicode string specified by String as a hexadecimal number.
575 The format of the input Unicode string String is
577 [spaces][zeros][x][hexadecimal digits].
579 The valid hexadecimal digit character is in the range [0-9], [a-f] and [A-F].
580 The prefix "0x" is optional. Both "x" and "X" is allowed in "0x" prefix.
581 If "x" appears in the input string, it must be prefixed with at least one 0.
582 The function will ignore the pad space, which includes spaces or tab characters,
583 before [zeros], [x] or [hexadecimal digit]. The running zero before [x] or
584 [hexadecimal digit] will be ignored. Then, the decoding starts after [x] or the
585 first valid hexadecimal digit. Then, the function stops at the first character that is
586 a not a valid hexadecimal character or NULL, whichever one comes first.
588 If String is NULL, then ASSERT().
589 If String is not aligned in a 16-bit boundary, then ASSERT().
590 If String has only pad spaces, then zero is returned.
591 If String has no leading pad spaces, leading zeros or valid hexadecimal digits,
592 then zero is returned.
593 If the number represented by String overflows according to the range defined by
594 UINT64, then ASSERT().
596 If PcdMaximumUnicodeStringLength is not zero, and String contains more than
597 PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator,
600 @param String Pointer to a Null-terminated Unicode string.
602 @retval Value translated from String.
608 IN CONST CHAR16
*String
612 Convert a Null-terminated Unicode string to a Null-terminated
613 ASCII string and returns the ASCII string.
615 This function converts the content of the Unicode string Source
616 to the ASCII string Destination by copying the lower 8 bits of
617 each Unicode character. It returns Destination.
619 If any Unicode characters in Source contain non-zero value in
620 the upper 8 bits, then ASSERT().
622 If Destination is NULL, then ASSERT().
623 If Source is NULL, then ASSERT().
624 If Source is not aligned on a 16-bit boundary, then ASSERT().
625 If Source and Destination overlap, then ASSERT().
627 If PcdMaximumUnicodeStringLength is not zero, and Source contains
628 more than PcdMaximumUnicodeStringLength Unicode characters not including
629 the Null-terminator, then ASSERT().
631 If PcdMaximumAsciiStringLength is not zero, and Source contains more
632 than PcdMaximumAsciiStringLength Unicode characters not including the
633 Null-terminator, then ASSERT().
635 @param Source Pointer to a Null-terminated Unicode string.
636 @param Destination Pointer to a Null-terminated ASCII string.
643 UnicodeStrToAsciiStr (
644 IN CONST CHAR16
*Source
,
645 OUT CHAR8
*Destination
650 Copies one Null-terminated ASCII string to another Null-terminated ASCII
651 string and returns the new ASCII string.
653 This function copies the contents of the ASCII string Source to the ASCII
654 string Destination, and returns Destination. If Source and Destination
655 overlap, then the results are undefined.
657 If Destination is NULL, then ASSERT().
658 If Source is NULL, then ASSERT().
659 If Source and Destination overlap, then ASSERT().
660 If PcdMaximumAsciiStringLength is not zero and Source contains more than
661 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
664 @param Destination Pointer to a Null-terminated ASCII string.
665 @param Source Pointer to a Null-terminated ASCII string.
673 OUT CHAR8
*Destination
,
674 IN CONST CHAR8
*Source
679 Copies up to a specified length one Null-terminated ASCII string to another
680 Null-terminated ASCII string and returns the new ASCII string.
682 This function copies the contents of the ASCII string Source to the ASCII
683 string Destination, and returns Destination. At most, Length ASCII characters
684 are copied from Source to Destination. If Length is 0, then Destination is
685 returned unmodified. If Length is greater that the number of ASCII characters
686 in Source, then Destination is padded with Null ASCII characters. If Source
687 and Destination overlap, then the results are undefined.
689 If Destination is NULL, then ASSERT().
690 If Source is NULL, then ASSERT().
691 If Source and Destination overlap, then ASSERT().
692 If PcdMaximumAsciiStringLength is not zero, and Length is greater than
693 PcdMaximumAsciiStringLength, then ASSERT().
694 If PcdMaximumAsciiStringLength is not zero, and Source contains more than
695 PcdMaximumAsciiStringLength ASCII characters, not including the Null-terminator,
698 @param Destination Pointer to a Null-terminated ASCII string.
699 @param Source Pointer to a Null-terminated ASCII string.
700 @param Length Maximum number of ASCII characters to copy.
708 OUT CHAR8
*Destination
,
709 IN CONST CHAR8
*Source
,
715 Returns the length of a Null-terminated ASCII string.
717 This function returns the number of ASCII characters in the Null-terminated
718 ASCII string specified by String.
720 If Length > 0 and Destination is NULL, then ASSERT().
721 If Length > 0 and Source is NULL, then ASSERT().
722 If PcdMaximumAsciiStringLength is not zero and String contains more than
723 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
726 @param String Pointer to a Null-terminated ASCII string.
728 @return The length of String.
734 IN CONST CHAR8
*String
739 Returns the size of a Null-terminated ASCII string in bytes, including the
742 This function returns the size, in bytes, of the Null-terminated ASCII string
745 If String is NULL, then ASSERT().
746 If PcdMaximumAsciiStringLength is not zero and String contains more than
747 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
750 @param String Pointer to a Null-terminated ASCII string.
752 @return The size of String.
758 IN CONST CHAR8
*String
763 Compares two Null-terminated ASCII strings, and returns the difference
764 between the first mismatched ASCII characters.
766 This function compares the Null-terminated ASCII string FirstString to the
767 Null-terminated ASCII string SecondString. If FirstString is identical to
768 SecondString, then 0 is returned. Otherwise, the value returned is the first
769 mismatched ASCII character in SecondString subtracted from the first
770 mismatched ASCII character in FirstString.
772 If FirstString is NULL, then ASSERT().
773 If SecondString is NULL, then ASSERT().
774 If PcdMaximumAsciiStringLength is not zero and FirstString contains more than
775 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
777 If PcdMaximumAsciiStringLength is not zero and SecondString contains more
778 than PcdMaximumAsciiStringLength ASCII characters not including the
779 Null-terminator, then ASSERT().
781 @param FirstString Pointer to a Null-terminated ASCII string.
782 @param SecondString Pointer to a Null-terminated ASCII string.
784 @retval ==0 FirstString is identical to SecondString.
785 @retval !=0 FirstString is not identical to SecondString.
791 IN CONST CHAR8
*FirstString
,
792 IN CONST CHAR8
*SecondString
797 Performs a case insensitive comparison of two Null-terminated ASCII strings,
798 and returns the difference between the first mismatched ASCII characters.
800 This function performs a case insensitive comparison of the Null-terminated
801 ASCII string FirstString to the Null-terminated ASCII string SecondString. If
802 FirstString is identical to SecondString, then 0 is returned. Otherwise, the
803 value returned is the first mismatched lower case ASCII character in
804 SecondString subtracted from the first mismatched lower case ASCII character
807 If FirstString is NULL, then ASSERT().
808 If SecondString is NULL, then ASSERT().
809 If PcdMaximumAsciiStringLength is not zero and FirstString contains more than
810 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
812 If PcdMaximumAsciiStringLength is not zero and SecondString contains more
813 than PcdMaximumAsciiStringLength ASCII characters not including the
814 Null-terminator, then ASSERT().
816 @param FirstString Pointer to a Null-terminated ASCII string.
817 @param SecondString Pointer to a Null-terminated ASCII string.
819 @retval ==0 FirstString is identical to SecondString using case insensitive
821 @retval !=0 FirstString is not identical to SecondString using case
822 insensitive comparisons.
828 IN CONST CHAR8
*FirstString
,
829 IN CONST CHAR8
*SecondString
834 Compares two Null-terminated ASCII strings with maximum lengths, and returns
835 the difference between the first mismatched ASCII characters.
837 This function compares the Null-terminated ASCII string FirstString to the
838 Null-terminated ASCII string SecondString. At most, Length ASCII characters
839 will be compared. If Length is 0, then 0 is returned. If FirstString is
840 identical to SecondString, then 0 is returned. Otherwise, the value returned
841 is the first mismatched ASCII character in SecondString subtracted from the
842 first mismatched ASCII character in FirstString.
844 If Length > 0 and FirstString is NULL, then ASSERT().
845 If Length > 0 and SecondString is NULL, then ASSERT().
846 If PcdMaximumAsciiStringLength is not zero, and Length is greater than
847 PcdMaximumAsciiStringLength, then ASSERT().
848 If PcdMaximumAsciiStringLength is not zero, and FirstString contains more than
849 PcdMaximumAsciiStringLength ASCII characters, not including the Null-terminator,
851 If PcdMaximumAsciiStringLength is not zero, and SecondString contains more than
852 PcdMaximumAsciiStringLength ASCII characters, not including the Null-terminator,
855 @param FirstString Pointer to a Null-terminated ASCII string.
856 @param SecondString Pointer to a Null-terminated ASCII string.
857 @param Length Maximum number of ASCII characters for compare.
859 @retval ==0 FirstString is identical to SecondString.
860 @retval !=0 FirstString is not identical to SecondString.
866 IN CONST CHAR8
*FirstString
,
867 IN CONST CHAR8
*SecondString
,
873 Concatenates one Null-terminated ASCII string to another Null-terminated
874 ASCII string, and returns the concatenated ASCII string.
876 This function concatenates two Null-terminated ASCII strings. The contents of
877 Null-terminated ASCII string Source are concatenated to the end of Null-
878 terminated ASCII string Destination. The Null-terminated concatenated ASCII
881 If Destination is NULL, then ASSERT().
882 If Source is NULL, then ASSERT().
883 If PcdMaximumAsciiStringLength is not zero and Destination contains more than
884 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
886 If PcdMaximumAsciiStringLength is not zero and Source contains more than
887 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
889 If PcdMaximumAsciiStringLength is not zero and concatenating Destination and
890 Source results in a ASCII string with more than PcdMaximumAsciiStringLength
891 ASCII characters, then ASSERT().
893 @param Destination Pointer to a Null-terminated ASCII string.
894 @param Source Pointer to a Null-terminated ASCII string.
902 IN OUT CHAR8
*Destination
,
903 IN CONST CHAR8
*Source
908 Concatenates up to a specified length one Null-terminated ASCII string to
909 the end of another Null-terminated ASCII string, and returns the
910 concatenated ASCII string.
912 This function concatenates two Null-terminated ASCII strings. The contents
913 of Null-terminated ASCII string Source are concatenated to the end of Null-
914 terminated ASCII string Destination, and Destination is returned. At most,
915 Length ASCII characters are concatenated from Source to the end of
916 Destination, and Destination is always Null-terminated. If Length is 0, then
917 Destination is returned unmodified. If Source and Destination overlap, then
918 the results are undefined.
920 If Length > 0 and Destination is NULL, then ASSERT().
921 If Length > 0 and Source is NULL, then ASSERT().
922 If Source and Destination overlap, then ASSERT().
923 If PcdMaximumAsciiStringLength is not zero, and Length is greater than
924 PcdMaximumAsciiStringLength, then ASSERT().
925 If PcdMaximumAsciiStringLength is not zero, and Destination contains more than
926 PcdMaximumAsciiStringLength ASCII characters, not including the Null-terminator,
928 If PcdMaximumAsciiStringLength is not zero, and Source contains more than
929 PcdMaximumAsciiStringLength ASCII characters, not including the Null-terminator,
931 If PcdMaximumAsciiStringLength is not zero, and concatenating Destination and
932 Source results in a ASCII string with more than PcdMaximumAsciiStringLength
933 ASCII characters, not including the Null-terminator, then ASSERT().
935 @param Destination Pointer to a Null-terminated ASCII string.
936 @param Source Pointer to a Null-terminated ASCII string.
937 @param Length Maximum number of ASCII characters to concatenate from
946 IN OUT CHAR8
*Destination
,
947 IN CONST CHAR8
*Source
,
953 Returns the first occurrence of a Null-terminated ASCII sub-string
954 in a Null-terminated ASCII string.
956 This function scans the contents of the ASCII string specified by String
957 and returns the first occurrence of SearchString. If SearchString is not
958 found in String, then NULL is returned. If the length of SearchString is zero,
959 then String is returned.
961 If String is NULL, then ASSERT().
962 If SearchString is NULL, then ASSERT().
964 If PcdMaximumAsciiStringLength is not zero, and SearchString or
965 String contains more than PcdMaximumAsciiStringLength Unicode characters
966 not including the Null-terminator, then ASSERT().
968 @param String Pointer to a Null-terminated ASCII string.
969 @param SearchString Pointer to a Null-terminated ASCII string to search for.
971 @retval NULL If the SearchString does not appear in String.
972 @retval others If there is a match return the first occurrence of SearchingString.
973 If the length of SearchString is zero,return String.
979 IN CONST CHAR8
*String
,
980 IN CONST CHAR8
*SearchString
985 Convert a Null-terminated ASCII decimal string to a value of type
988 This function returns a value of type UINTN by interpreting the contents
989 of the ASCII string String as a decimal number. The format of the input
990 ASCII string String is:
992 [spaces] [decimal digits].
994 The valid decimal digit character is in the range [0-9]. The function will
995 ignore the pad space, which includes spaces or tab characters, before the digits.
996 The running zero in the beginning of [decimal digits] will be ignored. Then, the
997 function stops at the first character that is a not a valid decimal character or
998 Null-terminator, whichever on comes first.
1000 If String has only pad spaces, then 0 is returned.
1001 If String has no pad spaces or valid decimal digits, then 0 is returned.
1002 If the number represented by String overflows according to the range defined by
1003 UINTN, then ASSERT().
1004 If String is NULL, then ASSERT().
1005 If PcdMaximumAsciiStringLength is not zero, and String contains more than
1006 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
1009 @param String Pointer to a Null-terminated ASCII string.
1011 @retval Value translated from String.
1016 AsciiStrDecimalToUintn (
1017 IN CONST CHAR8
*String
1022 Convert a Null-terminated ASCII decimal string to a value of type
1025 This function returns a value of type UINT64 by interpreting the contents
1026 of the ASCII string String as a decimal number. The format of the input
1027 ASCII string String is:
1029 [spaces] [decimal digits].
1031 The valid decimal digit character is in the range [0-9]. The function will
1032 ignore the pad space, which includes spaces or tab characters, before the digits.
1033 The running zero in the beginning of [decimal digits] will be ignored. Then, the
1034 function stops at the first character that is a not a valid decimal character or
1035 Null-terminator, whichever on comes first.
1037 If String has only pad spaces, then 0 is returned.
1038 If String has no pad spaces or valid decimal digits, then 0 is returned.
1039 If the number represented by String overflows according to the range defined by
1040 UINT64, then ASSERT().
1041 If String is NULL, then ASSERT().
1042 If PcdMaximumAsciiStringLength is not zero, and String contains more than
1043 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
1046 @param String Pointer to a Null-terminated ASCII string.
1048 @retval Value translated from String.
1053 AsciiStrDecimalToUint64 (
1054 IN CONST CHAR8
*String
1059 Convert a Null-terminated ASCII hexadecimal string to a value of type UINTN.
1061 This function returns a value of type UINTN by interpreting the contents of
1062 the ASCII string String as a hexadecimal number. The format of the input ASCII
1065 [spaces][zeros][x][hexadecimal digits].
1067 The valid hexadecimal digit character is in the range [0-9], [a-f] and [A-F].
1068 The prefix "0x" is optional. Both "x" and "X" is allowed in "0x" prefix. If "x"
1069 appears in the input string, it must be prefixed with at least one 0. The function
1070 will ignore the pad space, which includes spaces or tab characters, before [zeros],
1071 [x] or [hexadecimal digits]. The running zero before [x] or [hexadecimal digits]
1072 will be ignored. Then, the decoding starts after [x] or the first valid hexadecimal
1073 digit. Then, the function stops at the first character that is a not a valid
1074 hexadecimal character or Null-terminator, whichever on comes first.
1076 If String has only pad spaces, then 0 is returned.
1077 If String has no leading pad spaces, leading zeros or valid hexadecimal digits, then
1080 If the number represented by String overflows according to the range defined by UINTN,
1082 If String is NULL, then ASSERT().
1083 If PcdMaximumAsciiStringLength is not zero,
1084 and String contains more than PcdMaximumAsciiStringLength ASCII characters not including
1085 the Null-terminator, then ASSERT().
1087 @param String Pointer to a Null-terminated ASCII string.
1089 @retval Value translated from String.
1094 AsciiStrHexToUintn (
1095 IN CONST CHAR8
*String
1100 Convert a Null-terminated ASCII hexadecimal string to a value of type UINT64.
1102 This function returns a value of type UINT64 by interpreting the contents of
1103 the ASCII string String as a hexadecimal number. The format of the input ASCII
1106 [spaces][zeros][x][hexadecimal digits].
1108 The valid hexadecimal digit character is in the range [0-9], [a-f] and [A-F].
1109 The prefix "0x" is optional. Both "x" and "X" is allowed in "0x" prefix. If "x"
1110 appears in the input string, it must be prefixed with at least one 0. The function
1111 will ignore the pad space, which includes spaces or tab characters, before [zeros],
1112 [x] or [hexadecimal digits]. The running zero before [x] or [hexadecimal digits]
1113 will be ignored. Then, the decoding starts after [x] or the first valid hexadecimal
1114 digit. Then, the function stops at the first character that is a not a valid
1115 hexadecimal character or Null-terminator, whichever on comes first.
1117 If String has only pad spaces, then 0 is returned.
1118 If String has no leading pad spaces, leading zeros or valid hexadecimal digits, then
1121 If the number represented by String overflows according to the range defined by UINT64,
1123 If String is NULL, then ASSERT().
1124 If PcdMaximumAsciiStringLength is not zero,
1125 and String contains more than PcdMaximumAsciiStringLength ASCII characters not including
1126 the Null-terminator, then ASSERT().
1128 @param String Pointer to a Null-terminated ASCII string.
1130 @retval Value translated from String.
1135 AsciiStrHexToUint64 (
1136 IN CONST CHAR8
*String
1141 Convert one Null-terminated ASCII string to a Null-terminated
1142 Unicode string and returns the Unicode string.
1144 This function converts the contents of the ASCII string Source to the Unicode
1145 string Destination, and returns Destination. The function terminates the
1146 Unicode string Destination by appending a Null-terminator character at the end.
1147 The caller is responsible to make sure Destination points to a buffer with size
1148 equal or greater than ((AsciiStrLen (Source) + 1) * sizeof (CHAR16)) in bytes.
1150 If Destination is NULL, then ASSERT().
1151 If Destination is not aligned on a 16-bit boundary, then ASSERT().
1152 If Source is NULL, then ASSERT().
1153 If Source and Destination overlap, then ASSERT().
1154 If PcdMaximumAsciiStringLength is not zero, and Source contains more than
1155 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
1157 If PcdMaximumUnicodeStringLength is not zero, and Source contains more than
1158 PcdMaximumUnicodeStringLength ASCII characters not including the
1159 Null-terminator, then ASSERT().
1161 @param Source Pointer to a Null-terminated ASCII string.
1162 @param Destination Pointer to a Null-terminated Unicode string.
1164 @return Destination.
1169 AsciiStrToUnicodeStr (
1170 IN CONST CHAR8
*Source
,
1171 OUT CHAR16
*Destination
1176 Converts an 8-bit value to an 8-bit BCD value.
1178 Converts the 8-bit value specified by Value to BCD. The BCD value is
1181 If Value >= 100, then ASSERT().
1183 @param Value The 8-bit value to convert to BCD. Range 0..99.
1185 @return The BCD value.
1196 Converts an 8-bit BCD value to an 8-bit value.
1198 Converts the 8-bit BCD value specified by Value to an 8-bit value. The 8-bit
1201 If Value >= 0xA0, then ASSERT().
1202 If (Value & 0x0F) >= 0x0A, then ASSERT().
1204 @param Value The 8-bit BCD value to convert to an 8-bit value.
1206 @return The 8-bit value is returned.
1217 // Linked List Functions and Macros
1221 Initializes the head node of a doubly linked list that is declared as a
1222 global variable in a module.
1224 Initializes the forward and backward links of a new linked list. After
1225 initializing a linked list with this macro, the other linked list functions
1226 may be used to add and remove nodes from the linked list. This macro results
1227 in smaller executables by initializing the linked list in the data section,
1228 instead if calling the InitializeListHead() function to perform the
1229 equivalent operation.
1231 @param ListHead The head note of a list to initialize.
1234 #define INITIALIZE_LIST_HEAD_VARIABLE(ListHead) {&(ListHead), &(ListHead)}
1238 Initializes the head node of a doubly linked list, and returns the pointer to
1239 the head node of the doubly linked list.
1241 Initializes the forward and backward links of a new linked list. After
1242 initializing a linked list with this function, the other linked list
1243 functions may be used to add and remove nodes from the linked list. It is up
1244 to the caller of this function to allocate the memory for ListHead.
1246 If ListHead is NULL, then ASSERT().
1248 @param ListHead A pointer to the head node of a new doubly linked list.
1255 InitializeListHead (
1256 IN OUT LIST_ENTRY
*ListHead
1261 Adds a node to the beginning of a doubly linked list, and returns the pointer
1262 to the head node of the doubly linked list.
1264 Adds the node Entry at the beginning of the doubly linked list denoted by
1265 ListHead, and returns ListHead.
1267 If ListHead is NULL, then ASSERT().
1268 If Entry is NULL, then ASSERT().
1269 If ListHead was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or
1270 InitializeListHead(), then ASSERT().
1271 If PcdMaximumLinkedListLenth is not zero, and prior to insertion the number
1272 of nodes in ListHead, including the ListHead node, is greater than or
1273 equal to PcdMaximumLinkedListLength, then ASSERT().
1275 @param ListHead A pointer to the head node of a doubly linked list.
1276 @param Entry A pointer to a node that is to be inserted at the beginning
1277 of a doubly linked list.
1285 IN OUT LIST_ENTRY
*ListHead
,
1286 IN OUT LIST_ENTRY
*Entry
1291 Adds a node to the end of a doubly linked list, and returns the pointer to
1292 the head node of the doubly linked list.
1294 Adds the node Entry to the end of the doubly linked list denoted by ListHead,
1295 and returns ListHead.
1297 If ListHead is NULL, then ASSERT().
1298 If Entry is NULL, then ASSERT().
1299 If ListHead was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or
1300 InitializeListHead(), then ASSERT().
1301 If PcdMaximumLinkedListLenth is not zero, and prior to insertion the number
1302 of nodes in ListHead, including the ListHead node, is greater than or
1303 equal to PcdMaximumLinkedListLength, then ASSERT().
1305 @param ListHead A pointer to the head node of a doubly linked list.
1306 @param Entry A pointer to a node that is to be added at the end of the
1315 IN OUT LIST_ENTRY
*ListHead
,
1316 IN OUT LIST_ENTRY
*Entry
1321 Retrieves the first node of a doubly linked list.
1323 Returns the first node of a doubly linked list. List must have been
1324 initialized with INTIALIZE_LIST_HEAD_VARIABLE() or InitializeListHead().
1325 If List is empty, then List is returned.
1327 If List is NULL, then ASSERT().
1328 If List was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or
1329 InitializeListHead(), then ASSERT().
1330 If PcdMaximumLinkedListLenth is not zero, and the number of nodes
1331 in List, including the List node, is greater than or equal to
1332 PcdMaximumLinkedListLength, then ASSERT().
1334 @param List A pointer to the head node of a doubly linked list.
1336 @return The first node of a doubly linked list.
1337 @retval NULL The list is empty.
1343 IN CONST LIST_ENTRY
*List
1348 Retrieves the next node of a doubly linked list.
1350 Returns the node of a doubly linked list that follows Node.
1351 List must have been initialized with INTIALIZE_LIST_HEAD_VARIABLE()
1352 or InitializeListHead(). If List is empty, then List is returned.
1354 If List is NULL, then ASSERT().
1355 If Node is NULL, then ASSERT().
1356 If List was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or
1357 InitializeListHead(), then ASSERT().
1358 If PcdMaximumLinkedListLenth is not zero, and List contains more than
1359 PcdMaximumLinkedListLenth nodes, then ASSERT().
1360 If Node is not a node in List, then ASSERT().
1362 @param List A pointer to the head node of a doubly linked list.
1363 @param Node A pointer to a node in the doubly linked list.
1365 @return Pointer to the next node if one exists. Otherwise a null value which
1366 is actually List is returned.
1372 IN CONST LIST_ENTRY
*List
,
1373 IN CONST LIST_ENTRY
*Node
1378 Checks to see if a doubly linked list is empty or not.
1380 Checks to see if the doubly linked list is empty. If the linked list contains
1381 zero nodes, this function returns TRUE. Otherwise, it returns FALSE.
1383 If ListHead is NULL, then ASSERT().
1384 If ListHead was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or
1385 InitializeListHead(), then ASSERT().
1386 If PcdMaximumLinkedListLenth is not zero, and the number of nodes
1387 in List, including the List node, is greater than or equal to
1388 PcdMaximumLinkedListLength, then ASSERT().
1390 @param ListHead A pointer to the head node of a doubly linked list.
1392 @retval TRUE The linked list is empty.
1393 @retval FALSE The linked list is not empty.
1399 IN CONST LIST_ENTRY
*ListHead
1404 Determines if a node in a doubly linked list is the head node of a the same
1405 doubly linked list. This function is typically used to terminate a loop that
1406 traverses all the nodes in a doubly linked list starting with the head node.
1408 Returns TRUE if Node is equal to List. Returns FALSE if Node is one of the
1409 nodes in the doubly linked list specified by List. List must have been
1410 initialized with INTIALIZE_LIST_HEAD_VARIABLE() or InitializeListHead().
1412 If List is NULL, then ASSERT().
1413 If Node is NULL, then ASSERT().
1414 If List was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or InitializeListHead(),
1416 If PcdMaximumLinkedListLenth is not zero, and the number of nodes
1417 in List, including the List node, is greater than or equal to
1418 PcdMaximumLinkedListLength, then ASSERT().
1419 If Node is not a node in List and Node is not equal to List, then ASSERT().
1421 @param List A pointer to the head node of a doubly linked list.
1422 @param Node A pointer to a node in the doubly linked list.
1424 @retval TRUE Node is one of the nodes in the doubly linked list.
1425 @retval FALSE Node is not one of the nodes in the doubly linked list.
1431 IN CONST LIST_ENTRY
*List
,
1432 IN CONST LIST_ENTRY
*Node
1437 Determines if a node the last node in a doubly linked list.
1439 Returns TRUE if Node is the last node in the doubly linked list specified by
1440 List. Otherwise, FALSE is returned. List must have been initialized with
1441 INTIALIZE_LIST_HEAD_VARIABLE() or InitializeListHead().
1443 If List is NULL, then ASSERT().
1444 If Node is NULL, then ASSERT().
1445 If List was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or
1446 InitializeListHead(), then ASSERT().
1447 If PcdMaximumLinkedListLenth is not zero, and the number of nodes
1448 in List, including the List node, is greater than or equal to
1449 PcdMaximumLinkedListLength, then ASSERT().
1450 If Node is not a node in List, then ASSERT().
1452 @param List A pointer to the head node of a doubly linked list.
1453 @param Node A pointer to a node in the doubly linked list.
1455 @retval TRUE Node is the last node in the linked list.
1456 @retval FALSE Node is not the last node in the linked list.
1462 IN CONST LIST_ENTRY
*List
,
1463 IN CONST LIST_ENTRY
*Node
1468 Swaps the location of two nodes in a doubly linked list, and returns the
1469 first node after the swap.
1471 If FirstEntry is identical to SecondEntry, then SecondEntry is returned.
1472 Otherwise, the location of the FirstEntry node is swapped with the location
1473 of the SecondEntry node in a doubly linked list. SecondEntry must be in the
1474 same double linked list as FirstEntry and that double linked list must have
1475 been initialized with INTIALIZE_LIST_HEAD_VARIABLE() or InitializeListHead().
1476 SecondEntry is returned after the nodes are swapped.
1478 If FirstEntry is NULL, then ASSERT().
1479 If SecondEntry is NULL, then ASSERT().
1480 If SecondEntry and FirstEntry are not in the same linked list, then ASSERT().
1481 If PcdMaximumLinkedListLength is not zero, and the number of nodes in the
1482 linked list containing the FirstEntry and SecondEntry nodes, including
1483 the FirstEntry and SecondEntry nodes, is greater than or equal to
1484 PcdMaximumLinkedListLength, then ASSERT().
1486 @param FirstEntry A pointer to a node in a linked list.
1487 @param SecondEntry A pointer to another node in the same linked list.
1489 @return SecondEntry.
1495 IN OUT LIST_ENTRY
*FirstEntry
,
1496 IN OUT LIST_ENTRY
*SecondEntry
1501 Removes a node from a doubly linked list, and returns the node that follows
1504 Removes the node Entry from a doubly linked list. It is up to the caller of
1505 this function to release the memory used by this node if that is required. On
1506 exit, the node following Entry in the doubly linked list is returned. If
1507 Entry is the only node in the linked list, then the head node of the linked
1510 If Entry is NULL, then ASSERT().
1511 If Entry is the head node of an empty list, then ASSERT().
1512 If PcdMaximumLinkedListLength is not zero, and the number of nodes in the
1513 linked list containing Entry, including the Entry node, is greater than
1514 or equal to PcdMaximumLinkedListLength, then ASSERT().
1516 @param Entry A pointer to a node in a linked list.
1524 IN CONST LIST_ENTRY
*Entry
1532 Shifts a 64-bit integer left between 0 and 63 bits. The low bits are filled
1533 with zeros. The shifted value is returned.
1535 This function shifts the 64-bit value Operand to the left by Count bits. The
1536 low Count bits are set to zero. The shifted value is returned.
1538 If Count is greater than 63, then ASSERT().
1540 @param Operand The 64-bit operand to shift left.
1541 @param Count The number of bits to shift left.
1543 @return Operand << Count.
1555 Shifts a 64-bit integer right between 0 and 63 bits. This high bits are
1556 filled with zeros. The shifted value is returned.
1558 This function shifts the 64-bit value Operand to the right by Count bits. The
1559 high Count bits are set to zero. The shifted value is returned.
1561 If Count is greater than 63, then ASSERT().
1563 @param Operand The 64-bit operand to shift right.
1564 @param Count The number of bits to shift right.
1566 @return Operand >> Count
1578 Shifts a 64-bit integer right between 0 and 63 bits. The high bits are filled
1579 with original integer's bit 63. The shifted value is returned.
1581 This function shifts the 64-bit value Operand to the right by Count bits. The
1582 high Count bits are set to bit 63 of Operand. The shifted value is returned.
1584 If Count is greater than 63, then ASSERT().
1586 @param Operand The 64-bit operand to shift right.
1587 @param Count The number of bits to shift right.
1589 @return Operand >> Count
1601 Rotates a 32-bit integer left between 0 and 31 bits, filling the low bits
1602 with the high bits that were rotated.
1604 This function rotates the 32-bit value Operand to the left by Count bits. The
1605 low Count bits are fill with the high Count bits of Operand. The rotated
1608 If Count is greater than 31, then ASSERT().
1610 @param Operand The 32-bit operand to rotate left.
1611 @param Count The number of bits to rotate left.
1613 @return Operand << Count
1625 Rotates a 32-bit integer right between 0 and 31 bits, filling the high bits
1626 with the low bits that were rotated.
1628 This function rotates the 32-bit value Operand to the right by Count bits.
1629 The high Count bits are fill with the low Count bits of Operand. The rotated
1632 If Count is greater than 31, then ASSERT().
1634 @param Operand The 32-bit operand to rotate right.
1635 @param Count The number of bits to rotate right.
1637 @return Operand >> Count
1649 Rotates a 64-bit integer left between 0 and 63 bits, filling the low bits
1650 with the high bits that were rotated.
1652 This function rotates the 64-bit value Operand to the left by Count bits. The
1653 low Count bits are fill with the high Count bits of Operand. The rotated
1656 If Count is greater than 63, then ASSERT().
1658 @param Operand The 64-bit operand to rotate left.
1659 @param Count The number of bits to rotate left.
1661 @return Operand << Count
1673 Rotates a 64-bit integer right between 0 and 63 bits, filling the high bits
1674 with the high low bits that were rotated.
1676 This function rotates the 64-bit value Operand to the right by Count bits.
1677 The high Count bits are fill with the low Count bits of Operand. The rotated
1680 If Count is greater than 63, then ASSERT().
1682 @param Operand The 64-bit operand to rotate right.
1683 @param Count The number of bits to rotate right.
1685 @return Operand >> Count
1697 Returns the bit position of the lowest bit set in a 32-bit value.
1699 This function computes the bit position of the lowest bit set in the 32-bit
1700 value specified by Operand. If Operand is zero, then -1 is returned.
1701 Otherwise, a value between 0 and 31 is returned.
1703 @param Operand The 32-bit operand to evaluate.
1705 @retval 0..31 The lowest bit set in Operand was found.
1706 @retval -1 Operand is zero.
1717 Returns the bit position of the lowest bit set in a 64-bit value.
1719 This function computes the bit position of the lowest bit set in the 64-bit
1720 value specified by Operand. If Operand is zero, then -1 is returned.
1721 Otherwise, a value between 0 and 63 is returned.
1723 @param Operand The 64-bit operand to evaluate.
1725 @retval 0..63 The lowest bit set in Operand was found.
1726 @retval -1 Operand is zero.
1738 Returns the bit position of the highest bit set in a 32-bit value. Equivalent
1741 This function computes the bit position of the highest bit set in the 32-bit
1742 value specified by Operand. If Operand is zero, then -1 is returned.
1743 Otherwise, a value between 0 and 31 is returned.
1745 @param Operand The 32-bit operand to evaluate.
1747 @retval 0..31 Position of the highest bit set in Operand if found.
1748 @retval -1 Operand is zero.
1759 Returns the bit position of the highest bit set in a 64-bit value. Equivalent
1762 This function computes the bit position of the highest bit set in the 64-bit
1763 value specified by Operand. If Operand is zero, then -1 is returned.
1764 Otherwise, a value between 0 and 63 is returned.
1766 @param Operand The 64-bit operand to evaluate.
1768 @retval 0..63 Position of the highest bit set in Operand if found.
1769 @retval -1 Operand is zero.
1780 Returns the value of the highest bit set in a 32-bit value. Equivalent to
1783 This function computes the value of the highest bit set in the 32-bit value
1784 specified by Operand. If Operand is zero, then zero is returned.
1786 @param Operand The 32-bit operand to evaluate.
1788 @return 1 << HighBitSet32(Operand)
1789 @retval 0 Operand is zero.
1800 Returns the value of the highest bit set in a 64-bit value. Equivalent to
1803 This function computes the value of the highest bit set in the 64-bit value
1804 specified by Operand. If Operand is zero, then zero is returned.
1806 @param Operand The 64-bit operand to evaluate.
1808 @return 1 << HighBitSet64(Operand)
1809 @retval 0 Operand is zero.
1820 Switches the endianess of a 16-bit integer.
1822 This function swaps the bytes in a 16-bit unsigned value to switch the value
1823 from little endian to big endian or vice versa. The byte swapped value is
1826 @param Value A 16-bit unsigned value.
1828 @return The byte swapped Value.
1839 Switches the endianess of a 32-bit integer.
1841 This function swaps the bytes in a 32-bit unsigned value to switch the value
1842 from little endian to big endian or vice versa. The byte swapped value is
1845 @param Value A 32-bit unsigned value.
1847 @return The byte swapped Value.
1858 Switches the endianess of a 64-bit integer.
1860 This function swaps the bytes in a 64-bit unsigned value to switch the value
1861 from little endian to big endian or vice versa. The byte swapped value is
1864 @param Value A 64-bit unsigned value.
1866 @return The byte swapped Value.
1877 Multiples a 64-bit unsigned integer by a 32-bit unsigned integer and
1878 generates a 64-bit unsigned result.
1880 This function multiples the 64-bit unsigned value Multiplicand by the 32-bit
1881 unsigned value Multiplier and generates a 64-bit unsigned result. This 64-
1882 bit unsigned result is returned.
1884 @param Multiplicand A 64-bit unsigned value.
1885 @param Multiplier A 32-bit unsigned value.
1887 @return Multiplicand * Multiplier
1893 IN UINT64 Multiplicand
,
1894 IN UINT32 Multiplier
1899 Multiples a 64-bit unsigned integer by a 64-bit unsigned integer and
1900 generates a 64-bit unsigned result.
1902 This function multiples the 64-bit unsigned value Multiplicand by the 64-bit
1903 unsigned value Multiplier and generates a 64-bit unsigned result. This 64-
1904 bit unsigned result is returned.
1906 @param Multiplicand A 64-bit unsigned value.
1907 @param Multiplier A 64-bit unsigned value.
1909 @return Multiplicand * Multiplier
1915 IN UINT64 Multiplicand
,
1916 IN UINT64 Multiplier
1921 Multiples a 64-bit signed integer by a 64-bit signed integer and generates a
1922 64-bit signed result.
1924 This function multiples the 64-bit signed value Multiplicand by the 64-bit
1925 signed value Multiplier and generates a 64-bit signed result. This 64-bit
1926 signed result is returned.
1928 @param Multiplicand A 64-bit signed value.
1929 @param Multiplier A 64-bit signed value.
1931 @return Multiplicand * Multiplier
1937 IN INT64 Multiplicand
,
1943 Divides a 64-bit unsigned integer by a 32-bit unsigned integer and generates
1944 a 64-bit unsigned result.
1946 This function divides the 64-bit unsigned value Dividend by the 32-bit
1947 unsigned value Divisor and generates a 64-bit unsigned quotient. This
1948 function returns the 64-bit unsigned quotient.
1950 If Divisor is 0, then ASSERT().
1952 @param Dividend A 64-bit unsigned value.
1953 @param Divisor A 32-bit unsigned value.
1955 @return Dividend / Divisor
1967 Divides a 64-bit unsigned integer by a 32-bit unsigned integer and generates
1968 a 32-bit unsigned remainder.
1970 This function divides the 64-bit unsigned value Dividend by the 32-bit
1971 unsigned value Divisor and generates a 32-bit remainder. This function
1972 returns the 32-bit unsigned remainder.
1974 If Divisor is 0, then ASSERT().
1976 @param Dividend A 64-bit unsigned value.
1977 @param Divisor A 32-bit unsigned value.
1979 @return Dividend % Divisor
1991 Divides a 64-bit unsigned integer by a 32-bit unsigned integer and generates
1992 a 64-bit unsigned result and an optional 32-bit unsigned remainder.
1994 This function divides the 64-bit unsigned value Dividend by the 32-bit
1995 unsigned value Divisor and generates a 64-bit unsigned quotient. If Remainder
1996 is not NULL, then the 32-bit unsigned remainder is returned in Remainder.
1997 This function returns the 64-bit unsigned quotient.
1999 If Divisor is 0, then ASSERT().
2001 @param Dividend A 64-bit unsigned value.
2002 @param Divisor A 32-bit unsigned value.
2003 @param Remainder A pointer to a 32-bit unsigned value. This parameter is
2004 optional and may be NULL.
2006 @return Dividend / Divisor
2011 DivU64x32Remainder (
2014 OUT UINT32
*Remainder OPTIONAL
2019 Divides a 64-bit unsigned integer by a 64-bit unsigned integer and generates
2020 a 64-bit unsigned result and an optional 64-bit unsigned remainder.
2022 This function divides the 64-bit unsigned value Dividend by the 64-bit
2023 unsigned value Divisor and generates a 64-bit unsigned quotient. If Remainder
2024 is not NULL, then the 64-bit unsigned remainder is returned in Remainder.
2025 This function returns the 64-bit unsigned quotient.
2027 If Divisor is 0, then ASSERT().
2029 @param Dividend A 64-bit unsigned value.
2030 @param Divisor A 64-bit unsigned value.
2031 @param Remainder A pointer to a 64-bit unsigned value. This parameter is
2032 optional and may be NULL.
2034 @return Dividend / Divisor
2039 DivU64x64Remainder (
2042 OUT UINT64
*Remainder OPTIONAL
2047 Divides a 64-bit signed integer by a 64-bit signed integer and generates a
2048 64-bit signed result and a optional 64-bit signed remainder.
2050 This function divides the 64-bit signed value Dividend by the 64-bit signed
2051 value Divisor and generates a 64-bit signed quotient. If Remainder is not
2052 NULL, then the 64-bit signed remainder is returned in Remainder. This
2053 function returns the 64-bit signed quotient.
2055 It is the caller's responsibility to not call this function with a Divisor of 0.
2056 If Divisor is 0, then the quotient and remainder should be assumed to be
2057 the largest negative integer.
2059 If Divisor is 0, then ASSERT().
2061 @param Dividend A 64-bit signed value.
2062 @param Divisor A 64-bit signed value.
2063 @param Remainder A pointer to a 64-bit signed value. This parameter is
2064 optional and may be NULL.
2066 @return Dividend / Divisor
2071 DivS64x64Remainder (
2074 OUT INT64
*Remainder OPTIONAL
2079 Reads a 16-bit value from memory that may be unaligned.
2081 This function returns the 16-bit value pointed to by Buffer. The function
2082 guarantees that the read operation does not produce an alignment fault.
2084 If the Buffer is NULL, then ASSERT().
2086 @param Buffer Pointer to a 16-bit value that may be unaligned.
2088 @return The 16-bit value read from Buffer.
2094 IN CONST UINT16
*Buffer
2099 Writes a 16-bit value to memory that may be unaligned.
2101 This function writes the 16-bit value specified by Value to Buffer. Value is
2102 returned. The function guarantees that the write operation does not produce
2105 If the Buffer is NULL, then ASSERT().
2107 @param Buffer Pointer to a 16-bit value that may be unaligned.
2108 @param Value 16-bit value to write to Buffer.
2110 @return The 16-bit value to write to Buffer.
2122 Reads a 24-bit value from memory that may be unaligned.
2124 This function returns the 24-bit value pointed to by Buffer. The function
2125 guarantees that the read operation does not produce an alignment fault.
2127 If the Buffer is NULL, then ASSERT().
2129 @param Buffer Pointer to a 24-bit value that may be unaligned.
2131 @return The 24-bit value read from Buffer.
2137 IN CONST UINT32
*Buffer
2142 Writes a 24-bit value to memory that may be unaligned.
2144 This function writes the 24-bit value specified by Value to Buffer. Value is
2145 returned. The function guarantees that the write operation does not produce
2148 If the Buffer is NULL, then ASSERT().
2150 @param Buffer Pointer to a 24-bit value that may be unaligned.
2151 @param Value 24-bit value to write to Buffer.
2153 @return The 24-bit value to write to Buffer.
2165 Reads a 32-bit value from memory that may be unaligned.
2167 This function returns the 32-bit value pointed to by Buffer. The function
2168 guarantees that the read operation does not produce an alignment fault.
2170 If the Buffer is NULL, then ASSERT().
2172 @param Buffer Pointer to a 32-bit value that may be unaligned.
2174 @return The 32-bit value read from Buffer.
2180 IN CONST UINT32
*Buffer
2185 Writes a 32-bit value to memory that may be unaligned.
2187 This function writes the 32-bit value specified by Value to Buffer. Value is
2188 returned. The function guarantees that the write operation does not produce
2191 If the Buffer is NULL, then ASSERT().
2193 @param Buffer Pointer to a 32-bit value that may be unaligned.
2194 @param Value 32-bit value to write to Buffer.
2196 @return The 32-bit value to write to Buffer.
2208 Reads a 64-bit value from memory that may be unaligned.
2210 This function returns the 64-bit value pointed to by Buffer. The function
2211 guarantees that the read operation does not produce an alignment fault.
2213 If the Buffer is NULL, then ASSERT().
2215 @param Buffer Pointer to a 64-bit value that may be unaligned.
2217 @return The 64-bit value read from Buffer.
2223 IN CONST UINT64
*Buffer
2228 Writes a 64-bit value to memory that may be unaligned.
2230 This function writes the 64-bit value specified by Value to Buffer. Value is
2231 returned. The function guarantees that the write operation does not produce
2234 If the Buffer is NULL, then ASSERT().
2236 @param Buffer Pointer to a 64-bit value that may be unaligned.
2237 @param Value 64-bit value to write to Buffer.
2239 @return The 64-bit value to write to Buffer.
2251 // Bit Field Functions
2255 Returns a bit field from an 8-bit value.
2257 Returns the bitfield specified by the StartBit and the EndBit from Operand.
2259 If 8-bit operations are not supported, then ASSERT().
2260 If StartBit is greater than 7, then ASSERT().
2261 If EndBit is greater than 7, then ASSERT().
2262 If EndBit is less than StartBit, then ASSERT().
2264 @param Operand Operand on which to perform the bitfield operation.
2265 @param StartBit The ordinal of the least significant bit in the bit field.
2267 @param EndBit The ordinal of the most significant bit in the bit field.
2270 @return The bit field read.
2283 Writes a bit field to an 8-bit value, and returns the result.
2285 Writes Value to the bit field specified by the StartBit and the EndBit in
2286 Operand. All other bits in Operand are preserved. The new 8-bit value is
2289 If 8-bit operations are not supported, then ASSERT().
2290 If StartBit is greater than 7, then ASSERT().
2291 If EndBit is greater than 7, then ASSERT().
2292 If EndBit is less than StartBit, then ASSERT().
2294 @param Operand Operand on which to perform the bitfield operation.
2295 @param StartBit The ordinal of the least significant bit in the bit field.
2297 @param EndBit The ordinal of the most significant bit in the bit field.
2299 @param Value New value of the bit field.
2301 @return The new 8-bit value.
2315 Reads a bit field from an 8-bit value, performs a bitwise OR, and returns the
2318 Performs a bitwise OR between the bit field specified by StartBit
2319 and EndBit in Operand and the value specified by OrData. All other bits in
2320 Operand are preserved. The new 8-bit value is returned.
2322 If 8-bit operations are not supported, then ASSERT().
2323 If StartBit is greater than 7, then ASSERT().
2324 If EndBit is greater than 7, then ASSERT().
2325 If EndBit is less than StartBit, then ASSERT().
2327 @param Operand Operand on which to perform the bitfield operation.
2328 @param StartBit The ordinal of the least significant bit in the bit field.
2330 @param EndBit The ordinal of the most significant bit in the bit field.
2332 @param OrData The value to OR with the read value from the value
2334 @return The new 8-bit value.
2348 Reads a bit field from an 8-bit value, performs a bitwise AND, and returns
2351 Performs a bitwise AND between the bit field specified by StartBit and EndBit
2352 in Operand and the value specified by AndData. All other bits in Operand are
2353 preserved. The new 8-bit value is returned.
2355 If 8-bit operations are not supported, then ASSERT().
2356 If StartBit is greater than 7, then ASSERT().
2357 If EndBit is greater than 7, then ASSERT().
2358 If EndBit is less than StartBit, then ASSERT().
2360 @param Operand Operand on which to perform the bitfield operation.
2361 @param StartBit The ordinal of the least significant bit in the bit field.
2363 @param EndBit The ordinal of the most significant bit in the bit field.
2365 @param AndData The value to AND with the read value from the value.
2367 @return The new 8-bit value.
2381 Reads a bit field from an 8-bit value, performs a bitwise AND followed by a
2382 bitwise OR, and returns the result.
2384 Performs a bitwise AND between the bit field specified by StartBit and EndBit
2385 in Operand and the value specified by AndData, followed by a bitwise
2386 OR with value specified by OrData. All other bits in Operand are
2387 preserved. The new 8-bit value is returned.
2389 If 8-bit operations are not supported, then ASSERT().
2390 If StartBit is greater than 7, then ASSERT().
2391 If EndBit is greater than 7, then ASSERT().
2392 If EndBit is less than StartBit, then ASSERT().
2394 @param Operand Operand on which to perform the bitfield operation.
2395 @param StartBit The ordinal of the least significant bit in the bit field.
2397 @param EndBit The ordinal of the most significant bit in the bit field.
2399 @param AndData The value to AND with the read value from the value.
2400 @param OrData The value to OR with the result of the AND operation.
2402 @return The new 8-bit value.
2407 BitFieldAndThenOr8 (
2417 Returns a bit field from a 16-bit value.
2419 Returns the bitfield specified by the StartBit and the EndBit from Operand.
2421 If 16-bit operations are not supported, then ASSERT().
2422 If StartBit is greater than 15, then ASSERT().
2423 If EndBit is greater than 15, then ASSERT().
2424 If EndBit is less than StartBit, then ASSERT().
2426 @param Operand Operand on which to perform the bitfield operation.
2427 @param StartBit The ordinal of the least significant bit in the bit field.
2429 @param EndBit The ordinal of the most significant bit in the bit field.
2432 @return The bit field read.
2445 Writes a bit field to a 16-bit value, and returns the result.
2447 Writes Value to the bit field specified by the StartBit and the EndBit in
2448 Operand. All other bits in Operand are preserved. The new 16-bit value is
2451 If 16-bit operations are not supported, then ASSERT().
2452 If StartBit is greater than 15, then ASSERT().
2453 If EndBit is greater than 15, then ASSERT().
2454 If EndBit is less than StartBit, then ASSERT().
2456 @param Operand Operand on which to perform the bitfield operation.
2457 @param StartBit The ordinal of the least significant bit in the bit field.
2459 @param EndBit The ordinal of the most significant bit in the bit field.
2461 @param Value New value of the bit field.
2463 @return The new 16-bit value.
2477 Reads a bit field from a 16-bit value, performs a bitwise OR, and returns the
2480 Performs a bitwise OR between the bit field specified by StartBit
2481 and EndBit in Operand and the value specified by OrData. All other bits in
2482 Operand are preserved. The new 16-bit value is returned.
2484 If 16-bit operations are not supported, then ASSERT().
2485 If StartBit is greater than 15, then ASSERT().
2486 If EndBit is greater than 15, then ASSERT().
2487 If EndBit is less than StartBit, then ASSERT().
2489 @param Operand Operand on which to perform the bitfield operation.
2490 @param StartBit The ordinal of the least significant bit in the bit field.
2492 @param EndBit The ordinal of the most significant bit in the bit field.
2494 @param OrData The value to OR with the read value from the value
2496 @return The new 16-bit value.
2510 Reads a bit field from a 16-bit value, performs a bitwise AND, and returns
2513 Performs a bitwise AND between the bit field specified by StartBit and EndBit
2514 in Operand and the value specified by AndData. All other bits in Operand are
2515 preserved. The new 16-bit value is returned.
2517 If 16-bit operations are not supported, then ASSERT().
2518 If StartBit is greater than 15, then ASSERT().
2519 If EndBit is greater than 15, then ASSERT().
2520 If EndBit is less than StartBit, then ASSERT().
2522 @param Operand Operand on which to perform the bitfield operation.
2523 @param StartBit The ordinal of the least significant bit in the bit field.
2525 @param EndBit The ordinal of the most significant bit in the bit field.
2527 @param AndData The value to AND with the read value from the value
2529 @return The new 16-bit value.
2543 Reads a bit field from a 16-bit value, performs a bitwise AND followed by a
2544 bitwise OR, and returns the result.
2546 Performs a bitwise AND between the bit field specified by StartBit and EndBit
2547 in Operand and the value specified by AndData, followed by a bitwise
2548 OR with value specified by OrData. All other bits in Operand are
2549 preserved. The new 16-bit value is returned.
2551 If 16-bit operations are not supported, then ASSERT().
2552 If StartBit is greater than 15, then ASSERT().
2553 If EndBit is greater than 15, then ASSERT().
2554 If EndBit is less than StartBit, then ASSERT().
2556 @param Operand Operand on which to perform the bitfield operation.
2557 @param StartBit The ordinal of the least significant bit in the bit field.
2559 @param EndBit The ordinal of the most significant bit in the bit field.
2561 @param AndData The value to AND with the read value from the value.
2562 @param OrData The value to OR with the result of the AND operation.
2564 @return The new 16-bit value.
2569 BitFieldAndThenOr16 (
2579 Returns a bit field from a 32-bit value.
2581 Returns the bitfield specified by the StartBit and the EndBit from Operand.
2583 If 32-bit operations are not supported, then ASSERT().
2584 If StartBit is greater than 31, then ASSERT().
2585 If EndBit is greater than 31, then ASSERT().
2586 If EndBit is less than StartBit, then ASSERT().
2588 @param Operand Operand on which to perform the bitfield operation.
2589 @param StartBit The ordinal of the least significant bit in the bit field.
2591 @param EndBit The ordinal of the most significant bit in the bit field.
2594 @return The bit field read.
2607 Writes a bit field to a 32-bit value, and returns the result.
2609 Writes Value to the bit field specified by the StartBit and the EndBit in
2610 Operand. All other bits in Operand are preserved. The new 32-bit value is
2613 If 32-bit operations are not supported, then ASSERT().
2614 If StartBit is greater than 31, then ASSERT().
2615 If EndBit is greater than 31, then ASSERT().
2616 If EndBit is less than StartBit, then ASSERT().
2618 @param Operand Operand on which to perform the bitfield operation.
2619 @param StartBit The ordinal of the least significant bit in the bit field.
2621 @param EndBit The ordinal of the most significant bit in the bit field.
2623 @param Value New value of the bit field.
2625 @return The new 32-bit value.
2639 Reads a bit field from a 32-bit value, performs a bitwise OR, and returns the
2642 Performs a bitwise OR between the bit field specified by StartBit
2643 and EndBit in Operand and the value specified by OrData. All other bits in
2644 Operand are preserved. The new 32-bit value is returned.
2646 If 32-bit operations are not supported, then ASSERT().
2647 If StartBit is greater than 31, then ASSERT().
2648 If EndBit is greater than 31, then ASSERT().
2649 If EndBit is less than StartBit, then ASSERT().
2651 @param Operand Operand on which to perform the bitfield operation.
2652 @param StartBit The ordinal of the least significant bit in the bit field.
2654 @param EndBit The ordinal of the most significant bit in the bit field.
2656 @param OrData The value to OR with the read value from the value
2658 @return The new 32-bit value.
2672 Reads a bit field from a 32-bit value, performs a bitwise AND, and returns
2675 Performs a bitwise AND between the bit field specified by StartBit and EndBit
2676 in Operand and the value specified by AndData. All other bits in Operand are
2677 preserved. The new 32-bit value is returned.
2679 If 32-bit operations are not supported, then ASSERT().
2680 If StartBit is greater than 31, then ASSERT().
2681 If EndBit is greater than 31, then ASSERT().
2682 If EndBit is less than StartBit, then ASSERT().
2684 @param Operand Operand on which to perform the bitfield operation.
2685 @param StartBit The ordinal of the least significant bit in the bit field.
2687 @param EndBit The ordinal of the most significant bit in the bit field.
2689 @param AndData The value to AND with the read value from the value
2691 @return The new 32-bit value.
2705 Reads a bit field from a 32-bit value, performs a bitwise AND followed by a
2706 bitwise OR, and returns the result.
2708 Performs a bitwise AND between the bit field specified by StartBit and EndBit
2709 in Operand and the value specified by AndData, followed by a bitwise
2710 OR with value specified by OrData. All other bits in Operand are
2711 preserved. The new 32-bit value is returned.
2713 If 32-bit operations are not supported, then ASSERT().
2714 If StartBit is greater than 31, then ASSERT().
2715 If EndBit is greater than 31, then ASSERT().
2716 If EndBit is less than StartBit, then ASSERT().
2718 @param Operand Operand on which to perform the bitfield operation.
2719 @param StartBit The ordinal of the least significant bit in the bit field.
2721 @param EndBit The ordinal of the most significant bit in the bit field.
2723 @param AndData The value to AND with the read value from the value.
2724 @param OrData The value to OR with the result of the AND operation.
2726 @return The new 32-bit value.
2731 BitFieldAndThenOr32 (
2741 Returns a bit field from a 64-bit value.
2743 Returns the bitfield specified by the StartBit and the EndBit from Operand.
2745 If 64-bit operations are not supported, then ASSERT().
2746 If StartBit is greater than 63, then ASSERT().
2747 If EndBit is greater than 63, then ASSERT().
2748 If EndBit is less than StartBit, then ASSERT().
2750 @param Operand Operand on which to perform the bitfield operation.
2751 @param StartBit The ordinal of the least significant bit in the bit field.
2753 @param EndBit The ordinal of the most significant bit in the bit field.
2756 @return The bit field read.
2769 Writes a bit field to a 64-bit value, and returns the result.
2771 Writes Value to the bit field specified by the StartBit and the EndBit in
2772 Operand. All other bits in Operand are preserved. The new 64-bit value is
2775 If 64-bit operations are not supported, then ASSERT().
2776 If StartBit is greater than 63, then ASSERT().
2777 If EndBit is greater than 63, then ASSERT().
2778 If EndBit is less than StartBit, then ASSERT().
2780 @param Operand Operand on which to perform the bitfield operation.
2781 @param StartBit The ordinal of the least significant bit in the bit field.
2783 @param EndBit The ordinal of the most significant bit in the bit field.
2785 @param Value New value of the bit field.
2787 @return The new 64-bit value.
2801 Reads a bit field from a 64-bit value, performs a bitwise OR, and returns the
2804 Performs a bitwise OR between the bit field specified by StartBit
2805 and EndBit in Operand and the value specified by OrData. All other bits in
2806 Operand are preserved. The new 64-bit value is returned.
2808 If 64-bit operations are not supported, then ASSERT().
2809 If StartBit is greater than 63, then ASSERT().
2810 If EndBit is greater than 63, then ASSERT().
2811 If EndBit is less than StartBit, then ASSERT().
2813 @param Operand Operand on which to perform the bitfield operation.
2814 @param StartBit The ordinal of the least significant bit in the bit field.
2816 @param EndBit The ordinal of the most significant bit in the bit field.
2818 @param OrData The value to OR with the read value from the value
2820 @return The new 64-bit value.
2834 Reads a bit field from a 64-bit value, performs a bitwise AND, and returns
2837 Performs a bitwise AND between the bit field specified by StartBit and EndBit
2838 in Operand and the value specified by AndData. All other bits in Operand are
2839 preserved. The new 64-bit value is returned.
2841 If 64-bit operations are not supported, then ASSERT().
2842 If StartBit is greater than 63, then ASSERT().
2843 If EndBit is greater than 63, then ASSERT().
2844 If EndBit is less than StartBit, then ASSERT().
2846 @param Operand Operand on which to perform the bitfield operation.
2847 @param StartBit The ordinal of the least significant bit in the bit field.
2849 @param EndBit The ordinal of the most significant bit in the bit field.
2851 @param AndData The value to AND with the read value from the value
2853 @return The new 64-bit value.
2867 Reads a bit field from a 64-bit value, performs a bitwise AND followed by a
2868 bitwise OR, and returns the result.
2870 Performs a bitwise AND between the bit field specified by StartBit and EndBit
2871 in Operand and the value specified by AndData, followed by a bitwise
2872 OR with value specified by OrData. All other bits in Operand are
2873 preserved. The new 64-bit value is returned.
2875 If 64-bit operations are not supported, then ASSERT().
2876 If StartBit is greater than 63, then ASSERT().
2877 If EndBit is greater than 63, then ASSERT().
2878 If EndBit is less than StartBit, then ASSERT().
2880 @param Operand Operand on which to perform the bitfield operation.
2881 @param StartBit The ordinal of the least significant bit in the bit field.
2883 @param EndBit The ordinal of the most significant bit in the bit field.
2885 @param AndData The value to AND with the read value from the value.
2886 @param OrData The value to OR with the result of the AND operation.
2888 @return The new 64-bit value.
2893 BitFieldAndThenOr64 (
2902 // Base Library Checksum Functions
2906 Returns the sum of all elements in a buffer in unit of UINT8.
2907 During calculation, the carry bits are dropped.
2909 This function calculates the sum of all elements in a buffer
2910 in unit of UINT8. The carry bits in result of addition are dropped.
2911 The result is returned as UINT8. If Length is Zero, then Zero is
2914 If Buffer is NULL, then ASSERT().
2915 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
2917 @param Buffer Pointer to the buffer to carry out the sum operation.
2918 @param Length The size, in bytes, of Buffer.
2920 @return Sum The sum of Buffer with carry bits dropped during additions.
2926 IN CONST UINT8
*Buffer
,
2932 Returns the two's complement checksum of all elements in a buffer
2935 This function first calculates the sum of the 8-bit values in the
2936 buffer specified by Buffer and Length. The carry bits in the result
2937 of addition are dropped. Then, the two's complement of the sum is
2938 returned. If Length is 0, then 0 is returned.
2940 If Buffer is NULL, then ASSERT().
2941 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
2943 @param Buffer Pointer to the buffer to carry out the checksum operation.
2944 @param Length The size, in bytes, of Buffer.
2946 @return Checksum The 2's complement checksum of Buffer.
2951 CalculateCheckSum8 (
2952 IN CONST UINT8
*Buffer
,
2958 Returns the sum of all elements in a buffer of 16-bit values. During
2959 calculation, the carry bits are dropped.
2961 This function calculates the sum of the 16-bit values in the buffer
2962 specified by Buffer and Length. The carry bits in result of addition are dropped.
2963 The 16-bit result is returned. If Length is 0, then 0 is returned.
2965 If Buffer is NULL, then ASSERT().
2966 If Buffer is not aligned on a 16-bit boundary, then ASSERT().
2967 If Length is not aligned on a 16-bit boundary, then ASSERT().
2968 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
2970 @param Buffer 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 UINT16
*Buffer
,
2985 Returns the two's complement checksum of all elements in a buffer of
2988 This function first calculates the sum of the 16-bit values in the buffer
2989 specified by Buffer and Length. The carry bits in the result of addition
2990 are dropped. Then, the two's complement of the sum is returned. If Length
2991 is 0, then 0 is returned.
2993 If Buffer is NULL, then ASSERT().
2994 If Buffer is not aligned on a 16-bit boundary, then ASSERT().
2995 If Length is not aligned on a 16-bit boundary, then ASSERT().
2996 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
2998 @param Buffer Pointer to the buffer to carry out the checksum operation.
2999 @param Length The size, in bytes, of Buffer.
3001 @return Checksum The 2's complement checksum of Buffer.
3006 CalculateCheckSum16 (
3007 IN CONST UINT16
*Buffer
,
3013 Returns the sum of all elements in a buffer of 32-bit values. During
3014 calculation, the carry bits are dropped.
3016 This function calculates the sum of the 32-bit values in the buffer
3017 specified by Buffer and Length. The carry bits in result of addition are dropped.
3018 The 32-bit result is returned. If Length is 0, then 0 is returned.
3020 If Buffer is NULL, then ASSERT().
3021 If Buffer is not aligned on a 32-bit boundary, then ASSERT().
3022 If Length is not aligned on a 32-bit boundary, then ASSERT().
3023 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
3025 @param Buffer Pointer to the buffer to carry out the sum operation.
3026 @param Length The size, in bytes, of Buffer.
3028 @return Sum The sum of Buffer with carry bits dropped during additions.
3034 IN CONST UINT32
*Buffer
,
3040 Returns the two's complement checksum of all elements in a buffer of
3043 This function first calculates the sum of the 32-bit values in the buffer
3044 specified by Buffer and Length. The carry bits in the result of addition
3045 are dropped. Then, the two's complement of the sum is returned. If Length
3046 is 0, then 0 is returned.
3048 If Buffer is NULL, then ASSERT().
3049 If Buffer is not aligned on a 32-bit boundary, then ASSERT().
3050 If Length is not aligned on a 32-bit boundary, then ASSERT().
3051 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
3053 @param Buffer Pointer to the buffer to carry out the checksum operation.
3054 @param Length The size, in bytes, of Buffer.
3056 @return Checksum The 2's complement checksum of Buffer.
3061 CalculateCheckSum32 (
3062 IN CONST UINT32
*Buffer
,
3068 Returns the sum of all elements in a buffer of 64-bit values. During
3069 calculation, the carry bits are dropped.
3071 This function calculates the sum of the 64-bit values in the buffer
3072 specified by Buffer and Length. The carry bits in result of addition are dropped.
3073 The 64-bit result is returned. If Length is 0, then 0 is returned.
3075 If Buffer is NULL, then ASSERT().
3076 If Buffer is not aligned on a 64-bit boundary, then ASSERT().
3077 If Length is not aligned on a 64-bit boundary, then ASSERT().
3078 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
3080 @param Buffer Pointer to the buffer to carry out the sum operation.
3081 @param Length The size, in bytes, of Buffer.
3083 @return Sum The sum of Buffer with carry bits dropped during additions.
3089 IN CONST UINT64
*Buffer
,
3095 Returns the two's complement checksum of all elements in a buffer of
3098 This function first calculates the sum of the 64-bit values in the buffer
3099 specified by Buffer and Length. The carry bits in the result of addition
3100 are dropped. Then, the two's complement of the sum is returned. If Length
3101 is 0, then 0 is returned.
3103 If Buffer is NULL, then ASSERT().
3104 If Buffer is not aligned on a 64-bit boundary, then ASSERT().
3105 If Length is not aligned on a 64-bit boundary, then ASSERT().
3106 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
3108 @param Buffer Pointer to the buffer to carry out the checksum operation.
3109 @param Length The size, in bytes, of Buffer.
3111 @return Checksum The 2's complement checksum of Buffer.
3116 CalculateCheckSum64 (
3117 IN CONST UINT64
*Buffer
,
3123 // Base Library CPU Functions
3127 Function entry point used when a stack switch is requested with SwitchStack()
3129 @param Context1 Context1 parameter passed into SwitchStack().
3130 @param Context2 Context2 parameter passed into SwitchStack().
3135 (EFIAPI
*SWITCH_STACK_ENTRY_POINT
)(
3136 IN VOID
*Context1
, OPTIONAL
3137 IN VOID
*Context2 OPTIONAL
3142 Used to serialize load and store operations.
3144 All loads and stores that proceed calls to this function are guaranteed to be
3145 globally visible when this function returns.
3156 Saves the current CPU context that can be restored with a call to LongJump()
3159 Saves the current CPU context in the buffer specified by JumpBuffer and
3160 returns 0. The initial call to SetJump() must always return 0. Subsequent
3161 calls to LongJump() cause a non-zero value to be returned by SetJump().
3163 If JumpBuffer is NULL, then ASSERT().
3164 For Itanium processors, if JumpBuffer is not aligned on a 16-byte boundary, then ASSERT().
3166 NOTE: The structure BASE_LIBRARY_JUMP_BUFFER is CPU architecture specific.
3167 The same structure must never be used for more than one CPU architecture context.
3168 For example, a BASE_LIBRARY_JUMP_BUFFER allocated by an IA-32 module must never be used from an x64 module.
3169 SetJump()/LongJump() is not currently supported for the EBC processor type.
3171 @param JumpBuffer A pointer to CPU context buffer.
3173 @retval 0 Indicates a return from SetJump().
3179 OUT BASE_LIBRARY_JUMP_BUFFER
*JumpBuffer
3184 Restores the CPU context that was saved with SetJump().
3186 Restores the CPU context from the buffer specified by JumpBuffer. This
3187 function never returns to the caller. Instead is resumes execution based on
3188 the state of JumpBuffer.
3190 If JumpBuffer is NULL, then ASSERT().
3191 For Itanium processors, if JumpBuffer is not aligned on a 16-byte boundary, then ASSERT().
3192 If Value is 0, then ASSERT().
3194 @param JumpBuffer A pointer to CPU context buffer.
3195 @param Value The value to return when the SetJump() context is
3196 restored and must be non-zero.
3202 IN BASE_LIBRARY_JUMP_BUFFER
*JumpBuffer
,
3208 Enables CPU interrupts.
3219 Disables CPU interrupts.
3230 Disables CPU interrupts and returns the interrupt state prior to the disable
3233 @retval TRUE CPU interrupts were enabled on entry to this call.
3234 @retval FALSE CPU interrupts were disabled on entry to this call.
3239 SaveAndDisableInterrupts (
3245 Enables CPU interrupts for the smallest window required to capture any
3251 EnableDisableInterrupts (
3257 Retrieves the current CPU interrupt state.
3259 Returns TRUE is interrupts are currently enabled. Otherwise
3262 @retval TRUE CPU interrupts are enabled.
3263 @retval FALSE CPU interrupts are disabled.
3274 Set the current CPU interrupt state.
3276 Sets the current CPU interrupt state to the state specified by
3277 InterruptState. If InterruptState is TRUE, then interrupts are enabled. If
3278 InterruptState is FALSE, then interrupts are disabled. InterruptState is
3281 @param InterruptState TRUE if interrupts should enabled. FALSE if
3282 interrupts should be disabled.
3284 @return InterruptState
3290 IN BOOLEAN InterruptState
3295 Requests CPU to pause for a short period of time.
3297 Requests CPU to pause for a short period of time. Typically used in MP
3298 systems to prevent memory starvation while waiting for a spin lock.
3309 Transfers control to a function starting with a new stack.
3311 Transfers control to the function specified by EntryPoint using the
3312 new stack specified by NewStack and passing in the parameters specified
3313 by Context1 and Context2. Context1 and Context2 are optional and may
3314 be NULL. The function EntryPoint must never return. This function
3315 supports a variable number of arguments following the NewStack parameter.
3316 These additional arguments are ignored on IA-32, x64, and EBC architectures.
3317 Itanium processors expect one additional parameter of type VOID * that specifies
3318 the new backing store pointer.
3320 If EntryPoint is NULL, then ASSERT().
3321 If NewStack is NULL, then ASSERT().
3323 @param EntryPoint A pointer to function to call with the new stack.
3324 @param Context1 A pointer to the context to pass into the EntryPoint
3326 @param Context2 A pointer to the context to pass into the EntryPoint
3328 @param NewStack A pointer to the new stack to use for the EntryPoint
3330 @param ... This variable argument list is ignored for IA-32, x64, and EBC architectures.
3331 For Itanium processors, this variable argument list is expected to contain
3332 a single parameter of type VOID * that specifies the new backing
3340 IN SWITCH_STACK_ENTRY_POINT EntryPoint
,
3341 IN VOID
*Context1
, OPTIONAL
3342 IN VOID
*Context2
, OPTIONAL
3349 Generates a breakpoint on the CPU.
3351 Generates a breakpoint on the CPU. The breakpoint must be implemented such
3352 that code can resume normal execution after the breakpoint.
3363 Executes an infinite loop.
3365 Forces the CPU to execute an infinite loop. A debugger may be used to skip
3366 past the loop and the code that follows the loop must execute properly. This
3367 implies that the infinite loop must not cause the code that follow it to be
3377 #if defined (MDE_CPU_IPF)
3380 Flush a range of cache lines in the cache coherency domain of the calling
3383 Flushes the cache lines specified by Address and Length. If Address is not aligned
3384 on a cache line boundary, then entire cache line containing Address is flushed.
3385 If Address + Length is not aligned on a cache line boundary, then the entire cache
3386 line containing Address + Length - 1 is flushed. This function may choose to flush
3387 the entire cache if that is more efficient than flushing the specified range. If
3388 Length is 0, the no cache lines are flushed. Address is returned.
3389 This function is only available on Itanium processors.
3391 If Length is greater than (MAX_ADDRESS - Address + 1), then ASSERT().
3393 @param Address The base address of the instruction lines to invalidate. If
3394 the CPU is in a physical addressing mode, then Address is a
3395 physical address. If the CPU is in a virtual addressing mode,
3396 then Address is a virtual address.
3398 @param Length The number of bytes to invalidate from the instruction cache.
3405 AsmFlushCacheRange (
3412 Executes a FC instruction
3413 Executes a FC instruction on the cache line specified by Address.
3414 The cache line size affected is at least 32-bytes (aligned on a 32-byte boundary).
3415 An implementation may flush a larger region. This function is only available on Itanium processors.
3417 @param Address The Address of cache line to be flushed.
3419 @return The address of FC instruction executed.
3430 Executes a FC.I instruction.
3431 Executes a FC.I instruction on the cache line specified by Address.
3432 The cache line size affected is at least 32-bytes (aligned on a 32-byte boundary).
3433 An implementation may flush a larger region. This function is only available on Itanium processors.
3435 @param Address The Address of cache line to be flushed.
3437 @return The address of FC.I instruction executed.
3448 Reads the current value of a Processor Identifier Register (CPUID).
3450 Reads and returns the current value of Processor Identifier Register specified by Index.
3451 The Index of largest implemented CPUID (One less than the number of implemented CPUID
3452 registers) is determined by CPUID [3] bits {7:0}.
3453 No parameter checking is performed on Index. If the Index value is beyond the
3454 implemented CPUID register range, a Reserved Register/Field fault may occur. The caller
3455 must either guarantee that Index is valid, or the caller must set up fault handlers to
3456 catch the faults. This function is only available on Itanium processors.
3458 @param Index The 8-bit Processor Identifier Register index to read.
3460 @return The current value of Processor Identifier Register specified by Index.
3471 Reads the current value of 64-bit Processor Status Register (PSR).
3472 This function is only available on Itanium processors.
3474 @return The current value of PSR.
3485 Writes the current value of 64-bit Processor Status Register (PSR).
3487 No parameter checking is performed on Value. All bits of Value corresponding to
3488 reserved fields of PSR must be 0 or a Reserved Register/Field fault may occur.
3489 The caller must either guarantee that Value is valid, or the caller must set up
3490 fault handlers to catch the faults. This function is only available on Itanium processors.
3492 @param Value The 64-bit value to write to PSR.
3494 @return The 64-bit value written to the PSR.
3505 Reads the current value of 64-bit Kernel Register #0 (KR0).
3507 Reads and returns the current value of KR0.
3508 This function is only available on Itanium processors.
3510 @return The current value of KR0.
3521 Reads the current value of 64-bit Kernel Register #1 (KR1).
3523 Reads and returns the current value of KR1.
3524 This function is only available on Itanium processors.
3526 @return The current value of KR1.
3537 Reads the current value of 64-bit Kernel Register #2 (KR2).
3539 Reads and returns the current value of KR2.
3540 This function is only available on Itanium processors.
3542 @return The current value of KR2.
3553 Reads the current value of 64-bit Kernel Register #3 (KR3).
3555 Reads and returns the current value of KR3.
3556 This function is only available on Itanium processors.
3558 @return The current value of KR3.
3569 Reads the current value of 64-bit Kernel Register #4 (KR4).
3571 Reads and returns the current value of KR4.
3572 This function is only available on Itanium processors.
3574 @return The current value of KR4.
3585 Reads the current value of 64-bit Kernel Register #5 (KR5).
3587 Reads and returns the current value of KR5.
3588 This function is only available on Itanium processors.
3590 @return The current value of KR5.
3601 Reads the current value of 64-bit Kernel Register #6 (KR6).
3603 Reads and returns the current value of KR6.
3604 This function is only available on Itanium processors.
3606 @return The current value of KR6.
3617 Reads the current value of 64-bit Kernel Register #7 (KR7).
3619 Reads and returns the current value of KR7.
3620 This function is only available on Itanium processors.
3622 @return The current value of KR7.
3633 Write the current value of 64-bit Kernel Register #0 (KR0).
3635 Writes the current value of KR0. The 64-bit value written to
3636 the KR0 is returned. This function is only available on Itanium processors.
3638 @param Value The 64-bit value to write to KR0.
3640 @return The 64-bit value written to the KR0.
3651 Write the current value of 64-bit Kernel Register #1 (KR1).
3653 Writes the current value of KR1. The 64-bit value written to
3654 the KR1 is returned. This function is only available on Itanium processors.
3656 @param Value The 64-bit value to write to KR1.
3658 @return The 64-bit value written to the KR1.
3669 Write the current value of 64-bit Kernel Register #2 (KR2).
3671 Writes the current value of KR2. The 64-bit value written to
3672 the KR2 is returned. This function is only available on Itanium processors.
3674 @param Value The 64-bit value to write to KR2.
3676 @return The 64-bit value written to the KR2.
3687 Write the current value of 64-bit Kernel Register #3 (KR3).
3689 Writes the current value of KR3. The 64-bit value written to
3690 the KR3 is returned. This function is only available on Itanium processors.
3692 @param Value The 64-bit value to write to KR3.
3694 @return The 64-bit value written to the KR3.
3705 Write the current value of 64-bit Kernel Register #4 (KR4).
3707 Writes the current value of KR4. The 64-bit value written to
3708 the KR4 is returned. This function is only available on Itanium processors.
3710 @param Value The 64-bit value to write to KR4.
3712 @return The 64-bit value written to the KR4.
3723 Write the current value of 64-bit Kernel Register #5 (KR5).
3725 Writes the current value of KR5. The 64-bit value written to
3726 the KR5 is returned. This function is only available on Itanium processors.
3728 @param Value The 64-bit value to write to KR5.
3730 @return The 64-bit value written to the KR5.
3741 Write the current value of 64-bit Kernel Register #6 (KR6).
3743 Writes the current value of KR6. The 64-bit value written to
3744 the KR6 is returned. This function is only available on Itanium processors.
3746 @param Value The 64-bit value to write to KR6.
3748 @return The 64-bit value written to the KR6.
3759 Write the current value of 64-bit Kernel Register #7 (KR7).
3761 Writes the current value of KR7. The 64-bit value written to
3762 the KR7 is returned. This function is only available on Itanium processors.
3764 @param Value The 64-bit value to write to KR7.
3766 @return The 64-bit value written to the KR7.
3777 Reads the current value of Interval Timer Counter Register (ITC).
3779 Reads and returns the current value of ITC.
3780 This function is only available on Itanium processors.
3782 @return The current value of ITC.
3793 Reads the current value of Interval Timer Vector Register (ITV).
3795 Reads and returns the current value of ITV.
3796 This function is only available on Itanium processors.
3798 @return The current value of ITV.
3809 Reads the current value of Interval Timer Match Register (ITM).
3811 Reads and returns the current value of ITM.
3812 This function is only available on Itanium processors.
3814 @return The current value of ITM.
3824 Writes the current value of 64-bit Interval Timer Counter Register (ITC).
3826 Writes the current value of ITC. The 64-bit value written to the ITC is returned.
3827 This function is only available on Itanium processors.
3829 @param Value The 64-bit value to write to ITC.
3831 @return The 64-bit value written to the ITC.
3842 Writes the current value of 64-bit Interval Timer Match Register (ITM).
3844 Writes the current value of ITM. The 64-bit value written to the ITM is returned.
3845 This function is only available on Itanium processors.
3847 @param Value The 64-bit value to write to ITM.
3849 @return The 64-bit value written to the ITM.
3860 Writes the current value of 64-bit Interval Timer Vector Register (ITV).
3862 Writes the current value of ITV. The 64-bit value written to the ITV is returned.
3863 No parameter checking is performed on Value. All bits of Value corresponding to
3864 reserved fields of ITV must be 0 or a Reserved Register/Field fault may occur.
3865 The caller must either guarantee that Value is valid, or the caller must set up
3866 fault handlers to catch the faults.
3867 This function is only available on Itanium processors.
3869 @param Value The 64-bit value to write to ITV.
3871 @return The 64-bit value written to the ITV.
3882 Reads the current value of Default Control Register (DCR).
3884 Reads and returns the current value of DCR. This function is only available on Itanium processors.
3886 @return The current value of DCR.
3897 Reads the current value of Interruption Vector Address Register (IVA).
3899 Reads and returns the current value of IVA. This function is only available on Itanium processors.
3901 @return The current value of IVA.
3911 Reads the current value of Page Table Address Register (PTA).
3913 Reads and returns the current value of PTA. This function is only available on Itanium processors.
3915 @return The current value of PTA.
3926 Writes the current value of 64-bit Default Control Register (DCR).
3928 Writes the current value of DCR. The 64-bit value written to the DCR is returned.
3929 No parameter checking is performed on Value. All bits of Value corresponding to
3930 reserved fields of DCR must be 0 or a Reserved Register/Field fault may occur.
3931 The caller must either guarantee that Value is valid, or the caller must set up
3932 fault handlers to catch the faults.
3933 This function is only available on Itanium processors.
3935 @param Value The 64-bit value to write to DCR.
3937 @return The 64-bit value written to the DCR.
3948 Writes the current value of 64-bit Interruption Vector Address Register (IVA).
3950 Writes the current value of IVA. The 64-bit value written to the IVA is returned.
3951 The size of vector table is 32 K bytes and is 32 K bytes aligned
3952 the low 15 bits of Value is ignored when written.
3953 This function is only available on Itanium processors.
3955 @param Value The 64-bit value to write to IVA.
3957 @return The 64-bit value written to the IVA.
3968 Writes the current value of 64-bit Page Table Address Register (PTA).
3970 Writes the current value of PTA. The 64-bit value written to the PTA is returned.
3971 No parameter checking is performed on Value. All bits of Value corresponding to
3972 reserved fields of DCR must be 0 or a Reserved Register/Field fault may occur.
3973 The caller must either guarantee that Value is valid, or the caller must set up
3974 fault handlers to catch the faults.
3975 This function is only available on Itanium processors.
3977 @param Value The 64-bit value to write to PTA.
3979 @return The 64-bit value written to the PTA.
3989 Reads the current value of Local Interrupt ID Register (LID).
3991 Reads and returns the current value of LID. This function is only available on Itanium processors.
3993 @return The current value of LID.
4004 Reads the current value of External Interrupt Vector Register (IVR).
4006 Reads and returns the current value of IVR. This function is only available on Itanium processors.
4008 @return The current value of IVR.
4019 Reads the current value of Task Priority Register (TPR).
4021 Reads and returns the current value of TPR. This function is only available on Itanium processors.
4023 @return The current value of TPR.
4034 Reads the current value of External Interrupt Request Register #0 (IRR0).
4036 Reads and returns the current value of IRR0. This function is only available on Itanium processors.
4038 @return The current value of IRR0.
4049 Reads the current value of External Interrupt Request Register #1 (IRR1).
4051 Reads and returns the current value of IRR1. This function is only available on Itanium processors.
4053 @return The current value of IRR1.
4064 Reads the current value of External Interrupt Request Register #2 (IRR2).
4066 Reads and returns the current value of IRR2. This function is only available on Itanium processors.
4068 @return The current value of IRR2.
4079 Reads the current value of External Interrupt Request Register #3 (IRR3).
4081 Reads and returns the current value of IRR3. This function is only available on Itanium processors.
4083 @return The current value of IRR3.
4094 Reads the current value of Performance Monitor Vector Register (PMV).
4096 Reads and returns the current value of PMV. This function is only available on Itanium processors.
4098 @return The current value of PMV.
4109 Reads the current value of Corrected Machine Check Vector Register (CMCV).
4111 Reads and returns the current value of CMCV. This function is only available on Itanium processors.
4113 @return The current value of CMCV.
4124 Reads the current value of Local Redirection Register #0 (LRR0).
4126 Reads and returns the current value of LRR0. This function is only available on Itanium processors.
4128 @return The current value of LRR0.
4139 Reads the current value of Local Redirection Register #1 (LRR1).
4141 Reads and returns the current value of LRR1. This function is only available on Itanium processors.
4143 @return The current value of LRR1.
4154 Writes the current value of 64-bit Page Local Interrupt ID Register (LID).
4156 Writes the current value of LID. The 64-bit value written to the LID is returned.
4157 No parameter checking is performed on Value. All bits of Value corresponding to
4158 reserved fields of LID must be 0 or a Reserved Register/Field fault may occur.
4159 The caller must either guarantee that Value is valid, or the caller must set up
4160 fault handlers to catch the faults.
4161 This function is only available on Itanium processors.
4163 @param Value The 64-bit value to write to LID.
4165 @return The 64-bit value written to the LID.
4176 Writes the current value of 64-bit Task Priority Register (TPR).
4178 Writes the current value of TPR. The 64-bit value written to the TPR is returned.
4179 No parameter checking is performed on Value. All bits of Value corresponding to
4180 reserved fields of TPR must be 0 or a Reserved Register/Field fault may occur.
4181 The caller must either guarantee that Value is valid, or the caller must set up
4182 fault handlers to catch the faults.
4183 This function is only available on Itanium processors.
4185 @param Value The 64-bit value to write to TPR.
4187 @return The 64-bit value written to the TPR.
4198 Performs a write operation on End OF External Interrupt Register (EOI).
4200 Writes a value of 0 to the EOI Register. This function is only available on Itanium processors.
4211 Writes the current value of 64-bit Performance Monitor Vector Register (PMV).
4213 Writes the current value of PMV. The 64-bit value written to the PMV is returned.
4214 No parameter checking is performed on Value. All bits of Value corresponding
4215 to reserved fields of PMV must be 0 or a Reserved Register/Field fault may occur.
4216 The caller must either guarantee that Value is valid, or the caller must set up
4217 fault handlers to catch the faults.
4218 This function is only available on Itanium processors.
4220 @param Value The 64-bit value to write to PMV.
4222 @return The 64-bit value written to the PMV.
4233 Writes the current value of 64-bit Corrected Machine Check Vector Register (CMCV).
4235 Writes the current value of CMCV. The 64-bit value written to the CMCV is returned.
4236 No parameter checking is performed on Value. All bits of Value corresponding
4237 to reserved fields of CMCV must be 0 or a Reserved Register/Field fault may occur.
4238 The caller must either guarantee that Value is valid, or the caller must set up
4239 fault handlers to catch the faults.
4240 This function is only available on Itanium processors.
4242 @param Value The 64-bit value to write to CMCV.
4244 @return The 64-bit value written to the CMCV.
4255 Writes the current value of 64-bit Local Redirection Register #0 (LRR0).
4257 Writes the current value of LRR0. The 64-bit value written to the LRR0 is returned.
4258 No parameter checking is performed on Value. All bits of Value corresponding
4259 to reserved fields of LRR0 must be 0 or a Reserved Register/Field fault may occur.
4260 The caller must either guarantee that Value is valid, or the caller must set up
4261 fault handlers to catch the faults.
4262 This function is only available on Itanium processors.
4264 @param Value The 64-bit value to write to LRR0.
4266 @return The 64-bit value written to the LRR0.
4277 Writes the current value of 64-bit Local Redirection Register #1 (LRR1).
4279 Writes the current value of LRR1. The 64-bit value written to the LRR1 is returned.
4280 No parameter checking is performed on Value. All bits of Value corresponding
4281 to reserved fields of LRR1 must be 0 or a Reserved Register/Field fault may occur.
4282 The caller must either guarantee that Value is valid, or the caller must
4283 set up fault handlers to catch the faults.
4284 This function is only available on Itanium processors.
4286 @param Value The 64-bit value to write to LRR1.
4288 @return The 64-bit value written to the LRR1.
4299 Reads the current value of Instruction Breakpoint Register (IBR).
4301 The Instruction Breakpoint Registers are used in pairs. The even numbered
4302 registers contain breakpoint addresses, and the odd numbered registers contain
4303 breakpoint mask conditions. At least 4 instruction registers pairs are implemented
4304 on all processor models. Implemented registers are contiguous starting with
4305 register 0. No parameter checking is performed on Index, and if the Index value
4306 is beyond the implemented IBR register range, a Reserved Register/Field fault may
4307 occur. The caller must either guarantee that Index is valid, or the caller must
4308 set up fault handlers to catch the faults.
4309 This function is only available on Itanium processors.
4311 @param Index The 8-bit Instruction Breakpoint Register index to read.
4313 @return The current value of Instruction Breakpoint Register specified by Index.
4324 Reads the current value of Data Breakpoint Register (DBR).
4326 The Data Breakpoint Registers are used in pairs. The even numbered registers
4327 contain breakpoint addresses, and odd numbered registers contain breakpoint
4328 mask conditions. At least 4 data registers pairs are implemented on all processor
4329 models. Implemented registers are contiguous starting with register 0.
4330 No parameter checking is performed on Index. If the Index value is beyond
4331 the implemented DBR register range, a Reserved Register/Field fault may occur.
4332 The caller must either guarantee that Index is valid, or the caller must set up
4333 fault handlers to catch the faults.
4334 This function is only available on Itanium processors.
4336 @param Index The 8-bit Data Breakpoint Register index to read.
4338 @return The current value of Data Breakpoint Register specified by Index.
4349 Reads the current value of Performance Monitor Configuration Register (PMC).
4351 All processor implementations provide at least 4 performance counters
4352 (PMC/PMD [4]...PMC/PMD [7] pairs), and 4 performance monitor counter overflow
4353 status registers (PMC [0]... PMC [3]). Processor implementations may provide
4354 additional implementation-dependent PMC and PMD to increase the number of
4355 'generic' performance counters (PMC/PMD pairs). The remainder of PMC and PMD
4356 register set is implementation dependent. No parameter checking is performed
4357 on Index. If the Index value is beyond the implemented PMC register range,
4358 zero value will be returned.
4359 This function is only available on Itanium processors.
4361 @param Index The 8-bit Performance Monitor Configuration Register index to read.
4363 @return The current value of Performance Monitor Configuration Register
4375 Reads the current value of Performance Monitor Data Register (PMD).
4377 All processor implementations provide at least 4 performance counters
4378 (PMC/PMD [4]...PMC/PMD [7] pairs), and 4 performance monitor counter
4379 overflow status registers (PMC [0]... PMC [3]). Processor implementations may
4380 provide additional implementation-dependent PMC and PMD to increase the number
4381 of 'generic' performance counters (PMC/PMD pairs). The remainder of PMC and PMD
4382 register set is implementation dependent. No parameter checking is performed
4383 on Index. If the Index value is beyond the implemented PMD register range,
4384 zero value will be returned.
4385 This function is only available on Itanium processors.
4387 @param Index The 8-bit Performance Monitor Data Register index to read.
4389 @return The current value of Performance Monitor Data Register specified by Index.
4400 Writes the current value of 64-bit Instruction Breakpoint Register (IBR).
4402 Writes current value of Instruction Breakpoint Register specified by Index.
4403 The Instruction Breakpoint Registers are used in pairs. The even numbered
4404 registers contain breakpoint addresses, and odd numbered registers contain
4405 breakpoint mask conditions. At least 4 instruction registers pairs are implemented
4406 on all processor models. Implemented registers are contiguous starting with
4407 register 0. No parameter checking is performed on Index. If the Index value
4408 is beyond the implemented IBR register range, a Reserved Register/Field fault may
4409 occur. The caller must either guarantee that Index is valid, or the caller must
4410 set up fault handlers to catch the faults.
4411 This function is only available on Itanium processors.
4413 @param Index The 8-bit Instruction Breakpoint Register index to write.
4414 @param Value The 64-bit value to write to IBR.
4416 @return The 64-bit value written to the IBR.
4428 Writes the current value of 64-bit Data Breakpoint Register (DBR).
4430 Writes current value of Data Breakpoint Register specified by Index.
4431 The Data Breakpoint Registers are used in pairs. The even numbered registers
4432 contain breakpoint addresses, and odd numbered registers contain breakpoint
4433 mask conditions. At least 4 data registers pairs are implemented on all processor
4434 models. Implemented registers are contiguous starting with register 0. No parameter
4435 checking is performed on Index. If the Index value is beyond the implemented
4436 DBR register range, a Reserved Register/Field fault may occur. The caller must
4437 either guarantee that Index is valid, or the caller must set up fault handlers to
4439 This function is only available on Itanium processors.
4441 @param Index The 8-bit Data Breakpoint Register index to write.
4442 @param Value The 64-bit value to write to DBR.
4444 @return The 64-bit value written to the DBR.
4456 Writes the current value of 64-bit Performance Monitor Configuration Register (PMC).
4458 Writes current value of Performance Monitor Configuration Register specified by Index.
4459 All processor implementations provide at least 4 performance counters
4460 (PMC/PMD [4]...PMC/PMD [7] pairs), and 4 performance monitor counter overflow status
4461 registers (PMC [0]... PMC [3]). Processor implementations may provide additional
4462 implementation-dependent PMC and PMD to increase the number of 'generic' performance
4463 counters (PMC/PMD pairs). The remainder of PMC and PMD register set is implementation
4464 dependent. No parameter checking is performed on Index. If the Index value is
4465 beyond the implemented PMC register range, the write is ignored.
4466 This function is only available on Itanium processors.
4468 @param Index The 8-bit Performance Monitor Configuration Register index to write.
4469 @param Value The 64-bit value to write to PMC.
4471 @return The 64-bit value written to the PMC.
4483 Writes the current value of 64-bit Performance Monitor Data Register (PMD).
4485 Writes current value of Performance Monitor Data Register specified by Index.
4486 All processor implementations provide at least 4 performance counters
4487 (PMC/PMD [4]...PMC/PMD [7] pairs), and 4 performance monitor counter overflow
4488 status registers (PMC [0]... PMC [3]). Processor implementations may provide
4489 additional implementation-dependent PMC and PMD to increase the number of 'generic'
4490 performance counters (PMC/PMD pairs). The remainder of PMC and PMD register set
4491 is implementation dependent. No parameter checking is performed on Index. If the
4492 Index value is beyond the implemented PMD register range, the write is ignored.
4493 This function is only available on Itanium processors.
4495 @param Index The 8-bit Performance Monitor Data Register index to write.
4496 @param Value The 64-bit value to write to PMD.
4498 @return The 64-bit value written to the PMD.
4510 Reads the current value of 64-bit Global Pointer (GP).
4512 Reads and returns the current value of GP.
4513 This function is only available on Itanium processors.
4515 @return The current value of GP.
4526 Write the current value of 64-bit Global Pointer (GP).
4528 Writes the current value of GP. The 64-bit value written to the GP is returned.
4529 No parameter checking is performed on Value.
4530 This function is only available on Itanium processors.
4532 @param Value The 64-bit value to write to GP.
4534 @return The 64-bit value written to the GP.
4545 Reads the current value of 64-bit Stack Pointer (SP).
4547 Reads and returns the current value of SP.
4548 This function is only available on Itanium processors.
4550 @return The current value of SP.
4561 /// Valid Index value for AsmReadControlRegister()
4563 #define IPF_CONTROL_REGISTER_DCR 0
4564 #define IPF_CONTROL_REGISTER_ITM 1
4565 #define IPF_CONTROL_REGISTER_IVA 2
4566 #define IPF_CONTROL_REGISTER_PTA 8
4567 #define IPF_CONTROL_REGISTER_IPSR 16
4568 #define IPF_CONTROL_REGISTER_ISR 17
4569 #define IPF_CONTROL_REGISTER_IIP 19
4570 #define IPF_CONTROL_REGISTER_IFA 20
4571 #define IPF_CONTROL_REGISTER_ITIR 21
4572 #define IPF_CONTROL_REGISTER_IIPA 22
4573 #define IPF_CONTROL_REGISTER_IFS 23
4574 #define IPF_CONTROL_REGISTER_IIM 24
4575 #define IPF_CONTROL_REGISTER_IHA 25
4576 #define IPF_CONTROL_REGISTER_LID 64
4577 #define IPF_CONTROL_REGISTER_IVR 65
4578 #define IPF_CONTROL_REGISTER_TPR 66
4579 #define IPF_CONTROL_REGISTER_EOI 67
4580 #define IPF_CONTROL_REGISTER_IRR0 68
4581 #define IPF_CONTROL_REGISTER_IRR1 69
4582 #define IPF_CONTROL_REGISTER_IRR2 70
4583 #define IPF_CONTROL_REGISTER_IRR3 71
4584 #define IPF_CONTROL_REGISTER_ITV 72
4585 #define IPF_CONTROL_REGISTER_PMV 73
4586 #define IPF_CONTROL_REGISTER_CMCV 74
4587 #define IPF_CONTROL_REGISTER_LRR0 80
4588 #define IPF_CONTROL_REGISTER_LRR1 81
4591 Reads a 64-bit control register.
4593 Reads and returns the control register specified by Index. The valid Index valued are defined
4594 above in "Related Definitions".
4595 If Index is invalid then 0xFFFFFFFFFFFFFFFF is returned. This function is only available on Itanium processors.
4597 @param Index The index of the control register to read.
4599 @return The control register specified by Index.
4604 AsmReadControlRegister (
4610 /// Valid Index value for AsmReadApplicationRegister()
4612 #define IPF_APPLICATION_REGISTER_K0 0
4613 #define IPF_APPLICATION_REGISTER_K1 1
4614 #define IPF_APPLICATION_REGISTER_K2 2
4615 #define IPF_APPLICATION_REGISTER_K3 3
4616 #define IPF_APPLICATION_REGISTER_K4 4
4617 #define IPF_APPLICATION_REGISTER_K5 5
4618 #define IPF_APPLICATION_REGISTER_K6 6
4619 #define IPF_APPLICATION_REGISTER_K7 7
4620 #define IPF_APPLICATION_REGISTER_RSC 16
4621 #define IPF_APPLICATION_REGISTER_BSP 17
4622 #define IPF_APPLICATION_REGISTER_BSPSTORE 18
4623 #define IPF_APPLICATION_REGISTER_RNAT 19
4624 #define IPF_APPLICATION_REGISTER_FCR 21
4625 #define IPF_APPLICATION_REGISTER_EFLAG 24
4626 #define IPF_APPLICATION_REGISTER_CSD 25
4627 #define IPF_APPLICATION_REGISTER_SSD 26
4628 #define IPF_APPLICATION_REGISTER_CFLG 27
4629 #define IPF_APPLICATION_REGISTER_FSR 28
4630 #define IPF_APPLICATION_REGISTER_FIR 29
4631 #define IPF_APPLICATION_REGISTER_FDR 30
4632 #define IPF_APPLICATION_REGISTER_CCV 32
4633 #define IPF_APPLICATION_REGISTER_UNAT 36
4634 #define IPF_APPLICATION_REGISTER_FPSR 40
4635 #define IPF_APPLICATION_REGISTER_ITC 44
4636 #define IPF_APPLICATION_REGISTER_PFS 64
4637 #define IPF_APPLICATION_REGISTER_LC 65
4638 #define IPF_APPLICATION_REGISTER_EC 66
4641 Reads a 64-bit application register.
4643 Reads and returns the application register specified by Index. The valid Index valued are defined
4644 above in "Related Definitions".
4645 If Index is invalid then 0xFFFFFFFFFFFFFFFF is returned. This function is only available on Itanium processors.
4647 @param Index The index of the application register to read.
4649 @return The application register specified by Index.
4654 AsmReadApplicationRegister (
4660 Reads the current value of a Machine Specific Register (MSR).
4662 Reads and returns the current value of the Machine Specific Register specified by Index. No
4663 parameter checking is performed on Index, and if the Index value is beyond the implemented MSR
4664 register range, a Reserved Register/Field fault may occur. The caller must either guarantee that
4665 Index is valid, or the caller must set up fault handlers to catch the faults. This function is
4666 only available on Itanium processors.
4668 @param Index The 8-bit Machine Specific Register index to read.
4670 @return The current value of the Machine Specific Register specified by Index.
4681 Writes the current value of a Machine Specific Register (MSR).
4683 Writes Value to the Machine Specific Register specified by Index. Value is returned. No
4684 parameter checking is performed on Index, and if the Index value is beyond the implemented MSR
4685 register range, a Reserved Register/Field fault may occur. The caller must either guarantee that
4686 Index is valid, or the caller must set up fault handlers to catch the faults. This function is
4687 only available on Itanium processors.
4689 @param Index The 8-bit Machine Specific Register index to write.
4690 @param Value The 64-bit value to write to the Machine Specific Register.
4692 @return The 64-bit value to write to the Machine Specific Register.
4704 Determines if the CPU is currently executing in virtual, physical, or mixed mode.
4706 Determines the current execution mode of the CPU.
4707 If the CPU is in virtual mode(PSR.RT=1, PSR.DT=1, PSR.IT=1), then 1 is returned.
4708 If the CPU is in physical mode(PSR.RT=0, PSR.DT=0, PSR.IT=0), then 0 is returned.
4709 If the CPU is not in physical mode or virtual mode, then it is in mixed mode,
4711 This function is only available on Itanium processors.
4713 @retval 1 The CPU is in virtual mode.
4714 @retval 0 The CPU is in physical mode.
4715 @retval -1 The CPU is in mixed mode.
4726 Makes a PAL procedure call.
4728 This is a wrapper function to make a PAL procedure call. Based on the Index
4729 value this API will make static or stacked PAL call. The following table
4730 describes the usage of PAL Procedure Index Assignment. Architected procedures
4731 may be designated as required or optional. If a PAL procedure is specified
4732 as optional, a unique return code of 0xFFFFFFFFFFFFFFFF is returned in the
4733 Status field of the PAL_CALL_RETURN structure.
4734 This indicates that the procedure is not present in this PAL implementation.
4735 It is the caller's responsibility to check for this return code after calling
4736 any optional PAL procedure.
4737 No parameter checking is performed on the 5 input parameters, but there are
4738 some common rules that the caller should follow when making a PAL call. Any
4739 address passed to PAL as buffers for return parameters must be 8-byte aligned.
4740 Unaligned addresses may cause undefined results. For those parameters defined
4741 as reserved or some fields defined as reserved must be zero filled or the invalid
4742 argument return value may be returned or undefined result may occur during the
4743 execution of the procedure. If the PalEntryPoint does not point to a valid
4744 PAL entry point then the system behavior is undefined. This function is only
4745 available on Itanium processors.
4747 @param PalEntryPoint The PAL procedure calls entry point.
4748 @param Index The PAL procedure Index number.
4749 @param Arg2 The 2nd parameter for PAL procedure calls.
4750 @param Arg3 The 3rd parameter for PAL procedure calls.
4751 @param Arg4 The 4th parameter for PAL procedure calls.
4753 @return structure returned from the PAL Call procedure, including the status and return value.
4759 IN UINT64 PalEntryPoint
,
4767 #if defined (MDE_CPU_IA32) || defined (MDE_CPU_X64)
4769 /// IA32 and x64 Specific Functions
4770 /// Byte packed structure for 16-bit Real Mode EFLAGS
4774 UINT32 CF
:1; ///< Carry Flag
4775 UINT32 Reserved_0
:1; ///< Reserved
4776 UINT32 PF
:1; ///< Parity Flag
4777 UINT32 Reserved_1
:1; ///< Reserved
4778 UINT32 AF
:1; ///< Auxiliary Carry Flag
4779 UINT32 Reserved_2
:1; ///< Reserved
4780 UINT32 ZF
:1; ///< Zero Flag
4781 UINT32 SF
:1; ///< Sign Flag
4782 UINT32 TF
:1; ///< Trap Flag
4783 UINT32 IF
:1; ///< Interrupt Enable Flag
4784 UINT32 DF
:1; ///< Direction Flag
4785 UINT32 OF
:1; ///< Overflow Flag
4786 UINT32 IOPL
:2; ///< I/O Privilege Level
4787 UINT32 NT
:1; ///< Nested Task
4788 UINT32 Reserved_3
:1; ///< Reserved
4794 /// Byte packed structure for EFLAGS/RFLAGS
4795 /// 32-bits on IA-32
4796 /// 64-bits on x64. The upper 32-bits on x64 are reserved
4800 UINT32 CF
:1; ///< Carry Flag
4801 UINT32 Reserved_0
:1; ///< Reserved
4802 UINT32 PF
:1; ///< Parity Flag
4803 UINT32 Reserved_1
:1; ///< Reserved
4804 UINT32 AF
:1; ///< Auxiliary Carry Flag
4805 UINT32 Reserved_2
:1; ///< Reserved
4806 UINT32 ZF
:1; ///< Zero Flag
4807 UINT32 SF
:1; ///< Sign Flag
4808 UINT32 TF
:1; ///< Trap Flag
4809 UINT32 IF
:1; ///< Interrupt Enable Flag
4810 UINT32 DF
:1; ///< Direction Flag
4811 UINT32 OF
:1; ///< Overflow Flag
4812 UINT32 IOPL
:2; ///< I/O Privilege Level
4813 UINT32 NT
:1; ///< Nested Task
4814 UINT32 Reserved_3
:1; ///< Reserved
4815 UINT32 RF
:1; ///< Resume Flag
4816 UINT32 VM
:1; ///< Virtual 8086 Mode
4817 UINT32 AC
:1; ///< Alignment Check
4818 UINT32 VIF
:1; ///< Virtual Interrupt Flag
4819 UINT32 VIP
:1; ///< Virtual Interrupt Pending
4820 UINT32 ID
:1; ///< ID Flag
4821 UINT32 Reserved_4
:10; ///< Reserved
4827 /// Byte packed structure for Control Register 0 (CR0)
4828 /// 32-bits on IA-32
4829 /// 64-bits on x64. The upper 32-bits on x64 are reserved
4833 UINT32 PE
:1; ///< Protection Enable
4834 UINT32 MP
:1; ///< Monitor Coprocessor
4835 UINT32 EM
:1; ///< Emulation
4836 UINT32 TS
:1; ///< Task Switched
4837 UINT32 ET
:1; ///< Extension Type
4838 UINT32 NE
:1; ///< Numeric Error
4839 UINT32 Reserved_0
:10; ///< Reserved
4840 UINT32 WP
:1; ///< Write Protect
4841 UINT32 Reserved_1
:1; ///< Reserved
4842 UINT32 AM
:1; ///< Alignment Mask
4843 UINT32 Reserved_2
:10; ///< Reserved
4844 UINT32 NW
:1; ///< Mot Write-through
4845 UINT32 CD
:1; ///< Cache Disable
4846 UINT32 PG
:1; ///< Paging
4852 /// Byte packed structure for Control Register 4 (CR4)
4853 /// 32-bits on IA-32
4854 /// 64-bits on x64. The upper 32-bits on x64 are reserved
4858 UINT32 VME
:1; ///< Virtual-8086 Mode Extensions
4859 UINT32 PVI
:1; ///< Protected-Mode Virtual Interrupts
4860 UINT32 TSD
:1; ///< Time Stamp Disable
4861 UINT32 DE
:1; ///< Debugging Extensions
4862 UINT32 PSE
:1; ///< Page Size Extensions
4863 UINT32 PAE
:1; ///< Physical Address Extension
4864 UINT32 MCE
:1; ///< Machine Check Enable
4865 UINT32 PGE
:1; ///< Page Global Enable
4866 UINT32 PCE
:1; ///< Performance Monitoring Counter
4868 UINT32 OSFXSR
:1; ///< Operating System Support for
4869 ///< FXSAVE and FXRSTOR instructions
4870 UINT32 OSXMMEXCPT
:1; ///< Operating System Support for
4871 ///< Unmasked SIMD Floating Point
4873 UINT32 Reserved_0
:2; ///< Reserved
4874 UINT32 VMXE
:1; ///< VMX Enable
4875 UINT32 Reserved_1
:18; ///< Reserved
4881 /// Byte packed structure for an IDTR, GDTR, LDTR descriptor
4890 #define IA32_IDT_GATE_TYPE_TASK 0x85
4891 #define IA32_IDT_GATE_TYPE_INTERRUPT_16 0x86
4892 #define IA32_IDT_GATE_TYPE_TRAP_16 0x87
4893 #define IA32_IDT_GATE_TYPE_INTERRUPT_32 0x8E
4894 #define IA32_IDT_GATE_TYPE_TRAP_32 0x8F
4897 #if defined (MDE_CPU_IA32)
4899 /// Byte packed structure for an IA-32 Interrupt Gate Descriptor
4903 UINT32 OffsetLow
:16; ///< Offset bits 15..0
4904 UINT32 Selector
:16; ///< Selector
4905 UINT32 Reserved_0
:8; ///< Reserved
4906 UINT32 GateType
:8; ///< Gate Type. See #defines above
4907 UINT32 OffsetHigh
:16; ///< Offset bits 31..16
4910 } IA32_IDT_GATE_DESCRIPTOR
;
4914 #if defined (MDE_CPU_X64)
4916 /// Byte packed structure for an x64 Interrupt Gate Descriptor
4920 UINT32 OffsetLow
:16; ///< Offset bits 15..0
4921 UINT32 Selector
:16; ///< Selector
4922 UINT32 Reserved_0
:8; ///< Reserved
4923 UINT32 GateType
:8; ///< Gate Type. See #defines above
4924 UINT32 OffsetHigh
:16; ///< Offset bits 31..16
4925 UINT32 OffsetUpper
:32; ///< Offset bits 63..32
4926 UINT32 Reserved_1
:32; ///< Reserved
4932 } IA32_IDT_GATE_DESCRIPTOR
;
4937 /// Byte packed structure for an FP/SSE/SSE2 context
4944 /// Structures for the 16-bit real mode thunks
4997 IA32_EFLAGS32 EFLAGS
;
5007 } IA32_REGISTER_SET
;
5010 /// Byte packed structure for an 16-bit real mode thunks
5013 IA32_REGISTER_SET
*RealModeState
;
5014 VOID
*RealModeBuffer
;
5015 UINT32 RealModeBufferSize
;
5016 UINT32 ThunkAttributes
;
5019 #define THUNK_ATTRIBUTE_BIG_REAL_MODE 0x00000001
5020 #define THUNK_ATTRIBUTE_DISABLE_A20_MASK_INT_15 0x00000002
5021 #define THUNK_ATTRIBUTE_DISABLE_A20_MASK_KBD_CTRL 0x00000004
5024 Retrieves CPUID information.
5026 Executes the CPUID instruction with EAX set to the value specified by Index.
5027 This function always returns Index.
5028 If Eax is not NULL, then the value of EAX after CPUID is returned in Eax.
5029 If Ebx is not NULL, then the value of EBX after CPUID is returned in Ebx.
5030 If Ecx is not NULL, then the value of ECX after CPUID is returned in Ecx.
5031 If Edx is not NULL, then the value of EDX after CPUID is returned in Edx.
5032 This function is only available on IA-32 and x64.
5034 @param Index The 32-bit value to load into EAX prior to invoking the CPUID
5036 @param Eax Pointer to the 32-bit EAX value returned by the CPUID
5037 instruction. This is an optional parameter that may be NULL.
5038 @param Ebx Pointer to the 32-bit EBX value returned by the CPUID
5039 instruction. This is an optional parameter that may be NULL.
5040 @param Ecx Pointer to the 32-bit ECX value returned by the CPUID
5041 instruction. This is an optional parameter that may be NULL.
5042 @param Edx Pointer to the 32-bit EDX value returned by the CPUID
5043 instruction. This is an optional parameter that may be NULL.
5052 OUT UINT32
*Eax
, OPTIONAL
5053 OUT UINT32
*Ebx
, OPTIONAL
5054 OUT UINT32
*Ecx
, OPTIONAL
5055 OUT UINT32
*Edx OPTIONAL
5060 Retrieves CPUID information using an extended leaf identifier.
5062 Executes the CPUID instruction with EAX set to the value specified by Index
5063 and ECX set to the value specified by SubIndex. This function always returns
5064 Index. This function is only available on IA-32 and x64.
5066 If Eax is not NULL, then the value of EAX after CPUID is returned in Eax.
5067 If Ebx is not NULL, then the value of EBX after CPUID is returned in Ebx.
5068 If Ecx is not NULL, then the value of ECX after CPUID is returned in Ecx.
5069 If Edx is not NULL, then the value of EDX after CPUID is returned in Edx.
5071 @param Index The 32-bit value to load into EAX prior to invoking the
5073 @param SubIndex The 32-bit value to load into ECX prior to invoking the
5075 @param Eax Pointer to the 32-bit EAX value returned by the CPUID
5076 instruction. This is an optional parameter that may be
5078 @param Ebx Pointer to the 32-bit EBX value returned by the CPUID
5079 instruction. This is an optional parameter that may be
5081 @param Ecx Pointer to the 32-bit ECX value returned by the CPUID
5082 instruction. This is an optional parameter that may be
5084 @param Edx Pointer to the 32-bit EDX value returned by the CPUID
5085 instruction. This is an optional parameter that may be
5096 OUT UINT32
*Eax
, OPTIONAL
5097 OUT UINT32
*Ebx
, OPTIONAL
5098 OUT UINT32
*Ecx
, OPTIONAL
5099 OUT UINT32
*Edx OPTIONAL
5104 Set CD bit and clear NW bit of CR0 followed by a WBINVD.
5106 Disables the caches by setting the CD bit of CR0 to 1, clearing the NW bit of CR0 to 0,
5107 and executing a WBINVD instruction. This function is only available on IA-32 and x64.
5118 Perform a WBINVD and clear both the CD and NW bits of CR0.
5120 Enables the caches by executing a WBINVD instruction and then clear both the CD and NW
5121 bits of CR0 to 0. This function is only available on IA-32 and x64.
5132 Returns the lower 32-bits of a Machine Specific Register(MSR).
5134 Reads and returns the lower 32-bits of the MSR specified by Index.
5135 No parameter checking is performed on Index, and some Index values may cause
5136 CPU exceptions. The caller must either guarantee that Index is valid, or the
5137 caller must set up exception handlers to catch the exceptions. This function
5138 is only available on IA-32 and x64.
5140 @param Index The 32-bit MSR index to read.
5142 @return The lower 32 bits of the MSR identified by Index.
5153 Writes a 32-bit value to a Machine Specific Register(MSR), and returns the value.
5154 The upper 32-bits of the MSR are set to zero.
5156 Writes the 32-bit value specified by Value to the MSR specified by Index. The
5157 upper 32-bits of the MSR write are set to zero. The 32-bit value written to
5158 the MSR is returned. No parameter checking is performed on Index or Value,
5159 and some of these may cause CPU exceptions. The caller must either guarantee
5160 that Index and Value are valid, or the caller must establish proper exception
5161 handlers. This function is only available on IA-32 and x64.
5163 @param Index The 32-bit MSR index to write.
5164 @param Value The 32-bit value to write to the MSR.
5178 Reads a 64-bit MSR, performs a bitwise OR on the lower 32-bits, and
5179 writes the result back to the 64-bit MSR.
5181 Reads the 64-bit MSR specified by Index, performs a bitwise OR
5182 between the lower 32-bits of the read result and the value specified by
5183 OrData, and writes the result to the 64-bit MSR specified by Index. The lower
5184 32-bits of the value written to the MSR is returned. No parameter checking is
5185 performed on Index or OrData, and some of these may cause CPU exceptions. The
5186 caller must either guarantee that Index and OrData are valid, or the caller
5187 must establish proper exception handlers. This function is only available on
5190 @param Index The 32-bit MSR index to write.
5191 @param OrData The value to OR with the read value from the MSR.
5193 @return The lower 32-bit value written to the MSR.
5205 Reads a 64-bit MSR, performs a bitwise AND on the lower 32-bits, and writes
5206 the result back to the 64-bit MSR.
5208 Reads the 64-bit MSR specified by Index, performs a bitwise AND between the
5209 lower 32-bits of the read result and the value specified by AndData, and
5210 writes the result to the 64-bit MSR specified by Index. The lower 32-bits of
5211 the value written to the MSR is returned. No parameter checking is performed
5212 on Index or AndData, and some of these may cause CPU exceptions. The caller
5213 must either guarantee that Index and AndData are valid, or the caller must
5214 establish proper exception handlers. This function is only available on IA-32
5217 @param Index The 32-bit MSR index to write.
5218 @param AndData The value to AND with the read value from the MSR.
5220 @return The lower 32-bit value written to the MSR.
5232 Reads a 64-bit MSR, performs a bitwise AND followed by a bitwise OR
5233 on the lower 32-bits, and writes the result back to the 64-bit MSR.
5235 Reads the 64-bit MSR specified by Index, performs a bitwise AND between the
5236 lower 32-bits of the read result and the value specified by AndData
5237 preserving the upper 32-bits, performs a bitwise OR between the
5238 result of the AND operation and the value specified by OrData, and writes the
5239 result to the 64-bit MSR specified by Address. The lower 32-bits of the value
5240 written to the MSR is returned. No parameter checking is performed on Index,
5241 AndData, or OrData, and some of these may cause CPU exceptions. The caller
5242 must either guarantee that Index, AndData, and OrData are valid, or the
5243 caller must establish proper exception handlers. This function is only
5244 available on IA-32 and x64.
5246 @param Index The 32-bit MSR index to write.
5247 @param AndData The value to AND with the read value from the MSR.
5248 @param OrData The value to OR with the result of the AND operation.
5250 @return The lower 32-bit value written to the MSR.
5263 Reads a bit field of an MSR.
5265 Reads the bit field in the lower 32-bits of a 64-bit MSR. The bit field is
5266 specified by the StartBit and the EndBit. The value of the bit field is
5267 returned. The caller must either guarantee that Index is valid, or the caller
5268 must set up exception handlers to catch the exceptions. This function is only
5269 available on IA-32 and x64.
5271 If StartBit is greater than 31, then ASSERT().
5272 If EndBit is greater than 31, then ASSERT().
5273 If EndBit is less than StartBit, then ASSERT().
5275 @param Index The 32-bit MSR index to read.
5276 @param StartBit The ordinal of the least significant bit in the bit field.
5278 @param EndBit The ordinal of the most significant bit in the bit field.
5281 @return The bit field read from the MSR.
5286 AsmMsrBitFieldRead32 (
5294 Writes a bit field to an MSR.
5296 Writes Value to a bit field in the lower 32-bits of a 64-bit MSR. The bit
5297 field is specified by the StartBit and the EndBit. All other bits in the
5298 destination MSR are preserved. The lower 32-bits of the MSR written is
5299 returned. The caller must either guarantee that Index and the data written
5300 is valid, or the caller must set up exception handlers to catch the exceptions.
5301 This function is only available on IA-32 and x64.
5303 If StartBit is greater than 31, then ASSERT().
5304 If EndBit is greater than 31, then ASSERT().
5305 If EndBit is less than StartBit, then ASSERT().
5307 @param Index The 32-bit MSR index to write.
5308 @param StartBit The ordinal of the least significant bit in the bit field.
5310 @param EndBit The ordinal of the most significant bit in the bit field.
5312 @param Value New value of the bit field.
5314 @return The lower 32-bit of the value written to the MSR.
5319 AsmMsrBitFieldWrite32 (
5328 Reads a bit field in a 64-bit MSR, performs a bitwise OR, and writes the
5329 result back to the bit field in the 64-bit MSR.
5331 Reads the 64-bit MSR specified by Index, performs a bitwise OR
5332 between the read result and the value specified by OrData, and writes the
5333 result to the 64-bit MSR specified by Index. The lower 32-bits of the value
5334 written to the MSR are returned. Extra left bits in OrData are stripped. The
5335 caller must either guarantee that Index and the data written is valid, or
5336 the caller must set up exception handlers to catch the exceptions. This
5337 function is only available on IA-32 and x64.
5339 If StartBit is greater than 31, then ASSERT().
5340 If EndBit is greater than 31, then ASSERT().
5341 If EndBit is less than StartBit, then ASSERT().
5343 @param Index The 32-bit MSR index to write.
5344 @param StartBit The ordinal of the least significant bit in the bit field.
5346 @param EndBit The ordinal of the most significant bit in the bit field.
5348 @param OrData The value to OR with the read value from the MSR.
5350 @return The lower 32-bit of the value written to the MSR.
5355 AsmMsrBitFieldOr32 (
5364 Reads a bit field in a 64-bit MSR, performs a bitwise AND, and writes the
5365 result back to the bit field in the 64-bit MSR.
5367 Reads the 64-bit MSR specified by Index, performs a bitwise AND between the
5368 read result and the value specified by AndData, and writes the result to the
5369 64-bit MSR specified by Index. The lower 32-bits of the value written to the
5370 MSR are returned. Extra left bits in AndData are stripped. The caller must
5371 either guarantee that Index and the data written is valid, or the caller must
5372 set up exception handlers to catch the exceptions. This function is only
5373 available on IA-32 and x64.
5375 If StartBit is greater than 31, then ASSERT().
5376 If EndBit is greater than 31, then ASSERT().
5377 If EndBit is less than StartBit, then ASSERT().
5379 @param Index The 32-bit MSR index to write.
5380 @param StartBit The ordinal of the least significant bit in the bit field.
5382 @param EndBit The ordinal of the most significant bit in the bit field.
5384 @param AndData The value to AND with the read value from the MSR.
5386 @return The lower 32-bit of the value written to the MSR.
5391 AsmMsrBitFieldAnd32 (
5400 Reads a bit field in a 64-bit MSR, performs a bitwise AND followed by a
5401 bitwise OR, and writes the result back to the bit field in the
5404 Reads the 64-bit MSR specified by Index, performs a bitwise AND followed by a
5405 bitwise OR between the read result and the value specified by
5406 AndData, and writes the result to the 64-bit MSR specified by Index. The
5407 lower 32-bits of the value written to the MSR are returned. Extra left bits
5408 in both AndData and OrData are stripped. The caller must either guarantee
5409 that Index and the data written is valid, or the caller must set up exception
5410 handlers to catch the exceptions. This function is only available on IA-32
5413 If StartBit is greater than 31, then ASSERT().
5414 If EndBit is greater than 31, then ASSERT().
5415 If EndBit is less than StartBit, then ASSERT().
5417 @param Index The 32-bit MSR index to write.
5418 @param StartBit The ordinal of the least significant bit in the bit field.
5420 @param EndBit The ordinal of the most significant bit in the bit field.
5422 @param AndData The value to AND with the read value from the MSR.
5423 @param OrData The value to OR with the result of the AND operation.
5425 @return The lower 32-bit of the value written to the MSR.
5430 AsmMsrBitFieldAndThenOr32 (
5440 Returns a 64-bit Machine Specific Register(MSR).
5442 Reads and returns the 64-bit MSR specified by Index. No parameter checking is
5443 performed on Index, and some Index values may cause CPU exceptions. The
5444 caller must either guarantee that Index is valid, or the caller must set up
5445 exception handlers to catch the exceptions. This function is only available
5448 @param Index The 32-bit MSR index to read.
5450 @return The value of the MSR identified by Index.
5461 Writes a 64-bit value to a Machine Specific Register(MSR), and returns the
5464 Writes the 64-bit value specified by Value to the MSR specified by Index. The
5465 64-bit value written to the MSR is returned. No parameter checking is
5466 performed on Index or Value, and some of these may cause CPU exceptions. The
5467 caller must either guarantee that Index and Value are valid, or the caller
5468 must establish proper exception handlers. This function is only available on
5471 @param Index The 32-bit MSR index to write.
5472 @param Value The 64-bit value to write to the MSR.
5486 Reads a 64-bit MSR, performs a bitwise OR, and writes the result
5487 back to the 64-bit MSR.
5489 Reads the 64-bit MSR specified by Index, performs a bitwise OR
5490 between the read result and the value specified by OrData, and writes the
5491 result to the 64-bit MSR specified by Index. The value written to the MSR is
5492 returned. No parameter checking is performed on Index or OrData, and some of
5493 these may cause CPU exceptions. The caller must either guarantee that Index
5494 and OrData are valid, or the caller must establish proper exception handlers.
5495 This function is only available on IA-32 and x64.
5497 @param Index The 32-bit MSR index to write.
5498 @param OrData The value to OR with the read value from the MSR.
5500 @return The value written back to the MSR.
5512 Reads a 64-bit MSR, performs a bitwise AND, and writes the result back to the
5515 Reads the 64-bit MSR specified by Index, performs a bitwise AND between the
5516 read result and the value specified by OrData, and writes the result to the
5517 64-bit MSR specified by Index. The value written to the MSR is returned. No
5518 parameter checking is performed on Index or OrData, and some of these may
5519 cause CPU exceptions. The caller must either guarantee that Index and OrData
5520 are valid, or the caller must establish proper exception handlers. This
5521 function is only available on IA-32 and x64.
5523 @param Index The 32-bit MSR index to write.
5524 @param AndData The value to AND with the read value from the MSR.
5526 @return The value written back to the MSR.
5538 Reads a 64-bit MSR, performs a bitwise AND followed by a bitwise
5539 OR, and writes the result back to the 64-bit MSR.
5541 Reads the 64-bit MSR specified by Index, performs a bitwise AND between read
5542 result and the value specified by AndData, performs a bitwise OR
5543 between the result of the AND operation and the value specified by OrData,
5544 and writes the result to the 64-bit MSR specified by Index. The value written
5545 to the MSR is returned. No parameter checking is performed on Index, AndData,
5546 or OrData, and some of these may cause CPU exceptions. The caller must either
5547 guarantee that Index, AndData, and OrData are valid, or the caller must
5548 establish proper exception handlers. This function is only available on IA-32
5551 @param Index The 32-bit MSR index to write.
5552 @param AndData The value to AND with the read value from the MSR.
5553 @param OrData The value to OR with the result of the AND operation.
5555 @return The value written back to the MSR.
5568 Reads a bit field of an MSR.
5570 Reads the bit field in the 64-bit MSR. The bit field is specified by the
5571 StartBit and the EndBit. The value of the bit field is returned. The caller
5572 must either guarantee that Index is valid, or the caller must set up
5573 exception handlers to catch the exceptions. This function is only available
5576 If StartBit is greater than 63, then ASSERT().
5577 If EndBit is greater than 63, then ASSERT().
5578 If EndBit is less than StartBit, then ASSERT().
5580 @param Index The 32-bit MSR index to read.
5581 @param StartBit The ordinal of the least significant bit in the bit field.
5583 @param EndBit The ordinal of the most significant bit in the bit field.
5586 @return The value read from the MSR.
5591 AsmMsrBitFieldRead64 (
5599 Writes a bit field to an MSR.
5601 Writes Value to a bit field in a 64-bit MSR. The bit field is specified by
5602 the StartBit and the EndBit. All other bits in the destination MSR are
5603 preserved. The MSR written is returned. The caller must either guarantee
5604 that Index and the data written is valid, or the caller must set up exception
5605 handlers to catch the exceptions. This function is only available on IA-32 and x64.
5607 If StartBit is greater than 63, then ASSERT().
5608 If EndBit is greater than 63, then ASSERT().
5609 If EndBit is less than StartBit, then ASSERT().
5611 @param Index The 32-bit MSR index to write.
5612 @param StartBit The ordinal of the least significant bit in the bit field.
5614 @param EndBit The ordinal of the most significant bit in the bit field.
5616 @param Value New value of the bit field.
5618 @return The value written back to the MSR.
5623 AsmMsrBitFieldWrite64 (
5632 Reads a bit field in a 64-bit MSR, performs a bitwise OR, and
5633 writes the result back to the bit field in the 64-bit MSR.
5635 Reads the 64-bit MSR specified by Index, performs a bitwise OR
5636 between the read result and the value specified by OrData, and writes the
5637 result to the 64-bit MSR specified by Index. The value written to the MSR is
5638 returned. Extra left bits in OrData are stripped. The caller must either
5639 guarantee that Index and the data written is valid, or the caller must set up
5640 exception handlers to catch the exceptions. This function is only available
5643 If StartBit is greater than 63, then ASSERT().
5644 If EndBit is greater than 63, then ASSERT().
5645 If EndBit is less than StartBit, then ASSERT().
5647 @param Index The 32-bit MSR index to write.
5648 @param StartBit The ordinal of the least significant bit in the bit field.
5650 @param EndBit The ordinal of the most significant bit in the bit field.
5652 @param OrData The value to OR with the read value from the bit field.
5654 @return The value written back to the MSR.
5659 AsmMsrBitFieldOr64 (
5668 Reads a bit field in a 64-bit MSR, performs a bitwise AND, and writes the
5669 result back to the bit field in the 64-bit MSR.
5671 Reads the 64-bit MSR specified by Index, performs a bitwise AND between the
5672 read result and the value specified by AndData, and writes the result to the
5673 64-bit MSR specified by Index. The value written to the MSR is returned.
5674 Extra left bits in AndData are stripped. The caller must either guarantee
5675 that Index and the data written is valid, or the caller must set up exception
5676 handlers to catch the exceptions. This function is only available on IA-32
5679 If StartBit is greater than 63, then ASSERT().
5680 If EndBit is greater than 63, then ASSERT().
5681 If EndBit is less than StartBit, then ASSERT().
5683 @param Index The 32-bit MSR index to write.
5684 @param StartBit The ordinal of the least significant bit in the bit field.
5686 @param EndBit The ordinal of the most significant bit in the bit field.
5688 @param AndData The value to AND with the read value from the bit field.
5690 @return The value written back to the MSR.
5695 AsmMsrBitFieldAnd64 (
5704 Reads a bit field in a 64-bit MSR, performs a bitwise AND followed by a
5705 bitwise OR, and writes the result back to the bit field in the
5708 Reads the 64-bit MSR specified by Index, performs a bitwise AND followed by
5709 a bitwise OR between the read result and the value specified by
5710 AndData, and writes the result to the 64-bit MSR specified by Index. The
5711 value written to the MSR is returned. Extra left bits in both AndData and
5712 OrData are stripped. The caller must either guarantee that Index and the data
5713 written is valid, or the caller must set up exception handlers to catch the
5714 exceptions. This function is only available on IA-32 and x64.
5716 If StartBit is greater than 63, then ASSERT().
5717 If EndBit is greater than 63, then ASSERT().
5718 If EndBit is less than StartBit, then ASSERT().
5720 @param Index The 32-bit MSR index to write.
5721 @param StartBit The ordinal of the least significant bit in the bit field.
5723 @param EndBit The ordinal of the most significant bit in the bit field.
5725 @param AndData The value to AND with the read value from the bit field.
5726 @param OrData The value to OR with the result of the AND operation.
5728 @return The value written back to the MSR.
5733 AsmMsrBitFieldAndThenOr64 (
5743 Reads the current value of the EFLAGS register.
5745 Reads and returns the current value of the EFLAGS register. This function is
5746 only available on IA-32 and x64. This returns a 32-bit value on IA-32 and a
5747 64-bit value on x64.
5749 @return EFLAGS on IA-32 or RFLAGS on x64.
5760 Reads the current value of the Control Register 0 (CR0).
5762 Reads and returns the current value of CR0. This function is only available
5763 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
5766 @return The value of the Control Register 0 (CR0).
5777 Reads the current value of the Control Register 2 (CR2).
5779 Reads and returns the current value of CR2. This function is only available
5780 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
5783 @return The value of the Control Register 2 (CR2).
5794 Reads the current value of the Control Register 3 (CR3).
5796 Reads and returns the current value of CR3. This function is only available
5797 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
5800 @return The value of the Control Register 3 (CR3).
5811 Reads the current value of the Control Register 4 (CR4).
5813 Reads and returns the current value of CR4. This function is only available
5814 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
5817 @return The value of the Control Register 4 (CR4).
5828 Writes a value to Control Register 0 (CR0).
5830 Writes and returns a new value to CR0. This function is only available on
5831 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
5833 @param Cr0 The value to write to CR0.
5835 @return The value written to CR0.
5846 Writes a value to Control Register 2 (CR2).
5848 Writes and returns a new value to CR2. This function is only available on
5849 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
5851 @param Cr2 The value to write to CR2.
5853 @return The value written to CR2.
5864 Writes a value to Control Register 3 (CR3).
5866 Writes and returns a new value to CR3. This function is only available on
5867 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
5869 @param Cr3 The value to write to CR3.
5871 @return The value written to CR3.
5882 Writes a value to Control Register 4 (CR4).
5884 Writes and returns a new value to CR4. This function is only available on
5885 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
5887 @param Cr4 The value to write to CR4.
5889 @return The value written to CR4.
5900 Reads the current value of Debug Register 0 (DR0).
5902 Reads and returns the current value of DR0. This function is only available
5903 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
5906 @return The value of Debug Register 0 (DR0).
5917 Reads the current value of Debug Register 1 (DR1).
5919 Reads and returns the current value of DR1. This function is only available
5920 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
5923 @return The value of Debug Register 1 (DR1).
5934 Reads the current value of Debug Register 2 (DR2).
5936 Reads and returns the current value of DR2. This function is only available
5937 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
5940 @return The value of Debug Register 2 (DR2).
5951 Reads the current value of Debug Register 3 (DR3).
5953 Reads and returns the current value of DR3. This function is only available
5954 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
5957 @return The value of Debug Register 3 (DR3).
5968 Reads the current value of Debug Register 4 (DR4).
5970 Reads and returns the current value of DR4. This function is only available
5971 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
5974 @return The value of Debug Register 4 (DR4).
5985 Reads the current value of Debug Register 5 (DR5).
5987 Reads and returns the current value of DR5. This function is only available
5988 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
5991 @return The value of Debug Register 5 (DR5).
6002 Reads the current value of Debug Register 6 (DR6).
6004 Reads and returns the current value of DR6. This function is only available
6005 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
6008 @return The value of Debug Register 6 (DR6).
6019 Reads the current value of Debug Register 7 (DR7).
6021 Reads and returns the current value of DR7. This function is only available
6022 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
6025 @return The value of Debug Register 7 (DR7).
6036 Writes a value to Debug Register 0 (DR0).
6038 Writes and returns a new value to DR0. This function is only available on
6039 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
6041 @param Dr0 The value to write to Dr0.
6043 @return The value written to Debug Register 0 (DR0).
6054 Writes a value to Debug Register 1 (DR1).
6056 Writes and returns a new value to DR1. This function is only available on
6057 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
6059 @param Dr1 The value to write to Dr1.
6061 @return The value written to Debug Register 1 (DR1).
6072 Writes a value to Debug Register 2 (DR2).
6074 Writes and returns a new value to DR2. This function is only available on
6075 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
6077 @param Dr2 The value to write to Dr2.
6079 @return The value written to Debug Register 2 (DR2).
6090 Writes a value to Debug Register 3 (DR3).
6092 Writes and returns a new value to DR3. This function is only available on
6093 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
6095 @param Dr3 The value to write to Dr3.
6097 @return The value written to Debug Register 3 (DR3).
6108 Writes a value to Debug Register 4 (DR4).
6110 Writes and returns a new value to DR4. This function is only available on
6111 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
6113 @param Dr4 The value to write to Dr4.
6115 @return The value written to Debug Register 4 (DR4).
6126 Writes a value to Debug Register 5 (DR5).
6128 Writes and returns a new value to DR5. This function is only available on
6129 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
6131 @param Dr5 The value to write to Dr5.
6133 @return The value written to Debug Register 5 (DR5).
6144 Writes a value to Debug Register 6 (DR6).
6146 Writes and returns a new value to DR6. This function is only available on
6147 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
6149 @param Dr6 The value to write to Dr6.
6151 @return The value written to Debug Register 6 (DR6).
6162 Writes a value to Debug Register 7 (DR7).
6164 Writes and returns a new value to DR7. This function is only available on
6165 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
6167 @param Dr7 The value to write to Dr7.
6169 @return The value written to Debug Register 7 (DR7).
6180 Reads the current value of Code Segment Register (CS).
6182 Reads and returns the current value of CS. This function is only available on
6185 @return The current value of CS.
6196 Reads the current value of Data Segment Register (DS).
6198 Reads and returns the current value of DS. This function is only available on
6201 @return The current value of DS.
6212 Reads the current value of Extra Segment Register (ES).
6214 Reads and returns the current value of ES. This function is only available on
6217 @return The current value of ES.
6228 Reads the current value of FS Data Segment Register (FS).
6230 Reads and returns the current value of FS. This function is only available on
6233 @return The current value of FS.
6244 Reads the current value of GS Data Segment Register (GS).
6246 Reads and returns the current value of GS. This function is only available on
6249 @return The current value of GS.
6260 Reads the current value of Stack Segment Register (SS).
6262 Reads and returns the current value of SS. This function is only available on
6265 @return The current value of SS.
6276 Reads the current value of Task Register (TR).
6278 Reads and returns the current value of TR. This function is only available on
6281 @return The current value of TR.
6292 Reads the current Global Descriptor Table Register(GDTR) descriptor.
6294 Reads and returns the current GDTR descriptor and returns it in Gdtr. This
6295 function is only available on IA-32 and x64.
6297 If Gdtr is NULL, then ASSERT().
6299 @param Gdtr Pointer to a GDTR descriptor.
6305 OUT IA32_DESCRIPTOR
*Gdtr
6310 Writes the current Global Descriptor Table Register (GDTR) descriptor.
6312 Writes and the current GDTR descriptor specified by Gdtr. This function is
6313 only available on IA-32 and x64.
6315 If Gdtr is NULL, then ASSERT().
6317 @param Gdtr Pointer to a GDTR descriptor.
6323 IN CONST IA32_DESCRIPTOR
*Gdtr
6328 Reads the current Interrupt Descriptor Table Register(IDTR) descriptor.
6330 Reads and returns the current IDTR descriptor and returns it in Idtr. This
6331 function is only available on IA-32 and x64.
6333 If Idtr is NULL, then ASSERT().
6335 @param Idtr Pointer to a IDTR descriptor.
6341 OUT IA32_DESCRIPTOR
*Idtr
6346 Writes the current Interrupt Descriptor Table Register(IDTR) descriptor.
6348 Writes the current IDTR descriptor and returns it in Idtr. This function is
6349 only available on IA-32 and x64.
6351 If Idtr is NULL, then ASSERT().
6353 @param Idtr Pointer to a IDTR descriptor.
6359 IN CONST IA32_DESCRIPTOR
*Idtr
6364 Reads the current Local Descriptor Table Register(LDTR) selector.
6366 Reads and returns the current 16-bit LDTR descriptor value. This function is
6367 only available on IA-32 and x64.
6369 @return The current selector of LDT.
6380 Writes the current Local Descriptor Table Register (LDTR) selector.
6382 Writes and the current LDTR descriptor specified by Ldtr. This function is
6383 only available on IA-32 and x64.
6385 @param Ldtr 16-bit LDTR selector value.
6396 Save the current floating point/SSE/SSE2 context to a buffer.
6398 Saves the current floating point/SSE/SSE2 state to the buffer specified by
6399 Buffer. Buffer must be aligned on a 16-byte boundary. This function is only
6400 available on IA-32 and x64.
6402 If Buffer is NULL, then ASSERT().
6403 If Buffer is not aligned on a 16-byte boundary, then ASSERT().
6405 @param Buffer Pointer to a buffer to save the floating point/SSE/SSE2 context.
6411 OUT IA32_FX_BUFFER
*Buffer
6416 Restores the current floating point/SSE/SSE2 context from a buffer.
6418 Restores the current floating point/SSE/SSE2 state from the buffer specified
6419 by Buffer. Buffer must be aligned on a 16-byte boundary. This function is
6420 only available on IA-32 and x64.
6422 If Buffer is NULL, then ASSERT().
6423 If Buffer is not aligned on a 16-byte boundary, then ASSERT().
6424 If Buffer was not saved with AsmFxSave(), then ASSERT().
6426 @param Buffer Pointer to a buffer to save the floating point/SSE/SSE2 context.
6432 IN CONST IA32_FX_BUFFER
*Buffer
6437 Reads the current value of 64-bit MMX Register #0 (MM0).
6439 Reads and returns the current value of MM0. This function is only available
6442 @return The current value of MM0.
6453 Reads the current value of 64-bit MMX Register #1 (MM1).
6455 Reads and returns the current value of MM1. This function is only available
6458 @return The current value of MM1.
6469 Reads the current value of 64-bit MMX Register #2 (MM2).
6471 Reads and returns the current value of MM2. This function is only available
6474 @return The current value of MM2.
6485 Reads the current value of 64-bit MMX Register #3 (MM3).
6487 Reads and returns the current value of MM3. This function is only available
6490 @return The current value of MM3.
6501 Reads the current value of 64-bit MMX Register #4 (MM4).
6503 Reads and returns the current value of MM4. This function is only available
6506 @return The current value of MM4.
6517 Reads the current value of 64-bit MMX Register #5 (MM5).
6519 Reads and returns the current value of MM5. This function is only available
6522 @return The current value of MM5.
6533 Reads the current value of 64-bit MMX Register #6 (MM6).
6535 Reads and returns the current value of MM6. This function is only available
6538 @return The current value of MM6.
6549 Reads the current value of 64-bit MMX Register #7 (MM7).
6551 Reads and returns the current value of MM7. This function is only available
6554 @return The current value of MM7.
6565 Writes the current value of 64-bit MMX Register #0 (MM0).
6567 Writes the current value of MM0. This function is only available on IA32 and
6570 @param Value The 64-bit value to write to MM0.
6581 Writes the current value of 64-bit MMX Register #1 (MM1).
6583 Writes the current value of MM1. This function is only available on IA32 and
6586 @param Value The 64-bit value to write to MM1.
6597 Writes the current value of 64-bit MMX Register #2 (MM2).
6599 Writes the current value of MM2. This function is only available on IA32 and
6602 @param Value The 64-bit value to write to MM2.
6613 Writes the current value of 64-bit MMX Register #3 (MM3).
6615 Writes the current value of MM3. This function is only available on IA32 and
6618 @param Value The 64-bit value to write to MM3.
6629 Writes the current value of 64-bit MMX Register #4 (MM4).
6631 Writes the current value of MM4. This function is only available on IA32 and
6634 @param Value The 64-bit value to write to MM4.
6645 Writes the current value of 64-bit MMX Register #5 (MM5).
6647 Writes the current value of MM5. This function is only available on IA32 and
6650 @param Value The 64-bit value to write to MM5.
6661 Writes the current value of 64-bit MMX Register #6 (MM6).
6663 Writes the current value of MM6. This function is only available on IA32 and
6666 @param Value The 64-bit value to write to MM6.
6677 Writes the current value of 64-bit MMX Register #7 (MM7).
6679 Writes the current value of MM7. This function is only available on IA32 and
6682 @param Value The 64-bit value to write to MM7.
6693 Reads the current value of Time Stamp Counter (TSC).
6695 Reads and returns the current value of TSC. This function is only available
6698 @return The current value of TSC
6709 Reads the current value of a Performance Counter (PMC).
6711 Reads and returns the current value of performance counter specified by
6712 Index. This function is only available on IA-32 and x64.
6714 @param Index The 32-bit Performance Counter index to read.
6716 @return The value of the PMC specified by Index.
6727 Sets up a monitor buffer that is used by AsmMwait().
6729 Executes a MONITOR instruction with the register state specified by Eax, Ecx
6730 and Edx. Returns Eax. This function is only available on IA-32 and x64.
6732 @param Eax The value to load into EAX or RAX before executing the MONITOR
6734 @param Ecx The value to load into ECX or RCX before executing the MONITOR
6736 @param Edx The value to load into EDX or RDX before executing the MONITOR
6752 Executes an MWAIT instruction.
6754 Executes an MWAIT instruction with the register state specified by Eax and
6755 Ecx. Returns Eax. This function is only available on IA-32 and x64.
6757 @param Eax The value to load into EAX or RAX before executing the MONITOR
6759 @param Ecx The value to load into ECX or RCX before executing the MONITOR
6774 Executes a WBINVD instruction.
6776 Executes a WBINVD instruction. This function is only available on IA-32 and
6788 Executes a INVD instruction.
6790 Executes a INVD instruction. This function is only available on IA-32 and
6802 Flushes a cache line from all the instruction and data caches within the
6803 coherency domain of the CPU.
6805 Flushed the cache line specified by LinearAddress, and returns LinearAddress.
6806 This function is only available on IA-32 and x64.
6808 @param LinearAddress The address of the cache line to flush. If the CPU is
6809 in a physical addressing mode, then LinearAddress is a
6810 physical address. If the CPU is in a virtual
6811 addressing mode, then LinearAddress is a virtual
6814 @return LinearAddress
6819 IN VOID
*LinearAddress
6824 Enables the 32-bit paging mode on the CPU.
6826 Enables the 32-bit paging mode on the CPU. CR0, CR3, CR4, and the page tables
6827 must be properly initialized prior to calling this service. This function
6828 assumes the current execution mode is 32-bit protected mode. This function is
6829 only available on IA-32. After the 32-bit paging mode is enabled, control is
6830 transferred to the function specified by EntryPoint using the new stack
6831 specified by NewStack and passing in the parameters specified by Context1 and
6832 Context2. Context1 and Context2 are optional and may be NULL. The function
6833 EntryPoint must never return.
6835 If the current execution mode is not 32-bit protected mode, then ASSERT().
6836 If EntryPoint is NULL, then ASSERT().
6837 If NewStack is NULL, then ASSERT().
6839 There are a number of constraints that must be followed before calling this
6841 1) Interrupts must be disabled.
6842 2) The caller must be in 32-bit protected mode with flat descriptors. This
6843 means all descriptors must have a base of 0 and a limit of 4GB.
6844 3) CR0 and CR4 must be compatible with 32-bit protected mode with flat
6846 4) CR3 must point to valid page tables that will be used once the transition
6847 is complete, and those page tables must guarantee that the pages for this
6848 function and the stack are identity mapped.
6850 @param EntryPoint A pointer to function to call with the new stack after
6852 @param Context1 A pointer to the context to pass into the EntryPoint
6853 function as the first parameter after paging is enabled.
6854 @param Context2 A pointer to the context to pass into the EntryPoint
6855 function as the second parameter after paging is enabled.
6856 @param NewStack A pointer to the new stack to use for the EntryPoint
6857 function after paging is enabled.
6863 IN SWITCH_STACK_ENTRY_POINT EntryPoint
,
6864 IN VOID
*Context1
, OPTIONAL
6865 IN VOID
*Context2
, OPTIONAL
6871 Disables the 32-bit paging mode on the CPU.
6873 Disables the 32-bit paging mode on the CPU and returns to 32-bit protected
6874 mode. This function assumes the current execution mode is 32-paged protected
6875 mode. This function is only available on IA-32. After the 32-bit paging mode
6876 is disabled, control is transferred to the function specified by EntryPoint
6877 using the new stack specified by NewStack and passing in the parameters
6878 specified by Context1 and Context2. Context1 and Context2 are optional and
6879 may be NULL. The function EntryPoint must never return.
6881 If the current execution mode is not 32-bit paged mode, then ASSERT().
6882 If EntryPoint is NULL, then ASSERT().
6883 If NewStack is NULL, then ASSERT().
6885 There are a number of constraints that must be followed before calling this
6887 1) Interrupts must be disabled.
6888 2) The caller must be in 32-bit paged mode.
6889 3) CR0, CR3, and CR4 must be compatible with 32-bit paged mode.
6890 4) CR3 must point to valid page tables that guarantee that the pages for
6891 this function and the stack are identity mapped.
6893 @param EntryPoint A pointer to function to call with the new stack after
6895 @param Context1 A pointer to the context to pass into the EntryPoint
6896 function as the first parameter after paging is disabled.
6897 @param Context2 A pointer to the context to pass into the EntryPoint
6898 function as the second parameter after paging is
6900 @param NewStack A pointer to the new stack to use for the EntryPoint
6901 function after paging is disabled.
6906 AsmDisablePaging32 (
6907 IN SWITCH_STACK_ENTRY_POINT EntryPoint
,
6908 IN VOID
*Context1
, OPTIONAL
6909 IN VOID
*Context2
, OPTIONAL
6915 Enables the 64-bit paging mode on the CPU.
6917 Enables the 64-bit paging mode on the CPU. CR0, CR3, CR4, and the page tables
6918 must be properly initialized prior to calling this service. This function
6919 assumes the current execution mode is 32-bit protected mode with flat
6920 descriptors. This function is only available on IA-32. After the 64-bit
6921 paging mode is enabled, control is transferred to the function specified by
6922 EntryPoint using the new stack specified by NewStack and passing in the
6923 parameters specified by Context1 and Context2. Context1 and Context2 are
6924 optional and may be 0. The function EntryPoint must never return.
6926 If the current execution mode is not 32-bit protected mode with flat
6927 descriptors, then ASSERT().
6928 If EntryPoint is 0, then ASSERT().
6929 If NewStack is 0, then ASSERT().
6931 @param Cs The 16-bit selector to load in the CS before EntryPoint
6932 is called. The descriptor in the GDT that this selector
6933 references must be setup for long mode.
6934 @param EntryPoint The 64-bit virtual address of the function to call with
6935 the new stack after paging is enabled.
6936 @param Context1 The 64-bit virtual address of the context to pass into
6937 the EntryPoint function as the first parameter after
6939 @param Context2 The 64-bit virtual address of the context to pass into
6940 the EntryPoint function as the second parameter after
6942 @param NewStack The 64-bit virtual address of the new stack to use for
6943 the EntryPoint function after paging is enabled.
6950 IN UINT64 EntryPoint
,
6951 IN UINT64 Context1
, OPTIONAL
6952 IN UINT64 Context2
, OPTIONAL
6958 Disables the 64-bit paging mode on the CPU.
6960 Disables the 64-bit paging mode on the CPU and returns to 32-bit protected
6961 mode. This function assumes the current execution mode is 64-paging mode.
6962 This function is only available on x64. After the 64-bit paging mode is
6963 disabled, control is transferred to the function specified by EntryPoint
6964 using the new stack specified by NewStack and passing in the parameters
6965 specified by Context1 and Context2. Context1 and Context2 are optional and
6966 may be 0. The function EntryPoint must never return.
6968 If the current execution mode is not 64-bit paged mode, then ASSERT().
6969 If EntryPoint is 0, then ASSERT().
6970 If NewStack is 0, then ASSERT().
6972 @param Cs The 16-bit selector to load in the CS before EntryPoint
6973 is called. The descriptor in the GDT that this selector
6974 references must be setup for 32-bit protected mode.
6975 @param EntryPoint The 64-bit virtual address of the function to call with
6976 the new stack after paging is disabled.
6977 @param Context1 The 64-bit virtual address of the context to pass into
6978 the EntryPoint function as the first parameter after
6980 @param Context2 The 64-bit virtual address of the context to pass into
6981 the EntryPoint function as the second parameter after
6983 @param NewStack The 64-bit virtual address of the new stack to use for
6984 the EntryPoint function after paging is disabled.
6989 AsmDisablePaging64 (
6991 IN UINT32 EntryPoint
,
6992 IN UINT32 Context1
, OPTIONAL
6993 IN UINT32 Context2
, OPTIONAL
6999 // 16-bit thunking services
7003 Retrieves the properties for 16-bit thunk functions.
7005 Computes the size of the buffer and stack below 1MB required to use the
7006 AsmPrepareThunk16(), AsmThunk16() and AsmPrepareAndThunk16() functions. This
7007 buffer size is returned in RealModeBufferSize, and the stack size is returned
7008 in ExtraStackSize. If parameters are passed to the 16-bit real mode code,
7009 then the actual minimum stack size is ExtraStackSize plus the maximum number
7010 of bytes that need to be passed to the 16-bit real mode code.
7012 If RealModeBufferSize is NULL, then ASSERT().
7013 If ExtraStackSize is NULL, then ASSERT().
7015 @param RealModeBufferSize A pointer to the size of the buffer below 1MB
7016 required to use the 16-bit thunk functions.
7017 @param ExtraStackSize A pointer to the extra size of stack below 1MB
7018 that the 16-bit thunk functions require for
7019 temporary storage in the transition to and from
7025 AsmGetThunk16Properties (
7026 OUT UINT32
*RealModeBufferSize
,
7027 OUT UINT32
*ExtraStackSize
7032 Prepares all structures a code required to use AsmThunk16().
7034 Prepares all structures and code required to use AsmThunk16().
7036 This interface is limited to be used in either physical mode or virtual modes with paging enabled where the
7037 virtual to physical mappings for ThunkContext.RealModeBuffer is mapped 1:1.
7039 If ThunkContext is NULL, then ASSERT().
7041 @param ThunkContext A pointer to the context structure that describes the
7042 16-bit real mode code to call.
7048 OUT THUNK_CONTEXT
*ThunkContext
7053 Transfers control to a 16-bit real mode entry point and returns the results.
7055 Transfers control to a 16-bit real mode entry point and returns the results.
7056 AsmPrepareThunk16() must be called with ThunkContext before this function is used.
7057 This function must be called with interrupts disabled.
7059 The register state from the RealModeState field of ThunkContext is restored just prior
7060 to calling the 16-bit real mode entry point. This includes the EFLAGS field of RealModeState,
7061 which is used to set the interrupt state when a 16-bit real mode entry point is called.
7062 Control is transferred to the 16-bit real mode entry point specified by the CS and Eip fields of RealModeState.
7063 The stack is initialized to the SS and ESP fields of RealModeState. Any parameters passed to
7064 the 16-bit real mode code must be populated by the caller at SS:ESP prior to calling this function.
7065 The 16-bit real mode entry point is invoked with a 16-bit CALL FAR instruction,
7066 so when accessing stack contents, the 16-bit real mode code must account for the 16-bit segment
7067 and 16-bit offset of the return address that were pushed onto the stack. The 16-bit real mode entry
7068 point must exit with a RETF instruction. The register state is captured into RealModeState immediately
7069 after the RETF instruction is executed.
7071 If EFLAGS specifies interrupts enabled, or any of the 16-bit real mode code enables interrupts,
7072 or any of the 16-bit real mode code makes a SW interrupt, then the caller is responsible for making sure
7073 the IDT at address 0 is initialized to handle any HW or SW interrupts that may occur while in 16-bit real mode.
7075 If EFLAGS specifies interrupts enabled, or any of the 16-bit real mode code enables interrupts,
7076 then the caller is responsible for making sure the 8259 PIC is in a state compatible with 16-bit real mode.
7077 This includes the base vectors, the interrupt masks, and the edge/level trigger mode.
7079 If THUNK_ATTRIBUTE_BIG_REAL_MODE is set in the ThunkAttributes field of ThunkContext, then the user code
7080 is invoked in big real mode. Otherwise, the user code is invoked in 16-bit real mode with 64KB segment limits.
7082 If neither THUNK_ATTRIBUTE_DISABLE_A20_MASK_INT_15 nor THUNK_ATTRIBUTE_DISABLE_A20_MASK_KBD_CTRL are set in
7083 ThunkAttributes, then it is assumed that the user code did not enable the A20 mask, and no attempt is made to
7084 disable the A20 mask.
7086 If THUNK_ATTRIBUTE_DISABLE_A20_MASK_INT_15 is set and THUNK_ATTRIBUTE_DISABLE_A20_MASK_KBD_CTRL is clear in
7087 ThunkAttributes, then attempt to use the INT 15 service to disable the A20 mask. If this INT 15 call fails,
7088 then attempt to disable the A20 mask by directly accessing the 8042 keyboard controller I/O ports.
7090 If THUNK_ATTRIBUTE_DISABLE_A20_MASK_INT_15 is clear and THUNK_ATTRIBUTE_DISABLE_A20_MASK_KBD_CTRL is set in
7091 ThunkAttributes, then attempt to disable the A20 mask by directly accessing the 8042 keyboard controller I/O ports.
7093 If ThunkContext is NULL, then ASSERT().
7094 If AsmPrepareThunk16() was not previously called with ThunkContext, then ASSERT().
7095 If both THUNK_ATTRIBUTE_DISABLE_A20_MASK_INT_15 and THUNK_ATTRIBUTE_DISABLE_A20_MASK_KBD_CTRL are set in
7096 ThunkAttributes, then ASSERT().
7098 This interface is limited to be used in either physical mode or virtual modes with paging enabled where the
7099 virtual to physical mappings for ThunkContext.RealModeBuffer is mapped 1:1.
7101 @param ThunkContext A pointer to the context structure that describes the
7102 16-bit real mode code to call.
7108 IN OUT THUNK_CONTEXT
*ThunkContext
7113 Prepares all structures and code for a 16-bit real mode thunk, transfers
7114 control to a 16-bit real mode entry point, and returns the results.
7116 Prepares all structures and code for a 16-bit real mode thunk, transfers
7117 control to a 16-bit real mode entry point, and returns the results. If the
7118 caller only need to perform a single 16-bit real mode thunk, then this
7119 service should be used. If the caller intends to make more than one 16-bit
7120 real mode thunk, then it is more efficient if AsmPrepareThunk16() is called
7121 once and AsmThunk16() can be called for each 16-bit real mode thunk.
7123 This interface is limited to be used in either physical mode or virtual modes with paging enabled where the
7124 virtual to physical mappings for ThunkContext.RealModeBuffer is mapped 1:1.
7126 See AsmPrepareThunk16() and AsmThunk16() for the detailed description and ASSERT() conditions.
7128 @param ThunkContext A pointer to the context structure that describes the
7129 16-bit real mode code to call.
7134 AsmPrepareAndThunk16 (
7135 IN OUT THUNK_CONTEXT
*ThunkContext