2 Provides string functions, linked list functions, math functions, synchronization
3 functions, and CPU architecture specific functions.
5 Copyright (c) 2006 - 2008, Intel Corporation
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 SPIN_LOCK
22 typedef volatile UINTN SPIN_LOCK
;
25 // Definitions for architecture specific types
27 #if defined (MDE_CPU_IA32)
29 /// IA32 context buffer used by SetJump() and LongJump()
38 } BASE_LIBRARY_JUMP_BUFFER
;
40 #define BASE_LIBRARY_JUMP_BUFFER_ALIGNMENT 4
42 #elif defined (MDE_CPU_IPF)
45 /// IPF context buffer used by SetJump() and LongJump()
80 UINT64 AfterSpillUNAT
;
86 } BASE_LIBRARY_JUMP_BUFFER
;
88 #define BASE_LIBRARY_JUMP_BUFFER_ALIGNMENT 0x10
90 #elif defined (MDE_CPU_X64)
92 /// X64 context buffer used by SetJump() and LongJump()
105 } BASE_LIBRARY_JUMP_BUFFER
;
107 #define BASE_LIBRARY_JUMP_BUFFER_ALIGNMENT 8
109 #elif defined (MDE_CPU_EBC)
111 /// EBC context buffer used by SetJump() and LongJump()
119 } BASE_LIBRARY_JUMP_BUFFER
;
121 #define BASE_LIBRARY_JUMP_BUFFER_ALIGNMENT 8
124 #error Unknown Processor Type
132 Copies one Null-terminated Unicode string to another Null-terminated Unicode
133 string and returns the new Unicode string.
135 This function copies the contents of the Unicode string Source to the Unicode
136 string Destination, and returns Destination. If Source and Destination
137 overlap, then the results are undefined.
139 If Destination is NULL, then ASSERT().
140 If Destination is not aligned on a 16-bit boundary, then ASSERT().
141 If Source is NULL, then ASSERT().
142 If Source is not aligned on a 16-bit boundary, then ASSERT().
143 If Source and Destination overlap, then ASSERT().
144 If PcdMaximumUnicodeStringLength is not zero, and Source contains more than
145 PcdMaximumUnicodeStringLength Unicode characters not including the
146 Null-terminator, then ASSERT().
148 @param Destination Pointer to a Null-terminated Unicode string.
149 @param Source Pointer to a Null-terminated Unicode string.
157 OUT CHAR16
*Destination
,
158 IN CONST CHAR16
*Source
163 Copies up to a specified length from one Null-terminated Unicode string to
164 another Null-terminated Unicode string and returns the new Unicode string.
166 This function copies the contents of the Unicode string Source to the Unicode
167 string Destination, and returns Destination. At most, Length Unicode
168 characters are copied from Source to Destination. If Length is 0, then
169 Destination is returned unmodified. If Length is greater that the number of
170 Unicode characters in Source, then Destination is padded with Null Unicode
171 characters. If Source and Destination overlap, then the results are
174 If Length > 0 and Destination is NULL, then ASSERT().
175 If Length > 0 and Destination is not aligned on a 16-bit boundary, then ASSERT().
176 If Length > 0 and Source is NULL, then ASSERT().
177 If Length > 0 and Source is not aligned on a 16-bit bounadry, then ASSERT().
178 If Source and Destination overlap, then ASSERT().
179 If PcdMaximumUnicodeStringLength is not zero, and Source contains more than
180 PcdMaximumUnicodeStringLength Unicode characters not including the
181 Null-terminator, then ASSERT().
183 @param Destination Pointer to a Null-terminated Unicode string.
184 @param Source Pointer to a Null-terminated Unicode string.
185 @param Length Maximum number of Unicode characters to copy.
193 OUT CHAR16
*Destination
,
194 IN CONST CHAR16
*Source
,
200 Returns the length of a Null-terminated Unicode string.
202 This function returns the number of Unicode characters in the Null-terminated
203 Unicode string specified by String.
205 If String is NULL, then ASSERT().
206 If String is not aligned on a 16-bit boundary, then ASSERT().
207 If PcdMaximumUnicodeStringLength is not zero, and String contains more than
208 PcdMaximumUnicodeStringLength Unicode characters not including the
209 Null-terminator, then ASSERT().
211 @param String Pointer to a Null-terminated Unicode string.
213 @return The length of String.
219 IN CONST CHAR16
*String
224 Returns the size of a Null-terminated Unicode string in bytes, including the
227 This function returns the size, in bytes, of the Null-terminated Unicode string
230 If String is NULL, then ASSERT().
231 If String is not aligned on a 16-bit boundary, then ASSERT().
232 If PcdMaximumUnicodeStringLength is not zero, and String contains more than
233 PcdMaximumUnicodeStringLength Unicode characters not including the
234 Null-terminator, then ASSERT().
236 @param String Pointer to a Null-terminated Unicode string.
238 @return The size of String.
244 IN CONST CHAR16
*String
249 Compares two Null-terminated Unicode strings, and returns the difference
250 between the first mismatched Unicode characters.
252 This function compares the Null-terminated Unicode string FirstString to the
253 Null-terminated Unicode string SecondString. If FirstString is identical to
254 SecondString, then 0 is returned. Otherwise, the value returned is the first
255 mismatched Unicode character in SecondString subtracted from the first
256 mismatched Unicode character in FirstString.
258 If FirstString is NULL, then ASSERT().
259 If FirstString is not aligned on a 16-bit boundary, then ASSERT().
260 If SecondString is NULL, then ASSERT().
261 If SecondString is not aligned on a 16-bit boundary, then ASSERT().
262 If PcdMaximumUnicodeStringLength is not zero, and FirstString contains more
263 than PcdMaximumUnicodeStringLength Unicode characters not including the
264 Null-terminator, then ASSERT().
265 If PcdMaximumUnicodeStringLength is not zero, and SecondString contains more
266 than PcdMaximumUnicodeStringLength Unicode characters not including the
267 Null-terminator, then ASSERT().
269 @param FirstString Pointer to a Null-terminated Unicode string.
270 @param SecondString Pointer to a Null-terminated Unicode string.
272 @retval 0 FirstString is identical to SecondString.
273 @return others FirstString is not identical to SecondString.
279 IN CONST CHAR16
*FirstString
,
280 IN CONST CHAR16
*SecondString
285 Compares up to a specified length the contents of two Null-terminated Unicode strings,
286 and returns the difference between the first mismatched Unicode characters.
288 This function compares the Null-terminated Unicode string FirstString to the
289 Null-terminated Unicode string SecondString. At most, Length Unicode
290 characters will be compared. If Length is 0, then 0 is returned. If
291 FirstString is identical to SecondString, then 0 is returned. Otherwise, the
292 value returned is the first mismatched Unicode character in SecondString
293 subtracted from the first mismatched Unicode character in FirstString.
295 If Length > 0 and FirstString is NULL, then ASSERT().
296 If Length > 0 and FirstString is not aligned on a 16-bit bounadary, then ASSERT().
297 If Length > 0 and SecondString is NULL, then ASSERT().
298 If Length > 0 and SecondString is not aligned on a 16-bit bounadary, then ASSERT().
299 If PcdMaximumUnicodeStringLength is not zero, and FirstString contains more
300 than PcdMaximumUnicodeStringLength Unicode characters not including the
301 Null-terminator, then ASSERT().
302 If PcdMaximumUnicodeStringLength is not zero, and SecondString contains more
303 than PcdMaximumUnicodeStringLength Unicode characters not including the
304 Null-terminator, then ASSERT().
306 @param FirstString Pointer to a Null-terminated Unicode string.
307 @param SecondString Pointer to a Null-terminated Unicode string.
308 @param Length Maximum number of Unicode characters to compare.
310 @retval 0 FirstString is identical to SecondString.
311 @return others FirstString is not identical to SecondString.
317 IN CONST CHAR16
*FirstString
,
318 IN CONST CHAR16
*SecondString
,
324 Concatenates one Null-terminated Unicode string to another Null-terminated
325 Unicode string, and returns the concatenated Unicode string.
327 This function concatenates two Null-terminated Unicode strings. The contents
328 of Null-terminated Unicode string Source are concatenated to the end of
329 Null-terminated Unicode string Destination. The Null-terminated concatenated
330 Unicode String is returned. If Source and Destination overlap, then the
331 results are undefined.
333 If Destination is NULL, then ASSERT().
334 If Destination is not aligned on a 16-bit bounadary, then ASSERT().
335 If Source is NULL, then ASSERT().
336 If Source is not aligned on a 16-bit bounadary, then ASSERT().
337 If Source and Destination overlap, then ASSERT().
338 If PcdMaximumUnicodeStringLength is not zero, and Destination contains more
339 than PcdMaximumUnicodeStringLength Unicode characters not including the
340 Null-terminator, then ASSERT().
341 If PcdMaximumUnicodeStringLength is not zero, and Source contains more than
342 PcdMaximumUnicodeStringLength Unicode characters not including the
343 Null-terminator, then ASSERT().
344 If PcdMaximumUnicodeStringLength is not zero, and concatenating Destination
345 and Source results in a Unicode string with more than
346 PcdMaximumUnicodeStringLength Unicode characters not including the
347 Null-terminator, then ASSERT().
349 @param Destination Pointer to a Null-terminated Unicode string.
350 @param Source Pointer to a Null-terminated Unicode string.
358 IN OUT CHAR16
*Destination
,
359 IN CONST CHAR16
*Source
364 Concatenates up to a specified length one Null-terminated Unicode to the end
365 of another Null-terminated Unicode string, and returns the concatenated
368 This function concatenates two Null-terminated Unicode strings. The contents
369 of Null-terminated Unicode string Source are concatenated to the end of
370 Null-terminated Unicode string Destination, and Destination is returned. At
371 most, Length Unicode characters are concatenated from Source to the end of
372 Destination, and Destination is always Null-terminated. If Length is 0, then
373 Destination is returned unmodified. If Source and Destination overlap, then
374 the results are undefined.
376 If Destination is NULL, then ASSERT().
377 If Length > 0 and Destination is not aligned on a 16-bit boundary, then ASSERT().
378 If Length > 0 and Source is NULL, then ASSERT().
379 If Length > 0 and Source is not aligned on a 16-bit boundary, then ASSERT().
380 If Source and Destination overlap, then ASSERT().
381 If PcdMaximumUnicodeStringLength is not zero, and Destination contains more
382 than PcdMaximumUnicodeStringLength Unicode characters not including the
383 Null-terminator, then ASSERT().
384 If PcdMaximumUnicodeStringLength is not zero, and Source contains more than
385 PcdMaximumUnicodeStringLength Unicode characters not including the
386 Null-terminator, then ASSERT().
387 If PcdMaximumUnicodeStringLength is not zero, and concatenating Destination
388 and Source results in a Unicode string with more than
389 PcdMaximumUnicodeStringLength Unicode characters not including the
390 Null-terminator, then ASSERT().
392 @param Destination Pointer to a Null-terminated Unicode string.
393 @param Source Pointer to a Null-terminated Unicode string.
394 @param Length Maximum number of Unicode characters to concatenate from
403 IN OUT CHAR16
*Destination
,
404 IN CONST CHAR16
*Source
,
409 Returns the first occurrence of a Null-terminated Unicode sub-string
410 in a Null-terminated Unicode string.
412 This function scans the contents of the Null-terminated Unicode string
413 specified by String and returns the first occurrence of SearchString.
414 If SearchString is not found in String, then NULL is returned. If
415 the length of SearchString is zero, then String is
418 If String is NULL, then ASSERT().
419 If String is not aligned on a 16-bit boundary, then ASSERT().
420 If SearchString is NULL, then ASSERT().
421 If SearchString is not aligned on a 16-bit boundary, then ASSERT().
423 If PcdMaximumUnicodeStringLength is not zero, and SearchString
424 or String contains more than PcdMaximumUnicodeStringLength Unicode
425 characters not including the Null-terminator, then ASSERT().
427 @param String Pointer to a Null-terminated Unicode string.
428 @param SearchString Pointer to a Null-terminated Unicode string to search for.
430 @retval NULL If the SearchString does not appear in String.
431 @return others If there is a match.
437 IN CONST CHAR16
*String
,
438 IN CONST CHAR16
*SearchString
442 Convert a Null-terminated Unicode decimal string to a value of
445 This function returns a value of type UINTN by interpreting the contents
446 of the Unicode string specified by String as a decimal number. The format
447 of the input Unicode string String is:
449 [spaces] [decimal digits].
451 The valid decimal digit character is in the range [0-9]. The
452 function will ignore the pad space, which includes spaces or
453 tab characters, before [decimal digits]. The running zero in the
454 beginning of [decimal digits] will be ignored. Then, the function
455 stops at the first character that is a not a valid decimal character
456 or a Null-terminator, whichever one comes first.
458 If String is NULL, then ASSERT().
459 If String is not aligned in a 16-bit boundary, then ASSERT().
460 If String has only pad spaces, then 0 is returned.
461 If String has no pad spaces or valid decimal digits,
463 If the number represented by String overflows according
464 to the range defined by UINTN, then ASSERT().
466 If PcdMaximumUnicodeStringLength is not zero, and String contains
467 more than PcdMaximumUnicodeStringLength Unicode characters not including
468 the Null-terminator, then ASSERT().
470 @param String Pointer to a Null-terminated Unicode string.
472 @retval Value translated from String.
478 IN CONST CHAR16
*String
482 Convert a Null-terminated Unicode decimal string to a value of
485 This function returns a value of type UINT64 by interpreting the contents
486 of the Unicode string specified by String as a decimal number. The format
487 of the input Unicode string String is:
489 [spaces] [decimal digits].
491 The valid decimal digit character is in the range [0-9]. The
492 function will ignore the pad space, which includes spaces or
493 tab characters, before [decimal digits]. The running zero in the
494 beginning of [decimal digits] will be ignored. Then, the function
495 stops at the first character that is a not a valid decimal character
496 or a Null-terminator, whichever one comes first.
498 If String is NULL, then ASSERT().
499 If String is not aligned in a 16-bit boundary, then ASSERT().
500 If String has only pad spaces, then 0 is returned.
501 If String has no pad spaces or valid decimal digits,
503 If the number represented by String overflows according
504 to the range defined by UINT64, then ASSERT().
506 If PcdMaximumUnicodeStringLength is not zero, and String contains
507 more than PcdMaximumUnicodeStringLength Unicode characters not including
508 the Null-terminator, then ASSERT().
510 @param String Pointer to a Null-terminated Unicode string.
512 @retval Value translated from String.
518 IN CONST CHAR16
*String
523 Convert a Null-terminated Unicode hexadecimal string to a value of type UINTN.
525 This function returns a value of type UINTN by interpreting the contents
526 of the Unicode string specified by String as a hexadecimal number.
527 The format of the input Unicode string String is:
529 [spaces][zeros][x][hexadecimal digits].
531 The valid hexadecimal digit character is in the range [0-9], [a-f] and [A-F].
532 The prefix "0x" is optional. Both "x" and "X" is allowed in "0x" prefix.
533 If "x" appears in the input string, it must be prefixed with at least one 0.
534 The function will ignore the pad space, which includes spaces or tab characters,
535 before [zeros], [x] or [hexadecimal digit]. The running zero before [x] or
536 [hexadecimal digit] will be ignored. Then, the decoding starts after [x] or the
537 first valid hexadecimal digit. Then, the function stops at the first character that is
538 a not a valid hexadecimal character or NULL, whichever one comes first.
540 If String is NULL, then ASSERT().
541 If String is not aligned in a 16-bit boundary, then ASSERT().
542 If String has only pad spaces, then zero is returned.
543 If String has no leading pad spaces, leading zeros or valid hexadecimal digits,
544 then zero is returned.
545 If the number represented by String overflows according to the range defined by
546 UINTN, then ASSERT().
548 If PcdMaximumUnicodeStringLength is not zero, and String contains more than
549 PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator,
552 @param String Pointer to a Null-terminated Unicode string.
554 @retval Value translated from String.
560 IN CONST CHAR16
*String
565 Convert a Null-terminated Unicode hexadecimal string to a value of type UINT64.
567 This function returns a value of type UINT64 by interpreting the contents
568 of the Unicode string specified by String as a hexadecimal number.
569 The format of the input Unicode string String is
571 [spaces][zeros][x][hexadecimal digits].
573 The valid hexadecimal digit character is in the range [0-9], [a-f] and [A-F].
574 The prefix "0x" is optional. Both "x" and "X" is allowed in "0x" prefix.
575 If "x" appears in the input string, it must be prefixed with at least one 0.
576 The function will ignore the pad space, which includes spaces or tab characters,
577 before [zeros], [x] or [hexadecimal digit]. The running zero before [x] or
578 [hexadecimal digit] will be ignored. Then, the decoding starts after [x] or the
579 first valid hexadecimal digit. Then, the function stops at the first character that is
580 a not a valid hexadecimal character or NULL, whichever one comes first.
582 If String is NULL, then ASSERT().
583 If String is not aligned in a 16-bit boundary, then ASSERT().
584 If String has only pad spaces, then zero is returned.
585 If String has no leading pad spaces, leading zeros or valid hexadecimal digits,
586 then zero is returned.
587 If the number represented by String overflows according to the range defined by
588 UINT64, then ASSERT().
590 If PcdMaximumUnicodeStringLength is not zero, and String contains more than
591 PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator,
594 @param String Pointer to a Null-terminated Unicode string.
596 @retval Value translated from String.
602 IN CONST CHAR16
*String
606 Convert a Null-terminated Unicode string to a Null-terminated
607 ASCII string and returns the ASCII string.
609 This function converts the content of the Unicode string Source
610 to the ASCII string Destination by copying the lower 8 bits of
611 each Unicode character. It returns Destination.
613 If any Unicode characters in Source contain non-zero value in
614 the upper 8 bits, then ASSERT().
616 If Destination is NULL, then ASSERT().
617 If Source is NULL, then ASSERT().
618 If Source is not aligned on a 16-bit boundary, then ASSERT().
619 If Source and Destination overlap, then ASSERT().
621 If PcdMaximumUnicodeStringLength is not zero, and Source contains
622 more than PcdMaximumUnicodeStringLength Unicode characters not including
623 the Null-terminator, then ASSERT().
625 If PcdMaximumAsciiStringLength is not zero, and Source contains more
626 than PcdMaximumAsciiStringLength Unicode characters not including the
627 Null-terminator, then ASSERT().
629 @param Source Pointer to a Null-terminated Unicode string.
630 @param Destination Pointer to a Null-terminated ASCII string.
637 UnicodeStrToAsciiStr (
638 IN CONST CHAR16
*Source
,
639 OUT CHAR8
*Destination
644 Copies one Null-terminated ASCII string to another Null-terminated ASCII
645 string and returns the new ASCII string.
647 This function copies the contents of the ASCII string Source to the ASCII
648 string Destination, and returns Destination. If Source and Destination
649 overlap, then the results are undefined.
651 If Destination is NULL, then ASSERT().
652 If Source is NULL, then ASSERT().
653 If Source and Destination overlap, then ASSERT().
654 If PcdMaximumAsciiStringLength is not zero and Source contains more than
655 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
658 @param Destination Pointer to a Null-terminated ASCII string.
659 @param Source Pointer to a Null-terminated ASCII string.
667 OUT CHAR8
*Destination
,
668 IN CONST CHAR8
*Source
673 Copies up to a specified length one Null-terminated ASCII string to another
674 Null-terminated ASCII string and returns the new ASCII string.
676 This function copies the contents of the ASCII string Source to the ASCII
677 string Destination, and returns Destination. At most, Length ASCII characters
678 are copied from Source to Destination. If Length is 0, then Destination is
679 returned unmodified. If Length is greater that the number of ASCII characters
680 in Source, then Destination is padded with Null ASCII characters. If Source
681 and Destination overlap, then the results are undefined.
683 If Destination is NULL, then ASSERT().
684 If Source is NULL, then ASSERT().
685 If Source and Destination overlap, then ASSERT().
686 If PcdMaximumAsciiStringLength is not zero, and Source contains more than
687 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
690 @param Destination Pointer to a Null-terminated ASCII string.
691 @param Source Pointer to a Null-terminated ASCII string.
692 @param Length Maximum number of ASCII characters to copy.
700 OUT CHAR8
*Destination
,
701 IN CONST CHAR8
*Source
,
707 Returns the length of a Null-terminated ASCII string.
709 This function returns the number of ASCII characters in the Null-terminated
710 ASCII string specified by String.
712 If Length > 0 and Destination is NULL, then ASSERT().
713 If Length > 0 and Source is NULL, then ASSERT().
714 If PcdMaximumAsciiStringLength is not zero and String contains more than
715 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
718 @param String Pointer to a Null-terminated ASCII string.
720 @return The length of String.
726 IN CONST CHAR8
*String
731 Returns the size of a Null-terminated ASCII string in bytes, including the
734 This function returns the size, in bytes, of the Null-terminated ASCII string
737 If String is NULL, then ASSERT().
738 If PcdMaximumAsciiStringLength is not zero and String contains more than
739 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
742 @param String Pointer to a Null-terminated ASCII string.
744 @return The size of String.
750 IN CONST CHAR8
*String
755 Compares two Null-terminated ASCII strings, and returns the difference
756 between the first mismatched ASCII characters.
758 This function compares the Null-terminated ASCII string FirstString to the
759 Null-terminated ASCII string SecondString. If FirstString is identical to
760 SecondString, then 0 is returned. Otherwise, the value returned is the first
761 mismatched ASCII character in SecondString subtracted from the first
762 mismatched ASCII character in FirstString.
764 If FirstString is NULL, then ASSERT().
765 If SecondString is NULL, then ASSERT().
766 If PcdMaximumAsciiStringLength is not zero and FirstString contains more than
767 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
769 If PcdMaximumAsciiStringLength is not zero and SecondString contains more
770 than PcdMaximumAsciiStringLength ASCII characters not including the
771 Null-terminator, then ASSERT().
773 @param FirstString Pointer to a Null-terminated ASCII string.
774 @param SecondString Pointer to a Null-terminated ASCII string.
776 @retval ==0 FirstString is identical to SecondString.
777 @retval !=0 FirstString is not identical to SecondString.
783 IN CONST CHAR8
*FirstString
,
784 IN CONST CHAR8
*SecondString
789 Performs a case insensitive comparison of two Null-terminated ASCII strings,
790 and returns the difference between the first mismatched ASCII characters.
792 This function performs a case insensitive comparison of the Null-terminated
793 ASCII string FirstString to the Null-terminated ASCII string SecondString. If
794 FirstString is identical to SecondString, then 0 is returned. Otherwise, the
795 value returned is the first mismatched lower case ASCII character in
796 SecondString subtracted from the first mismatched lower case ASCII character
799 If FirstString is NULL, then ASSERT().
800 If SecondString is NULL, then ASSERT().
801 If PcdMaximumAsciiStringLength is not zero and FirstString contains more than
802 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
804 If PcdMaximumAsciiStringLength is not zero and SecondString contains more
805 than PcdMaximumAsciiStringLength ASCII characters not including the
806 Null-terminator, then ASSERT().
808 @param FirstString Pointer to a Null-terminated ASCII string.
809 @param SecondString Pointer to a Null-terminated ASCII string.
811 @retval ==0 FirstString is identical to SecondString using case insensitive
813 @retval !=0 FirstString is not identical to SecondString using case
814 insensitive comparisons.
820 IN CONST CHAR8
*FirstString
,
821 IN CONST CHAR8
*SecondString
826 Compares two Null-terminated ASCII strings with maximum lengths, and returns
827 the difference between the first mismatched ASCII characters.
829 This function compares the Null-terminated ASCII string FirstString to the
830 Null-terminated ASCII string SecondString. At most, Length ASCII characters
831 will be compared. If Length is 0, then 0 is returned. If FirstString is
832 identical to SecondString, then 0 is returned. Otherwise, the value returned
833 is the first mismatched ASCII character in SecondString subtracted from the
834 first mismatched ASCII character in FirstString.
836 If Length > 0 and FirstString is NULL, then ASSERT().
837 If Length > 0 and SecondString is NULL, then ASSERT().
838 If PcdMaximumAsciiStringLength is not zero and FirstString contains more than
839 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
841 If PcdMaximumAsciiStringLength is not zero and SecondString contains more than
842 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
845 @param FirstString Pointer to a Null-terminated ASCII string.
846 @param SecondString Pointer to a Null-terminated ASCII string.
847 @param Length Maximum number of ASCII characters for compare.
849 @retval ==0 FirstString is identical to SecondString.
850 @retval !=0 FirstString is not identical to SecondString.
856 IN CONST CHAR8
*FirstString
,
857 IN CONST CHAR8
*SecondString
,
863 Concatenates one Null-terminated ASCII string to another Null-terminated
864 ASCII string, and returns the concatenated ASCII string.
866 This function concatenates two Null-terminated ASCII strings. The contents of
867 Null-terminated ASCII string Source are concatenated to the end of Null-
868 terminated ASCII string Destination. The Null-terminated concatenated ASCII
871 If Destination is NULL, then ASSERT().
872 If Source is NULL, then ASSERT().
873 If PcdMaximumAsciiStringLength is not zero and Destination contains more than
874 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
876 If PcdMaximumAsciiStringLength is not zero and Source contains more than
877 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
879 If PcdMaximumAsciiStringLength is not zero and concatenating Destination and
880 Source results in a ASCII string with more than PcdMaximumAsciiStringLength
881 ASCII characters, then ASSERT().
883 @param Destination Pointer to a Null-terminated ASCII string.
884 @param Source Pointer to a Null-terminated ASCII string.
892 IN OUT CHAR8
*Destination
,
893 IN CONST CHAR8
*Source
898 Concatenates up to a specified length one Null-terminated ASCII string to
899 the end of another Null-terminated ASCII string, and returns the
900 concatenated ASCII string.
902 This function concatenates two Null-terminated ASCII strings. The contents
903 of Null-terminated ASCII string Source are concatenated to the end of Null-
904 terminated ASCII string Destination, and Destination is returned. At most,
905 Length ASCII characters are concatenated from Source to the end of
906 Destination, and Destination is always Null-terminated. If Length is 0, then
907 Destination is returned unmodified. If Source and Destination overlap, then
908 the results are undefined.
910 If Length > 0 and Destination is NULL, then ASSERT().
911 If Length > 0 and Source is NULL, then ASSERT().
912 If Source and Destination overlap, then ASSERT().
913 If PcdMaximumAsciiStringLength is not zero, and Destination contains more than
914 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
916 If PcdMaximumAsciiStringLength is not zero, and Source contains more than
917 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
919 If PcdMaximumAsciiStringLength is not zero, and concatenating Destination and
920 Source results in a ASCII string with more than PcdMaximumAsciiStringLength
921 ASCII characters not including the Null-terminator, then ASSERT().
923 @param Destination Pointer to a Null-terminated ASCII string.
924 @param Source Pointer to a Null-terminated ASCII string.
925 @param Length Maximum number of ASCII characters to concatenate from
934 IN OUT CHAR8
*Destination
,
935 IN CONST CHAR8
*Source
,
941 Returns the first occurrence of a Null-terminated ASCII sub-string
942 in a Null-terminated ASCII string.
944 This function scans the contents of the ASCII string specified by String
945 and returns the first occurrence of SearchString. If SearchString is not
946 found in String, then NULL is returned. If the length of SearchString is zero,
947 then String is returned.
949 If String is NULL, then ASSERT().
950 If SearchString is NULL, then ASSERT().
952 If PcdMaximumAsciiStringLength is not zero, and SearchString or
953 String contains more than PcdMaximumAsciiStringLength Unicode characters
954 not including the Null-terminator, then ASSERT().
956 @param String Pointer to a Null-terminated ASCII string.
957 @param SearchString Pointer to a Null-terminated ASCII string to search for.
959 @retval NULL If the SearchString does not appear in String.
960 @retval others If there is a match return the first occurrence of SearchingString.
961 If the length of SearchString is zero,return String.
967 IN CONST CHAR8
*String
,
968 IN CONST CHAR8
*SearchString
973 Convert a Null-terminated ASCII decimal string to a value of type
976 This function returns a value of type UINTN by interpreting the contents
977 of the ASCII string String as a decimal number. The format of the input
978 ASCII string String is:
980 [spaces] [decimal digits].
982 The valid decimal digit character is in the range [0-9]. The function will
983 ignore the pad space, which includes spaces or tab characters, before the digits.
984 The running zero in the beginning of [decimal digits] will be ignored. Then, the
985 function stops at the first character that is a not a valid decimal character or
986 Null-terminator, whichever on comes first.
988 If String has only pad spaces, then 0 is returned.
989 If String has no pad spaces or valid decimal digits, then 0 is returned.
990 If the number represented by String overflows according to the range defined by
991 UINTN, then ASSERT().
992 If String is NULL, then ASSERT().
993 If PcdMaximumAsciiStringLength is not zero, and String contains more than
994 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
997 @param String Pointer to a Null-terminated ASCII string.
999 @retval Value translated from String.
1004 AsciiStrDecimalToUintn (
1005 IN CONST CHAR8
*String
1010 Convert a Null-terminated ASCII decimal string to a value of type
1013 This function returns a value of type UINT64 by interpreting the contents
1014 of the ASCII string String as a decimal number. The format of the input
1015 ASCII string String is:
1017 [spaces] [decimal digits].
1019 The valid decimal digit character is in the range [0-9]. The function will
1020 ignore the pad space, which includes spaces or tab characters, before the digits.
1021 The running zero in the beginning of [decimal digits] will be ignored. Then, the
1022 function stops at the first character that is a not a valid decimal character or
1023 Null-terminator, whichever on comes first.
1025 If String has only pad spaces, then 0 is returned.
1026 If String has no pad spaces or valid decimal digits, then 0 is returned.
1027 If the number represented by String overflows according to the range defined by
1028 UINT64, then ASSERT().
1029 If String is NULL, then ASSERT().
1030 If PcdMaximumAsciiStringLength is not zero, and String contains more than
1031 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
1034 @param String Pointer to a Null-terminated ASCII string.
1036 @retval Value translated from String.
1041 AsciiStrDecimalToUint64 (
1042 IN CONST CHAR8
*String
1047 Convert a Null-terminated ASCII hexadecimal string to a value of type UINTN.
1049 This function returns a value of type UINTN by interpreting the contents of
1050 the ASCII string String as a hexadecimal number. The format of the input ASCII
1053 [spaces][zeros][x][hexadecimal digits].
1055 The valid hexadecimal digit character is in the range [0-9], [a-f] and [A-F].
1056 The prefix "0x" is optional. Both "x" and "X" is allowed in "0x" prefix. If "x"
1057 appears in the input string, it must be prefixed with at least one 0. The function
1058 will ignore the pad space, which includes spaces or tab characters, before [zeros],
1059 [x] or [hexadecimal digits]. The running zero before [x] or [hexadecimal digits]
1060 will be ignored. Then, the decoding starts after [x] or the first valid hexadecimal
1061 digit. Then, the function stops at the first character that is a not a valid
1062 hexadecimal character or Null-terminator, whichever on comes first.
1064 If String has only pad spaces, then 0 is returned.
1065 If String has no leading pad spaces, leading zeros or valid hexadecimal digits, then
1068 If the number represented by String overflows according to the range defined by UINTN,
1070 If String is NULL, then ASSERT().
1071 If PcdMaximumAsciiStringLength is not zero,
1072 and String contains more than PcdMaximumAsciiStringLength ASCII characters not including
1073 the Null-terminator, then ASSERT().
1075 @param String Pointer to a Null-terminated ASCII string.
1077 @retval Value translated from String.
1082 AsciiStrHexToUintn (
1083 IN CONST CHAR8
*String
1088 Convert a Null-terminated ASCII hexadecimal string to a value of type UINT64.
1090 This function returns a value of type UINT64 by interpreting the contents of
1091 the ASCII string String as a hexadecimal number. The format of the input ASCII
1094 [spaces][zeros][x][hexadecimal digits].
1096 The valid hexadecimal digit character is in the range [0-9], [a-f] and [A-F].
1097 The prefix "0x" is optional. Both "x" and "X" is allowed in "0x" prefix. If "x"
1098 appears in the input string, it must be prefixed with at least one 0. The function
1099 will ignore the pad space, which includes spaces or tab characters, before [zeros],
1100 [x] or [hexadecimal digits]. The running zero before [x] or [hexadecimal digits]
1101 will be ignored. Then, the decoding starts after [x] or the first valid hexadecimal
1102 digit. Then, the function stops at the first character that is a not a valid
1103 hexadecimal character or Null-terminator, whichever on comes first.
1105 If String has only pad spaces, then 0 is returned.
1106 If String has no leading pad spaces, leading zeros or valid hexadecimal digits, then
1109 If the number represented by String overflows according to the range defined by UINT64,
1111 If String is NULL, then ASSERT().
1112 If PcdMaximumAsciiStringLength is not zero,
1113 and String contains more than PcdMaximumAsciiStringLength ASCII characters not including
1114 the Null-terminator, then ASSERT().
1116 @param String Pointer to a Null-terminated ASCII string.
1118 @retval Value translated from String.
1123 AsciiStrHexToUint64 (
1124 IN CONST CHAR8
*String
1129 Convert one Null-terminated ASCII string to a Null-terminated
1130 Unicode string and returns the Unicode string.
1132 This function converts the contents of the ASCII string Source to the Unicode
1133 string Destination, and returns Destination. The function terminates the
1134 Unicode string Destination by appending a Null-terminator character at the end.
1135 The caller is responsible to make sure Destination points to a buffer with size
1136 equal or greater than ((AsciiStrLen (Source) + 1) * sizeof (CHAR16)) in bytes.
1138 If Destination is NULL, then ASSERT().
1139 If Destination is not aligned on a 16-bit boundary, then ASSERT().
1140 If Source is NULL, then ASSERT().
1141 If Source and Destination overlap, then ASSERT().
1142 If PcdMaximumAsciiStringLength is not zero, and Source contains more than
1143 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
1145 If PcdMaximumUnicodeStringLength is not zero, and Source contains more than
1146 PcdMaximumUnicodeStringLength ASCII characters not including the
1147 Null-terminator, then ASSERT().
1149 @param Source Pointer to a Null-terminated ASCII string.
1150 @param Destination Pointer to a Null-terminated Unicode string.
1152 @return Destination.
1157 AsciiStrToUnicodeStr (
1158 IN CONST CHAR8
*Source
,
1159 OUT CHAR16
*Destination
1164 Converts an 8-bit value to an 8-bit BCD value.
1166 Converts the 8-bit value specified by Value to BCD. The BCD value is
1169 If Value >= 100, then ASSERT().
1171 @param Value The 8-bit value to convert to BCD. Range 0..99.
1173 @return The BCD value.
1184 Converts an 8-bit BCD value to an 8-bit value.
1186 Converts the 8-bit BCD value specified by Value to an 8-bit value. The 8-bit
1189 If Value >= 0xA0, then ASSERT().
1190 If (Value & 0x0F) >= 0x0A, then ASSERT().
1192 @param Value The 8-bit BCD value to convert to an 8-bit value.
1194 @return The 8-bit value is returned.
1205 // Linked List Functions and Macros
1209 Initializes the head node of a doubly linked list that is declared as a
1210 global variable in a module.
1212 Initializes the forward and backward links of a new linked list. After
1213 initializing a linked list with this macro, the other linked list functions
1214 may be used to add and remove nodes from the linked list. This macro results
1215 in smaller executables by initializing the linked list in the data section,
1216 instead if calling the InitializeListHead() function to perform the
1217 equivalent operation.
1219 @param ListHead The head note of a list to initiailize.
1222 #define INITIALIZE_LIST_HEAD_VARIABLE(ListHead) {&(ListHead), &(ListHead)}
1226 Initializes the head node of a doubly linked list, and returns the pointer to
1227 the head node of the doubly linked list.
1229 Initializes the forward and backward links of a new linked list. After
1230 initializing a linked list with this function, the other linked list
1231 functions may be used to add and remove nodes from the linked list. It is up
1232 to the caller of this function to allocate the memory for ListHead.
1234 If ListHead is NULL, then ASSERT().
1236 @param ListHead A pointer to the head node of a new doubly linked list.
1243 InitializeListHead (
1244 IN OUT LIST_ENTRY
*ListHead
1249 Adds a node to the beginning of a doubly linked list, and returns the pointer
1250 to the head node of the doubly linked list.
1252 Adds the node Entry at the beginning of the doubly linked list denoted by
1253 ListHead, and returns ListHead.
1255 If ListHead is NULL, then ASSERT().
1256 If Entry is NULL, then ASSERT().
1257 If ListHead was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or
1258 InitializeListHead(), then ASSERT().
1259 If PcdMaximumLinkedListLenth is not zero, and prior to insertion the number
1260 of nodes in ListHead, including the ListHead node, is greater than or
1261 equal to PcdMaximumLinkedListLength, then ASSERT().
1263 @param ListHead A pointer to the head node of a doubly linked list.
1264 @param Entry A pointer to a node that is to be inserted at the beginning
1265 of a doubly linked list.
1273 IN OUT LIST_ENTRY
*ListHead
,
1274 IN OUT LIST_ENTRY
*Entry
1279 Adds a node to the end of a doubly linked list, and returns the pointer to
1280 the head node of the doubly linked list.
1282 Adds the node Entry to the end of the doubly linked list denoted by ListHead,
1283 and returns ListHead.
1285 If ListHead is NULL, then ASSERT().
1286 If Entry is NULL, then ASSERT().
1287 If ListHead was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or
1288 InitializeListHead(), then ASSERT().
1289 If PcdMaximumLinkedListLenth is not zero, and prior to insertion the number
1290 of nodes in ListHead, including the ListHead node, is greater than or
1291 equal to PcdMaximumLinkedListLength, then ASSERT().
1293 @param ListHead A pointer to the head node of a doubly linked list.
1294 @param Entry A pointer to a node that is to be added at the end of the
1303 IN OUT LIST_ENTRY
*ListHead
,
1304 IN OUT LIST_ENTRY
*Entry
1309 Retrieves the first node of a doubly linked list.
1311 Returns the first node of a doubly linked list. List must have been
1312 initialized with INTIALIZE_LIST_HEAD_VARIABLE() or InitializeListHead().
1313 If List is empty, then List is returned.
1315 If List is NULL, then ASSERT().
1316 If List was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or
1317 InitializeListHead(), then ASSERT().
1318 If PcdMaximumLinkedListLenth is not zero, and the number of nodes
1319 in List, including the List node, is greater than or equal to
1320 PcdMaximumLinkedListLength, then ASSERT().
1322 @param List A pointer to the head node of a doubly linked list.
1324 @return The first node of a doubly linked list.
1325 @retval NULL The list is empty.
1331 IN CONST LIST_ENTRY
*List
1336 Retrieves the next node of a doubly linked list.
1338 Returns the node of a doubly linked list that follows Node.
1339 List must have been initialized with INTIALIZE_LIST_HEAD_VARIABLE()
1340 or InitializeListHead(). If List is empty, then List is returned.
1342 If List is NULL, then ASSERT().
1343 If Node is NULL, then ASSERT().
1344 If List was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or
1345 InitializeListHead(), then ASSERT().
1346 If PcdMaximumLinkedListLenth is not zero, and List contains more than
1347 PcdMaximumLinkedListLenth nodes, then ASSERT().
1348 If Node is not a node in List, then ASSERT().
1350 @param List A pointer to the head node of a doubly linked list.
1351 @param Node A pointer to a node in the doubly linked list.
1353 @return Pointer to the next node if one exists. Otherwise a null value which
1354 is actually List is returned.
1360 IN CONST LIST_ENTRY
*List
,
1361 IN CONST LIST_ENTRY
*Node
1366 Checks to see if a doubly linked list is empty or not.
1368 Checks to see if the doubly linked list is empty. If the linked list contains
1369 zero nodes, this function returns TRUE. Otherwise, it returns FALSE.
1371 If ListHead is NULL, then ASSERT().
1372 If ListHead was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or
1373 InitializeListHead(), then ASSERT().
1374 If PcdMaximumLinkedListLenth is not zero, and the number of nodes
1375 in List, including the List node, is greater than or equal to
1376 PcdMaximumLinkedListLength, then ASSERT().
1378 @param ListHead A pointer to the head node of a doubly linked list.
1380 @retval TRUE The linked list is empty.
1381 @retval FALSE The linked list is not empty.
1387 IN CONST LIST_ENTRY
*ListHead
1392 Determines if a node in a doubly linked list is the head node of a the same
1393 doubly linked list. This function is typically used to terminate a loop that
1394 traverses all the nodes in a doubly linked list starting with the head node.
1396 Returns TRUE if Node is equal to List. Returns FALSE if Node is one of the
1397 nodes in the doubly linked list specified by List. List must have been
1398 initialized with INTIALIZE_LIST_HEAD_VARIABLE() or InitializeListHead().
1400 If List is NULL, then ASSERT().
1401 If Node is NULL, then ASSERT().
1402 If List was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or InitializeListHead(),
1404 If PcdMaximumLinkedListLenth is not zero, and the number of nodes
1405 in List, including the List node, is greater than or equal to
1406 PcdMaximumLinkedListLength, then ASSERT().
1407 If Node is not a node in List and Node is not equal to List, then ASSERT().
1409 @param List A pointer to the head node of a doubly linked list.
1410 @param Node A pointer to a node in the doubly linked list.
1412 @retval TRUE Node is one of the nodes in the doubly linked list.
1413 @retval FALSE Node is not one of the nodes in the doubly linked list.
1419 IN CONST LIST_ENTRY
*List
,
1420 IN CONST LIST_ENTRY
*Node
1425 Determines if a node the last node in a doubly linked list.
1427 Returns TRUE if Node is the last node in the doubly linked list specified by
1428 List. Otherwise, FALSE is returned. List must have been initialized with
1429 INTIALIZE_LIST_HEAD_VARIABLE() or InitializeListHead().
1431 If List is NULL, then ASSERT().
1432 If Node is NULL, then ASSERT().
1433 If List was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or
1434 InitializeListHead(), then ASSERT().
1435 If PcdMaximumLinkedListLenth is not zero, and the number of nodes
1436 in List, including the List node, is greater than or equal to
1437 PcdMaximumLinkedListLength, then ASSERT().
1438 If Node is not a node in List, then ASSERT().
1440 @param List A pointer to the head node of a doubly linked list.
1441 @param Node A pointer to a node in the doubly linked list.
1443 @retval TRUE Node is the last node in the linked list.
1444 @retval FALSE Node is not the last node in the linked list.
1450 IN CONST LIST_ENTRY
*List
,
1451 IN CONST LIST_ENTRY
*Node
1456 Swaps the location of two nodes in a doubly linked list, and returns the
1457 first node after the swap.
1459 If FirstEntry is identical to SecondEntry, then SecondEntry is returned.
1460 Otherwise, the location of the FirstEntry node is swapped with the location
1461 of the SecondEntry node in a doubly linked list. SecondEntry must be in the
1462 same double linked list as FirstEntry and that double linked list must have
1463 been initialized with INTIALIZE_LIST_HEAD_VARIABLE() or InitializeListHead().
1464 SecondEntry is returned after the nodes are swapped.
1466 If FirstEntry is NULL, then ASSERT().
1467 If SecondEntry is NULL, then ASSERT().
1468 If SecondEntry and FirstEntry are not in the same linked list, then ASSERT().
1469 If PcdMaximumLinkedListLength is not zero, and the number of nodes in the
1470 linked list containing the FirstEntry and SecondEntry nodes, including
1471 the FirstEntry and SecondEntry nodes, is greater than or equal to
1472 PcdMaximumLinkedListLength, then ASSERT().
1474 @param FirstEntry A pointer to a node in a linked list.
1475 @param SecondEntry A pointer to another node in the same linked list.
1477 @return SecondEntry.
1483 IN OUT LIST_ENTRY
*FirstEntry
,
1484 IN OUT LIST_ENTRY
*SecondEntry
1489 Removes a node from a doubly linked list, and returns the node that follows
1492 Removes the node Entry from a doubly linked list. It is up to the caller of
1493 this function to release the memory used by this node if that is required. On
1494 exit, the node following Entry in the doubly linked list is returned. If
1495 Entry is the only node in the linked list, then the head node of the linked
1498 If Entry is NULL, then ASSERT().
1499 If Entry is the head node of an empty list, then ASSERT().
1500 If PcdMaximumLinkedListLength is not zero, and the number of nodes in the
1501 linked list containing Entry, including the Entry node, is greater than
1502 or equal to PcdMaximumLinkedListLength, then ASSERT().
1504 @param Entry A pointer to a node in a linked list.
1512 IN CONST LIST_ENTRY
*Entry
1520 Shifts a 64-bit integer left between 0 and 63 bits. The low bits are filled
1521 with zeros. The shifted value is returned.
1523 This function shifts the 64-bit value Operand to the left by Count bits. The
1524 low Count bits are set to zero. The shifted value is returned.
1526 If Count is greater than 63, then ASSERT().
1528 @param Operand The 64-bit operand to shift left.
1529 @param Count The number of bits to shift left.
1531 @return Operand << Count.
1543 Shifts a 64-bit integer right between 0 and 63 bits. This high bits are
1544 filled with zeros. The shifted value is returned.
1546 This function shifts the 64-bit value Operand to the right by Count bits. The
1547 high Count bits are set to zero. The shifted value is returned.
1549 If Count is greater than 63, then ASSERT().
1551 @param Operand The 64-bit operand to shift right.
1552 @param Count The number of bits to shift right.
1554 @return Operand >> Count
1566 Shifts a 64-bit integer right between 0 and 63 bits. The high bits are filled
1567 with original integer's bit 63. The shifted value is returned.
1569 This function shifts the 64-bit value Operand to the right by Count bits. The
1570 high Count bits are set to bit 63 of Operand. The shifted value is returned.
1572 If Count is greater than 63, then ASSERT().
1574 @param Operand The 64-bit operand to shift right.
1575 @param Count The number of bits to shift right.
1577 @return Operand >> Count
1589 Rotates a 32-bit integer left between 0 and 31 bits, filling the low bits
1590 with the high bits that were rotated.
1592 This function rotates the 32-bit value Operand to the left by Count bits. The
1593 low Count bits are fill with the high Count bits of Operand. The rotated
1596 If Count is greater than 31, then ASSERT().
1598 @param Operand The 32-bit operand to rotate left.
1599 @param Count The number of bits to rotate left.
1601 @return Operand << Count
1613 Rotates a 32-bit integer right between 0 and 31 bits, filling the high bits
1614 with the low bits that were rotated.
1616 This function rotates the 32-bit value Operand to the right by Count bits.
1617 The high Count bits are fill with the low Count bits of Operand. The rotated
1620 If Count is greater than 31, then ASSERT().
1622 @param Operand The 32-bit operand to rotate right.
1623 @param Count The number of bits to rotate right.
1625 @return Operand >>> Count
1637 Rotates a 64-bit integer left between 0 and 63 bits, filling the low bits
1638 with the high bits that were rotated.
1640 This function rotates the 64-bit value Operand to the left by Count bits. The
1641 low Count bits are fill with the high Count bits of Operand. The rotated
1644 If Count is greater than 63, then ASSERT().
1646 @param Operand The 64-bit operand to rotate left.
1647 @param Count The number of bits to rotate left.
1649 @return Operand << Count
1661 Rotates a 64-bit integer right between 0 and 63 bits, filling the high bits
1662 with the high low bits that were rotated.
1664 This function rotates the 64-bit value Operand to the right by Count bits.
1665 The high Count bits are fill with the low Count bits of Operand. The rotated
1668 If Count is greater than 63, then ASSERT().
1670 @param Operand The 64-bit operand to rotate right.
1671 @param Count The number of bits to rotate right.
1673 @return Operand >> Count
1685 Returns the bit position of the lowest bit set in a 32-bit value.
1687 This function computes the bit position of the lowest bit set in the 32-bit
1688 value specified by Operand. If Operand is zero, then -1 is returned.
1689 Otherwise, a value between 0 and 31 is returned.
1691 @param Operand The 32-bit operand to evaluate.
1693 @retval 0..31 The lowest bit set in Operand was found.
1694 @retval -1 Operand is zero.
1705 Returns the bit position of the lowest bit set in a 64-bit value.
1707 This function computes the bit position of the lowest bit set in the 64-bit
1708 value specified by Operand. If Operand is zero, then -1 is returned.
1709 Otherwise, a value between 0 and 63 is returned.
1711 @param Operand The 64-bit operand to evaluate.
1713 @retval 0..63 The lowest bit set in Operand was found.
1714 @retval -1 Operand is zero.
1726 Returns the bit position of the highest bit set in a 32-bit value. Equivalent
1729 This function computes the bit position of the highest bit set in the 32-bit
1730 value specified by Operand. If Operand is zero, then -1 is returned.
1731 Otherwise, a value between 0 and 31 is returned.
1733 @param Operand The 32-bit operand to evaluate.
1735 @retval 0..31 Position of the highest bit set in Operand if found.
1736 @retval -1 Operand is zero.
1747 Returns the bit position of the highest bit set in a 64-bit value. Equivalent
1750 This function computes the bit position of the highest bit set in the 64-bit
1751 value specified by Operand. If Operand is zero, then -1 is returned.
1752 Otherwise, a value between 0 and 63 is returned.
1754 @param Operand The 64-bit operand to evaluate.
1756 @retval 0..63 Position of the highest bit set in Operand if found.
1757 @retval -1 Operand is zero.
1768 Returns the value of the highest bit set in a 32-bit value. Equivalent to
1771 This function computes the value of the highest bit set in the 32-bit value
1772 specified by Operand. If Operand is zero, then zero is returned.
1774 @param Operand The 32-bit operand to evaluate.
1776 @return 1 << HighBitSet32(Operand)
1777 @retval 0 Operand is zero.
1788 Returns the value of the highest bit set in a 64-bit value. Equivalent to
1791 This function computes the value of the highest bit set in the 64-bit value
1792 specified by Operand. If Operand is zero, then zero is returned.
1794 @param Operand The 64-bit operand to evaluate.
1796 @return 1 << HighBitSet64(Operand)
1797 @retval 0 Operand is zero.
1808 Switches the endianess of a 16-bit integer.
1810 This function swaps the bytes in a 16-bit unsigned value to switch the value
1811 from little endian to big endian or vice versa. The byte swapped value is
1814 @param Value Operand A 16-bit unsigned value.
1816 @return The byte swapped Operand.
1827 Switches the endianess of a 32-bit integer.
1829 This function swaps the bytes in a 32-bit unsigned value to switch the value
1830 from little endian to big endian or vice versa. The byte swapped value is
1833 @param Value Operand A 32-bit unsigned value.
1835 @return The byte swapped Operand.
1846 Switches the endianess of a 64-bit integer.
1848 This function swaps the bytes in a 64-bit unsigned value to switch the value
1849 from little endian to big endian or vice versa. The byte swapped value is
1852 @param Value Operand A 64-bit unsigned value.
1854 @return The byte swapped Operand.
1865 Multiples a 64-bit unsigned integer by a 32-bit unsigned integer and
1866 generates a 64-bit unsigned result.
1868 This function multiples the 64-bit unsigned value Multiplicand by the 32-bit
1869 unsigned value Multiplier and generates a 64-bit unsigned result. This 64-
1870 bit unsigned result is returned.
1872 @param Multiplicand A 64-bit unsigned value.
1873 @param Multiplier A 32-bit unsigned value.
1875 @return Multiplicand * Multiplier
1881 IN UINT64 Multiplicand
,
1882 IN UINT32 Multiplier
1887 Multiples a 64-bit unsigned integer by a 64-bit unsigned integer and
1888 generates a 64-bit unsigned result.
1890 This function multiples the 64-bit unsigned value Multiplicand by the 64-bit
1891 unsigned value Multiplier and generates a 64-bit unsigned result. This 64-
1892 bit unsigned result is returned.
1894 If the result overflows, then ASSERT().
1896 @param Multiplicand A 64-bit unsigned value.
1897 @param Multiplier A 64-bit unsigned value.
1899 @return Multiplicand * Multiplier
1905 IN UINT64 Multiplicand
,
1906 IN UINT64 Multiplier
1911 Multiples a 64-bit signed integer by a 64-bit signed integer and generates a
1912 64-bit signed result.
1914 This function multiples the 64-bit signed value Multiplicand by the 64-bit
1915 signed value Multiplier and generates a 64-bit signed result. This 64-bit
1916 signed result is returned.
1918 @param Multiplicand A 64-bit signed value.
1919 @param Multiplier A 64-bit signed value.
1921 @return Multiplicand * Multiplier
1927 IN INT64 Multiplicand
,
1933 Divides a 64-bit unsigned integer by a 32-bit unsigned integer and generates
1934 a 64-bit unsigned result.
1936 This function divides the 64-bit unsigned value Dividend by the 32-bit
1937 unsigned value Divisor and generates a 64-bit unsigned quotient. This
1938 function returns the 64-bit unsigned quotient.
1940 If Divisor is 0, then ASSERT().
1942 @param Dividend A 64-bit unsigned value.
1943 @param Divisor A 32-bit unsigned value.
1945 @return Dividend / Divisor
1957 Divides a 64-bit unsigned integer by a 32-bit unsigned integer and generates
1958 a 32-bit unsigned remainder.
1960 This function divides the 64-bit unsigned value Dividend by the 32-bit
1961 unsigned value Divisor and generates a 32-bit remainder. This function
1962 returns the 32-bit unsigned remainder.
1964 If Divisor is 0, then ASSERT().
1966 @param Dividend A 64-bit unsigned value.
1967 @param Divisor A 32-bit unsigned value.
1969 @return Dividend % Divisor
1981 Divides a 64-bit unsigned integer by a 32-bit unsigned integer and generates
1982 a 64-bit unsigned result and an optional 32-bit unsigned remainder.
1984 This function divides the 64-bit unsigned value Dividend by the 32-bit
1985 unsigned value Divisor and generates a 64-bit unsigned quotient. If Remainder
1986 is not NULL, then the 32-bit unsigned remainder is returned in Remainder.
1987 This function returns the 64-bit unsigned quotient.
1989 If Divisor is 0, then ASSERT().
1991 @param Dividend A 64-bit unsigned value.
1992 @param Divisor A 32-bit unsigned value.
1993 @param Remainder A pointer to a 32-bit unsigned value. This parameter is
1994 optional and may be NULL.
1996 @return Dividend / Divisor
2001 DivU64x32Remainder (
2004 OUT UINT32
*Remainder OPTIONAL
2009 Divides a 64-bit unsigned integer by a 64-bit unsigned integer and generates
2010 a 64-bit unsigned result and an optional 64-bit unsigned remainder.
2012 This function divides the 64-bit unsigned value Dividend by the 64-bit
2013 unsigned value Divisor and generates a 64-bit unsigned quotient. If Remainder
2014 is not NULL, then the 64-bit unsigned remainder is returned in Remainder.
2015 This function returns the 64-bit unsigned quotient.
2017 If Divisor is 0, then ASSERT().
2019 @param Dividend A 64-bit unsigned value.
2020 @param Divisor A 64-bit unsigned value.
2021 @param Remainder A pointer to a 64-bit unsigned value. This parameter is
2022 optional and may be NULL.
2024 @return Dividend / Divisor
2029 DivU64x64Remainder (
2032 OUT UINT64
*Remainder OPTIONAL
2037 Divides a 64-bit signed integer by a 64-bit signed integer and generates a
2038 64-bit signed result and a optional 64-bit signed remainder.
2040 This function divides the 64-bit signed value Dividend by the 64-bit signed
2041 value Divisor and generates a 64-bit signed quotient. If Remainder is not
2042 NULL, then the 64-bit signed remainder is returned in Remainder. This
2043 function returns the 64-bit signed quotient.
2045 It is the caller's responsibility to not call this function with a Divisor of 0.
2046 If Divisor is 0, then the quotient and remainder should be assumed to be
2047 the largest negative integer.
2049 If Divisor is 0, then ASSERT().
2051 @param Dividend A 64-bit signed value.
2052 @param Divisor A 64-bit signed value.
2053 @param Remainder A pointer to a 64-bit signed value. This parameter is
2054 optional and may be NULL.
2056 @return Dividend / Divisor
2061 DivS64x64Remainder (
2064 OUT INT64
*Remainder OPTIONAL
2069 Reads a 16-bit value from memory that may be unaligned.
2071 This function returns the 16-bit value pointed to by Buffer. The function
2072 guarantees that the read operation does not produce an alignment fault.
2074 If the Buffer is NULL, then ASSERT().
2076 @param Buffer Pointer to a 16-bit value that may be unaligned.
2078 @return The 16-bit value read from Buffer.
2084 IN CONST UINT16
*Buffer
2089 Writes a 16-bit value to memory that may be unaligned.
2091 This function writes the 16-bit value specified by Value to Buffer. Value is
2092 returned. The function guarantees that the write operation does not produce
2095 If the Buffer is NULL, then ASSERT().
2097 @param Buffer Pointer to a 16-bit value that may be unaligned.
2098 @param Value 16-bit value to write to Buffer.
2100 @return The 16-bit value to write to Buffer.
2112 Reads a 24-bit value from memory that may be unaligned.
2114 This function returns the 24-bit value pointed to by Buffer. The function
2115 guarantees that the read operation does not produce an alignment fault.
2117 If the Buffer is NULL, then ASSERT().
2119 @param Buffer Pointer to a 24-bit value that may be unaligned.
2121 @return The 24-bit value read from Buffer.
2127 IN CONST UINT32
*Buffer
2132 Writes a 24-bit value to memory that may be unaligned.
2134 This function writes the 24-bit value specified by Value to Buffer. Value is
2135 returned. The function guarantees that the write operation does not produce
2138 If the Buffer is NULL, then ASSERT().
2140 @param Buffer Pointer to a 24-bit value that may be unaligned.
2141 @param Value 24-bit value to write to Buffer.
2143 @return The 24-bit value to write to Buffer.
2155 Reads a 32-bit value from memory that may be unaligned.
2157 This function returns the 32-bit value pointed to by Buffer. The function
2158 guarantees that the read operation does not produce an alignment fault.
2160 If the Buffer is NULL, then ASSERT().
2162 @param Buffer Pointer to a 32-bit value that may be unaligned.
2164 @return The 32-bit value read from Buffer.
2170 IN CONST UINT32
*Buffer
2175 Writes a 32-bit value to memory that may be unaligned.
2177 This function writes the 32-bit value specified by Value to Buffer. Value is
2178 returned. The function guarantees that the write operation does not produce
2181 If the Buffer is NULL, then ASSERT().
2183 @param Buffer Pointer to a 32-bit value that may be unaligned.
2184 @param Value 32-bit value to write to Buffer.
2186 @return The 32-bit value to write to Buffer.
2198 Reads a 64-bit value from memory that may be unaligned.
2200 This function returns the 64-bit value pointed to by Buffer. The function
2201 guarantees that the read operation does not produce an alignment fault.
2203 If the Buffer is NULL, then ASSERT().
2205 @param Buffer Pointer to a 64-bit value that may be unaligned.
2207 @return The 64-bit value read from Buffer.
2213 IN CONST UINT64
*Buffer
2218 Writes a 64-bit value to memory that may be unaligned.
2220 This function writes the 64-bit value specified by Value to Buffer. Value is
2221 returned. The function guarantees that the write operation does not produce
2224 If the Buffer is NULL, then ASSERT().
2226 @param Buffer Pointer to a 64-bit value that may be unaligned.
2227 @param Value 64-bit value to write to Buffer.
2229 @return The 64-bit value to write to Buffer.
2241 // Bit Field Functions
2245 Returns a bit field from an 8-bit value.
2247 Returns the bitfield specified by the StartBit and the EndBit from Operand.
2249 If 8-bit operations are not supported, then ASSERT().
2250 If StartBit is greater than 7, then ASSERT().
2251 If EndBit is greater than 7, then ASSERT().
2252 If EndBit is less than StartBit, then ASSERT().
2254 @param Operand Operand on which to perform the bitfield operation.
2255 @param StartBit The ordinal of the least significant bit in the bit field.
2257 @param EndBit The ordinal of the most significant bit in the bit field.
2260 @return The bit field read.
2273 Writes a bit field to an 8-bit value, and returns the result.
2275 Writes Value to the bit field specified by the StartBit and the EndBit in
2276 Operand. All other bits in Operand are preserved. The new 8-bit value is
2279 If 8-bit operations are not supported, then ASSERT().
2280 If StartBit is greater than 7, then ASSERT().
2281 If EndBit is greater than 7, then ASSERT().
2282 If EndBit is less than StartBit, then ASSERT().
2284 @param Operand Operand on which to perform the bitfield operation.
2285 @param StartBit The ordinal of the least significant bit in the bit field.
2287 @param EndBit The ordinal of the most significant bit in the bit field.
2289 @param Value New value of the bit field.
2291 @return The new 8-bit value.
2305 Reads a bit field from an 8-bit value, performs a bitwise OR, and returns the
2308 Performs a bitwise inclusive OR between the bit field specified by StartBit
2309 and EndBit in Operand and the value specified by OrData. All other bits in
2310 Operand are preserved. The new 8-bit value is returned.
2312 If 8-bit operations are not supported, then ASSERT().
2313 If StartBit is greater than 7, then ASSERT().
2314 If EndBit is greater than 7, then ASSERT().
2315 If EndBit is less than StartBit, then ASSERT().
2317 @param Operand Operand on which to perform the bitfield operation.
2318 @param StartBit The ordinal of the least significant bit in the bit field.
2320 @param EndBit The ordinal of the most significant bit in the bit field.
2322 @param OrData The value to OR with the read value from the value
2324 @return The new 8-bit value.
2338 Reads a bit field from an 8-bit value, performs a bitwise AND, and returns
2341 Performs a bitwise AND between the bit field specified by StartBit and EndBit
2342 in Operand and the value specified by AndData. All other bits in Operand are
2343 preserved. The new 8-bit value is returned.
2345 If 8-bit operations are not supported, then ASSERT().
2346 If StartBit is greater than 7, then ASSERT().
2347 If EndBit is greater than 7, then ASSERT().
2348 If EndBit is less than StartBit, then ASSERT().
2350 @param Operand Operand on which to perform the bitfield operation.
2351 @param StartBit The ordinal of the least significant bit in the bit field.
2353 @param EndBit The ordinal of the most significant bit in the bit field.
2355 @param AndData The value to AND with the read value from the value.
2357 @return The new 8-bit value.
2371 Reads a bit field from an 8-bit value, performs a bitwise AND followed by a
2372 bitwise OR, and returns the result.
2374 Performs a bitwise AND between the bit field specified by StartBit and EndBit
2375 in Operand and the value specified by AndData, followed by a bitwise
2376 inclusive OR with value specified by OrData. All other bits in Operand are
2377 preserved. The new 8-bit value is returned.
2379 If 8-bit operations are not supported, then ASSERT().
2380 If StartBit is greater than 7, then ASSERT().
2381 If EndBit is greater than 7, then ASSERT().
2382 If EndBit is less than StartBit, then ASSERT().
2384 @param Operand Operand on which to perform the bitfield operation.
2385 @param StartBit The ordinal of the least significant bit in the bit field.
2387 @param EndBit The ordinal of the most significant bit in the bit field.
2389 @param AndData The value to AND with the read value from the value.
2390 @param OrData The value to OR with the result of the AND operation.
2392 @return The new 8-bit value.
2397 BitFieldAndThenOr8 (
2407 Returns a bit field from a 16-bit value.
2409 Returns the bitfield specified by the StartBit and the EndBit from Operand.
2411 If 16-bit operations are not supported, then ASSERT().
2412 If StartBit is greater than 15, then ASSERT().
2413 If EndBit is greater than 15, then ASSERT().
2414 If EndBit is less than StartBit, then ASSERT().
2416 @param Operand Operand on which to perform the bitfield operation.
2417 @param StartBit The ordinal of the least significant bit in the bit field.
2419 @param EndBit The ordinal of the most significant bit in the bit field.
2422 @return The bit field read.
2435 Writes a bit field to a 16-bit value, and returns the result.
2437 Writes Value to the bit field specified by the StartBit and the EndBit in
2438 Operand. All other bits in Operand are preserved. The new 16-bit value is
2441 If 16-bit operations are not supported, then ASSERT().
2442 If StartBit is greater than 15, then ASSERT().
2443 If EndBit is greater than 15, then ASSERT().
2444 If EndBit is less than StartBit, then ASSERT().
2446 @param Operand Operand on which to perform the bitfield operation.
2447 @param StartBit The ordinal of the least significant bit in the bit field.
2449 @param EndBit The ordinal of the most significant bit in the bit field.
2451 @param Value New value of the bit field.
2453 @return The new 16-bit value.
2467 Reads a bit field from a 16-bit value, performs a bitwise OR, and returns the
2470 Performs a bitwise inclusive OR between the bit field specified by StartBit
2471 and EndBit in Operand and the value specified by OrData. All other bits in
2472 Operand are preserved. The new 16-bit value is returned.
2474 If 16-bit operations are not supported, then ASSERT().
2475 If StartBit is greater than 15, then ASSERT().
2476 If EndBit is greater than 15, then ASSERT().
2477 If EndBit is less than StartBit, then ASSERT().
2479 @param Operand Operand on which to perform the bitfield operation.
2480 @param StartBit The ordinal of the least significant bit in the bit field.
2482 @param EndBit The ordinal of the most significant bit in the bit field.
2484 @param OrData The value to OR with the read value from the value
2486 @return The new 16-bit value.
2500 Reads a bit field from a 16-bit value, performs a bitwise AND, and returns
2503 Performs a bitwise AND between the bit field specified by StartBit and EndBit
2504 in Operand and the value specified by AndData. All other bits in Operand are
2505 preserved. The new 16-bit value is returned.
2507 If 16-bit operations are not supported, then ASSERT().
2508 If StartBit is greater than 15, then ASSERT().
2509 If EndBit is greater than 15, then ASSERT().
2510 If EndBit is less than StartBit, then ASSERT().
2512 @param Operand Operand on which to perform the bitfield operation.
2513 @param StartBit The ordinal of the least significant bit in the bit field.
2515 @param EndBit The ordinal of the most significant bit in the bit field.
2517 @param AndData The value to AND with the read value from the value
2519 @return The new 16-bit value.
2533 Reads a bit field from a 16-bit value, performs a bitwise AND followed by a
2534 bitwise OR, and returns the result.
2536 Performs a bitwise AND between the bit field specified by StartBit and EndBit
2537 in Operand and the value specified by AndData, followed by a bitwise
2538 inclusive OR with value specified by OrData. All other bits in Operand are
2539 preserved. The new 16-bit value is returned.
2541 If 16-bit operations are not supported, then ASSERT().
2542 If StartBit is greater than 15, then ASSERT().
2543 If EndBit is greater than 15, then ASSERT().
2544 If EndBit is less than StartBit, then ASSERT().
2546 @param Operand Operand on which to perform the bitfield operation.
2547 @param StartBit The ordinal of the least significant bit in the bit field.
2549 @param EndBit The ordinal of the most significant bit in the bit field.
2551 @param AndData The value to AND with the read value from the value.
2552 @param OrData The value to OR with the result of the AND operation.
2554 @return The new 16-bit value.
2559 BitFieldAndThenOr16 (
2569 Returns a bit field from a 32-bit value.
2571 Returns the bitfield specified by the StartBit and the EndBit from Operand.
2573 If 32-bit operations are not supported, then ASSERT().
2574 If StartBit is greater than 31, then ASSERT().
2575 If EndBit is greater than 31, then ASSERT().
2576 If EndBit is less than StartBit, then ASSERT().
2578 @param Operand Operand on which to perform the bitfield operation.
2579 @param StartBit The ordinal of the least significant bit in the bit field.
2581 @param EndBit The ordinal of the most significant bit in the bit field.
2584 @return The bit field read.
2597 Writes a bit field to a 32-bit value, and returns the result.
2599 Writes Value to the bit field specified by the StartBit and the EndBit in
2600 Operand. All other bits in Operand are preserved. The new 32-bit value is
2603 If 32-bit operations are not supported, then ASSERT().
2604 If StartBit is greater than 31, then ASSERT().
2605 If EndBit is greater than 31, then ASSERT().
2606 If EndBit is less than StartBit, then ASSERT().
2608 @param Operand Operand on which to perform the bitfield operation.
2609 @param StartBit The ordinal of the least significant bit in the bit field.
2611 @param EndBit The ordinal of the most significant bit in the bit field.
2613 @param Value New value of the bit field.
2615 @return The new 32-bit value.
2629 Reads a bit field from a 32-bit value, performs a bitwise OR, and returns the
2632 Performs a bitwise inclusive OR between the bit field specified by StartBit
2633 and EndBit in Operand and the value specified by OrData. All other bits in
2634 Operand are preserved. The new 32-bit value is returned.
2636 If 32-bit operations are not supported, then ASSERT().
2637 If StartBit is greater than 31, then ASSERT().
2638 If EndBit is greater than 31, then ASSERT().
2639 If EndBit is less than StartBit, then ASSERT().
2641 @param Operand Operand on which to perform the bitfield operation.
2642 @param StartBit The ordinal of the least significant bit in the bit field.
2644 @param EndBit The ordinal of the most significant bit in the bit field.
2646 @param OrData The value to OR with the read value from the value
2648 @return The new 32-bit value.
2662 Reads a bit field from a 32-bit value, performs a bitwise AND, and returns
2665 Performs a bitwise AND between the bit field specified by StartBit and EndBit
2666 in Operand and the value specified by AndData. All other bits in Operand are
2667 preserved. The new 32-bit value is returned.
2669 If 32-bit operations are not supported, then ASSERT().
2670 If StartBit is greater than 31, then ASSERT().
2671 If EndBit is greater than 31, then ASSERT().
2672 If EndBit is less than StartBit, then ASSERT().
2674 @param Operand Operand on which to perform the bitfield operation.
2675 @param StartBit The ordinal of the least significant bit in the bit field.
2677 @param EndBit The ordinal of the most significant bit in the bit field.
2679 @param AndData The value to AND with the read value from the value
2681 @return The new 32-bit value.
2695 Reads a bit field from a 32-bit value, performs a bitwise AND followed by a
2696 bitwise OR, and returns the result.
2698 Performs a bitwise AND between the bit field specified by StartBit and EndBit
2699 in Operand and the value specified by AndData, followed by a bitwise
2700 inclusive OR with value specified by OrData. All other bits in Operand are
2701 preserved. The new 32-bit value is returned.
2703 If 32-bit operations are not supported, then ASSERT().
2704 If StartBit is greater than 31, then ASSERT().
2705 If EndBit is greater than 31, then ASSERT().
2706 If EndBit is less than StartBit, then ASSERT().
2708 @param Operand Operand on which to perform the bitfield operation.
2709 @param StartBit The ordinal of the least significant bit in the bit field.
2711 @param EndBit The ordinal of the most significant bit in the bit field.
2713 @param AndData The value to AND with the read value from the value.
2714 @param OrData The value to OR with the result of the AND operation.
2716 @return The new 32-bit value.
2721 BitFieldAndThenOr32 (
2731 Returns a bit field from a 64-bit value.
2733 Returns the bitfield specified by the StartBit and the EndBit from Operand.
2735 If 64-bit operations are not supported, then ASSERT().
2736 If StartBit is greater than 63, then ASSERT().
2737 If EndBit is greater than 63, then ASSERT().
2738 If EndBit is less than StartBit, then ASSERT().
2740 @param Operand Operand on which to perform the bitfield operation.
2741 @param StartBit The ordinal of the least significant bit in the bit field.
2743 @param EndBit The ordinal of the most significant bit in the bit field.
2746 @return The bit field read.
2759 Writes a bit field to a 64-bit value, and returns the result.
2761 Writes Value to the bit field specified by the StartBit and the EndBit in
2762 Operand. All other bits in Operand are preserved. The new 64-bit value is
2765 If 64-bit operations are not supported, then ASSERT().
2766 If StartBit is greater than 63, then ASSERT().
2767 If EndBit is greater than 63, then ASSERT().
2768 If EndBit is less than StartBit, then ASSERT().
2770 @param Operand Operand on which to perform the bitfield operation.
2771 @param StartBit The ordinal of the least significant bit in the bit field.
2773 @param EndBit The ordinal of the most significant bit in the bit field.
2775 @param Value New value of the bit field.
2777 @return The new 64-bit value.
2791 Reads a bit field from a 64-bit value, performs a bitwise OR, and returns the
2794 Performs a bitwise inclusive OR between the bit field specified by StartBit
2795 and EndBit in Operand and the value specified by OrData. All other bits in
2796 Operand are preserved. The new 64-bit value is returned.
2798 If 64-bit operations are not supported, then ASSERT().
2799 If StartBit is greater than 63, then ASSERT().
2800 If EndBit is greater than 63, then ASSERT().
2801 If EndBit is less than StartBit, then ASSERT().
2803 @param Operand Operand on which to perform the bitfield operation.
2804 @param StartBit The ordinal of the least significant bit in the bit field.
2806 @param EndBit The ordinal of the most significant bit in the bit field.
2808 @param OrData The value to OR with the read value from the value
2810 @return The new 64-bit value.
2824 Reads a bit field from a 64-bit value, performs a bitwise AND, and returns
2827 Performs a bitwise AND between the bit field specified by StartBit and EndBit
2828 in Operand and the value specified by AndData. All other bits in Operand are
2829 preserved. The new 64-bit value is returned.
2831 If 64-bit operations are not supported, then ASSERT().
2832 If StartBit is greater than 63, then ASSERT().
2833 If EndBit is greater than 63, then ASSERT().
2834 If EndBit is less than StartBit, then ASSERT().
2836 @param Operand Operand on which to perform the bitfield operation.
2837 @param StartBit The ordinal of the least significant bit in the bit field.
2839 @param EndBit The ordinal of the most significant bit in the bit field.
2841 @param AndData The value to AND with the read value from the value
2843 @return The new 64-bit value.
2857 Reads a bit field from a 64-bit value, performs a bitwise AND followed by a
2858 bitwise OR, and returns the result.
2860 Performs a bitwise AND between the bit field specified by StartBit and EndBit
2861 in Operand and the value specified by AndData, followed by a bitwise
2862 inclusive OR with value specified by OrData. All other bits in Operand are
2863 preserved. The new 64-bit value is returned.
2865 If 64-bit operations are not supported, then ASSERT().
2866 If StartBit is greater than 63, then ASSERT().
2867 If EndBit is greater than 63, then ASSERT().
2868 If EndBit is less than StartBit, then ASSERT().
2870 @param Operand Operand on which to perform the bitfield operation.
2871 @param StartBit The ordinal of the least significant bit in the bit field.
2873 @param EndBit The ordinal of the most significant bit in the bit field.
2875 @param AndData The value to AND with the read value from the value.
2876 @param OrData The value to OR with the result of the AND operation.
2878 @return The new 64-bit value.
2883 BitFieldAndThenOr64 (
2893 // Base Library Synchronization Functions
2897 Retrieves the architecture specific spin lock alignment requirements for
2898 optimal spin lock performance.
2900 This function retrieves the spin lock alignment requirements for optimal
2901 performance on a given CPU architecture. The spin lock alignment must be a
2902 power of two and is returned by this function. If there are no alignment
2903 requirements, then 1 must be returned. The spin lock synchronization
2904 functions must function correctly if the spin lock size and alignment values
2905 returned by this function are not used at all. These values are hints to the
2906 consumers of the spin lock synchronization functions to obtain optimal spin
2909 @return The architecture specific spin lock alignment.
2914 GetSpinLockProperties (
2920 Initializes a spin lock to the released state and returns the spin lock.
2922 This function initializes the spin lock specified by SpinLock to the released
2923 state, and returns SpinLock. Optimal performance can be achieved by calling
2924 GetSpinLockProperties() to determine the size and alignment requirements for
2927 If SpinLock is NULL, then ASSERT().
2929 @param SpinLock A pointer to the spin lock to initialize to the released
2932 @return SpinLock in release state.
2937 InitializeSpinLock (
2938 OUT SPIN_LOCK
*SpinLock
2943 Waits until a spin lock can be placed in the acquired state.
2945 This function checks the state of the spin lock specified by SpinLock. If
2946 SpinLock is in the released state, then this function places SpinLock in the
2947 acquired state and returns SpinLock. Otherwise, this function waits
2948 indefinitely for the spin lock to be released, and then places it in the
2949 acquired state and returns SpinLock. All state transitions of SpinLock must
2950 be performed using MP safe mechanisms.
2952 If SpinLock is NULL, then ASSERT().
2953 If SpinLock was not initialized with InitializeSpinLock(), then ASSERT().
2954 If PcdSpinLockTimeout is not zero, and SpinLock is can not be acquired in
2955 PcdSpinLockTimeout microseconds, then ASSERT().
2957 @param SpinLock A pointer to the spin lock to place in the acquired state.
2959 @return SpinLock acquired lock.
2965 IN OUT SPIN_LOCK
*SpinLock
2970 Attempts to place a spin lock in the acquired state.
2972 This function checks the state of the spin lock specified by SpinLock. If
2973 SpinLock is in the released state, then this function places SpinLock in the
2974 acquired state and returns TRUE. Otherwise, FALSE is returned. All state
2975 transitions of SpinLock must be performed using MP safe mechanisms.
2977 If SpinLock is NULL, then ASSERT().
2978 If SpinLock was not initialized with InitializeSpinLock(), then ASSERT().
2980 @param SpinLock A pointer to the spin lock to place in the acquired state.
2982 @retval TRUE SpinLock was placed in the acquired state.
2983 @retval FALSE SpinLock could not be acquired.
2988 AcquireSpinLockOrFail (
2989 IN OUT SPIN_LOCK
*SpinLock
2994 Releases a spin lock.
2996 This function places the spin lock specified by SpinLock in the release state
2997 and returns SpinLock.
2999 If SpinLock is NULL, then ASSERT().
3000 If SpinLock was not initialized with InitializeSpinLock(), then ASSERT().
3002 @param SpinLock A pointer to the spin lock to release.
3004 @return SpinLock released lock.
3010 IN OUT SPIN_LOCK
*SpinLock
3015 Performs an atomic increment of an 32-bit unsigned integer.
3017 Performs an atomic increment of the 32-bit unsigned integer specified by
3018 Value and returns the incremented value. The increment operation must be
3019 performed using MP safe mechanisms. The state of the return value is not
3020 guaranteed to be MP safe.
3022 If Value is NULL, then ASSERT().
3024 @param Value A pointer to the 32-bit value to increment.
3026 @return The incremented value.
3031 InterlockedIncrement (
3037 Performs an atomic decrement of an 32-bit unsigned integer.
3039 Performs an atomic decrement of the 32-bit unsigned integer specified by
3040 Value and returns the decremented value. The decrement operation must be
3041 performed using MP safe mechanisms. The state of the return value is not
3042 guaranteed to be MP safe.
3044 If Value is NULL, then ASSERT().
3046 @param Value A pointer to the 32-bit value to decrement.
3048 @return The decremented value.
3053 InterlockedDecrement (
3059 Performs an atomic compare exchange operation on a 32-bit unsigned integer.
3061 Performs an atomic compare exchange operation on the 32-bit unsigned integer
3062 specified by Value. If Value is equal to CompareValue, then Value is set to
3063 ExchangeValue and CompareValue is returned. If Value is not equal to CompareValue,
3064 then Value is returned. The compare exchange operation must be performed using
3067 If Value is NULL, then ASSERT().
3069 @param Value A pointer to the 32-bit value for the compare exchange
3071 @param CompareValue 32-bit value used in compare operation.
3072 @param ExchangeValue 32-bit value used in exchange operation.
3074 @return The original *Value before exchange.
3079 InterlockedCompareExchange32 (
3080 IN OUT UINT32
*Value
,
3081 IN UINT32 CompareValue
,
3082 IN UINT32 ExchangeValue
3087 Performs an atomic compare exchange operation on a 64-bit unsigned integer.
3089 Performs an atomic compare exchange operation on the 64-bit unsigned integer specified
3090 by Value. If Value is equal to CompareValue, then Value is set to ExchangeValue and
3091 CompareValue is returned. If Value is not equal to CompareValue, then Value is returned.
3092 The compare exchange operation must be performed using MP safe mechanisms.
3094 If Value is NULL, then ASSERT().
3096 @param Value A pointer to the 64-bit value for the compare exchange
3098 @param CompareValue 64-bit value used in compare operation.
3099 @param ExchangeValue 64-bit value used in exchange operation.
3101 @return The original *Value before exchange.
3106 InterlockedCompareExchange64 (
3107 IN OUT UINT64
*Value
,
3108 IN UINT64 CompareValue
,
3109 IN UINT64 ExchangeValue
3114 Performs an atomic compare exchange operation on a pointer value.
3116 Performs an atomic compare exchange operation on the pointer value specified
3117 by Value. If Value is equal to CompareValue, then Value is set to
3118 ExchangeValue and CompareValue is returned. If Value is not equal to
3119 CompareValue, then Value is returned. The compare exchange operation must be
3120 performed using MP safe mechanisms.
3122 If Value is NULL, then ASSERT().
3124 @param Value A pointer to the pointer value for the compare exchange
3126 @param CompareValue Pointer value used in compare operation.
3127 @param ExchangeValue Pointer value used in exchange operation.
3129 @return The original *Value before exchange.
3133 InterlockedCompareExchangePointer (
3134 IN OUT VOID
**Value
,
3135 IN VOID
*CompareValue
,
3136 IN VOID
*ExchangeValue
3141 // Base Library Checksum Functions
3145 Returns the sum of all elements in a buffer in unit of UINT8.
3146 During calculation, the carry bits are dropped.
3148 This function calculates the sum of all elements in a buffer
3149 in unit of UINT8. The carry bits in result of addition are dropped.
3150 The result is returned as UINT8. If Length is Zero, then Zero is
3153 If Buffer is NULL, then ASSERT().
3154 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
3156 @param Buffer Pointer to the buffer to carry out the sum operation.
3157 @param Length The size, in bytes, of Buffer.
3159 @return Sum The sum of Buffer with carry bits dropped during additions.
3165 IN CONST UINT8
*Buffer
,
3171 Returns the two's complement checksum of all elements in a buffer
3174 This function first calculates the sum of the 8-bit values in the
3175 buffer specified by Buffer and Length. The carry bits in the result
3176 of addition are dropped. Then, the two's complement of the sum is
3177 returned. If Length is 0, then 0 is returned.
3179 If Buffer is NULL, then ASSERT().
3180 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
3182 @param Buffer Pointer to the buffer to carry out the checksum operation.
3183 @param Length The size, in bytes, of Buffer.
3185 @return Checksum The 2's complement checksum of Buffer.
3190 CalculateCheckSum8 (
3191 IN CONST UINT8
*Buffer
,
3197 Returns the sum of all elements in a buffer of 16-bit values. During
3198 calculation, the carry bits are dropped.
3200 This function calculates the sum of the 16-bit values in the buffer
3201 specified by Buffer and Length. The carry bits in result of addition are dropped.
3202 The 16-bit result is returned. If Length is 0, then 0 is returned.
3204 If Buffer is NULL, then ASSERT().
3205 If Buffer is not aligned on a 16-bit boundary, then ASSERT().
3206 If Length is not aligned on a 16-bit boundary, then ASSERT().
3207 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
3209 @param Buffer Pointer to the buffer to carry out the sum operation.
3210 @param Length The size, in bytes, of Buffer.
3212 @return Sum The sum of Buffer with carry bits dropped during additions.
3218 IN CONST UINT16
*Buffer
,
3224 Returns the two's complement checksum of all elements in a buffer of
3227 This function first calculates the sum of the 16-bit values in the buffer
3228 specified by Buffer and Length. The carry bits in the result of addition
3229 are dropped. Then, the two's complement of the sum is returned. If Length
3230 is 0, then 0 is returned.
3232 If Buffer is NULL, then ASSERT().
3233 If Buffer is not aligned on a 16-bit boundary, then ASSERT().
3234 If Length is not aligned on a 16-bit boundary, then ASSERT().
3235 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
3237 @param Buffer Pointer to the buffer to carry out the checksum operation.
3238 @param Length The size, in bytes, of Buffer.
3240 @return Checksum The 2's complement checksum of Buffer.
3245 CalculateCheckSum16 (
3246 IN CONST UINT16
*Buffer
,
3252 Returns the sum of all elements in a buffer of 32-bit values. During
3253 calculation, the carry bits are dropped.
3255 This function calculates the sum of the 32-bit values in the buffer
3256 specified by Buffer and Length. The carry bits in result of addition are dropped.
3257 The 32-bit result is returned. If Length is 0, then 0 is returned.
3259 If Buffer is NULL, then ASSERT().
3260 If Buffer is not aligned on a 32-bit boundary, then ASSERT().
3261 If Length is not aligned on a 32-bit boundary, then ASSERT().
3262 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
3264 @param Buffer Pointer to the buffer to carry out the sum operation.
3265 @param Length The size, in bytes, of Buffer.
3267 @return Sum The sum of Buffer with carry bits dropped during additions.
3273 IN CONST UINT32
*Buffer
,
3279 Returns the two's complement checksum of all elements in a buffer of
3282 This function first calculates the sum of the 32-bit values in the buffer
3283 specified by Buffer and Length. The carry bits in the result of addition
3284 are dropped. Then, the two's complement of the sum is returned. If Length
3285 is 0, then 0 is returned.
3287 If Buffer is NULL, then ASSERT().
3288 If Buffer is not aligned on a 32-bit boundary, then ASSERT().
3289 If Length is not aligned on a 32-bit boundary, then ASSERT().
3290 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
3292 @param Buffer Pointer to the buffer to carry out the checksum operation.
3293 @param Length The size, in bytes, of Buffer.
3295 @return Checksum The 2's complement checksum of Buffer.
3300 CalculateCheckSum32 (
3301 IN CONST UINT32
*Buffer
,
3307 Returns the sum of all elements in a buffer of 64-bit values. During
3308 calculation, the carry bits are dropped.
3310 This function calculates the sum of the 64-bit values in the buffer
3311 specified by Buffer and Length. The carry bits in result of addition are dropped.
3312 The 64-bit result is returned. If Length is 0, then 0 is returned.
3314 If Buffer is NULL, then ASSERT().
3315 If Buffer is not aligned on a 64-bit boundary, then ASSERT().
3316 If Length is not aligned on a 64-bit boundary, then ASSERT().
3317 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
3319 @param Buffer Pointer to the buffer to carry out the sum operation.
3320 @param Length The size, in bytes, of Buffer.
3322 @return Sum The sum of Buffer with carry bits dropped during additions.
3328 IN CONST UINT64
*Buffer
,
3334 Returns the two's complement checksum of all elements in a buffer of
3337 This function first calculates the sum of the 64-bit values in the buffer
3338 specified by Buffer and Length. The carry bits in the result of addition
3339 are dropped. Then, the two's complement of the sum is returned. If Length
3340 is 0, then 0 is returned.
3342 If Buffer is NULL, then ASSERT().
3343 If Buffer is not aligned on a 64-bit boundary, then ASSERT().
3344 If Length is not aligned on a 64-bit boundary, then ASSERT().
3345 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
3347 @param Buffer Pointer to the buffer to carry out the checksum operation.
3348 @param Length The size, in bytes, of Buffer.
3350 @return Checksum The 2's complement checksum of Buffer.
3355 CalculateCheckSum64 (
3356 IN CONST UINT64
*Buffer
,
3362 /// Base Library CPU Functions
3366 (EFIAPI
*SWITCH_STACK_ENTRY_POINT
)(
3367 IN VOID
*Context1
, OPTIONAL
3368 IN VOID
*Context2 OPTIONAL
3373 Used to serialize load and store operations.
3375 All loads and stores that proceed calls to this function are guaranteed to be
3376 globally visible when this function returns.
3387 Saves the current CPU context that can be restored with a call to LongJump()
3390 Saves the current CPU context in the buffer specified by JumpBuffer and
3391 returns 0. The initial call to SetJump() must always return 0. Subsequent
3392 calls to LongJump() cause a non-zero value to be returned by SetJump().
3394 If JumpBuffer is NULL, then ASSERT().
3395 For IPF CPUs, if JumpBuffer is not aligned on a 16-byte boundary, then ASSERT().
3397 NOTE: The structure BASE_LIBRARY_JUMP_BUFFER is CPU architecture specific.
3398 The same structure must never be used for more than one CPU architecture context.
3399 For example, a BASE_LIBRARY_JUMP_BUFFER allocated by an IA-32 module must never be used from an x64 module.
3400 SetJump()/LongJump() is not currently supported for the EBC processor type.
3402 @param JumpBuffer A pointer to CPU context buffer.
3404 @retval 0 Indicates a return from SetJump().
3410 OUT BASE_LIBRARY_JUMP_BUFFER
*JumpBuffer
3415 Restores the CPU context that was saved with SetJump().
3417 Restores the CPU context from the buffer specified by JumpBuffer. This
3418 function never returns to the caller. Instead is resumes execution based on
3419 the state of JumpBuffer.
3421 If JumpBuffer is NULL, then ASSERT().
3422 For IPF CPUs, if JumpBuffer is not aligned on a 16-byte boundary, then ASSERT().
3423 If Value is 0, then ASSERT().
3425 @param JumpBuffer A pointer to CPU context buffer.
3426 @param Value The value to return when the SetJump() context is
3427 restored and must be non-zero.
3433 IN BASE_LIBRARY_JUMP_BUFFER
*JumpBuffer
,
3439 Enables CPU interrupts.
3450 Disables CPU interrupts.
3461 Disables CPU interrupts and returns the interrupt state prior to the disable
3464 @retval TRUE CPU interrupts were enabled on entry to this call.
3465 @retval FALSE CPU interrupts were disabled on entry to this call.
3470 SaveAndDisableInterrupts (
3476 Enables CPU interrupts for the smallest window required to capture any
3482 EnableDisableInterrupts (
3488 Retrieves the current CPU interrupt state.
3490 Returns TRUE is interrupts are currently enabled. Otherwise
3493 @retval TRUE CPU interrupts are enabled.
3494 @retval FALSE CPU interrupts are disabled.
3505 Set the current CPU interrupt state.
3507 Sets the current CPU interrupt state to the state specified by
3508 InterruptState. If InterruptState is TRUE, then interrupts are enabled. If
3509 InterruptState is FALSE, then interrupts are disabled. InterruptState is
3512 @param InterruptState TRUE if interrupts should enabled. FALSE if
3513 interrupts should be disabled.
3515 @return InterruptState
3521 IN BOOLEAN InterruptState
3526 Requests CPU to pause for a short period of time.
3528 Requests CPU to pause for a short period of time. Typically used in MP
3529 systems to prevent memory starvation while waiting for a spin lock.
3540 Transfers control to a function starting with a new stack.
3542 Transfers control to the function specified by EntryPoint using the
3543 new stack specified by NewStack and passing in the parameters specified
3544 by Context1 and Context2. Context1 and Context2 are optional and may
3545 be NULL. The function EntryPoint must never return. This function
3546 supports a variable number of arguments following the NewStack parameter.
3547 These additional arguments are ignored on IA-32, x64, and EBC.
3548 IPF CPUs expect one additional parameter of type VOID * that specifies
3549 the new backing store pointer.
3551 If EntryPoint is NULL, then ASSERT().
3552 If NewStack is NULL, then ASSERT().
3554 @param EntryPoint A pointer to function to call with the new stack.
3555 @param Context1 A pointer to the context to pass into the EntryPoint
3557 @param Context2 A pointer to the context to pass into the EntryPoint
3559 @param NewStack A pointer to the new stack to use for the EntryPoint
3561 @param ... This variable argument list is ignored for IA32, x64, and EBC.
3562 For IPF, this variable argument list is expected to contain
3563 a single parameter of type VOID * that specifies the new backing
3571 IN SWITCH_STACK_ENTRY_POINT EntryPoint
,
3572 IN VOID
*Context1
, OPTIONAL
3573 IN VOID
*Context2
, OPTIONAL
3580 Generates a breakpoint on the CPU.
3582 Generates a breakpoint on the CPU. The breakpoint must be implemented such
3583 that code can resume normal execution after the breakpoint.
3594 Executes an infinite loop.
3596 Forces the CPU to execute an infinite loop. A debugger may be used to skip
3597 past the loop and the code that follows the loop must execute properly. This
3598 implies that the infinite loop must not cause the code that follow it to be
3608 #if defined (MDE_CPU_IPF)
3611 Flush a range of cache lines in the cache coherency domain of the calling
3614 Invalidates the cache lines specified by Address and Length. If Address is
3615 not aligned on a cache line boundary, then entire cache line containing
3616 Address is invalidated. If Address + Length is not aligned on a cache line
3617 boundary, then the entire instruction cache line containing Address + Length
3618 -1 is invalidated. This function may choose to invalidate the entire
3619 instruction cache if that is more efficient than invalidating the specified
3620 range. If Length is 0, the no instruction cache lines are invalidated.
3621 Address is returned.
3623 If Length is greater than (MAX_ADDRESS - Address + 1), then ASSERT().
3625 @param Address The base address of the instruction lines to invalidate. If
3626 the CPU is in a physical addressing mode, then Address is a
3627 physical address. If the CPU is in a virtual addressing mode,
3628 then Address is a virtual address.
3630 @param Length The number of bytes to invalidate from the instruction cache.
3637 IpfFlushCacheRange (
3644 Executes a FC instruction
3645 Executes a FC instruction on the cache line specified by Address.
3646 The cache line size affected is at least 32-bytes (aligned on a 32-byte boundary).
3647 An implementation may flush a larger region. This function is only available on IPF.
3649 @param Address The Address of cache line to be flushed.
3651 @return The address of FC instruction executed.
3662 Executes a FC.I instruction.
3663 Executes a FC.I instruction on the cache line specified by Address.
3664 The cache line size affected is at least 32-bytes (aligned on a 32-byte boundary).
3665 An implementation may flush a larger region. This function is only available on IPF.
3667 @param Address The Address of cache line to be flushed.
3669 @return The address of FC.I instruction executed.
3680 Reads the current value of a Processor Identifier Register (CPUID).
3682 Reads and returns the current value of Processor Identifier Register specified by Index.
3683 The Index of largest implemented CPUID (One less than the number of implemented CPUID
3684 registers) is determined by CPUID [3] bits {7:0}.
3685 No parameter checking is performed on Index. If the Index value is beyond the
3686 implemented CPUID register range, a Reserved Register/Field fault may occur. The caller
3687 must either guarantee that Index is valid, or the caller must set up fault handlers to
3688 catch the faults. This function is only available on IPF.
3690 @param Index The 8-bit Processor Identifier Register index to read.
3692 @return The current value of Processor Identifier Register specified by Index.
3703 Reads the current value of 64-bit Processor Status Register (PSR).
3704 This function is only available on IPF.
3706 @return The current value of PSR.
3717 Writes the current value of 64-bit Processor Status Register (PSR).
3719 No parameter checking is performed on Value. All bits of Value corresponding to
3720 reserved fields of PSR must be 0 or a Reserved Register/Field fault may occur.
3721 The caller must either guarantee that Value is valid, or the caller must set up
3722 fault handlers to catch the faults. This function is only available on IPF.
3724 @param Value The 64-bit value to write to PSR.
3726 @return The 64-bit value written to the PSR.
3737 Reads the current value of 64-bit Kernel Register #0 (KR0).
3738 This function is only available on IPF.
3740 @return The current value of KR0.
3751 Reads the current value of 64-bit Kernel Register #1 (KR1).
3752 This function is only available on IPF.
3754 @return The current value of KR1.
3765 Reads the current value of 64-bit Kernel Register #2 (KR2).
3766 This function is only available on IPF.
3768 @return The current value of KR2.
3779 Reads the current value of 64-bit Kernel Register #3 (KR3).
3780 This function is only available on IPF.
3782 @return The current value of KR3.
3793 Reads the current value of 64-bit Kernel Register #4 (KR4).
3794 This function is only available on IPF.
3796 @return The current value of KR4.
3807 Reads the current value of 64-bit Kernel Register #5 (KR5).
3808 This function is only available on IPF.
3810 @return The current value of KR5.
3821 Reads the current value of 64-bit Kernel Register #6 (KR6).
3822 This function is only available on IPF.
3824 @return The current value of KR6.
3835 Reads the current value of 64-bit Kernel Register #7 (KR7).
3836 This function is only available on IPF.
3838 @return The current value of KR7.
3849 Write the current value of 64-bit Kernel Register #0 (KR0).
3850 This function is only available on IPF.
3852 @param Value The 64-bit value to write to KR0.
3854 @return The 64-bit value written to the KR0.
3865 Write the current value of 64-bit Kernel Register #1 (KR1).
3866 This function is only available on IPF.
3868 @param Value The 64-bit value to write to KR1.
3870 @return The 64-bit value written to the KR1.
3881 Write the current value of 64-bit Kernel Register #2 (KR2).
3882 This function is only available on IPF.
3884 @param Value The 64-bit value to write to KR2.
3886 @return The 64-bit value written to the KR2.
3897 Write the current value of 64-bit Kernel Register #3 (KR3).
3898 This function is only available on IPF.
3900 @param Value The 64-bit value to write to KR3.
3902 @return The 64-bit value written to the KR3.
3913 Write the current value of 64-bit Kernel Register #4 (KR4).
3914 This function is only available on IPF.
3916 @param Value The 64-bit value to write to KR4.
3918 @return The 64-bit value written to the KR4.
3929 Write the current value of 64-bit Kernel Register #5 (KR5).
3930 This function is only available on IPF.
3932 @param Value The 64-bit value to write to KR5.
3934 @return The 64-bit value written to the KR5.
3945 Write the current value of 64-bit Kernel Register #6 (KR6).
3946 This function is only available on IPF.
3948 @param Value The 64-bit value to write to KR6.
3950 @return The 64-bit value written to the KR6.
3961 Write the current value of 64-bit Kernel Register #7 (KR7).
3962 This function is only available on IPF.
3964 @param Value The 64-bit value to write to KR7.
3966 @return The 64-bit value written to the KR7.
3977 Reads the current value of Interval Timer Counter Register (ITC).
3978 This function is only available on IPF.
3980 @return The current value of ITC.
3991 Reads the current value of Interval Timer Vector Register (ITV).
3992 This function is only available on IPF.
3994 @return The current value of ITV.
4005 Reads the current value of Interval Timer Match Register (ITM).
4006 This function is only available on IPF.
4008 @return The current value of ITM.
4018 Writes the current value of 64-bit Interval Timer Counter Register (ITC).
4019 This function is only available on IPF.
4021 @param Value The 64-bit value to write to ITC.
4023 @return The 64-bit value written to the ITC.
4034 Writes the current value of 64-bit Interval Timer Match Register (ITM).
4035 This function is only available on IPF.
4037 @param Value The 64-bit value to write to ITM.
4039 @return The 64-bit value written to the ITM.
4050 Writes the current value of 64-bit Interval Timer Vector Register (ITV).
4051 No parameter checking is performed on Value. All bits of Value corresponding to
4052 reserved fields of ITV must be 0 or a Reserved Register/Field fault may occur.
4053 The caller must either guarantee that Value is valid, or the caller must set up
4054 fault handlers to catch the faults.
4055 This function is only available on IPF.
4057 @param Value The 64-bit value to write to ITV.
4059 @return The 64-bit value written to the ITV.
4070 Reads the current value of Default Control Register (DCR).
4071 This function is only available on IPF.
4073 @return The current value of DCR.
4084 Reads the current value of Interruption Vector Address Register (IVA).
4085 This function is only available on IPF.
4087 @return The current value of IVA.
4097 Reads the current value of Page Table Address Register (PTA).
4098 This function is only available on IPF.
4100 @return The current value of PTA.
4111 Writes the current value of 64-bit Default Control Register (DCR).
4112 No parameter checking is performed on Value. All bits of Value corresponding to
4113 reserved fields of DCR must be 0 or a Reserved Register/Field fault may occur.
4114 The caller must either guarantee that Value is valid, or the caller must set up
4115 fault handlers to catch the faults.
4116 This function is only available on IPF.
4118 @param Value The 64-bit value to write to DCR.
4120 @return The 64-bit value written to the DCR.
4131 Writes the current value of 64-bit Interruption Vector Address Register (IVA).
4132 The size of vector table is 32 K bytes and is 32 K bytes aligned
4133 the low 15 bits of Value is ignored when written.
4134 This function is only available on IPF.
4136 @param Value The 64-bit value to write to IVA.
4138 @return The 64-bit value written to the IVA.
4149 Writes the current value of 64-bit Page Table Address Register (PTA).
4150 No parameter checking is performed on Value. All bits of Value corresponding to
4151 reserved fields of DCR must be 0 or a Reserved Register/Field fault may occur.
4152 The caller must either guarantee that Value is valid, or the caller must set up
4153 fault handlers to catch the faults.
4154 This function is only available on IPF.
4156 @param Value The 64-bit value to write to PTA.
4158 @return The 64-bit value written to the PTA.
4168 Reads the current value of Local Interrupt ID Register (LID).
4169 This function is only available on IPF.
4171 @return The current value of LID.
4182 Reads the current value of External Interrupt Vector Register (IVR).
4183 This function is only available on IPF.
4185 @return The current value of IVR.
4196 Reads the current value of Task Priority Register (TPR).
4197 This function is only available on IPF.
4199 @return The current value of TPR.
4210 Reads the current value of External Interrupt Request Register #0 (IRR0).
4211 This function is only available on IPF.
4213 @return The current value of IRR0.
4224 Reads the current value of External Interrupt Request Register #1 (IRR1).
4225 This function is only available on IPF.
4227 @return The current value of IRR1.
4238 Reads the current value of External Interrupt Request Register #2 (IRR2).
4239 This function is only available on IPF.
4241 @return The current value of IRR2.
4252 Reads the current value of External Interrupt Request Register #3 (IRR3).
4253 This function is only available on IPF.
4255 @return The current value of IRR3.
4266 Reads the current value of Performance Monitor Vector Register (PMV).
4267 This function is only available on IPF.
4269 @return The current value of PMV.
4280 Reads the current value of Corrected Machine Check Vector Register (CMCV).
4281 This function is only available on IPF.
4283 @return The current value of CMCV.
4294 Reads the current value of Local Redirection Register #0 (LRR0).
4295 This function is only available on IPF.
4297 @return The current value of LRR0.
4308 Reads the current value of Local Redirection Register #1 (LRR1).
4309 This function is only available on IPF.
4311 @return The current value of LRR1.
4322 Writes the current value of 64-bit Page Local Interrupt ID Register (LID).
4323 No parameter checking is performed on Value. All bits of Value corresponding to
4324 reserved fields of LID must be 0 or a Reserved Register/Field fault may occur.
4325 The caller must either guarantee that Value is valid, or the caller must set up
4326 fault handlers to catch the faults.
4327 This function is only available on IPF.
4329 @param Value The 64-bit value to write to LID.
4331 @return The 64-bit value written to the LID.
4342 Writes the current value of 64-bit Task Priority Register (TPR).
4343 No parameter checking is performed on Value. All bits of Value corresponding to
4344 reserved fields of TPR must be 0 or a Reserved Register/Field fault may occur.
4345 The caller must either guarantee that Value is valid, or the caller must set up
4346 fault handlers to catch the faults.
4347 This function is only available on IPF.
4349 @param Value The 64-bit value to write to TPR.
4351 @return The 64-bit value written to the TPR.
4362 Performs a write operation on End OF External Interrupt Register (EOI).
4363 Writes a value of 0 to the EOI Register. This function is only available on IPF.
4374 Writes the current value of 64-bit Performance Monitor Vector Register (PMV).
4375 No parameter checking is performed on Value. All bits of Value corresponding
4376 to reserved fields of PMV must be 0 or a Reserved Register/Field fault may occur.
4377 The caller must either guarantee that Value is valid, or the caller must set up
4378 fault handlers to catch the faults.
4379 This function is only available on IPF.
4381 @param Value The 64-bit value to write to PMV.
4383 @return The 64-bit value written to the PMV.
4394 Writes the current value of 64-bit Corrected Machine Check Vector Register (CMCV).
4395 No parameter checking is performed on Value. All bits of Value corresponding
4396 to reserved fields of CMCV must be 0 or a Reserved Register/Field fault may occur.
4397 The caller must either guarantee that Value is valid, or the caller must set up
4398 fault handlers to catch the faults.
4399 This function is only available on IPF.
4401 @param Value The 64-bit value to write to CMCV.
4403 @return The 64-bit value written to the CMCV.
4414 Writes the current value of 64-bit Local Redirection Register #0 (LRR0).
4415 No parameter checking is performed on Value. All bits of Value corresponding
4416 to reserved fields of LRR0 must be 0 or a Reserved Register/Field fault may occur.
4417 The caller must either guarantee that Value is valid, or the caller must set up
4418 fault handlers to catch the faults.
4419 This function is only available on IPF.
4421 @param Value The 64-bit value to write to LRR0.
4423 @return The 64-bit value written to the LRR0.
4434 Writes the current value of 64-bit Local Redirection Register #1 (LRR1).
4435 No parameter checking is performed on Value. All bits of Value corresponding
4436 to reserved fields of LRR1 must be 0 or a Reserved Register/Field fault may occur.
4437 The caller must either guarantee that Value is valid, or the caller must
4438 set up fault handlers to catch the faults.
4439 This function is only available on IPF.
4441 @param Value The 64-bit value to write to LRR1.
4443 @return The 64-bit value written to the LRR1.
4454 Reads the current value of Instruction Breakpoint Register (IBR).
4456 The Instruction Breakpoint Registers are used in pairs. The even numbered
4457 registers contain breakpoint addresses, and the odd numbered registers contain
4458 breakpoint mask conditions. At least 4 instruction registers pairs are implemented
4459 on all processor models. Implemented registers are contiguous starting with
4460 register 0. No parameter checking is performed on Index, and if the Index value
4461 is beyond the implemented IBR register range, a Reserved Register/Field fault may
4462 occur. The caller must either guarantee that Index is valid, or the caller must
4463 set up fault handlers to catch the faults.
4464 This function is only available on IPF.
4466 @param Index The 8-bit Instruction Breakpoint Register index to read.
4468 @return The current value of Instruction Breakpoint Register specified by Index.
4479 Reads the current value of Data Breakpoint Register (DBR).
4481 The Data Breakpoint Registers are used in pairs. The even numbered registers
4482 contain breakpoint addresses, and odd numbered registers contain breakpoint
4483 mask conditions. At least 4 data registers pairs are implemented on all processor
4484 models. Implemented registers are contiguous starting with register 0.
4485 No parameter checking is performed on Index. If the Index value is beyond
4486 the implemented DBR register range, a Reserved Register/Field fault may occur.
4487 The caller must either guarantee that Index is valid, or the caller must set up
4488 fault handlers to catch the faults.
4489 This function is only available on IPF.
4491 @param Index The 8-bit Data Breakpoint Register index to read.
4493 @return The current value of Data Breakpoint Register specified by Index.
4504 Reads the current value of Performance Monitor Configuration Register (PMC).
4506 All processor implementations provide at least 4 performance counters
4507 (PMC/PMD [4]...PMC/PMD [7] pairs), and 4 performance monitor counter overflow
4508 status registers (PMC [0]... PMC [3]). Processor implementations may provide
4509 additional implementation-dependent PMC and PMD to increase the number of
4510 'generic' performance counters (PMC/PMD pairs). The remainder of PMC and PMD
4511 register set is implementation dependent. No parameter checking is performed
4512 on Index. If the Index value is beyond the implemented PMC register range,
4513 zero value will be returned.
4514 This function is only available on IPF.
4516 @param Index The 8-bit Performance Monitor Configuration Register index to read.
4518 @return The current value of Performance Monitor Configuration Register
4530 Reads the current value of Performance Monitor Data Register (PMD).
4532 All processor implementations provide at least 4 performance counters
4533 (PMC/PMD [4]...PMC/PMD [7] pairs), and 4 performance monitor counter
4534 overflow status registers (PMC [0]... PMC [3]). Processor implementations may
4535 provide additional implementation-dependent PMC and PMD to increase the number
4536 of 'generic' performance counters (PMC/PMD pairs). The remainder of PMC and PMD
4537 register set is implementation dependent. No parameter checking is performed
4538 on Index. If the Index value is beyond the implemented PMD register range,
4539 zero value will be returned.
4540 This function is only available on IPF.
4542 @param Index The 8-bit Performance Monitor Data Register index to read.
4544 @return The current value of Performance Monitor Data Register specified by Index.
4555 Writes the current value of 64-bit Instruction Breakpoint Register (IBR).
4557 Writes current value of Instruction Breakpoint Register specified by Index.
4558 The Instruction Breakpoint Registers are used in pairs. The even numbered
4559 registers contain breakpoint addresses, and odd numbered registers contain
4560 breakpoint mask conditions. At least 4 instruction registers pairs are implemented
4561 on all processor models. Implemented registers are contiguous starting with
4562 register 0. No parameter checking is performed on Index. If the Index value
4563 is beyond the implemented IBR register range, a Reserved Register/Field fault may
4564 occur. The caller must either guarantee that Index is valid, or the caller must
4565 set up fault handlers to catch the faults.
4566 This function is only available on IPF.
4568 @param Index The 8-bit Instruction Breakpoint Register index to write.
4569 @param Value The 64-bit value to write to IBR.
4571 @return The 64-bit value written to the IBR.
4583 Writes the current value of 64-bit Data Breakpoint Register (DBR).
4585 Writes current value of Data Breakpoint Register specified by Index.
4586 The Data Breakpoint Registers are used in pairs. The even numbered registers
4587 contain breakpoint addresses, and odd numbered registers contain breakpoint
4588 mask conditions. At least 4 data registers pairs are implemented on all processor
4589 models. Implemented registers are contiguous starting with register 0. No parameter
4590 checking is performed on Index. If the Index value is beyond the implemented
4591 DBR register range, a Reserved Register/Field fault may occur. The caller must
4592 either guarantee that Index is valid, or the caller must set up fault handlers to
4594 This function is only available on IPF.
4596 @param Index The 8-bit Data Breakpoint Register index to write.
4597 @param Value The 64-bit value to write to DBR.
4599 @return The 64-bit value written to the DBR.
4611 Writes the current value of 64-bit Performance Monitor Configuration Register (PMC).
4613 Writes current value of Performance Monitor Configuration Register specified by Index.
4614 All processor implementations provide at least 4 performance counters
4615 (PMC/PMD [4]...PMC/PMD [7] pairs), and 4 performance monitor counter overflow status
4616 registers (PMC [0]... PMC [3]). Processor implementations may provide additional
4617 implementation-dependent PMC and PMD to increase the number of 'generic' performance
4618 counters (PMC/PMD pairs). The remainder of PMC and PMD register set is implementation
4619 dependent. No parameter checking is performed on Index. If the Index value is
4620 beyond the implemented PMC register range, the write is ignored.
4621 This function is only available on IPF.
4623 @param Index The 8-bit Performance Monitor Configuration Register index to write.
4624 @param Value The 64-bit value to write to PMC.
4626 @return The 64-bit value written to the PMC.
4638 Writes the current value of 64-bit Performance Monitor Data Register (PMD).
4640 Writes current value of Performance Monitor Data Register specified by Index.
4641 All processor implementations provide at least 4 performance counters
4642 (PMC/PMD [4]...PMC/PMD [7] pairs), and 4 performance monitor counter overflow
4643 status registers (PMC [0]... PMC [3]). Processor implementations may provide
4644 additional implementation-dependent PMC and PMD to increase the number of 'generic'
4645 performance counters (PMC/PMD pairs). The remainder of PMC and PMD register set
4646 is implementation dependent. No parameter checking is performed on Index. If the
4647 Index value is beyond the implemented PMD register range, the write is ignored.
4648 This function is only available on IPF.
4650 @param Index The 8-bit Performance Monitor Data Register index to write.
4651 @param Value The 64-bit value to write to PMD.
4653 @return The 64-bit value written to the PMD.
4665 Reads the current value of 64-bit Global Pointer (GP).
4667 Reads and returns the current value of GP.
4668 This function is only available on IPF.
4670 @return The current value of GP.
4681 Write the current value of 64-bit Global Pointer (GP).
4683 Writes the current value of GP. The 64-bit value written to the GP is returned.
4684 No parameter checking is performed on Value.
4685 This function is only available on IPF.
4687 @param Value The 64-bit value to write to GP.
4689 @return The 64-bit value written to the GP.
4700 Reads the current value of 64-bit Stack Pointer (SP).
4702 Reads and returns the current value of SP.
4703 This function is only available on IPF.
4705 @return The current value of SP.
4716 /// Valid Index value for AsmReadControlRegister()
4718 #define IPF_CONTROL_REGISTER_DCR 0
4719 #define IPF_CONTROL_REGISTER_ITM 1
4720 #define IPF_CONTROL_REGISTER_IVA 2
4721 #define IPF_CONTROL_REGISTER_PTA 8
4722 #define IPF_CONTROL_REGISTER_IPSR 16
4723 #define IPF_CONTROL_REGISTER_ISR 17
4724 #define IPF_CONTROL_REGISTER_IIP 19
4725 #define IPF_CONTROL_REGISTER_IFA 20
4726 #define IPF_CONTROL_REGISTER_ITIR 21
4727 #define IPF_CONTROL_REGISTER_IIPA 22
4728 #define IPF_CONTROL_REGISTER_IFS 23
4729 #define IPF_CONTROL_REGISTER_IIM 24
4730 #define IPF_CONTROL_REGISTER_IHA 25
4731 #define IPF_CONTROL_REGISTER_LID 64
4732 #define IPF_CONTROL_REGISTER_IVR 65
4733 #define IPF_CONTROL_REGISTER_TPR 66
4734 #define IPF_CONTROL_REGISTER_EOI 67
4735 #define IPF_CONTROL_REGISTER_IRR0 68
4736 #define IPF_CONTROL_REGISTER_IRR1 69
4737 #define IPF_CONTROL_REGISTER_IRR2 70
4738 #define IPF_CONTROL_REGISTER_IRR3 71
4739 #define IPF_CONTROL_REGISTER_ITV 72
4740 #define IPF_CONTROL_REGISTER_PMV 73
4741 #define IPF_CONTROL_REGISTER_CMCV 74
4742 #define IPF_CONTROL_REGISTER_LRR0 80
4743 #define IPF_CONTROL_REGISTER_LRR1 81
4746 Reads a 64-bit control register.
4748 Reads and returns the control register specified by Index. The valid Index valued are defined
4749 above in "Related Definitions".
4750 If Index is invalid then 0xFFFFFFFFFFFFFFFF is returned. This function is only available on IPF.
4752 @param Index The index of the control register to read.
4754 @return The control register specified by Index.
4759 AsmReadControlRegister (
4765 /// Valid Index value for AsmReadApplicationRegister()
4767 #define IPF_APPLICATION_REGISTER_K0 0
4768 #define IPF_APPLICATION_REGISTER_K1 1
4769 #define IPF_APPLICATION_REGISTER_K2 2
4770 #define IPF_APPLICATION_REGISTER_K3 3
4771 #define IPF_APPLICATION_REGISTER_K4 4
4772 #define IPF_APPLICATION_REGISTER_K5 5
4773 #define IPF_APPLICATION_REGISTER_K6 6
4774 #define IPF_APPLICATION_REGISTER_K7 7
4775 #define IPF_APPLICATION_REGISTER_RSC 16
4776 #define IPF_APPLICATION_REGISTER_BSP 17
4777 #define IPF_APPLICATION_REGISTER_BSPSTORE 18
4778 #define IPF_APPLICATION_REGISTER_RNAT 19
4779 #define IPF_APPLICATION_REGISTER_FCR 21
4780 #define IPF_APPLICATION_REGISTER_EFLAG 24
4781 #define IPF_APPLICATION_REGISTER_CSD 25
4782 #define IPF_APPLICATION_REGISTER_SSD 26
4783 #define IPF_APPLICATION_REGISTER_CFLG 27
4784 #define IPF_APPLICATION_REGISTER_FSR 28
4785 #define IPF_APPLICATION_REGISTER_FIR 29
4786 #define IPF_APPLICATION_REGISTER_FDR 30
4787 #define IPF_APPLICATION_REGISTER_CCV 32
4788 #define IPF_APPLICATION_REGISTER_UNAT 36
4789 #define IPF_APPLICATION_REGISTER_FPSR 40
4790 #define IPF_APPLICATION_REGISTER_ITC 44
4791 #define IPF_APPLICATION_REGISTER_PFS 64
4792 #define IPF_APPLICATION_REGISTER_LC 65
4793 #define IPF_APPLICATION_REGISTER_EC 66
4796 Reads a 64-bit application register.
4798 Reads and returns the application register specified by Index. The valid Index valued are defined
4799 above in "Related Definitions".
4800 If Index is invalid then 0xFFFFFFFFFFFFFFFF is returned. This function is only available on IPF.
4802 @param Index The index of the application register to read.
4804 @return The application register specified by Index.
4809 AsmReadApplicationRegister (
4815 Determines if the CPU is currently executing in virtual, physical, or mixed mode.
4817 Determines the current execution mode of the CPU.
4818 If the CPU is in virtual mode(PSR.RT=1, PSR.DT=1, PSR.IT=1), then 1 is returned.
4819 If the CPU is in physical mode(PSR.RT=0, PSR.DT=0, PSR.IT=0), then 0 is returned.
4820 If the CPU is not in physical mode or virtual mode, then it is in mixed mode,
4822 This function is only available on IPF.
4824 @retval 1 The CPU is in virtual mode.
4825 @retval 0 The CPU is in physical mode.
4826 @retval -1 The CPU is in mixed mode.
4837 Makes a PAL procedure call.
4839 This is a wrapper function to make a PAL procedure call. Based on the Index
4840 value this API will make static or stacked PAL call. The following table
4841 describes the usage of PAL Procedure Index Assignment. Architected procedures
4842 may be designated as required or optional. If a PAL procedure is specified
4843 as optional, a unique return code of 0xFFFFFFFFFFFFFFFF is returned in the
4844 Status field of the PAL_CALL_RETURN structure.
4845 This indicates that the procedure is not present in this PAL implementation.
4846 It is the caller's responsibility to check for this return code after calling
4847 any optional PAL procedure.
4848 No parameter checking is performed on the 5 input parameters, but there are
4849 some common rules that the caller should follow when making a PAL call. Any
4850 address passed to PAL as buffers for return parameters must be 8-byte aligned.
4851 Unaligned addresses may cause undefined results. For those parameters defined
4852 as reserved or some fields defined as reserved must be zero filled or the invalid
4853 argument return value may be returned or undefined result may occur during the
4854 execution of the procedure. If the PalEntryPoint does not point to a valid
4855 PAL entry point then the system behavior is undefined. This function is only
4858 @param PalEntryPoint The PAL procedure calls entry point.
4859 @param Index The PAL procedure Index number.
4860 @param Arg2 The 2nd parameter for PAL procedure calls.
4861 @param Arg3 The 3rd parameter for PAL procedure calls.
4862 @param Arg4 The 4th parameter for PAL procedure calls.
4864 @return structure returned from the PAL Call procedure, including the status and return value.
4870 IN UINT64 PalEntryPoint
,
4878 #elif defined (MDE_CPU_IA32) || defined (MDE_CPU_X64)
4880 /// IA32 and X64 Specific Functions
4881 /// Byte packed structure for 16-bit Real Mode EFLAGS
4885 UINT32 CF
:1; /// Carry Flag
4886 UINT32 Reserved_0
:1; /// Reserved
4887 UINT32 PF
:1; /// Parity Flag
4888 UINT32 Reserved_1
:1; /// Reserved
4889 UINT32 AF
:1; /// Auxiliary Carry Flag
4890 UINT32 Reserved_2
:1; /// Reserved
4891 UINT32 ZF
:1; /// Zero Flag
4892 UINT32 SF
:1; /// Sign Flag
4893 UINT32 TF
:1; /// Trap Flag
4894 UINT32 IF
:1; /// Interrupt Enable Flag
4895 UINT32 DF
:1; /// Direction Flag
4896 UINT32 OF
:1; /// Overflow Flag
4897 UINT32 IOPL
:2; /// I/O Privilege Level
4898 UINT32 NT
:1; /// Nested Task
4899 UINT32 Reserved_3
:1; /// Reserved
4905 /// Byte packed structure for EFLAGS/RFLAGS
4906 /// 32-bits on IA-32
4907 /// 64-bits on X64. The upper 32-bits on X64 are reserved
4911 UINT32 CF
:1; /// Carry Flag
4912 UINT32 Reserved_0
:1; /// Reserved
4913 UINT32 PF
:1; /// Parity Flag
4914 UINT32 Reserved_1
:1; /// Reserved
4915 UINT32 AF
:1; /// Auxiliary Carry Flag
4916 UINT32 Reserved_2
:1; /// Reserved
4917 UINT32 ZF
:1; /// Zero Flag
4918 UINT32 SF
:1; /// Sign Flag
4919 UINT32 TF
:1; /// Trap Flag
4920 UINT32 IF
:1; /// Interrupt Enable Flag
4921 UINT32 DF
:1; /// Direction Flag
4922 UINT32 OF
:1; /// Overflow Flag
4923 UINT32 IOPL
:2; /// I/O Privilege Level
4924 UINT32 NT
:1; /// Nested Task
4925 UINT32 Reserved_3
:1; /// Reserved
4926 UINT32 RF
:1; /// Resume Flag
4927 UINT32 VM
:1; /// Virtual 8086 Mode
4928 UINT32 AC
:1; /// Alignment Check
4929 UINT32 VIF
:1; /// Virtual Interrupt Flag
4930 UINT32 VIP
:1; /// Virtual Interrupt Pending
4931 UINT32 ID
:1; /// ID Flag
4932 UINT32 Reserved_4
:10; /// Reserved
4938 /// Byte packed structure for Control Register 0 (CR0)
4939 /// 32-bits on IA-32
4940 /// 64-bits on X64. The upper 32-bits on X64 are reserved
4944 UINT32 PE
:1; /// Protection Enable
4945 UINT32 MP
:1; /// Monitor Coprocessor
4946 UINT32 EM
:1; /// Emulation
4947 UINT32 TS
:1; /// Task Switched
4948 UINT32 ET
:1; /// Extension Type
4949 UINT32 NE
:1; /// Numeric Error
4950 UINT32 Reserved_0
:10; /// Reserved
4951 UINT32 WP
:1; /// Write Protect
4952 UINT32 Reserved_1
:1; /// Reserved
4953 UINT32 AM
:1; /// Alignment Mask
4954 UINT32 Reserved_2
:10; /// Reserved
4955 UINT32 NW
:1; /// Mot Write-through
4956 UINT32 CD
:1; /// Cache Disable
4957 UINT32 PG
:1; /// Paging
4963 /// Byte packed structure for Control Register 4 (CR4)
4964 /// 32-bits on IA-32
4965 /// 64-bits on X64. The upper 32-bits on X64 are reserved
4969 UINT32 VME
:1; /// Virtual-8086 Mode Extensions
4970 UINT32 PVI
:1; /// Protected-Mode Virtual Interrupts
4971 UINT32 TSD
:1; /// Time Stamp Disable
4972 UINT32 DE
:1; /// Debugging Extensions
4973 UINT32 PSE
:1; /// Page Size Extensions
4974 UINT32 PAE
:1; /// Physical Address Extension
4975 UINT32 MCE
:1; /// Machine Check Enable
4976 UINT32 PGE
:1; /// Page Global Enable
4977 UINT32 PCE
:1; /// Performance Monitoring Counter
4979 UINT32 OSFXSR
:1; /// Operating System Support for
4980 /// FXSAVE and FXRSTOR instructions
4981 UINT32 OSXMMEXCPT
:1; /// Operating System Support for
4982 /// Unmasked SIMD Floating Point
4984 UINT32 Reserved_0
:2; /// Reserved
4985 UINT32 VMXE
:1; /// VMX Enable
4986 UINT32 Reserved_1
:18; /// Reseved
4992 /// Byte packed structure for an IDTR, GDTR, LDTR descriptor
4993 /// @todo How to make this structure byte-packed in a compiler independent way?
5002 #define IA32_IDT_GATE_TYPE_TASK 0x85
5003 #define IA32_IDT_GATE_TYPE_INTERRUPT_16 0x86
5004 #define IA32_IDT_GATE_TYPE_TRAP_16 0x87
5005 #define IA32_IDT_GATE_TYPE_INTERRUPT_32 0x8E
5006 #define IA32_IDT_GATE_TYPE_TRAP_32 0x8F
5009 /// Byte packed structure for an Interrupt Gate Descriptor
5011 #if defined (MDE_CPU_IA32)
5015 UINT32 OffsetLow
:16; // Offset bits 15..0
5016 UINT32 Selector
:16; // Selector
5017 UINT32 Reserved_0
:8; // Reserved
5018 UINT32 GateType
:8; // Gate Type. See #defines above
5019 UINT32 OffsetHigh
:16; // Offset bits 31..16
5022 } IA32_IDT_GATE_DESCRIPTOR
;
5026 #if defined (MDE_CPU_X64)
5030 UINT32 OffsetLow
:16; // Offset bits 15..0
5031 UINT32 Selector
:16; // Selector
5032 UINT32 Reserved_0
:8; // Reserved
5033 UINT32 GateType
:8; // Gate Type. See #defines above
5034 UINT32 OffsetHigh
:16; // Offset bits 31..16
5035 UINT32 OffsetUpper
:32; // Offset bits 63..32
5036 UINT32 Reserved_1
:32; // Reserved
5040 } IA32_IDT_GATE_DESCRIPTOR
;
5045 /// Byte packed structure for an FP/SSE/SSE2 context
5052 /// Structures for the 16-bit real mode thunks
5105 IA32_EFLAGS32 EFLAGS
;
5115 } IA32_REGISTER_SET
;
5118 /// Byte packed structure for an 16-bit real mode thunks
5121 IA32_REGISTER_SET
*RealModeState
;
5122 VOID
*RealModeBuffer
;
5123 UINT32 RealModeBufferSize
;
5124 UINT32 ThunkAttributes
;
5127 #define THUNK_ATTRIBUTE_BIG_REAL_MODE 0x00000001
5128 #define THUNK_ATTRIBUTE_DISABLE_A20_MASK_INT_15 0x00000002
5129 #define THUNK_ATTRIBUTE_DISABLE_A20_MASK_KBD_CTRL 0x00000004
5132 Retrieves CPUID information.
5134 Executes the CPUID instruction with EAX set to the value specified by Index.
5135 This function always returns Index.
5136 If Eax is not NULL, then the value of EAX after CPUID is returned in Eax.
5137 If Ebx is not NULL, then the value of EBX after CPUID is returned in Ebx.
5138 If Ecx is not NULL, then the value of ECX after CPUID is returned in Ecx.
5139 If Edx is not NULL, then the value of EDX after CPUID is returned in Edx.
5140 This function is only available on IA-32 and X64.
5142 @param Index The 32-bit value to load into EAX prior to invoking the CPUID
5144 @param Eax Pointer to the 32-bit EAX value returned by the CPUID
5145 instruction. This is an optional parameter that may be NULL.
5146 @param Ebx Pointer to the 32-bit EBX value returned by the CPUID
5147 instruction. This is an optional parameter that may be NULL.
5148 @param Ecx Pointer to the 32-bit ECX value returned by the CPUID
5149 instruction. This is an optional parameter that may be NULL.
5150 @param Edx Pointer to the 32-bit EDX value returned by the CPUID
5151 instruction. This is an optional parameter that may be NULL.
5160 OUT UINT32
*Eax
, OPTIONAL
5161 OUT UINT32
*Ebx
, OPTIONAL
5162 OUT UINT32
*Ecx
, OPTIONAL
5163 OUT UINT32
*Edx OPTIONAL
5168 Retrieves CPUID information using an extended leaf identifier.
5170 Executes the CPUID instruction with EAX set to the value specified by Index
5171 and ECX set to the value specified by SubIndex. This function always returns
5172 Index. This function is only available on IA-32 and x64.
5174 If Eax is not NULL, then the value of EAX after CPUID is returned in Eax.
5175 If Ebx is not NULL, then the value of EBX after CPUID is returned in Ebx.
5176 If Ecx is not NULL, then the value of ECX after CPUID is returned in Ecx.
5177 If Edx is not NULL, then the value of EDX after CPUID is returned in Edx.
5179 @param Index The 32-bit value to load into EAX prior to invoking the
5181 @param SubIndex The 32-bit value to load into ECX prior to invoking the
5183 @param Eax Pointer to the 32-bit EAX value returned by the CPUID
5184 instruction. This is an optional parameter that may be
5186 @param Ebx Pointer to the 32-bit EBX value returned by the CPUID
5187 instruction. This is an optional parameter that may be
5189 @param Ecx Pointer to the 32-bit ECX value returned by the CPUID
5190 instruction. This is an optional parameter that may be
5192 @param Edx Pointer to the 32-bit EDX value returned by the CPUID
5193 instruction. This is an optional parameter that may be
5204 OUT UINT32
*Eax
, OPTIONAL
5205 OUT UINT32
*Ebx
, OPTIONAL
5206 OUT UINT32
*Ecx
, OPTIONAL
5207 OUT UINT32
*Edx OPTIONAL
5212 Returns the lower 32-bits of a Machine Specific Register(MSR).
5214 Reads and returns the lower 32-bits of the MSR specified by Index.
5215 No parameter checking is performed on Index, and some Index values may cause
5216 CPU exceptions. The caller must either guarantee that Index is valid, or the
5217 caller must set up exception handlers to catch the exceptions. This function
5218 is only available on IA-32 and X64.
5220 @param Index The 32-bit MSR index to read.
5222 @return The lower 32 bits of the MSR identified by Index.
5233 Writes a 32-bit value to a Machine Specific Register(MSR), and returns the value.
5234 The upper 32-bits of the MSR are set to zero.
5236 Writes the 32-bit value specified by Value to the MSR specified by Index. The
5237 upper 32-bits of the MSR write are set to zero. The 32-bit value written to
5238 the MSR is returned. No parameter checking is performed on Index or Value,
5239 and some of these may cause CPU exceptions. The caller must either guarantee
5240 that Index and Value are valid, or the caller must establish proper exception
5241 handlers. This function is only available on IA-32 and X64.
5243 @param Index The 32-bit MSR index to write.
5244 @param Value The 32-bit value to write to the MSR.
5258 Reads a 64-bit MSR, performs a bitwise inclusive OR on the lower 32-bits, and
5259 writes the result back to the 64-bit MSR.
5261 Reads the 64-bit MSR specified by Index, performs a bitwise inclusive OR
5262 between the lower 32-bits of the read result and the value specified by
5263 OrData, and writes the result to the 64-bit MSR specified by Index. The lower
5264 32-bits of the value written to the MSR is returned. No parameter checking is
5265 performed on Index or OrData, and some of these may cause CPU exceptions. The
5266 caller must either guarantee that Index and OrData are valid, or the caller
5267 must establish proper exception handlers. This function is only available on
5270 @param Index The 32-bit MSR index to write.
5271 @param OrData The value to OR with the read value from the MSR.
5273 @return The lower 32-bit value written to the MSR.
5285 Reads a 64-bit MSR, performs a bitwise AND on the lower 32-bits, and writes
5286 the result back to the 64-bit MSR.
5288 Reads the 64-bit MSR specified by Index, performs a bitwise AND between the
5289 lower 32-bits of the read result and the value specified by AndData, and
5290 writes the result to the 64-bit MSR specified by Index. The lower 32-bits of
5291 the value written to the MSR is returned. No parameter checking is performed
5292 on Index or AndData, and some of these may cause CPU exceptions. The caller
5293 must either guarantee that Index and AndData are valid, or the caller must
5294 establish proper exception handlers. This function is only available on IA-32
5297 @param Index The 32-bit MSR index to write.
5298 @param AndData The value to AND with the read value from the MSR.
5300 @return The lower 32-bit value written to the MSR.
5312 Reads a 64-bit MSR, performs a bitwise AND followed by a bitwise inclusive OR
5313 on the lower 32-bits, and writes the result back to the 64-bit MSR.
5315 Reads the 64-bit MSR specified by Index, performs a bitwise AND between the
5316 lower 32-bits of the read result and the value specified by AndData
5317 preserving the upper 32-bits, performs a bitwise inclusive OR between the
5318 result of the AND operation and the value specified by OrData, and writes the
5319 result to the 64-bit MSR specified by Address. The lower 32-bits of the value
5320 written to the MSR is returned. No parameter checking is performed on Index,
5321 AndData, or OrData, and some of these may cause CPU exceptions. The caller
5322 must either guarantee that Index, AndData, and OrData are valid, or the
5323 caller must establish proper exception handlers. This function is only
5324 available on IA-32 and X64.
5326 @param Index The 32-bit MSR index to write.
5327 @param AndData The value to AND with the read value from the MSR.
5328 @param OrData The value to OR with the result of the AND operation.
5330 @return The lower 32-bit value written to the MSR.
5343 Reads a bit field of an MSR.
5345 Reads the bit field in the lower 32-bits of a 64-bit MSR. The bit field is
5346 specified by the StartBit and the EndBit. The value of the bit field is
5347 returned. The caller must either guarantee that Index is valid, or the caller
5348 must set up exception handlers to catch the exceptions. This function is only
5349 available on IA-32 and X64.
5351 If StartBit is greater than 31, then ASSERT().
5352 If EndBit is greater than 31, then ASSERT().
5353 If EndBit is less than StartBit, then ASSERT().
5355 @param Index The 32-bit MSR index to read.
5356 @param StartBit The ordinal of the least significant bit in the bit field.
5358 @param EndBit The ordinal of the most significant bit in the bit field.
5361 @return The bit field read from the MSR.
5366 AsmMsrBitFieldRead32 (
5374 Writes a bit field to an MSR.
5376 Writes Value to a bit field in the lower 32-bits of a 64-bit MSR. The bit
5377 field is specified by the StartBit and the EndBit. All other bits in the
5378 destination MSR are preserved. The lower 32-bits of the MSR written is
5379 returned. Extra left bits in Value are stripped. The caller must either
5380 guarantee that Index and the data written is valid, or the caller must set up
5381 exception handlers to catch the exceptions. This function is only available
5384 If StartBit is greater than 31, then ASSERT().
5385 If EndBit is greater than 31, then ASSERT().
5386 If EndBit is less than StartBit, then ASSERT().
5388 @param Index The 32-bit MSR index to write.
5389 @param StartBit The ordinal of the least significant bit in the bit field.
5391 @param EndBit The ordinal of the most significant bit in the bit field.
5393 @param Value New value of the bit field.
5395 @return The lower 32-bit of the value written to the MSR.
5400 AsmMsrBitFieldWrite32 (
5409 Reads a bit field in a 64-bit MSR, performs a bitwise OR, and writes the
5410 result back to the bit field in the 64-bit MSR.
5412 Reads the 64-bit MSR specified by Index, performs a bitwise inclusive OR
5413 between the read result and the value specified by OrData, and writes the
5414 result to the 64-bit MSR specified by Index. The lower 32-bits of the value
5415 written to the MSR are returned. Extra left bits in OrData are stripped. The
5416 caller must either guarantee that Index and the data written is valid, or
5417 the caller must set up exception handlers to catch the exceptions. This
5418 function is only available on IA-32 and X64.
5420 If StartBit is greater than 31, then ASSERT().
5421 If EndBit is greater than 31, then ASSERT().
5422 If EndBit is less than StartBit, then ASSERT().
5424 @param Index The 32-bit MSR index to write.
5425 @param StartBit The ordinal of the least significant bit in the bit field.
5427 @param EndBit The ordinal of the most significant bit in the bit field.
5429 @param OrData The value to OR with the read value from the MSR.
5431 @return The lower 32-bit of the value written to the MSR.
5436 AsmMsrBitFieldOr32 (
5445 Reads a bit field in a 64-bit MSR, performs a bitwise AND, and writes the
5446 result back to the bit field in the 64-bit MSR.
5448 Reads the 64-bit MSR specified by Index, performs a bitwise AND between the
5449 read result and the value specified by AndData, and writes the result to the
5450 64-bit MSR specified by Index. The lower 32-bits of the value written to the
5451 MSR are returned. Extra left bits in AndData are stripped. The caller must
5452 either guarantee that Index and the data written is valid, or the caller must
5453 set up exception handlers to catch the exceptions. This function is only
5454 available on IA-32 and X64.
5456 If StartBit is greater than 31, then ASSERT().
5457 If EndBit is greater than 31, then ASSERT().
5458 If EndBit is less than StartBit, then ASSERT().
5460 @param Index The 32-bit MSR index to write.
5461 @param StartBit The ordinal of the least significant bit in the bit field.
5463 @param EndBit The ordinal of the most significant bit in the bit field.
5465 @param AndData The value to AND with the read value from the MSR.
5467 @return The lower 32-bit of the value written to the MSR.
5472 AsmMsrBitFieldAnd32 (
5481 Reads a bit field in a 64-bit MSR, performs a bitwise AND followed by a
5482 bitwise inclusive OR, and writes the result back to the bit field in the
5485 Reads the 64-bit MSR specified by Index, performs a bitwise AND followed by a
5486 bitwise inclusive OR between the read result and the value specified by
5487 AndData, and writes the result to the 64-bit MSR specified by Index. The
5488 lower 32-bits of the value written to the MSR are returned. Extra left bits
5489 in both AndData and OrData are stripped. The caller must either guarantee
5490 that Index and the data written is valid, or the caller must set up exception
5491 handlers to catch the exceptions. This function is only available on IA-32
5494 If StartBit is greater than 31, then ASSERT().
5495 If EndBit is greater than 31, then ASSERT().
5496 If EndBit is less than StartBit, then ASSERT().
5498 @param Index The 32-bit MSR index to write.
5499 @param StartBit The ordinal of the least significant bit in the bit field.
5501 @param EndBit The ordinal of the most significant bit in the bit field.
5503 @param AndData The value to AND with the read value from the MSR.
5504 @param OrData The value to OR with the result of the AND operation.
5506 @return The lower 32-bit of the value written to the MSR.
5511 AsmMsrBitFieldAndThenOr32 (
5521 Returns a 64-bit Machine Specific Register(MSR).
5523 Reads and returns the 64-bit MSR specified by Index. No parameter checking is
5524 performed on Index, and some Index values may cause CPU exceptions. The
5525 caller must either guarantee that Index is valid, or the caller must set up
5526 exception handlers to catch the exceptions. This function is only available
5529 @param Index The 32-bit MSR index to read.
5531 @return The value of the MSR identified by Index.
5542 Writes a 64-bit value to a Machine Specific Register(MSR), and returns the
5545 Writes the 64-bit value specified by Value to the MSR specified by Index. The
5546 64-bit value written to the MSR is returned. No parameter checking is
5547 performed on Index or Value, and some of these may cause CPU exceptions. The
5548 caller must either guarantee that Index and Value are valid, or the caller
5549 must establish proper exception handlers. This function is only available on
5552 @param Index The 32-bit MSR index to write.
5553 @param Value The 64-bit value to write to the MSR.
5567 Reads a 64-bit MSR, performs a bitwise inclusive OR, and writes the result
5568 back to the 64-bit MSR.
5570 Reads the 64-bit MSR specified by Index, performs a bitwise inclusive OR
5571 between the read result and the value specified by OrData, and writes the
5572 result to the 64-bit MSR specified by Index. The value written to the MSR is
5573 returned. No parameter checking is performed on Index or OrData, and some of
5574 these may cause CPU exceptions. The caller must either guarantee that Index
5575 and OrData are valid, or the caller must establish proper exception handlers.
5576 This function is only available on IA-32 and X64.
5578 @param Index The 32-bit MSR index to write.
5579 @param OrData The value to OR with the read value from the MSR.
5581 @return The value written back to the MSR.
5593 Reads a 64-bit MSR, performs a bitwise AND, and writes the result back to the
5596 Reads the 64-bit MSR specified by Index, performs a bitwise AND between the
5597 read result and the value specified by OrData, and writes the result to the
5598 64-bit MSR specified by Index. The value written to the MSR is returned. No
5599 parameter checking is performed on Index or OrData, and some of these may
5600 cause CPU exceptions. The caller must either guarantee that Index and OrData
5601 are valid, or the caller must establish proper exception handlers. This
5602 function is only available on IA-32 and X64.
5604 @param Index The 32-bit MSR index to write.
5605 @param AndData The value to AND with the read value from the MSR.
5607 @return The value written back to the MSR.
5619 Reads a 64-bit MSR, performs a bitwise AND followed by a bitwise inclusive
5620 OR, and writes the result back to the 64-bit MSR.
5622 Reads the 64-bit MSR specified by Index, performs a bitwise AND between read
5623 result and the value specified by AndData, performs a bitwise inclusive OR
5624 between the result of the AND operation and the value specified by OrData,
5625 and writes the result to the 64-bit MSR specified by Index. The value written
5626 to the MSR is returned. No parameter checking is performed on Index, AndData,
5627 or OrData, and some of these may cause CPU exceptions. The caller must either
5628 guarantee that Index, AndData, and OrData are valid, or the caller must
5629 establish proper exception handlers. This function is only available on IA-32
5632 @param Index The 32-bit MSR index to write.
5633 @param AndData The value to AND with the read value from the MSR.
5634 @param OrData The value to OR with the result of the AND operation.
5636 @return The value written back to the MSR.
5649 Reads a bit field of an MSR.
5651 Reads the bit field in the 64-bit MSR. The bit field is specified by the
5652 StartBit and the EndBit. The value of the bit field is returned. The caller
5653 must either guarantee that Index is valid, or the caller must set up
5654 exception handlers to catch the exceptions. This function is only available
5657 If StartBit is greater than 63, then ASSERT().
5658 If EndBit is greater than 63, then ASSERT().
5659 If EndBit is less than StartBit, then ASSERT().
5661 @param Index The 32-bit MSR index to read.
5662 @param StartBit The ordinal of the least significant bit in the bit field.
5664 @param EndBit The ordinal of the most significant bit in the bit field.
5667 @return The value read from the MSR.
5672 AsmMsrBitFieldRead64 (
5680 Writes a bit field to an MSR.
5682 Writes Value to a bit field in a 64-bit MSR. The bit field is specified by
5683 the StartBit and the EndBit. All other bits in the destination MSR are
5684 preserved. The MSR written is returned. Extra left bits in Value are
5685 stripped. The caller must either guarantee that Index and the data written is
5686 valid, or the caller must set up exception handlers to catch the exceptions.
5687 This function is only available on IA-32 and X64.
5689 If StartBit is greater than 63, then ASSERT().
5690 If EndBit is greater than 63, then ASSERT().
5691 If EndBit is less than StartBit, then ASSERT().
5693 @param Index The 32-bit MSR index to write.
5694 @param StartBit The ordinal of the least significant bit in the bit field.
5696 @param EndBit The ordinal of the most significant bit in the bit field.
5698 @param Value New value of the bit field.
5700 @return The value written back to the MSR.
5705 AsmMsrBitFieldWrite64 (
5714 Reads a bit field in a 64-bit MSR, performs a bitwise inclusive OR, and
5715 writes the result back to the bit field in the 64-bit MSR.
5717 Reads the 64-bit MSR specified by Index, performs a bitwise inclusive OR
5718 between the read result and the value specified by OrData, and writes the
5719 result to the 64-bit MSR specified by Index. The value written to the MSR is
5720 returned. Extra left bits in OrData are stripped. The caller must either
5721 guarantee that Index and the data written is valid, or the caller must set up
5722 exception handlers to catch the exceptions. This function is only available
5725 If StartBit is greater than 63, then ASSERT().
5726 If EndBit is greater than 63, then ASSERT().
5727 If EndBit is less than StartBit, then ASSERT().
5729 @param Index The 32-bit MSR index to write.
5730 @param StartBit The ordinal of the least significant bit in the bit field.
5732 @param EndBit The ordinal of the most significant bit in the bit field.
5734 @param OrData The value to OR with the read value from the bit field.
5736 @return The value written back to the MSR.
5741 AsmMsrBitFieldOr64 (
5750 Reads a bit field in a 64-bit MSR, performs a bitwise AND, and writes the
5751 result back to the bit field in the 64-bit MSR.
5753 Reads the 64-bit MSR specified by Index, performs a bitwise AND between the
5754 read result and the value specified by AndData, and writes the result to the
5755 64-bit MSR specified by Index. The value written to the MSR is returned.
5756 Extra left bits in AndData are stripped. The caller must either guarantee
5757 that Index and the data written is valid, or the caller must set up exception
5758 handlers to catch the exceptions. This function is only available on IA-32
5761 If StartBit is greater than 63, then ASSERT().
5762 If EndBit is greater than 63, then ASSERT().
5763 If EndBit is less than StartBit, then ASSERT().
5765 @param Index The 32-bit MSR index to write.
5766 @param StartBit The ordinal of the least significant bit in the bit field.
5768 @param EndBit The ordinal of the most significant bit in the bit field.
5770 @param AndData The value to AND with the read value from the bit field.
5772 @return The value written back to the MSR.
5777 AsmMsrBitFieldAnd64 (
5786 Reads a bit field in a 64-bit MSR, performs a bitwise AND followed by a
5787 bitwise inclusive OR, and writes the result back to the bit field in the
5790 Reads the 64-bit MSR specified by Index, performs a bitwise AND followed by
5791 a bitwise inclusive OR between the read result and the value specified by
5792 AndData, and writes the result to the 64-bit MSR specified by Index. The
5793 value written to the MSR is returned. Extra left bits in both AndData and
5794 OrData are stripped. The caller must either guarantee that Index and the data
5795 written is valid, or the caller must set up exception handlers to catch the
5796 exceptions. This function is only available on IA-32 and X64.
5798 If StartBit is greater than 63, then ASSERT().
5799 If EndBit is greater than 63, then ASSERT().
5800 If EndBit is less than StartBit, then ASSERT().
5802 @param Index The 32-bit MSR index to write.
5803 @param StartBit The ordinal of the least significant bit in the bit field.
5805 @param EndBit The ordinal of the most significant bit in the bit field.
5807 @param AndData The value to AND with the read value from the bit field.
5808 @param OrData The value to OR with the result of the AND operation.
5810 @return The value written back to the MSR.
5815 AsmMsrBitFieldAndThenOr64 (
5825 Reads the current value of the EFLAGS register.
5827 Reads and returns the current value of the EFLAGS register. This function is
5828 only available on IA-32 and X64. This returns a 32-bit value on IA-32 and a
5829 64-bit value on X64.
5831 @return EFLAGS on IA-32 or RFLAGS on X64.
5842 Reads the current value of the Control Register 0 (CR0).
5844 Reads and returns the current value of CR0. This function is only available
5845 on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on
5848 @return The value of the Control Register 0 (CR0).
5859 Reads the current value of the Control Register 2 (CR2).
5861 Reads and returns the current value of CR2. This function is only available
5862 on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on
5865 @return The value of the Control Register 2 (CR2).
5876 Reads the current value of the Control Register 3 (CR3).
5878 Reads and returns the current value of CR3. This function is only available
5879 on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on
5882 @return The value of the Control Register 3 (CR3).
5893 Reads the current value of the Control Register 4 (CR4).
5895 Reads and returns the current value of CR4. This function is only available
5896 on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on
5899 @return The value of the Control Register 4 (CR4).
5910 Writes a value to Control Register 0 (CR0).
5912 Writes and returns a new value to CR0. This function is only available on
5913 IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.
5915 @param Cr0 The value to write to CR0.
5917 @return The value written to CR0.
5928 Writes a value to Control Register 2 (CR2).
5930 Writes and returns a new value to CR2. This function is only available on
5931 IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.
5933 @param Cr2 The value to write to CR2.
5935 @return The value written to CR2.
5946 Writes a value to Control Register 3 (CR3).
5948 Writes and returns a new value to CR3. This function is only available on
5949 IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.
5951 @param Cr3 The value to write to CR3.
5953 @return The value written to CR3.
5964 Writes a value to Control Register 4 (CR4).
5966 Writes and returns a new value to CR4. This function is only available on
5967 IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.
5969 @param Cr4 The value to write to CR4.
5971 @return The value written to CR4.
5982 Reads the current value of Debug Register 0 (DR0).
5984 Reads and returns the current value of DR0. This function is only available
5985 on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on
5988 @return The value of Debug Register 0 (DR0).
5999 Reads the current value of Debug Register 1 (DR1).
6001 Reads and returns the current value of DR1. This function is only available
6002 on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on
6005 @return The value of Debug Register 1 (DR1).
6016 Reads the current value of Debug Register 2 (DR2).
6018 Reads and returns the current value of DR2. This function is only available
6019 on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on
6022 @return The value of Debug Register 2 (DR2).
6033 Reads the current value of Debug Register 3 (DR3).
6035 Reads and returns the current value of DR3. This function is only available
6036 on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on
6039 @return The value of Debug Register 3 (DR3).
6050 Reads the current value of Debug Register 4 (DR4).
6052 Reads and returns the current value of DR4. This function is only available
6053 on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on
6056 @return The value of Debug Register 4 (DR4).
6067 Reads the current value of Debug Register 5 (DR5).
6069 Reads and returns the current value of DR5. This function is only available
6070 on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on
6073 @return The value of Debug Register 5 (DR5).
6084 Reads the current value of Debug Register 6 (DR6).
6086 Reads and returns the current value of DR6. This function is only available
6087 on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on
6090 @return The value of Debug Register 6 (DR6).
6101 Reads the current value of Debug Register 7 (DR7).
6103 Reads and returns the current value of DR7. This function is only available
6104 on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on
6107 @return The value of Debug Register 7 (DR7).
6118 Writes a value to Debug Register 0 (DR0).
6120 Writes and returns a new value to DR0. This function is only available on
6121 IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.
6123 @param Dr0 The value to write to Dr0.
6125 @return The value written to Debug Register 0 (DR0).
6136 Writes a value to Debug Register 1 (DR1).
6138 Writes and returns a new value to DR1. This function is only available on
6139 IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.
6141 @param Dr1 The value to write to Dr1.
6143 @return The value written to Debug Register 1 (DR1).
6154 Writes a value to Debug Register 2 (DR2).
6156 Writes and returns a new value to DR2. This function is only available on
6157 IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.
6159 @param Dr2 The value to write to Dr2.
6161 @return The value written to Debug Register 2 (DR2).
6172 Writes a value to Debug Register 3 (DR3).
6174 Writes and returns a new value to DR3. This function is only available on
6175 IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.
6177 @param Dr3 The value to write to Dr3.
6179 @return The value written to Debug Register 3 (DR3).
6190 Writes a value to Debug Register 4 (DR4).
6192 Writes and returns a new value to DR4. This function is only available on
6193 IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.
6195 @param Dr4 The value to write to Dr4.
6197 @return The value written to Debug Register 4 (DR4).
6208 Writes a value to Debug Register 5 (DR5).
6210 Writes and returns a new value to DR5. This function is only available on
6211 IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.
6213 @param Dr5 The value to write to Dr5.
6215 @return The value written to Debug Register 5 (DR5).
6226 Writes a value to Debug Register 6 (DR6).
6228 Writes and returns a new value to DR6. This function is only available on
6229 IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.
6231 @param Dr6 The value to write to Dr6.
6233 @return The value written to Debug Register 6 (DR6).
6244 Writes a value to Debug Register 7 (DR7).
6246 Writes and returns a new value to DR7. This function is only available on
6247 IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.
6249 @param Dr7 The value to write to Dr7.
6251 @return The value written to Debug Register 7 (DR7).
6262 Reads the current value of Code Segment Register (CS).
6264 Reads and returns the current value of CS. This function is only available on
6267 @return The current value of CS.
6278 Reads the current value of Data Segment Register (DS).
6280 Reads and returns the current value of DS. This function is only available on
6283 @return The current value of DS.
6294 Reads the current value of Extra Segment Register (ES).
6296 Reads and returns the current value of ES. This function is only available on
6299 @return The current value of ES.
6310 Reads the current value of FS Data Segment Register (FS).
6312 Reads and returns the current value of FS. This function is only available on
6315 @return The current value of FS.
6326 Reads the current value of GS Data Segment Register (GS).
6328 Reads and returns the current value of GS. This function is only available on
6331 @return The current value of GS.
6342 Reads the current value of Stack Segment Register (SS).
6344 Reads and returns the current value of SS. This function is only available on
6347 @return The current value of SS.
6358 Reads the current value of Task Register (TR).
6360 Reads and returns the current value of TR. This function is only available on
6363 @return The current value of TR.
6374 Reads the current Global Descriptor Table Register(GDTR) descriptor.
6376 Reads and returns the current GDTR descriptor and returns it in Gdtr. This
6377 function is only available on IA-32 and X64.
6379 If Gdtr is NULL, then ASSERT().
6381 @param Gdtr Pointer to a GDTR descriptor.
6387 OUT IA32_DESCRIPTOR
*Gdtr
6392 Writes the current Global Descriptor Table Register (GDTR) descriptor.
6394 Writes and the current GDTR descriptor specified by Gdtr. This function is
6395 only available on IA-32 and X64.
6397 If Gdtr is NULL, then ASSERT().
6399 @param Gdtr Pointer to a GDTR descriptor.
6405 IN CONST IA32_DESCRIPTOR
*Gdtr
6410 Reads the current Interrupt Descriptor Table Register(IDTR) descriptor.
6412 Reads and returns the current IDTR descriptor and returns it in Idtr. This
6413 function is only available on IA-32 and X64.
6415 If Idtr is NULL, then ASSERT().
6417 @param Idtr Pointer to a IDTR descriptor.
6423 OUT IA32_DESCRIPTOR
*Idtr
6428 Writes the current Interrupt Descriptor Table Register(IDTR) descriptor.
6430 Writes the current IDTR descriptor and returns it in Idtr. This function is
6431 only available on IA-32 and X64.
6433 If Idtr is NULL, then ASSERT().
6435 @param Idtr Pointer to a IDTR descriptor.
6441 IN CONST IA32_DESCRIPTOR
*Idtr
6446 Reads the current Local Descriptor Table Register(LDTR) selector.
6448 Reads and returns the current 16-bit LDTR descriptor value. This function is
6449 only available on IA-32 and X64.
6451 @return The current selector of LDT.
6462 Writes the current Local Descriptor Table Register (LDTR) selector.
6464 Writes and the current LDTR descriptor specified by Ldtr. This function is
6465 only available on IA-32 and X64.
6467 @param Ldtr 16-bit LDTR selector value.
6478 Save the current floating point/SSE/SSE2 context to a buffer.
6480 Saves the current floating point/SSE/SSE2 state to the buffer specified by
6481 Buffer. Buffer must be aligned on a 16-byte boundary. This function is only
6482 available on IA-32 and X64.
6484 If Buffer is NULL, then ASSERT().
6485 If Buffer is not aligned on a 16-byte boundary, then ASSERT().
6487 @param Buffer Pointer to a buffer to save the floating point/SSE/SSE2 context.
6493 OUT IA32_FX_BUFFER
*Buffer
6498 Restores the current floating point/SSE/SSE2 context from a buffer.
6500 Restores the current floating point/SSE/SSE2 state from the buffer specified
6501 by Buffer. Buffer must be aligned on a 16-byte boundary. This function is
6502 only available on IA-32 and X64.
6504 If Buffer is NULL, then ASSERT().
6505 If Buffer is not aligned on a 16-byte boundary, then ASSERT().
6506 If Buffer was not saved with AsmFxSave(), then ASSERT().
6508 @param Buffer Pointer to a buffer to save the floating point/SSE/SSE2 context.
6514 IN CONST IA32_FX_BUFFER
*Buffer
6519 Reads the current value of 64-bit MMX Register #0 (MM0).
6521 Reads and returns the current value of MM0. This function is only available
6524 @return The current value of MM0.
6535 Reads the current value of 64-bit MMX Register #1 (MM1).
6537 Reads and returns the current value of MM1. This function is only available
6540 @return The current value of MM1.
6551 Reads the current value of 64-bit MMX Register #2 (MM2).
6553 Reads and returns the current value of MM2. This function is only available
6556 @return The current value of MM2.
6567 Reads the current value of 64-bit MMX Register #3 (MM3).
6569 Reads and returns the current value of MM3. This function is only available
6572 @return The current value of MM3.
6583 Reads the current value of 64-bit MMX Register #4 (MM4).
6585 Reads and returns the current value of MM4. This function is only available
6588 @return The current value of MM4.
6599 Reads the current value of 64-bit MMX Register #5 (MM5).
6601 Reads and returns the current value of MM5. This function is only available
6604 @return The current value of MM5.
6615 Reads the current value of 64-bit MMX Register #6 (MM6).
6617 Reads and returns the current value of MM6. This function is only available
6620 @return The current value of MM6.
6631 Reads the current value of 64-bit MMX Register #7 (MM7).
6633 Reads and returns the current value of MM7. This function is only available
6636 @return The current value of MM7.
6647 Writes the current value of 64-bit MMX Register #0 (MM0).
6649 Writes the current value of MM0. This function is only available on IA32 and
6652 @param Value The 64-bit value to write to MM0.
6663 Writes the current value of 64-bit MMX Register #1 (MM1).
6665 Writes the current value of MM1. This function is only available on IA32 and
6668 @param Value The 64-bit value to write to MM1.
6679 Writes the current value of 64-bit MMX Register #2 (MM2).
6681 Writes the current value of MM2. This function is only available on IA32 and
6684 @param Value The 64-bit value to write to MM2.
6695 Writes the current value of 64-bit MMX Register #3 (MM3).
6697 Writes the current value of MM3. This function is only available on IA32 and
6700 @param Value The 64-bit value to write to MM3.
6711 Writes the current value of 64-bit MMX Register #4 (MM4).
6713 Writes the current value of MM4. This function is only available on IA32 and
6716 @param Value The 64-bit value to write to MM4.
6727 Writes the current value of 64-bit MMX Register #5 (MM5).
6729 Writes the current value of MM5. This function is only available on IA32 and
6732 @param Value The 64-bit value to write to MM5.
6743 Writes the current value of 64-bit MMX Register #6 (MM6).
6745 Writes the current value of MM6. This function is only available on IA32 and
6748 @param Value The 64-bit value to write to MM6.
6759 Writes the current value of 64-bit MMX Register #7 (MM7).
6761 Writes the current value of MM7. This function is only available on IA32 and
6764 @param Value The 64-bit value to write to MM7.
6775 Reads the current value of Time Stamp Counter (TSC).
6777 Reads and returns the current value of TSC. This function is only available
6780 @return The current value of TSC
6791 Reads the current value of a Performance Counter (PMC).
6793 Reads and returns the current value of performance counter specified by
6794 Index. This function is only available on IA-32 and X64.
6796 @param Index The 32-bit Performance Counter index to read.
6798 @return The value of the PMC specified by Index.
6809 Sets up a monitor buffer that is used by AsmMwait().
6811 Executes a MONITOR instruction with the register state specified by Eax, Ecx
6812 and Edx. Returns Eax. This function is only available on IA-32 and X64.
6814 @param Eax The value to load into EAX or RAX before executing the MONITOR
6816 @param Ecx The value to load into ECX or RCX before executing the MONITOR
6818 @param Edx The value to load into EDX or RDX before executing the MONITOR
6834 Executes an MWAIT instruction.
6836 Executes an MWAIT instruction with the register state specified by Eax and
6837 Ecx. Returns Eax. This function is only available on IA-32 and X64.
6839 @param Eax The value to load into EAX or RAX before executing the MONITOR
6841 @param Ecx The value to load into ECX or RCX before executing the MONITOR
6856 Executes a WBINVD instruction.
6858 Executes a WBINVD instruction. This function is only available on IA-32 and
6870 Executes a INVD instruction.
6872 Executes a INVD instruction. This function is only available on IA-32 and
6884 Flushes a cache line from all the instruction and data caches within the
6885 coherency domain of the CPU.
6887 Flushed the cache line specified by LinearAddress, and returns LinearAddress.
6888 This function is only available on IA-32 and X64.
6890 @param LinearAddress The address of the cache line to flush. If the CPU is
6891 in a physical addressing mode, then LinearAddress is a
6892 physical address. If the CPU is in a virtual
6893 addressing mode, then LinearAddress is a virtual
6896 @return LinearAddress
6901 IN VOID
*LinearAddress
6906 Enables the 32-bit paging mode on the CPU.
6908 Enables the 32-bit paging mode on the CPU. CR0, CR3, CR4, and the page tables
6909 must be properly initialized prior to calling this service. This function
6910 assumes the current execution mode is 32-bit protected mode. This function is
6911 only available on IA-32. After the 32-bit paging mode is enabled, control is
6912 transferred to the function specified by EntryPoint using the new stack
6913 specified by NewStack and passing in the parameters specified by Context1 and
6914 Context2. Context1 and Context2 are optional and may be NULL. The function
6915 EntryPoint must never return.
6917 If the current execution mode is not 32-bit protected mode, then ASSERT().
6918 If EntryPoint is NULL, then ASSERT().
6919 If NewStack is NULL, then ASSERT().
6921 There are a number of constraints that must be followed before calling this
6923 1) Interrupts must be disabled.
6924 2) The caller must be in 32-bit protected mode with flat descriptors. This
6925 means all descriptors must have a base of 0 and a limit of 4GB.
6926 3) CR0 and CR4 must be compatible with 32-bit protected mode with flat
6928 4) CR3 must point to valid page tables that will be used once the transition
6929 is complete, and those page tables must guarantee that the pages for this
6930 function and the stack are identity mapped.
6932 @param EntryPoint A pointer to function to call with the new stack after
6934 @param Context1 A pointer to the context to pass into the EntryPoint
6935 function as the first parameter after paging is enabled.
6936 @param Context2 A pointer to the context to pass into the EntryPoint
6937 function as the second parameter after paging is enabled.
6938 @param NewStack A pointer to the new stack to use for the EntryPoint
6939 function after paging is enabled.
6945 IN SWITCH_STACK_ENTRY_POINT EntryPoint
,
6946 IN VOID
*Context1
, OPTIONAL
6947 IN VOID
*Context2
, OPTIONAL
6953 Disables the 32-bit paging mode on the CPU.
6955 Disables the 32-bit paging mode on the CPU and returns to 32-bit protected
6956 mode. This function assumes the current execution mode is 32-paged protected
6957 mode. This function is only available on IA-32. After the 32-bit paging mode
6958 is disabled, control is transferred to the function specified by EntryPoint
6959 using the new stack specified by NewStack and passing in the parameters
6960 specified by Context1 and Context2. Context1 and Context2 are optional and
6961 may be NULL. The function EntryPoint must never return.
6963 If the current execution mode is not 32-bit paged mode, then ASSERT().
6964 If EntryPoint is NULL, then ASSERT().
6965 If NewStack is NULL, then ASSERT().
6967 There are a number of constraints that must be followed before calling this
6969 1) Interrupts must be disabled.
6970 2) The caller must be in 32-bit paged mode.
6971 3) CR0, CR3, and CR4 must be compatible with 32-bit paged mode.
6972 4) CR3 must point to valid page tables that guarantee that the pages for
6973 this function and the stack are identity mapped.
6975 @param EntryPoint A pointer to function to call with the new stack after
6977 @param Context1 A pointer to the context to pass into the EntryPoint
6978 function as the first parameter after paging is disabled.
6979 @param Context2 A pointer to the context to pass into the EntryPoint
6980 function as the second parameter after paging is
6982 @param NewStack A pointer to the new stack to use for the EntryPoint
6983 function after paging is disabled.
6988 AsmDisablePaging32 (
6989 IN SWITCH_STACK_ENTRY_POINT EntryPoint
,
6990 IN VOID
*Context1
, OPTIONAL
6991 IN VOID
*Context2
, OPTIONAL
6997 Enables the 64-bit paging mode on the CPU.
6999 Enables the 64-bit paging mode on the CPU. CR0, CR3, CR4, and the page tables
7000 must be properly initialized prior to calling this service. This function
7001 assumes the current execution mode is 32-bit protected mode with flat
7002 descriptors. This function is only available on IA-32. After the 64-bit
7003 paging mode is enabled, control is transferred to the function specified by
7004 EntryPoint using the new stack specified by NewStack and passing in the
7005 parameters specified by Context1 and Context2. Context1 and Context2 are
7006 optional and may be 0. The function EntryPoint must never return.
7008 If the current execution mode is not 32-bit protected mode with flat
7009 descriptors, then ASSERT().
7010 If EntryPoint is 0, then ASSERT().
7011 If NewStack is 0, then ASSERT().
7013 @param Cs The 16-bit selector to load in the CS before EntryPoint
7014 is called. The descriptor in the GDT that this selector
7015 references must be setup for long mode.
7016 @param EntryPoint The 64-bit virtual address of the function to call with
7017 the new stack after paging is enabled.
7018 @param Context1 The 64-bit virtual address of the context to pass into
7019 the EntryPoint function as the first parameter after
7021 @param Context2 The 64-bit virtual address of the context to pass into
7022 the EntryPoint function as the second parameter after
7024 @param NewStack The 64-bit virtual address of the new stack to use for
7025 the EntryPoint function after paging is enabled.
7032 IN UINT64 EntryPoint
,
7033 IN UINT64 Context1
, OPTIONAL
7034 IN UINT64 Context2
, OPTIONAL
7040 Disables the 64-bit paging mode on the CPU.
7042 Disables the 64-bit paging mode on the CPU and returns to 32-bit protected
7043 mode. This function assumes the current execution mode is 64-paging mode.
7044 This function is only available on X64. After the 64-bit paging mode is
7045 disabled, control is transferred to the function specified by EntryPoint
7046 using the new stack specified by NewStack and passing in the parameters
7047 specified by Context1 and Context2. Context1 and Context2 are optional and
7048 may be 0. The function EntryPoint must never return.
7050 If the current execution mode is not 64-bit paged mode, then ASSERT().
7051 If EntryPoint is 0, then ASSERT().
7052 If NewStack is 0, then ASSERT().
7054 @param Cs The 16-bit selector to load in the CS before EntryPoint
7055 is called. The descriptor in the GDT that this selector
7056 references must be setup for 32-bit protected mode.
7057 @param EntryPoint The 64-bit virtual address of the function to call with
7058 the new stack after paging is disabled.
7059 @param Context1 The 64-bit virtual address of the context to pass into
7060 the EntryPoint function as the first parameter after
7062 @param Context2 The 64-bit virtual address of the context to pass into
7063 the EntryPoint function as the second parameter after
7065 @param NewStack The 64-bit virtual address of the new stack to use for
7066 the EntryPoint function after paging is disabled.
7071 AsmDisablePaging64 (
7073 IN UINT32 EntryPoint
,
7074 IN UINT32 Context1
, OPTIONAL
7075 IN UINT32 Context2
, OPTIONAL
7081 // 16-bit thunking services
7085 Retrieves the properties for 16-bit thunk functions.
7087 Computes the size of the buffer and stack below 1MB required to use the
7088 AsmPrepareThunk16(), AsmThunk16() and AsmPrepareAndThunk16() functions. This
7089 buffer size is returned in RealModeBufferSize, and the stack size is returned
7090 in ExtraStackSize. If parameters are passed to the 16-bit real mode code,
7091 then the actual minimum stack size is ExtraStackSize plus the maximum number
7092 of bytes that need to be passed to the 16-bit real mode code.
7094 If RealModeBufferSize is NULL, then ASSERT().
7095 If ExtraStackSize is NULL, then ASSERT().
7097 @param RealModeBufferSize A pointer to the size of the buffer below 1MB
7098 required to use the 16-bit thunk functions.
7099 @param ExtraStackSize A pointer to the extra size of stack below 1MB
7100 that the 16-bit thunk functions require for
7101 temporary storage in the transition to and from
7107 AsmGetThunk16Properties (
7108 OUT UINT32
*RealModeBufferSize
,
7109 OUT UINT32
*ExtraStackSize
7114 Prepares all structures a code required to use AsmThunk16().
7116 Prepares all structures and code required to use AsmThunk16().
7118 If ThunkContext is NULL, then ASSERT().
7120 @param ThunkContext A pointer to the context structure that describes the
7121 16-bit real mode code to call.
7127 OUT THUNK_CONTEXT
*ThunkContext
7132 Transfers control to a 16-bit real mode entry point and returns the results.
7134 Transfers control to a 16-bit real mode entry point and returns the results.
7135 AsmPrepareThunk16() must be called with ThunkContext before this function is used.
7136 This function must be called with interrupts disabled.
7138 The register state from the RealModeState field of ThunkContext is restored just prior
7139 to calling the 16-bit real mode entry point. This includes the EFLAGS field of RealModeState,
7140 which is used to set the interrupt state when a 16-bit real mode entry point is called.
7141 Control is transferred to the 16-bit real mode entry point specified by the CS and Eip fields of RealModeState.
7142 The stack is initialized to the SS and ESP fields of RealModeState. Any parameters passed to
7143 the 16-bit real mode code must be populated by the caller at SS:ESP prior to calling this function.
7144 The 16-bit real mode entry point is invoked with a 16-bit CALL FAR instruction,
7145 so when accessing stack contents, the 16-bit real mode code must account for the 16-bit segment
7146 and 16-bit offset of the return address that were pushed onto the stack. The 16-bit real mode entry
7147 point must exit with a RETF instruction. The register state is captured into RealModeState immediately
7148 after the RETF instruction is executed.
7150 If EFLAGS specifies interrupts enabled, or any of the 16-bit real mode code enables interrupts,
7151 or any of the 16-bit real mode code makes a SW interrupt, then the caller is responsible for making sure
7152 the IDT at address 0 is initialized to handle any HW or SW interrupts that may occur while in 16-bit real mode.
7154 If EFLAGS specifies interrupts enabled, or any of the 16-bit real mode code enables interrupts,
7155 then the caller is responsible for making sure the 8259 PIC is in a state compatible with 16-bit real mode.
7156 This includes the base vectors, the interrupt masks, and the edge/level trigger mode.
7158 If THUNK_ATTRIBUTE_BIG_REAL_MODE is set in the ThunkAttributes field of ThunkContext, then the user code
7159 is invoked in big real mode. Otherwise, the user code is invoked in 16-bit real mode with 64KB segment limits.
7161 If neither THUNK_ATTRIBUTE_DISABLE_A20_MASK_INT_15 nor THUNK_ATTRIBUTE_DISABLE_A20_MASK_KBD_CTRL are set in
7162 ThunkAttributes, then it is assumed that the user code did not enable the A20 mask, and no attempt is made to
7163 disable the A20 mask.
7165 If THUNK_ATTRIBUTE_DISABLE_A20_MASK_INT_15 is set and THUNK_ATTRIBUTE_DISABLE_A20_MASK_KBD_CTRL is clear in
7166 ThunkAttributes, then attempt to use the INT 15 service to disable the A20 mask. If this INT 15 call fails,
7167 then attempt to disable the A20 mask by directly accessing the 8042 keyboard controller I/O ports.
7169 If THUNK_ATTRIBUTE_DISABLE_A20_MASK_INT_15 is clear and THUNK_ATTRIBUTE_DISABLE_A20_MASK_KBD_CTRL is set in
7170 ThunkAttributes, then attempt to disable the A20 mask by directly accessing the 8042 keyboard controller I/O ports.
7172 If ThunkContext is NULL, then ASSERT().
7173 If AsmPrepareThunk16() was not previously called with ThunkContext, then ASSERT().
7174 If both THUNK_ATTRIBUTE_DISABLE_A20_MASK_INT_15 and THUNK_ATTRIBUTE_DISABLE_A20_MASK_KBD_CTRL are set in
7175 ThunkAttributes, then ASSERT().
7177 @param ThunkContext A pointer to the context structure that describes the
7178 16-bit real mode code to call.
7184 IN OUT THUNK_CONTEXT
*ThunkContext
7189 Prepares all structures and code for a 16-bit real mode thunk, transfers
7190 control to a 16-bit real mode entry point, and returns the results.
7192 Prepares all structures and code for a 16-bit real mode thunk, transfers
7193 control to a 16-bit real mode entry point, and returns the results. If the
7194 caller only need to perform a single 16-bit real mode thunk, then this
7195 service should be used. If the caller intends to make more than one 16-bit
7196 real mode thunk, then it is more efficient if AsmPrepareThunk16() is called
7197 once and AsmThunk16() can be called for each 16-bit real mode thunk.
7199 See AsmPrepareThunk16() and AsmThunk16() for the detailed description and ASSERT() conditions.
7201 @param ThunkContext A pointer to the context structure that describes the
7202 16-bit real mode code to call.
7207 AsmPrepareAndThunk16 (
7208 IN OUT THUNK_CONTEXT
*ThunkContext