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 /// IA32 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 /// IPF 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 context buffer used by SetJump() and LongJump()
104 } BASE_LIBRARY_JUMP_BUFFER
;
106 #define BASE_LIBRARY_JUMP_BUFFER_ALIGNMENT 8
108 #endif // defined (MDE_CPU_X64)
110 #if defined (MDE_CPU_EBC)
112 /// EBC context buffer used by SetJump() and LongJump()
120 } BASE_LIBRARY_JUMP_BUFFER
;
122 #define BASE_LIBRARY_JUMP_BUFFER_ALIGNMENT 8
124 #endif // defined (MDE_CPU_EBC)
131 Copies one Null-terminated Unicode string to another Null-terminated Unicode
132 string and returns the new Unicode string.
134 This function copies the contents of the Unicode string Source to the Unicode
135 string Destination, and returns Destination. If Source and Destination
136 overlap, then the results are undefined.
138 If Destination is NULL, then ASSERT().
139 If Destination is not aligned on a 16-bit boundary, then ASSERT().
140 If Source is NULL, then ASSERT().
141 If Source is not aligned on a 16-bit boundary, then ASSERT().
142 If Source and Destination overlap, then ASSERT().
143 If PcdMaximumUnicodeStringLength is not zero, and Source contains more than
144 PcdMaximumUnicodeStringLength Unicode characters not including the
145 Null-terminator, then ASSERT().
147 @param Destination Pointer to a Null-terminated Unicode string.
148 @param Source Pointer to a Null-terminated Unicode string.
156 OUT CHAR16
*Destination
,
157 IN CONST CHAR16
*Source
162 Copies up to a specified length from one Null-terminated Unicode string to
163 another Null-terminated Unicode string and returns the new Unicode string.
165 This function copies the contents of the Unicode string Source to the Unicode
166 string Destination, and returns Destination. At most, Length Unicode
167 characters are copied from Source to Destination. If Length is 0, then
168 Destination is returned unmodified. If Length is greater that the number of
169 Unicode characters in Source, then Destination is padded with Null Unicode
170 characters. If Source and Destination overlap, then the results are
173 If Length > 0 and Destination is NULL, then ASSERT().
174 If Length > 0 and Destination is not aligned on a 16-bit boundary, then ASSERT().
175 If Length > 0 and Source is NULL, then ASSERT().
176 If Length > 0 and Source is not aligned on a 16-bit boundary, then ASSERT().
177 If Source and Destination overlap, then ASSERT().
178 If PcdMaximumUnicodeStringLength is not zero, and Source contains more than
179 PcdMaximumUnicodeStringLength Unicode characters not including the
180 Null-terminator, then ASSERT().
182 @param Destination Pointer to a Null-terminated Unicode string.
183 @param Source Pointer to a Null-terminated Unicode string.
184 @param Length Maximum number of Unicode characters to copy.
192 OUT CHAR16
*Destination
,
193 IN CONST CHAR16
*Source
,
199 Returns the length of a Null-terminated Unicode string.
201 This function returns the number of Unicode characters in the Null-terminated
202 Unicode string specified by String.
204 If String is NULL, then ASSERT().
205 If String is not aligned on a 16-bit boundary, then ASSERT().
206 If PcdMaximumUnicodeStringLength is not zero, and String contains more than
207 PcdMaximumUnicodeStringLength Unicode characters not including the
208 Null-terminator, then ASSERT().
210 @param String Pointer to a Null-terminated Unicode string.
212 @return The length of String.
218 IN CONST CHAR16
*String
223 Returns the size of a Null-terminated Unicode string in bytes, including the
226 This function returns the size, in bytes, of the Null-terminated Unicode string
229 If String is NULL, then ASSERT().
230 If String is not aligned on a 16-bit boundary, then ASSERT().
231 If PcdMaximumUnicodeStringLength is not zero, and String contains more than
232 PcdMaximumUnicodeStringLength Unicode characters not including the
233 Null-terminator, then ASSERT().
235 @param String Pointer to a Null-terminated Unicode string.
237 @return The size of String.
243 IN CONST CHAR16
*String
248 Compares two Null-terminated Unicode strings, and returns the difference
249 between the first mismatched Unicode characters.
251 This function compares the Null-terminated Unicode string FirstString to the
252 Null-terminated Unicode string SecondString. If FirstString is identical to
253 SecondString, then 0 is returned. Otherwise, the value returned is the first
254 mismatched Unicode character in SecondString subtracted from the first
255 mismatched Unicode character in FirstString.
257 If FirstString is NULL, then ASSERT().
258 If FirstString is not aligned on a 16-bit boundary, then ASSERT().
259 If SecondString is NULL, then ASSERT().
260 If SecondString is not aligned on a 16-bit boundary, then ASSERT().
261 If PcdMaximumUnicodeStringLength is not zero, and FirstString contains more
262 than PcdMaximumUnicodeStringLength Unicode characters not including the
263 Null-terminator, then ASSERT().
264 If PcdMaximumUnicodeStringLength is not zero, and SecondString contains more
265 than PcdMaximumUnicodeStringLength Unicode characters not including the
266 Null-terminator, then ASSERT().
268 @param FirstString Pointer to a Null-terminated Unicode string.
269 @param SecondString Pointer to a Null-terminated Unicode string.
271 @retval 0 FirstString is identical to SecondString.
272 @return others FirstString is not identical to SecondString.
278 IN CONST CHAR16
*FirstString
,
279 IN CONST CHAR16
*SecondString
284 Compares up to a specified length the contents of two Null-terminated Unicode strings,
285 and returns the difference between the first mismatched Unicode characters.
287 This function compares the Null-terminated Unicode string FirstString to the
288 Null-terminated Unicode string SecondString. At most, Length Unicode
289 characters will be compared. If Length is 0, then 0 is returned. If
290 FirstString is identical to SecondString, then 0 is returned. Otherwise, the
291 value returned is the first mismatched Unicode character in SecondString
292 subtracted from the first mismatched Unicode character in FirstString.
294 If Length > 0 and FirstString is NULL, then ASSERT().
295 If Length > 0 and FirstString is not aligned on a 16-bit boundary, then ASSERT().
296 If Length > 0 and SecondString is NULL, then ASSERT().
297 If Length > 0 and SecondString is not aligned on a 16-bit boundary, then ASSERT().
298 If PcdMaximumUnicodeStringLength is not zero, and FirstString contains more
299 than PcdMaximumUnicodeStringLength Unicode characters not including the
300 Null-terminator, then ASSERT().
301 If PcdMaximumUnicodeStringLength is not zero, and SecondString contains more
302 than PcdMaximumUnicodeStringLength Unicode characters not including the
303 Null-terminator, then ASSERT().
305 @param FirstString Pointer to a Null-terminated Unicode string.
306 @param SecondString Pointer to a Null-terminated Unicode string.
307 @param Length Maximum number of Unicode characters to compare.
309 @retval 0 FirstString is identical to SecondString.
310 @return others FirstString is not identical to SecondString.
316 IN CONST CHAR16
*FirstString
,
317 IN CONST CHAR16
*SecondString
,
323 Concatenates one Null-terminated Unicode string to another Null-terminated
324 Unicode string, and returns the concatenated Unicode string.
326 This function concatenates two Null-terminated Unicode strings. The contents
327 of Null-terminated Unicode string Source are concatenated to the end of
328 Null-terminated Unicode string Destination. The Null-terminated concatenated
329 Unicode String is returned. If Source and Destination overlap, then the
330 results are undefined.
332 If Destination is NULL, then ASSERT().
333 If Destination is not aligned on a 16-bit boundary, then ASSERT().
334 If Source is NULL, then ASSERT().
335 If Source is not aligned on a 16-bit boundary, then ASSERT().
336 If Source and Destination overlap, then ASSERT().
337 If PcdMaximumUnicodeStringLength is not zero, and Destination contains more
338 than PcdMaximumUnicodeStringLength Unicode characters not including the
339 Null-terminator, then ASSERT().
340 If PcdMaximumUnicodeStringLength is not zero, and Source contains more than
341 PcdMaximumUnicodeStringLength Unicode characters not including the
342 Null-terminator, then ASSERT().
343 If PcdMaximumUnicodeStringLength is not zero, and concatenating Destination
344 and Source results in a Unicode string with more than
345 PcdMaximumUnicodeStringLength Unicode characters not including the
346 Null-terminator, then ASSERT().
348 @param Destination Pointer to a Null-terminated Unicode string.
349 @param Source Pointer to a Null-terminated Unicode string.
357 IN OUT CHAR16
*Destination
,
358 IN CONST CHAR16
*Source
363 Concatenates up to a specified length one Null-terminated Unicode to the end
364 of another Null-terminated Unicode string, and returns the concatenated
367 This function concatenates two Null-terminated Unicode strings. The contents
368 of Null-terminated Unicode string Source are concatenated to the end of
369 Null-terminated Unicode string Destination, and Destination is returned. At
370 most, Length Unicode characters are concatenated from Source to the end of
371 Destination, and Destination is always Null-terminated. If Length is 0, then
372 Destination is returned unmodified. If Source and Destination overlap, then
373 the results are undefined.
375 If Destination is NULL, then ASSERT().
376 If Length > 0 and Destination is not aligned on a 16-bit boundary, then ASSERT().
377 If Length > 0 and Source is NULL, then ASSERT().
378 If Length > 0 and Source is not aligned on a 16-bit boundary, then ASSERT().
379 If Source and Destination overlap, then ASSERT().
380 If PcdMaximumUnicodeStringLength is not zero, and Destination contains more
381 than PcdMaximumUnicodeStringLength Unicode characters not including the
382 Null-terminator, then ASSERT().
383 If PcdMaximumUnicodeStringLength is not zero, and Source contains more than
384 PcdMaximumUnicodeStringLength Unicode characters not including the
385 Null-terminator, then ASSERT().
386 If PcdMaximumUnicodeStringLength is not zero, and concatenating Destination
387 and Source results in a Unicode string with more than
388 PcdMaximumUnicodeStringLength Unicode characters not including the
389 Null-terminator, then ASSERT().
391 @param Destination Pointer to a Null-terminated Unicode string.
392 @param Source Pointer to a Null-terminated Unicode string.
393 @param Length Maximum number of Unicode characters to concatenate from
402 IN OUT CHAR16
*Destination
,
403 IN CONST CHAR16
*Source
,
408 Returns the first occurrence of a Null-terminated Unicode sub-string
409 in a Null-terminated Unicode string.
411 This function scans the contents of the Null-terminated Unicode string
412 specified by String and returns the first occurrence of SearchString.
413 If SearchString is not found in String, then NULL is returned. If
414 the length of SearchString is zero, then String is
417 If String is NULL, then ASSERT().
418 If String is not aligned on a 16-bit boundary, then ASSERT().
419 If SearchString is NULL, then ASSERT().
420 If SearchString is not aligned on a 16-bit boundary, then ASSERT().
422 If PcdMaximumUnicodeStringLength is not zero, and SearchString
423 or String contains more than PcdMaximumUnicodeStringLength Unicode
424 characters not including the Null-terminator, then ASSERT().
426 @param String Pointer to a Null-terminated Unicode string.
427 @param SearchString Pointer to a Null-terminated Unicode string to search for.
429 @retval NULL If the SearchString does not appear in String.
430 @return others If there is a match.
436 IN CONST CHAR16
*String
,
437 IN CONST CHAR16
*SearchString
441 Convert a Null-terminated Unicode decimal string to a value of
444 This function returns a value of type UINTN by interpreting the contents
445 of the Unicode string specified by String as a decimal number. The format
446 of the input Unicode string String is:
448 [spaces] [decimal digits].
450 The valid decimal digit character is in the range [0-9]. The
451 function will ignore the pad space, which includes spaces or
452 tab characters, before [decimal digits]. The running zero in the
453 beginning of [decimal digits] will be ignored. Then, the function
454 stops at the first character that is a not a valid decimal character
455 or a Null-terminator, whichever one comes first.
457 If String is NULL, then ASSERT().
458 If String is not aligned in a 16-bit boundary, then ASSERT().
459 If String has only pad spaces, then 0 is returned.
460 If String has no pad spaces or valid decimal digits,
462 If the number represented by String overflows according
463 to the range defined by UINTN, then ASSERT().
465 If PcdMaximumUnicodeStringLength is not zero, and String contains
466 more than PcdMaximumUnicodeStringLength Unicode characters not including
467 the Null-terminator, then ASSERT().
469 @param String Pointer to a Null-terminated Unicode string.
471 @retval Value translated from String.
477 IN CONST CHAR16
*String
481 Convert a Null-terminated Unicode decimal string to a value of
484 This function returns a value of type UINT64 by interpreting the contents
485 of the Unicode string specified by String as a decimal number. The format
486 of the input Unicode string String is:
488 [spaces] [decimal digits].
490 The valid decimal digit character is in the range [0-9]. The
491 function will ignore the pad space, which includes spaces or
492 tab characters, before [decimal digits]. The running zero in the
493 beginning of [decimal digits] will be ignored. Then, the function
494 stops at the first character that is a not a valid decimal character
495 or a Null-terminator, whichever one comes first.
497 If String is NULL, then ASSERT().
498 If String is not aligned in a 16-bit boundary, then ASSERT().
499 If String has only pad spaces, then 0 is returned.
500 If String has no pad spaces or valid decimal digits,
502 If the number represented by String overflows according
503 to the range defined by UINT64, then ASSERT().
505 If PcdMaximumUnicodeStringLength is not zero, and String contains
506 more than PcdMaximumUnicodeStringLength Unicode characters not including
507 the Null-terminator, then ASSERT().
509 @param String Pointer to a Null-terminated Unicode string.
511 @retval Value translated from String.
517 IN CONST CHAR16
*String
522 Convert a Null-terminated Unicode hexadecimal string to a value of type UINTN.
524 This function returns a value of type UINTN by interpreting the contents
525 of the Unicode string specified by String as a hexadecimal number.
526 The format of the input Unicode string String is:
528 [spaces][zeros][x][hexadecimal digits].
530 The valid hexadecimal digit character is in the range [0-9], [a-f] and [A-F].
531 The prefix "0x" is optional. Both "x" and "X" is allowed in "0x" prefix.
532 If "x" appears in the input string, it must be prefixed with at least one 0.
533 The function will ignore the pad space, which includes spaces or tab characters,
534 before [zeros], [x] or [hexadecimal digit]. The running zero before [x] or
535 [hexadecimal digit] will be ignored. Then, the decoding starts after [x] or the
536 first valid hexadecimal digit. Then, the function stops at the first character that is
537 a not a valid hexadecimal character or NULL, whichever one comes first.
539 If String is NULL, then ASSERT().
540 If String is not aligned in a 16-bit boundary, then ASSERT().
541 If String has only pad spaces, then zero is returned.
542 If String has no leading pad spaces, leading zeros or valid hexadecimal digits,
543 then zero is returned.
544 If the number represented by String overflows according to the range defined by
545 UINTN, then ASSERT().
547 If PcdMaximumUnicodeStringLength is not zero, and String contains more than
548 PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator,
551 @param String Pointer to a Null-terminated Unicode string.
553 @retval Value translated from String.
559 IN CONST CHAR16
*String
564 Convert a Null-terminated Unicode hexadecimal string to a value of type UINT64.
566 This function returns a value of type UINT64 by interpreting the contents
567 of the Unicode string specified by String as a hexadecimal number.
568 The format of the input Unicode string String is
570 [spaces][zeros][x][hexadecimal digits].
572 The valid hexadecimal digit character is in the range [0-9], [a-f] and [A-F].
573 The prefix "0x" is optional. Both "x" and "X" is allowed in "0x" prefix.
574 If "x" appears in the input string, it must be prefixed with at least one 0.
575 The function will ignore the pad space, which includes spaces or tab characters,
576 before [zeros], [x] or [hexadecimal digit]. The running zero before [x] or
577 [hexadecimal digit] will be ignored. Then, the decoding starts after [x] or the
578 first valid hexadecimal digit. Then, the function stops at the first character that is
579 a not a valid hexadecimal character or NULL, whichever one comes first.
581 If String is NULL, then ASSERT().
582 If String is not aligned in a 16-bit boundary, then ASSERT().
583 If String has only pad spaces, then zero is returned.
584 If String has no leading pad spaces, leading zeros or valid hexadecimal digits,
585 then zero is returned.
586 If the number represented by String overflows according to the range defined by
587 UINT64, then ASSERT().
589 If PcdMaximumUnicodeStringLength is not zero, and String contains more than
590 PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator,
593 @param String Pointer to a Null-terminated Unicode string.
595 @retval Value translated from String.
601 IN CONST CHAR16
*String
605 Convert a Null-terminated Unicode string to a Null-terminated
606 ASCII string and returns the ASCII string.
608 This function converts the content of the Unicode string Source
609 to the ASCII string Destination by copying the lower 8 bits of
610 each Unicode character. It returns Destination.
612 If any Unicode characters in Source contain non-zero value in
613 the upper 8 bits, then ASSERT().
615 If Destination is NULL, then ASSERT().
616 If Source is NULL, then ASSERT().
617 If Source is not aligned on a 16-bit boundary, then ASSERT().
618 If Source and Destination overlap, then ASSERT().
620 If PcdMaximumUnicodeStringLength is not zero, and Source contains
621 more than PcdMaximumUnicodeStringLength Unicode characters not including
622 the Null-terminator, then ASSERT().
624 If PcdMaximumAsciiStringLength is not zero, and Source contains more
625 than PcdMaximumAsciiStringLength Unicode characters not including the
626 Null-terminator, then ASSERT().
628 @param Source Pointer to a Null-terminated Unicode string.
629 @param Destination Pointer to a Null-terminated ASCII string.
636 UnicodeStrToAsciiStr (
637 IN CONST CHAR16
*Source
,
638 OUT CHAR8
*Destination
643 Copies one Null-terminated ASCII string to another Null-terminated ASCII
644 string and returns the new ASCII string.
646 This function copies the contents of the ASCII string Source to the ASCII
647 string Destination, and returns Destination. If Source and Destination
648 overlap, then the results are undefined.
650 If Destination is NULL, then ASSERT().
651 If Source is NULL, then ASSERT().
652 If Source and Destination overlap, then ASSERT().
653 If PcdMaximumAsciiStringLength is not zero and Source contains more than
654 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
657 @param Destination Pointer to a Null-terminated ASCII string.
658 @param Source Pointer to a Null-terminated ASCII string.
666 OUT CHAR8
*Destination
,
667 IN CONST CHAR8
*Source
672 Copies up to a specified length one Null-terminated ASCII string to another
673 Null-terminated ASCII string and returns the new ASCII string.
675 This function copies the contents of the ASCII string Source to the ASCII
676 string Destination, and returns Destination. At most, Length ASCII characters
677 are copied from Source to Destination. If Length is 0, then Destination is
678 returned unmodified. If Length is greater that the number of ASCII characters
679 in Source, then Destination is padded with Null ASCII characters. If Source
680 and Destination overlap, then the results are undefined.
682 If Destination is NULL, then ASSERT().
683 If Source is NULL, then ASSERT().
684 If Source and Destination overlap, then ASSERT().
685 If PcdMaximumAsciiStringLength is not zero, and Source contains more than
686 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
689 @param Destination Pointer to a Null-terminated ASCII string.
690 @param Source Pointer to a Null-terminated ASCII string.
691 @param Length Maximum number of ASCII characters to copy.
699 OUT CHAR8
*Destination
,
700 IN CONST CHAR8
*Source
,
706 Returns the length of a Null-terminated ASCII string.
708 This function returns the number of ASCII characters in the Null-terminated
709 ASCII string specified by String.
711 If Length > 0 and Destination is NULL, then ASSERT().
712 If Length > 0 and Source is NULL, then ASSERT().
713 If PcdMaximumAsciiStringLength is not zero and String contains more than
714 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
717 @param String Pointer to a Null-terminated ASCII string.
719 @return The length of String.
725 IN CONST CHAR8
*String
730 Returns the size of a Null-terminated ASCII string in bytes, including the
733 This function returns the size, in bytes, of the Null-terminated ASCII string
736 If String is NULL, then ASSERT().
737 If PcdMaximumAsciiStringLength is not zero and String contains more than
738 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
741 @param String Pointer to a Null-terminated ASCII string.
743 @return The size of String.
749 IN CONST CHAR8
*String
754 Compares two Null-terminated ASCII strings, and returns the difference
755 between the first mismatched ASCII characters.
757 This function compares the Null-terminated ASCII string FirstString to the
758 Null-terminated ASCII string SecondString. If FirstString is identical to
759 SecondString, then 0 is returned. Otherwise, the value returned is the first
760 mismatched ASCII character in SecondString subtracted from the first
761 mismatched ASCII character in FirstString.
763 If FirstString is NULL, then ASSERT().
764 If SecondString is NULL, then ASSERT().
765 If PcdMaximumAsciiStringLength is not zero and FirstString contains more than
766 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
768 If PcdMaximumAsciiStringLength is not zero and SecondString contains more
769 than PcdMaximumAsciiStringLength ASCII characters not including the
770 Null-terminator, then ASSERT().
772 @param FirstString Pointer to a Null-terminated ASCII string.
773 @param SecondString Pointer to a Null-terminated ASCII string.
775 @retval ==0 FirstString is identical to SecondString.
776 @retval !=0 FirstString is not identical to SecondString.
782 IN CONST CHAR8
*FirstString
,
783 IN CONST CHAR8
*SecondString
788 Performs a case insensitive comparison of two Null-terminated ASCII strings,
789 and returns the difference between the first mismatched ASCII characters.
791 This function performs a case insensitive comparison of the Null-terminated
792 ASCII string FirstString to the Null-terminated ASCII string SecondString. If
793 FirstString is identical to SecondString, then 0 is returned. Otherwise, the
794 value returned is the first mismatched lower case ASCII character in
795 SecondString subtracted from the first mismatched lower case ASCII character
798 If FirstString is NULL, then ASSERT().
799 If SecondString is NULL, then ASSERT().
800 If PcdMaximumAsciiStringLength is not zero and FirstString contains more than
801 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
803 If PcdMaximumAsciiStringLength is not zero and SecondString contains more
804 than PcdMaximumAsciiStringLength ASCII characters not including the
805 Null-terminator, then ASSERT().
807 @param FirstString Pointer to a Null-terminated ASCII string.
808 @param SecondString Pointer to a Null-terminated ASCII string.
810 @retval ==0 FirstString is identical to SecondString using case insensitive
812 @retval !=0 FirstString is not identical to SecondString using case
813 insensitive comparisons.
819 IN CONST CHAR8
*FirstString
,
820 IN CONST CHAR8
*SecondString
825 Compares two Null-terminated ASCII strings with maximum lengths, and returns
826 the difference between the first mismatched ASCII characters.
828 This function compares the Null-terminated ASCII string FirstString to the
829 Null-terminated ASCII string SecondString. At most, Length ASCII characters
830 will be compared. If Length is 0, then 0 is returned. If FirstString is
831 identical to SecondString, then 0 is returned. Otherwise, the value returned
832 is the first mismatched ASCII character in SecondString subtracted from the
833 first mismatched ASCII character in FirstString.
835 If Length > 0 and FirstString is NULL, then ASSERT().
836 If Length > 0 and SecondString is NULL, then ASSERT().
837 If PcdMaximumAsciiStringLength is not zero and FirstString contains more than
838 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
840 If PcdMaximumAsciiStringLength is not zero and SecondString contains more than
841 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
844 @param FirstString Pointer to a Null-terminated ASCII string.
845 @param SecondString Pointer to a Null-terminated ASCII string.
846 @param Length Maximum number of ASCII characters for compare.
848 @retval ==0 FirstString is identical to SecondString.
849 @retval !=0 FirstString is not identical to SecondString.
855 IN CONST CHAR8
*FirstString
,
856 IN CONST CHAR8
*SecondString
,
862 Concatenates one Null-terminated ASCII string to another Null-terminated
863 ASCII string, and returns the concatenated ASCII string.
865 This function concatenates two Null-terminated ASCII strings. The contents of
866 Null-terminated ASCII string Source are concatenated to the end of Null-
867 terminated ASCII string Destination. The Null-terminated concatenated ASCII
870 If Destination is NULL, then ASSERT().
871 If Source is NULL, then ASSERT().
872 If PcdMaximumAsciiStringLength is not zero and Destination contains more than
873 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
875 If PcdMaximumAsciiStringLength is not zero and Source contains more than
876 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
878 If PcdMaximumAsciiStringLength is not zero and concatenating Destination and
879 Source results in a ASCII string with more than PcdMaximumAsciiStringLength
880 ASCII characters, then ASSERT().
882 @param Destination Pointer to a Null-terminated ASCII string.
883 @param Source Pointer to a Null-terminated ASCII string.
891 IN OUT CHAR8
*Destination
,
892 IN CONST CHAR8
*Source
897 Concatenates up to a specified length one Null-terminated ASCII string to
898 the end of another Null-terminated ASCII string, and returns the
899 concatenated ASCII string.
901 This function concatenates two Null-terminated ASCII strings. The contents
902 of Null-terminated ASCII string Source are concatenated to the end of Null-
903 terminated ASCII string Destination, and Destination is returned. At most,
904 Length ASCII characters are concatenated from Source to the end of
905 Destination, and Destination is always Null-terminated. If Length is 0, then
906 Destination is returned unmodified. If Source and Destination overlap, then
907 the results are undefined.
909 If Length > 0 and Destination is NULL, then ASSERT().
910 If Length > 0 and Source is NULL, then ASSERT().
911 If Source and Destination overlap, then ASSERT().
912 If PcdMaximumAsciiStringLength is not zero, and Destination contains more than
913 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
915 If PcdMaximumAsciiStringLength is not zero, and Source contains more than
916 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
918 If PcdMaximumAsciiStringLength is not zero, and concatenating Destination and
919 Source results in a ASCII string with more than PcdMaximumAsciiStringLength
920 ASCII characters not including the Null-terminator, then ASSERT().
922 @param Destination Pointer to a Null-terminated ASCII string.
923 @param Source Pointer to a Null-terminated ASCII string.
924 @param Length Maximum number of ASCII characters to concatenate from
933 IN OUT CHAR8
*Destination
,
934 IN CONST CHAR8
*Source
,
940 Returns the first occurrence of a Null-terminated ASCII sub-string
941 in a Null-terminated ASCII string.
943 This function scans the contents of the ASCII string specified by String
944 and returns the first occurrence of SearchString. If SearchString is not
945 found in String, then NULL is returned. If the length of SearchString is zero,
946 then String is returned.
948 If String is NULL, then ASSERT().
949 If SearchString is NULL, then ASSERT().
951 If PcdMaximumAsciiStringLength is not zero, and SearchString or
952 String contains more than PcdMaximumAsciiStringLength Unicode characters
953 not including the Null-terminator, then ASSERT().
955 @param String Pointer to a Null-terminated ASCII string.
956 @param SearchString Pointer to a Null-terminated ASCII string to search for.
958 @retval NULL If the SearchString does not appear in String.
959 @retval others If there is a match return the first occurrence of SearchingString.
960 If the length of SearchString is zero,return String.
966 IN CONST CHAR8
*String
,
967 IN CONST CHAR8
*SearchString
972 Convert a Null-terminated ASCII decimal string to a value of type
975 This function returns a value of type UINTN by interpreting the contents
976 of the ASCII string String as a decimal number. The format of the input
977 ASCII string String is:
979 [spaces] [decimal digits].
981 The valid decimal digit character is in the range [0-9]. The function will
982 ignore the pad space, which includes spaces or tab characters, before the digits.
983 The running zero in the beginning of [decimal digits] will be ignored. Then, the
984 function stops at the first character that is a not a valid decimal character or
985 Null-terminator, whichever on comes first.
987 If String has only pad spaces, then 0 is returned.
988 If String has no pad spaces or valid decimal digits, then 0 is returned.
989 If the number represented by String overflows according to the range defined by
990 UINTN, then ASSERT().
991 If String is NULL, then ASSERT().
992 If PcdMaximumAsciiStringLength is not zero, and String contains more than
993 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
996 @param String Pointer to a Null-terminated ASCII string.
998 @retval Value translated from String.
1003 AsciiStrDecimalToUintn (
1004 IN CONST CHAR8
*String
1009 Convert a Null-terminated ASCII decimal string to a value of type
1012 This function returns a value of type UINT64 by interpreting the contents
1013 of the ASCII string String as a decimal number. The format of the input
1014 ASCII string String is:
1016 [spaces] [decimal digits].
1018 The valid decimal digit character is in the range [0-9]. The function will
1019 ignore the pad space, which includes spaces or tab characters, before the digits.
1020 The running zero in the beginning of [decimal digits] will be ignored. Then, the
1021 function stops at the first character that is a not a valid decimal character or
1022 Null-terminator, whichever on comes first.
1024 If String has only pad spaces, then 0 is returned.
1025 If String has no pad spaces or valid decimal digits, then 0 is returned.
1026 If the number represented by String overflows according to the range defined by
1027 UINT64, then ASSERT().
1028 If String is NULL, then ASSERT().
1029 If PcdMaximumAsciiStringLength is not zero, and String contains more than
1030 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
1033 @param String Pointer to a Null-terminated ASCII string.
1035 @retval Value translated from String.
1040 AsciiStrDecimalToUint64 (
1041 IN CONST CHAR8
*String
1046 Convert a Null-terminated ASCII hexadecimal string to a value of type UINTN.
1048 This function returns a value of type UINTN by interpreting the contents of
1049 the ASCII string String as a hexadecimal number. The format of the input ASCII
1052 [spaces][zeros][x][hexadecimal digits].
1054 The valid hexadecimal digit character is in the range [0-9], [a-f] and [A-F].
1055 The prefix "0x" is optional. Both "x" and "X" is allowed in "0x" prefix. If "x"
1056 appears in the input string, it must be prefixed with at least one 0. The function
1057 will ignore the pad space, which includes spaces or tab characters, before [zeros],
1058 [x] or [hexadecimal digits]. The running zero before [x] or [hexadecimal digits]
1059 will be ignored. Then, the decoding starts after [x] or the first valid hexadecimal
1060 digit. Then, the function stops at the first character that is a not a valid
1061 hexadecimal character or Null-terminator, whichever on comes first.
1063 If String has only pad spaces, then 0 is returned.
1064 If String has no leading pad spaces, leading zeros or valid hexadecimal digits, then
1067 If the number represented by String overflows according to the range defined by UINTN,
1069 If String is NULL, then ASSERT().
1070 If PcdMaximumAsciiStringLength is not zero,
1071 and String contains more than PcdMaximumAsciiStringLength ASCII characters not including
1072 the Null-terminator, then ASSERT().
1074 @param String Pointer to a Null-terminated ASCII string.
1076 @retval Value translated from String.
1081 AsciiStrHexToUintn (
1082 IN CONST CHAR8
*String
1087 Convert a Null-terminated ASCII hexadecimal string to a value of type UINT64.
1089 This function returns a value of type UINT64 by interpreting the contents of
1090 the ASCII string String as a hexadecimal number. The format of the input ASCII
1093 [spaces][zeros][x][hexadecimal digits].
1095 The valid hexadecimal digit character is in the range [0-9], [a-f] and [A-F].
1096 The prefix "0x" is optional. Both "x" and "X" is allowed in "0x" prefix. If "x"
1097 appears in the input string, it must be prefixed with at least one 0. The function
1098 will ignore the pad space, which includes spaces or tab characters, before [zeros],
1099 [x] or [hexadecimal digits]. The running zero before [x] or [hexadecimal digits]
1100 will be ignored. Then, the decoding starts after [x] or the first valid hexadecimal
1101 digit. Then, the function stops at the first character that is a not a valid
1102 hexadecimal character or Null-terminator, whichever on comes first.
1104 If String has only pad spaces, then 0 is returned.
1105 If String has no leading pad spaces, leading zeros or valid hexadecimal digits, then
1108 If the number represented by String overflows according to the range defined by UINT64,
1110 If String is NULL, then ASSERT().
1111 If PcdMaximumAsciiStringLength is not zero,
1112 and String contains more than PcdMaximumAsciiStringLength ASCII characters not including
1113 the Null-terminator, then ASSERT().
1115 @param String Pointer to a Null-terminated ASCII string.
1117 @retval Value translated from String.
1122 AsciiStrHexToUint64 (
1123 IN CONST CHAR8
*String
1128 Convert one Null-terminated ASCII string to a Null-terminated
1129 Unicode string and returns the Unicode string.
1131 This function converts the contents of the ASCII string Source to the Unicode
1132 string Destination, and returns Destination. The function terminates the
1133 Unicode string Destination by appending a Null-terminator character at the end.
1134 The caller is responsible to make sure Destination points to a buffer with size
1135 equal or greater than ((AsciiStrLen (Source) + 1) * sizeof (CHAR16)) in bytes.
1137 If Destination is NULL, then ASSERT().
1138 If Destination is not aligned on a 16-bit boundary, then ASSERT().
1139 If Source is NULL, then ASSERT().
1140 If Source and Destination overlap, then ASSERT().
1141 If PcdMaximumAsciiStringLength is not zero, and Source contains more than
1142 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
1144 If PcdMaximumUnicodeStringLength is not zero, and Source contains more than
1145 PcdMaximumUnicodeStringLength ASCII characters not including the
1146 Null-terminator, then ASSERT().
1148 @param Source Pointer to a Null-terminated ASCII string.
1149 @param Destination Pointer to a Null-terminated Unicode string.
1151 @return Destination.
1156 AsciiStrToUnicodeStr (
1157 IN CONST CHAR8
*Source
,
1158 OUT CHAR16
*Destination
1163 Converts an 8-bit value to an 8-bit BCD value.
1165 Converts the 8-bit value specified by Value to BCD. The BCD value is
1168 If Value >= 100, then ASSERT().
1170 @param Value The 8-bit value to convert to BCD. Range 0..99.
1172 @return The BCD value.
1183 Converts an 8-bit BCD value to an 8-bit value.
1185 Converts the 8-bit BCD value specified by Value to an 8-bit value. The 8-bit
1188 If Value >= 0xA0, then ASSERT().
1189 If (Value & 0x0F) >= 0x0A, then ASSERT().
1191 @param Value The 8-bit BCD value to convert to an 8-bit value.
1193 @return The 8-bit value is returned.
1204 // Linked List Functions and Macros
1208 Initializes the head node of a doubly linked list that is declared as a
1209 global variable in a module.
1211 Initializes the forward and backward links of a new linked list. After
1212 initializing a linked list with this macro, the other linked list functions
1213 may be used to add and remove nodes from the linked list. This macro results
1214 in smaller executables by initializing the linked list in the data section,
1215 instead if calling the InitializeListHead() function to perform the
1216 equivalent operation.
1218 @param ListHead The head note of a list to initialize.
1221 #define INITIALIZE_LIST_HEAD_VARIABLE(ListHead) {&(ListHead), &(ListHead)}
1225 Initializes the head node of a doubly linked list, and returns the pointer to
1226 the head node of the doubly linked list.
1228 Initializes the forward and backward links of a new linked list. After
1229 initializing a linked list with this function, the other linked list
1230 functions may be used to add and remove nodes from the linked list. It is up
1231 to the caller of this function to allocate the memory for ListHead.
1233 If ListHead is NULL, then ASSERT().
1235 @param ListHead A pointer to the head node of a new doubly linked list.
1242 InitializeListHead (
1243 IN OUT LIST_ENTRY
*ListHead
1248 Adds a node to the beginning of a doubly linked list, and returns the pointer
1249 to the head node of the doubly linked list.
1251 Adds the node Entry at the beginning of the doubly linked list denoted by
1252 ListHead, and returns ListHead.
1254 If ListHead is NULL, then ASSERT().
1255 If Entry is NULL, then ASSERT().
1256 If ListHead was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or
1257 InitializeListHead(), then ASSERT().
1258 If PcdMaximumLinkedListLenth is not zero, and prior to insertion the number
1259 of nodes in ListHead, including the ListHead node, is greater than or
1260 equal to PcdMaximumLinkedListLength, then ASSERT().
1262 @param ListHead A pointer to the head node of a doubly linked list.
1263 @param Entry A pointer to a node that is to be inserted at the beginning
1264 of a doubly linked list.
1272 IN OUT LIST_ENTRY
*ListHead
,
1273 IN OUT LIST_ENTRY
*Entry
1278 Adds a node to the end of a doubly linked list, and returns the pointer to
1279 the head node of the doubly linked list.
1281 Adds the node Entry to the end of the doubly linked list denoted by ListHead,
1282 and returns ListHead.
1284 If ListHead is NULL, then ASSERT().
1285 If Entry is NULL, then ASSERT().
1286 If ListHead was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or
1287 InitializeListHead(), then ASSERT().
1288 If PcdMaximumLinkedListLenth is not zero, and prior to insertion the number
1289 of nodes in ListHead, including the ListHead node, is greater than or
1290 equal to PcdMaximumLinkedListLength, then ASSERT().
1292 @param ListHead A pointer to the head node of a doubly linked list.
1293 @param Entry A pointer to a node that is to be added at the end of the
1302 IN OUT LIST_ENTRY
*ListHead
,
1303 IN OUT LIST_ENTRY
*Entry
1308 Retrieves the first node of a doubly linked list.
1310 Returns the first node of a doubly linked list. List must have been
1311 initialized with INTIALIZE_LIST_HEAD_VARIABLE() or InitializeListHead().
1312 If List is empty, then List is returned.
1314 If List is NULL, then ASSERT().
1315 If List was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or
1316 InitializeListHead(), then ASSERT().
1317 If PcdMaximumLinkedListLenth is not zero, and the number of nodes
1318 in List, including the List node, is greater than or equal to
1319 PcdMaximumLinkedListLength, then ASSERT().
1321 @param List A pointer to the head node of a doubly linked list.
1323 @return The first node of a doubly linked list.
1324 @retval NULL The list is empty.
1330 IN CONST LIST_ENTRY
*List
1335 Retrieves the next node of a doubly linked list.
1337 Returns the node of a doubly linked list that follows Node.
1338 List must have been initialized with INTIALIZE_LIST_HEAD_VARIABLE()
1339 or InitializeListHead(). If List is empty, then List is returned.
1341 If List is NULL, then ASSERT().
1342 If Node is NULL, then ASSERT().
1343 If List was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or
1344 InitializeListHead(), then ASSERT().
1345 If PcdMaximumLinkedListLenth is not zero, and List contains more than
1346 PcdMaximumLinkedListLenth nodes, then ASSERT().
1347 If Node is not a node in List, then ASSERT().
1349 @param List A pointer to the head node of a doubly linked list.
1350 @param Node A pointer to a node in the doubly linked list.
1352 @return Pointer to the next node if one exists. Otherwise a null value which
1353 is actually List is returned.
1359 IN CONST LIST_ENTRY
*List
,
1360 IN CONST LIST_ENTRY
*Node
1365 Checks to see if a doubly linked list is empty or not.
1367 Checks to see if the doubly linked list is empty. If the linked list contains
1368 zero nodes, this function returns TRUE. Otherwise, it returns FALSE.
1370 If ListHead is NULL, then ASSERT().
1371 If ListHead was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or
1372 InitializeListHead(), then ASSERT().
1373 If PcdMaximumLinkedListLenth is not zero, and the number of nodes
1374 in List, including the List node, is greater than or equal to
1375 PcdMaximumLinkedListLength, then ASSERT().
1377 @param ListHead A pointer to the head node of a doubly linked list.
1379 @retval TRUE The linked list is empty.
1380 @retval FALSE The linked list is not empty.
1386 IN CONST LIST_ENTRY
*ListHead
1391 Determines if a node in a doubly linked list is the head node of a the same
1392 doubly linked list. This function is typically used to terminate a loop that
1393 traverses all the nodes in a doubly linked list starting with the head node.
1395 Returns TRUE if Node is equal to List. Returns FALSE if Node is one of the
1396 nodes in the doubly linked list specified by List. List must have been
1397 initialized with INTIALIZE_LIST_HEAD_VARIABLE() or InitializeListHead().
1399 If List is NULL, then ASSERT().
1400 If Node is NULL, then ASSERT().
1401 If List was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or InitializeListHead(),
1403 If PcdMaximumLinkedListLenth is not zero, and the number of nodes
1404 in List, including the List node, is greater than or equal to
1405 PcdMaximumLinkedListLength, then ASSERT().
1406 If Node is not a node in List and Node is not equal to List, then ASSERT().
1408 @param List A pointer to the head node of a doubly linked list.
1409 @param Node A pointer to a node in the doubly linked list.
1411 @retval TRUE Node is one of the nodes in the doubly linked list.
1412 @retval FALSE Node is not one of the nodes in the doubly linked list.
1418 IN CONST LIST_ENTRY
*List
,
1419 IN CONST LIST_ENTRY
*Node
1424 Determines if a node the last node in a doubly linked list.
1426 Returns TRUE if Node is the last node in the doubly linked list specified by
1427 List. Otherwise, FALSE is returned. List must have been initialized with
1428 INTIALIZE_LIST_HEAD_VARIABLE() or InitializeListHead().
1430 If List is NULL, then ASSERT().
1431 If Node is NULL, then ASSERT().
1432 If List was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or
1433 InitializeListHead(), then ASSERT().
1434 If PcdMaximumLinkedListLenth is not zero, and the number of nodes
1435 in List, including the List node, is greater than or equal to
1436 PcdMaximumLinkedListLength, then ASSERT().
1437 If Node is not a node in List, then ASSERT().
1439 @param List A pointer to the head node of a doubly linked list.
1440 @param Node A pointer to a node in the doubly linked list.
1442 @retval TRUE Node is the last node in the linked list.
1443 @retval FALSE Node is not the last node in the linked list.
1449 IN CONST LIST_ENTRY
*List
,
1450 IN CONST LIST_ENTRY
*Node
1455 Swaps the location of two nodes in a doubly linked list, and returns the
1456 first node after the swap.
1458 If FirstEntry is identical to SecondEntry, then SecondEntry is returned.
1459 Otherwise, the location of the FirstEntry node is swapped with the location
1460 of the SecondEntry node in a doubly linked list. SecondEntry must be in the
1461 same double linked list as FirstEntry and that double linked list must have
1462 been initialized with INTIALIZE_LIST_HEAD_VARIABLE() or InitializeListHead().
1463 SecondEntry is returned after the nodes are swapped.
1465 If FirstEntry is NULL, then ASSERT().
1466 If SecondEntry is NULL, then ASSERT().
1467 If SecondEntry and FirstEntry are not in the same linked list, then ASSERT().
1468 If PcdMaximumLinkedListLength is not zero, and the number of nodes in the
1469 linked list containing the FirstEntry and SecondEntry nodes, including
1470 the FirstEntry and SecondEntry nodes, is greater than or equal to
1471 PcdMaximumLinkedListLength, then ASSERT().
1473 @param FirstEntry A pointer to a node in a linked list.
1474 @param SecondEntry A pointer to another node in the same linked list.
1476 @return SecondEntry.
1482 IN OUT LIST_ENTRY
*FirstEntry
,
1483 IN OUT LIST_ENTRY
*SecondEntry
1488 Removes a node from a doubly linked list, and returns the node that follows
1491 Removes the node Entry from a doubly linked list. It is up to the caller of
1492 this function to release the memory used by this node if that is required. On
1493 exit, the node following Entry in the doubly linked list is returned. If
1494 Entry is the only node in the linked list, then the head node of the linked
1497 If Entry is NULL, then ASSERT().
1498 If Entry is the head node of an empty list, then ASSERT().
1499 If PcdMaximumLinkedListLength is not zero, and the number of nodes in the
1500 linked list containing Entry, including the Entry node, is greater than
1501 or equal to PcdMaximumLinkedListLength, then ASSERT().
1503 @param Entry A pointer to a node in a linked list.
1511 IN CONST LIST_ENTRY
*Entry
1519 Shifts a 64-bit integer left between 0 and 63 bits. The low bits are filled
1520 with zeros. The shifted value is returned.
1522 This function shifts the 64-bit value Operand to the left by Count bits. The
1523 low Count bits are set to zero. The shifted value is returned.
1525 If Count is greater than 63, then ASSERT().
1527 @param Operand The 64-bit operand to shift left.
1528 @param Count The number of bits to shift left.
1530 @return Operand << Count.
1542 Shifts a 64-bit integer right between 0 and 63 bits. This high bits are
1543 filled with zeros. The shifted value is returned.
1545 This function shifts the 64-bit value Operand to the right by Count bits. The
1546 high Count bits are set to zero. The shifted value is returned.
1548 If Count is greater than 63, then ASSERT().
1550 @param Operand The 64-bit operand to shift right.
1551 @param Count The number of bits to shift right.
1553 @return Operand >> Count
1565 Shifts a 64-bit integer right between 0 and 63 bits. The high bits are filled
1566 with original integer's bit 63. The shifted value is returned.
1568 This function shifts the 64-bit value Operand to the right by Count bits. The
1569 high Count bits are set to bit 63 of Operand. The shifted value is returned.
1571 If Count is greater than 63, then ASSERT().
1573 @param Operand The 64-bit operand to shift right.
1574 @param Count The number of bits to shift right.
1576 @return Operand >> Count
1588 Rotates a 32-bit integer left between 0 and 31 bits, filling the low bits
1589 with the high bits that were rotated.
1591 This function rotates the 32-bit value Operand to the left by Count bits. The
1592 low Count bits are fill with the high Count bits of Operand. The rotated
1595 If Count is greater than 31, then ASSERT().
1597 @param Operand The 32-bit operand to rotate left.
1598 @param Count The number of bits to rotate left.
1600 @return Operand << Count
1612 Rotates a 32-bit integer right between 0 and 31 bits, filling the high bits
1613 with the low bits that were rotated.
1615 This function rotates the 32-bit value Operand to the right by Count bits.
1616 The high Count bits are fill with the low Count bits of Operand. The rotated
1619 If Count is greater than 31, then ASSERT().
1621 @param Operand The 32-bit operand to rotate right.
1622 @param Count The number of bits to rotate right.
1624 @return Operand >> Count
1636 Rotates a 64-bit integer left between 0 and 63 bits, filling the low bits
1637 with the high bits that were rotated.
1639 This function rotates the 64-bit value Operand to the left by Count bits. The
1640 low Count bits are fill with the high Count bits of Operand. The rotated
1643 If Count is greater than 63, then ASSERT().
1645 @param Operand The 64-bit operand to rotate left.
1646 @param Count The number of bits to rotate left.
1648 @return Operand << Count
1660 Rotates a 64-bit integer right between 0 and 63 bits, filling the high bits
1661 with the high low bits that were rotated.
1663 This function rotates the 64-bit value Operand to the right by Count bits.
1664 The high Count bits are fill with the low Count bits of Operand. The rotated
1667 If Count is greater than 63, then ASSERT().
1669 @param Operand The 64-bit operand to rotate right.
1670 @param Count The number of bits to rotate right.
1672 @return Operand >> Count
1684 Returns the bit position of the lowest bit set in a 32-bit value.
1686 This function computes the bit position of the lowest bit set in the 32-bit
1687 value specified by Operand. If Operand is zero, then -1 is returned.
1688 Otherwise, a value between 0 and 31 is returned.
1690 @param Operand The 32-bit operand to evaluate.
1692 @retval 0..31 The lowest bit set in Operand was found.
1693 @retval -1 Operand is zero.
1704 Returns the bit position of the lowest bit set in a 64-bit value.
1706 This function computes the bit position of the lowest bit set in the 64-bit
1707 value specified by Operand. If Operand is zero, then -1 is returned.
1708 Otherwise, a value between 0 and 63 is returned.
1710 @param Operand The 64-bit operand to evaluate.
1712 @retval 0..63 The lowest bit set in Operand was found.
1713 @retval -1 Operand is zero.
1725 Returns the bit position of the highest bit set in a 32-bit value. Equivalent
1728 This function computes the bit position of the highest bit set in the 32-bit
1729 value specified by Operand. If Operand is zero, then -1 is returned.
1730 Otherwise, a value between 0 and 31 is returned.
1732 @param Operand The 32-bit operand to evaluate.
1734 @retval 0..31 Position of the highest bit set in Operand if found.
1735 @retval -1 Operand is zero.
1746 Returns the bit position of the highest bit set in a 64-bit value. Equivalent
1749 This function computes the bit position of the highest bit set in the 64-bit
1750 value specified by Operand. If Operand is zero, then -1 is returned.
1751 Otherwise, a value between 0 and 63 is returned.
1753 @param Operand The 64-bit operand to evaluate.
1755 @retval 0..63 Position of the highest bit set in Operand if found.
1756 @retval -1 Operand is zero.
1767 Returns the value of the highest bit set in a 32-bit value. Equivalent to
1770 This function computes the value of the highest bit set in the 32-bit value
1771 specified by Operand. If Operand is zero, then zero is returned.
1773 @param Operand The 32-bit operand to evaluate.
1775 @return 1 << HighBitSet32(Operand)
1776 @retval 0 Operand is zero.
1787 Returns the value of the highest bit set in a 64-bit value. Equivalent to
1790 This function computes the value of the highest bit set in the 64-bit value
1791 specified by Operand. If Operand is zero, then zero is returned.
1793 @param Operand The 64-bit operand to evaluate.
1795 @return 1 << HighBitSet64(Operand)
1796 @retval 0 Operand is zero.
1807 Switches the endianess of a 16-bit integer.
1809 This function swaps the bytes in a 16-bit unsigned value to switch the value
1810 from little endian to big endian or vice versa. The byte swapped value is
1813 @param Value A 16-bit unsigned value.
1815 @return The byte swapped Value.
1826 Switches the endianess of a 32-bit integer.
1828 This function swaps the bytes in a 32-bit unsigned value to switch the value
1829 from little endian to big endian or vice versa. The byte swapped value is
1832 @param Value A 32-bit unsigned value.
1834 @return The byte swapped Value.
1845 Switches the endianess of a 64-bit integer.
1847 This function swaps the bytes in a 64-bit unsigned value to switch the value
1848 from little endian to big endian or vice versa. The byte swapped value is
1851 @param Value A 64-bit unsigned value.
1853 @return The byte swapped Value.
1864 Multiples a 64-bit unsigned integer by a 32-bit unsigned integer and
1865 generates a 64-bit unsigned result.
1867 This function multiples the 64-bit unsigned value Multiplicand by the 32-bit
1868 unsigned value Multiplier and generates a 64-bit unsigned result. This 64-
1869 bit unsigned result is returned.
1871 @param Multiplicand A 64-bit unsigned value.
1872 @param Multiplier A 32-bit unsigned value.
1874 @return Multiplicand * Multiplier
1880 IN UINT64 Multiplicand
,
1881 IN UINT32 Multiplier
1886 Multiples a 64-bit unsigned integer by a 64-bit unsigned integer and
1887 generates a 64-bit unsigned result.
1889 This function multiples the 64-bit unsigned value Multiplicand by the 64-bit
1890 unsigned value Multiplier and generates a 64-bit unsigned result. This 64-
1891 bit unsigned result is returned.
1893 @param Multiplicand A 64-bit unsigned value.
1894 @param Multiplier A 64-bit unsigned value.
1896 @return Multiplicand * Multiplier
1902 IN UINT64 Multiplicand
,
1903 IN UINT64 Multiplier
1908 Multiples a 64-bit signed integer by a 64-bit signed integer and generates a
1909 64-bit signed result.
1911 This function multiples the 64-bit signed value Multiplicand by the 64-bit
1912 signed value Multiplier and generates a 64-bit signed result. This 64-bit
1913 signed result is returned.
1915 @param Multiplicand A 64-bit signed value.
1916 @param Multiplier A 64-bit signed value.
1918 @return Multiplicand * Multiplier
1924 IN INT64 Multiplicand
,
1930 Divides a 64-bit unsigned integer by a 32-bit unsigned integer and generates
1931 a 64-bit unsigned result.
1933 This function divides the 64-bit unsigned value Dividend by the 32-bit
1934 unsigned value Divisor and generates a 64-bit unsigned quotient. This
1935 function returns the 64-bit unsigned quotient.
1937 If Divisor is 0, then ASSERT().
1939 @param Dividend A 64-bit unsigned value.
1940 @param Divisor A 32-bit unsigned value.
1942 @return Dividend / Divisor
1954 Divides a 64-bit unsigned integer by a 32-bit unsigned integer and generates
1955 a 32-bit unsigned remainder.
1957 This function divides the 64-bit unsigned value Dividend by the 32-bit
1958 unsigned value Divisor and generates a 32-bit remainder. This function
1959 returns the 32-bit unsigned remainder.
1961 If Divisor is 0, then ASSERT().
1963 @param Dividend A 64-bit unsigned value.
1964 @param Divisor A 32-bit unsigned value.
1966 @return Dividend % Divisor
1978 Divides a 64-bit unsigned integer by a 32-bit unsigned integer and generates
1979 a 64-bit unsigned result and an optional 32-bit unsigned remainder.
1981 This function divides the 64-bit unsigned value Dividend by the 32-bit
1982 unsigned value Divisor and generates a 64-bit unsigned quotient. If Remainder
1983 is not NULL, then the 32-bit unsigned remainder is returned in Remainder.
1984 This function returns the 64-bit unsigned quotient.
1986 If Divisor is 0, then ASSERT().
1988 @param Dividend A 64-bit unsigned value.
1989 @param Divisor A 32-bit unsigned value.
1990 @param Remainder A pointer to a 32-bit unsigned value. This parameter is
1991 optional and may be NULL.
1993 @return Dividend / Divisor
1998 DivU64x32Remainder (
2001 OUT UINT32
*Remainder OPTIONAL
2006 Divides a 64-bit unsigned integer by a 64-bit unsigned integer and generates
2007 a 64-bit unsigned result and an optional 64-bit unsigned remainder.
2009 This function divides the 64-bit unsigned value Dividend by the 64-bit
2010 unsigned value Divisor and generates a 64-bit unsigned quotient. If Remainder
2011 is not NULL, then the 64-bit unsigned remainder is returned in Remainder.
2012 This function returns the 64-bit unsigned quotient.
2014 If Divisor is 0, then ASSERT().
2016 @param Dividend A 64-bit unsigned value.
2017 @param Divisor A 64-bit unsigned value.
2018 @param Remainder A pointer to a 64-bit unsigned value. This parameter is
2019 optional and may be NULL.
2021 @return Dividend / Divisor
2026 DivU64x64Remainder (
2029 OUT UINT64
*Remainder OPTIONAL
2034 Divides a 64-bit signed integer by a 64-bit signed integer and generates a
2035 64-bit signed result and a optional 64-bit signed remainder.
2037 This function divides the 64-bit signed value Dividend by the 64-bit signed
2038 value Divisor and generates a 64-bit signed quotient. If Remainder is not
2039 NULL, then the 64-bit signed remainder is returned in Remainder. This
2040 function returns the 64-bit signed quotient.
2042 It is the caller's responsibility to not call this function with a Divisor of 0.
2043 If Divisor is 0, then the quotient and remainder should be assumed to be
2044 the largest negative integer.
2046 If Divisor is 0, then ASSERT().
2048 @param Dividend A 64-bit signed value.
2049 @param Divisor A 64-bit signed value.
2050 @param Remainder A pointer to a 64-bit signed value. This parameter is
2051 optional and may be NULL.
2053 @return Dividend / Divisor
2058 DivS64x64Remainder (
2061 OUT INT64
*Remainder OPTIONAL
2066 Reads a 16-bit value from memory that may be unaligned.
2068 This function returns the 16-bit value pointed to by Buffer. The function
2069 guarantees that the read operation does not produce an alignment fault.
2071 If the Buffer is NULL, then ASSERT().
2073 @param Buffer Pointer to a 16-bit value that may be unaligned.
2075 @return The 16-bit value read from Buffer.
2081 IN CONST UINT16
*Buffer
2086 Writes a 16-bit value to memory that may be unaligned.
2088 This function writes the 16-bit value specified by Value to Buffer. Value is
2089 returned. The function guarantees that the write operation does not produce
2092 If the Buffer is NULL, then ASSERT().
2094 @param Buffer Pointer to a 16-bit value that may be unaligned.
2095 @param Value 16-bit value to write to Buffer.
2097 @return The 16-bit value to write to Buffer.
2109 Reads a 24-bit value from memory that may be unaligned.
2111 This function returns the 24-bit value pointed to by Buffer. The function
2112 guarantees that the read operation does not produce an alignment fault.
2114 If the Buffer is NULL, then ASSERT().
2116 @param Buffer Pointer to a 24-bit value that may be unaligned.
2118 @return The 24-bit value read from Buffer.
2124 IN CONST UINT32
*Buffer
2129 Writes a 24-bit value to memory that may be unaligned.
2131 This function writes the 24-bit value specified by Value to Buffer. Value is
2132 returned. The function guarantees that the write operation does not produce
2135 If the Buffer is NULL, then ASSERT().
2137 @param Buffer Pointer to a 24-bit value that may be unaligned.
2138 @param Value 24-bit value to write to Buffer.
2140 @return The 24-bit value to write to Buffer.
2152 Reads a 32-bit value from memory that may be unaligned.
2154 This function returns the 32-bit value pointed to by Buffer. The function
2155 guarantees that the read operation does not produce an alignment fault.
2157 If the Buffer is NULL, then ASSERT().
2159 @param Buffer Pointer to a 32-bit value that may be unaligned.
2161 @return The 32-bit value read from Buffer.
2167 IN CONST UINT32
*Buffer
2172 Writes a 32-bit value to memory that may be unaligned.
2174 This function writes the 32-bit value specified by Value to Buffer. Value is
2175 returned. The function guarantees that the write operation does not produce
2178 If the Buffer is NULL, then ASSERT().
2180 @param Buffer Pointer to a 32-bit value that may be unaligned.
2181 @param Value 32-bit value to write to Buffer.
2183 @return The 32-bit value to write to Buffer.
2195 Reads a 64-bit value from memory that may be unaligned.
2197 This function returns the 64-bit value pointed to by Buffer. The function
2198 guarantees that the read operation does not produce an alignment fault.
2200 If the Buffer is NULL, then ASSERT().
2202 @param Buffer Pointer to a 64-bit value that may be unaligned.
2204 @return The 64-bit value read from Buffer.
2210 IN CONST UINT64
*Buffer
2215 Writes a 64-bit value to memory that may be unaligned.
2217 This function writes the 64-bit value specified by Value to Buffer. Value is
2218 returned. The function guarantees that the write operation does not produce
2221 If the Buffer is NULL, then ASSERT().
2223 @param Buffer Pointer to a 64-bit value that may be unaligned.
2224 @param Value 64-bit value to write to Buffer.
2226 @return The 64-bit value to write to Buffer.
2238 // Bit Field Functions
2242 Returns a bit field from an 8-bit value.
2244 Returns the bitfield specified by the StartBit and the EndBit from Operand.
2246 If 8-bit operations are not supported, then ASSERT().
2247 If StartBit is greater than 7, then ASSERT().
2248 If EndBit is greater than 7, then ASSERT().
2249 If EndBit is less than StartBit, then ASSERT().
2251 @param Operand Operand on which to perform the bitfield operation.
2252 @param StartBit The ordinal of the least significant bit in the bit field.
2254 @param EndBit The ordinal of the most significant bit in the bit field.
2257 @return The bit field read.
2270 Writes a bit field to an 8-bit value, and returns the result.
2272 Writes Value to the bit field specified by the StartBit and the EndBit in
2273 Operand. All other bits in Operand are preserved. The new 8-bit value is
2276 If 8-bit operations are not supported, then ASSERT().
2277 If StartBit is greater than 7, then ASSERT().
2278 If EndBit is greater than 7, then ASSERT().
2279 If EndBit is less than StartBit, then ASSERT().
2281 @param Operand Operand on which to perform the bitfield operation.
2282 @param StartBit The ordinal of the least significant bit in the bit field.
2284 @param EndBit The ordinal of the most significant bit in the bit field.
2286 @param Value New value of the bit field.
2288 @return The new 8-bit value.
2302 Reads a bit field from an 8-bit value, performs a bitwise OR, and returns the
2305 Performs a bitwise OR between the bit field specified by StartBit
2306 and EndBit in Operand and the value specified by OrData. All other bits in
2307 Operand are preserved. The new 8-bit value is returned.
2309 If 8-bit operations are not supported, then ASSERT().
2310 If StartBit is greater than 7, then ASSERT().
2311 If EndBit is greater than 7, then ASSERT().
2312 If EndBit is less than StartBit, then ASSERT().
2314 @param Operand Operand on which to perform the bitfield operation.
2315 @param StartBit The ordinal of the least significant bit in the bit field.
2317 @param EndBit The ordinal of the most significant bit in the bit field.
2319 @param OrData The value to OR with the read value from the value
2321 @return The new 8-bit value.
2335 Reads a bit field from an 8-bit value, performs a bitwise AND, and returns
2338 Performs a bitwise AND between the bit field specified by StartBit and EndBit
2339 in Operand and the value specified by AndData. All other bits in Operand are
2340 preserved. The new 8-bit value is returned.
2342 If 8-bit operations are not supported, then ASSERT().
2343 If StartBit is greater than 7, then ASSERT().
2344 If EndBit is greater than 7, then ASSERT().
2345 If EndBit is less than StartBit, then ASSERT().
2347 @param Operand Operand on which to perform the bitfield operation.
2348 @param StartBit The ordinal of the least significant bit in the bit field.
2350 @param EndBit The ordinal of the most significant bit in the bit field.
2352 @param AndData The value to AND with the read value from the value.
2354 @return The new 8-bit value.
2368 Reads a bit field from an 8-bit value, performs a bitwise AND followed by a
2369 bitwise OR, and returns the result.
2371 Performs a bitwise AND between the bit field specified by StartBit and EndBit
2372 in Operand and the value specified by AndData, followed by a bitwise
2373 OR with value specified by OrData. All other bits in Operand are
2374 preserved. The new 8-bit value is returned.
2376 If 8-bit operations are not supported, then ASSERT().
2377 If StartBit is greater than 7, then ASSERT().
2378 If EndBit is greater than 7, then ASSERT().
2379 If EndBit is less than StartBit, then ASSERT().
2381 @param Operand Operand on which to perform the bitfield operation.
2382 @param StartBit The ordinal of the least significant bit in the bit field.
2384 @param EndBit The ordinal of the most significant bit in the bit field.
2386 @param AndData The value to AND with the read value from the value.
2387 @param OrData The value to OR with the result of the AND operation.
2389 @return The new 8-bit value.
2394 BitFieldAndThenOr8 (
2404 Returns a bit field from a 16-bit value.
2406 Returns the bitfield specified by the StartBit and the EndBit from Operand.
2408 If 16-bit operations are not supported, then ASSERT().
2409 If StartBit is greater than 15, then ASSERT().
2410 If EndBit is greater than 15, then ASSERT().
2411 If EndBit is less than StartBit, then ASSERT().
2413 @param Operand Operand on which to perform the bitfield operation.
2414 @param StartBit The ordinal of the least significant bit in the bit field.
2416 @param EndBit The ordinal of the most significant bit in the bit field.
2419 @return The bit field read.
2432 Writes a bit field to a 16-bit value, and returns the result.
2434 Writes Value to the bit field specified by the StartBit and the EndBit in
2435 Operand. All other bits in Operand are preserved. The new 16-bit value is
2438 If 16-bit operations are not supported, then ASSERT().
2439 If StartBit is greater than 15, then ASSERT().
2440 If EndBit is greater than 15, then ASSERT().
2441 If EndBit is less than StartBit, then ASSERT().
2443 @param Operand Operand on which to perform the bitfield operation.
2444 @param StartBit The ordinal of the least significant bit in the bit field.
2446 @param EndBit The ordinal of the most significant bit in the bit field.
2448 @param Value New value of the bit field.
2450 @return The new 16-bit value.
2464 Reads a bit field from a 16-bit value, performs a bitwise OR, and returns the
2467 Performs a bitwise OR between the bit field specified by StartBit
2468 and EndBit in Operand and the value specified by OrData. All other bits in
2469 Operand are preserved. The new 16-bit value is returned.
2471 If 16-bit operations are not supported, then ASSERT().
2472 If StartBit is greater than 15, then ASSERT().
2473 If EndBit is greater than 15, then ASSERT().
2474 If EndBit is less than StartBit, then ASSERT().
2476 @param Operand Operand on which to perform the bitfield operation.
2477 @param StartBit The ordinal of the least significant bit in the bit field.
2479 @param EndBit The ordinal of the most significant bit in the bit field.
2481 @param OrData The value to OR with the read value from the value
2483 @return The new 16-bit value.
2497 Reads a bit field from a 16-bit value, performs a bitwise AND, and returns
2500 Performs a bitwise AND between the bit field specified by StartBit and EndBit
2501 in Operand and the value specified by AndData. All other bits in Operand are
2502 preserved. The new 16-bit value is returned.
2504 If 16-bit operations are not supported, then ASSERT().
2505 If StartBit is greater than 15, then ASSERT().
2506 If EndBit is greater than 15, then ASSERT().
2507 If EndBit is less than StartBit, then ASSERT().
2509 @param Operand Operand on which to perform the bitfield operation.
2510 @param StartBit The ordinal of the least significant bit in the bit field.
2512 @param EndBit The ordinal of the most significant bit in the bit field.
2514 @param AndData The value to AND with the read value from the value
2516 @return The new 16-bit value.
2530 Reads a bit field from a 16-bit value, performs a bitwise AND followed by a
2531 bitwise OR, and returns the result.
2533 Performs a bitwise AND between the bit field specified by StartBit and EndBit
2534 in Operand and the value specified by AndData, followed by a bitwise
2535 OR with value specified by OrData. All other bits in Operand are
2536 preserved. The new 16-bit value is returned.
2538 If 16-bit operations are not supported, then ASSERT().
2539 If StartBit is greater than 15, then ASSERT().
2540 If EndBit is greater than 15, then ASSERT().
2541 If EndBit is less than StartBit, then ASSERT().
2543 @param Operand Operand on which to perform the bitfield operation.
2544 @param StartBit The ordinal of the least significant bit in the bit field.
2546 @param EndBit The ordinal of the most significant bit in the bit field.
2548 @param AndData The value to AND with the read value from the value.
2549 @param OrData The value to OR with the result of the AND operation.
2551 @return The new 16-bit value.
2556 BitFieldAndThenOr16 (
2566 Returns a bit field from a 32-bit value.
2568 Returns the bitfield specified by the StartBit and the EndBit from Operand.
2570 If 32-bit operations are not supported, then ASSERT().
2571 If StartBit is greater than 31, then ASSERT().
2572 If EndBit is greater than 31, then ASSERT().
2573 If EndBit is less than StartBit, then ASSERT().
2575 @param Operand Operand on which to perform the bitfield operation.
2576 @param StartBit The ordinal of the least significant bit in the bit field.
2578 @param EndBit The ordinal of the most significant bit in the bit field.
2581 @return The bit field read.
2594 Writes a bit field to a 32-bit value, and returns the result.
2596 Writes Value to the bit field specified by the StartBit and the EndBit in
2597 Operand. All other bits in Operand are preserved. The new 32-bit value is
2600 If 32-bit operations are not supported, then ASSERT().
2601 If StartBit is greater than 31, then ASSERT().
2602 If EndBit is greater than 31, then ASSERT().
2603 If EndBit is less than StartBit, then ASSERT().
2605 @param Operand Operand on which to perform the bitfield operation.
2606 @param StartBit The ordinal of the least significant bit in the bit field.
2608 @param EndBit The ordinal of the most significant bit in the bit field.
2610 @param Value New value of the bit field.
2612 @return The new 32-bit value.
2626 Reads a bit field from a 32-bit value, performs a bitwise OR, and returns the
2629 Performs a bitwise OR between the bit field specified by StartBit
2630 and EndBit in Operand and the value specified by OrData. All other bits in
2631 Operand are preserved. The new 32-bit value is returned.
2633 If 32-bit operations are not supported, then ASSERT().
2634 If StartBit is greater than 31, then ASSERT().
2635 If EndBit is greater than 31, then ASSERT().
2636 If EndBit is less than StartBit, then ASSERT().
2638 @param Operand Operand on which to perform the bitfield operation.
2639 @param StartBit The ordinal of the least significant bit in the bit field.
2641 @param EndBit The ordinal of the most significant bit in the bit field.
2643 @param OrData The value to OR with the read value from the value
2645 @return The new 32-bit value.
2659 Reads a bit field from a 32-bit value, performs a bitwise AND, and returns
2662 Performs a bitwise AND between the bit field specified by StartBit and EndBit
2663 in Operand and the value specified by AndData. All other bits in Operand are
2664 preserved. The new 32-bit value is returned.
2666 If 32-bit operations are not supported, then ASSERT().
2667 If StartBit is greater than 31, then ASSERT().
2668 If EndBit is greater than 31, then ASSERT().
2669 If EndBit is less than StartBit, then ASSERT().
2671 @param Operand Operand on which to perform the bitfield operation.
2672 @param StartBit The ordinal of the least significant bit in the bit field.
2674 @param EndBit The ordinal of the most significant bit in the bit field.
2676 @param AndData The value to AND with the read value from the value
2678 @return The new 32-bit value.
2692 Reads a bit field from a 32-bit value, performs a bitwise AND followed by a
2693 bitwise OR, and returns the result.
2695 Performs a bitwise AND between the bit field specified by StartBit and EndBit
2696 in Operand and the value specified by AndData, followed by a bitwise
2697 OR with value specified by OrData. All other bits in Operand are
2698 preserved. The new 32-bit value is returned.
2700 If 32-bit operations are not supported, then ASSERT().
2701 If StartBit is greater than 31, then ASSERT().
2702 If EndBit is greater than 31, then ASSERT().
2703 If EndBit is less than StartBit, then ASSERT().
2705 @param Operand Operand on which to perform the bitfield operation.
2706 @param StartBit The ordinal of the least significant bit in the bit field.
2708 @param EndBit The ordinal of the most significant bit in the bit field.
2710 @param AndData The value to AND with the read value from the value.
2711 @param OrData The value to OR with the result of the AND operation.
2713 @return The new 32-bit value.
2718 BitFieldAndThenOr32 (
2728 Returns a bit field from a 64-bit value.
2730 Returns the bitfield specified by the StartBit and the EndBit from Operand.
2732 If 64-bit operations are not supported, then ASSERT().
2733 If StartBit is greater than 63, then ASSERT().
2734 If EndBit is greater than 63, then ASSERT().
2735 If EndBit is less than StartBit, then ASSERT().
2737 @param Operand Operand on which to perform the bitfield operation.
2738 @param StartBit The ordinal of the least significant bit in the bit field.
2740 @param EndBit The ordinal of the most significant bit in the bit field.
2743 @return The bit field read.
2756 Writes a bit field to a 64-bit value, and returns the result.
2758 Writes Value to the bit field specified by the StartBit and the EndBit in
2759 Operand. All other bits in Operand are preserved. The new 64-bit value is
2762 If 64-bit operations are not supported, then ASSERT().
2763 If StartBit is greater than 63, then ASSERT().
2764 If EndBit is greater than 63, then ASSERT().
2765 If EndBit is less than StartBit, then ASSERT().
2767 @param Operand Operand on which to perform the bitfield operation.
2768 @param StartBit The ordinal of the least significant bit in the bit field.
2770 @param EndBit The ordinal of the most significant bit in the bit field.
2772 @param Value New value of the bit field.
2774 @return The new 64-bit value.
2788 Reads a bit field from a 64-bit value, performs a bitwise OR, and returns the
2791 Performs a bitwise OR between the bit field specified by StartBit
2792 and EndBit in Operand and the value specified by OrData. All other bits in
2793 Operand are preserved. The new 64-bit value is returned.
2795 If 64-bit operations are not supported, then ASSERT().
2796 If StartBit is greater than 63, then ASSERT().
2797 If EndBit is greater than 63, then ASSERT().
2798 If EndBit is less than StartBit, then ASSERT().
2800 @param Operand Operand on which to perform the bitfield operation.
2801 @param StartBit The ordinal of the least significant bit in the bit field.
2803 @param EndBit The ordinal of the most significant bit in the bit field.
2805 @param OrData The value to OR with the read value from the value
2807 @return The new 64-bit value.
2821 Reads a bit field from a 64-bit value, performs a bitwise AND, and returns
2824 Performs a bitwise AND between the bit field specified by StartBit and EndBit
2825 in Operand and the value specified by AndData. All other bits in Operand are
2826 preserved. The new 64-bit value is returned.
2828 If 64-bit operations are not supported, then ASSERT().
2829 If StartBit is greater than 63, then ASSERT().
2830 If EndBit is greater than 63, then ASSERT().
2831 If EndBit is less than StartBit, then ASSERT().
2833 @param Operand Operand on which to perform the bitfield operation.
2834 @param StartBit The ordinal of the least significant bit in the bit field.
2836 @param EndBit The ordinal of the most significant bit in the bit field.
2838 @param AndData The value to AND with the read value from the value
2840 @return The new 64-bit value.
2854 Reads a bit field from a 64-bit value, performs a bitwise AND followed by a
2855 bitwise OR, and returns the result.
2857 Performs a bitwise AND between the bit field specified by StartBit and EndBit
2858 in Operand and the value specified by AndData, followed by a bitwise
2859 OR with value specified by OrData. All other bits in Operand are
2860 preserved. The new 64-bit value is returned.
2862 If 64-bit operations are not supported, then ASSERT().
2863 If StartBit is greater than 63, then ASSERT().
2864 If EndBit is greater than 63, then ASSERT().
2865 If EndBit is less than StartBit, then ASSERT().
2867 @param Operand Operand on which to perform the bitfield operation.
2868 @param StartBit The ordinal of the least significant bit in the bit field.
2870 @param EndBit The ordinal of the most significant bit in the bit field.
2872 @param AndData The value to AND with the read value from the value.
2873 @param OrData The value to OR with the result of the AND operation.
2875 @return The new 64-bit value.
2880 BitFieldAndThenOr64 (
2889 // Base Library Checksum Functions
2893 Returns the sum of all elements in a buffer in unit of UINT8.
2894 During calculation, the carry bits are dropped.
2896 This function calculates the sum of all elements in a buffer
2897 in unit of UINT8. The carry bits in result of addition are dropped.
2898 The result is returned as UINT8. If Length is Zero, then Zero is
2901 If Buffer is NULL, then ASSERT().
2902 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
2904 @param Buffer Pointer to the buffer to carry out the sum operation.
2905 @param Length The size, in bytes, of Buffer.
2907 @return Sum The sum of Buffer with carry bits dropped during additions.
2913 IN CONST UINT8
*Buffer
,
2919 Returns the two's complement checksum of all elements in a buffer
2922 This function first calculates the sum of the 8-bit values in the
2923 buffer specified by Buffer and Length. The carry bits in the result
2924 of addition are dropped. Then, the two's complement of the sum is
2925 returned. If Length is 0, then 0 is returned.
2927 If Buffer is NULL, then ASSERT().
2928 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
2930 @param Buffer Pointer to the buffer to carry out the checksum operation.
2931 @param Length The size, in bytes, of Buffer.
2933 @return Checksum The 2's complement checksum of Buffer.
2938 CalculateCheckSum8 (
2939 IN CONST UINT8
*Buffer
,
2945 Returns the sum of all elements in a buffer of 16-bit values. During
2946 calculation, the carry bits are dropped.
2948 This function calculates the sum of the 16-bit values in the buffer
2949 specified by Buffer and Length. The carry bits in result of addition are dropped.
2950 The 16-bit result is returned. If Length is 0, then 0 is returned.
2952 If Buffer is NULL, then ASSERT().
2953 If Buffer is not aligned on a 16-bit boundary, then ASSERT().
2954 If Length is not aligned on a 16-bit boundary, then ASSERT().
2955 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
2957 @param Buffer Pointer to the buffer to carry out the sum operation.
2958 @param Length The size, in bytes, of Buffer.
2960 @return Sum The sum of Buffer with carry bits dropped during additions.
2966 IN CONST UINT16
*Buffer
,
2972 Returns the two's complement checksum of all elements in a buffer of
2975 This function first calculates the sum of the 16-bit values in the buffer
2976 specified by Buffer and Length. The carry bits in the result of addition
2977 are dropped. Then, the two's complement of the sum is returned. If Length
2978 is 0, then 0 is returned.
2980 If Buffer is NULL, then ASSERT().
2981 If Buffer is not aligned on a 16-bit boundary, then ASSERT().
2982 If Length is not aligned on a 16-bit boundary, then ASSERT().
2983 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
2985 @param Buffer Pointer to the buffer to carry out the checksum operation.
2986 @param Length The size, in bytes, of Buffer.
2988 @return Checksum The 2's complement checksum of Buffer.
2993 CalculateCheckSum16 (
2994 IN CONST UINT16
*Buffer
,
3000 Returns the sum of all elements in a buffer of 32-bit values. During
3001 calculation, the carry bits are dropped.
3003 This function calculates the sum of the 32-bit values in the buffer
3004 specified by Buffer and Length. The carry bits in result of addition are dropped.
3005 The 32-bit result is returned. If Length is 0, then 0 is returned.
3007 If Buffer is NULL, then ASSERT().
3008 If Buffer is not aligned on a 32-bit boundary, then ASSERT().
3009 If Length is not aligned on a 32-bit boundary, then ASSERT().
3010 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
3012 @param Buffer Pointer to the buffer to carry out the sum operation.
3013 @param Length The size, in bytes, of Buffer.
3015 @return Sum The sum of Buffer with carry bits dropped during additions.
3021 IN CONST UINT32
*Buffer
,
3027 Returns the two's complement checksum of all elements in a buffer of
3030 This function first calculates the sum of the 32-bit values in the buffer
3031 specified by Buffer and Length. The carry bits in the result of addition
3032 are dropped. Then, the two's complement of the sum is returned. If Length
3033 is 0, then 0 is returned.
3035 If Buffer is NULL, then ASSERT().
3036 If Buffer is not aligned on a 32-bit boundary, then ASSERT().
3037 If Length is not aligned on a 32-bit boundary, then ASSERT().
3038 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
3040 @param Buffer Pointer to the buffer to carry out the checksum operation.
3041 @param Length The size, in bytes, of Buffer.
3043 @return Checksum The 2's complement checksum of Buffer.
3048 CalculateCheckSum32 (
3049 IN CONST UINT32
*Buffer
,
3055 Returns the sum of all elements in a buffer of 64-bit values. During
3056 calculation, the carry bits are dropped.
3058 This function calculates the sum of the 64-bit values in the buffer
3059 specified by Buffer and Length. The carry bits in result of addition are dropped.
3060 The 64-bit result is returned. If Length is 0, then 0 is returned.
3062 If Buffer is NULL, then ASSERT().
3063 If Buffer is not aligned on a 64-bit boundary, then ASSERT().
3064 If Length is not aligned on a 64-bit boundary, then ASSERT().
3065 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
3067 @param Buffer Pointer to the buffer to carry out the sum operation.
3068 @param Length The size, in bytes, of Buffer.
3070 @return Sum The sum of Buffer with carry bits dropped during additions.
3076 IN CONST UINT64
*Buffer
,
3082 Returns the two's complement checksum of all elements in a buffer of
3085 This function first calculates the sum of the 64-bit values in the buffer
3086 specified by Buffer and Length. The carry bits in the result of addition
3087 are dropped. Then, the two's complement of the sum is returned. If Length
3088 is 0, then 0 is returned.
3090 If Buffer is NULL, then ASSERT().
3091 If Buffer is not aligned on a 64-bit boundary, then ASSERT().
3092 If Length is not aligned on a 64-bit boundary, then ASSERT().
3093 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
3095 @param Buffer Pointer to the buffer to carry out the checksum operation.
3096 @param Length The size, in bytes, of Buffer.
3098 @return Checksum The 2's complement checksum of Buffer.
3103 CalculateCheckSum64 (
3104 IN CONST UINT64
*Buffer
,
3110 // Base Library CPU Functions
3114 Function entry point used when a stack switch is requested with SwitchStack()
3116 @param Context1 Context1 parameter passed into SwitchStack().
3117 @param Context2 Context2 parameter passed into SwitchStack().
3122 (EFIAPI
*SWITCH_STACK_ENTRY_POINT
)(
3123 IN VOID
*Context1
, OPTIONAL
3124 IN VOID
*Context2 OPTIONAL
3129 Used to serialize load and store operations.
3131 All loads and stores that proceed calls to this function are guaranteed to be
3132 globally visible when this function returns.
3143 Saves the current CPU context that can be restored with a call to LongJump()
3146 Saves the current CPU context in the buffer specified by JumpBuffer and
3147 returns 0. The initial call to SetJump() must always return 0. Subsequent
3148 calls to LongJump() cause a non-zero value to be returned by SetJump().
3150 If JumpBuffer is NULL, then ASSERT().
3151 For IPF CPUs, if JumpBuffer is not aligned on a 16-byte boundary, then ASSERT().
3153 NOTE: The structure BASE_LIBRARY_JUMP_BUFFER is CPU architecture specific.
3154 The same structure must never be used for more than one CPU architecture context.
3155 For example, a BASE_LIBRARY_JUMP_BUFFER allocated by an IA-32 module must never be used from an x64 module.
3156 SetJump()/LongJump() is not currently supported for the EBC processor type.
3158 @param JumpBuffer A pointer to CPU context buffer.
3160 @retval 0 Indicates a return from SetJump().
3166 OUT BASE_LIBRARY_JUMP_BUFFER
*JumpBuffer
3171 Restores the CPU context that was saved with SetJump().
3173 Restores the CPU context from the buffer specified by JumpBuffer. This
3174 function never returns to the caller. Instead is resumes execution based on
3175 the state of JumpBuffer.
3177 If JumpBuffer is NULL, then ASSERT().
3178 For IPF CPUs, if JumpBuffer is not aligned on a 16-byte boundary, then ASSERT().
3179 If Value is 0, then ASSERT().
3181 @param JumpBuffer A pointer to CPU context buffer.
3182 @param Value The value to return when the SetJump() context is
3183 restored and must be non-zero.
3189 IN BASE_LIBRARY_JUMP_BUFFER
*JumpBuffer
,
3195 Enables CPU interrupts.
3206 Disables CPU interrupts.
3217 Disables CPU interrupts and returns the interrupt state prior to the disable
3220 @retval TRUE CPU interrupts were enabled on entry to this call.
3221 @retval FALSE CPU interrupts were disabled on entry to this call.
3226 SaveAndDisableInterrupts (
3232 Enables CPU interrupts for the smallest window required to capture any
3238 EnableDisableInterrupts (
3244 Retrieves the current CPU interrupt state.
3246 Returns TRUE is interrupts are currently enabled. Otherwise
3249 @retval TRUE CPU interrupts are enabled.
3250 @retval FALSE CPU interrupts are disabled.
3261 Set the current CPU interrupt state.
3263 Sets the current CPU interrupt state to the state specified by
3264 InterruptState. If InterruptState is TRUE, then interrupts are enabled. If
3265 InterruptState is FALSE, then interrupts are disabled. InterruptState is
3268 @param InterruptState TRUE if interrupts should enabled. FALSE if
3269 interrupts should be disabled.
3271 @return InterruptState
3277 IN BOOLEAN InterruptState
3282 Requests CPU to pause for a short period of time.
3284 Requests CPU to pause for a short period of time. Typically used in MP
3285 systems to prevent memory starvation while waiting for a spin lock.
3296 Transfers control to a function starting with a new stack.
3298 Transfers control to the function specified by EntryPoint using the
3299 new stack specified by NewStack and passing in the parameters specified
3300 by Context1 and Context2. Context1 and Context2 are optional and may
3301 be NULL. The function EntryPoint must never return. This function
3302 supports a variable number of arguments following the NewStack parameter.
3303 These additional arguments are ignored on IA-32, x64, and EBC.
3304 IPF CPUs expect one additional parameter of type VOID * that specifies
3305 the new backing store pointer.
3307 If EntryPoint is NULL, then ASSERT().
3308 If NewStack is NULL, then ASSERT().
3310 @param EntryPoint A pointer to function to call with the new stack.
3311 @param Context1 A pointer to the context to pass into the EntryPoint
3313 @param Context2 A pointer to the context to pass into the EntryPoint
3315 @param NewStack A pointer to the new stack to use for the EntryPoint
3317 @param ... This variable argument list is ignored for IA32, x64, and EBC.
3318 For IPF, this variable argument list is expected to contain
3319 a single parameter of type VOID * that specifies the new backing
3327 IN SWITCH_STACK_ENTRY_POINT EntryPoint
,
3328 IN VOID
*Context1
, OPTIONAL
3329 IN VOID
*Context2
, OPTIONAL
3336 Generates a breakpoint on the CPU.
3338 Generates a breakpoint on the CPU. The breakpoint must be implemented such
3339 that code can resume normal execution after the breakpoint.
3350 Executes an infinite loop.
3352 Forces the CPU to execute an infinite loop. A debugger may be used to skip
3353 past the loop and the code that follows the loop must execute properly. This
3354 implies that the infinite loop must not cause the code that follow it to be
3364 #if defined (MDE_CPU_IPF)
3367 Flush a range of cache lines in the cache coherency domain of the calling
3370 Flushes the cache lines specified by Address and Length. If Address is not aligned
3371 on a cache line boundary, then entire cache line containing Address is flushed.
3372 If Address + Length is not aligned on a cache line boundary, then the entire cache
3373 line containing Address + Length - 1 is flushed. This function may choose to flush
3374 the entire cache if that is more efficient than flushing the specified range. If
3375 Length is 0, the no cache lines are flushed. Address is returned.
3376 This function is only available on IPF.
3378 If Length is greater than (MAX_ADDRESS - Address + 1), then ASSERT().
3380 @param Address The base address of the instruction lines to invalidate. If
3381 the CPU is in a physical addressing mode, then Address is a
3382 physical address. If the CPU is in a virtual addressing mode,
3383 then Address is a virtual address.
3385 @param Length The number of bytes to invalidate from the instruction cache.
3392 AsmFlushCacheRange (
3399 Executes a FC instruction
3400 Executes a FC instruction on the cache line specified by Address.
3401 The cache line size affected is at least 32-bytes (aligned on a 32-byte boundary).
3402 An implementation may flush a larger region. This function is only available on IPF.
3404 @param Address The Address of cache line to be flushed.
3406 @return The address of FC instruction executed.
3417 Executes a FC.I instruction.
3418 Executes a FC.I instruction on the cache line specified by Address.
3419 The cache line size affected is at least 32-bytes (aligned on a 32-byte boundary).
3420 An implementation may flush a larger region. This function is only available on IPF.
3422 @param Address The Address of cache line to be flushed.
3424 @return The address of FC.I instruction executed.
3435 Reads the current value of a Processor Identifier Register (CPUID).
3437 Reads and returns the current value of Processor Identifier Register specified by Index.
3438 The Index of largest implemented CPUID (One less than the number of implemented CPUID
3439 registers) is determined by CPUID [3] bits {7:0}.
3440 No parameter checking is performed on Index. If the Index value is beyond the
3441 implemented CPUID register range, a Reserved Register/Field fault may occur. The caller
3442 must either guarantee that Index is valid, or the caller must set up fault handlers to
3443 catch the faults. This function is only available on IPF.
3445 @param Index The 8-bit Processor Identifier Register index to read.
3447 @return The current value of Processor Identifier Register specified by Index.
3458 Reads the current value of 64-bit Processor Status Register (PSR).
3459 This function is only available on IPF.
3461 @return The current value of PSR.
3472 Writes the current value of 64-bit Processor Status Register (PSR).
3474 No parameter checking is performed on Value. All bits of Value corresponding to
3475 reserved fields of PSR must be 0 or a Reserved Register/Field fault may occur.
3476 The caller must either guarantee that Value is valid, or the caller must set up
3477 fault handlers to catch the faults. This function is only available on IPF.
3479 @param Value The 64-bit value to write to PSR.
3481 @return The 64-bit value written to the PSR.
3492 Reads the current value of 64-bit Kernel Register #0 (KR0).
3494 Reads and returns the current value of KR0.
3495 This function is only available on IPF.
3497 @return The current value of KR0.
3508 Reads the current value of 64-bit Kernel Register #1 (KR1).
3510 Reads and returns the current value of KR1.
3511 This function is only available on IPF.
3513 @return The current value of KR1.
3524 Reads the current value of 64-bit Kernel Register #2 (KR2).
3526 Reads and returns the current value of KR2.
3527 This function is only available on IPF.
3529 @return The current value of KR2.
3540 Reads the current value of 64-bit Kernel Register #3 (KR3).
3542 Reads and returns the current value of KR3.
3543 This function is only available on IPF.
3545 @return The current value of KR3.
3556 Reads the current value of 64-bit Kernel Register #4 (KR4).
3558 Reads and returns the current value of KR4.
3559 This function is only available on IPF.
3561 @return The current value of KR4.
3572 Reads the current value of 64-bit Kernel Register #5 (KR5).
3574 Reads and returns the current value of KR5.
3575 This function is only available on IPF.
3577 @return The current value of KR5.
3588 Reads the current value of 64-bit Kernel Register #6 (KR6).
3590 Reads and returns the current value of KR6.
3591 This function is only available on IPF.
3593 @return The current value of KR6.
3604 Reads the current value of 64-bit Kernel Register #7 (KR7).
3606 Reads and returns the current value of KR7.
3607 This function is only available on IPF.
3609 @return The current value of KR7.
3620 Write the current value of 64-bit Kernel Register #0 (KR0).
3622 Writes the current value of KR0. The 64-bit value written to
3623 the KR0 is returned. This function is only available on IPF.
3625 @param Value The 64-bit value to write to KR0.
3627 @return The 64-bit value written to the KR0.
3638 Write the current value of 64-bit Kernel Register #1 (KR1).
3640 Writes the current value of KR1. The 64-bit value written to
3641 the KR1 is returned. This function is only available on IPF.
3643 @param Value The 64-bit value to write to KR1.
3645 @return The 64-bit value written to the KR1.
3656 Write the current value of 64-bit Kernel Register #2 (KR2).
3658 Writes the current value of KR2. The 64-bit value written to
3659 the KR2 is returned. This function is only available on IPF.
3661 @param Value The 64-bit value to write to KR2.
3663 @return The 64-bit value written to the KR2.
3674 Write the current value of 64-bit Kernel Register #3 (KR3).
3676 Writes the current value of KR3. The 64-bit value written to
3677 the KR3 is returned. This function is only available on IPF.
3679 @param Value The 64-bit value to write to KR3.
3681 @return The 64-bit value written to the KR3.
3692 Write the current value of 64-bit Kernel Register #4 (KR4).
3694 Writes the current value of KR4. The 64-bit value written to
3695 the KR4 is returned. This function is only available on IPF.
3697 @param Value The 64-bit value to write to KR4.
3699 @return The 64-bit value written to the KR4.
3710 Write the current value of 64-bit Kernel Register #5 (KR5).
3712 Writes the current value of KR5. The 64-bit value written to
3713 the KR5 is returned. This function is only available on IPF.
3715 @param Value The 64-bit value to write to KR5.
3717 @return The 64-bit value written to the KR5.
3728 Write the current value of 64-bit Kernel Register #6 (KR6).
3730 Writes the current value of KR6. The 64-bit value written to
3731 the KR6 is returned. This function is only available on IPF.
3733 @param Value The 64-bit value to write to KR6.
3735 @return The 64-bit value written to the KR6.
3746 Write the current value of 64-bit Kernel Register #7 (KR7).
3748 Writes the current value of KR7. The 64-bit value written to
3749 the KR7 is returned. This function is only available on IPF.
3751 @param Value The 64-bit value to write to KR7.
3753 @return The 64-bit value written to the KR7.
3764 Reads the current value of Interval Timer Counter Register (ITC).
3766 Reads and returns the current value of ITC.
3767 This function is only available on IPF.
3769 @return The current value of ITC.
3780 Reads the current value of Interval Timer Vector Register (ITV).
3782 Reads and returns the current value of ITV.
3783 This function is only available on IPF.
3785 @return The current value of ITV.
3796 Reads the current value of Interval Timer Match Register (ITM).
3798 Reads and returns the current value of ITM.
3799 This function is only available on IPF.
3801 @return The current value of ITM.
3811 Writes the current value of 64-bit Interval Timer Counter Register (ITC).
3813 Writes the current value of ITC. The 64-bit value written to the ITC is returned.
3814 This function is only available on IPF.
3816 @param Value The 64-bit value to write to ITC.
3818 @return The 64-bit value written to the ITC.
3829 Writes the current value of 64-bit Interval Timer Match Register (ITM).
3831 Writes the current value of ITM. The 64-bit value written to the ITM is returned.
3832 This function is only available on IPF.
3834 @param Value The 64-bit value to write to ITM.
3836 @return The 64-bit value written to the ITM.
3847 Writes the current value of 64-bit Interval Timer Vector Register (ITV).
3849 Writes the current value of ITV. The 64-bit value written to the ITV is returned.
3850 No parameter checking is performed on Value. All bits of Value corresponding to
3851 reserved fields of ITV must be 0 or a Reserved Register/Field fault may occur.
3852 The caller must either guarantee that Value is valid, or the caller must set up
3853 fault handlers to catch the faults.
3854 This function is only available on IPF.
3856 @param Value The 64-bit value to write to ITV.
3858 @return The 64-bit value written to the ITV.
3869 Reads the current value of Default Control Register (DCR).
3871 Reads and returns the current value of DCR. This function is only available on IPF.
3873 @return The current value of DCR.
3884 Reads the current value of Interruption Vector Address Register (IVA).
3886 Reads and returns the current value of IVA. This function is only available on IPF.
3888 @return The current value of IVA.
3898 Reads the current value of Page Table Address Register (PTA).
3900 Reads and returns the current value of PTA. This function is only available on IPF.
3902 @return The current value of PTA.
3913 Writes the current value of 64-bit Default Control Register (DCR).
3915 Writes the current value of DCR. The 64-bit value written to the DCR is returned.
3916 No parameter checking is performed on Value. All bits of Value corresponding to
3917 reserved fields of DCR must be 0 or a Reserved Register/Field fault may occur.
3918 The caller must either guarantee that Value is valid, or the caller must set up
3919 fault handlers to catch the faults.
3920 This function is only available on IPF.
3922 @param Value The 64-bit value to write to DCR.
3924 @return The 64-bit value written to the DCR.
3935 Writes the current value of 64-bit Interruption Vector Address Register (IVA).
3937 Writes the current value of IVA. The 64-bit value written to the IVA is returned.
3938 The size of vector table is 32 K bytes and is 32 K bytes aligned
3939 the low 15 bits of Value is ignored when written.
3940 This function is only available on IPF.
3942 @param Value The 64-bit value to write to IVA.
3944 @return The 64-bit value written to the IVA.
3955 Writes the current value of 64-bit Page Table Address Register (PTA).
3957 Writes the current value of PTA. The 64-bit value written to the PTA is returned.
3958 No parameter checking is performed on Value. All bits of Value corresponding to
3959 reserved fields of DCR must be 0 or a Reserved Register/Field fault may occur.
3960 The caller must either guarantee that Value is valid, or the caller must set up
3961 fault handlers to catch the faults.
3962 This function is only available on IPF.
3964 @param Value The 64-bit value to write to PTA.
3966 @return The 64-bit value written to the PTA.
3976 Reads the current value of Local Interrupt ID Register (LID).
3978 Reads and returns the current value of LID. This function is only available on IPF.
3980 @return The current value of LID.
3991 Reads the current value of External Interrupt Vector Register (IVR).
3993 Reads and returns the current value of IVR. This function is only available on IPF.
3995 @return The current value of IVR.
4006 Reads the current value of Task Priority Register (TPR).
4008 Reads and returns the current value of TPR. This function is only available on IPF.
4010 @return The current value of TPR.
4021 Reads the current value of External Interrupt Request Register #0 (IRR0).
4023 Reads and returns the current value of IRR0. This function is only available on IPF.
4025 @return The current value of IRR0.
4036 Reads the current value of External Interrupt Request Register #1 (IRR1).
4038 Reads and returns the current value of IRR1. This function is only available on IPF.
4040 @return The current value of IRR1.
4051 Reads the current value of External Interrupt Request Register #2 (IRR2).
4053 Reads and returns the current value of IRR2. This function is only available on IPF.
4055 @return The current value of IRR2.
4066 Reads the current value of External Interrupt Request Register #3 (IRR3).
4068 Reads and returns the current value of IRR3. This function is only available on IPF.
4070 @return The current value of IRR3.
4081 Reads the current value of Performance Monitor Vector Register (PMV).
4083 Reads and returns the current value of PMV. This function is only available on IPF.
4085 @return The current value of PMV.
4096 Reads the current value of Corrected Machine Check Vector Register (CMCV).
4098 Reads and returns the current value of CMCV. This function is only available on IPF.
4100 @return The current value of CMCV.
4111 Reads the current value of Local Redirection Register #0 (LRR0).
4113 Reads and returns the current value of LRR0. This function is only available on IPF.
4115 @return The current value of LRR0.
4126 Reads the current value of Local Redirection Register #1 (LRR1).
4128 Reads and returns the current value of LRR1. This function is only available on IPF.
4130 @return The current value of LRR1.
4141 Writes the current value of 64-bit Page Local Interrupt ID Register (LID).
4143 Writes the current value of LID. The 64-bit value written to the LID is returned.
4144 No parameter checking is performed on Value. All bits of Value corresponding to
4145 reserved fields of LID must be 0 or a Reserved Register/Field fault may occur.
4146 The caller must either guarantee that Value is valid, or the caller must set up
4147 fault handlers to catch the faults.
4148 This function is only available on IPF.
4150 @param Value The 64-bit value to write to LID.
4152 @return The 64-bit value written to the LID.
4163 Writes the current value of 64-bit Task Priority Register (TPR).
4165 Writes the current value of TPR. The 64-bit value written to the TPR is returned.
4166 No parameter checking is performed on Value. All bits of Value corresponding to
4167 reserved fields of TPR must be 0 or a Reserved Register/Field fault may occur.
4168 The caller must either guarantee that Value is valid, or the caller must set up
4169 fault handlers to catch the faults.
4170 This function is only available on IPF.
4172 @param Value The 64-bit value to write to TPR.
4174 @return The 64-bit value written to the TPR.
4185 Performs a write operation on End OF External Interrupt Register (EOI).
4187 Writes a value of 0 to the EOI Register. This function is only available on IPF.
4198 Writes the current value of 64-bit Performance Monitor Vector Register (PMV).
4200 Writes the current value of PMV. The 64-bit value written to the PMV is returned.
4201 No parameter checking is performed on Value. All bits of Value corresponding
4202 to reserved fields of PMV must be 0 or a Reserved Register/Field fault may occur.
4203 The caller must either guarantee that Value is valid, or the caller must set up
4204 fault handlers to catch the faults.
4205 This function is only available on IPF.
4207 @param Value The 64-bit value to write to PMV.
4209 @return The 64-bit value written to the PMV.
4220 Writes the current value of 64-bit Corrected Machine Check Vector Register (CMCV).
4222 Writes the current value of CMCV. The 64-bit value written to the CMCV is returned.
4223 No parameter checking is performed on Value. All bits of Value corresponding
4224 to reserved fields of CMCV must be 0 or a Reserved Register/Field fault may occur.
4225 The caller must either guarantee that Value is valid, or the caller must set up
4226 fault handlers to catch the faults.
4227 This function is only available on IPF.
4229 @param Value The 64-bit value to write to CMCV.
4231 @return The 64-bit value written to the CMCV.
4242 Writes the current value of 64-bit Local Redirection Register #0 (LRR0).
4244 Writes the current value of LRR0. The 64-bit value written to the LRR0 is returned.
4245 No parameter checking is performed on Value. All bits of Value corresponding
4246 to reserved fields of LRR0 must be 0 or a Reserved Register/Field fault may occur.
4247 The caller must either guarantee that Value is valid, or the caller must set up
4248 fault handlers to catch the faults.
4249 This function is only available on IPF.
4251 @param Value The 64-bit value to write to LRR0.
4253 @return The 64-bit value written to the LRR0.
4264 Writes the current value of 64-bit Local Redirection Register #1 (LRR1).
4266 Writes the current value of LRR1. The 64-bit value written to the LRR1 is returned.
4267 No parameter checking is performed on Value. All bits of Value corresponding
4268 to reserved fields of LRR1 must be 0 or a Reserved Register/Field fault may occur.
4269 The caller must either guarantee that Value is valid, or the caller must
4270 set up fault handlers to catch the faults.
4271 This function is only available on IPF.
4273 @param Value The 64-bit value to write to LRR1.
4275 @return The 64-bit value written to the LRR1.
4286 Reads the current value of Instruction Breakpoint Register (IBR).
4288 The Instruction Breakpoint Registers are used in pairs. The even numbered
4289 registers contain breakpoint addresses, and the odd numbered registers contain
4290 breakpoint mask conditions. At least 4 instruction registers pairs are implemented
4291 on all processor models. Implemented registers are contiguous starting with
4292 register 0. No parameter checking is performed on Index, and if the Index value
4293 is beyond the implemented IBR register range, a Reserved Register/Field fault may
4294 occur. The caller must either guarantee that Index is valid, or the caller must
4295 set up fault handlers to catch the faults.
4296 This function is only available on IPF.
4298 @param Index The 8-bit Instruction Breakpoint Register index to read.
4300 @return The current value of Instruction Breakpoint Register specified by Index.
4311 Reads the current value of Data Breakpoint Register (DBR).
4313 The Data Breakpoint Registers are used in pairs. The even numbered registers
4314 contain breakpoint addresses, and odd numbered registers contain breakpoint
4315 mask conditions. At least 4 data registers pairs are implemented on all processor
4316 models. Implemented registers are contiguous starting with register 0.
4317 No parameter checking is performed on Index. If the Index value is beyond
4318 the implemented DBR register range, a Reserved Register/Field fault may occur.
4319 The caller must either guarantee that Index is valid, or the caller must set up
4320 fault handlers to catch the faults.
4321 This function is only available on IPF.
4323 @param Index The 8-bit Data Breakpoint Register index to read.
4325 @return The current value of Data Breakpoint Register specified by Index.
4336 Reads the current value of Performance Monitor Configuration Register (PMC).
4338 All processor implementations provide at least 4 performance counters
4339 (PMC/PMD [4]...PMC/PMD [7] pairs), and 4 performance monitor counter overflow
4340 status registers (PMC [0]... PMC [3]). Processor implementations may provide
4341 additional implementation-dependent PMC and PMD to increase the number of
4342 'generic' performance counters (PMC/PMD pairs). The remainder of PMC and PMD
4343 register set is implementation dependent. No parameter checking is performed
4344 on Index. If the Index value is beyond the implemented PMC register range,
4345 zero value will be returned.
4346 This function is only available on IPF.
4348 @param Index The 8-bit Performance Monitor Configuration Register index to read.
4350 @return The current value of Performance Monitor Configuration Register
4362 Reads the current value of Performance Monitor Data Register (PMD).
4364 All processor implementations provide at least 4 performance counters
4365 (PMC/PMD [4]...PMC/PMD [7] pairs), and 4 performance monitor counter
4366 overflow status registers (PMC [0]... PMC [3]). Processor implementations may
4367 provide additional implementation-dependent PMC and PMD to increase the number
4368 of 'generic' performance counters (PMC/PMD pairs). The remainder of PMC and PMD
4369 register set is implementation dependent. No parameter checking is performed
4370 on Index. If the Index value is beyond the implemented PMD register range,
4371 zero value will be returned.
4372 This function is only available on IPF.
4374 @param Index The 8-bit Performance Monitor Data Register index to read.
4376 @return The current value of Performance Monitor Data Register specified by Index.
4387 Writes the current value of 64-bit Instruction Breakpoint Register (IBR).
4389 Writes current value of Instruction Breakpoint Register specified by Index.
4390 The Instruction Breakpoint Registers are used in pairs. The even numbered
4391 registers contain breakpoint addresses, and odd numbered registers contain
4392 breakpoint mask conditions. At least 4 instruction registers pairs are implemented
4393 on all processor models. Implemented registers are contiguous starting with
4394 register 0. No parameter checking is performed on Index. If the Index value
4395 is beyond the implemented IBR register range, a Reserved Register/Field fault may
4396 occur. The caller must either guarantee that Index is valid, or the caller must
4397 set up fault handlers to catch the faults.
4398 This function is only available on IPF.
4400 @param Index The 8-bit Instruction Breakpoint Register index to write.
4401 @param Value The 64-bit value to write to IBR.
4403 @return The 64-bit value written to the IBR.
4415 Writes the current value of 64-bit Data Breakpoint Register (DBR).
4417 Writes current value of Data Breakpoint Register specified by Index.
4418 The Data Breakpoint Registers are used in pairs. The even numbered registers
4419 contain breakpoint addresses, and odd numbered registers contain breakpoint
4420 mask conditions. At least 4 data registers pairs are implemented on all processor
4421 models. Implemented registers are contiguous starting with register 0. No parameter
4422 checking is performed on Index. If the Index value is beyond the implemented
4423 DBR register range, a Reserved Register/Field fault may occur. The caller must
4424 either guarantee that Index is valid, or the caller must set up fault handlers to
4426 This function is only available on IPF.
4428 @param Index The 8-bit Data Breakpoint Register index to write.
4429 @param Value The 64-bit value to write to DBR.
4431 @return The 64-bit value written to the DBR.
4443 Writes the current value of 64-bit Performance Monitor Configuration Register (PMC).
4445 Writes current value of Performance Monitor Configuration Register specified by Index.
4446 All processor implementations provide at least 4 performance counters
4447 (PMC/PMD [4]...PMC/PMD [7] pairs), and 4 performance monitor counter overflow status
4448 registers (PMC [0]... PMC [3]). Processor implementations may provide additional
4449 implementation-dependent PMC and PMD to increase the number of 'generic' performance
4450 counters (PMC/PMD pairs). The remainder of PMC and PMD register set is implementation
4451 dependent. No parameter checking is performed on Index. If the Index value is
4452 beyond the implemented PMC register range, the write is ignored.
4453 This function is only available on IPF.
4455 @param Index The 8-bit Performance Monitor Configuration Register index to write.
4456 @param Value The 64-bit value to write to PMC.
4458 @return The 64-bit value written to the PMC.
4470 Writes the current value of 64-bit Performance Monitor Data Register (PMD).
4472 Writes current value of Performance Monitor Data Register specified by Index.
4473 All processor implementations provide at least 4 performance counters
4474 (PMC/PMD [4]...PMC/PMD [7] pairs), and 4 performance monitor counter overflow
4475 status registers (PMC [0]... PMC [3]). Processor implementations may provide
4476 additional implementation-dependent PMC and PMD to increase the number of 'generic'
4477 performance counters (PMC/PMD pairs). The remainder of PMC and PMD register set
4478 is implementation dependent. No parameter checking is performed on Index. If the
4479 Index value is beyond the implemented PMD register range, the write is ignored.
4480 This function is only available on IPF.
4482 @param Index The 8-bit Performance Monitor Data Register index to write.
4483 @param Value The 64-bit value to write to PMD.
4485 @return The 64-bit value written to the PMD.
4497 Reads the current value of 64-bit Global Pointer (GP).
4499 Reads and returns the current value of GP.
4500 This function is only available on IPF.
4502 @return The current value of GP.
4513 Write the current value of 64-bit Global Pointer (GP).
4515 Writes the current value of GP. The 64-bit value written to the GP is returned.
4516 No parameter checking is performed on Value.
4517 This function is only available on IPF.
4519 @param Value The 64-bit value to write to GP.
4521 @return The 64-bit value written to the GP.
4532 Reads the current value of 64-bit Stack Pointer (SP).
4534 Reads and returns the current value of SP.
4535 This function is only available on IPF.
4537 @return The current value of SP.
4548 /// Valid Index value for AsmReadControlRegister()
4550 #define IPF_CONTROL_REGISTER_DCR 0
4551 #define IPF_CONTROL_REGISTER_ITM 1
4552 #define IPF_CONTROL_REGISTER_IVA 2
4553 #define IPF_CONTROL_REGISTER_PTA 8
4554 #define IPF_CONTROL_REGISTER_IPSR 16
4555 #define IPF_CONTROL_REGISTER_ISR 17
4556 #define IPF_CONTROL_REGISTER_IIP 19
4557 #define IPF_CONTROL_REGISTER_IFA 20
4558 #define IPF_CONTROL_REGISTER_ITIR 21
4559 #define IPF_CONTROL_REGISTER_IIPA 22
4560 #define IPF_CONTROL_REGISTER_IFS 23
4561 #define IPF_CONTROL_REGISTER_IIM 24
4562 #define IPF_CONTROL_REGISTER_IHA 25
4563 #define IPF_CONTROL_REGISTER_LID 64
4564 #define IPF_CONTROL_REGISTER_IVR 65
4565 #define IPF_CONTROL_REGISTER_TPR 66
4566 #define IPF_CONTROL_REGISTER_EOI 67
4567 #define IPF_CONTROL_REGISTER_IRR0 68
4568 #define IPF_CONTROL_REGISTER_IRR1 69
4569 #define IPF_CONTROL_REGISTER_IRR2 70
4570 #define IPF_CONTROL_REGISTER_IRR3 71
4571 #define IPF_CONTROL_REGISTER_ITV 72
4572 #define IPF_CONTROL_REGISTER_PMV 73
4573 #define IPF_CONTROL_REGISTER_CMCV 74
4574 #define IPF_CONTROL_REGISTER_LRR0 80
4575 #define IPF_CONTROL_REGISTER_LRR1 81
4578 Reads a 64-bit control register.
4580 Reads and returns the control register specified by Index. The valid Index valued are defined
4581 above in "Related Definitions".
4582 If Index is invalid then 0xFFFFFFFFFFFFFFFF is returned. This function is only available on IPF.
4584 @param Index The index of the control register to read.
4586 @return The control register specified by Index.
4591 AsmReadControlRegister (
4597 /// Valid Index value for AsmReadApplicationRegister()
4599 #define IPF_APPLICATION_REGISTER_K0 0
4600 #define IPF_APPLICATION_REGISTER_K1 1
4601 #define IPF_APPLICATION_REGISTER_K2 2
4602 #define IPF_APPLICATION_REGISTER_K3 3
4603 #define IPF_APPLICATION_REGISTER_K4 4
4604 #define IPF_APPLICATION_REGISTER_K5 5
4605 #define IPF_APPLICATION_REGISTER_K6 6
4606 #define IPF_APPLICATION_REGISTER_K7 7
4607 #define IPF_APPLICATION_REGISTER_RSC 16
4608 #define IPF_APPLICATION_REGISTER_BSP 17
4609 #define IPF_APPLICATION_REGISTER_BSPSTORE 18
4610 #define IPF_APPLICATION_REGISTER_RNAT 19
4611 #define IPF_APPLICATION_REGISTER_FCR 21
4612 #define IPF_APPLICATION_REGISTER_EFLAG 24
4613 #define IPF_APPLICATION_REGISTER_CSD 25
4614 #define IPF_APPLICATION_REGISTER_SSD 26
4615 #define IPF_APPLICATION_REGISTER_CFLG 27
4616 #define IPF_APPLICATION_REGISTER_FSR 28
4617 #define IPF_APPLICATION_REGISTER_FIR 29
4618 #define IPF_APPLICATION_REGISTER_FDR 30
4619 #define IPF_APPLICATION_REGISTER_CCV 32
4620 #define IPF_APPLICATION_REGISTER_UNAT 36
4621 #define IPF_APPLICATION_REGISTER_FPSR 40
4622 #define IPF_APPLICATION_REGISTER_ITC 44
4623 #define IPF_APPLICATION_REGISTER_PFS 64
4624 #define IPF_APPLICATION_REGISTER_LC 65
4625 #define IPF_APPLICATION_REGISTER_EC 66
4628 Reads a 64-bit application register.
4630 Reads and returns the application register specified by Index. The valid Index valued are defined
4631 above in "Related Definitions".
4632 If Index is invalid then 0xFFFFFFFFFFFFFFFF is returned. This function is only available on IPF.
4634 @param Index The index of the application register to read.
4636 @return The application register specified by Index.
4641 AsmReadApplicationRegister (
4647 Reads the current value of a Machine Specific Register (MSR).
4649 Reads and returns the current value of the Machine Specific Register specified by Index. No
4650 parameter checking is performed on Index, and if the Index value is beyond the implemented MSR
4651 register range, a Reserved Register/Field fault may occur. The caller must either guarantee that
4652 Index is valid, or the caller must set up fault handlers to catch the faults. This function is
4653 only available on IPF.
4655 @param Index The 8-bit Machine Specific Register index to read.
4657 @return The current value of the Machine Specific Register specified by Index.
4668 Writes the current value of a Machine Specific Register (MSR).
4670 Writes Value to the Machine Specific Register specified by Index. Value is returned. No
4671 parameter checking is performed on Index, and if the Index value is beyond the implemented MSR
4672 register range, a Reserved Register/Field fault may occur. The caller must either guarantee that
4673 Index is valid, or the caller must set up fault handlers to catch the faults. This function is
4674 only available on IPF.
4676 @param Index The 8-bit Machine Specific Register index to write.
4677 @param Value The 64-bit value to write to the Machine Specific Register.
4679 @return The 64-bit value to write to the Machine Specific Register.
4691 Determines if the CPU is currently executing in virtual, physical, or mixed mode.
4693 Determines the current execution mode of the CPU.
4694 If the CPU is in virtual mode(PSR.RT=1, PSR.DT=1, PSR.IT=1), then 1 is returned.
4695 If the CPU is in physical mode(PSR.RT=0, PSR.DT=0, PSR.IT=0), then 0 is returned.
4696 If the CPU is not in physical mode or virtual mode, then it is in mixed mode,
4698 This function is only available on IPF.
4700 @retval 1 The CPU is in virtual mode.
4701 @retval 0 The CPU is in physical mode.
4702 @retval -1 The CPU is in mixed mode.
4713 Makes a PAL procedure call.
4715 This is a wrapper function to make a PAL procedure call. Based on the Index
4716 value this API will make static or stacked PAL call. The following table
4717 describes the usage of PAL Procedure Index Assignment. Architected procedures
4718 may be designated as required or optional. If a PAL procedure is specified
4719 as optional, a unique return code of 0xFFFFFFFFFFFFFFFF is returned in the
4720 Status field of the PAL_CALL_RETURN structure.
4721 This indicates that the procedure is not present in this PAL implementation.
4722 It is the caller's responsibility to check for this return code after calling
4723 any optional PAL procedure.
4724 No parameter checking is performed on the 5 input parameters, but there are
4725 some common rules that the caller should follow when making a PAL call. Any
4726 address passed to PAL as buffers for return parameters must be 8-byte aligned.
4727 Unaligned addresses may cause undefined results. For those parameters defined
4728 as reserved or some fields defined as reserved must be zero filled or the invalid
4729 argument return value may be returned or undefined result may occur during the
4730 execution of the procedure. If the PalEntryPoint does not point to a valid
4731 PAL entry point then the system behavior is undefined. This function is only
4734 @param PalEntryPoint The PAL procedure calls entry point.
4735 @param Index The PAL procedure Index number.
4736 @param Arg2 The 2nd parameter for PAL procedure calls.
4737 @param Arg3 The 3rd parameter for PAL procedure calls.
4738 @param Arg4 The 4th parameter for PAL procedure calls.
4740 @return structure returned from the PAL Call procedure, including the status and return value.
4746 IN UINT64 PalEntryPoint
,
4754 #if defined (MDE_CPU_IA32) || defined (MDE_CPU_X64)
4756 /// IA32 and x64 Specific Functions
4757 /// Byte packed structure for 16-bit Real Mode EFLAGS
4761 UINT32 CF
:1; ///< Carry Flag
4762 UINT32 Reserved_0
:1; ///< Reserved
4763 UINT32 PF
:1; ///< Parity Flag
4764 UINT32 Reserved_1
:1; ///< Reserved
4765 UINT32 AF
:1; ///< Auxiliary Carry Flag
4766 UINT32 Reserved_2
:1; ///< Reserved
4767 UINT32 ZF
:1; ///< Zero Flag
4768 UINT32 SF
:1; ///< Sign Flag
4769 UINT32 TF
:1; ///< Trap Flag
4770 UINT32 IF
:1; ///< Interrupt Enable Flag
4771 UINT32 DF
:1; ///< Direction Flag
4772 UINT32 OF
:1; ///< Overflow Flag
4773 UINT32 IOPL
:2; ///< I/O Privilege Level
4774 UINT32 NT
:1; ///< Nested Task
4775 UINT32 Reserved_3
:1; ///< Reserved
4781 /// Byte packed structure for EFLAGS/RFLAGS
4782 /// 32-bits on IA-32
4783 /// 64-bits on x64. The upper 32-bits on x64 are reserved
4787 UINT32 CF
:1; ///< Carry Flag
4788 UINT32 Reserved_0
:1; ///< Reserved
4789 UINT32 PF
:1; ///< Parity Flag
4790 UINT32 Reserved_1
:1; ///< Reserved
4791 UINT32 AF
:1; ///< Auxiliary Carry Flag
4792 UINT32 Reserved_2
:1; ///< Reserved
4793 UINT32 ZF
:1; ///< Zero Flag
4794 UINT32 SF
:1; ///< Sign Flag
4795 UINT32 TF
:1; ///< Trap Flag
4796 UINT32 IF
:1; ///< Interrupt Enable Flag
4797 UINT32 DF
:1; ///< Direction Flag
4798 UINT32 OF
:1; ///< Overflow Flag
4799 UINT32 IOPL
:2; ///< I/O Privilege Level
4800 UINT32 NT
:1; ///< Nested Task
4801 UINT32 Reserved_3
:1; ///< Reserved
4802 UINT32 RF
:1; ///< Resume Flag
4803 UINT32 VM
:1; ///< Virtual 8086 Mode
4804 UINT32 AC
:1; ///< Alignment Check
4805 UINT32 VIF
:1; ///< Virtual Interrupt Flag
4806 UINT32 VIP
:1; ///< Virtual Interrupt Pending
4807 UINT32 ID
:1; ///< ID Flag
4808 UINT32 Reserved_4
:10; ///< Reserved
4814 /// Byte packed structure for Control Register 0 (CR0)
4815 /// 32-bits on IA-32
4816 /// 64-bits on x64. The upper 32-bits on x64 are reserved
4820 UINT32 PE
:1; ///< Protection Enable
4821 UINT32 MP
:1; ///< Monitor Coprocessor
4822 UINT32 EM
:1; ///< Emulation
4823 UINT32 TS
:1; ///< Task Switched
4824 UINT32 ET
:1; ///< Extension Type
4825 UINT32 NE
:1; ///< Numeric Error
4826 UINT32 Reserved_0
:10; ///< Reserved
4827 UINT32 WP
:1; ///< Write Protect
4828 UINT32 Reserved_1
:1; ///< Reserved
4829 UINT32 AM
:1; ///< Alignment Mask
4830 UINT32 Reserved_2
:10; ///< Reserved
4831 UINT32 NW
:1; ///< Mot Write-through
4832 UINT32 CD
:1; ///< Cache Disable
4833 UINT32 PG
:1; ///< Paging
4839 /// Byte packed structure for Control Register 4 (CR4)
4840 /// 32-bits on IA-32
4841 /// 64-bits on x64. The upper 32-bits on x64 are reserved
4845 UINT32 VME
:1; ///< Virtual-8086 Mode Extensions
4846 UINT32 PVI
:1; ///< Protected-Mode Virtual Interrupts
4847 UINT32 TSD
:1; ///< Time Stamp Disable
4848 UINT32 DE
:1; ///< Debugging Extensions
4849 UINT32 PSE
:1; ///< Page Size Extensions
4850 UINT32 PAE
:1; ///< Physical Address Extension
4851 UINT32 MCE
:1; ///< Machine Check Enable
4852 UINT32 PGE
:1; ///< Page Global Enable
4853 UINT32 PCE
:1; ///< Performance Monitoring Counter
4855 UINT32 OSFXSR
:1; ///< Operating System Support for
4856 ///< FXSAVE and FXRSTOR instructions
4857 UINT32 OSXMMEXCPT
:1; ///< Operating System Support for
4858 ///< Unmasked SIMD Floating Point
4860 UINT32 Reserved_0
:2; ///< Reserved
4861 UINT32 VMXE
:1; ///< VMX Enable
4862 UINT32 Reserved_1
:18; ///< Reserved
4868 /// Byte packed structure for an IDTR, GDTR, LDTR descriptor
4877 #define IA32_IDT_GATE_TYPE_TASK 0x85
4878 #define IA32_IDT_GATE_TYPE_INTERRUPT_16 0x86
4879 #define IA32_IDT_GATE_TYPE_TRAP_16 0x87
4880 #define IA32_IDT_GATE_TYPE_INTERRUPT_32 0x8E
4881 #define IA32_IDT_GATE_TYPE_TRAP_32 0x8F
4884 #if defined (MDE_CPU_IA32)
4886 /// Byte packed structure for an IA32 Interrupt Gate Descriptor
4890 UINT32 OffsetLow
:16; ///< Offset bits 15..0
4891 UINT32 Selector
:16; ///< Selector
4892 UINT32 Reserved_0
:8; ///< Reserved
4893 UINT32 GateType
:8; ///< Gate Type. See #defines above
4894 UINT32 OffsetHigh
:16; ///< Offset bits 31..16
4897 } IA32_IDT_GATE_DESCRIPTOR
;
4901 #if defined (MDE_CPU_X64)
4903 /// Byte packed structure for an x64 Interrupt Gate Descriptor
4907 UINT32 OffsetLow
:16; ///< Offset bits 15..0
4908 UINT32 Selector
:16; ///< Selector
4909 UINT32 Reserved_0
:8; ///< Reserved
4910 UINT32 GateType
:8; ///< Gate Type. See #defines above
4911 UINT32 OffsetHigh
:16; ///< Offset bits 31..16
4912 UINT32 OffsetUpper
:32; ///< Offset bits 63..32
4913 UINT32 Reserved_1
:32; ///< Reserved
4919 } IA32_IDT_GATE_DESCRIPTOR
;
4924 /// Byte packed structure for an FP/SSE/SSE2 context
4931 /// Structures for the 16-bit real mode thunks
4984 IA32_EFLAGS32 EFLAGS
;
4994 } IA32_REGISTER_SET
;
4997 /// Byte packed structure for an 16-bit real mode thunks
5000 IA32_REGISTER_SET
*RealModeState
;
5001 VOID
*RealModeBuffer
;
5002 UINT32 RealModeBufferSize
;
5003 UINT32 ThunkAttributes
;
5006 #define THUNK_ATTRIBUTE_BIG_REAL_MODE 0x00000001
5007 #define THUNK_ATTRIBUTE_DISABLE_A20_MASK_INT_15 0x00000002
5008 #define THUNK_ATTRIBUTE_DISABLE_A20_MASK_KBD_CTRL 0x00000004
5011 Retrieves CPUID information.
5013 Executes the CPUID instruction with EAX set to the value specified by Index.
5014 This function always returns Index.
5015 If Eax is not NULL, then the value of EAX after CPUID is returned in Eax.
5016 If Ebx is not NULL, then the value of EBX after CPUID is returned in Ebx.
5017 If Ecx is not NULL, then the value of ECX after CPUID is returned in Ecx.
5018 If Edx is not NULL, then the value of EDX after CPUID is returned in Edx.
5019 This function is only available on IA-32 and x64.
5021 @param Index The 32-bit value to load into EAX prior to invoking the CPUID
5023 @param Eax Pointer to the 32-bit EAX value returned by the CPUID
5024 instruction. This is an optional parameter that may be NULL.
5025 @param Ebx Pointer to the 32-bit EBX value returned by the CPUID
5026 instruction. This is an optional parameter that may be NULL.
5027 @param Ecx Pointer to the 32-bit ECX value returned by the CPUID
5028 instruction. This is an optional parameter that may be NULL.
5029 @param Edx Pointer to the 32-bit EDX value returned by the CPUID
5030 instruction. This is an optional parameter that may be NULL.
5039 OUT UINT32
*Eax
, OPTIONAL
5040 OUT UINT32
*Ebx
, OPTIONAL
5041 OUT UINT32
*Ecx
, OPTIONAL
5042 OUT UINT32
*Edx OPTIONAL
5047 Retrieves CPUID information using an extended leaf identifier.
5049 Executes the CPUID instruction with EAX set to the value specified by Index
5050 and ECX set to the value specified by SubIndex. This function always returns
5051 Index. This function is only available on IA-32 and x64.
5053 If Eax is not NULL, then the value of EAX after CPUID is returned in Eax.
5054 If Ebx is not NULL, then the value of EBX after CPUID is returned in Ebx.
5055 If Ecx is not NULL, then the value of ECX after CPUID is returned in Ecx.
5056 If Edx is not NULL, then the value of EDX after CPUID is returned in Edx.
5058 @param Index The 32-bit value to load into EAX prior to invoking the
5060 @param SubIndex The 32-bit value to load into ECX prior to invoking the
5062 @param Eax Pointer to the 32-bit EAX value returned by the CPUID
5063 instruction. This is an optional parameter that may be
5065 @param Ebx Pointer to the 32-bit EBX value returned by the CPUID
5066 instruction. This is an optional parameter that may be
5068 @param Ecx Pointer to the 32-bit ECX value returned by the CPUID
5069 instruction. This is an optional parameter that may be
5071 @param Edx Pointer to the 32-bit EDX value returned by the CPUID
5072 instruction. This is an optional parameter that may be
5083 OUT UINT32
*Eax
, OPTIONAL
5084 OUT UINT32
*Ebx
, OPTIONAL
5085 OUT UINT32
*Ecx
, OPTIONAL
5086 OUT UINT32
*Edx OPTIONAL
5091 Set CD bit and clear NW bit of CR0 followed by a WBINVD.
5093 Disables the caches by setting the CD bit of CR0 to 1, clearing the NW bit of CR0 to 0,
5094 and executing a WBINVD instruction. This function is only available on IA-32 and x64.
5105 Perform a WBINVD and clear both the CD and NW bits of CR0.
5107 Enables the caches by executing a WBINVD instruction and then clear both the CD and NW
5108 bits of CR0 to 0. This function is only available on IA-32 and x64.
5119 Returns the lower 32-bits of a Machine Specific Register(MSR).
5121 Reads and returns the lower 32-bits of the MSR specified by Index.
5122 No parameter checking is performed on Index, and some Index values may cause
5123 CPU exceptions. The caller must either guarantee that Index is valid, or the
5124 caller must set up exception handlers to catch the exceptions. This function
5125 is only available on IA-32 and x64.
5127 @param Index The 32-bit MSR index to read.
5129 @return The lower 32 bits of the MSR identified by Index.
5140 Writes a 32-bit value to a Machine Specific Register(MSR), and returns the value.
5141 The upper 32-bits of the MSR are set to zero.
5143 Writes the 32-bit value specified by Value to the MSR specified by Index. The
5144 upper 32-bits of the MSR write are set to zero. The 32-bit value written to
5145 the MSR is returned. No parameter checking is performed on Index or Value,
5146 and some of these may cause CPU exceptions. The caller must either guarantee
5147 that Index and Value are valid, or the caller must establish proper exception
5148 handlers. This function is only available on IA-32 and x64.
5150 @param Index The 32-bit MSR index to write.
5151 @param Value The 32-bit value to write to the MSR.
5165 Reads a 64-bit MSR, performs a bitwise OR on the lower 32-bits, and
5166 writes the result back to the 64-bit MSR.
5168 Reads the 64-bit MSR specified by Index, performs a bitwise OR
5169 between the lower 32-bits of the read result and the value specified by
5170 OrData, and writes the result to the 64-bit MSR specified by Index. The lower
5171 32-bits of the value written to the MSR is returned. No parameter checking is
5172 performed on Index or OrData, and some of these may cause CPU exceptions. The
5173 caller must either guarantee that Index and OrData are valid, or the caller
5174 must establish proper exception handlers. This function is only available on
5177 @param Index The 32-bit MSR index to write.
5178 @param OrData The value to OR with the read value from the MSR.
5180 @return The lower 32-bit value written to the MSR.
5192 Reads a 64-bit MSR, performs a bitwise AND on the lower 32-bits, and writes
5193 the result back to the 64-bit MSR.
5195 Reads the 64-bit MSR specified by Index, performs a bitwise AND between the
5196 lower 32-bits of the read result and the value specified by AndData, and
5197 writes the result to the 64-bit MSR specified by Index. The lower 32-bits of
5198 the value written to the MSR is returned. No parameter checking is performed
5199 on Index or AndData, and some of these may cause CPU exceptions. The caller
5200 must either guarantee that Index and AndData are valid, or the caller must
5201 establish proper exception handlers. This function is only available on IA-32
5204 @param Index The 32-bit MSR index to write.
5205 @param AndData The value to AND with the read value from the MSR.
5207 @return The lower 32-bit value written to the MSR.
5219 Reads a 64-bit MSR, performs a bitwise AND followed by a bitwise OR
5220 on the lower 32-bits, and writes the result back to the 64-bit MSR.
5222 Reads the 64-bit MSR specified by Index, performs a bitwise AND between the
5223 lower 32-bits of the read result and the value specified by AndData
5224 preserving the upper 32-bits, performs a bitwise OR between the
5225 result of the AND operation and the value specified by OrData, and writes the
5226 result to the 64-bit MSR specified by Address. The lower 32-bits of the value
5227 written to the MSR is returned. No parameter checking is performed on Index,
5228 AndData, or OrData, and some of these may cause CPU exceptions. The caller
5229 must either guarantee that Index, AndData, and OrData are valid, or the
5230 caller must establish proper exception handlers. This function is only
5231 available on IA-32 and x64.
5233 @param Index The 32-bit MSR index to write.
5234 @param AndData The value to AND with the read value from the MSR.
5235 @param OrData The value to OR with the result of the AND operation.
5237 @return The lower 32-bit value written to the MSR.
5250 Reads a bit field of an MSR.
5252 Reads the bit field in the lower 32-bits of a 64-bit MSR. The bit field is
5253 specified by the StartBit and the EndBit. The value of the bit field is
5254 returned. The caller must either guarantee that Index is valid, or the caller
5255 must set up exception handlers to catch the exceptions. This function is only
5256 available on IA-32 and x64.
5258 If StartBit is greater than 31, then ASSERT().
5259 If EndBit is greater than 31, then ASSERT().
5260 If EndBit is less than StartBit, then ASSERT().
5262 @param Index The 32-bit MSR index to read.
5263 @param StartBit The ordinal of the least significant bit in the bit field.
5265 @param EndBit The ordinal of the most significant bit in the bit field.
5268 @return The bit field read from the MSR.
5273 AsmMsrBitFieldRead32 (
5281 Writes a bit field to an MSR.
5283 Writes Value to a bit field in the lower 32-bits of a 64-bit MSR. The bit
5284 field is specified by the StartBit and the EndBit. All other bits in the
5285 destination MSR are preserved. The lower 32-bits of the MSR written is
5286 returned. The caller must either guarantee that Index and the data written
5287 is valid, or the caller must set up exception handlers to catch the exceptions.
5288 This function is only available on IA-32 and x64.
5290 If StartBit is greater than 31, then ASSERT().
5291 If EndBit is greater than 31, then ASSERT().
5292 If EndBit is less than StartBit, then ASSERT().
5294 @param Index The 32-bit MSR index to write.
5295 @param StartBit The ordinal of the least significant bit in the bit field.
5297 @param EndBit The ordinal of the most significant bit in the bit field.
5299 @param Value New value of the bit field.
5301 @return The lower 32-bit of the value written to the MSR.
5306 AsmMsrBitFieldWrite32 (
5315 Reads a bit field in a 64-bit MSR, performs a bitwise OR, and writes the
5316 result back to the bit field in the 64-bit MSR.
5318 Reads the 64-bit MSR specified by Index, performs a bitwise OR
5319 between the read result and the value specified by OrData, and writes the
5320 result to the 64-bit MSR specified by Index. The lower 32-bits of the value
5321 written to the MSR are returned. Extra left bits in OrData are stripped. The
5322 caller must either guarantee that Index and the data written is valid, or
5323 the caller must set up exception handlers to catch the exceptions. This
5324 function is only available on IA-32 and x64.
5326 If StartBit is greater than 31, then ASSERT().
5327 If EndBit is greater than 31, then ASSERT().
5328 If EndBit is less than StartBit, then ASSERT().
5330 @param Index The 32-bit MSR index to write.
5331 @param StartBit The ordinal of the least significant bit in the bit field.
5333 @param EndBit The ordinal of the most significant bit in the bit field.
5335 @param OrData The value to OR with the read value from the MSR.
5337 @return The lower 32-bit of the value written to the MSR.
5342 AsmMsrBitFieldOr32 (
5351 Reads a bit field in a 64-bit MSR, performs a bitwise AND, and writes the
5352 result back to the bit field in the 64-bit MSR.
5354 Reads the 64-bit MSR specified by Index, performs a bitwise AND between the
5355 read result and the value specified by AndData, and writes the result to the
5356 64-bit MSR specified by Index. The lower 32-bits of the value written to the
5357 MSR are returned. Extra left bits in AndData are stripped. The caller must
5358 either guarantee that Index and the data written is valid, or the caller must
5359 set up exception handlers to catch the exceptions. This function is only
5360 available on IA-32 and x64.
5362 If StartBit is greater than 31, then ASSERT().
5363 If EndBit is greater than 31, then ASSERT().
5364 If EndBit is less than StartBit, then ASSERT().
5366 @param Index The 32-bit MSR index to write.
5367 @param StartBit The ordinal of the least significant bit in the bit field.
5369 @param EndBit The ordinal of the most significant bit in the bit field.
5371 @param AndData The value to AND with the read value from the MSR.
5373 @return The lower 32-bit of the value written to the MSR.
5378 AsmMsrBitFieldAnd32 (
5387 Reads a bit field in a 64-bit MSR, performs a bitwise AND followed by a
5388 bitwise OR, and writes the result back to the bit field in the
5391 Reads the 64-bit MSR specified by Index, performs a bitwise AND followed by a
5392 bitwise OR between the read result and the value specified by
5393 AndData, and writes the result to the 64-bit MSR specified by Index. The
5394 lower 32-bits of the value written to the MSR are returned. Extra left bits
5395 in both AndData and OrData are stripped. The caller must either guarantee
5396 that Index and the data written is valid, or the caller must set up exception
5397 handlers to catch the exceptions. This function is only available on IA-32
5400 If StartBit is greater than 31, then ASSERT().
5401 If EndBit is greater than 31, then ASSERT().
5402 If EndBit is less than StartBit, then ASSERT().
5404 @param Index The 32-bit MSR index to write.
5405 @param StartBit The ordinal of the least significant bit in the bit field.
5407 @param EndBit The ordinal of the most significant bit in the bit field.
5409 @param AndData The value to AND with the read value from the MSR.
5410 @param OrData The value to OR with the result of the AND operation.
5412 @return The lower 32-bit of the value written to the MSR.
5417 AsmMsrBitFieldAndThenOr32 (
5427 Returns a 64-bit Machine Specific Register(MSR).
5429 Reads and returns the 64-bit MSR specified by Index. No parameter checking is
5430 performed on Index, and some Index values may cause CPU exceptions. The
5431 caller must either guarantee that Index is valid, or the caller must set up
5432 exception handlers to catch the exceptions. This function is only available
5435 @param Index The 32-bit MSR index to read.
5437 @return The value of the MSR identified by Index.
5448 Writes a 64-bit value to a Machine Specific Register(MSR), and returns the
5451 Writes the 64-bit value specified by Value to the MSR specified by Index. The
5452 64-bit value written to the MSR is returned. No parameter checking is
5453 performed on Index or Value, and some of these may cause CPU exceptions. The
5454 caller must either guarantee that Index and Value are valid, or the caller
5455 must establish proper exception handlers. This function is only available on
5458 @param Index The 32-bit MSR index to write.
5459 @param Value The 64-bit value to write to the MSR.
5473 Reads a 64-bit MSR, performs a bitwise OR, and writes the result
5474 back to the 64-bit MSR.
5476 Reads the 64-bit MSR specified by Index, performs a bitwise OR
5477 between the read result and the value specified by OrData, and writes the
5478 result to the 64-bit MSR specified by Index. The value written to the MSR is
5479 returned. No parameter checking is performed on Index or OrData, and some of
5480 these may cause CPU exceptions. The caller must either guarantee that Index
5481 and OrData are valid, or the caller must establish proper exception handlers.
5482 This function is only available on IA-32 and x64.
5484 @param Index The 32-bit MSR index to write.
5485 @param OrData The value to OR with the read value from the MSR.
5487 @return The value written back to the MSR.
5499 Reads a 64-bit MSR, performs a bitwise AND, and writes the result back to the
5502 Reads the 64-bit MSR specified by Index, performs a bitwise AND between the
5503 read result and the value specified by OrData, and writes the result to the
5504 64-bit MSR specified by Index. The value written to the MSR is returned. No
5505 parameter checking is performed on Index or OrData, and some of these may
5506 cause CPU exceptions. The caller must either guarantee that Index and OrData
5507 are valid, or the caller must establish proper exception handlers. This
5508 function is only available on IA-32 and x64.
5510 @param Index The 32-bit MSR index to write.
5511 @param AndData The value to AND with the read value from the MSR.
5513 @return The value written back to the MSR.
5525 Reads a 64-bit MSR, performs a bitwise AND followed by a bitwise
5526 OR, and writes the result back to the 64-bit MSR.
5528 Reads the 64-bit MSR specified by Index, performs a bitwise AND between read
5529 result and the value specified by AndData, performs a bitwise OR
5530 between the result of the AND operation and the value specified by OrData,
5531 and writes the result to the 64-bit MSR specified by Index. The value written
5532 to the MSR is returned. No parameter checking is performed on Index, AndData,
5533 or OrData, and some of these may cause CPU exceptions. The caller must either
5534 guarantee that Index, AndData, and OrData are valid, or the caller must
5535 establish proper exception handlers. This function is only available on IA-32
5538 @param Index The 32-bit MSR index to write.
5539 @param AndData The value to AND with the read value from the MSR.
5540 @param OrData The value to OR with the result of the AND operation.
5542 @return The value written back to the MSR.
5555 Reads a bit field of an MSR.
5557 Reads the bit field in the 64-bit MSR. The bit field is specified by the
5558 StartBit and the EndBit. The value of the bit field is returned. The caller
5559 must either guarantee that Index is valid, or the caller must set up
5560 exception handlers to catch the exceptions. This function is only available
5563 If StartBit is greater than 63, then ASSERT().
5564 If EndBit is greater than 63, then ASSERT().
5565 If EndBit is less than StartBit, then ASSERT().
5567 @param Index The 32-bit MSR index to read.
5568 @param StartBit The ordinal of the least significant bit in the bit field.
5570 @param EndBit The ordinal of the most significant bit in the bit field.
5573 @return The value read from the MSR.
5578 AsmMsrBitFieldRead64 (
5586 Writes a bit field to an MSR.
5588 Writes Value to a bit field in a 64-bit MSR. The bit field is specified by
5589 the StartBit and the EndBit. All other bits in the destination MSR are
5590 preserved. The MSR written is returned. The caller must either guarantee
5591 that Index and the data written is valid, or the caller must set up exception
5592 handlers to catch the exceptions. This function is only available on IA-32 and x64.
5594 If StartBit is greater than 63, then ASSERT().
5595 If EndBit is greater than 63, then ASSERT().
5596 If EndBit is less than StartBit, then ASSERT().
5598 @param Index The 32-bit MSR index to write.
5599 @param StartBit The ordinal of the least significant bit in the bit field.
5601 @param EndBit The ordinal of the most significant bit in the bit field.
5603 @param Value New value of the bit field.
5605 @return The value written back to the MSR.
5610 AsmMsrBitFieldWrite64 (
5619 Reads a bit field in a 64-bit MSR, performs a bitwise OR, and
5620 writes the result back to the bit field in the 64-bit MSR.
5622 Reads the 64-bit MSR specified by Index, performs a bitwise OR
5623 between the read result and the value specified by OrData, and writes the
5624 result to the 64-bit MSR specified by Index. The value written to the MSR is
5625 returned. Extra left bits in OrData are stripped. The caller must either
5626 guarantee that Index and the data written is valid, or the caller must set up
5627 exception handlers to catch the exceptions. This function is only available
5630 If StartBit is greater than 63, then ASSERT().
5631 If EndBit is greater than 63, then ASSERT().
5632 If EndBit is less than StartBit, then ASSERT().
5634 @param Index The 32-bit MSR index to write.
5635 @param StartBit The ordinal of the least significant bit in the bit field.
5637 @param EndBit The ordinal of the most significant bit in the bit field.
5639 @param OrData The value to OR with the read value from the bit field.
5641 @return The value written back to the MSR.
5646 AsmMsrBitFieldOr64 (
5655 Reads a bit field in a 64-bit MSR, performs a bitwise AND, and writes the
5656 result back to the bit field in the 64-bit MSR.
5658 Reads the 64-bit MSR specified by Index, performs a bitwise AND between the
5659 read result and the value specified by AndData, and writes the result to the
5660 64-bit MSR specified by Index. The value written to the MSR is returned.
5661 Extra left bits in AndData are stripped. The caller must either guarantee
5662 that Index and the data written is valid, or the caller must set up exception
5663 handlers to catch the exceptions. This function is only available on IA-32
5666 If StartBit is greater than 63, then ASSERT().
5667 If EndBit is greater than 63, then ASSERT().
5668 If EndBit is less than StartBit, then ASSERT().
5670 @param Index The 32-bit MSR index to write.
5671 @param StartBit The ordinal of the least significant bit in the bit field.
5673 @param EndBit The ordinal of the most significant bit in the bit field.
5675 @param AndData The value to AND with the read value from the bit field.
5677 @return The value written back to the MSR.
5682 AsmMsrBitFieldAnd64 (
5691 Reads a bit field in a 64-bit MSR, performs a bitwise AND followed by a
5692 bitwise OR, and writes the result back to the bit field in the
5695 Reads the 64-bit MSR specified by Index, performs a bitwise AND followed by
5696 a bitwise OR between the read result and the value specified by
5697 AndData, and writes the result to the 64-bit MSR specified by Index. The
5698 value written to the MSR is returned. Extra left bits in both AndData and
5699 OrData are stripped. The caller must either guarantee that Index and the data
5700 written is valid, or the caller must set up exception handlers to catch the
5701 exceptions. This function is only available on IA-32 and x64.
5703 If StartBit is greater than 63, then ASSERT().
5704 If EndBit is greater than 63, then ASSERT().
5705 If EndBit is less than StartBit, then ASSERT().
5707 @param Index The 32-bit MSR index to write.
5708 @param StartBit The ordinal of the least significant bit in the bit field.
5710 @param EndBit The ordinal of the most significant bit in the bit field.
5712 @param AndData The value to AND with the read value from the bit field.
5713 @param OrData The value to OR with the result of the AND operation.
5715 @return The value written back to the MSR.
5720 AsmMsrBitFieldAndThenOr64 (
5730 Reads the current value of the EFLAGS register.
5732 Reads and returns the current value of the EFLAGS register. This function is
5733 only available on IA-32 and x64. This returns a 32-bit value on IA-32 and a
5734 64-bit value on x64.
5736 @return EFLAGS on IA-32 or RFLAGS on x64.
5747 Reads the current value of the Control Register 0 (CR0).
5749 Reads and returns the current value of CR0. This function is only available
5750 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
5753 @return The value of the Control Register 0 (CR0).
5764 Reads the current value of the Control Register 2 (CR2).
5766 Reads and returns the current value of CR2. This function is only available
5767 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
5770 @return The value of the Control Register 2 (CR2).
5781 Reads the current value of the Control Register 3 (CR3).
5783 Reads and returns the current value of CR3. This function is only available
5784 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
5787 @return The value of the Control Register 3 (CR3).
5798 Reads the current value of the Control Register 4 (CR4).
5800 Reads and returns the current value of CR4. This function is only available
5801 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
5804 @return The value of the Control Register 4 (CR4).
5815 Writes a value to Control Register 0 (CR0).
5817 Writes and returns a new value to CR0. This function is only available on
5818 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
5820 @param Cr0 The value to write to CR0.
5822 @return The value written to CR0.
5833 Writes a value to Control Register 2 (CR2).
5835 Writes and returns a new value to CR2. This function is only available on
5836 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
5838 @param Cr2 The value to write to CR2.
5840 @return The value written to CR2.
5851 Writes a value to Control Register 3 (CR3).
5853 Writes and returns a new value to CR3. This function is only available on
5854 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
5856 @param Cr3 The value to write to CR3.
5858 @return The value written to CR3.
5869 Writes a value to Control Register 4 (CR4).
5871 Writes and returns a new value to CR4. This function is only available on
5872 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
5874 @param Cr4 The value to write to CR4.
5876 @return The value written to CR4.
5887 Reads the current value of Debug Register 0 (DR0).
5889 Reads and returns the current value of DR0. This function is only available
5890 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
5893 @return The value of Debug Register 0 (DR0).
5904 Reads the current value of Debug Register 1 (DR1).
5906 Reads and returns the current value of DR1. This function is only available
5907 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
5910 @return The value of Debug Register 1 (DR1).
5921 Reads the current value of Debug Register 2 (DR2).
5923 Reads and returns the current value of DR2. This function is only available
5924 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
5927 @return The value of Debug Register 2 (DR2).
5938 Reads the current value of Debug Register 3 (DR3).
5940 Reads and returns the current value of DR3. This function is only available
5941 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
5944 @return The value of Debug Register 3 (DR3).
5955 Reads the current value of Debug Register 4 (DR4).
5957 Reads and returns the current value of DR4. This function is only available
5958 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
5961 @return The value of Debug Register 4 (DR4).
5972 Reads the current value of Debug Register 5 (DR5).
5974 Reads and returns the current value of DR5. This function is only available
5975 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
5978 @return The value of Debug Register 5 (DR5).
5989 Reads the current value of Debug Register 6 (DR6).
5991 Reads and returns the current value of DR6. This function is only available
5992 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
5995 @return The value of Debug Register 6 (DR6).
6006 Reads the current value of Debug Register 7 (DR7).
6008 Reads and returns the current value of DR7. This function is only available
6009 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
6012 @return The value of Debug Register 7 (DR7).
6023 Writes a value to Debug Register 0 (DR0).
6025 Writes and returns a new value to DR0. This function is only available on
6026 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
6028 @param Dr0 The value to write to Dr0.
6030 @return The value written to Debug Register 0 (DR0).
6041 Writes a value to Debug Register 1 (DR1).
6043 Writes and returns a new value to DR1. This function is only available on
6044 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
6046 @param Dr1 The value to write to Dr1.
6048 @return The value written to Debug Register 1 (DR1).
6059 Writes a value to Debug Register 2 (DR2).
6061 Writes and returns a new value to DR2. This function is only available on
6062 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
6064 @param Dr2 The value to write to Dr2.
6066 @return The value written to Debug Register 2 (DR2).
6077 Writes a value to Debug Register 3 (DR3).
6079 Writes and returns a new value to DR3. This function is only available on
6080 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
6082 @param Dr3 The value to write to Dr3.
6084 @return The value written to Debug Register 3 (DR3).
6095 Writes a value to Debug Register 4 (DR4).
6097 Writes and returns a new value to DR4. This function is only available on
6098 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
6100 @param Dr4 The value to write to Dr4.
6102 @return The value written to Debug Register 4 (DR4).
6113 Writes a value to Debug Register 5 (DR5).
6115 Writes and returns a new value to DR5. This function is only available on
6116 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
6118 @param Dr5 The value to write to Dr5.
6120 @return The value written to Debug Register 5 (DR5).
6131 Writes a value to Debug Register 6 (DR6).
6133 Writes and returns a new value to DR6. This function is only available on
6134 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
6136 @param Dr6 The value to write to Dr6.
6138 @return The value written to Debug Register 6 (DR6).
6149 Writes a value to Debug Register 7 (DR7).
6151 Writes and returns a new value to DR7. This function is only available on
6152 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
6154 @param Dr7 The value to write to Dr7.
6156 @return The value written to Debug Register 7 (DR7).
6167 Reads the current value of Code Segment Register (CS).
6169 Reads and returns the current value of CS. This function is only available on
6172 @return The current value of CS.
6183 Reads the current value of Data Segment Register (DS).
6185 Reads and returns the current value of DS. This function is only available on
6188 @return The current value of DS.
6199 Reads the current value of Extra Segment Register (ES).
6201 Reads and returns the current value of ES. This function is only available on
6204 @return The current value of ES.
6215 Reads the current value of FS Data Segment Register (FS).
6217 Reads and returns the current value of FS. This function is only available on
6220 @return The current value of FS.
6231 Reads the current value of GS Data Segment Register (GS).
6233 Reads and returns the current value of GS. This function is only available on
6236 @return The current value of GS.
6247 Reads the current value of Stack Segment Register (SS).
6249 Reads and returns the current value of SS. This function is only available on
6252 @return The current value of SS.
6263 Reads the current value of Task Register (TR).
6265 Reads and returns the current value of TR. This function is only available on
6268 @return The current value of TR.
6279 Reads the current Global Descriptor Table Register(GDTR) descriptor.
6281 Reads and returns the current GDTR descriptor and returns it in Gdtr. This
6282 function is only available on IA-32 and x64.
6284 If Gdtr is NULL, then ASSERT().
6286 @param Gdtr Pointer to a GDTR descriptor.
6292 OUT IA32_DESCRIPTOR
*Gdtr
6297 Writes the current Global Descriptor Table Register (GDTR) descriptor.
6299 Writes and the current GDTR descriptor specified by Gdtr. This function is
6300 only available on IA-32 and x64.
6302 If Gdtr is NULL, then ASSERT().
6304 @param Gdtr Pointer to a GDTR descriptor.
6310 IN CONST IA32_DESCRIPTOR
*Gdtr
6315 Reads the current Interrupt Descriptor Table Register(IDTR) descriptor.
6317 Reads and returns the current IDTR descriptor and returns it in Idtr. This
6318 function is only available on IA-32 and x64.
6320 If Idtr is NULL, then ASSERT().
6322 @param Idtr Pointer to a IDTR descriptor.
6328 OUT IA32_DESCRIPTOR
*Idtr
6333 Writes the current Interrupt Descriptor Table Register(IDTR) descriptor.
6335 Writes the current IDTR descriptor and returns it in Idtr. This function is
6336 only available on IA-32 and x64.
6338 If Idtr is NULL, then ASSERT().
6340 @param Idtr Pointer to a IDTR descriptor.
6346 IN CONST IA32_DESCRIPTOR
*Idtr
6351 Reads the current Local Descriptor Table Register(LDTR) selector.
6353 Reads and returns the current 16-bit LDTR descriptor value. This function is
6354 only available on IA-32 and x64.
6356 @return The current selector of LDT.
6367 Writes the current Local Descriptor Table Register (LDTR) selector.
6369 Writes and the current LDTR descriptor specified by Ldtr. This function is
6370 only available on IA-32 and x64.
6372 @param Ldtr 16-bit LDTR selector value.
6383 Save the current floating point/SSE/SSE2 context to a buffer.
6385 Saves the current floating point/SSE/SSE2 state to the buffer specified by
6386 Buffer. Buffer must be aligned on a 16-byte boundary. This function is only
6387 available on IA-32 and x64.
6389 If Buffer is NULL, then ASSERT().
6390 If Buffer is not aligned on a 16-byte boundary, then ASSERT().
6392 @param Buffer Pointer to a buffer to save the floating point/SSE/SSE2 context.
6398 OUT IA32_FX_BUFFER
*Buffer
6403 Restores the current floating point/SSE/SSE2 context from a buffer.
6405 Restores the current floating point/SSE/SSE2 state from the buffer specified
6406 by Buffer. Buffer must be aligned on a 16-byte boundary. This function is
6407 only available on IA-32 and x64.
6409 If Buffer is NULL, then ASSERT().
6410 If Buffer is not aligned on a 16-byte boundary, then ASSERT().
6411 If Buffer was not saved with AsmFxSave(), then ASSERT().
6413 @param Buffer Pointer to a buffer to save the floating point/SSE/SSE2 context.
6419 IN CONST IA32_FX_BUFFER
*Buffer
6424 Reads the current value of 64-bit MMX Register #0 (MM0).
6426 Reads and returns the current value of MM0. This function is only available
6429 @return The current value of MM0.
6440 Reads the current value of 64-bit MMX Register #1 (MM1).
6442 Reads and returns the current value of MM1. This function is only available
6445 @return The current value of MM1.
6456 Reads the current value of 64-bit MMX Register #2 (MM2).
6458 Reads and returns the current value of MM2. This function is only available
6461 @return The current value of MM2.
6472 Reads the current value of 64-bit MMX Register #3 (MM3).
6474 Reads and returns the current value of MM3. This function is only available
6477 @return The current value of MM3.
6488 Reads the current value of 64-bit MMX Register #4 (MM4).
6490 Reads and returns the current value of MM4. This function is only available
6493 @return The current value of MM4.
6504 Reads the current value of 64-bit MMX Register #5 (MM5).
6506 Reads and returns the current value of MM5. This function is only available
6509 @return The current value of MM5.
6520 Reads the current value of 64-bit MMX Register #6 (MM6).
6522 Reads and returns the current value of MM6. This function is only available
6525 @return The current value of MM6.
6536 Reads the current value of 64-bit MMX Register #7 (MM7).
6538 Reads and returns the current value of MM7. This function is only available
6541 @return The current value of MM7.
6552 Writes the current value of 64-bit MMX Register #0 (MM0).
6554 Writes the current value of MM0. This function is only available on IA32 and
6557 @param Value The 64-bit value to write to MM0.
6568 Writes the current value of 64-bit MMX Register #1 (MM1).
6570 Writes the current value of MM1. This function is only available on IA32 and
6573 @param Value The 64-bit value to write to MM1.
6584 Writes the current value of 64-bit MMX Register #2 (MM2).
6586 Writes the current value of MM2. This function is only available on IA32 and
6589 @param Value The 64-bit value to write to MM2.
6600 Writes the current value of 64-bit MMX Register #3 (MM3).
6602 Writes the current value of MM3. This function is only available on IA32 and
6605 @param Value The 64-bit value to write to MM3.
6616 Writes the current value of 64-bit MMX Register #4 (MM4).
6618 Writes the current value of MM4. This function is only available on IA32 and
6621 @param Value The 64-bit value to write to MM4.
6632 Writes the current value of 64-bit MMX Register #5 (MM5).
6634 Writes the current value of MM5. This function is only available on IA32 and
6637 @param Value The 64-bit value to write to MM5.
6648 Writes the current value of 64-bit MMX Register #6 (MM6).
6650 Writes the current value of MM6. This function is only available on IA32 and
6653 @param Value The 64-bit value to write to MM6.
6664 Writes the current value of 64-bit MMX Register #7 (MM7).
6666 Writes the current value of MM7. This function is only available on IA32 and
6669 @param Value The 64-bit value to write to MM7.
6680 Reads the current value of Time Stamp Counter (TSC).
6682 Reads and returns the current value of TSC. This function is only available
6685 @return The current value of TSC
6696 Reads the current value of a Performance Counter (PMC).
6698 Reads and returns the current value of performance counter specified by
6699 Index. This function is only available on IA-32 and x64.
6701 @param Index The 32-bit Performance Counter index to read.
6703 @return The value of the PMC specified by Index.
6714 Sets up a monitor buffer that is used by AsmMwait().
6716 Executes a MONITOR instruction with the register state specified by Eax, Ecx
6717 and Edx. Returns Eax. This function is only available on IA-32 and x64.
6719 @param Eax The value to load into EAX or RAX before executing the MONITOR
6721 @param Ecx The value to load into ECX or RCX before executing the MONITOR
6723 @param Edx The value to load into EDX or RDX before executing the MONITOR
6739 Executes an MWAIT instruction.
6741 Executes an MWAIT instruction with the register state specified by Eax and
6742 Ecx. Returns Eax. This function is only available on IA-32 and x64.
6744 @param Eax The value to load into EAX or RAX before executing the MONITOR
6746 @param Ecx The value to load into ECX or RCX before executing the MONITOR
6761 Executes a WBINVD instruction.
6763 Executes a WBINVD instruction. This function is only available on IA-32 and
6775 Executes a INVD instruction.
6777 Executes a INVD instruction. This function is only available on IA-32 and
6789 Flushes a cache line from all the instruction and data caches within the
6790 coherency domain of the CPU.
6792 Flushed the cache line specified by LinearAddress, and returns LinearAddress.
6793 This function is only available on IA-32 and x64.
6795 @param LinearAddress The address of the cache line to flush. If the CPU is
6796 in a physical addressing mode, then LinearAddress is a
6797 physical address. If the CPU is in a virtual
6798 addressing mode, then LinearAddress is a virtual
6801 @return LinearAddress
6806 IN VOID
*LinearAddress
6811 Enables the 32-bit paging mode on the CPU.
6813 Enables the 32-bit paging mode on the CPU. CR0, CR3, CR4, and the page tables
6814 must be properly initialized prior to calling this service. This function
6815 assumes the current execution mode is 32-bit protected mode. This function is
6816 only available on IA-32. After the 32-bit paging mode is enabled, control is
6817 transferred to the function specified by EntryPoint using the new stack
6818 specified by NewStack and passing in the parameters specified by Context1 and
6819 Context2. Context1 and Context2 are optional and may be NULL. The function
6820 EntryPoint must never return.
6822 If the current execution mode is not 32-bit protected mode, then ASSERT().
6823 If EntryPoint is NULL, then ASSERT().
6824 If NewStack is NULL, then ASSERT().
6826 There are a number of constraints that must be followed before calling this
6828 1) Interrupts must be disabled.
6829 2) The caller must be in 32-bit protected mode with flat descriptors. This
6830 means all descriptors must have a base of 0 and a limit of 4GB.
6831 3) CR0 and CR4 must be compatible with 32-bit protected mode with flat
6833 4) CR3 must point to valid page tables that will be used once the transition
6834 is complete, and those page tables must guarantee that the pages for this
6835 function and the stack are identity mapped.
6837 @param EntryPoint A pointer to function to call with the new stack after
6839 @param Context1 A pointer to the context to pass into the EntryPoint
6840 function as the first parameter after paging is enabled.
6841 @param Context2 A pointer to the context to pass into the EntryPoint
6842 function as the second parameter after paging is enabled.
6843 @param NewStack A pointer to the new stack to use for the EntryPoint
6844 function after paging is enabled.
6850 IN SWITCH_STACK_ENTRY_POINT EntryPoint
,
6851 IN VOID
*Context1
, OPTIONAL
6852 IN VOID
*Context2
, OPTIONAL
6858 Disables the 32-bit paging mode on the CPU.
6860 Disables the 32-bit paging mode on the CPU and returns to 32-bit protected
6861 mode. This function assumes the current execution mode is 32-paged protected
6862 mode. This function is only available on IA-32. After the 32-bit paging mode
6863 is disabled, control is transferred to the function specified by EntryPoint
6864 using the new stack specified by NewStack and passing in the parameters
6865 specified by Context1 and Context2. Context1 and Context2 are optional and
6866 may be NULL. The function EntryPoint must never return.
6868 If the current execution mode is not 32-bit paged mode, then ASSERT().
6869 If EntryPoint is NULL, then ASSERT().
6870 If NewStack is NULL, then ASSERT().
6872 There are a number of constraints that must be followed before calling this
6874 1) Interrupts must be disabled.
6875 2) The caller must be in 32-bit paged mode.
6876 3) CR0, CR3, and CR4 must be compatible with 32-bit paged mode.
6877 4) CR3 must point to valid page tables that guarantee that the pages for
6878 this function and the stack are identity mapped.
6880 @param EntryPoint A pointer to function to call with the new stack after
6882 @param Context1 A pointer to the context to pass into the EntryPoint
6883 function as the first parameter after paging is disabled.
6884 @param Context2 A pointer to the context to pass into the EntryPoint
6885 function as the second parameter after paging is
6887 @param NewStack A pointer to the new stack to use for the EntryPoint
6888 function after paging is disabled.
6893 AsmDisablePaging32 (
6894 IN SWITCH_STACK_ENTRY_POINT EntryPoint
,
6895 IN VOID
*Context1
, OPTIONAL
6896 IN VOID
*Context2
, OPTIONAL
6902 Enables the 64-bit paging mode on the CPU.
6904 Enables the 64-bit paging mode on the CPU. CR0, CR3, CR4, and the page tables
6905 must be properly initialized prior to calling this service. This function
6906 assumes the current execution mode is 32-bit protected mode with flat
6907 descriptors. This function is only available on IA-32. After the 64-bit
6908 paging mode is enabled, control is transferred to the function specified by
6909 EntryPoint using the new stack specified by NewStack and passing in the
6910 parameters specified by Context1 and Context2. Context1 and Context2 are
6911 optional and may be 0. The function EntryPoint must never return.
6913 If the current execution mode is not 32-bit protected mode with flat
6914 descriptors, then ASSERT().
6915 If EntryPoint is 0, then ASSERT().
6916 If NewStack is 0, then ASSERT().
6918 @param Cs The 16-bit selector to load in the CS before EntryPoint
6919 is called. The descriptor in the GDT that this selector
6920 references must be setup for long mode.
6921 @param EntryPoint The 64-bit virtual address of the function to call with
6922 the new stack after paging is enabled.
6923 @param Context1 The 64-bit virtual address of the context to pass into
6924 the EntryPoint function as the first parameter after
6926 @param Context2 The 64-bit virtual address of the context to pass into
6927 the EntryPoint function as the second parameter after
6929 @param NewStack The 64-bit virtual address of the new stack to use for
6930 the EntryPoint function after paging is enabled.
6937 IN UINT64 EntryPoint
,
6938 IN UINT64 Context1
, OPTIONAL
6939 IN UINT64 Context2
, OPTIONAL
6945 Disables the 64-bit paging mode on the CPU.
6947 Disables the 64-bit paging mode on the CPU and returns to 32-bit protected
6948 mode. This function assumes the current execution mode is 64-paging mode.
6949 This function is only available on x64. After the 64-bit paging mode is
6950 disabled, control is transferred to the function specified by EntryPoint
6951 using the new stack specified by NewStack and passing in the parameters
6952 specified by Context1 and Context2. Context1 and Context2 are optional and
6953 may be 0. The function EntryPoint must never return.
6955 If the current execution mode is not 64-bit paged mode, then ASSERT().
6956 If EntryPoint is 0, then ASSERT().
6957 If NewStack is 0, then ASSERT().
6959 @param Cs The 16-bit selector to load in the CS before EntryPoint
6960 is called. The descriptor in the GDT that this selector
6961 references must be setup for 32-bit protected mode.
6962 @param EntryPoint The 64-bit virtual address of the function to call with
6963 the new stack after paging is disabled.
6964 @param Context1 The 64-bit virtual address of the context to pass into
6965 the EntryPoint function as the first parameter after
6967 @param Context2 The 64-bit virtual address of the context to pass into
6968 the EntryPoint function as the second parameter after
6970 @param NewStack The 64-bit virtual address of the new stack to use for
6971 the EntryPoint function after paging is disabled.
6976 AsmDisablePaging64 (
6978 IN UINT32 EntryPoint
,
6979 IN UINT32 Context1
, OPTIONAL
6980 IN UINT32 Context2
, OPTIONAL
6986 // 16-bit thunking services
6990 Retrieves the properties for 16-bit thunk functions.
6992 Computes the size of the buffer and stack below 1MB required to use the
6993 AsmPrepareThunk16(), AsmThunk16() and AsmPrepareAndThunk16() functions. This
6994 buffer size is returned in RealModeBufferSize, and the stack size is returned
6995 in ExtraStackSize. If parameters are passed to the 16-bit real mode code,
6996 then the actual minimum stack size is ExtraStackSize plus the maximum number
6997 of bytes that need to be passed to the 16-bit real mode code.
6999 If RealModeBufferSize is NULL, then ASSERT().
7000 If ExtraStackSize is NULL, then ASSERT().
7002 @param RealModeBufferSize A pointer to the size of the buffer below 1MB
7003 required to use the 16-bit thunk functions.
7004 @param ExtraStackSize A pointer to the extra size of stack below 1MB
7005 that the 16-bit thunk functions require for
7006 temporary storage in the transition to and from
7012 AsmGetThunk16Properties (
7013 OUT UINT32
*RealModeBufferSize
,
7014 OUT UINT32
*ExtraStackSize
7019 Prepares all structures a code required to use AsmThunk16().
7021 Prepares all structures and code required to use AsmThunk16().
7023 If ThunkContext is NULL, then ASSERT().
7025 @param ThunkContext A pointer to the context structure that describes the
7026 16-bit real mode code to call.
7032 OUT THUNK_CONTEXT
*ThunkContext
7037 Transfers control to a 16-bit real mode entry point and returns the results.
7039 Transfers control to a 16-bit real mode entry point and returns the results.
7040 AsmPrepareThunk16() must be called with ThunkContext before this function is used.
7041 This function must be called with interrupts disabled.
7043 The register state from the RealModeState field of ThunkContext is restored just prior
7044 to calling the 16-bit real mode entry point. This includes the EFLAGS field of RealModeState,
7045 which is used to set the interrupt state when a 16-bit real mode entry point is called.
7046 Control is transferred to the 16-bit real mode entry point specified by the CS and Eip fields of RealModeState.
7047 The stack is initialized to the SS and ESP fields of RealModeState. Any parameters passed to
7048 the 16-bit real mode code must be populated by the caller at SS:ESP prior to calling this function.
7049 The 16-bit real mode entry point is invoked with a 16-bit CALL FAR instruction,
7050 so when accessing stack contents, the 16-bit real mode code must account for the 16-bit segment
7051 and 16-bit offset of the return address that were pushed onto the stack. The 16-bit real mode entry
7052 point must exit with a RETF instruction. The register state is captured into RealModeState immediately
7053 after the RETF instruction is executed.
7055 If EFLAGS specifies interrupts enabled, or any of the 16-bit real mode code enables interrupts,
7056 or any of the 16-bit real mode code makes a SW interrupt, then the caller is responsible for making sure
7057 the IDT at address 0 is initialized to handle any HW or SW interrupts that may occur while in 16-bit real mode.
7059 If EFLAGS specifies interrupts enabled, or any of the 16-bit real mode code enables interrupts,
7060 then the caller is responsible for making sure the 8259 PIC is in a state compatible with 16-bit real mode.
7061 This includes the base vectors, the interrupt masks, and the edge/level trigger mode.
7063 If THUNK_ATTRIBUTE_BIG_REAL_MODE is set in the ThunkAttributes field of ThunkContext, then the user code
7064 is invoked in big real mode. Otherwise, the user code is invoked in 16-bit real mode with 64KB segment limits.
7066 If neither THUNK_ATTRIBUTE_DISABLE_A20_MASK_INT_15 nor THUNK_ATTRIBUTE_DISABLE_A20_MASK_KBD_CTRL are set in
7067 ThunkAttributes, then it is assumed that the user code did not enable the A20 mask, and no attempt is made to
7068 disable the A20 mask.
7070 If THUNK_ATTRIBUTE_DISABLE_A20_MASK_INT_15 is set and THUNK_ATTRIBUTE_DISABLE_A20_MASK_KBD_CTRL is clear in
7071 ThunkAttributes, then attempt to use the INT 15 service to disable the A20 mask. If this INT 15 call fails,
7072 then attempt to disable the A20 mask by directly accessing the 8042 keyboard controller I/O ports.
7074 If THUNK_ATTRIBUTE_DISABLE_A20_MASK_INT_15 is clear and THUNK_ATTRIBUTE_DISABLE_A20_MASK_KBD_CTRL is set in
7075 ThunkAttributes, then attempt to disable the A20 mask by directly accessing the 8042 keyboard controller I/O ports.
7077 If ThunkContext is NULL, then ASSERT().
7078 If AsmPrepareThunk16() was not previously called with ThunkContext, then ASSERT().
7079 If both THUNK_ATTRIBUTE_DISABLE_A20_MASK_INT_15 and THUNK_ATTRIBUTE_DISABLE_A20_MASK_KBD_CTRL are set in
7080 ThunkAttributes, then ASSERT().
7082 @param ThunkContext A pointer to the context structure that describes the
7083 16-bit real mode code to call.
7089 IN OUT THUNK_CONTEXT
*ThunkContext
7094 Prepares all structures and code for a 16-bit real mode thunk, transfers
7095 control to a 16-bit real mode entry point, and returns the results.
7097 Prepares all structures and code for a 16-bit real mode thunk, transfers
7098 control to a 16-bit real mode entry point, and returns the results. If the
7099 caller only need to perform a single 16-bit real mode thunk, then this
7100 service should be used. If the caller intends to make more than one 16-bit
7101 real mode thunk, then it is more efficient if AsmPrepareThunk16() is called
7102 once and AsmThunk16() can be called for each 16-bit real mode thunk.
7104 See AsmPrepareThunk16() and AsmThunk16() for the detailed description and ASSERT() conditions.
7106 @param ThunkContext A pointer to the context structure that describes the
7107 16-bit real mode code to call.
7112 AsmPrepareAndThunk16 (
7113 IN OUT THUNK_CONTEXT
*ThunkContext