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 PcdVerifyNodeInList is TRUE and 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 PcdVerifyNodeInList is TRUE and Node is not a node in List the and Node is not equal
1420 to List, then ASSERT().
1422 @param List A pointer to the head node of a doubly linked list.
1423 @param Node A pointer to a node in the doubly linked list.
1425 @retval TRUE Node is one of the nodes in the doubly linked list.
1426 @retval FALSE Node is not one of the nodes in the doubly linked list.
1432 IN CONST LIST_ENTRY
*List
,
1433 IN CONST LIST_ENTRY
*Node
1438 Determines if a node the last node in a doubly linked list.
1440 Returns TRUE if Node is the last node in the doubly linked list specified by
1441 List. Otherwise, FALSE is returned. List must have been initialized with
1442 INTIALIZE_LIST_HEAD_VARIABLE() or InitializeListHead().
1444 If List is NULL, then ASSERT().
1445 If Node is NULL, then ASSERT().
1446 If List was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or
1447 InitializeListHead(), then ASSERT().
1448 If PcdMaximumLinkedListLenth is not zero, and the number of nodes
1449 in List, including the List node, is greater than or equal to
1450 PcdMaximumLinkedListLength, then ASSERT().
1451 If PcdVerifyNodeInList is TRUE and Node is not a node in List, then ASSERT().
1453 @param List A pointer to the head node of a doubly linked list.
1454 @param Node A pointer to a node in the doubly linked list.
1456 @retval TRUE Node is the last node in the linked list.
1457 @retval FALSE Node is not the last node in the linked list.
1463 IN CONST LIST_ENTRY
*List
,
1464 IN CONST LIST_ENTRY
*Node
1469 Swaps the location of two nodes in a doubly linked list, and returns the
1470 first node after the swap.
1472 If FirstEntry is identical to SecondEntry, then SecondEntry is returned.
1473 Otherwise, the location of the FirstEntry node is swapped with the location
1474 of the SecondEntry node in a doubly linked list. SecondEntry must be in the
1475 same double linked list as FirstEntry and that double linked list must have
1476 been initialized with INTIALIZE_LIST_HEAD_VARIABLE() or InitializeListHead().
1477 SecondEntry is returned after the nodes are swapped.
1479 If FirstEntry is NULL, then ASSERT().
1480 If SecondEntry is NULL, then ASSERT().
1481 If PcdVerifyNodeInList is TRUE and SecondEntry and FirstEntry are not in the
1482 same linked list, then ASSERT().
1483 If PcdMaximumLinkedListLength is not zero, and the number of nodes in the
1484 linked list containing the FirstEntry and SecondEntry nodes, including
1485 the FirstEntry and SecondEntry nodes, is greater than or equal to
1486 PcdMaximumLinkedListLength, then ASSERT().
1488 @param FirstEntry A pointer to a node in a linked list.
1489 @param SecondEntry A pointer to another node in the same linked list.
1491 @return SecondEntry.
1497 IN OUT LIST_ENTRY
*FirstEntry
,
1498 IN OUT LIST_ENTRY
*SecondEntry
1503 Removes a node from a doubly linked list, and returns the node that follows
1506 Removes the node Entry from a doubly linked list. It is up to the caller of
1507 this function to release the memory used by this node if that is required. On
1508 exit, the node following Entry in the doubly linked list is returned. If
1509 Entry is the only node in the linked list, then the head node of the linked
1512 If Entry is NULL, then ASSERT().
1513 If Entry is the head node of an empty list, then ASSERT().
1514 If PcdMaximumLinkedListLength is not zero, and the number of nodes in the
1515 linked list containing Entry, including the Entry node, is greater than
1516 or equal to PcdMaximumLinkedListLength, then ASSERT().
1518 @param Entry A pointer to a node in a linked list.
1526 IN CONST LIST_ENTRY
*Entry
1534 Shifts a 64-bit integer left between 0 and 63 bits. The low bits are filled
1535 with zeros. The shifted value is returned.
1537 This function shifts the 64-bit value Operand to the left by Count bits. The
1538 low Count bits are set to zero. The shifted value is returned.
1540 If Count is greater than 63, then ASSERT().
1542 @param Operand The 64-bit operand to shift left.
1543 @param Count The number of bits to shift left.
1545 @return Operand << Count.
1557 Shifts a 64-bit integer right between 0 and 63 bits. This high bits are
1558 filled with zeros. The shifted value is returned.
1560 This function shifts the 64-bit value Operand to the right by Count bits. The
1561 high Count bits are set to zero. The shifted value is returned.
1563 If Count is greater than 63, then ASSERT().
1565 @param Operand The 64-bit operand to shift right.
1566 @param Count The number of bits to shift right.
1568 @return Operand >> Count
1580 Shifts a 64-bit integer right between 0 and 63 bits. The high bits are filled
1581 with original integer's bit 63. The shifted value is returned.
1583 This function shifts the 64-bit value Operand to the right by Count bits. The
1584 high Count bits are set to bit 63 of Operand. The shifted value is returned.
1586 If Count is greater than 63, then ASSERT().
1588 @param Operand The 64-bit operand to shift right.
1589 @param Count The number of bits to shift right.
1591 @return Operand >> Count
1603 Rotates a 32-bit integer left between 0 and 31 bits, filling the low bits
1604 with the high bits that were rotated.
1606 This function rotates the 32-bit value Operand to the left by Count bits. The
1607 low Count bits are fill with the high Count bits of Operand. The rotated
1610 If Count is greater than 31, then ASSERT().
1612 @param Operand The 32-bit operand to rotate left.
1613 @param Count The number of bits to rotate left.
1615 @return Operand << Count
1627 Rotates a 32-bit integer right between 0 and 31 bits, filling the high bits
1628 with the low bits that were rotated.
1630 This function rotates the 32-bit value Operand to the right by Count bits.
1631 The high Count bits are fill with the low Count bits of Operand. The rotated
1634 If Count is greater than 31, then ASSERT().
1636 @param Operand The 32-bit operand to rotate right.
1637 @param Count The number of bits to rotate right.
1639 @return Operand >> Count
1651 Rotates a 64-bit integer left between 0 and 63 bits, filling the low bits
1652 with the high bits that were rotated.
1654 This function rotates the 64-bit value Operand to the left by Count bits. The
1655 low Count bits are fill with the high Count bits of Operand. The rotated
1658 If Count is greater than 63, then ASSERT().
1660 @param Operand The 64-bit operand to rotate left.
1661 @param Count The number of bits to rotate left.
1663 @return Operand << Count
1675 Rotates a 64-bit integer right between 0 and 63 bits, filling the high bits
1676 with the high low bits that were rotated.
1678 This function rotates the 64-bit value Operand to the right by Count bits.
1679 The high Count bits are fill with the low Count bits of Operand. The rotated
1682 If Count is greater than 63, then ASSERT().
1684 @param Operand The 64-bit operand to rotate right.
1685 @param Count The number of bits to rotate right.
1687 @return Operand >> Count
1699 Returns the bit position of the lowest bit set in a 32-bit value.
1701 This function computes the bit position of the lowest bit set in the 32-bit
1702 value specified by Operand. If Operand is zero, then -1 is returned.
1703 Otherwise, a value between 0 and 31 is returned.
1705 @param Operand The 32-bit operand to evaluate.
1707 @retval 0..31 The lowest bit set in Operand was found.
1708 @retval -1 Operand is zero.
1719 Returns the bit position of the lowest bit set in a 64-bit value.
1721 This function computes the bit position of the lowest bit set in the 64-bit
1722 value specified by Operand. If Operand is zero, then -1 is returned.
1723 Otherwise, a value between 0 and 63 is returned.
1725 @param Operand The 64-bit operand to evaluate.
1727 @retval 0..63 The lowest bit set in Operand was found.
1728 @retval -1 Operand is zero.
1740 Returns the bit position of the highest bit set in a 32-bit value. Equivalent
1743 This function computes the bit position of the highest bit set in the 32-bit
1744 value specified by Operand. If Operand is zero, then -1 is returned.
1745 Otherwise, a value between 0 and 31 is returned.
1747 @param Operand The 32-bit operand to evaluate.
1749 @retval 0..31 Position of the highest bit set in Operand if found.
1750 @retval -1 Operand is zero.
1761 Returns the bit position of the highest bit set in a 64-bit value. Equivalent
1764 This function computes the bit position of the highest bit set in the 64-bit
1765 value specified by Operand. If Operand is zero, then -1 is returned.
1766 Otherwise, a value between 0 and 63 is returned.
1768 @param Operand The 64-bit operand to evaluate.
1770 @retval 0..63 Position of the highest bit set in Operand if found.
1771 @retval -1 Operand is zero.
1782 Returns the value of the highest bit set in a 32-bit value. Equivalent to
1785 This function computes the value of the highest bit set in the 32-bit value
1786 specified by Operand. If Operand is zero, then zero is returned.
1788 @param Operand The 32-bit operand to evaluate.
1790 @return 1 << HighBitSet32(Operand)
1791 @retval 0 Operand is zero.
1802 Returns the value of the highest bit set in a 64-bit value. Equivalent to
1805 This function computes the value of the highest bit set in the 64-bit value
1806 specified by Operand. If Operand is zero, then zero is returned.
1808 @param Operand The 64-bit operand to evaluate.
1810 @return 1 << HighBitSet64(Operand)
1811 @retval 0 Operand is zero.
1822 Switches the endianess of a 16-bit integer.
1824 This function swaps the bytes in a 16-bit unsigned value to switch the value
1825 from little endian to big endian or vice versa. The byte swapped value is
1828 @param Value A 16-bit unsigned value.
1830 @return The byte swapped Value.
1841 Switches the endianess of a 32-bit integer.
1843 This function swaps the bytes in a 32-bit unsigned value to switch the value
1844 from little endian to big endian or vice versa. The byte swapped value is
1847 @param Value A 32-bit unsigned value.
1849 @return The byte swapped Value.
1860 Switches the endianess of a 64-bit integer.
1862 This function swaps the bytes in a 64-bit unsigned value to switch the value
1863 from little endian to big endian or vice versa. The byte swapped value is
1866 @param Value A 64-bit unsigned value.
1868 @return The byte swapped Value.
1879 Multiples a 64-bit unsigned integer by a 32-bit unsigned integer and
1880 generates a 64-bit unsigned result.
1882 This function multiples the 64-bit unsigned value Multiplicand by the 32-bit
1883 unsigned value Multiplier and generates a 64-bit unsigned result. This 64-
1884 bit unsigned result is returned.
1886 @param Multiplicand A 64-bit unsigned value.
1887 @param Multiplier A 32-bit unsigned value.
1889 @return Multiplicand * Multiplier
1895 IN UINT64 Multiplicand
,
1896 IN UINT32 Multiplier
1901 Multiples a 64-bit unsigned integer by a 64-bit unsigned integer and
1902 generates a 64-bit unsigned result.
1904 This function multiples the 64-bit unsigned value Multiplicand by the 64-bit
1905 unsigned value Multiplier and generates a 64-bit unsigned result. This 64-
1906 bit unsigned result is returned.
1908 @param Multiplicand A 64-bit unsigned value.
1909 @param Multiplier A 64-bit unsigned value.
1911 @return Multiplicand * Multiplier
1917 IN UINT64 Multiplicand
,
1918 IN UINT64 Multiplier
1923 Multiples a 64-bit signed integer by a 64-bit signed integer and generates a
1924 64-bit signed result.
1926 This function multiples the 64-bit signed value Multiplicand by the 64-bit
1927 signed value Multiplier and generates a 64-bit signed result. This 64-bit
1928 signed result is returned.
1930 @param Multiplicand A 64-bit signed value.
1931 @param Multiplier A 64-bit signed value.
1933 @return Multiplicand * Multiplier
1939 IN INT64 Multiplicand
,
1945 Divides a 64-bit unsigned integer by a 32-bit unsigned integer and generates
1946 a 64-bit unsigned result.
1948 This function divides the 64-bit unsigned value Dividend by the 32-bit
1949 unsigned value Divisor and generates a 64-bit unsigned quotient. This
1950 function returns the 64-bit unsigned quotient.
1952 If Divisor is 0, then ASSERT().
1954 @param Dividend A 64-bit unsigned value.
1955 @param Divisor A 32-bit unsigned value.
1957 @return Dividend / Divisor
1969 Divides a 64-bit unsigned integer by a 32-bit unsigned integer and generates
1970 a 32-bit unsigned remainder.
1972 This function divides the 64-bit unsigned value Dividend by the 32-bit
1973 unsigned value Divisor and generates a 32-bit remainder. This function
1974 returns the 32-bit unsigned remainder.
1976 If Divisor is 0, then ASSERT().
1978 @param Dividend A 64-bit unsigned value.
1979 @param Divisor A 32-bit unsigned value.
1981 @return Dividend % Divisor
1993 Divides a 64-bit unsigned integer by a 32-bit unsigned integer and generates
1994 a 64-bit unsigned result and an optional 32-bit unsigned remainder.
1996 This function divides the 64-bit unsigned value Dividend by the 32-bit
1997 unsigned value Divisor and generates a 64-bit unsigned quotient. If Remainder
1998 is not NULL, then the 32-bit unsigned remainder is returned in Remainder.
1999 This function returns the 64-bit unsigned quotient.
2001 If Divisor is 0, then ASSERT().
2003 @param Dividend A 64-bit unsigned value.
2004 @param Divisor A 32-bit unsigned value.
2005 @param Remainder A pointer to a 32-bit unsigned value. This parameter is
2006 optional and may be NULL.
2008 @return Dividend / Divisor
2013 DivU64x32Remainder (
2016 OUT UINT32
*Remainder OPTIONAL
2021 Divides a 64-bit unsigned integer by a 64-bit unsigned integer and generates
2022 a 64-bit unsigned result and an optional 64-bit unsigned remainder.
2024 This function divides the 64-bit unsigned value Dividend by the 64-bit
2025 unsigned value Divisor and generates a 64-bit unsigned quotient. If Remainder
2026 is not NULL, then the 64-bit unsigned remainder is returned in Remainder.
2027 This function returns the 64-bit unsigned quotient.
2029 If Divisor is 0, then ASSERT().
2031 @param Dividend A 64-bit unsigned value.
2032 @param Divisor A 64-bit unsigned value.
2033 @param Remainder A pointer to a 64-bit unsigned value. This parameter is
2034 optional and may be NULL.
2036 @return Dividend / Divisor
2041 DivU64x64Remainder (
2044 OUT UINT64
*Remainder OPTIONAL
2049 Divides a 64-bit signed integer by a 64-bit signed integer and generates a
2050 64-bit signed result and a optional 64-bit signed remainder.
2052 This function divides the 64-bit signed value Dividend by the 64-bit signed
2053 value Divisor and generates a 64-bit signed quotient. If Remainder is not
2054 NULL, then the 64-bit signed remainder is returned in Remainder. This
2055 function returns the 64-bit signed quotient.
2057 It is the caller's responsibility to not call this function with a Divisor of 0.
2058 If Divisor is 0, then the quotient and remainder should be assumed to be
2059 the largest negative integer.
2061 If Divisor is 0, then ASSERT().
2063 @param Dividend A 64-bit signed value.
2064 @param Divisor A 64-bit signed value.
2065 @param Remainder A pointer to a 64-bit signed value. This parameter is
2066 optional and may be NULL.
2068 @return Dividend / Divisor
2073 DivS64x64Remainder (
2076 OUT INT64
*Remainder OPTIONAL
2081 Reads a 16-bit value from memory that may be unaligned.
2083 This function returns the 16-bit value pointed to by Buffer. The function
2084 guarantees that the read operation does not produce an alignment fault.
2086 If the Buffer is NULL, then ASSERT().
2088 @param Buffer Pointer to a 16-bit value that may be unaligned.
2090 @return The 16-bit value read from Buffer.
2096 IN CONST UINT16
*Buffer
2101 Writes a 16-bit value to memory that may be unaligned.
2103 This function writes the 16-bit value specified by Value to Buffer. Value is
2104 returned. The function guarantees that the write operation does not produce
2107 If the Buffer is NULL, then ASSERT().
2109 @param Buffer Pointer to a 16-bit value that may be unaligned.
2110 @param Value 16-bit value to write to Buffer.
2112 @return The 16-bit value to write to Buffer.
2124 Reads a 24-bit value from memory that may be unaligned.
2126 This function returns the 24-bit value pointed to by Buffer. The function
2127 guarantees that the read operation does not produce an alignment fault.
2129 If the Buffer is NULL, then ASSERT().
2131 @param Buffer Pointer to a 24-bit value that may be unaligned.
2133 @return The 24-bit value read from Buffer.
2139 IN CONST UINT32
*Buffer
2144 Writes a 24-bit value to memory that may be unaligned.
2146 This function writes the 24-bit value specified by Value to Buffer. Value is
2147 returned. The function guarantees that the write operation does not produce
2150 If the Buffer is NULL, then ASSERT().
2152 @param Buffer Pointer to a 24-bit value that may be unaligned.
2153 @param Value 24-bit value to write to Buffer.
2155 @return The 24-bit value to write to Buffer.
2167 Reads a 32-bit value from memory that may be unaligned.
2169 This function returns the 32-bit value pointed to by Buffer. The function
2170 guarantees that the read operation does not produce an alignment fault.
2172 If the Buffer is NULL, then ASSERT().
2174 @param Buffer Pointer to a 32-bit value that may be unaligned.
2176 @return The 32-bit value read from Buffer.
2182 IN CONST UINT32
*Buffer
2187 Writes a 32-bit value to memory that may be unaligned.
2189 This function writes the 32-bit value specified by Value to Buffer. Value is
2190 returned. The function guarantees that the write operation does not produce
2193 If the Buffer is NULL, then ASSERT().
2195 @param Buffer Pointer to a 32-bit value that may be unaligned.
2196 @param Value 32-bit value to write to Buffer.
2198 @return The 32-bit value to write to Buffer.
2210 Reads a 64-bit value from memory that may be unaligned.
2212 This function returns the 64-bit value pointed to by Buffer. The function
2213 guarantees that the read operation does not produce an alignment fault.
2215 If the Buffer is NULL, then ASSERT().
2217 @param Buffer Pointer to a 64-bit value that may be unaligned.
2219 @return The 64-bit value read from Buffer.
2225 IN CONST UINT64
*Buffer
2230 Writes a 64-bit value to memory that may be unaligned.
2232 This function writes the 64-bit value specified by Value to Buffer. Value is
2233 returned. The function guarantees that the write operation does not produce
2236 If the Buffer is NULL, then ASSERT().
2238 @param Buffer Pointer to a 64-bit value that may be unaligned.
2239 @param Value 64-bit value to write to Buffer.
2241 @return The 64-bit value to write to Buffer.
2253 // Bit Field Functions
2257 Returns a bit field from an 8-bit value.
2259 Returns the bitfield specified by the StartBit and the EndBit from Operand.
2261 If 8-bit operations are not supported, then ASSERT().
2262 If StartBit is greater than 7, then ASSERT().
2263 If EndBit is greater than 7, then ASSERT().
2264 If EndBit is less than StartBit, then ASSERT().
2266 @param Operand Operand on which to perform the bitfield operation.
2267 @param StartBit The ordinal of the least significant bit in the bit field.
2269 @param EndBit The ordinal of the most significant bit in the bit field.
2272 @return The bit field read.
2285 Writes a bit field to an 8-bit value, and returns the result.
2287 Writes Value to the bit field specified by the StartBit and the EndBit in
2288 Operand. All other bits in Operand are preserved. The new 8-bit value is
2291 If 8-bit operations are not supported, then ASSERT().
2292 If StartBit is greater than 7, then ASSERT().
2293 If EndBit is greater than 7, then ASSERT().
2294 If EndBit is less than StartBit, then ASSERT().
2296 @param Operand Operand on which to perform the bitfield operation.
2297 @param StartBit The ordinal of the least significant bit in the bit field.
2299 @param EndBit The ordinal of the most significant bit in the bit field.
2301 @param Value New value of the bit field.
2303 @return The new 8-bit value.
2317 Reads a bit field from an 8-bit value, performs a bitwise OR, and returns the
2320 Performs a bitwise OR between the bit field specified by StartBit
2321 and EndBit in Operand and the value specified by OrData. All other bits in
2322 Operand are preserved. The new 8-bit value is returned.
2324 If 8-bit operations are not supported, then ASSERT().
2325 If StartBit is greater than 7, then ASSERT().
2326 If EndBit is greater than 7, then ASSERT().
2327 If EndBit is less than StartBit, then ASSERT().
2329 @param Operand Operand on which to perform the bitfield operation.
2330 @param StartBit The ordinal of the least significant bit in the bit field.
2332 @param EndBit The ordinal of the most significant bit in the bit field.
2334 @param OrData The value to OR with the read value from the value
2336 @return The new 8-bit value.
2350 Reads a bit field from an 8-bit value, performs a bitwise AND, and returns
2353 Performs a bitwise AND between the bit field specified by StartBit and EndBit
2354 in Operand and the value specified by AndData. All other bits in Operand are
2355 preserved. The new 8-bit value is returned.
2357 If 8-bit operations are not supported, then ASSERT().
2358 If StartBit is greater than 7, then ASSERT().
2359 If EndBit is greater than 7, then ASSERT().
2360 If EndBit is less than StartBit, then ASSERT().
2362 @param Operand Operand on which to perform the bitfield operation.
2363 @param StartBit The ordinal of the least significant bit in the bit field.
2365 @param EndBit The ordinal of the most significant bit in the bit field.
2367 @param AndData The value to AND with the read value from the value.
2369 @return The new 8-bit value.
2383 Reads a bit field from an 8-bit value, performs a bitwise AND followed by a
2384 bitwise OR, and returns the result.
2386 Performs a bitwise AND between the bit field specified by StartBit and EndBit
2387 in Operand and the value specified by AndData, followed by a bitwise
2388 OR with value specified by OrData. All other bits in Operand are
2389 preserved. The new 8-bit value is returned.
2391 If 8-bit operations are not supported, then ASSERT().
2392 If StartBit is greater than 7, then ASSERT().
2393 If EndBit is greater than 7, then ASSERT().
2394 If EndBit is less than StartBit, then ASSERT().
2396 @param Operand Operand on which to perform the bitfield operation.
2397 @param StartBit The ordinal of the least significant bit in the bit field.
2399 @param EndBit The ordinal of the most significant bit in the bit field.
2401 @param AndData The value to AND with the read value from the value.
2402 @param OrData The value to OR with the result of the AND operation.
2404 @return The new 8-bit value.
2409 BitFieldAndThenOr8 (
2419 Returns a bit field from a 16-bit value.
2421 Returns the bitfield specified by the StartBit and the EndBit from Operand.
2423 If 16-bit operations are not supported, then ASSERT().
2424 If StartBit is greater than 15, then ASSERT().
2425 If EndBit is greater than 15, then ASSERT().
2426 If EndBit is less than StartBit, then ASSERT().
2428 @param Operand Operand on which to perform the bitfield operation.
2429 @param StartBit The ordinal of the least significant bit in the bit field.
2431 @param EndBit The ordinal of the most significant bit in the bit field.
2434 @return The bit field read.
2447 Writes a bit field to a 16-bit value, and returns the result.
2449 Writes Value to the bit field specified by the StartBit and the EndBit in
2450 Operand. All other bits in Operand are preserved. The new 16-bit value is
2453 If 16-bit operations are not supported, then ASSERT().
2454 If StartBit is greater than 15, then ASSERT().
2455 If EndBit is greater than 15, then ASSERT().
2456 If EndBit is less than StartBit, then ASSERT().
2458 @param Operand Operand on which to perform the bitfield operation.
2459 @param StartBit The ordinal of the least significant bit in the bit field.
2461 @param EndBit The ordinal of the most significant bit in the bit field.
2463 @param Value New value of the bit field.
2465 @return The new 16-bit value.
2479 Reads a bit field from a 16-bit value, performs a bitwise OR, and returns the
2482 Performs a bitwise OR between the bit field specified by StartBit
2483 and EndBit in Operand and the value specified by OrData. All other bits in
2484 Operand are preserved. The new 16-bit value is returned.
2486 If 16-bit operations are not supported, then ASSERT().
2487 If StartBit is greater than 15, then ASSERT().
2488 If EndBit is greater than 15, then ASSERT().
2489 If EndBit is less than StartBit, then ASSERT().
2491 @param Operand Operand on which to perform the bitfield operation.
2492 @param StartBit The ordinal of the least significant bit in the bit field.
2494 @param EndBit The ordinal of the most significant bit in the bit field.
2496 @param OrData The value to OR with the read value from the value
2498 @return The new 16-bit value.
2512 Reads a bit field from a 16-bit value, performs a bitwise AND, and returns
2515 Performs a bitwise AND between the bit field specified by StartBit and EndBit
2516 in Operand and the value specified by AndData. All other bits in Operand are
2517 preserved. The new 16-bit value is returned.
2519 If 16-bit operations are not supported, then ASSERT().
2520 If StartBit is greater than 15, then ASSERT().
2521 If EndBit is greater than 15, then ASSERT().
2522 If EndBit is less than StartBit, then ASSERT().
2524 @param Operand Operand on which to perform the bitfield operation.
2525 @param StartBit The ordinal of the least significant bit in the bit field.
2527 @param EndBit The ordinal of the most significant bit in the bit field.
2529 @param AndData The value to AND with the read value from the value
2531 @return The new 16-bit value.
2545 Reads a bit field from a 16-bit value, performs a bitwise AND followed by a
2546 bitwise OR, and returns the result.
2548 Performs a bitwise AND between the bit field specified by StartBit and EndBit
2549 in Operand and the value specified by AndData, followed by a bitwise
2550 OR with value specified by OrData. All other bits in Operand are
2551 preserved. The new 16-bit value is returned.
2553 If 16-bit operations are not supported, then ASSERT().
2554 If StartBit is greater than 15, then ASSERT().
2555 If EndBit is greater than 15, then ASSERT().
2556 If EndBit is less than StartBit, then ASSERT().
2558 @param Operand Operand on which to perform the bitfield operation.
2559 @param StartBit The ordinal of the least significant bit in the bit field.
2561 @param EndBit The ordinal of the most significant bit in the bit field.
2563 @param AndData The value to AND with the read value from the value.
2564 @param OrData The value to OR with the result of the AND operation.
2566 @return The new 16-bit value.
2571 BitFieldAndThenOr16 (
2581 Returns a bit field from a 32-bit value.
2583 Returns the bitfield specified by the StartBit and the EndBit from Operand.
2585 If 32-bit operations are not supported, then ASSERT().
2586 If StartBit is greater than 31, then ASSERT().
2587 If EndBit is greater than 31, then ASSERT().
2588 If EndBit is less than StartBit, then ASSERT().
2590 @param Operand Operand on which to perform the bitfield operation.
2591 @param StartBit The ordinal of the least significant bit in the bit field.
2593 @param EndBit The ordinal of the most significant bit in the bit field.
2596 @return The bit field read.
2609 Writes a bit field to a 32-bit value, and returns the result.
2611 Writes Value to the bit field specified by the StartBit and the EndBit in
2612 Operand. All other bits in Operand are preserved. The new 32-bit value is
2615 If 32-bit operations are not supported, then ASSERT().
2616 If StartBit is greater than 31, then ASSERT().
2617 If EndBit is greater than 31, then ASSERT().
2618 If EndBit is less than StartBit, then ASSERT().
2620 @param Operand Operand on which to perform the bitfield operation.
2621 @param StartBit The ordinal of the least significant bit in the bit field.
2623 @param EndBit The ordinal of the most significant bit in the bit field.
2625 @param Value New value of the bit field.
2627 @return The new 32-bit value.
2641 Reads a bit field from a 32-bit value, performs a bitwise OR, and returns the
2644 Performs a bitwise OR between the bit field specified by StartBit
2645 and EndBit in Operand and the value specified by OrData. All other bits in
2646 Operand are preserved. The new 32-bit value is returned.
2648 If 32-bit operations are not supported, then ASSERT().
2649 If StartBit is greater than 31, then ASSERT().
2650 If EndBit is greater than 31, then ASSERT().
2651 If EndBit is less than StartBit, then ASSERT().
2653 @param Operand Operand on which to perform the bitfield operation.
2654 @param StartBit The ordinal of the least significant bit in the bit field.
2656 @param EndBit The ordinal of the most significant bit in the bit field.
2658 @param OrData The value to OR with the read value from the value
2660 @return The new 32-bit value.
2674 Reads a bit field from a 32-bit value, performs a bitwise AND, and returns
2677 Performs a bitwise AND between the bit field specified by StartBit and EndBit
2678 in Operand and the value specified by AndData. All other bits in Operand are
2679 preserved. The new 32-bit value is returned.
2681 If 32-bit operations are not supported, then ASSERT().
2682 If StartBit is greater than 31, then ASSERT().
2683 If EndBit is greater than 31, then ASSERT().
2684 If EndBit is less than StartBit, then ASSERT().
2686 @param Operand Operand on which to perform the bitfield operation.
2687 @param StartBit The ordinal of the least significant bit in the bit field.
2689 @param EndBit The ordinal of the most significant bit in the bit field.
2691 @param AndData The value to AND with the read value from the value
2693 @return The new 32-bit value.
2707 Reads a bit field from a 32-bit value, performs a bitwise AND followed by a
2708 bitwise OR, and returns the result.
2710 Performs a bitwise AND between the bit field specified by StartBit and EndBit
2711 in Operand and the value specified by AndData, followed by a bitwise
2712 OR with value specified by OrData. All other bits in Operand are
2713 preserved. The new 32-bit value is returned.
2715 If 32-bit operations are not supported, then ASSERT().
2716 If StartBit is greater than 31, then ASSERT().
2717 If EndBit is greater than 31, then ASSERT().
2718 If EndBit is less than StartBit, then ASSERT().
2720 @param Operand Operand on which to perform the bitfield operation.
2721 @param StartBit The ordinal of the least significant bit in the bit field.
2723 @param EndBit The ordinal of the most significant bit in the bit field.
2725 @param AndData The value to AND with the read value from the value.
2726 @param OrData The value to OR with the result of the AND operation.
2728 @return The new 32-bit value.
2733 BitFieldAndThenOr32 (
2743 Returns a bit field from a 64-bit value.
2745 Returns the bitfield specified by the StartBit and the EndBit from Operand.
2747 If 64-bit operations are not supported, then ASSERT().
2748 If StartBit is greater than 63, then ASSERT().
2749 If EndBit is greater than 63, then ASSERT().
2750 If EndBit is less than StartBit, then ASSERT().
2752 @param Operand Operand on which to perform the bitfield operation.
2753 @param StartBit The ordinal of the least significant bit in the bit field.
2755 @param EndBit The ordinal of the most significant bit in the bit field.
2758 @return The bit field read.
2771 Writes a bit field to a 64-bit value, and returns the result.
2773 Writes Value to the bit field specified by the StartBit and the EndBit in
2774 Operand. All other bits in Operand are preserved. The new 64-bit value is
2777 If 64-bit operations are not supported, then ASSERT().
2778 If StartBit is greater than 63, then ASSERT().
2779 If EndBit is greater than 63, then ASSERT().
2780 If EndBit is less than StartBit, then ASSERT().
2782 @param Operand Operand on which to perform the bitfield operation.
2783 @param StartBit The ordinal of the least significant bit in the bit field.
2785 @param EndBit The ordinal of the most significant bit in the bit field.
2787 @param Value New value of the bit field.
2789 @return The new 64-bit value.
2803 Reads a bit field from a 64-bit value, performs a bitwise OR, and returns the
2806 Performs a bitwise OR between the bit field specified by StartBit
2807 and EndBit in Operand and the value specified by OrData. All other bits in
2808 Operand are preserved. The new 64-bit value is returned.
2810 If 64-bit operations are not supported, then ASSERT().
2811 If StartBit is greater than 63, then ASSERT().
2812 If EndBit is greater than 63, then ASSERT().
2813 If EndBit is less than StartBit, then ASSERT().
2815 @param Operand Operand on which to perform the bitfield operation.
2816 @param StartBit The ordinal of the least significant bit in the bit field.
2818 @param EndBit The ordinal of the most significant bit in the bit field.
2820 @param OrData The value to OR with the read value from the value
2822 @return The new 64-bit value.
2836 Reads a bit field from a 64-bit value, performs a bitwise AND, and returns
2839 Performs a bitwise AND between the bit field specified by StartBit and EndBit
2840 in Operand and the value specified by AndData. All other bits in Operand are
2841 preserved. The new 64-bit value is returned.
2843 If 64-bit operations are not supported, then ASSERT().
2844 If StartBit is greater than 63, then ASSERT().
2845 If EndBit is greater than 63, then ASSERT().
2846 If EndBit is less than StartBit, then ASSERT().
2848 @param Operand Operand on which to perform the bitfield operation.
2849 @param StartBit The ordinal of the least significant bit in the bit field.
2851 @param EndBit The ordinal of the most significant bit in the bit field.
2853 @param AndData The value to AND with the read value from the value
2855 @return The new 64-bit value.
2869 Reads a bit field from a 64-bit value, performs a bitwise AND followed by a
2870 bitwise OR, and returns the result.
2872 Performs a bitwise AND between the bit field specified by StartBit and EndBit
2873 in Operand and the value specified by AndData, followed by a bitwise
2874 OR with value specified by OrData. All other bits in Operand are
2875 preserved. The new 64-bit value is returned.
2877 If 64-bit operations are not supported, then ASSERT().
2878 If StartBit is greater than 63, then ASSERT().
2879 If EndBit is greater than 63, then ASSERT().
2880 If EndBit is less than StartBit, then ASSERT().
2882 @param Operand Operand on which to perform the bitfield operation.
2883 @param StartBit The ordinal of the least significant bit in the bit field.
2885 @param EndBit The ordinal of the most significant bit in the bit field.
2887 @param AndData The value to AND with the read value from the value.
2888 @param OrData The value to OR with the result of the AND operation.
2890 @return The new 64-bit value.
2895 BitFieldAndThenOr64 (
2904 // Base Library Checksum Functions
2908 Returns the sum of all elements in a buffer in unit of UINT8.
2909 During calculation, the carry bits are dropped.
2911 This function calculates the sum of all elements in a buffer
2912 in unit of UINT8. The carry bits in result of addition are dropped.
2913 The result is returned as UINT8. If Length is Zero, then Zero is
2916 If Buffer is NULL, then ASSERT().
2917 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
2919 @param Buffer Pointer to the buffer to carry out the sum operation.
2920 @param Length The size, in bytes, of Buffer.
2922 @return Sum The sum of Buffer with carry bits dropped during additions.
2928 IN CONST UINT8
*Buffer
,
2934 Returns the two's complement checksum of all elements in a buffer
2937 This function first calculates the sum of the 8-bit values in the
2938 buffer specified by Buffer and Length. The carry bits in the result
2939 of addition are dropped. Then, the two's complement of the sum is
2940 returned. If Length is 0, then 0 is returned.
2942 If Buffer is NULL, then ASSERT().
2943 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
2945 @param Buffer Pointer to the buffer to carry out the checksum operation.
2946 @param Length The size, in bytes, of Buffer.
2948 @return Checksum The 2's complement checksum of Buffer.
2953 CalculateCheckSum8 (
2954 IN CONST UINT8
*Buffer
,
2960 Returns the sum of all elements in a buffer of 16-bit values. During
2961 calculation, the carry bits are dropped.
2963 This function calculates the sum of the 16-bit values in the buffer
2964 specified by Buffer and Length. The carry bits in result of addition are dropped.
2965 The 16-bit result is returned. If Length is 0, then 0 is returned.
2967 If Buffer is NULL, then ASSERT().
2968 If Buffer is not aligned on a 16-bit boundary, then ASSERT().
2969 If Length is not aligned on a 16-bit boundary, then ASSERT().
2970 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
2972 @param Buffer Pointer to the buffer to carry out the sum operation.
2973 @param Length The size, in bytes, of Buffer.
2975 @return Sum The sum of Buffer with carry bits dropped during additions.
2981 IN CONST UINT16
*Buffer
,
2987 Returns the two's complement checksum of all elements in a buffer of
2990 This function first calculates the sum of the 16-bit values in the buffer
2991 specified by Buffer and Length. The carry bits in the result of addition
2992 are dropped. Then, the two's complement of the sum is returned. If Length
2993 is 0, then 0 is returned.
2995 If Buffer is NULL, then ASSERT().
2996 If Buffer is not aligned on a 16-bit boundary, then ASSERT().
2997 If Length is not aligned on a 16-bit boundary, then ASSERT().
2998 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
3000 @param Buffer Pointer to the buffer to carry out the checksum operation.
3001 @param Length The size, in bytes, of Buffer.
3003 @return Checksum The 2's complement checksum of Buffer.
3008 CalculateCheckSum16 (
3009 IN CONST UINT16
*Buffer
,
3015 Returns the sum of all elements in a buffer of 32-bit values. During
3016 calculation, the carry bits are dropped.
3018 This function calculates the sum of the 32-bit values in the buffer
3019 specified by Buffer and Length. The carry bits in result of addition are dropped.
3020 The 32-bit result is returned. If Length is 0, then 0 is returned.
3022 If Buffer is NULL, then ASSERT().
3023 If Buffer is not aligned on a 32-bit boundary, then ASSERT().
3024 If Length is not aligned on a 32-bit boundary, then ASSERT().
3025 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
3027 @param Buffer Pointer to the buffer to carry out the sum operation.
3028 @param Length The size, in bytes, of Buffer.
3030 @return Sum The sum of Buffer with carry bits dropped during additions.
3036 IN CONST UINT32
*Buffer
,
3042 Returns the two's complement checksum of all elements in a buffer of
3045 This function first calculates the sum of the 32-bit values in the buffer
3046 specified by Buffer and Length. The carry bits in the result of addition
3047 are dropped. Then, the two's complement of the sum is returned. If Length
3048 is 0, then 0 is returned.
3050 If Buffer is NULL, then ASSERT().
3051 If Buffer is not aligned on a 32-bit boundary, then ASSERT().
3052 If Length is not aligned on a 32-bit boundary, then ASSERT().
3053 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
3055 @param Buffer Pointer to the buffer to carry out the checksum operation.
3056 @param Length The size, in bytes, of Buffer.
3058 @return Checksum The 2's complement checksum of Buffer.
3063 CalculateCheckSum32 (
3064 IN CONST UINT32
*Buffer
,
3070 Returns the sum of all elements in a buffer of 64-bit values. During
3071 calculation, the carry bits are dropped.
3073 This function calculates the sum of the 64-bit values in the buffer
3074 specified by Buffer and Length. The carry bits in result of addition are dropped.
3075 The 64-bit result is returned. If Length is 0, then 0 is returned.
3077 If Buffer is NULL, then ASSERT().
3078 If Buffer is not aligned on a 64-bit boundary, then ASSERT().
3079 If Length is not aligned on a 64-bit boundary, then ASSERT().
3080 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
3082 @param Buffer Pointer to the buffer to carry out the sum operation.
3083 @param Length The size, in bytes, of Buffer.
3085 @return Sum The sum of Buffer with carry bits dropped during additions.
3091 IN CONST UINT64
*Buffer
,
3097 Returns the two's complement checksum of all elements in a buffer of
3100 This function first calculates the sum of the 64-bit values in the buffer
3101 specified by Buffer and Length. The carry bits in the result of addition
3102 are dropped. Then, the two's complement of the sum is returned. If Length
3103 is 0, then 0 is returned.
3105 If Buffer is NULL, then ASSERT().
3106 If Buffer is not aligned on a 64-bit boundary, then ASSERT().
3107 If Length is not aligned on a 64-bit boundary, then ASSERT().
3108 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
3110 @param Buffer Pointer to the buffer to carry out the checksum operation.
3111 @param Length The size, in bytes, of Buffer.
3113 @return Checksum The 2's complement checksum of Buffer.
3118 CalculateCheckSum64 (
3119 IN CONST UINT64
*Buffer
,
3125 // Base Library CPU Functions
3129 Function entry point used when a stack switch is requested with SwitchStack()
3131 @param Context1 Context1 parameter passed into SwitchStack().
3132 @param Context2 Context2 parameter passed into SwitchStack().
3137 (EFIAPI
*SWITCH_STACK_ENTRY_POINT
)(
3138 IN VOID
*Context1
, OPTIONAL
3139 IN VOID
*Context2 OPTIONAL
3144 Used to serialize load and store operations.
3146 All loads and stores that proceed calls to this function are guaranteed to be
3147 globally visible when this function returns.
3158 Saves the current CPU context that can be restored with a call to LongJump()
3161 Saves the current CPU context in the buffer specified by JumpBuffer and
3162 returns 0. The initial call to SetJump() must always return 0. Subsequent
3163 calls to LongJump() cause a non-zero value to be returned by SetJump().
3165 If JumpBuffer is NULL, then ASSERT().
3166 For Itanium processors, if JumpBuffer is not aligned on a 16-byte boundary, then ASSERT().
3168 NOTE: The structure BASE_LIBRARY_JUMP_BUFFER is CPU architecture specific.
3169 The same structure must never be used for more than one CPU architecture context.
3170 For example, a BASE_LIBRARY_JUMP_BUFFER allocated by an IA-32 module must never be used from an x64 module.
3171 SetJump()/LongJump() is not currently supported for the EBC processor type.
3173 @param JumpBuffer A pointer to CPU context buffer.
3175 @retval 0 Indicates a return from SetJump().
3181 OUT BASE_LIBRARY_JUMP_BUFFER
*JumpBuffer
3186 Restores the CPU context that was saved with SetJump().
3188 Restores the CPU context from the buffer specified by JumpBuffer. This
3189 function never returns to the caller. Instead is resumes execution based on
3190 the state of JumpBuffer.
3192 If JumpBuffer is NULL, then ASSERT().
3193 For Itanium processors, if JumpBuffer is not aligned on a 16-byte boundary, then ASSERT().
3194 If Value is 0, then ASSERT().
3196 @param JumpBuffer A pointer to CPU context buffer.
3197 @param Value The value to return when the SetJump() context is
3198 restored and must be non-zero.
3204 IN BASE_LIBRARY_JUMP_BUFFER
*JumpBuffer
,
3210 Enables CPU interrupts.
3221 Disables CPU interrupts.
3232 Disables CPU interrupts and returns the interrupt state prior to the disable
3235 @retval TRUE CPU interrupts were enabled on entry to this call.
3236 @retval FALSE CPU interrupts were disabled on entry to this call.
3241 SaveAndDisableInterrupts (
3247 Enables CPU interrupts for the smallest window required to capture any
3253 EnableDisableInterrupts (
3259 Retrieves the current CPU interrupt state.
3261 Returns TRUE is interrupts are currently enabled. Otherwise
3264 @retval TRUE CPU interrupts are enabled.
3265 @retval FALSE CPU interrupts are disabled.
3276 Set the current CPU interrupt state.
3278 Sets the current CPU interrupt state to the state specified by
3279 InterruptState. If InterruptState is TRUE, then interrupts are enabled. If
3280 InterruptState is FALSE, then interrupts are disabled. InterruptState is
3283 @param InterruptState TRUE if interrupts should enabled. FALSE if
3284 interrupts should be disabled.
3286 @return InterruptState
3292 IN BOOLEAN InterruptState
3297 Requests CPU to pause for a short period of time.
3299 Requests CPU to pause for a short period of time. Typically used in MP
3300 systems to prevent memory starvation while waiting for a spin lock.
3311 Transfers control to a function starting with a new stack.
3313 Transfers control to the function specified by EntryPoint using the
3314 new stack specified by NewStack and passing in the parameters specified
3315 by Context1 and Context2. Context1 and Context2 are optional and may
3316 be NULL. The function EntryPoint must never return. This function
3317 supports a variable number of arguments following the NewStack parameter.
3318 These additional arguments are ignored on IA-32, x64, and EBC architectures.
3319 Itanium processors expect one additional parameter of type VOID * that specifies
3320 the new backing store pointer.
3322 If EntryPoint is NULL, then ASSERT().
3323 If NewStack is NULL, then ASSERT().
3325 @param EntryPoint A pointer to function to call with the new stack.
3326 @param Context1 A pointer to the context to pass into the EntryPoint
3328 @param Context2 A pointer to the context to pass into the EntryPoint
3330 @param NewStack A pointer to the new stack to use for the EntryPoint
3332 @param ... This variable argument list is ignored for IA-32, x64, and EBC architectures.
3333 For Itanium processors, this variable argument list is expected to contain
3334 a single parameter of type VOID * that specifies the new backing
3342 IN SWITCH_STACK_ENTRY_POINT EntryPoint
,
3343 IN VOID
*Context1
, OPTIONAL
3344 IN VOID
*Context2
, OPTIONAL
3351 Generates a breakpoint on the CPU.
3353 Generates a breakpoint on the CPU. The breakpoint must be implemented such
3354 that code can resume normal execution after the breakpoint.
3365 Executes an infinite loop.
3367 Forces the CPU to execute an infinite loop. A debugger may be used to skip
3368 past the loop and the code that follows the loop must execute properly. This
3369 implies that the infinite loop must not cause the code that follow it to be
3379 #if defined (MDE_CPU_IPF)
3382 Flush a range of cache lines in the cache coherency domain of the calling
3385 Flushes the cache lines specified by Address and Length. If Address is not aligned
3386 on a cache line boundary, then entire cache line containing Address is flushed.
3387 If Address + Length is not aligned on a cache line boundary, then the entire cache
3388 line containing Address + Length - 1 is flushed. This function may choose to flush
3389 the entire cache if that is more efficient than flushing the specified range. If
3390 Length is 0, the no cache lines are flushed. Address is returned.
3391 This function is only available on Itanium processors.
3393 If Length is greater than (MAX_ADDRESS - Address + 1), then ASSERT().
3395 @param Address The base address of the instruction lines to invalidate. If
3396 the CPU is in a physical addressing mode, then Address is a
3397 physical address. If the CPU is in a virtual addressing mode,
3398 then Address is a virtual address.
3400 @param Length The number of bytes to invalidate from the instruction cache.
3407 AsmFlushCacheRange (
3414 Executes a FC instruction
3415 Executes a FC instruction on the cache line specified by Address.
3416 The cache line size affected is at least 32-bytes (aligned on a 32-byte boundary).
3417 An implementation may flush a larger region. This function is only available on Itanium processors.
3419 @param Address The Address of cache line to be flushed.
3421 @return The address of FC instruction executed.
3432 Executes a FC.I instruction.
3433 Executes a FC.I instruction on the cache line specified by Address.
3434 The cache line size affected is at least 32-bytes (aligned on a 32-byte boundary).
3435 An implementation may flush a larger region. This function is only available on Itanium processors.
3437 @param Address The Address of cache line to be flushed.
3439 @return The address of FC.I instruction executed.
3450 Reads the current value of a Processor Identifier Register (CPUID).
3452 Reads and returns the current value of Processor Identifier Register specified by Index.
3453 The Index of largest implemented CPUID (One less than the number of implemented CPUID
3454 registers) is determined by CPUID [3] bits {7:0}.
3455 No parameter checking is performed on Index. If the Index value is beyond the
3456 implemented CPUID register range, a Reserved Register/Field fault may occur. The caller
3457 must either guarantee that Index is valid, or the caller must set up fault handlers to
3458 catch the faults. This function is only available on Itanium processors.
3460 @param Index The 8-bit Processor Identifier Register index to read.
3462 @return The current value of Processor Identifier Register specified by Index.
3473 Reads the current value of 64-bit Processor Status Register (PSR).
3474 This function is only available on Itanium processors.
3476 @return The current value of PSR.
3487 Writes the current value of 64-bit Processor Status Register (PSR).
3489 No parameter checking is performed on Value. All bits of Value corresponding to
3490 reserved fields of PSR must be 0 or a Reserved Register/Field fault may occur.
3491 The caller must either guarantee that Value is valid, or the caller must set up
3492 fault handlers to catch the faults. This function is only available on Itanium processors.
3494 @param Value The 64-bit value to write to PSR.
3496 @return The 64-bit value written to the PSR.
3507 Reads the current value of 64-bit Kernel Register #0 (KR0).
3509 Reads and returns the current value of KR0.
3510 This function is only available on Itanium processors.
3512 @return The current value of KR0.
3523 Reads the current value of 64-bit Kernel Register #1 (KR1).
3525 Reads and returns the current value of KR1.
3526 This function is only available on Itanium processors.
3528 @return The current value of KR1.
3539 Reads the current value of 64-bit Kernel Register #2 (KR2).
3541 Reads and returns the current value of KR2.
3542 This function is only available on Itanium processors.
3544 @return The current value of KR2.
3555 Reads the current value of 64-bit Kernel Register #3 (KR3).
3557 Reads and returns the current value of KR3.
3558 This function is only available on Itanium processors.
3560 @return The current value of KR3.
3571 Reads the current value of 64-bit Kernel Register #4 (KR4).
3573 Reads and returns the current value of KR4.
3574 This function is only available on Itanium processors.
3576 @return The current value of KR4.
3587 Reads the current value of 64-bit Kernel Register #5 (KR5).
3589 Reads and returns the current value of KR5.
3590 This function is only available on Itanium processors.
3592 @return The current value of KR5.
3603 Reads the current value of 64-bit Kernel Register #6 (KR6).
3605 Reads and returns the current value of KR6.
3606 This function is only available on Itanium processors.
3608 @return The current value of KR6.
3619 Reads the current value of 64-bit Kernel Register #7 (KR7).
3621 Reads and returns the current value of KR7.
3622 This function is only available on Itanium processors.
3624 @return The current value of KR7.
3635 Write the current value of 64-bit Kernel Register #0 (KR0).
3637 Writes the current value of KR0. The 64-bit value written to
3638 the KR0 is returned. This function is only available on Itanium processors.
3640 @param Value The 64-bit value to write to KR0.
3642 @return The 64-bit value written to the KR0.
3653 Write the current value of 64-bit Kernel Register #1 (KR1).
3655 Writes the current value of KR1. The 64-bit value written to
3656 the KR1 is returned. This function is only available on Itanium processors.
3658 @param Value The 64-bit value to write to KR1.
3660 @return The 64-bit value written to the KR1.
3671 Write the current value of 64-bit Kernel Register #2 (KR2).
3673 Writes the current value of KR2. The 64-bit value written to
3674 the KR2 is returned. This function is only available on Itanium processors.
3676 @param Value The 64-bit value to write to KR2.
3678 @return The 64-bit value written to the KR2.
3689 Write the current value of 64-bit Kernel Register #3 (KR3).
3691 Writes the current value of KR3. The 64-bit value written to
3692 the KR3 is returned. This function is only available on Itanium processors.
3694 @param Value The 64-bit value to write to KR3.
3696 @return The 64-bit value written to the KR3.
3707 Write the current value of 64-bit Kernel Register #4 (KR4).
3709 Writes the current value of KR4. The 64-bit value written to
3710 the KR4 is returned. This function is only available on Itanium processors.
3712 @param Value The 64-bit value to write to KR4.
3714 @return The 64-bit value written to the KR4.
3725 Write the current value of 64-bit Kernel Register #5 (KR5).
3727 Writes the current value of KR5. The 64-bit value written to
3728 the KR5 is returned. This function is only available on Itanium processors.
3730 @param Value The 64-bit value to write to KR5.
3732 @return The 64-bit value written to the KR5.
3743 Write the current value of 64-bit Kernel Register #6 (KR6).
3745 Writes the current value of KR6. The 64-bit value written to
3746 the KR6 is returned. This function is only available on Itanium processors.
3748 @param Value The 64-bit value to write to KR6.
3750 @return The 64-bit value written to the KR6.
3761 Write the current value of 64-bit Kernel Register #7 (KR7).
3763 Writes the current value of KR7. The 64-bit value written to
3764 the KR7 is returned. This function is only available on Itanium processors.
3766 @param Value The 64-bit value to write to KR7.
3768 @return The 64-bit value written to the KR7.
3779 Reads the current value of Interval Timer Counter Register (ITC).
3781 Reads and returns the current value of ITC.
3782 This function is only available on Itanium processors.
3784 @return The current value of ITC.
3795 Reads the current value of Interval Timer Vector Register (ITV).
3797 Reads and returns the current value of ITV.
3798 This function is only available on Itanium processors.
3800 @return The current value of ITV.
3811 Reads the current value of Interval Timer Match Register (ITM).
3813 Reads and returns the current value of ITM.
3814 This function is only available on Itanium processors.
3816 @return The current value of ITM.
3826 Writes the current value of 64-bit Interval Timer Counter Register (ITC).
3828 Writes the current value of ITC. The 64-bit value written to the ITC is returned.
3829 This function is only available on Itanium processors.
3831 @param Value The 64-bit value to write to ITC.
3833 @return The 64-bit value written to the ITC.
3844 Writes the current value of 64-bit Interval Timer Match Register (ITM).
3846 Writes the current value of ITM. The 64-bit value written to the ITM is returned.
3847 This function is only available on Itanium processors.
3849 @param Value The 64-bit value to write to ITM.
3851 @return The 64-bit value written to the ITM.
3862 Writes the current value of 64-bit Interval Timer Vector Register (ITV).
3864 Writes the current value of ITV. The 64-bit value written to the ITV is returned.
3865 No parameter checking is performed on Value. All bits of Value corresponding to
3866 reserved fields of ITV must be 0 or a Reserved Register/Field fault may occur.
3867 The caller must either guarantee that Value is valid, or the caller must set up
3868 fault handlers to catch the faults.
3869 This function is only available on Itanium processors.
3871 @param Value The 64-bit value to write to ITV.
3873 @return The 64-bit value written to the ITV.
3884 Reads the current value of Default Control Register (DCR).
3886 Reads and returns the current value of DCR. This function is only available on Itanium processors.
3888 @return The current value of DCR.
3899 Reads the current value of Interruption Vector Address Register (IVA).
3901 Reads and returns the current value of IVA. This function is only available on Itanium processors.
3903 @return The current value of IVA.
3913 Reads the current value of Page Table Address Register (PTA).
3915 Reads and returns the current value of PTA. This function is only available on Itanium processors.
3917 @return The current value of PTA.
3928 Writes the current value of 64-bit Default Control Register (DCR).
3930 Writes the current value of DCR. The 64-bit value written to the DCR is returned.
3931 No parameter checking is performed on Value. All bits of Value corresponding to
3932 reserved fields of DCR must be 0 or a Reserved Register/Field fault may occur.
3933 The caller must either guarantee that Value is valid, or the caller must set up
3934 fault handlers to catch the faults.
3935 This function is only available on Itanium processors.
3937 @param Value The 64-bit value to write to DCR.
3939 @return The 64-bit value written to the DCR.
3950 Writes the current value of 64-bit Interruption Vector Address Register (IVA).
3952 Writes the current value of IVA. The 64-bit value written to the IVA is returned.
3953 The size of vector table is 32 K bytes and is 32 K bytes aligned
3954 the low 15 bits of Value is ignored when written.
3955 This function is only available on Itanium processors.
3957 @param Value The 64-bit value to write to IVA.
3959 @return The 64-bit value written to the IVA.
3970 Writes the current value of 64-bit Page Table Address Register (PTA).
3972 Writes the current value of PTA. The 64-bit value written to the PTA is returned.
3973 No parameter checking is performed on Value. All bits of Value corresponding to
3974 reserved fields of DCR must be 0 or a Reserved Register/Field fault may occur.
3975 The caller must either guarantee that Value is valid, or the caller must set up
3976 fault handlers to catch the faults.
3977 This function is only available on Itanium processors.
3979 @param Value The 64-bit value to write to PTA.
3981 @return The 64-bit value written to the PTA.
3991 Reads the current value of Local Interrupt ID Register (LID).
3993 Reads and returns the current value of LID. This function is only available on Itanium processors.
3995 @return The current value of LID.
4006 Reads the current value of External Interrupt Vector Register (IVR).
4008 Reads and returns the current value of IVR. This function is only available on Itanium processors.
4010 @return The current value of IVR.
4021 Reads the current value of Task Priority Register (TPR).
4023 Reads and returns the current value of TPR. This function is only available on Itanium processors.
4025 @return The current value of TPR.
4036 Reads the current value of External Interrupt Request Register #0 (IRR0).
4038 Reads and returns the current value of IRR0. This function is only available on Itanium processors.
4040 @return The current value of IRR0.
4051 Reads the current value of External Interrupt Request Register #1 (IRR1).
4053 Reads and returns the current value of IRR1. This function is only available on Itanium processors.
4055 @return The current value of IRR1.
4066 Reads the current value of External Interrupt Request Register #2 (IRR2).
4068 Reads and returns the current value of IRR2. This function is only available on Itanium processors.
4070 @return The current value of IRR2.
4081 Reads the current value of External Interrupt Request Register #3 (IRR3).
4083 Reads and returns the current value of IRR3. This function is only available on Itanium processors.
4085 @return The current value of IRR3.
4096 Reads the current value of Performance Monitor Vector Register (PMV).
4098 Reads and returns the current value of PMV. This function is only available on Itanium processors.
4100 @return The current value of PMV.
4111 Reads the current value of Corrected Machine Check Vector Register (CMCV).
4113 Reads and returns the current value of CMCV. This function is only available on Itanium processors.
4115 @return The current value of CMCV.
4126 Reads the current value of Local Redirection Register #0 (LRR0).
4128 Reads and returns the current value of LRR0. This function is only available on Itanium processors.
4130 @return The current value of LRR0.
4141 Reads the current value of Local Redirection Register #1 (LRR1).
4143 Reads and returns the current value of LRR1. This function is only available on Itanium processors.
4145 @return The current value of LRR1.
4156 Writes the current value of 64-bit Page Local Interrupt ID Register (LID).
4158 Writes the current value of LID. The 64-bit value written to the LID is returned.
4159 No parameter checking is performed on Value. All bits of Value corresponding to
4160 reserved fields of LID must be 0 or a Reserved Register/Field fault may occur.
4161 The caller must either guarantee that Value is valid, or the caller must set up
4162 fault handlers to catch the faults.
4163 This function is only available on Itanium processors.
4165 @param Value The 64-bit value to write to LID.
4167 @return The 64-bit value written to the LID.
4178 Writes the current value of 64-bit Task Priority Register (TPR).
4180 Writes the current value of TPR. The 64-bit value written to the TPR is returned.
4181 No parameter checking is performed on Value. All bits of Value corresponding to
4182 reserved fields of TPR must be 0 or a Reserved Register/Field fault may occur.
4183 The caller must either guarantee that Value is valid, or the caller must set up
4184 fault handlers to catch the faults.
4185 This function is only available on Itanium processors.
4187 @param Value The 64-bit value to write to TPR.
4189 @return The 64-bit value written to the TPR.
4200 Performs a write operation on End OF External Interrupt Register (EOI).
4202 Writes a value of 0 to the EOI Register. This function is only available on Itanium processors.
4213 Writes the current value of 64-bit Performance Monitor Vector Register (PMV).
4215 Writes the current value of PMV. The 64-bit value written to the PMV is returned.
4216 No parameter checking is performed on Value. All bits of Value corresponding
4217 to reserved fields of PMV must be 0 or a Reserved Register/Field fault may occur.
4218 The caller must either guarantee that Value is valid, or the caller must set up
4219 fault handlers to catch the faults.
4220 This function is only available on Itanium processors.
4222 @param Value The 64-bit value to write to PMV.
4224 @return The 64-bit value written to the PMV.
4235 Writes the current value of 64-bit Corrected Machine Check Vector Register (CMCV).
4237 Writes the current value of CMCV. The 64-bit value written to the CMCV is returned.
4238 No parameter checking is performed on Value. All bits of Value corresponding
4239 to reserved fields of CMCV must be 0 or a Reserved Register/Field fault may occur.
4240 The caller must either guarantee that Value is valid, or the caller must set up
4241 fault handlers to catch the faults.
4242 This function is only available on Itanium processors.
4244 @param Value The 64-bit value to write to CMCV.
4246 @return The 64-bit value written to the CMCV.
4257 Writes the current value of 64-bit Local Redirection Register #0 (LRR0).
4259 Writes the current value of LRR0. The 64-bit value written to the LRR0 is returned.
4260 No parameter checking is performed on Value. All bits of Value corresponding
4261 to reserved fields of LRR0 must be 0 or a Reserved Register/Field fault may occur.
4262 The caller must either guarantee that Value is valid, or the caller must set up
4263 fault handlers to catch the faults.
4264 This function is only available on Itanium processors.
4266 @param Value The 64-bit value to write to LRR0.
4268 @return The 64-bit value written to the LRR0.
4279 Writes the current value of 64-bit Local Redirection Register #1 (LRR1).
4281 Writes the current value of LRR1. The 64-bit value written to the LRR1 is returned.
4282 No parameter checking is performed on Value. All bits of Value corresponding
4283 to reserved fields of LRR1 must be 0 or a Reserved Register/Field fault may occur.
4284 The caller must either guarantee that Value is valid, or the caller must
4285 set up fault handlers to catch the faults.
4286 This function is only available on Itanium processors.
4288 @param Value The 64-bit value to write to LRR1.
4290 @return The 64-bit value written to the LRR1.
4301 Reads the current value of Instruction Breakpoint Register (IBR).
4303 The Instruction Breakpoint Registers are used in pairs. The even numbered
4304 registers contain breakpoint addresses, and the odd numbered registers contain
4305 breakpoint mask conditions. At least 4 instruction registers pairs are implemented
4306 on all processor models. Implemented registers are contiguous starting with
4307 register 0. No parameter checking is performed on Index, and if the Index value
4308 is beyond the implemented IBR register range, a Reserved Register/Field fault may
4309 occur. The caller must either guarantee that Index is valid, or the caller must
4310 set up fault handlers to catch the faults.
4311 This function is only available on Itanium processors.
4313 @param Index The 8-bit Instruction Breakpoint Register index to read.
4315 @return The current value of Instruction Breakpoint Register specified by Index.
4326 Reads the current value of Data Breakpoint Register (DBR).
4328 The Data Breakpoint Registers are used in pairs. The even numbered registers
4329 contain breakpoint addresses, and odd numbered registers contain breakpoint
4330 mask conditions. At least 4 data registers pairs are implemented on all processor
4331 models. Implemented registers are contiguous starting with register 0.
4332 No parameter checking is performed on Index. If the Index value is beyond
4333 the implemented DBR register range, a Reserved Register/Field fault may occur.
4334 The caller must either guarantee that Index is valid, or the caller must set up
4335 fault handlers to catch the faults.
4336 This function is only available on Itanium processors.
4338 @param Index The 8-bit Data Breakpoint Register index to read.
4340 @return The current value of Data Breakpoint Register specified by Index.
4351 Reads the current value of Performance Monitor Configuration Register (PMC).
4353 All processor implementations provide at least 4 performance counters
4354 (PMC/PMD [4]...PMC/PMD [7] pairs), and 4 performance monitor counter overflow
4355 status registers (PMC [0]... PMC [3]). Processor implementations may provide
4356 additional implementation-dependent PMC and PMD to increase the number of
4357 'generic' performance counters (PMC/PMD pairs). The remainder of PMC and PMD
4358 register set is implementation dependent. No parameter checking is performed
4359 on Index. If the Index value is beyond the implemented PMC register range,
4360 zero value will be returned.
4361 This function is only available on Itanium processors.
4363 @param Index The 8-bit Performance Monitor Configuration Register index to read.
4365 @return The current value of Performance Monitor Configuration Register
4377 Reads the current value of Performance Monitor Data Register (PMD).
4379 All processor implementations provide at least 4 performance counters
4380 (PMC/PMD [4]...PMC/PMD [7] pairs), and 4 performance monitor counter
4381 overflow status registers (PMC [0]... PMC [3]). Processor implementations may
4382 provide additional implementation-dependent PMC and PMD to increase the number
4383 of 'generic' performance counters (PMC/PMD pairs). The remainder of PMC and PMD
4384 register set is implementation dependent. No parameter checking is performed
4385 on Index. If the Index value is beyond the implemented PMD register range,
4386 zero value will be returned.
4387 This function is only available on Itanium processors.
4389 @param Index The 8-bit Performance Monitor Data Register index to read.
4391 @return The current value of Performance Monitor Data Register specified by Index.
4402 Writes the current value of 64-bit Instruction Breakpoint Register (IBR).
4404 Writes current value of Instruction Breakpoint Register specified by Index.
4405 The Instruction Breakpoint Registers are used in pairs. The even numbered
4406 registers contain breakpoint addresses, and odd numbered registers contain
4407 breakpoint mask conditions. At least 4 instruction registers pairs are implemented
4408 on all processor models. Implemented registers are contiguous starting with
4409 register 0. No parameter checking is performed on Index. If the Index value
4410 is beyond the implemented IBR register range, a Reserved Register/Field fault may
4411 occur. The caller must either guarantee that Index is valid, or the caller must
4412 set up fault handlers to catch the faults.
4413 This function is only available on Itanium processors.
4415 @param Index The 8-bit Instruction Breakpoint Register index to write.
4416 @param Value The 64-bit value to write to IBR.
4418 @return The 64-bit value written to the IBR.
4430 Writes the current value of 64-bit Data Breakpoint Register (DBR).
4432 Writes current value of Data Breakpoint Register specified by Index.
4433 The Data Breakpoint Registers are used in pairs. The even numbered registers
4434 contain breakpoint addresses, and odd numbered registers contain breakpoint
4435 mask conditions. At least 4 data registers pairs are implemented on all processor
4436 models. Implemented registers are contiguous starting with register 0. No parameter
4437 checking is performed on Index. If the Index value is beyond the implemented
4438 DBR register range, a Reserved Register/Field fault may occur. The caller must
4439 either guarantee that Index is valid, or the caller must set up fault handlers to
4441 This function is only available on Itanium processors.
4443 @param Index The 8-bit Data Breakpoint Register index to write.
4444 @param Value The 64-bit value to write to DBR.
4446 @return The 64-bit value written to the DBR.
4458 Writes the current value of 64-bit Performance Monitor Configuration Register (PMC).
4460 Writes current value of Performance Monitor Configuration Register specified by Index.
4461 All processor implementations provide at least 4 performance counters
4462 (PMC/PMD [4]...PMC/PMD [7] pairs), and 4 performance monitor counter overflow status
4463 registers (PMC [0]... PMC [3]). Processor implementations may provide additional
4464 implementation-dependent PMC and PMD to increase the number of 'generic' performance
4465 counters (PMC/PMD pairs). The remainder of PMC and PMD register set is implementation
4466 dependent. No parameter checking is performed on Index. If the Index value is
4467 beyond the implemented PMC register range, the write is ignored.
4468 This function is only available on Itanium processors.
4470 @param Index The 8-bit Performance Monitor Configuration Register index to write.
4471 @param Value The 64-bit value to write to PMC.
4473 @return The 64-bit value written to the PMC.
4485 Writes the current value of 64-bit Performance Monitor Data Register (PMD).
4487 Writes current value of Performance Monitor Data Register specified by Index.
4488 All processor implementations provide at least 4 performance counters
4489 (PMC/PMD [4]...PMC/PMD [7] pairs), and 4 performance monitor counter overflow
4490 status registers (PMC [0]... PMC [3]). Processor implementations may provide
4491 additional implementation-dependent PMC and PMD to increase the number of 'generic'
4492 performance counters (PMC/PMD pairs). The remainder of PMC and PMD register set
4493 is implementation dependent. No parameter checking is performed on Index. If the
4494 Index value is beyond the implemented PMD register range, the write is ignored.
4495 This function is only available on Itanium processors.
4497 @param Index The 8-bit Performance Monitor Data Register index to write.
4498 @param Value The 64-bit value to write to PMD.
4500 @return The 64-bit value written to the PMD.
4512 Reads the current value of 64-bit Global Pointer (GP).
4514 Reads and returns the current value of GP.
4515 This function is only available on Itanium processors.
4517 @return The current value of GP.
4528 Write the current value of 64-bit Global Pointer (GP).
4530 Writes the current value of GP. The 64-bit value written to the GP is returned.
4531 No parameter checking is performed on Value.
4532 This function is only available on Itanium processors.
4534 @param Value The 64-bit value to write to GP.
4536 @return The 64-bit value written to the GP.
4547 Reads the current value of 64-bit Stack Pointer (SP).
4549 Reads and returns the current value of SP.
4550 This function is only available on Itanium processors.
4552 @return The current value of SP.
4563 /// Valid Index value for AsmReadControlRegister()
4565 #define IPF_CONTROL_REGISTER_DCR 0
4566 #define IPF_CONTROL_REGISTER_ITM 1
4567 #define IPF_CONTROL_REGISTER_IVA 2
4568 #define IPF_CONTROL_REGISTER_PTA 8
4569 #define IPF_CONTROL_REGISTER_IPSR 16
4570 #define IPF_CONTROL_REGISTER_ISR 17
4571 #define IPF_CONTROL_REGISTER_IIP 19
4572 #define IPF_CONTROL_REGISTER_IFA 20
4573 #define IPF_CONTROL_REGISTER_ITIR 21
4574 #define IPF_CONTROL_REGISTER_IIPA 22
4575 #define IPF_CONTROL_REGISTER_IFS 23
4576 #define IPF_CONTROL_REGISTER_IIM 24
4577 #define IPF_CONTROL_REGISTER_IHA 25
4578 #define IPF_CONTROL_REGISTER_LID 64
4579 #define IPF_CONTROL_REGISTER_IVR 65
4580 #define IPF_CONTROL_REGISTER_TPR 66
4581 #define IPF_CONTROL_REGISTER_EOI 67
4582 #define IPF_CONTROL_REGISTER_IRR0 68
4583 #define IPF_CONTROL_REGISTER_IRR1 69
4584 #define IPF_CONTROL_REGISTER_IRR2 70
4585 #define IPF_CONTROL_REGISTER_IRR3 71
4586 #define IPF_CONTROL_REGISTER_ITV 72
4587 #define IPF_CONTROL_REGISTER_PMV 73
4588 #define IPF_CONTROL_REGISTER_CMCV 74
4589 #define IPF_CONTROL_REGISTER_LRR0 80
4590 #define IPF_CONTROL_REGISTER_LRR1 81
4593 Reads a 64-bit control register.
4595 Reads and returns the control register specified by Index. The valid Index valued are defined
4596 above in "Related Definitions".
4597 If Index is invalid then 0xFFFFFFFFFFFFFFFF is returned. This function is only available on Itanium processors.
4599 @param Index The index of the control register to read.
4601 @return The control register specified by Index.
4606 AsmReadControlRegister (
4612 /// Valid Index value for AsmReadApplicationRegister()
4614 #define IPF_APPLICATION_REGISTER_K0 0
4615 #define IPF_APPLICATION_REGISTER_K1 1
4616 #define IPF_APPLICATION_REGISTER_K2 2
4617 #define IPF_APPLICATION_REGISTER_K3 3
4618 #define IPF_APPLICATION_REGISTER_K4 4
4619 #define IPF_APPLICATION_REGISTER_K5 5
4620 #define IPF_APPLICATION_REGISTER_K6 6
4621 #define IPF_APPLICATION_REGISTER_K7 7
4622 #define IPF_APPLICATION_REGISTER_RSC 16
4623 #define IPF_APPLICATION_REGISTER_BSP 17
4624 #define IPF_APPLICATION_REGISTER_BSPSTORE 18
4625 #define IPF_APPLICATION_REGISTER_RNAT 19
4626 #define IPF_APPLICATION_REGISTER_FCR 21
4627 #define IPF_APPLICATION_REGISTER_EFLAG 24
4628 #define IPF_APPLICATION_REGISTER_CSD 25
4629 #define IPF_APPLICATION_REGISTER_SSD 26
4630 #define IPF_APPLICATION_REGISTER_CFLG 27
4631 #define IPF_APPLICATION_REGISTER_FSR 28
4632 #define IPF_APPLICATION_REGISTER_FIR 29
4633 #define IPF_APPLICATION_REGISTER_FDR 30
4634 #define IPF_APPLICATION_REGISTER_CCV 32
4635 #define IPF_APPLICATION_REGISTER_UNAT 36
4636 #define IPF_APPLICATION_REGISTER_FPSR 40
4637 #define IPF_APPLICATION_REGISTER_ITC 44
4638 #define IPF_APPLICATION_REGISTER_PFS 64
4639 #define IPF_APPLICATION_REGISTER_LC 65
4640 #define IPF_APPLICATION_REGISTER_EC 66
4643 Reads a 64-bit application register.
4645 Reads and returns the application register specified by Index. The valid Index valued are defined
4646 above in "Related Definitions".
4647 If Index is invalid then 0xFFFFFFFFFFFFFFFF is returned. This function is only available on Itanium processors.
4649 @param Index The index of the application register to read.
4651 @return The application register specified by Index.
4656 AsmReadApplicationRegister (
4662 Reads the current value of a Machine Specific Register (MSR).
4664 Reads and returns the current value of the Machine Specific Register specified by Index. No
4665 parameter checking is performed on Index, and if the Index value is beyond the implemented MSR
4666 register range, a Reserved Register/Field fault may occur. The caller must either guarantee that
4667 Index is valid, or the caller must set up fault handlers to catch the faults. This function is
4668 only available on Itanium processors.
4670 @param Index The 8-bit Machine Specific Register index to read.
4672 @return The current value of the Machine Specific Register specified by Index.
4683 Writes the current value of a Machine Specific Register (MSR).
4685 Writes Value to the Machine Specific Register specified by Index. Value is returned. No
4686 parameter checking is performed on Index, and if the Index value is beyond the implemented MSR
4687 register range, a Reserved Register/Field fault may occur. The caller must either guarantee that
4688 Index is valid, or the caller must set up fault handlers to catch the faults. This function is
4689 only available on Itanium processors.
4691 @param Index The 8-bit Machine Specific Register index to write.
4692 @param Value The 64-bit value to write to the Machine Specific Register.
4694 @return The 64-bit value to write to the Machine Specific Register.
4706 Determines if the CPU is currently executing in virtual, physical, or mixed mode.
4708 Determines the current execution mode of the CPU.
4709 If the CPU is in virtual mode(PSR.RT=1, PSR.DT=1, PSR.IT=1), then 1 is returned.
4710 If the CPU is in physical mode(PSR.RT=0, PSR.DT=0, PSR.IT=0), then 0 is returned.
4711 If the CPU is not in physical mode or virtual mode, then it is in mixed mode,
4713 This function is only available on Itanium processors.
4715 @retval 1 The CPU is in virtual mode.
4716 @retval 0 The CPU is in physical mode.
4717 @retval -1 The CPU is in mixed mode.
4728 Makes a PAL procedure call.
4730 This is a wrapper function to make a PAL procedure call. Based on the Index
4731 value this API will make static or stacked PAL call. The following table
4732 describes the usage of PAL Procedure Index Assignment. Architected procedures
4733 may be designated as required or optional. If a PAL procedure is specified
4734 as optional, a unique return code of 0xFFFFFFFFFFFFFFFF is returned in the
4735 Status field of the PAL_CALL_RETURN structure.
4736 This indicates that the procedure is not present in this PAL implementation.
4737 It is the caller's responsibility to check for this return code after calling
4738 any optional PAL procedure.
4739 No parameter checking is performed on the 5 input parameters, but there are
4740 some common rules that the caller should follow when making a PAL call. Any
4741 address passed to PAL as buffers for return parameters must be 8-byte aligned.
4742 Unaligned addresses may cause undefined results. For those parameters defined
4743 as reserved or some fields defined as reserved must be zero filled or the invalid
4744 argument return value may be returned or undefined result may occur during the
4745 execution of the procedure. If the PalEntryPoint does not point to a valid
4746 PAL entry point then the system behavior is undefined. This function is only
4747 available on Itanium processors.
4749 @param PalEntryPoint The PAL procedure calls entry point.
4750 @param Index The PAL procedure Index number.
4751 @param Arg2 The 2nd parameter for PAL procedure calls.
4752 @param Arg3 The 3rd parameter for PAL procedure calls.
4753 @param Arg4 The 4th parameter for PAL procedure calls.
4755 @return structure returned from the PAL Call procedure, including the status and return value.
4761 IN UINT64 PalEntryPoint
,
4769 #if defined (MDE_CPU_IA32) || defined (MDE_CPU_X64)
4771 /// IA32 and x64 Specific Functions
4772 /// Byte packed structure for 16-bit Real Mode EFLAGS
4776 UINT32 CF
:1; ///< Carry Flag
4777 UINT32 Reserved_0
:1; ///< Reserved
4778 UINT32 PF
:1; ///< Parity Flag
4779 UINT32 Reserved_1
:1; ///< Reserved
4780 UINT32 AF
:1; ///< Auxiliary Carry Flag
4781 UINT32 Reserved_2
:1; ///< Reserved
4782 UINT32 ZF
:1; ///< Zero Flag
4783 UINT32 SF
:1; ///< Sign Flag
4784 UINT32 TF
:1; ///< Trap Flag
4785 UINT32 IF
:1; ///< Interrupt Enable Flag
4786 UINT32 DF
:1; ///< Direction Flag
4787 UINT32 OF
:1; ///< Overflow Flag
4788 UINT32 IOPL
:2; ///< I/O Privilege Level
4789 UINT32 NT
:1; ///< Nested Task
4790 UINT32 Reserved_3
:1; ///< Reserved
4796 /// Byte packed structure for EFLAGS/RFLAGS
4797 /// 32-bits on IA-32
4798 /// 64-bits on x64. The upper 32-bits on x64 are reserved
4802 UINT32 CF
:1; ///< Carry Flag
4803 UINT32 Reserved_0
:1; ///< Reserved
4804 UINT32 PF
:1; ///< Parity Flag
4805 UINT32 Reserved_1
:1; ///< Reserved
4806 UINT32 AF
:1; ///< Auxiliary Carry Flag
4807 UINT32 Reserved_2
:1; ///< Reserved
4808 UINT32 ZF
:1; ///< Zero Flag
4809 UINT32 SF
:1; ///< Sign Flag
4810 UINT32 TF
:1; ///< Trap Flag
4811 UINT32 IF
:1; ///< Interrupt Enable Flag
4812 UINT32 DF
:1; ///< Direction Flag
4813 UINT32 OF
:1; ///< Overflow Flag
4814 UINT32 IOPL
:2; ///< I/O Privilege Level
4815 UINT32 NT
:1; ///< Nested Task
4816 UINT32 Reserved_3
:1; ///< Reserved
4817 UINT32 RF
:1; ///< Resume Flag
4818 UINT32 VM
:1; ///< Virtual 8086 Mode
4819 UINT32 AC
:1; ///< Alignment Check
4820 UINT32 VIF
:1; ///< Virtual Interrupt Flag
4821 UINT32 VIP
:1; ///< Virtual Interrupt Pending
4822 UINT32 ID
:1; ///< ID Flag
4823 UINT32 Reserved_4
:10; ///< Reserved
4829 /// Byte packed structure for Control Register 0 (CR0)
4830 /// 32-bits on IA-32
4831 /// 64-bits on x64. The upper 32-bits on x64 are reserved
4835 UINT32 PE
:1; ///< Protection Enable
4836 UINT32 MP
:1; ///< Monitor Coprocessor
4837 UINT32 EM
:1; ///< Emulation
4838 UINT32 TS
:1; ///< Task Switched
4839 UINT32 ET
:1; ///< Extension Type
4840 UINT32 NE
:1; ///< Numeric Error
4841 UINT32 Reserved_0
:10; ///< Reserved
4842 UINT32 WP
:1; ///< Write Protect
4843 UINT32 Reserved_1
:1; ///< Reserved
4844 UINT32 AM
:1; ///< Alignment Mask
4845 UINT32 Reserved_2
:10; ///< Reserved
4846 UINT32 NW
:1; ///< Mot Write-through
4847 UINT32 CD
:1; ///< Cache Disable
4848 UINT32 PG
:1; ///< Paging
4854 /// Byte packed structure for Control Register 4 (CR4)
4855 /// 32-bits on IA-32
4856 /// 64-bits on x64. The upper 32-bits on x64 are reserved
4860 UINT32 VME
:1; ///< Virtual-8086 Mode Extensions
4861 UINT32 PVI
:1; ///< Protected-Mode Virtual Interrupts
4862 UINT32 TSD
:1; ///< Time Stamp Disable
4863 UINT32 DE
:1; ///< Debugging Extensions
4864 UINT32 PSE
:1; ///< Page Size Extensions
4865 UINT32 PAE
:1; ///< Physical Address Extension
4866 UINT32 MCE
:1; ///< Machine Check Enable
4867 UINT32 PGE
:1; ///< Page Global Enable
4868 UINT32 PCE
:1; ///< Performance Monitoring Counter
4870 UINT32 OSFXSR
:1; ///< Operating System Support for
4871 ///< FXSAVE and FXRSTOR instructions
4872 UINT32 OSXMMEXCPT
:1; ///< Operating System Support for
4873 ///< Unmasked SIMD Floating Point
4875 UINT32 Reserved_0
:2; ///< Reserved
4876 UINT32 VMXE
:1; ///< VMX Enable
4877 UINT32 Reserved_1
:18; ///< Reserved
4883 /// Byte packed structure for an IDTR, GDTR, LDTR descriptor
4892 #define IA32_IDT_GATE_TYPE_TASK 0x85
4893 #define IA32_IDT_GATE_TYPE_INTERRUPT_16 0x86
4894 #define IA32_IDT_GATE_TYPE_TRAP_16 0x87
4895 #define IA32_IDT_GATE_TYPE_INTERRUPT_32 0x8E
4896 #define IA32_IDT_GATE_TYPE_TRAP_32 0x8F
4899 #if defined (MDE_CPU_IA32)
4901 /// Byte packed structure for an IA-32 Interrupt Gate Descriptor
4905 UINT32 OffsetLow
:16; ///< Offset bits 15..0
4906 UINT32 Selector
:16; ///< Selector
4907 UINT32 Reserved_0
:8; ///< Reserved
4908 UINT32 GateType
:8; ///< Gate Type. See #defines above
4909 UINT32 OffsetHigh
:16; ///< Offset bits 31..16
4912 } IA32_IDT_GATE_DESCRIPTOR
;
4916 #if defined (MDE_CPU_X64)
4918 /// Byte packed structure for an x64 Interrupt Gate Descriptor
4922 UINT32 OffsetLow
:16; ///< Offset bits 15..0
4923 UINT32 Selector
:16; ///< Selector
4924 UINT32 Reserved_0
:8; ///< Reserved
4925 UINT32 GateType
:8; ///< Gate Type. See #defines above
4926 UINT32 OffsetHigh
:16; ///< Offset bits 31..16
4927 UINT32 OffsetUpper
:32; ///< Offset bits 63..32
4928 UINT32 Reserved_1
:32; ///< Reserved
4934 } IA32_IDT_GATE_DESCRIPTOR
;
4939 /// Byte packed structure for an FP/SSE/SSE2 context
4946 /// Structures for the 16-bit real mode thunks
4999 IA32_EFLAGS32 EFLAGS
;
5009 } IA32_REGISTER_SET
;
5012 /// Byte packed structure for an 16-bit real mode thunks
5015 IA32_REGISTER_SET
*RealModeState
;
5016 VOID
*RealModeBuffer
;
5017 UINT32 RealModeBufferSize
;
5018 UINT32 ThunkAttributes
;
5021 #define THUNK_ATTRIBUTE_BIG_REAL_MODE 0x00000001
5022 #define THUNK_ATTRIBUTE_DISABLE_A20_MASK_INT_15 0x00000002
5023 #define THUNK_ATTRIBUTE_DISABLE_A20_MASK_KBD_CTRL 0x00000004
5026 Retrieves CPUID information.
5028 Executes the CPUID instruction with EAX set to the value specified by Index.
5029 This function always returns Index.
5030 If Eax is not NULL, then the value of EAX after CPUID is returned in Eax.
5031 If Ebx is not NULL, then the value of EBX after CPUID is returned in Ebx.
5032 If Ecx is not NULL, then the value of ECX after CPUID is returned in Ecx.
5033 If Edx is not NULL, then the value of EDX after CPUID is returned in Edx.
5034 This function is only available on IA-32 and x64.
5036 @param Index The 32-bit value to load into EAX prior to invoking the CPUID
5038 @param Eax Pointer to the 32-bit EAX value returned by the CPUID
5039 instruction. This is an optional parameter that may be NULL.
5040 @param Ebx Pointer to the 32-bit EBX value returned by the CPUID
5041 instruction. This is an optional parameter that may be NULL.
5042 @param Ecx Pointer to the 32-bit ECX value returned by the CPUID
5043 instruction. This is an optional parameter that may be NULL.
5044 @param Edx Pointer to the 32-bit EDX value returned by the CPUID
5045 instruction. This is an optional parameter that may be NULL.
5054 OUT UINT32
*Eax
, OPTIONAL
5055 OUT UINT32
*Ebx
, OPTIONAL
5056 OUT UINT32
*Ecx
, OPTIONAL
5057 OUT UINT32
*Edx OPTIONAL
5062 Retrieves CPUID information using an extended leaf identifier.
5064 Executes the CPUID instruction with EAX set to the value specified by Index
5065 and ECX set to the value specified by SubIndex. This function always returns
5066 Index. This function is only available on IA-32 and x64.
5068 If Eax is not NULL, then the value of EAX after CPUID is returned in Eax.
5069 If Ebx is not NULL, then the value of EBX after CPUID is returned in Ebx.
5070 If Ecx is not NULL, then the value of ECX after CPUID is returned in Ecx.
5071 If Edx is not NULL, then the value of EDX after CPUID is returned in Edx.
5073 @param Index The 32-bit value to load into EAX prior to invoking the
5075 @param SubIndex The 32-bit value to load into ECX prior to invoking the
5077 @param Eax Pointer to the 32-bit EAX value returned by the CPUID
5078 instruction. This is an optional parameter that may be
5080 @param Ebx Pointer to the 32-bit EBX value returned by the CPUID
5081 instruction. This is an optional parameter that may be
5083 @param Ecx Pointer to the 32-bit ECX value returned by the CPUID
5084 instruction. This is an optional parameter that may be
5086 @param Edx Pointer to the 32-bit EDX value returned by the CPUID
5087 instruction. This is an optional parameter that may be
5098 OUT UINT32
*Eax
, OPTIONAL
5099 OUT UINT32
*Ebx
, OPTIONAL
5100 OUT UINT32
*Ecx
, OPTIONAL
5101 OUT UINT32
*Edx OPTIONAL
5106 Set CD bit and clear NW bit of CR0 followed by a WBINVD.
5108 Disables the caches by setting the CD bit of CR0 to 1, clearing the NW bit of CR0 to 0,
5109 and executing a WBINVD instruction. This function is only available on IA-32 and x64.
5120 Perform a WBINVD and clear both the CD and NW bits of CR0.
5122 Enables the caches by executing a WBINVD instruction and then clear both the CD and NW
5123 bits of CR0 to 0. This function is only available on IA-32 and x64.
5134 Returns the lower 32-bits of a Machine Specific Register(MSR).
5136 Reads and returns the lower 32-bits of the MSR specified by Index.
5137 No parameter checking is performed on Index, and some Index values may cause
5138 CPU exceptions. The caller must either guarantee that Index is valid, or the
5139 caller must set up exception handlers to catch the exceptions. This function
5140 is only available on IA-32 and x64.
5142 @param Index The 32-bit MSR index to read.
5144 @return The lower 32 bits of the MSR identified by Index.
5155 Writes a 32-bit value to a Machine Specific Register(MSR), and returns the value.
5156 The upper 32-bits of the MSR are set to zero.
5158 Writes the 32-bit value specified by Value to the MSR specified by Index. The
5159 upper 32-bits of the MSR write are set to zero. The 32-bit value written to
5160 the MSR is returned. No parameter checking is performed on Index or Value,
5161 and some of these may cause CPU exceptions. The caller must either guarantee
5162 that Index and Value are valid, or the caller must establish proper exception
5163 handlers. This function is only available on IA-32 and x64.
5165 @param Index The 32-bit MSR index to write.
5166 @param Value The 32-bit value to write to the MSR.
5180 Reads a 64-bit MSR, performs a bitwise OR on the lower 32-bits, and
5181 writes the result back to the 64-bit MSR.
5183 Reads the 64-bit MSR specified by Index, performs a bitwise OR
5184 between the lower 32-bits of the read result and the value specified by
5185 OrData, and writes the result to the 64-bit MSR specified by Index. The lower
5186 32-bits of the value written to the MSR is returned. No parameter checking is
5187 performed on Index or OrData, and some of these may cause CPU exceptions. The
5188 caller must either guarantee that Index and OrData are valid, or the caller
5189 must establish proper exception handlers. This function is only available on
5192 @param Index The 32-bit MSR index to write.
5193 @param OrData The value to OR with the read value from the MSR.
5195 @return The lower 32-bit value written to the MSR.
5207 Reads a 64-bit MSR, performs a bitwise AND on the lower 32-bits, and writes
5208 the result back to the 64-bit MSR.
5210 Reads the 64-bit MSR specified by Index, performs a bitwise AND between the
5211 lower 32-bits of the read result and the value specified by AndData, and
5212 writes the result to the 64-bit MSR specified by Index. The lower 32-bits of
5213 the value written to the MSR is returned. No parameter checking is performed
5214 on Index or AndData, and some of these may cause CPU exceptions. The caller
5215 must either guarantee that Index and AndData are valid, or the caller must
5216 establish proper exception handlers. This function is only available on IA-32
5219 @param Index The 32-bit MSR index to write.
5220 @param AndData The value to AND with the read value from the MSR.
5222 @return The lower 32-bit value written to the MSR.
5234 Reads a 64-bit MSR, performs a bitwise AND followed by a bitwise OR
5235 on the lower 32-bits, and writes the result back to the 64-bit MSR.
5237 Reads the 64-bit MSR specified by Index, performs a bitwise AND between the
5238 lower 32-bits of the read result and the value specified by AndData
5239 preserving the upper 32-bits, performs a bitwise OR between the
5240 result of the AND operation and the value specified by OrData, and writes the
5241 result to the 64-bit MSR specified by Address. The lower 32-bits of the value
5242 written to the MSR is returned. No parameter checking is performed on Index,
5243 AndData, or OrData, and some of these may cause CPU exceptions. The caller
5244 must either guarantee that Index, AndData, and OrData are valid, or the
5245 caller must establish proper exception handlers. This function is only
5246 available on IA-32 and x64.
5248 @param Index The 32-bit MSR index to write.
5249 @param AndData The value to AND with the read value from the MSR.
5250 @param OrData The value to OR with the result of the AND operation.
5252 @return The lower 32-bit value written to the MSR.
5265 Reads a bit field of an MSR.
5267 Reads the bit field in the lower 32-bits of a 64-bit MSR. The bit field is
5268 specified by the StartBit and the EndBit. The value of the bit field is
5269 returned. The caller must either guarantee that Index is valid, or the caller
5270 must set up exception handlers to catch the exceptions. This function is only
5271 available on IA-32 and x64.
5273 If StartBit is greater than 31, then ASSERT().
5274 If EndBit is greater than 31, then ASSERT().
5275 If EndBit is less than StartBit, then ASSERT().
5277 @param Index The 32-bit MSR index to read.
5278 @param StartBit The ordinal of the least significant bit in the bit field.
5280 @param EndBit The ordinal of the most significant bit in the bit field.
5283 @return The bit field read from the MSR.
5288 AsmMsrBitFieldRead32 (
5296 Writes a bit field to an MSR.
5298 Writes Value to a bit field in the lower 32-bits of a 64-bit MSR. The bit
5299 field is specified by the StartBit and the EndBit. All other bits in the
5300 destination MSR are preserved. The lower 32-bits of the MSR written is
5301 returned. The caller must either guarantee that Index and the data written
5302 is valid, or the caller must set up exception handlers to catch the exceptions.
5303 This function is only available on IA-32 and x64.
5305 If StartBit is greater than 31, then ASSERT().
5306 If EndBit is greater than 31, then ASSERT().
5307 If EndBit is less than StartBit, then ASSERT().
5309 @param Index The 32-bit MSR index to write.
5310 @param StartBit The ordinal of the least significant bit in the bit field.
5312 @param EndBit The ordinal of the most significant bit in the bit field.
5314 @param Value New value of the bit field.
5316 @return The lower 32-bit of the value written to the MSR.
5321 AsmMsrBitFieldWrite32 (
5330 Reads a bit field in a 64-bit MSR, performs a bitwise OR, and writes the
5331 result back to the bit field in the 64-bit MSR.
5333 Reads the 64-bit MSR specified by Index, performs a bitwise OR
5334 between the read result and the value specified by OrData, and writes the
5335 result to the 64-bit MSR specified by Index. The lower 32-bits of the value
5336 written to the MSR are returned. Extra left bits in OrData are stripped. The
5337 caller must either guarantee that Index and the data written is valid, or
5338 the caller must set up exception handlers to catch the exceptions. This
5339 function is only available on IA-32 and x64.
5341 If StartBit is greater than 31, then ASSERT().
5342 If EndBit is greater than 31, then ASSERT().
5343 If EndBit is less than StartBit, then ASSERT().
5345 @param Index The 32-bit MSR index to write.
5346 @param StartBit The ordinal of the least significant bit in the bit field.
5348 @param EndBit The ordinal of the most significant bit in the bit field.
5350 @param OrData The value to OR with the read value from the MSR.
5352 @return The lower 32-bit of the value written to the MSR.
5357 AsmMsrBitFieldOr32 (
5366 Reads a bit field in a 64-bit MSR, performs a bitwise AND, and writes the
5367 result back to the bit field in the 64-bit MSR.
5369 Reads the 64-bit MSR specified by Index, performs a bitwise AND between the
5370 read result and the value specified by AndData, and writes the result to the
5371 64-bit MSR specified by Index. The lower 32-bits of the value written to the
5372 MSR are returned. Extra left bits in AndData are stripped. The caller must
5373 either guarantee that Index and the data written is valid, or the caller must
5374 set up exception handlers to catch the exceptions. This function is only
5375 available on IA-32 and x64.
5377 If StartBit is greater than 31, then ASSERT().
5378 If EndBit is greater than 31, then ASSERT().
5379 If EndBit is less than StartBit, then ASSERT().
5381 @param Index The 32-bit MSR index to write.
5382 @param StartBit The ordinal of the least significant bit in the bit field.
5384 @param EndBit The ordinal of the most significant bit in the bit field.
5386 @param AndData The value to AND with the read value from the MSR.
5388 @return The lower 32-bit of the value written to the MSR.
5393 AsmMsrBitFieldAnd32 (
5402 Reads a bit field in a 64-bit MSR, performs a bitwise AND followed by a
5403 bitwise OR, and writes the result back to the bit field in the
5406 Reads the 64-bit MSR specified by Index, performs a bitwise AND followed by a
5407 bitwise OR between the read result and the value specified by
5408 AndData, and writes the result to the 64-bit MSR specified by Index. The
5409 lower 32-bits of the value written to the MSR are returned. Extra left bits
5410 in both AndData and OrData are stripped. The caller must either guarantee
5411 that Index and the data written is valid, or the caller must set up exception
5412 handlers to catch the exceptions. This function is only available on IA-32
5415 If StartBit is greater than 31, then ASSERT().
5416 If EndBit is greater than 31, then ASSERT().
5417 If EndBit is less than StartBit, then ASSERT().
5419 @param Index The 32-bit MSR index to write.
5420 @param StartBit The ordinal of the least significant bit in the bit field.
5422 @param EndBit The ordinal of the most significant bit in the bit field.
5424 @param AndData The value to AND with the read value from the MSR.
5425 @param OrData The value to OR with the result of the AND operation.
5427 @return The lower 32-bit of the value written to the MSR.
5432 AsmMsrBitFieldAndThenOr32 (
5442 Returns a 64-bit Machine Specific Register(MSR).
5444 Reads and returns the 64-bit MSR specified by Index. No parameter checking is
5445 performed on Index, and some Index values may cause CPU exceptions. The
5446 caller must either guarantee that Index is valid, or the caller must set up
5447 exception handlers to catch the exceptions. This function is only available
5450 @param Index The 32-bit MSR index to read.
5452 @return The value of the MSR identified by Index.
5463 Writes a 64-bit value to a Machine Specific Register(MSR), and returns the
5466 Writes the 64-bit value specified by Value to the MSR specified by Index. The
5467 64-bit value written to the MSR is returned. No parameter checking is
5468 performed on Index or Value, and some of these may cause CPU exceptions. The
5469 caller must either guarantee that Index and Value are valid, or the caller
5470 must establish proper exception handlers. This function is only available on
5473 @param Index The 32-bit MSR index to write.
5474 @param Value The 64-bit value to write to the MSR.
5488 Reads a 64-bit MSR, performs a bitwise OR, and writes the result
5489 back to the 64-bit MSR.
5491 Reads the 64-bit MSR specified by Index, performs a bitwise OR
5492 between the read result and the value specified by OrData, and writes the
5493 result to the 64-bit MSR specified by Index. The value written to the MSR is
5494 returned. No parameter checking is performed on Index or OrData, and some of
5495 these may cause CPU exceptions. The caller must either guarantee that Index
5496 and OrData are valid, or the caller must establish proper exception handlers.
5497 This function is only available on IA-32 and x64.
5499 @param Index The 32-bit MSR index to write.
5500 @param OrData The value to OR with the read value from the MSR.
5502 @return The value written back to the MSR.
5514 Reads a 64-bit MSR, performs a bitwise AND, and writes the result back to the
5517 Reads the 64-bit MSR specified by Index, performs a bitwise AND between the
5518 read result and the value specified by OrData, and writes the result to the
5519 64-bit MSR specified by Index. The value written to the MSR is returned. No
5520 parameter checking is performed on Index or OrData, and some of these may
5521 cause CPU exceptions. The caller must either guarantee that Index and OrData
5522 are valid, or the caller must establish proper exception handlers. This
5523 function is only available on IA-32 and x64.
5525 @param Index The 32-bit MSR index to write.
5526 @param AndData The value to AND with the read value from the MSR.
5528 @return The value written back to the MSR.
5540 Reads a 64-bit MSR, performs a bitwise AND followed by a bitwise
5541 OR, and writes the result back to the 64-bit MSR.
5543 Reads the 64-bit MSR specified by Index, performs a bitwise AND between read
5544 result and the value specified by AndData, performs a bitwise OR
5545 between the result of the AND operation and the value specified by OrData,
5546 and writes the result to the 64-bit MSR specified by Index. The value written
5547 to the MSR is returned. No parameter checking is performed on Index, AndData,
5548 or OrData, and some of these may cause CPU exceptions. The caller must either
5549 guarantee that Index, AndData, and OrData are valid, or the caller must
5550 establish proper exception handlers. This function is only available on IA-32
5553 @param Index The 32-bit MSR index to write.
5554 @param AndData The value to AND with the read value from the MSR.
5555 @param OrData The value to OR with the result of the AND operation.
5557 @return The value written back to the MSR.
5570 Reads a bit field of an MSR.
5572 Reads the bit field in the 64-bit MSR. The bit field is specified by the
5573 StartBit and the EndBit. The value of the bit field is returned. The caller
5574 must either guarantee that Index is valid, or the caller must set up
5575 exception handlers to catch the exceptions. This function is only available
5578 If StartBit is greater than 63, then ASSERT().
5579 If EndBit is greater than 63, then ASSERT().
5580 If EndBit is less than StartBit, then ASSERT().
5582 @param Index The 32-bit MSR index to read.
5583 @param StartBit The ordinal of the least significant bit in the bit field.
5585 @param EndBit The ordinal of the most significant bit in the bit field.
5588 @return The value read from the MSR.
5593 AsmMsrBitFieldRead64 (
5601 Writes a bit field to an MSR.
5603 Writes Value to a bit field in a 64-bit MSR. The bit field is specified by
5604 the StartBit and the EndBit. All other bits in the destination MSR are
5605 preserved. The MSR written is returned. The caller must either guarantee
5606 that Index and the data written is valid, or the caller must set up exception
5607 handlers to catch the exceptions. This function is only available on IA-32 and x64.
5609 If StartBit is greater than 63, then ASSERT().
5610 If EndBit is greater than 63, then ASSERT().
5611 If EndBit is less than StartBit, then ASSERT().
5613 @param Index The 32-bit MSR index to write.
5614 @param StartBit The ordinal of the least significant bit in the bit field.
5616 @param EndBit The ordinal of the most significant bit in the bit field.
5618 @param Value New value of the bit field.
5620 @return The value written back to the MSR.
5625 AsmMsrBitFieldWrite64 (
5634 Reads a bit field in a 64-bit MSR, performs a bitwise OR, and
5635 writes the result back to the bit field in the 64-bit MSR.
5637 Reads the 64-bit MSR specified by Index, performs a bitwise OR
5638 between the read result and the value specified by OrData, and writes the
5639 result to the 64-bit MSR specified by Index. The value written to the MSR is
5640 returned. Extra left bits in OrData are stripped. The caller must either
5641 guarantee that Index and the data written is valid, or the caller must set up
5642 exception handlers to catch the exceptions. This function is only available
5645 If StartBit is greater than 63, then ASSERT().
5646 If EndBit is greater than 63, then ASSERT().
5647 If EndBit is less than StartBit, then ASSERT().
5649 @param Index The 32-bit MSR index to write.
5650 @param StartBit The ordinal of the least significant bit in the bit field.
5652 @param EndBit The ordinal of the most significant bit in the bit field.
5654 @param OrData The value to OR with the read value from the bit field.
5656 @return The value written back to the MSR.
5661 AsmMsrBitFieldOr64 (
5670 Reads a bit field in a 64-bit MSR, performs a bitwise AND, and writes the
5671 result back to the bit field in the 64-bit MSR.
5673 Reads the 64-bit MSR specified by Index, performs a bitwise AND between the
5674 read result and the value specified by AndData, and writes the result to the
5675 64-bit MSR specified by Index. The value written to the MSR is returned.
5676 Extra left bits in AndData are stripped. The caller must either guarantee
5677 that Index and the data written is valid, or the caller must set up exception
5678 handlers to catch the exceptions. This function is only available on IA-32
5681 If StartBit is greater than 63, then ASSERT().
5682 If EndBit is greater than 63, then ASSERT().
5683 If EndBit is less than StartBit, then ASSERT().
5685 @param Index The 32-bit MSR index to write.
5686 @param StartBit The ordinal of the least significant bit in the bit field.
5688 @param EndBit The ordinal of the most significant bit in the bit field.
5690 @param AndData The value to AND with the read value from the bit field.
5692 @return The value written back to the MSR.
5697 AsmMsrBitFieldAnd64 (
5706 Reads a bit field in a 64-bit MSR, performs a bitwise AND followed by a
5707 bitwise OR, and writes the result back to the bit field in the
5710 Reads the 64-bit MSR specified by Index, performs a bitwise AND followed by
5711 a bitwise OR between the read result and the value specified by
5712 AndData, and writes the result to the 64-bit MSR specified by Index. The
5713 value written to the MSR is returned. Extra left bits in both AndData and
5714 OrData are stripped. The caller must either guarantee that Index and the data
5715 written is valid, or the caller must set up exception handlers to catch the
5716 exceptions. This function is only available on IA-32 and x64.
5718 If StartBit is greater than 63, then ASSERT().
5719 If EndBit is greater than 63, then ASSERT().
5720 If EndBit is less than StartBit, then ASSERT().
5722 @param Index The 32-bit MSR index to write.
5723 @param StartBit The ordinal of the least significant bit in the bit field.
5725 @param EndBit The ordinal of the most significant bit in the bit field.
5727 @param AndData The value to AND with the read value from the bit field.
5728 @param OrData The value to OR with the result of the AND operation.
5730 @return The value written back to the MSR.
5735 AsmMsrBitFieldAndThenOr64 (
5745 Reads the current value of the EFLAGS register.
5747 Reads and returns the current value of the EFLAGS register. This function is
5748 only available on IA-32 and x64. This returns a 32-bit value on IA-32 and a
5749 64-bit value on x64.
5751 @return EFLAGS on IA-32 or RFLAGS on x64.
5762 Reads the current value of the Control Register 0 (CR0).
5764 Reads and returns the current value of CR0. This function is only available
5765 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
5768 @return The value of the Control Register 0 (CR0).
5779 Reads the current value of the Control Register 2 (CR2).
5781 Reads and returns the current value of CR2. This function is only available
5782 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
5785 @return The value of the Control Register 2 (CR2).
5796 Reads the current value of the Control Register 3 (CR3).
5798 Reads and returns the current value of CR3. This function is only available
5799 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
5802 @return The value of the Control Register 3 (CR3).
5813 Reads the current value of the Control Register 4 (CR4).
5815 Reads and returns the current value of CR4. This function is only available
5816 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
5819 @return The value of the Control Register 4 (CR4).
5830 Writes a value to Control Register 0 (CR0).
5832 Writes and returns a new value to CR0. This function is only available on
5833 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
5835 @param Cr0 The value to write to CR0.
5837 @return The value written to CR0.
5848 Writes a value to Control Register 2 (CR2).
5850 Writes and returns a new value to CR2. This function is only available on
5851 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
5853 @param Cr2 The value to write to CR2.
5855 @return The value written to CR2.
5866 Writes a value to Control Register 3 (CR3).
5868 Writes and returns a new value to CR3. This function is only available on
5869 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
5871 @param Cr3 The value to write to CR3.
5873 @return The value written to CR3.
5884 Writes a value to Control Register 4 (CR4).
5886 Writes and returns a new value to CR4. This function is only available on
5887 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
5889 @param Cr4 The value to write to CR4.
5891 @return The value written to CR4.
5902 Reads the current value of Debug Register 0 (DR0).
5904 Reads and returns the current value of DR0. This function is only available
5905 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
5908 @return The value of Debug Register 0 (DR0).
5919 Reads the current value of Debug Register 1 (DR1).
5921 Reads and returns the current value of DR1. This function is only available
5922 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
5925 @return The value of Debug Register 1 (DR1).
5936 Reads the current value of Debug Register 2 (DR2).
5938 Reads and returns the current value of DR2. This function is only available
5939 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
5942 @return The value of Debug Register 2 (DR2).
5953 Reads the current value of Debug Register 3 (DR3).
5955 Reads and returns the current value of DR3. This function is only available
5956 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
5959 @return The value of Debug Register 3 (DR3).
5970 Reads the current value of Debug Register 4 (DR4).
5972 Reads and returns the current value of DR4. This function is only available
5973 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
5976 @return The value of Debug Register 4 (DR4).
5987 Reads the current value of Debug Register 5 (DR5).
5989 Reads and returns the current value of DR5. This function is only available
5990 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
5993 @return The value of Debug Register 5 (DR5).
6004 Reads the current value of Debug Register 6 (DR6).
6006 Reads and returns the current value of DR6. This function is only available
6007 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
6010 @return The value of Debug Register 6 (DR6).
6021 Reads the current value of Debug Register 7 (DR7).
6023 Reads and returns the current value of DR7. This function is only available
6024 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
6027 @return The value of Debug Register 7 (DR7).
6038 Writes a value to Debug Register 0 (DR0).
6040 Writes and returns a new value to DR0. This function is only available on
6041 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
6043 @param Dr0 The value to write to Dr0.
6045 @return The value written to Debug Register 0 (DR0).
6056 Writes a value to Debug Register 1 (DR1).
6058 Writes and returns a new value to DR1. This function is only available on
6059 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
6061 @param Dr1 The value to write to Dr1.
6063 @return The value written to Debug Register 1 (DR1).
6074 Writes a value to Debug Register 2 (DR2).
6076 Writes and returns a new value to DR2. This function is only available on
6077 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
6079 @param Dr2 The value to write to Dr2.
6081 @return The value written to Debug Register 2 (DR2).
6092 Writes a value to Debug Register 3 (DR3).
6094 Writes and returns a new value to DR3. This function is only available on
6095 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
6097 @param Dr3 The value to write to Dr3.
6099 @return The value written to Debug Register 3 (DR3).
6110 Writes a value to Debug Register 4 (DR4).
6112 Writes and returns a new value to DR4. This function is only available on
6113 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
6115 @param Dr4 The value to write to Dr4.
6117 @return The value written to Debug Register 4 (DR4).
6128 Writes a value to Debug Register 5 (DR5).
6130 Writes and returns a new value to DR5. This function is only available on
6131 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
6133 @param Dr5 The value to write to Dr5.
6135 @return The value written to Debug Register 5 (DR5).
6146 Writes a value to Debug Register 6 (DR6).
6148 Writes and returns a new value to DR6. This function is only available on
6149 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
6151 @param Dr6 The value to write to Dr6.
6153 @return The value written to Debug Register 6 (DR6).
6164 Writes a value to Debug Register 7 (DR7).
6166 Writes and returns a new value to DR7. This function is only available on
6167 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
6169 @param Dr7 The value to write to Dr7.
6171 @return The value written to Debug Register 7 (DR7).
6182 Reads the current value of Code Segment Register (CS).
6184 Reads and returns the current value of CS. This function is only available on
6187 @return The current value of CS.
6198 Reads the current value of Data Segment Register (DS).
6200 Reads and returns the current value of DS. This function is only available on
6203 @return The current value of DS.
6214 Reads the current value of Extra Segment Register (ES).
6216 Reads and returns the current value of ES. This function is only available on
6219 @return The current value of ES.
6230 Reads the current value of FS Data Segment Register (FS).
6232 Reads and returns the current value of FS. This function is only available on
6235 @return The current value of FS.
6246 Reads the current value of GS Data Segment Register (GS).
6248 Reads and returns the current value of GS. This function is only available on
6251 @return The current value of GS.
6262 Reads the current value of Stack Segment Register (SS).
6264 Reads and returns the current value of SS. This function is only available on
6267 @return The current value of SS.
6278 Reads the current value of Task Register (TR).
6280 Reads and returns the current value of TR. This function is only available on
6283 @return The current value of TR.
6294 Reads the current Global Descriptor Table Register(GDTR) descriptor.
6296 Reads and returns the current GDTR descriptor and returns it in Gdtr. This
6297 function is only available on IA-32 and x64.
6299 If Gdtr is NULL, then ASSERT().
6301 @param Gdtr Pointer to a GDTR descriptor.
6307 OUT IA32_DESCRIPTOR
*Gdtr
6312 Writes the current Global Descriptor Table Register (GDTR) descriptor.
6314 Writes and the current GDTR descriptor specified by Gdtr. This function is
6315 only available on IA-32 and x64.
6317 If Gdtr is NULL, then ASSERT().
6319 @param Gdtr Pointer to a GDTR descriptor.
6325 IN CONST IA32_DESCRIPTOR
*Gdtr
6330 Reads the current Interrupt Descriptor Table Register(IDTR) descriptor.
6332 Reads and returns the current IDTR descriptor and returns it in Idtr. This
6333 function is only available on IA-32 and x64.
6335 If Idtr is NULL, then ASSERT().
6337 @param Idtr Pointer to a IDTR descriptor.
6343 OUT IA32_DESCRIPTOR
*Idtr
6348 Writes the current Interrupt Descriptor Table Register(IDTR) descriptor.
6350 Writes the current IDTR descriptor and returns it in Idtr. This function is
6351 only available on IA-32 and x64.
6353 If Idtr is NULL, then ASSERT().
6355 @param Idtr Pointer to a IDTR descriptor.
6361 IN CONST IA32_DESCRIPTOR
*Idtr
6366 Reads the current Local Descriptor Table Register(LDTR) selector.
6368 Reads and returns the current 16-bit LDTR descriptor value. This function is
6369 only available on IA-32 and x64.
6371 @return The current selector of LDT.
6382 Writes the current Local Descriptor Table Register (LDTR) selector.
6384 Writes and the current LDTR descriptor specified by Ldtr. This function is
6385 only available on IA-32 and x64.
6387 @param Ldtr 16-bit LDTR selector value.
6398 Save the current floating point/SSE/SSE2 context to a buffer.
6400 Saves the current floating point/SSE/SSE2 state to the buffer specified by
6401 Buffer. Buffer must be aligned on a 16-byte boundary. This function is only
6402 available on IA-32 and x64.
6404 If Buffer is NULL, then ASSERT().
6405 If Buffer is not aligned on a 16-byte boundary, then ASSERT().
6407 @param Buffer Pointer to a buffer to save the floating point/SSE/SSE2 context.
6413 OUT IA32_FX_BUFFER
*Buffer
6418 Restores the current floating point/SSE/SSE2 context from a buffer.
6420 Restores the current floating point/SSE/SSE2 state from the buffer specified
6421 by Buffer. Buffer must be aligned on a 16-byte boundary. This function is
6422 only available on IA-32 and x64.
6424 If Buffer is NULL, then ASSERT().
6425 If Buffer is not aligned on a 16-byte boundary, then ASSERT().
6426 If Buffer was not saved with AsmFxSave(), then ASSERT().
6428 @param Buffer Pointer to a buffer to save the floating point/SSE/SSE2 context.
6434 IN CONST IA32_FX_BUFFER
*Buffer
6439 Reads the current value of 64-bit MMX Register #0 (MM0).
6441 Reads and returns the current value of MM0. This function is only available
6444 @return The current value of MM0.
6455 Reads the current value of 64-bit MMX Register #1 (MM1).
6457 Reads and returns the current value of MM1. This function is only available
6460 @return The current value of MM1.
6471 Reads the current value of 64-bit MMX Register #2 (MM2).
6473 Reads and returns the current value of MM2. This function is only available
6476 @return The current value of MM2.
6487 Reads the current value of 64-bit MMX Register #3 (MM3).
6489 Reads and returns the current value of MM3. This function is only available
6492 @return The current value of MM3.
6503 Reads the current value of 64-bit MMX Register #4 (MM4).
6505 Reads and returns the current value of MM4. This function is only available
6508 @return The current value of MM4.
6519 Reads the current value of 64-bit MMX Register #5 (MM5).
6521 Reads and returns the current value of MM5. This function is only available
6524 @return The current value of MM5.
6535 Reads the current value of 64-bit MMX Register #6 (MM6).
6537 Reads and returns the current value of MM6. This function is only available
6540 @return The current value of MM6.
6551 Reads the current value of 64-bit MMX Register #7 (MM7).
6553 Reads and returns the current value of MM7. This function is only available
6556 @return The current value of MM7.
6567 Writes the current value of 64-bit MMX Register #0 (MM0).
6569 Writes the current value of MM0. This function is only available on IA32 and
6572 @param Value The 64-bit value to write to MM0.
6583 Writes the current value of 64-bit MMX Register #1 (MM1).
6585 Writes the current value of MM1. This function is only available on IA32 and
6588 @param Value The 64-bit value to write to MM1.
6599 Writes the current value of 64-bit MMX Register #2 (MM2).
6601 Writes the current value of MM2. This function is only available on IA32 and
6604 @param Value The 64-bit value to write to MM2.
6615 Writes the current value of 64-bit MMX Register #3 (MM3).
6617 Writes the current value of MM3. This function is only available on IA32 and
6620 @param Value The 64-bit value to write to MM3.
6631 Writes the current value of 64-bit MMX Register #4 (MM4).
6633 Writes the current value of MM4. This function is only available on IA32 and
6636 @param Value The 64-bit value to write to MM4.
6647 Writes the current value of 64-bit MMX Register #5 (MM5).
6649 Writes the current value of MM5. This function is only available on IA32 and
6652 @param Value The 64-bit value to write to MM5.
6663 Writes the current value of 64-bit MMX Register #6 (MM6).
6665 Writes the current value of MM6. This function is only available on IA32 and
6668 @param Value The 64-bit value to write to MM6.
6679 Writes the current value of 64-bit MMX Register #7 (MM7).
6681 Writes the current value of MM7. This function is only available on IA32 and
6684 @param Value The 64-bit value to write to MM7.
6695 Reads the current value of Time Stamp Counter (TSC).
6697 Reads and returns the current value of TSC. This function is only available
6700 @return The current value of TSC
6711 Reads the current value of a Performance Counter (PMC).
6713 Reads and returns the current value of performance counter specified by
6714 Index. This function is only available on IA-32 and x64.
6716 @param Index The 32-bit Performance Counter index to read.
6718 @return The value of the PMC specified by Index.
6729 Sets up a monitor buffer that is used by AsmMwait().
6731 Executes a MONITOR instruction with the register state specified by Eax, Ecx
6732 and Edx. Returns Eax. This function is only available on IA-32 and x64.
6734 @param Eax The value to load into EAX or RAX before executing the MONITOR
6736 @param Ecx The value to load into ECX or RCX before executing the MONITOR
6738 @param Edx The value to load into EDX or RDX before executing the MONITOR
6754 Executes an MWAIT instruction.
6756 Executes an MWAIT instruction with the register state specified by Eax and
6757 Ecx. Returns Eax. This function is only available on IA-32 and x64.
6759 @param Eax The value to load into EAX or RAX before executing the MONITOR
6761 @param Ecx The value to load into ECX or RCX before executing the MONITOR
6776 Executes a WBINVD instruction.
6778 Executes a WBINVD instruction. This function is only available on IA-32 and
6790 Executes a INVD instruction.
6792 Executes a INVD instruction. This function is only available on IA-32 and
6804 Flushes a cache line from all the instruction and data caches within the
6805 coherency domain of the CPU.
6807 Flushed the cache line specified by LinearAddress, and returns LinearAddress.
6808 This function is only available on IA-32 and x64.
6810 @param LinearAddress The address of the cache line to flush. If the CPU is
6811 in a physical addressing mode, then LinearAddress is a
6812 physical address. If the CPU is in a virtual
6813 addressing mode, then LinearAddress is a virtual
6816 @return LinearAddress
6821 IN VOID
*LinearAddress
6826 Enables the 32-bit paging mode on the CPU.
6828 Enables the 32-bit paging mode on the CPU. CR0, CR3, CR4, and the page tables
6829 must be properly initialized prior to calling this service. This function
6830 assumes the current execution mode is 32-bit protected mode. This function is
6831 only available on IA-32. After the 32-bit paging mode is enabled, control is
6832 transferred to the function specified by EntryPoint using the new stack
6833 specified by NewStack and passing in the parameters specified by Context1 and
6834 Context2. Context1 and Context2 are optional and may be NULL. The function
6835 EntryPoint must never return.
6837 If the current execution mode is not 32-bit protected mode, then ASSERT().
6838 If EntryPoint is NULL, then ASSERT().
6839 If NewStack is NULL, then ASSERT().
6841 There are a number of constraints that must be followed before calling this
6843 1) Interrupts must be disabled.
6844 2) The caller must be in 32-bit protected mode with flat descriptors. This
6845 means all descriptors must have a base of 0 and a limit of 4GB.
6846 3) CR0 and CR4 must be compatible with 32-bit protected mode with flat
6848 4) CR3 must point to valid page tables that will be used once the transition
6849 is complete, and those page tables must guarantee that the pages for this
6850 function and the stack are identity mapped.
6852 @param EntryPoint A pointer to function to call with the new stack after
6854 @param Context1 A pointer to the context to pass into the EntryPoint
6855 function as the first parameter after paging is enabled.
6856 @param Context2 A pointer to the context to pass into the EntryPoint
6857 function as the second parameter after paging is enabled.
6858 @param NewStack A pointer to the new stack to use for the EntryPoint
6859 function after paging is enabled.
6865 IN SWITCH_STACK_ENTRY_POINT EntryPoint
,
6866 IN VOID
*Context1
, OPTIONAL
6867 IN VOID
*Context2
, OPTIONAL
6873 Disables the 32-bit paging mode on the CPU.
6875 Disables the 32-bit paging mode on the CPU and returns to 32-bit protected
6876 mode. This function assumes the current execution mode is 32-paged protected
6877 mode. This function is only available on IA-32. After the 32-bit paging mode
6878 is disabled, control is transferred to the function specified by EntryPoint
6879 using the new stack specified by NewStack and passing in the parameters
6880 specified by Context1 and Context2. Context1 and Context2 are optional and
6881 may be NULL. The function EntryPoint must never return.
6883 If the current execution mode is not 32-bit paged mode, then ASSERT().
6884 If EntryPoint is NULL, then ASSERT().
6885 If NewStack is NULL, then ASSERT().
6887 There are a number of constraints that must be followed before calling this
6889 1) Interrupts must be disabled.
6890 2) The caller must be in 32-bit paged mode.
6891 3) CR0, CR3, and CR4 must be compatible with 32-bit paged mode.
6892 4) CR3 must point to valid page tables that guarantee that the pages for
6893 this function and the stack are identity mapped.
6895 @param EntryPoint A pointer to function to call with the new stack after
6897 @param Context1 A pointer to the context to pass into the EntryPoint
6898 function as the first parameter after paging is disabled.
6899 @param Context2 A pointer to the context to pass into the EntryPoint
6900 function as the second parameter after paging is
6902 @param NewStack A pointer to the new stack to use for the EntryPoint
6903 function after paging is disabled.
6908 AsmDisablePaging32 (
6909 IN SWITCH_STACK_ENTRY_POINT EntryPoint
,
6910 IN VOID
*Context1
, OPTIONAL
6911 IN VOID
*Context2
, OPTIONAL
6917 Enables the 64-bit paging mode on the CPU.
6919 Enables the 64-bit paging mode on the CPU. CR0, CR3, CR4, and the page tables
6920 must be properly initialized prior to calling this service. This function
6921 assumes the current execution mode is 32-bit protected mode with flat
6922 descriptors. This function is only available on IA-32. After the 64-bit
6923 paging mode is enabled, control is transferred to the function specified by
6924 EntryPoint using the new stack specified by NewStack and passing in the
6925 parameters specified by Context1 and Context2. Context1 and Context2 are
6926 optional and may be 0. The function EntryPoint must never return.
6928 If the current execution mode is not 32-bit protected mode with flat
6929 descriptors, then ASSERT().
6930 If EntryPoint is 0, then ASSERT().
6931 If NewStack is 0, then ASSERT().
6933 @param Cs The 16-bit selector to load in the CS before EntryPoint
6934 is called. The descriptor in the GDT that this selector
6935 references must be setup for long mode.
6936 @param EntryPoint The 64-bit virtual address of the function to call with
6937 the new stack after paging is enabled.
6938 @param Context1 The 64-bit virtual address of the context to pass into
6939 the EntryPoint function as the first parameter after
6941 @param Context2 The 64-bit virtual address of the context to pass into
6942 the EntryPoint function as the second parameter after
6944 @param NewStack The 64-bit virtual address of the new stack to use for
6945 the EntryPoint function after paging is enabled.
6952 IN UINT64 EntryPoint
,
6953 IN UINT64 Context1
, OPTIONAL
6954 IN UINT64 Context2
, OPTIONAL
6960 Disables the 64-bit paging mode on the CPU.
6962 Disables the 64-bit paging mode on the CPU and returns to 32-bit protected
6963 mode. This function assumes the current execution mode is 64-paging mode.
6964 This function is only available on x64. After the 64-bit paging mode is
6965 disabled, control is transferred to the function specified by EntryPoint
6966 using the new stack specified by NewStack and passing in the parameters
6967 specified by Context1 and Context2. Context1 and Context2 are optional and
6968 may be 0. The function EntryPoint must never return.
6970 If the current execution mode is not 64-bit paged mode, then ASSERT().
6971 If EntryPoint is 0, then ASSERT().
6972 If NewStack is 0, then ASSERT().
6974 @param Cs The 16-bit selector to load in the CS before EntryPoint
6975 is called. The descriptor in the GDT that this selector
6976 references must be setup for 32-bit protected mode.
6977 @param EntryPoint The 64-bit virtual address of the function to call with
6978 the new stack after paging is disabled.
6979 @param Context1 The 64-bit virtual address of the context to pass into
6980 the EntryPoint function as the first parameter after
6982 @param Context2 The 64-bit virtual address of the context to pass into
6983 the EntryPoint function as the second parameter after
6985 @param NewStack The 64-bit virtual address of the new stack to use for
6986 the EntryPoint function after paging is disabled.
6991 AsmDisablePaging64 (
6993 IN UINT32 EntryPoint
,
6994 IN UINT32 Context1
, OPTIONAL
6995 IN UINT32 Context2
, OPTIONAL
7001 // 16-bit thunking services
7005 Retrieves the properties for 16-bit thunk functions.
7007 Computes the size of the buffer and stack below 1MB required to use the
7008 AsmPrepareThunk16(), AsmThunk16() and AsmPrepareAndThunk16() functions. This
7009 buffer size is returned in RealModeBufferSize, and the stack size is returned
7010 in ExtraStackSize. If parameters are passed to the 16-bit real mode code,
7011 then the actual minimum stack size is ExtraStackSize plus the maximum number
7012 of bytes that need to be passed to the 16-bit real mode code.
7014 If RealModeBufferSize is NULL, then ASSERT().
7015 If ExtraStackSize is NULL, then ASSERT().
7017 @param RealModeBufferSize A pointer to the size of the buffer below 1MB
7018 required to use the 16-bit thunk functions.
7019 @param ExtraStackSize A pointer to the extra size of stack below 1MB
7020 that the 16-bit thunk functions require for
7021 temporary storage in the transition to and from
7027 AsmGetThunk16Properties (
7028 OUT UINT32
*RealModeBufferSize
,
7029 OUT UINT32
*ExtraStackSize
7034 Prepares all structures a code required to use AsmThunk16().
7036 Prepares all structures and code required to use AsmThunk16().
7038 This interface is limited to be used in either physical mode or virtual modes with paging enabled where the
7039 virtual to physical mappings for ThunkContext.RealModeBuffer is mapped 1:1.
7041 If ThunkContext is NULL, then ASSERT().
7043 @param ThunkContext A pointer to the context structure that describes the
7044 16-bit real mode code to call.
7050 OUT THUNK_CONTEXT
*ThunkContext
7055 Transfers control to a 16-bit real mode entry point and returns the results.
7057 Transfers control to a 16-bit real mode entry point and returns the results.
7058 AsmPrepareThunk16() must be called with ThunkContext before this function is used.
7059 This function must be called with interrupts disabled.
7061 The register state from the RealModeState field of ThunkContext is restored just prior
7062 to calling the 16-bit real mode entry point. This includes the EFLAGS field of RealModeState,
7063 which is used to set the interrupt state when a 16-bit real mode entry point is called.
7064 Control is transferred to the 16-bit real mode entry point specified by the CS and Eip fields of RealModeState.
7065 The stack is initialized to the SS and ESP fields of RealModeState. Any parameters passed to
7066 the 16-bit real mode code must be populated by the caller at SS:ESP prior to calling this function.
7067 The 16-bit real mode entry point is invoked with a 16-bit CALL FAR instruction,
7068 so when accessing stack contents, the 16-bit real mode code must account for the 16-bit segment
7069 and 16-bit offset of the return address that were pushed onto the stack. The 16-bit real mode entry
7070 point must exit with a RETF instruction. The register state is captured into RealModeState immediately
7071 after the RETF instruction is executed.
7073 If EFLAGS specifies interrupts enabled, or any of the 16-bit real mode code enables interrupts,
7074 or any of the 16-bit real mode code makes a SW interrupt, then the caller is responsible for making sure
7075 the IDT at address 0 is initialized to handle any HW or SW interrupts that may occur while in 16-bit real mode.
7077 If EFLAGS specifies interrupts enabled, or any of the 16-bit real mode code enables interrupts,
7078 then the caller is responsible for making sure the 8259 PIC is in a state compatible with 16-bit real mode.
7079 This includes the base vectors, the interrupt masks, and the edge/level trigger mode.
7081 If THUNK_ATTRIBUTE_BIG_REAL_MODE is set in the ThunkAttributes field of ThunkContext, then the user code
7082 is invoked in big real mode. Otherwise, the user code is invoked in 16-bit real mode with 64KB segment limits.
7084 If neither THUNK_ATTRIBUTE_DISABLE_A20_MASK_INT_15 nor THUNK_ATTRIBUTE_DISABLE_A20_MASK_KBD_CTRL are set in
7085 ThunkAttributes, then it is assumed that the user code did not enable the A20 mask, and no attempt is made to
7086 disable the A20 mask.
7088 If THUNK_ATTRIBUTE_DISABLE_A20_MASK_INT_15 is set and THUNK_ATTRIBUTE_DISABLE_A20_MASK_KBD_CTRL is clear in
7089 ThunkAttributes, then attempt to use the INT 15 service to disable the A20 mask. If this INT 15 call fails,
7090 then attempt to disable the A20 mask by directly accessing the 8042 keyboard controller I/O ports.
7092 If THUNK_ATTRIBUTE_DISABLE_A20_MASK_INT_15 is clear and THUNK_ATTRIBUTE_DISABLE_A20_MASK_KBD_CTRL is set in
7093 ThunkAttributes, then attempt to disable the A20 mask by directly accessing the 8042 keyboard controller I/O ports.
7095 If ThunkContext is NULL, then ASSERT().
7096 If AsmPrepareThunk16() was not previously called with ThunkContext, then ASSERT().
7097 If both THUNK_ATTRIBUTE_DISABLE_A20_MASK_INT_15 and THUNK_ATTRIBUTE_DISABLE_A20_MASK_KBD_CTRL are set in
7098 ThunkAttributes, then ASSERT().
7100 This interface is limited to be used in either physical mode or virtual modes with paging enabled where the
7101 virtual to physical mappings for ThunkContext.RealModeBuffer is mapped 1:1.
7103 @param ThunkContext A pointer to the context structure that describes the
7104 16-bit real mode code to call.
7110 IN OUT THUNK_CONTEXT
*ThunkContext
7115 Prepares all structures and code for a 16-bit real mode thunk, transfers
7116 control to a 16-bit real mode entry point, and returns the results.
7118 Prepares all structures and code for a 16-bit real mode thunk, transfers
7119 control to a 16-bit real mode entry point, and returns the results. If the
7120 caller only need to perform a single 16-bit real mode thunk, then this
7121 service should be used. If the caller intends to make more than one 16-bit
7122 real mode thunk, then it is more efficient if AsmPrepareThunk16() is called
7123 once and AsmThunk16() can be called for each 16-bit real mode thunk.
7125 This interface is limited to be used in either physical mode or virtual modes with paging enabled where the
7126 virtual to physical mappings for ThunkContext.RealModeBuffer is mapped 1:1.
7128 See AsmPrepareThunk16() and AsmThunk16() for the detailed description and ASSERT() conditions.
7130 @param ThunkContext A pointer to the context structure that describes the
7131 16-bit real mode code to call.
7136 AsmPrepareAndThunk16 (
7137 IN OUT THUNK_CONTEXT
*ThunkContext