2 Memory-only library functions with no library constructor/destructor
4 Copyright (c) 2006 - 2007, Intel Corporation
5 All rights reserved. This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
13 Module Name: BaseLib.h
21 // Definitions for architecture specific types
22 // These include SPIN_LOCK and BASE_LIBRARY_JUMP_BUFFER
28 typedef volatile UINTN SPIN_LOCK
;
30 #if defined (MDE_CPU_IA32)
32 // IA32 context buffer used by SetJump() and LongJump()
41 } BASE_LIBRARY_JUMP_BUFFER
;
43 #define BASE_LIBRARY_JUMP_BUFFER_ALIGNMENT 8
45 #elif defined (MDE_CPU_IPF)
47 // IPF context buffer used by SetJump() and LongJump()
82 UINT64 AfterSpillUNAT
;
88 } BASE_LIBRARY_JUMP_BUFFER
;
90 #define BASE_LIBRARY_JUMP_BUFFER_ALIGNMENT 0x10
92 #elif defined (MDE_CPU_X64)
94 // X64 context buffer used by SetJump() and LongJump()
107 } BASE_LIBRARY_JUMP_BUFFER
;
109 #define BASE_LIBRARY_JUMP_BUFFER_ALIGNMENT 8
111 #elif defined (MDE_CPU_EBC)
113 // EBC context buffer used by SetJump() and LongJump()
121 } BASE_LIBRARY_JUMP_BUFFER
;
123 #define BASE_LIBRARY_JUMP_BUFFER_ALIGNMENT 8
126 #error Unknown Processor Type
134 Copies one Null-terminated Unicode string to another Null-terminated Unicode
135 string and returns the new Unicode string.
137 This function copies the contents of the Unicode string Source to the Unicode
138 string Destination, and returns Destination. If Source and Destination
139 overlap, then the results are undefined.
141 If Destination is NULL, then ASSERT().
142 If Destination is not aligned on a 16-bit boundary, then ASSERT().
143 If Source is NULL, then ASSERT().
144 If Source is not aligned on a 16-bit boundary, then ASSERT().
145 If Source and Destination overlap, then ASSERT().
146 If PcdMaximumUnicodeStringLength is not zero, and Source contains more than
147 PcdMaximumUnicodeStringLength Unicode characters not including the
148 Null-terminator, then ASSERT().
150 @param Destination Pointer to a Null-terminated Unicode string.
151 @param Source Pointer to a Null-terminated Unicode string.
159 OUT CHAR16
*Destination
,
160 IN CONST CHAR16
*Source
165 Copies one Null-terminated Unicode string with a maximum length to another
166 Null-terminated Unicode string with a maximum length and returns the new
169 This function copies the contents of the Unicode string Source to the Unicode
170 string Destination, and returns Destination. At most, Length Unicode
171 characters are copied from Source to Destination. If Length is 0, then
172 Destination is returned unmodified. If Length is greater that the number of
173 Unicode characters in Source, then Destination is padded with Null Unicode
174 characters. If Source and Destination overlap, then the results are
177 If Length > 0 and Destination is NULL, then ASSERT().
178 If Length > 0 and Destination is not aligned on a 16-bit boundary, then ASSERT().
179 If Length > 0 and Source is NULL, then ASSERT().
180 If Length > 0 and Source is not aligned on a 16-bit bounadry, then ASSERT().
181 If Source and Destination overlap, then ASSERT().
182 If PcdMaximumUnicodeStringLength is not zero, and Source contains more than
183 PcdMaximumUnicodeStringLength Unicode characters not including the
184 Null-terminator, then ASSERT().
186 @param Destination Pointer to a Null-terminated Unicode string.
187 @param Source Pointer to a Null-terminated Unicode string.
188 @param Length Maximum number of Unicode characters to copy.
196 OUT CHAR16
*Destination
,
197 IN CONST CHAR16
*Source
,
203 Returns the length of a Null-terminated Unicode string.
205 This function returns the number of Unicode characters in the Null-terminated
206 Unicode string specified by String.
208 If String is NULL, then ASSERT().
209 If String is not aligned on a 16-bit boundary, then ASSERT().
210 If PcdMaximumUnicodeStringLength is not zero, and String contains more than
211 PcdMaximumUnicodeStringLength Unicode characters not including the
212 Null-terminator, then ASSERT().
214 @param String Pointer to a Null-terminated Unicode string.
216 @return The length of String.
222 IN CONST CHAR16
*String
227 Returns the size of a Null-terminated Unicode string in bytes, including the
230 This function returns the size, in bytes, of the Null-terminated Unicode
231 string specified by String.
233 If String is NULL, then ASSERT().
234 If String is not aligned on a 16-bit boundary, then ASSERT().
235 If PcdMaximumUnicodeStringLength is not zero, and String contains more than
236 PcdMaximumUnicodeStringLength Unicode characters not including the
237 Null-terminator, then ASSERT().
239 @param String Pointer to a Null-terminated Unicode string.
241 @return The size of String.
247 IN CONST CHAR16
*String
252 Compares two Null-terminated Unicode strings, and returns the difference
253 between the first mismatched Unicode characters.
255 This function compares the Null-terminated Unicode string FirstString to the
256 Null-terminated Unicode string SecondString. If FirstString is identical to
257 SecondString, then 0 is returned. Otherwise, the value returned is the first
258 mismatched Unicode character in SecondString subtracted from the first
259 mismatched Unicode character in FirstString.
261 If FirstString is NULL, then ASSERT().
262 If FirstString is not aligned on a 16-bit boundary, then ASSERT().
263 If SecondString is NULL, then ASSERT().
264 If SecondString is not aligned on a 16-bit boundary, then ASSERT().
265 If PcdMaximumUnicodeStringLength is not zero, and FirstString contains more
266 than PcdMaximumUnicodeStringLength Unicode characters not including the
267 Null-terminator, then ASSERT().
268 If PcdMaximumUnicodeStringLength is not zero, and SecondString contains more
269 than PcdMaximumUnicodeStringLength Unicode characters not including the
270 Null-terminator, then ASSERT().
272 @param FirstString Pointer to a Null-terminated Unicode string.
273 @param SecondString Pointer to a Null-terminated Unicode string.
275 @retval 0 FirstString is identical to SecondString.
276 @retval !=0 FirstString is not identical to SecondString.
282 IN CONST CHAR16
*FirstString
,
283 IN CONST CHAR16
*SecondString
288 Compares two Null-terminated Unicode strings with maximum lengths, and
289 returns the difference between the first mismatched Unicode characters.
291 This function compares the Null-terminated Unicode string FirstString to the
292 Null-terminated Unicode string SecondString. At most, Length Unicode
293 characters will be compared. If Length is 0, then 0 is returned. If
294 FirstString is identical to SecondString, then 0 is returned. Otherwise, the
295 value returned is the first mismatched Unicode character in SecondString
296 subtracted from the first mismatched Unicode character in FirstString.
298 If Length > 0 and FirstString is NULL, then ASSERT().
299 If Length > 0 and FirstString is not aligned on a 16-bit bounadary, then ASSERT().
300 If Length > 0 and SecondString is NULL, then ASSERT().
301 If Length > 0 and SecondString is not aligned on a 16-bit bounadary, then ASSERT().
302 If PcdMaximumUnicodeStringLength is not zero, and FirstString contains more
303 than PcdMaximumUnicodeStringLength Unicode characters not including the
304 Null-terminator, then ASSERT().
305 If PcdMaximumUnicodeStringLength is not zero, and SecondString contains more
306 than PcdMaximumUnicodeStringLength Unicode characters not including the
307 Null-terminator, then ASSERT().
309 @param FirstString Pointer to a Null-terminated Unicode string.
310 @param SecondString Pointer to a Null-terminated Unicode string.
311 @param Length Maximum number of Unicode characters to compare.
313 @retval 0 FirstString is identical to SecondString.
314 @retval !=0 FirstString is not identical to SecondString.
320 IN CONST CHAR16
*FirstString
,
321 IN CONST CHAR16
*SecondString
,
327 Concatenates one Null-terminated Unicode string to another Null-terminated
328 Unicode string, and returns the concatenated Unicode string.
330 This function concatenates two Null-terminated Unicode strings. The contents
331 of Null-terminated Unicode string Source are concatenated to the end of
332 Null-terminated Unicode string Destination. The Null-terminated concatenated
333 Unicode String is returned. If Source and Destination overlap, then the
334 results are undefined.
336 If Destination is NULL, then ASSERT().
337 If Destination is not aligned on a 16-bit bounadary, then ASSERT().
338 If Source is NULL, then ASSERT().
339 If Source is not aligned on a 16-bit bounadary, then ASSERT().
340 If Source and Destination overlap, then ASSERT().
341 If PcdMaximumUnicodeStringLength is not zero, and Destination contains more
342 than PcdMaximumUnicodeStringLength Unicode characters not including the
343 Null-terminator, then ASSERT().
344 If PcdMaximumUnicodeStringLength is not zero, and Source contains more than
345 PcdMaximumUnicodeStringLength Unicode characters not including the
346 Null-terminator, then ASSERT().
347 If PcdMaximumUnicodeStringLength is not zero, and concatenating Destination
348 and Source results in a Unicode string with more than
349 PcdMaximumUnicodeStringLength Unicode characters not including the
350 Null-terminator, then ASSERT().
352 @param Destination Pointer to a Null-terminated Unicode string.
353 @param Source Pointer to a Null-terminated Unicode string.
361 IN OUT CHAR16
*Destination
,
362 IN CONST CHAR16
*Source
367 Concatenates one Null-terminated Unicode string with a maximum length to the
368 end of another Null-terminated Unicode string, and returns the concatenated
371 This function concatenates two Null-terminated Unicode strings. The contents
372 of Null-terminated Unicode string Source are concatenated to the end of
373 Null-terminated Unicode string Destination, and Destination is returned. At
374 most, Length Unicode characters are concatenated from Source to the end of
375 Destination, and Destination is always Null-terminated. If Length is 0, then
376 Destination is returned unmodified. If Source and Destination overlap, then
377 the results are undefined.
379 If Destination is NULL, then ASSERT().
380 If Length > 0 and Destination is not aligned on a 16-bit boundary, then ASSERT().
381 If Length > 0 and Source is NULL, then ASSERT().
382 If Length > 0 and Source is not aligned on a 16-bit boundary, then ASSERT().
383 If Source and Destination overlap, then ASSERT().
384 If PcdMaximumUnicodeStringLength is not zero, and Destination contains more
385 than PcdMaximumUnicodeStringLength Unicode characters not including the
386 Null-terminator, then ASSERT().
387 If PcdMaximumUnicodeStringLength is not zero, and Source contains more than
388 PcdMaximumUnicodeStringLength Unicode characters not including the
389 Null-terminator, then ASSERT().
390 If PcdMaximumUnicodeStringLength is not zero, and concatenating Destination
391 and Source results in a Unicode string with more than
392 PcdMaximumUnicodeStringLength Unicode characters not including the
393 Null-terminator, then ASSERT().
395 @param Destination Pointer to a Null-terminated Unicode string.
396 @param Source Pointer to a Null-terminated Unicode string.
397 @param Length Maximum number of Unicode characters to concatenate from
406 IN OUT CHAR16
*Destination
,
407 IN CONST CHAR16
*Source
,
412 Returns the first occurance of a Null-terminated Unicode sub-string
413 in a Null-terminated Unicode string.
415 This function scans the contents of the Null-terminated Unicode string
416 specified by String and returns the first occurrence of SearchString.
417 If SearchString is not found in String, then NULL is returned. If
418 the length of SearchString is zero, then String is
421 If String is NULL, then ASSERT().
422 If String is not aligned on a 16-bit boundary, then ASSERT().
423 If SearchString is NULL, then ASSERT().
424 If SearchString is not aligned on a 16-bit boundary, then ASSERT().
426 If PcdMaximumUnicodeStringLength is not zero, and SearchString
427 or String contains more than PcdMaximumUnicodeStringLength Unicode
428 characters not including the Null-terminator, then ASSERT().
430 @param String Pointer to a Null-terminated Unicode string.
431 @param SearchString Pointer to a Null-terminated Unicode string to search for.
433 @retval NULL If the SearchString does not appear in String.
434 @retval !NULL If there is a match.
440 IN CONST CHAR16
*String
,
441 IN CONST CHAR16
*SearchString
445 Convert a Null-terminated Unicode decimal string to a value of
448 This function returns a value of type UINTN by interpreting the contents
449 of the Unicode string specified by String as a decimal number. The format
450 of the input Unicode string String is:
452 [spaces] [decimal digits].
454 The valid decimal digit character is in the range [0-9]. The
455 function will ignore the pad space, which includes spaces or
456 tab characters, before [decimal digits]. The running zero in the
457 beginning of [decimal digits] will be ignored. Then, the function
458 stops at the first character that is a not a valid decimal character
459 or a Null-terminator, whichever one comes first.
461 If String is NULL, then ASSERT().
462 If String is not aligned in a 16-bit boundary, then ASSERT().
463 If String has only pad spaces, then 0 is returned.
464 If String has no pad spaces or valid decimal digits,
466 If the number represented by String overflows according
467 to the range defined by UINTN, then ASSERT().
469 If PcdMaximumUnicodeStringLength is not zero, and String contains
470 more than PcdMaximumUnicodeStringLength Unicode characters not including
471 the Null-terminator, then ASSERT().
473 @param String Pointer to a Null-terminated Unicode string.
481 IN CONST CHAR16
*String
485 Convert a Null-terminated Unicode decimal string to a value of
488 This function returns a value of type UINT64 by interpreting the contents
489 of the Unicode string specified by String as a decimal number. The format
490 of the input Unicode string String is:
492 [spaces] [decimal digits].
494 The valid decimal digit character is in the range [0-9]. The
495 function will ignore the pad space, which includes spaces or
496 tab characters, before [decimal digits]. The running zero in the
497 beginning of [decimal digits] will be ignored. Then, the function
498 stops at the first character that is a not a valid decimal character
499 or a Null-terminator, whichever one comes first.
501 If String is NULL, then ASSERT().
502 If String is not aligned in a 16-bit boundary, then ASSERT().
503 If String has only pad spaces, then 0 is returned.
504 If String has no pad spaces or valid decimal digits,
506 If the number represented by String overflows according
507 to the range defined by UINT64, then ASSERT().
509 If PcdMaximumUnicodeStringLength is not zero, and String contains
510 more than PcdMaximumUnicodeStringLength Unicode characters not including
511 the Null-terminator, then ASSERT().
513 @param String Pointer to a Null-terminated Unicode string.
521 IN CONST CHAR16
*String
526 Convert a Null-terminated Unicode hexadecimal string to a value of type UINTN.
528 This function returns a value of type UINTN by interpreting the contents
529 of the Unicode string specified by String as a hexadecimal number.
530 The format of the input Unicode string String is:
532 [spaces][zeros][x][hexadecimal digits].
534 The valid hexadecimal digit character is in the range [0-9], [a-f] and [A-F].
535 The prefix "0x" is optional. Both "x" and "X" is allowed in "0x" prefix.
536 If "x" appears in the input string, it must be prefixed with at least one 0.
537 The function will ignore the pad space, which includes spaces or tab characters,
538 before [zeros], [x] or [hexadecimal digit]. The running zero before [x] or
539 [hexadecimal digit] will be ignored. Then, the decoding starts after [x] or the
540 first valid hexadecimal digit. Then, the function stops at the first character that is
541 a not a valid hexadecimal character or NULL, whichever one comes first.
543 If String is NULL, then ASSERT().
544 If String is not aligned in a 16-bit boundary, then ASSERT().
545 If String has only pad spaces, then zero is returned.
546 If String has no leading pad spaces, leading zeros or valid hexadecimal digits,
547 then zero is returned.
548 If the number represented by String overflows according to the range defined by
549 UINTN, then ASSERT().
551 If PcdMaximumUnicodeStringLength is not zero, and String contains more than
552 PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator,
555 @param String Pointer to a Null-terminated Unicode string.
563 IN CONST CHAR16
*String
568 Convert a Null-terminated Unicode hexadecimal string to a value of type UINT64.
570 This function returns a value of type UINT64 by interpreting the contents
571 of the Unicode string specified by String as a hexadecimal number.
572 The format of the input Unicode string String is
574 [spaces][zeros][x][hexadecimal digits].
576 The valid hexadecimal digit character is in the range [0-9], [a-f] and [A-F].
577 The prefix "0x" is optional. Both "x" and "X" is allowed in "0x" prefix.
578 If "x" appears in the input string, it must be prefixed with at least one 0.
579 The function will ignore the pad space, which includes spaces or tab characters,
580 before [zeros], [x] or [hexadecimal digit]. The running zero before [x] or
581 [hexadecimal digit] will be ignored. Then, the decoding starts after [x] or the
582 first valid hexadecimal digit. Then, the function stops at the first character that is
583 a not a valid hexadecimal character or NULL, whichever one comes first.
585 If String is NULL, then ASSERT().
586 If String is not aligned in a 16-bit boundary, then ASSERT().
587 If String has only pad spaces, then zero is returned.
588 If String has no leading pad spaces, leading zeros or valid hexadecimal digits,
589 then zero is returned.
590 If the number represented by String overflows according to the range defined by
591 UINT64, then ASSERT().
593 If PcdMaximumUnicodeStringLength is not zero, and String contains more than
594 PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator,
597 @param String Pointer to a Null-terminated Unicode string.
605 IN CONST CHAR16
*String
610 Convert one Null-terminated Unicode string to a Null-terminated
611 ASCII string and returns the ASCII string.
613 This function converts the content of the Unicode string Source
614 to the ASCII string Destination by copying the lower 8 bits of
615 each Unicode character. It returns Destination.
617 If any Unicode characters in Source contain non-zero value in
618 the upper 8 bits, then ASSERT().
620 If Destination is NULL, then ASSERT().
621 If Source is NULL, then ASSERT().
622 If Source is not aligned on a 16-bit boundary, then ASSERT().
623 If Source and Destination overlap, then ASSERT().
625 If PcdMaximumUnicodeStringLength is not zero, and Source contains
626 more than PcdMaximumUnicodeStringLength Unicode characters not including
627 the Null-terminator, then ASSERT().
629 If PcdMaximumAsciiStringLength is not zero, and Source contains more
630 than PcdMaximumAsciiStringLength Unicode characters not including the
631 Null-terminator, then ASSERT().
633 @param Source Pointer to a Null-terminated Unicode string.
634 @param Destination Pointer to a Null-terminated ASCII string.
641 UnicodeStrToAsciiStr (
642 IN CONST CHAR16
*Source
,
643 OUT CHAR8
*Destination
648 Copies one Null-terminated ASCII string to another Null-terminated ASCII
649 string and returns the new ASCII string.
651 This function copies the contents of the ASCII string Source to the ASCII
652 string Destination, and returns Destination. If Source and Destination
653 overlap, then the results are undefined.
655 If Destination is NULL, then ASSERT().
656 If Source is NULL, then ASSERT().
657 If Source and Destination overlap, then ASSERT().
658 If PcdMaximumAsciiStringLength is not zero and Source contains more than
659 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
662 @param Destination Pointer to a Null-terminated ASCII string.
663 @param Source Pointer to a Null-terminated ASCII string.
671 OUT CHAR8
*Destination
,
672 IN CONST CHAR8
*Source
677 Copies one Null-terminated ASCII string with a maximum length to another
678 Null-terminated ASCII string with a maximum length and returns the new ASCII
681 This function copies the contents of the ASCII string Source to the ASCII
682 string Destination, and returns Destination. At most, Length ASCII characters
683 are copied from Source to Destination. If Length is 0, then Destination is
684 returned unmodified. If Length is greater that the number of ASCII characters
685 in Source, then Destination is padded with Null ASCII characters. If Source
686 and Destination overlap, then the results are undefined.
688 If Destination is NULL, then ASSERT().
689 If Source is NULL, then ASSERT().
690 If Source and Destination overlap, then ASSERT().
691 If PcdMaximumAsciiStringLength is not zero, and Source contains more than
692 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
695 @param Destination Pointer to a Null-terminated ASCII string.
696 @param Source Pointer to a Null-terminated ASCII string.
697 @param Length Maximum number of ASCII characters to copy.
705 OUT CHAR8
*Destination
,
706 IN CONST CHAR8
*Source
,
712 Returns the length of a Null-terminated ASCII string.
714 This function returns the number of ASCII characters in the Null-terminated
715 ASCII string specified by String.
717 If Length > 0 and Destination is NULL, then ASSERT().
718 If Length > 0 and Source is NULL, then ASSERT().
719 If PcdMaximumAsciiStringLength is not zero and String contains more than
720 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
723 @param String Pointer to a Null-terminated ASCII string.
725 @return The length of String.
731 IN CONST CHAR8
*String
736 Returns the size of a Null-terminated ASCII string in bytes, including the
739 This function returns the size, in bytes, of the Null-terminated ASCII string
742 If String is NULL, then ASSERT().
743 If PcdMaximumAsciiStringLength is not zero and String contains more than
744 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
747 @param String Pointer to a Null-terminated ASCII string.
749 @return The size of String.
755 IN CONST CHAR8
*String
760 Compares two Null-terminated ASCII strings, and returns the difference
761 between the first mismatched ASCII characters.
763 This function compares the Null-terminated ASCII string FirstString to the
764 Null-terminated ASCII string SecondString. If FirstString is identical to
765 SecondString, then 0 is returned. Otherwise, the value returned is the first
766 mismatched ASCII character in SecondString subtracted from the first
767 mismatched ASCII character in FirstString.
769 If FirstString is NULL, then ASSERT().
770 If SecondString is NULL, then ASSERT().
771 If PcdMaximumAsciiStringLength is not zero and FirstString contains more than
772 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
774 If PcdMaximumAsciiStringLength is not zero and SecondString contains more
775 than PcdMaximumAsciiStringLength ASCII characters not including the
776 Null-terminator, then ASSERT().
778 @param FirstString Pointer to a Null-terminated ASCII string.
779 @param SecondString Pointer to a Null-terminated ASCII string.
781 @retval 0 FirstString is identical to SecondString.
782 @retval !=0 FirstString is not identical to SecondString.
788 IN CONST CHAR8
*FirstString
,
789 IN CONST CHAR8
*SecondString
794 Performs a case insensitive comparison of two Null-terminated ASCII strings,
795 and returns the difference between the first mismatched ASCII characters.
797 This function performs a case insensitive comparison of the Null-terminated
798 ASCII string FirstString to the Null-terminated ASCII string SecondString. If
799 FirstString is identical to SecondString, then 0 is returned. Otherwise, the
800 value returned is the first mismatched lower case ASCII character in
801 SecondString subtracted from the first mismatched lower case ASCII character
804 If FirstString is NULL, then ASSERT().
805 If SecondString is NULL, then ASSERT().
806 If PcdMaximumAsciiStringLength is not zero and FirstString contains more than
807 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
809 If PcdMaximumAsciiStringLength is not zero and SecondString contains more
810 than PcdMaximumAsciiStringLength ASCII characters not including the
811 Null-terminator, then ASSERT().
813 @param FirstString Pointer to a Null-terminated ASCII string.
814 @param SecondString Pointer to a Null-terminated ASCII string.
816 @retval 0 FirstString is identical to SecondString using case insensitive
818 @retval !=0 FirstString is not identical to SecondString using case
819 insensitive comparisons.
825 IN CONST CHAR8
*FirstString
,
826 IN CONST CHAR8
*SecondString
831 Compares two Null-terminated ASCII strings with maximum lengths, and returns
832 the difference between the first mismatched ASCII characters.
834 This function compares the Null-terminated ASCII string FirstString to the
835 Null-terminated ASCII string SecondString. At most, Length ASCII characters
836 will be compared. If Length is 0, then 0 is returned. If FirstString is
837 identical to SecondString, then 0 is returned. Otherwise, the value returned
838 is the first mismatched ASCII character in SecondString subtracted from the
839 first mismatched ASCII character in FirstString.
841 If Length > 0 and FirstString is NULL, then ASSERT().
842 If Length > 0 and SecondString is NULL, then ASSERT().
843 If PcdMaximumAsciiStringLength is not zero and FirstString contains more than
844 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
846 If PcdMaximumAsciiStringLength is not zero and SecondString contains more than
847 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
850 @param FirstString Pointer to a Null-terminated ASCII string.
851 @param SecondString Pointer to a Null-terminated ASCII string.
853 @retval 0 FirstString is identical to SecondString.
854 @retval !=0 FirstString is not identical to SecondString.
860 IN CONST CHAR8
*FirstString
,
861 IN CONST CHAR8
*SecondString
,
867 Concatenates one Null-terminated ASCII string to another Null-terminated
868 ASCII string, and returns the concatenated ASCII string.
870 This function concatenates two Null-terminated ASCII strings. The contents of
871 Null-terminated ASCII string Source are concatenated to the end of Null-
872 terminated ASCII string Destination. The Null-terminated concatenated ASCII
875 If Destination is NULL, then ASSERT().
876 If Source is NULL, then ASSERT().
877 If PcdMaximumAsciiStringLength is not zero and Destination contains more than
878 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
880 If PcdMaximumAsciiStringLength is not zero and Source contains more than
881 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
883 If PcdMaximumAsciiStringLength is not zero and concatenating Destination and
884 Source results in a ASCII string with more than PcdMaximumAsciiStringLength
885 ASCII characters, then ASSERT().
887 @param Destination Pointer to a Null-terminated ASCII string.
888 @param Source Pointer to a Null-terminated ASCII string.
896 IN OUT CHAR8
*Destination
,
897 IN CONST CHAR8
*Source
902 Concatenates one Null-terminated ASCII string with a maximum length to the
903 end of another Null-terminated ASCII string, and returns the concatenated
906 This function concatenates two Null-terminated ASCII strings. The contents
907 of Null-terminated ASCII string Source are concatenated to the end of Null-
908 terminated ASCII string Destination, and Destination is returned. At most,
909 Length ASCII characters are concatenated from Source to the end of
910 Destination, and Destination is always Null-terminated. If Length is 0, then
911 Destination is returned unmodified. If Source and Destination overlap, then
912 the results are undefined.
914 If Length > 0 and Destination is NULL, then ASSERT().
915 If Length > 0 and Source is NULL, then ASSERT().
916 If Source and Destination overlap, then ASSERT().
917 If PcdMaximumAsciiStringLength is not zero, and Destination contains more than
918 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
920 If PcdMaximumAsciiStringLength is not zero, and Source contains more than
921 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
923 If PcdMaximumAsciiStringLength is not zero, and concatenating Destination and
924 Source results in a ASCII string with more than PcdMaximumAsciiStringLength
925 ASCII characters not including the Null-terminator, then ASSERT().
927 @param Destination Pointer to a Null-terminated ASCII string.
928 @param Source Pointer to a Null-terminated ASCII string.
929 @param Length Maximum number of ASCII characters to concatenate from
938 IN OUT CHAR8
*Destination
,
939 IN CONST CHAR8
*Source
,
945 Returns the first occurance of a Null-terminated ASCII sub-string
946 in a Null-terminated ASCII string.
948 This function scans the contents of the ASCII string specified by String
949 and returns the first occurrence of SearchString. If SearchString is not
950 found in String, then NULL is returned. If the length of SearchString is zero,
951 then String is returned.
953 If String is NULL, then ASSERT().
954 If SearchString is NULL, then ASSERT().
956 If PcdMaximumAsciiStringLength is not zero, and SearchString or
957 String contains more than PcdMaximumAsciiStringLength Unicode characters
958 not including the Null-terminator, then ASSERT().
960 @param String Pointer to a Null-terminated ASCII string.
961 @param SearchString Pointer to a Null-terminated ASCII string to search for.
963 @retval NULL If the SearchString does not appear in String.
964 @retval !NULL If there is a match.
970 IN CONST CHAR8
*String
,
971 IN CONST CHAR8
*SearchString
976 Convert a Null-terminated ASCII decimal string to a value of type
979 This function returns a value of type UINTN by interpreting the contents
980 of the ASCII string String as a decimal number. The format of the input
981 ASCII string String is:
983 [spaces] [decimal digits].
985 The valid decimal digit character is in the range [0-9]. The function will
986 ignore the pad space, which includes spaces or tab characters, before the digits.
987 The running zero in the beginning of [decimal digits] will be ignored. Then, the
988 function stops at the first character that is a not a valid decimal character or
989 Null-terminator, whichever on comes first.
991 If String has only pad spaces, then 0 is returned.
992 If String has no pad spaces or valid decimal digits, then 0 is returned.
993 If the number represented by String overflows according to the range defined by
994 UINTN, then ASSERT().
995 If String is NULL, then ASSERT().
996 If PcdMaximumAsciiStringLength is not zero, and String contains more than
997 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
1000 @param String Pointer to a Null-terminated ASCII string.
1007 AsciiStrDecimalToUintn (
1008 IN CONST CHAR8
*String
1013 Convert a Null-terminated ASCII decimal string to a value of type
1016 This function returns a value of type UINT64 by interpreting the contents
1017 of the ASCII string String as a decimal number. The format of the input
1018 ASCII string String is:
1020 [spaces] [decimal digits].
1022 The valid decimal digit character is in the range [0-9]. The function will
1023 ignore the pad space, which includes spaces or tab characters, before the digits.
1024 The running zero in the beginning of [decimal digits] will be ignored. Then, the
1025 function stops at the first character that is a not a valid decimal character or
1026 Null-terminator, whichever on comes first.
1028 If String has only pad spaces, then 0 is returned.
1029 If String has no pad spaces or valid decimal digits, then 0 is returned.
1030 If the number represented by String overflows according to the range defined by
1031 UINT64, then ASSERT().
1032 If String is NULL, then ASSERT().
1033 If PcdMaximumAsciiStringLength is not zero, and String contains more than
1034 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
1037 @param String Pointer to a Null-terminated ASCII string.
1044 AsciiStrDecimalToUint64 (
1045 IN CONST CHAR8
*String
1050 Convert a Null-terminated ASCII hexadecimal string to a value of type UINTN.
1052 This function returns a value of type UINTN by interpreting the contents of
1053 the ASCII string String as a hexadecimal number. The format of the input ASCII
1056 [spaces][zeros][x][hexadecimal digits].
1058 The valid hexadecimal digit character is in the range [0-9], [a-f] and [A-F].
1059 The prefix "0x" is optional. Both "x" and "X" is allowed in "0x" prefix. If "x"
1060 appears in the input string, it must be prefixed with at least one 0. The function
1061 will ignore the pad space, which includes spaces or tab characters, before [zeros],
1062 [x] or [hexadecimal digits]. The running zero before [x] or [hexadecimal digits]
1063 will be ignored. Then, the decoding starts after [x] or the first valid hexadecimal
1064 digit. Then, the function stops at the first character that is a not a valid
1065 hexadecimal character or Null-terminator, whichever on comes first.
1067 If String has only pad spaces, then 0 is returned.
1068 If String has no leading pad spaces, leading zeros or valid hexadecimal digits, then
1071 If the number represented by String overflows according to the range defined by UINTN,
1073 If String is NULL, then ASSERT().
1074 If PcdMaximumAsciiStringLength is not zero,
1075 and String contains more than PcdMaximumAsciiStringLength ASCII characters not including
1076 the Null-terminator, then ASSERT().
1078 @param String Pointer to a Null-terminated ASCII string.
1085 AsciiStrHexToUintn (
1086 IN CONST CHAR8
*String
1091 Convert a Null-terminated ASCII hexadecimal string to a value of type UINT64.
1093 This function returns a value of type UINT64 by interpreting the contents of
1094 the ASCII string String as a hexadecimal number. The format of the input ASCII
1097 [spaces][zeros][x][hexadecimal digits].
1099 The valid hexadecimal digit character is in the range [0-9], [a-f] and [A-F].
1100 The prefix "0x" is optional. Both "x" and "X" is allowed in "0x" prefix. If "x"
1101 appears in the input string, it must be prefixed with at least one 0. The function
1102 will ignore the pad space, which includes spaces or tab characters, before [zeros],
1103 [x] or [hexadecimal digits]. The running zero before [x] or [hexadecimal digits]
1104 will be ignored. Then, the decoding starts after [x] or the first valid hexadecimal
1105 digit. Then, the function stops at the first character that is a not a valid
1106 hexadecimal character or Null-terminator, whichever on comes first.
1108 If String has only pad spaces, then 0 is returned.
1109 If String has no leading pad spaces, leading zeros or valid hexadecimal digits, then
1112 If the number represented by String overflows according to the range defined by UINT64,
1114 If String is NULL, then ASSERT().
1115 If PcdMaximumAsciiStringLength is not zero,
1116 and String contains more than PcdMaximumAsciiStringLength ASCII characters not including
1117 the Null-terminator, then ASSERT().
1119 @param String Pointer to a Null-terminated ASCII string.
1126 AsciiStrHexToUint64 (
1127 IN CONST CHAR8
*String
1132 Convert one Null-terminated ASCII string to a Null-terminated
1133 Unicode string and returns the Unicode string.
1135 This function converts the contents of the ASCII string Source to the Unicode
1136 string Destination, and returns Destination. The function terminates the
1137 Unicode string Destination by appending a Null-terminator character at the end.
1138 The caller is responsible to make sure Destination points to a buffer with size
1139 equal or greater than ((AsciiStrLen (Source) + 1) * sizeof (CHAR16)) in bytes.
1141 If Destination is NULL, then ASSERT().
1142 If Destination is not aligned on a 16-bit boundary, then ASSERT().
1143 If Source is NULL, then ASSERT().
1144 If Source and Destination overlap, then ASSERT().
1145 If PcdMaximumAsciiStringLength is not zero, and Source contains more than
1146 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
1148 If PcdMaximumUnicodeStringLength is not zero, and Source contains more than
1149 PcdMaximumUnicodeStringLength ASCII characters not including the
1150 Null-terminator, then ASSERT().
1152 @param Source Pointer to a Null-terminated ASCII string.
1153 @param Destination Pointer to a Null-terminated Unicode string.
1160 AsciiStrToUnicodeStr (
1161 IN CONST CHAR8
*Source
,
1162 OUT CHAR16
*Destination
1167 Converts an 8-bit value to an 8-bit BCD value.
1169 Converts the 8-bit value specified by Value to BCD. The BCD value is
1172 If Value >= 100, then ASSERT().
1174 @param Value The 8-bit value to convert to BCD. Range 0..99.
1176 @return The BCD value
1187 Converts an 8-bit BCD value to an 8-bit value.
1189 Converts the 8-bit BCD value specified by Value to an 8-bit value. The 8-bit
1192 If Value >= 0xA0, then ASSERT().
1193 If (Value & 0x0F) >= 0x0A, then ASSERT().
1195 @param Value The 8-bit BCD value to convert to an 8-bit value.
1197 @return The 8-bit value is returned.
1208 // Linked List Functions and Macros
1212 Initializes the head node of a doubly linked list that is declared as a
1213 global variable in a module.
1215 Initializes the forward and backward links of a new linked list. After
1216 initializing a linked list with this macro, the other linked list functions
1217 may be used to add and remove nodes from the linked list. This macro results
1218 in smaller executables by initializing the linked list in the data section,
1219 instead if calling the InitializeListHead() function to perform the
1220 equivalent operation.
1222 @param ListHead The head note of a list to initiailize.
1225 #define INITIALIZE_LIST_HEAD_VARIABLE(ListHead) {&ListHead, &ListHead}
1229 Initializes the head node of a doubly linked list, and returns the pointer to
1230 the head node of the doubly linked list.
1232 Initializes the forward and backward links of a new linked list. After
1233 initializing a linked list with this function, the other linked list
1234 functions may be used to add and remove nodes from the linked list. It is up
1235 to the caller of this function to allocate the memory for ListHead.
1237 If ListHead is NULL, then ASSERT().
1239 @param ListHead A pointer to the head node of a new doubly linked list.
1246 InitializeListHead (
1247 IN LIST_ENTRY
*ListHead
1252 Adds a node to the beginning of a doubly linked list, and returns the pointer
1253 to the head node of the doubly linked list.
1255 Adds the node Entry at the beginning of the doubly linked list denoted by
1256 ListHead, and returns ListHead.
1258 If ListHead is NULL, then ASSERT().
1259 If Entry is NULL, then ASSERT().
1260 If ListHead was not initialized with InitializeListHead(), then ASSERT().
1261 If PcdMaximumLinkedListLenth is not zero, and prior to insertion the number
1262 of nodes in ListHead, including the ListHead node, is greater than or
1263 equal to PcdMaximumLinkedListLength, then ASSERT().
1265 @param ListHead A pointer to the head node of a doubly linked list.
1266 @param Entry A pointer to a node that is to be inserted at the beginning
1267 of a doubly linked list.
1275 IN LIST_ENTRY
*ListHead
,
1276 IN LIST_ENTRY
*Entry
1281 Adds a node to the end of a doubly linked list, and returns the pointer to
1282 the head node of the doubly linked list.
1284 Adds the node Entry to the end of the doubly linked list denoted by ListHead,
1285 and returns ListHead.
1287 If ListHead is NULL, then ASSERT().
1288 If Entry is NULL, then ASSERT().
1289 If ListHead was not initialized with InitializeListHead(), then ASSERT().
1290 If PcdMaximumLinkedListLenth is not zero, and prior to insertion the number
1291 of nodes in ListHead, including the ListHead node, is greater than or
1292 equal to PcdMaximumLinkedListLength, then ASSERT().
1294 @param ListHead A pointer to the head node of a doubly linked list.
1295 @param Entry A pointer to a node that is to be added at the end of the
1304 IN LIST_ENTRY
*ListHead
,
1305 IN LIST_ENTRY
*Entry
1310 Retrieves the first node of a doubly linked list.
1312 Returns the first node of a doubly linked list. List must have been
1313 initialized with InitializeListHead(). If List is empty, then NULL is
1316 If List is NULL, then ASSERT().
1317 If List was not initialized with 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. List must have
1339 been initialized with InitializeListHead(). If List is empty, then List is
1342 If List is NULL, then ASSERT().
1343 If Node is NULL, then ASSERT().
1344 If List was not initialized with InitializeListHead(), then ASSERT().
1345 If PcdMaximumLinkedListLenth is not zero, and List contains more than
1346 PcdMaximumLinkedListLenth nodes, then ASSERT().
1347 If Node is not a node in List, then ASSERT().
1349 @param List A pointer to the head node of a doubly linked list.
1350 @param Node A pointer to a node in the doubly linked list.
1352 @return Pointer to the next node if one exists. Otherwise a null value which
1353 is actually List is returned.
1359 IN CONST LIST_ENTRY
*List
,
1360 IN CONST LIST_ENTRY
*Node
1365 Checks to see if a doubly linked list is empty or not.
1367 Checks to see if the doubly linked list is empty. If the linked list contains
1368 zero nodes, this function returns TRUE. Otherwise, it returns FALSE.
1370 If ListHead is NULL, then ASSERT().
1371 If ListHead was not initialized with InitializeListHead(), then ASSERT().
1372 If PcdMaximumLinkedListLenth is not zero, and the number of nodes
1373 in List, including the List node, is greater than or equal to
1374 PcdMaximumLinkedListLength, then ASSERT().
1376 @param ListHead A pointer to the head node of a doubly linked list.
1378 @retval TRUE The linked list is empty.
1379 @retval FALSE The linked list is not empty.
1385 IN CONST LIST_ENTRY
*ListHead
1390 Determines if a node in a doubly linked list is null.
1392 Returns FALSE if Node is one of the nodes in the doubly linked list specified
1393 by List. Otherwise, TRUE is returned. List must have been initialized with
1394 InitializeListHead().
1396 If List is NULL, then ASSERT().
1397 If Node is NULL, then ASSERT().
1398 If List was not initialized with InitializeListHead(), then ASSERT().
1399 If PcdMaximumLinkedListLenth is not zero, and the number of nodes
1400 in List, including the List node, is greater than or equal to
1401 PcdMaximumLinkedListLength, then ASSERT().
1402 If Node is not a node in List and Node is not equal to List, then ASSERT().
1404 @param List A pointer to the head node of a doubly linked list.
1405 @param Node A pointer to a node in the doubly linked list.
1407 @retval TRUE Node is one of the nodes in the doubly linked list.
1408 @retval FALSE Node is not one of the nodes in the doubly linked list.
1414 IN CONST LIST_ENTRY
*List
,
1415 IN CONST LIST_ENTRY
*Node
1420 Determines if a node the last node in a doubly linked list.
1422 Returns TRUE if Node is the last node in the doubly linked list specified by
1423 List. Otherwise, FALSE is returned. List must have been initialized with
1424 InitializeListHead().
1426 If List is NULL, then ASSERT().
1427 If Node is NULL, then ASSERT().
1428 If List was not initialized with InitializeListHead(), then ASSERT().
1429 If PcdMaximumLinkedListLenth is not zero, and the number of nodes
1430 in List, including the List node, is greater than or equal to
1431 PcdMaximumLinkedListLength, then ASSERT().
1432 If Node is not a node in List, then ASSERT().
1434 @param List A pointer to the head node of a doubly linked list.
1435 @param Node A pointer to a node in the doubly linked list.
1437 @retval TRUE Node is the last node in the linked list.
1438 @retval FALSE Node is not the last node in the linked list.
1444 IN CONST LIST_ENTRY
*List
,
1445 IN CONST LIST_ENTRY
*Node
1450 Swaps the location of two nodes in a doubly linked list, and returns the
1451 first node after the swap.
1453 If FirstEntry is identical to SecondEntry, then SecondEntry is returned.
1454 Otherwise, the location of the FirstEntry node is swapped with the location
1455 of the SecondEntry node in a doubly linked list. SecondEntry must be in the
1456 same double linked list as FirstEntry and that double linked list must have
1457 been initialized with InitializeListHead(). SecondEntry is returned after the
1460 If FirstEntry is NULL, then ASSERT().
1461 If SecondEntry is NULL, then ASSERT().
1462 If SecondEntry and FirstEntry are not in the same linked list, then ASSERT().
1463 If PcdMaximumLinkedListLength is not zero, and the number of nodes in the
1464 linked list containing the FirstEntry and SecondEntry nodes, including
1465 the FirstEntry and SecondEntry nodes, is greater than or equal to
1466 PcdMaximumLinkedListLength, then ASSERT().
1468 @param FirstEntry A pointer to a node in a linked list.
1469 @param SecondEntry A pointer to another node in the same linked list.
1475 IN LIST_ENTRY
*FirstEntry
,
1476 IN LIST_ENTRY
*SecondEntry
1481 Removes a node from a doubly linked list, and returns the node that follows
1484 Removes the node Entry from a doubly linked list. It is up to the caller of
1485 this function to release the memory used by this node if that is required. On
1486 exit, the node following Entry in the doubly linked list is returned. If
1487 Entry is the only node in the linked list, then the head node of the linked
1490 If Entry is NULL, then ASSERT().
1491 If Entry is the head node of an empty list, then ASSERT().
1492 If PcdMaximumLinkedListLength is not zero, and the number of nodes in the
1493 linked list containing Entry, including the Entry node, is greater than
1494 or equal to PcdMaximumLinkedListLength, then ASSERT().
1496 @param Entry A pointer to a node in a linked list
1504 IN CONST LIST_ENTRY
*Entry
1512 Shifts a 64-bit integer left between 0 and 63 bits. The low bits are filled
1513 with zeros. The shifted value is returned.
1515 This function shifts the 64-bit value Operand to the left by Count bits. The
1516 low Count bits are set to zero. The shifted value is returned.
1518 If Count is greater than 63, then ASSERT().
1520 @param Operand The 64-bit operand to shift left.
1521 @param Count The number of bits to shift left.
1523 @return Operand << Count
1535 Shifts a 64-bit integer right between 0 and 63 bits. This high bits are
1536 filled with zeros. The shifted value is returned.
1538 This function shifts the 64-bit value Operand to the right by Count bits. The
1539 high Count bits are set to zero. The shifted value is returned.
1541 If Count is greater than 63, then ASSERT().
1543 @param Operand The 64-bit operand to shift right.
1544 @param Count The number of bits to shift right.
1546 @return Operand >> Count
1558 Shifts a 64-bit integer right between 0 and 63 bits. The high bits are filled
1559 with original integer's bit 63. The shifted value is returned.
1561 This function shifts the 64-bit value Operand to the right by Count bits. The
1562 high Count bits are set to bit 63 of Operand. The shifted value is returned.
1564 If Count is greater than 63, then ASSERT().
1566 @param Operand The 64-bit operand to shift right.
1567 @param Count The number of bits to shift right.
1569 @return Operand >> Count
1581 Rotates a 32-bit integer left between 0 and 31 bits, filling the low bits
1582 with the high bits that were rotated.
1584 This function rotates the 32-bit value Operand to the left by Count bits. The
1585 low Count bits are fill with the high Count bits of Operand. The rotated
1588 If Count is greater than 31, then ASSERT().
1590 @param Operand The 32-bit operand to rotate left.
1591 @param Count The number of bits to rotate left.
1593 @return Operand <<< Count
1605 Rotates a 32-bit integer right between 0 and 31 bits, filling the high bits
1606 with the low bits that were rotated.
1608 This function rotates the 32-bit value Operand to the right by Count bits.
1609 The high Count bits are fill with the low Count bits of Operand. The rotated
1612 If Count is greater than 31, then ASSERT().
1614 @param Operand The 32-bit operand to rotate right.
1615 @param Count The number of bits to rotate right.
1617 @return Operand >>> Count
1629 Rotates a 64-bit integer left between 0 and 63 bits, filling the low bits
1630 with the high bits that were rotated.
1632 This function rotates the 64-bit value Operand to the left by Count bits. The
1633 low Count bits are fill with the high Count bits of Operand. The rotated
1636 If Count is greater than 63, then ASSERT().
1638 @param Operand The 64-bit operand to rotate left.
1639 @param Count The number of bits to rotate left.
1641 @return Operand <<< Count
1653 Rotates a 64-bit integer right between 0 and 63 bits, filling the high bits
1654 with the high low bits that were rotated.
1656 This function rotates the 64-bit value Operand to the right by Count bits.
1657 The high Count bits are fill with the low Count bits of Operand. The rotated
1660 If Count is greater than 63, then ASSERT().
1662 @param Operand The 64-bit operand to rotate right.
1663 @param Count The number of bits to rotate right.
1665 @return Operand >>> Count
1677 Returns the bit position of the lowest bit set in a 32-bit value.
1679 This function computes the bit position of the lowest bit set in the 32-bit
1680 value specified by Operand. If Operand is zero, then -1 is returned.
1681 Otherwise, a value between 0 and 31 is returned.
1683 @param Operand The 32-bit operand to evaluate.
1685 @return Position of the lowest bit set in Operand if found.
1686 @retval -1 Operand is zero.
1697 Returns the bit position of the lowest bit set in a 64-bit value.
1699 This function computes the bit position of the lowest bit set in the 64-bit
1700 value specified by Operand. If Operand is zero, then -1 is returned.
1701 Otherwise, a value between 0 and 63 is returned.
1703 @param Operand The 64-bit operand to evaluate.
1705 @return Position of the lowest bit set in Operand if found.
1706 @retval -1 Operand is zero.
1717 Returns the bit position of the highest bit set in a 32-bit value. Equivalent
1720 This function computes the bit position of the highest bit set in the 32-bit
1721 value specified by Operand. If Operand is zero, then -1 is returned.
1722 Otherwise, a value between 0 and 31 is returned.
1724 @param Operand The 32-bit operand to evaluate.
1726 @return Position of the highest bit set in Operand if found.
1727 @retval -1 Operand is zero.
1738 Returns the bit position of the highest bit set in a 64-bit value. Equivalent
1741 This function computes the bit position of the highest bit set in the 64-bit
1742 value specified by Operand. If Operand is zero, then -1 is returned.
1743 Otherwise, a value between 0 and 63 is returned.
1745 @param Operand The 64-bit operand to evaluate.
1747 @return Position of the highest bit set in Operand if found.
1748 @retval -1 Operand is zero.
1759 Returns the value of the highest bit set in a 32-bit value. Equivalent to
1760 1 << HighBitSet32(x).
1762 This function computes the value of the highest bit set in the 32-bit value
1763 specified by Operand. If Operand is zero, then zero is returned.
1765 @param Operand The 32-bit operand to evaluate.
1767 @return 1 << HighBitSet32(Operand)
1768 @retval 0 Operand is zero.
1779 Returns the value of the highest bit set in a 64-bit value. Equivalent to
1780 1 << HighBitSet64(x).
1782 This function computes the value of the highest bit set in the 64-bit value
1783 specified by Operand. If Operand is zero, then zero is returned.
1785 @param Operand The 64-bit operand to evaluate.
1787 @return 1 << HighBitSet64(Operand)
1788 @retval 0 Operand is zero.
1799 Switches the endianess of a 16-bit integer.
1801 This function swaps the bytes in a 16-bit unsigned value to switch the value
1802 from little endian to big endian or vice versa. The byte swapped value is
1805 @param Operand A 16-bit unsigned value.
1807 @return The byte swaped Operand.
1818 Switches the endianess of a 32-bit integer.
1820 This function swaps the bytes in a 32-bit unsigned value to switch the value
1821 from little endian to big endian or vice versa. The byte swapped value is
1824 @param Operand A 32-bit unsigned value.
1826 @return The byte swaped Operand.
1837 Switches the endianess of a 64-bit integer.
1839 This function swaps the bytes in a 64-bit unsigned value to switch the value
1840 from little endian to big endian or vice versa. The byte swapped value is
1843 @param Operand A 64-bit unsigned value.
1845 @return The byte swaped Operand.
1856 Multiples a 64-bit unsigned integer by a 32-bit unsigned integer and
1857 generates a 64-bit unsigned result.
1859 This function multiples the 64-bit unsigned value Multiplicand by the 32-bit
1860 unsigned value Multiplier and generates a 64-bit unsigned result. This 64-
1861 bit unsigned result is returned.
1863 If the result overflows, then ASSERT().
1865 @param Multiplicand A 64-bit unsigned value.
1866 @param Multiplier A 32-bit unsigned value.
1868 @return Multiplicand * Multiplier
1874 IN UINT64 Multiplicand
,
1875 IN UINT32 Multiplier
1880 Multiples a 64-bit unsigned integer by a 64-bit unsigned integer and
1881 generates a 64-bit unsigned result.
1883 This function multiples the 64-bit unsigned value Multiplicand by the 64-bit
1884 unsigned value Multiplier and generates a 64-bit unsigned result. This 64-
1885 bit unsigned result is returned.
1887 If the result overflows, then ASSERT().
1889 @param Multiplicand A 64-bit unsigned value.
1890 @param Multiplier A 64-bit unsigned value.
1892 @return Multiplicand * Multiplier
1898 IN UINT64 Multiplicand
,
1899 IN UINT64 Multiplier
1904 Multiples a 64-bit signed integer by a 64-bit signed integer and generates a
1905 64-bit signed result.
1907 This function multiples the 64-bit signed value Multiplicand by the 64-bit
1908 signed value Multiplier and generates a 64-bit signed result. This 64-bit
1909 signed result is returned.
1911 If the result overflows, then ASSERT().
1913 @param Multiplicand A 64-bit signed value.
1914 @param Multiplier A 64-bit signed value.
1916 @return Multiplicand * Multiplier
1922 IN INT64 Multiplicand
,
1928 Divides a 64-bit unsigned integer by a 32-bit unsigned integer and generates
1929 a 64-bit unsigned result.
1931 This function divides the 64-bit unsigned value Dividend by the 32-bit
1932 unsigned value Divisor and generates a 64-bit unsigned quotient. This
1933 function returns the 64-bit unsigned quotient.
1935 If Divisor is 0, then ASSERT().
1937 @param Dividend A 64-bit unsigned value.
1938 @param Divisor A 32-bit unsigned value.
1940 @return Dividend / Divisor
1952 Divides a 64-bit unsigned integer by a 32-bit unsigned integer and generates
1953 a 32-bit unsigned remainder.
1955 This function divides the 64-bit unsigned value Dividend by the 32-bit
1956 unsigned value Divisor and generates a 32-bit remainder. This function
1957 returns the 32-bit unsigned remainder.
1959 If Divisor is 0, then ASSERT().
1961 @param Dividend A 64-bit unsigned value.
1962 @param Divisor A 32-bit unsigned value.
1964 @return Dividend % Divisor
1976 Divides a 64-bit unsigned integer by a 32-bit unsigned integer and generates
1977 a 64-bit unsigned result and an optional 32-bit unsigned remainder.
1979 This function divides the 64-bit unsigned value Dividend by the 32-bit
1980 unsigned value Divisor and generates a 64-bit unsigned quotient. If Remainder
1981 is not NULL, then the 32-bit unsigned remainder is returned in Remainder.
1982 This function returns the 64-bit unsigned quotient.
1984 If Divisor is 0, then ASSERT().
1986 @param Dividend A 64-bit unsigned value.
1987 @param Divisor A 32-bit unsigned value.
1988 @param Remainder A pointer to a 32-bit unsigned value. This parameter is
1989 optional and may be NULL.
1991 @return Dividend / Divisor
1996 DivU64x32Remainder (
1999 OUT UINT32
*Remainder OPTIONAL
2004 Divides a 64-bit unsigned integer by a 64-bit unsigned integer and generates
2005 a 64-bit unsigned result and an optional 64-bit unsigned remainder.
2007 This function divides the 64-bit unsigned value Dividend by the 64-bit
2008 unsigned value Divisor and generates a 64-bit unsigned quotient. If Remainder
2009 is not NULL, then the 64-bit unsigned remainder is returned in Remainder.
2010 This function returns the 64-bit unsigned quotient.
2012 If Divisor is 0, then ASSERT().
2014 @param Dividend A 64-bit unsigned value.
2015 @param Divisor A 64-bit unsigned value.
2016 @param Remainder A pointer to a 64-bit unsigned value. This parameter is
2017 optional and may be NULL.
2019 @return Dividend / Divisor
2024 DivU64x64Remainder (
2027 OUT UINT64
*Remainder OPTIONAL
2032 Divides a 64-bit signed integer by a 64-bit signed integer and generates a
2033 64-bit signed result and a optional 64-bit signed remainder.
2035 This function divides the 64-bit signed value Dividend by the 64-bit signed
2036 value Divisor and generates a 64-bit signed quotient. If Remainder is not
2037 NULL, then the 64-bit signed remainder is returned in Remainder. This
2038 function returns the 64-bit signed quotient.
2040 If Divisor is 0, then ASSERT().
2042 @param Dividend A 64-bit signed value.
2043 @param Divisor A 64-bit signed value.
2044 @param Remainder A pointer to a 64-bit signed value. This parameter is
2045 optional and may be NULL.
2047 @return Dividend / Divisor
2052 DivS64x64Remainder (
2055 OUT INT64
*Remainder OPTIONAL
2060 Reads a 16-bit value from memory that may be unaligned.
2062 This function returns the 16-bit value pointed to by Buffer. The function
2063 guarantees that the read operation does not produce an alignment fault.
2065 If the Buffer is NULL, then ASSERT().
2067 @param Buffer Pointer to a 16-bit value that may be unaligned.
2075 IN CONST UINT16
*Uint16
2080 Writes a 16-bit value to memory that may be unaligned.
2082 This function writes the 16-bit value specified by Value to Buffer. Value is
2083 returned. The function guarantees that the write operation does not produce
2086 If the Buffer is NULL, then ASSERT().
2088 @param Buffer Pointer to a 16-bit value that may be unaligned.
2089 @param Value 16-bit value to write to Buffer.
2103 Reads a 24-bit value from memory that may be unaligned.
2105 This function returns the 24-bit value pointed to by Buffer. The function
2106 guarantees that the read operation does not produce an alignment fault.
2108 If the Buffer is NULL, then ASSERT().
2110 @param Buffer Pointer to a 24-bit value that may be unaligned.
2112 @return The value read.
2118 IN CONST UINT32
*Buffer
2123 Writes a 24-bit value to memory that may be unaligned.
2125 This function writes the 24-bit value specified by Value to Buffer. Value is
2126 returned. The function guarantees that the write operation does not produce
2129 If the Buffer is NULL, then ASSERT().
2131 @param Buffer Pointer to a 24-bit value that may be unaligned.
2132 @param Value 24-bit value to write to Buffer.
2134 @return The value written.
2146 Reads a 32-bit value from memory that may be unaligned.
2148 This function returns the 32-bit value pointed to by Buffer. The function
2149 guarantees that the read operation does not produce an alignment fault.
2151 If the Buffer is NULL, then ASSERT().
2153 @param Buffer Pointer to a 32-bit value that may be unaligned.
2161 IN CONST UINT32
*Uint32
2166 Writes a 32-bit value to memory that may be unaligned.
2168 This function writes the 32-bit value specified by Value to Buffer. Value is
2169 returned. The function guarantees that the write operation does not produce
2172 If the Buffer is NULL, then ASSERT().
2174 @param Buffer Pointer to a 32-bit value that may be unaligned.
2175 @param Value 32-bit value to write to Buffer.
2189 Reads a 64-bit value from memory that may be unaligned.
2191 This function returns the 64-bit value pointed to by Buffer. The function
2192 guarantees that the read operation does not produce an alignment fault.
2194 If the Buffer is NULL, then ASSERT().
2196 @param Buffer Pointer to a 64-bit value that may be unaligned.
2204 IN CONST UINT64
*Uint64
2209 Writes a 64-bit value to memory that may be unaligned.
2211 This function writes the 64-bit value specified by Value to Buffer. Value is
2212 returned. The function guarantees that the write operation does not produce
2215 If the Buffer is NULL, then ASSERT().
2217 @param Buffer Pointer to a 64-bit value that may be unaligned.
2218 @param Value 64-bit value to write to Buffer.
2232 // Bit Field Functions
2236 Returns a bit field from an 8-bit value.
2238 Returns the bitfield specified by the StartBit and the EndBit from Operand.
2240 If 8-bit operations are not supported, then ASSERT().
2241 If StartBit is greater than 7, then ASSERT().
2242 If EndBit is greater than 7, then ASSERT().
2243 If EndBit is less than StartBit, then ASSERT().
2245 @param Operand Operand on which to perform the bitfield operation.
2246 @param StartBit The ordinal of the least significant bit in the bit field.
2248 @param EndBit The ordinal of the most significant bit in the bit field.
2251 @return The bit field read.
2264 Writes a bit field to an 8-bit value, and returns the result.
2266 Writes Value to the bit field specified by the StartBit and the EndBit in
2267 Operand. All other bits in Operand are preserved. The new 8-bit value is
2270 If 8-bit operations are not supported, then ASSERT().
2271 If StartBit is greater than 7, then ASSERT().
2272 If EndBit is greater than 7, then ASSERT().
2273 If EndBit is less than StartBit, then ASSERT().
2275 @param Operand Operand on which to perform the bitfield operation.
2276 @param StartBit The ordinal of the least significant bit in the bit field.
2278 @param EndBit The ordinal of the most significant bit in the bit field.
2280 @param Value New value of the bit field.
2282 @return The new 8-bit value.
2296 Reads a bit field from an 8-bit value, performs a bitwise OR, and returns the
2299 Performs a bitwise inclusive OR between the bit field specified by StartBit
2300 and EndBit in Operand and the value specified by OrData. All other bits in
2301 Operand are preserved. The new 8-bit value is returned.
2303 If 8-bit operations are not supported, then ASSERT().
2304 If StartBit is greater than 7, then ASSERT().
2305 If EndBit is greater than 7, then ASSERT().
2306 If EndBit is less than StartBit, then ASSERT().
2308 @param Operand Operand on which to perform the bitfield operation.
2309 @param StartBit The ordinal of the least significant bit in the bit field.
2311 @param EndBit The ordinal of the most significant bit in the bit field.
2313 @param OrData The value to OR with the read value from the value
2315 @return The new 8-bit value.
2329 Reads a bit field from an 8-bit value, performs a bitwise AND, and returns
2332 Performs a bitwise AND between the bit field specified by StartBit and EndBit
2333 in Operand and the value specified by AndData. All other bits in Operand are
2334 preserved. The new 8-bit value is returned.
2336 If 8-bit operations are not supported, then ASSERT().
2337 If StartBit is greater than 7, then ASSERT().
2338 If EndBit is greater than 7, then ASSERT().
2339 If EndBit is less than StartBit, then ASSERT().
2341 @param Operand Operand on which to perform the bitfield operation.
2342 @param StartBit The ordinal of the least significant bit in the bit field.
2344 @param EndBit The ordinal of the most significant bit in the bit field.
2346 @param AndData The value to AND with the read value from the value.
2348 @return The new 8-bit value.
2362 Reads a bit field from an 8-bit value, performs a bitwise AND followed by a
2363 bitwise OR, and returns the result.
2365 Performs a bitwise AND between the bit field specified by StartBit and EndBit
2366 in Operand and the value specified by AndData, followed by a bitwise
2367 inclusive OR with value specified by OrData. All other bits in Operand are
2368 preserved. The new 8-bit value is returned.
2370 If 8-bit operations are not supported, then ASSERT().
2371 If StartBit is greater than 7, then ASSERT().
2372 If EndBit is greater than 7, then ASSERT().
2373 If EndBit is less than StartBit, then ASSERT().
2375 @param Operand Operand on which to perform the bitfield operation.
2376 @param StartBit The ordinal of the least significant bit in the bit field.
2378 @param EndBit The ordinal of the most significant bit in the bit field.
2380 @param AndData The value to AND with the read value from the value.
2381 @param OrData The value to OR with the result of the AND operation.
2383 @return The new 8-bit value.
2388 BitFieldAndThenOr8 (
2398 Returns a bit field from a 16-bit value.
2400 Returns the bitfield specified by the StartBit and the EndBit from Operand.
2402 If 16-bit operations are not supported, then ASSERT().
2403 If StartBit is greater than 15, then ASSERT().
2404 If EndBit is greater than 15, then ASSERT().
2405 If EndBit is less than StartBit, then ASSERT().
2407 @param Operand Operand on which to perform the bitfield operation.
2408 @param StartBit The ordinal of the least significant bit in the bit field.
2410 @param EndBit The ordinal of the most significant bit in the bit field.
2413 @return The bit field read.
2426 Writes a bit field to a 16-bit value, and returns the result.
2428 Writes Value to the bit field specified by the StartBit and the EndBit in
2429 Operand. All other bits in Operand are preserved. The new 16-bit value is
2432 If 16-bit operations are not supported, then ASSERT().
2433 If StartBit is greater than 15, then ASSERT().
2434 If EndBit is greater than 15, then ASSERT().
2435 If EndBit is less than StartBit, then ASSERT().
2437 @param Operand Operand on which to perform the bitfield operation.
2438 @param StartBit The ordinal of the least significant bit in the bit field.
2440 @param EndBit The ordinal of the most significant bit in the bit field.
2442 @param Value New value of the bit field.
2444 @return The new 16-bit value.
2458 Reads a bit field from a 16-bit value, performs a bitwise OR, and returns the
2461 Performs a bitwise inclusive OR between the bit field specified by StartBit
2462 and EndBit in Operand and the value specified by OrData. All other bits in
2463 Operand are preserved. The new 16-bit value is returned.
2465 If 16-bit operations are not supported, then ASSERT().
2466 If StartBit is greater than 15, then ASSERT().
2467 If EndBit is greater than 15, then ASSERT().
2468 If EndBit is less than StartBit, then ASSERT().
2470 @param Operand Operand on which to perform the bitfield operation.
2471 @param StartBit The ordinal of the least significant bit in the bit field.
2473 @param EndBit The ordinal of the most significant bit in the bit field.
2475 @param OrData The value to OR with the read value from the value
2477 @return The new 16-bit value.
2491 Reads a bit field from a 16-bit value, performs a bitwise AND, and returns
2494 Performs a bitwise AND between the bit field specified by StartBit and EndBit
2495 in Operand and the value specified by AndData. All other bits in Operand are
2496 preserved. The new 16-bit value is returned.
2498 If 16-bit operations are not supported, then ASSERT().
2499 If StartBit is greater than 15, then ASSERT().
2500 If EndBit is greater than 15, then ASSERT().
2501 If EndBit is less than StartBit, then ASSERT().
2503 @param Operand Operand on which to perform the bitfield operation.
2504 @param StartBit The ordinal of the least significant bit in the bit field.
2506 @param EndBit The ordinal of the most significant bit in the bit field.
2508 @param AndData The value to AND with the read value from the value
2510 @return The new 16-bit value.
2524 Reads a bit field from a 16-bit value, performs a bitwise AND followed by a
2525 bitwise OR, and returns the result.
2527 Performs a bitwise AND between the bit field specified by StartBit and EndBit
2528 in Operand and the value specified by AndData, followed by a bitwise
2529 inclusive OR with value specified by OrData. All other bits in Operand are
2530 preserved. The new 16-bit value is returned.
2532 If 16-bit operations are not supported, then ASSERT().
2533 If StartBit is greater than 15, then ASSERT().
2534 If EndBit is greater than 15, then ASSERT().
2535 If EndBit is less than StartBit, then ASSERT().
2537 @param Operand Operand on which to perform the bitfield operation.
2538 @param StartBit The ordinal of the least significant bit in the bit field.
2540 @param EndBit The ordinal of the most significant bit in the bit field.
2542 @param AndData The value to AND with the read value from the value.
2543 @param OrData The value to OR with the result of the AND operation.
2545 @return The new 16-bit value.
2550 BitFieldAndThenOr16 (
2560 Returns a bit field from a 32-bit value.
2562 Returns the bitfield specified by the StartBit and the EndBit from Operand.
2564 If 32-bit operations are not supported, then ASSERT().
2565 If StartBit is greater than 31, then ASSERT().
2566 If EndBit is greater than 31, then ASSERT().
2567 If EndBit is less than StartBit, then ASSERT().
2569 @param Operand Operand on which to perform the bitfield operation.
2570 @param StartBit The ordinal of the least significant bit in the bit field.
2572 @param EndBit The ordinal of the most significant bit in the bit field.
2575 @return The bit field read.
2588 Writes a bit field to a 32-bit value, and returns the result.
2590 Writes Value to the bit field specified by the StartBit and the EndBit in
2591 Operand. All other bits in Operand are preserved. The new 32-bit value is
2594 If 32-bit operations are not supported, then ASSERT().
2595 If StartBit is greater than 31, then ASSERT().
2596 If EndBit is greater than 31, then ASSERT().
2597 If EndBit is less than StartBit, then ASSERT().
2599 @param Operand Operand on which to perform the bitfield operation.
2600 @param StartBit The ordinal of the least significant bit in the bit field.
2602 @param EndBit The ordinal of the most significant bit in the bit field.
2604 @param Value New value of the bit field.
2606 @return The new 32-bit value.
2620 Reads a bit field from a 32-bit value, performs a bitwise OR, and returns the
2623 Performs a bitwise inclusive OR between the bit field specified by StartBit
2624 and EndBit in Operand and the value specified by OrData. All other bits in
2625 Operand are preserved. The new 32-bit value is returned.
2627 If 32-bit operations are not supported, then ASSERT().
2628 If StartBit is greater than 31, then ASSERT().
2629 If EndBit is greater than 31, then ASSERT().
2630 If EndBit is less than StartBit, then ASSERT().
2632 @param Operand Operand on which to perform the bitfield operation.
2633 @param StartBit The ordinal of the least significant bit in the bit field.
2635 @param EndBit The ordinal of the most significant bit in the bit field.
2637 @param OrData The value to OR with the read value from the value
2639 @return The new 32-bit value.
2653 Reads a bit field from a 32-bit value, performs a bitwise AND, and returns
2656 Performs a bitwise AND between the bit field specified by StartBit and EndBit
2657 in Operand and the value specified by AndData. All other bits in Operand are
2658 preserved. The new 32-bit value is returned.
2660 If 32-bit operations are not supported, then ASSERT().
2661 If StartBit is greater than 31, then ASSERT().
2662 If EndBit is greater than 31, then ASSERT().
2663 If EndBit is less than StartBit, then ASSERT().
2665 @param Operand Operand on which to perform the bitfield operation.
2666 @param StartBit The ordinal of the least significant bit in the bit field.
2668 @param EndBit The ordinal of the most significant bit in the bit field.
2670 @param AndData The value to AND with the read value from the value
2672 @return The new 32-bit value.
2686 Reads a bit field from a 32-bit value, performs a bitwise AND followed by a
2687 bitwise OR, and returns the result.
2689 Performs a bitwise AND between the bit field specified by StartBit and EndBit
2690 in Operand and the value specified by AndData, followed by a bitwise
2691 inclusive OR with value specified by OrData. All other bits in Operand are
2692 preserved. The new 32-bit value is returned.
2694 If 32-bit operations are not supported, then ASSERT().
2695 If StartBit is greater than 31, then ASSERT().
2696 If EndBit is greater than 31, then ASSERT().
2697 If EndBit is less than StartBit, then ASSERT().
2699 @param Operand Operand on which to perform the bitfield operation.
2700 @param StartBit The ordinal of the least significant bit in the bit field.
2702 @param EndBit The ordinal of the most significant bit in the bit field.
2704 @param AndData The value to AND with the read value from the value.
2705 @param OrData The value to OR with the result of the AND operation.
2707 @return The new 32-bit value.
2712 BitFieldAndThenOr32 (
2722 Returns a bit field from a 64-bit value.
2724 Returns the bitfield specified by the StartBit and the EndBit from Operand.
2726 If 64-bit operations are not supported, then ASSERT().
2727 If StartBit is greater than 63, then ASSERT().
2728 If EndBit is greater than 63, then ASSERT().
2729 If EndBit is less than StartBit, then ASSERT().
2731 @param Operand Operand on which to perform the bitfield operation.
2732 @param StartBit The ordinal of the least significant bit in the bit field.
2734 @param EndBit The ordinal of the most significant bit in the bit field.
2737 @return The bit field read.
2750 Writes a bit field to a 64-bit value, and returns the result.
2752 Writes Value to the bit field specified by the StartBit and the EndBit in
2753 Operand. All other bits in Operand are preserved. The new 64-bit value is
2756 If 64-bit operations are not supported, then ASSERT().
2757 If StartBit is greater than 63, then ASSERT().
2758 If EndBit is greater than 63, then ASSERT().
2759 If EndBit is less than StartBit, then ASSERT().
2761 @param Operand Operand on which to perform the bitfield operation.
2762 @param StartBit The ordinal of the least significant bit in the bit field.
2764 @param EndBit The ordinal of the most significant bit in the bit field.
2766 @param Value New value of the bit field.
2768 @return The new 64-bit value.
2782 Reads a bit field from a 64-bit value, performs a bitwise OR, and returns the
2785 Performs a bitwise inclusive OR between the bit field specified by StartBit
2786 and EndBit in Operand and the value specified by OrData. All other bits in
2787 Operand are preserved. The new 64-bit value is returned.
2789 If 64-bit operations are not supported, then ASSERT().
2790 If StartBit is greater than 63, then ASSERT().
2791 If EndBit is greater than 63, then ASSERT().
2792 If EndBit is less than StartBit, then ASSERT().
2794 @param Operand Operand on which to perform the bitfield operation.
2795 @param StartBit The ordinal of the least significant bit in the bit field.
2797 @param EndBit The ordinal of the most significant bit in the bit field.
2799 @param OrData The value to OR with the read value from the value
2801 @return The new 64-bit value.
2815 Reads a bit field from a 64-bit value, performs a bitwise AND, and returns
2818 Performs a bitwise AND between the bit field specified by StartBit and EndBit
2819 in Operand and the value specified by AndData. All other bits in Operand are
2820 preserved. The new 64-bit value is returned.
2822 If 64-bit operations are not supported, then ASSERT().
2823 If StartBit is greater than 63, then ASSERT().
2824 If EndBit is greater than 63, then ASSERT().
2825 If EndBit is less than StartBit, then ASSERT().
2827 @param Operand Operand on which to perform the bitfield operation.
2828 @param StartBit The ordinal of the least significant bit in the bit field.
2830 @param EndBit The ordinal of the most significant bit in the bit field.
2832 @param AndData The value to AND with the read value from the value
2834 @return The new 64-bit value.
2848 Reads a bit field from a 64-bit value, performs a bitwise AND followed by a
2849 bitwise OR, and returns the result.
2851 Performs a bitwise AND between the bit field specified by StartBit and EndBit
2852 in Operand and the value specified by AndData, followed by a bitwise
2853 inclusive OR with value specified by OrData. All other bits in Operand are
2854 preserved. The new 64-bit value is returned.
2856 If 64-bit operations are not supported, then ASSERT().
2857 If StartBit is greater than 63, then ASSERT().
2858 If EndBit is greater than 63, then ASSERT().
2859 If EndBit is less than StartBit, then ASSERT().
2861 @param Operand Operand on which to perform the bitfield operation.
2862 @param StartBit The ordinal of the least significant bit in the bit field.
2864 @param EndBit The ordinal of the most significant bit in the bit field.
2866 @param AndData The value to AND with the read value from the value.
2867 @param OrData The value to OR with the result of the AND operation.
2869 @return The new 64-bit value.
2874 BitFieldAndThenOr64 (
2884 // Base Library Synchronization Functions
2888 Retrieves the architecture specific spin lock alignment requirements for
2889 optimal spin lock performance.
2891 This function retrieves the spin lock alignment requirements for optimal
2892 performance on a given CPU architecture. The spin lock alignment must be a
2893 power of two and is returned by this function. If there are no alignment
2894 requirements, then 1 must be returned. The spin lock synchronization
2895 functions must function correctly if the spin lock size and alignment values
2896 returned by this function are not used at all. These values are hints to the
2897 consumers of the spin lock synchronization functions to obtain optimal spin
2900 @return The architecture specific spin lock alignment.
2905 GetSpinLockProperties (
2911 Initializes a spin lock to the released state and returns the spin lock.
2913 This function initializes the spin lock specified by SpinLock to the released
2914 state, and returns SpinLock. Optimal performance can be achieved by calling
2915 GetSpinLockProperties() to determine the size and alignment requirements for
2918 If SpinLock is NULL, then ASSERT().
2920 @param SpinLock A pointer to the spin lock to initialize to the released
2928 InitializeSpinLock (
2929 IN SPIN_LOCK
*SpinLock
2934 Waits until a spin lock can be placed in the acquired state.
2936 This function checks the state of the spin lock specified by SpinLock. If
2937 SpinLock is in the released state, then this function places SpinLock in the
2938 acquired state and returns SpinLock. Otherwise, this function waits
2939 indefinitely for the spin lock to be released, and then places it in the
2940 acquired state and returns SpinLock. All state transitions of SpinLock must
2941 be performed using MP safe mechanisms.
2943 If SpinLock is NULL, then ASSERT().
2944 If SpinLock was not initialized with InitializeSpinLock(), then ASSERT().
2945 If PcdSpinLockTimeout is not zero, and SpinLock is can not be acquired in
2946 PcdSpinLockTimeout microseconds, then ASSERT().
2948 @param SpinLock A pointer to the spin lock to place in the acquired state.
2956 IN SPIN_LOCK
*SpinLock
2961 Attempts to place a spin lock in the acquired state.
2963 This function checks the state of the spin lock specified by SpinLock. If
2964 SpinLock is in the released state, then this function places SpinLock in the
2965 acquired state and returns TRUE. Otherwise, FALSE is returned. All state
2966 transitions of SpinLock must be performed using MP safe mechanisms.
2968 If SpinLock is NULL, then ASSERT().
2969 If SpinLock was not initialized with InitializeSpinLock(), then ASSERT().
2971 @param SpinLock A pointer to the spin lock to place in the acquired state.
2973 @retval TRUE SpinLock was placed in the acquired state.
2974 @retval FALSE SpinLock could not be acquired.
2979 AcquireSpinLockOrFail (
2980 IN SPIN_LOCK
*SpinLock
2985 Releases a spin lock.
2987 This function places the spin lock specified by SpinLock in the release state
2988 and returns SpinLock.
2990 If SpinLock is NULL, then ASSERT().
2991 If SpinLock was not initialized with InitializeSpinLock(), then ASSERT().
2993 @param SpinLock A pointer to the spin lock to release.
3001 IN SPIN_LOCK
*SpinLock
3006 Performs an atomic increment of an 32-bit unsigned integer.
3008 Performs an atomic increment of the 32-bit unsigned integer specified by
3009 Value and returns the incremented value. The increment operation must be
3010 performed using MP safe mechanisms. The state of the return value is not
3011 guaranteed to be MP safe.
3013 If Value is NULL, then ASSERT().
3015 @param Value A pointer to the 32-bit value to increment.
3017 @return The incremented value.
3022 InterlockedIncrement (
3028 Performs an atomic decrement of an 32-bit unsigned integer.
3030 Performs an atomic decrement of the 32-bit unsigned integer specified by
3031 Value and returns the decremented value. The decrement operation must be
3032 performed using MP safe mechanisms. The state of the return value is not
3033 guaranteed to be MP safe.
3035 If Value is NULL, then ASSERT().
3037 @param Value A pointer to the 32-bit value to decrement.
3039 @return The decremented value.
3044 InterlockedDecrement (
3050 Performs an atomic compare exchange operation on a 32-bit unsigned integer.
3052 Performs an atomic compare exchange operation on the 32-bit unsigned integer
3053 specified by Value. If Value is equal to CompareValue, then Value is set to
3054 ExchangeValue and CompareValue is returned. If Value is not equal to CompareValue,
3055 then Value is returned. The compare exchange operation must be performed using
3058 If Value is NULL, then ASSERT().
3060 @param Value A pointer to the 32-bit value for the compare exchange
3062 @param CompareValue 32-bit value used in compare operation.
3063 @param ExchangeValue 32-bit value used in exchange operation.
3065 @return The original *Value before exchange.
3070 InterlockedCompareExchange32 (
3071 IN OUT UINT32
*Value
,
3072 IN UINT32 CompareValue
,
3073 IN UINT32 ExchangeValue
3078 Performs an atomic compare exchange operation on a 64-bit unsigned integer.
3080 Performs an atomic compare exchange operation on the 64-bit unsigned integer specified
3081 by Value. If Value is equal to CompareValue, then Value is set to ExchangeValue and
3082 CompareValue is returned. If Value is not equal to CompareValue, then Value is returned.
3083 The compare exchange operation must be performed using MP safe mechanisms.
3085 If Value is NULL, then ASSERT().
3087 @param Value A pointer to the 64-bit value for the compare exchange
3089 @param CompareValue 64-bit value used in compare operation.
3090 @param ExchangeValue 64-bit value used in exchange operation.
3092 @return The original *Value before exchange.
3097 InterlockedCompareExchange64 (
3098 IN OUT UINT64
*Value
,
3099 IN UINT64 CompareValue
,
3100 IN UINT64 ExchangeValue
3105 Performs an atomic compare exchange operation on a pointer value.
3107 Performs an atomic compare exchange operation on the pointer value specified
3108 by Value. If Value is equal to CompareValue, then Value is set to
3109 ExchangeValue and CompareValue is returned. If Value is not equal to
3110 CompareValue, then Value is returned. The compare exchange operation must be
3111 performed using MP safe mechanisms.
3113 If Value is NULL, then ASSERT().
3115 @param Value A pointer to the pointer value for the compare exchange
3117 @param CompareValue Pointer value used in compare operation.
3118 @param ExchangeValue Pointer value used in exchange operation.
3123 InterlockedCompareExchangePointer (
3124 IN OUT VOID
**Value
,
3125 IN VOID
*CompareValue
,
3126 IN VOID
*ExchangeValue
3131 // Base Library Checksum Functions
3135 Calculate the sum of all elements in a buffer in unit of UINT8.
3136 During calculation, the carry bits are dropped.
3138 This function calculates the sum of all elements in a buffer
3139 in unit of UINT8. The carry bits in result of addition are dropped.
3140 The result is returned as UINT8. If Length is Zero, then Zero is
3143 If Buffer is NULL, then ASSERT().
3144 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
3146 @param Buffer Pointer to the buffer to carry out the sum operation.
3147 @param Length The size, in bytes, of Buffer .
3149 @return Sum The sum of Buffer with carry bits dropped during additions.
3155 IN CONST UINT8
*Buffer
,
3161 Returns the two's complement checksum of all elements in a buffer
3164 This function first calculates the sum of the 8-bit values in the
3165 buffer specified by Buffer and Length. The carry bits in the result
3166 of addition are dropped. Then, the two's complement of the sum is
3167 returned. If Length is 0, then 0 is returned.
3169 If Buffer is NULL, then ASSERT().
3170 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
3173 @param Buffer Pointer to the buffer to carry out the checksum operation.
3174 @param Length The size, in bytes, of Buffer.
3176 @return Checksum The 2's complement checksum of Buffer.
3181 CalculateCheckSum8 (
3182 IN CONST UINT8
*Buffer
,
3188 Returns the sum of all elements in a buffer of 16-bit values. During
3189 calculation, the carry bits are dropped.
3191 This function calculates the sum of the 16-bit values in the buffer
3192 specified by Buffer and Length. The carry bits in result of addition are dropped.
3193 The 16-bit result is returned. If Length is 0, then 0 is returned.
3195 If Buffer is NULL, then ASSERT().
3196 If Buffer is not aligned on a 16-bit boundary, then ASSERT().
3197 If Length is not aligned on a 16-bit boundary, then ASSERT().
3198 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
3200 @param Buffer Pointer to the buffer to carry out the sum operation.
3201 @param Length The size, in bytes, of Buffer.
3203 @return Sum The sum of Buffer with carry bits dropped during additions.
3209 IN CONST UINT16
*Buffer
,
3215 Returns the two's complement checksum of all elements in a buffer of
3218 This function first calculates the sum of the 16-bit values in the buffer
3219 specified by Buffer and Length. The carry bits in the result of addition
3220 are dropped. Then, the two's complement of the sum is returned. If Length
3221 is 0, then 0 is returned.
3223 If Buffer is NULL, then ASSERT().
3224 If Buffer is not aligned on a 16-bit boundary, then ASSERT().
3225 If Length is not aligned on a 16-bit boundary, then ASSERT().
3226 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
3228 @param Buffer Pointer to the buffer to carry out the checksum operation.
3229 @param Length The size, in bytes, of Buffer.
3231 @return Checksum The 2's complement checksum of Buffer.
3236 CalculateCheckSum16 (
3237 IN CONST UINT16
*Buffer
,
3243 Returns the sum of all elements in a buffer of 32-bit values. During
3244 calculation, the carry bits are dropped.
3246 This function calculates the sum of the 32-bit values in the buffer
3247 specified by Buffer and Length. The carry bits in result of addition are dropped.
3248 The 32-bit result is returned. If Length is 0, then 0 is returned.
3250 If Buffer is NULL, then ASSERT().
3251 If Buffer is not aligned on a 32-bit boundary, then ASSERT().
3252 If Length is not aligned on a 32-bit boundary, then ASSERT().
3253 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
3255 @param Buffer Pointer to the buffer to carry out the sum operation.
3256 @param Length The size, in bytes, of Buffer.
3258 @return Sum The sum of Buffer with carry bits dropped during additions.
3264 IN CONST UINT32
*Buffer
,
3270 Returns the two's complement checksum of all elements in a buffer of
3273 This function first calculates the sum of the 32-bit values in the buffer
3274 specified by Buffer and Length. The carry bits in the result of addition
3275 are dropped. Then, the two's complement of the sum is returned. If Length
3276 is 0, then 0 is returned.
3278 If Buffer is NULL, then ASSERT().
3279 If Buffer is not aligned on a 32-bit boundary, then ASSERT().
3280 If Length is not aligned on a 32-bit boundary, then ASSERT().
3281 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
3283 @param Buffer Pointer to the buffer to carry out the checksum operation.
3284 @param Length The size, in bytes, of Buffer.
3286 @return Checksum The 2's complement checksum of Buffer.
3291 CalculateCheckSum32 (
3292 IN CONST UINT32
*Buffer
,
3298 Returns the sum of all elements in a buffer of 64-bit values. During
3299 calculation, the carry bits are dropped.
3301 This function calculates the sum of the 64-bit values in the buffer
3302 specified by Buffer and Length. The carry bits in result of addition are dropped.
3303 The 64-bit result is returned. If Length is 0, then 0 is returned.
3305 If Buffer is NULL, then ASSERT().
3306 If Buffer is not aligned on a 64-bit boundary, then ASSERT().
3307 If Length is not aligned on a 64-bit boundary, then ASSERT().
3308 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
3310 @param Buffer Pointer to the buffer to carry out the sum operation.
3311 @param Length The size, in bytes, of Buffer.
3313 @return Sum The sum of Buffer with carry bits dropped during additions.
3319 IN CONST UINT64
*Buffer
,
3325 Returns the two's complement checksum of all elements in a buffer of
3328 This function first calculates the sum of the 64-bit values in the buffer
3329 specified by Buffer and Length. The carry bits in the result of addition
3330 are dropped. Then, the two's complement of the sum is returned. If Length
3331 is 0, then 0 is returned.
3333 If Buffer is NULL, then ASSERT().
3334 If Buffer is not aligned on a 64-bit boundary, then ASSERT().
3335 If Length is not aligned on a 64-bit boundary, then ASSERT().
3336 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
3338 @param Buffer Pointer to the buffer to carry out the checksum operation.
3339 @param Length The size, in bytes, of Buffer.
3341 @return Checksum The 2's complement checksum of Buffer.
3346 CalculateCheckSum64 (
3347 IN CONST UINT64
*Buffer
,
3353 // Base Library CPU Functions
3357 (EFIAPI
*SWITCH_STACK_ENTRY_POINT
) (
3358 IN VOID
*Context1
, OPTIONAL
3359 IN VOID
*Context2 OPTIONAL
3364 Used to serialize load and store operations.
3366 All loads and stores that proceed calls to this function are guaranteed to be
3367 globally visible when this function returns.
3378 Saves the current CPU context that can be restored with a call to LongJump()
3381 Saves the current CPU context in the buffer specified by JumpBuffer and
3382 returns 0. The initial call to SetJump() must always return 0. Subsequent
3383 calls to LongJump() cause a non-zero value to be returned by SetJump().
3385 If JumpBuffer is NULL, then ASSERT().
3386 For IPF CPUs, if JumpBuffer is not aligned on a 16-byte boundary, then ASSERT().
3388 @param JumpBuffer A pointer to CPU context buffer.
3390 @retval 0 Indicates a return from SetJump().
3396 OUT BASE_LIBRARY_JUMP_BUFFER
*JumpBuffer
3401 Restores the CPU context that was saved with SetJump().
3403 Restores the CPU context from the buffer specified by JumpBuffer. This
3404 function never returns to the caller. Instead is resumes execution based on
3405 the state of JumpBuffer.
3407 If JumpBuffer is NULL, then ASSERT().
3408 For IPF CPUs, if JumpBuffer is not aligned on a 16-byte boundary, then ASSERT().
3409 If Value is 0, then ASSERT().
3411 @param JumpBuffer A pointer to CPU context buffer.
3412 @param Value The value to return when the SetJump() context is
3413 restored and must be non-zero.
3419 IN BASE_LIBRARY_JUMP_BUFFER
*JumpBuffer
,
3425 Enables CPU interrupts.
3427 Enables CPU interrupts.
3438 Disables CPU interrupts.
3440 Disables CPU interrupts.
3451 Disables CPU interrupts and returns the interrupt state prior to the disable
3454 Disables CPU interrupts and returns the interrupt state prior to the disable
3457 @retval TRUE CPU interrupts were enabled on entry to this call.
3458 @retval FALSE CPU interrupts were disabled on entry to this call.
3463 SaveAndDisableInterrupts (
3469 Enables CPU interrupts for the smallest window required to capture any
3472 Enables CPU interrupts for the smallest window required to capture any
3478 EnableDisableInterrupts (
3484 Retrieves the current CPU interrupt state.
3486 Retrieves the current CPU interrupt state. Returns TRUE is interrupts are
3487 currently enabled. Otherwise returns FALSE.
3489 @retval TRUE CPU interrupts are enabled.
3490 @retval FALSE CPU interrupts are disabled.
3501 Set the current CPU interrupt state.
3503 Sets the current CPU interrupt state to the state specified by
3504 InterruptState. If InterruptState is TRUE, then interrupts are enabled. If
3505 InterruptState is FALSE, then interrupts are disabled. InterruptState is
3508 @param InterruptState TRUE if interrupts should enabled. FALSE if
3509 interrupts should be disabled.
3511 @return InterruptState
3517 IN BOOLEAN InterruptState
3522 Places the CPU in a sleep state until an interrupt is received.
3524 Places the CPU in a sleep state until an interrupt is received. If interrupts
3525 are disabled prior to calling this function, then the CPU will be placed in a
3526 sleep state indefinitely.
3537 Requests CPU to pause for a short period of time.
3539 Requests CPU to pause for a short period of time. Typically used in MP
3540 systems to prevent memory starvation while waiting for a spin lock.
3551 Flushes all the Translation Lookaside Buffers(TLB) entries in a CPU.
3553 Flushes all the Translation Lookaside Buffers(TLB) entries in a CPU.
3564 Transfers control to a function starting with a new stack.
3566 Transfers control to the function specified by EntryPoint using the
3567 new stack specified by NewStack and passing in the parameters specified
3568 by Context1 and Context2. Context1 and Context2 are optional and may
3569 be NULL. The function EntryPoint must never return. This function
3570 supports a variable number of arguments following the NewStack parameter.
3571 These additional arguments are ignored on IA-32, x64, and EBC.
3572 IPF CPUs expect one additional parameter of type VOID * that specifies
3573 the new backing store pointer.
3575 If EntryPoint is NULL, then ASSERT().
3576 If NewStack is NULL, then ASSERT().
3578 @param EntryPoint A pointer to function to call with the new stack.
3579 @param Context1 A pointer to the context to pass into the EntryPoint
3581 @param Context2 A pointer to the context to pass into the EntryPoint
3583 @param NewStack A pointer to the new stack to use for the EntryPoint
3590 IN SWITCH_STACK_ENTRY_POINT EntryPoint
,
3591 IN VOID
*Context1
, OPTIONAL
3592 IN VOID
*Context2
, OPTIONAL
3599 Generates a breakpoint on the CPU.
3601 Generates a breakpoint on the CPU. The breakpoint must be implemented such
3602 that code can resume normal execution after the breakpoint.
3613 Executes an infinite loop.
3615 Forces the CPU to execute an infinite loop. A debugger may be used to skip
3616 past the loop and the code that follows the loop must execute properly. This
3617 implies that the infinite loop must not cause the code that follow it to be
3628 #if defined (MDE_CPU_IPF)
3631 Flush a range of cache lines in the cache coherency domain of the calling
3634 Invalidates the cache lines specified by Address and Length. If Address is
3635 not aligned on a cache line boundary, then entire cache line containing
3636 Address is invalidated. If Address + Length is not aligned on a cache line
3637 boundary, then the entire instruction cache line containing Address + Length
3638 -1 is invalidated. This function may choose to invalidate the entire
3639 instruction cache if that is more efficient than invalidating the specified
3640 range. If Length is 0, the no instruction cache lines are invalidated.
3641 Address is returned.
3643 If Length is greater than (MAX_ADDRESS - Address + 1), then ASSERT().
3645 @param Address The base address of the instruction lines to invalidate. If
3646 the CPU is in a physical addressing mode, then Address is a
3647 physical address. If the CPU is in a virtual addressing mode,
3648 then Address is a virtual address.
3650 @param Length The number of bytes to invalidate from the instruction cache.
3657 IpfFlushCacheRange (
3664 Executes a FC instruction
3665 Executes a FC instruction on the cache line specified by Address.
3666 The cache line size affected is at least 32-bytes (aligned on a 32-byte boundary).
3667 An implementation may flush a larger region. This function is only available on IPF.
3669 @param Address The Address of cache line to be flushed.
3671 @return The address of FC instruction executed.
3682 Executes a FC.I instruction.
3683 Executes a FC.I instruction on the cache line specified by Address.
3684 The cache line size affected is at least 32-bytes (aligned on a 32-byte boundary).
3685 An implementation may flush a larger region. This function is only available on IPF.
3687 @param Address The Address of cache line to be flushed.
3689 @return The address of FC.I instruction executed.
3700 Reads the current value of a Processor Identifier Register (CPUID).
3701 The Index of largest implemented CPUID (One less than the number of implemented CPUID
3702 registers) is determined by CPUID [3] bits {7:0}.
3703 No parameter checking is performed on Index. If the Index value is beyond the
3704 implemented CPUID register range, a Reserved Register/Field fault may occur. The caller
3705 must either guarantee that Index is valid, or the caller must set up fault handlers to
3706 catch the faults. This function is only available on IPF.
3708 @param Index The 8-bit Processor Identifier Register index to read.
3710 @return The current value of Processor Identifier Register specified by Index.
3721 Reads the current value of 64-bit Processor Status Register (PSR).
3722 This function is only available on IPF.
3724 @return The current value of PSR.
3735 Writes the current value of 64-bit Processor Status Register (PSR).
3736 No parameter checking is performed on Value. All bits of Value corresponding to
3737 reserved fields of PSR must be 0 or a Reserved Register/Field fault may occur. The caller must either guarantee that Value is valid, or the caller must set up fault handlers to catch the faults.
3738 This function is only available on IPF.
3740 @param Value The 64-bit value to write to PSR.
3742 @return The 64-bit value written to the PSR.
3753 Reads the current value of 64-bit Kernel Register #0 (KR0).
3754 This function is only available on IPF.
3756 @return The current value of KR0.
3767 Reads the current value of 64-bit Kernel Register #1 (KR1).
3768 This function is only available on IPF.
3770 @return The current value of KR1.
3781 Reads the current value of 64-bit Kernel Register #2 (KR2).
3782 This function is only available on IPF.
3784 @return The current value of KR2.
3795 Reads the current value of 64-bit Kernel Register #3 (KR3).
3796 This function is only available on IPF.
3798 @return The current value of KR3.
3809 Reads the current value of 64-bit Kernel Register #4 (KR4).
3810 This function is only available on IPF.
3812 @return The current value of KR4.
3823 Reads the current value of 64-bit Kernel Register #5 (KR5).
3824 This function is only available on IPF.
3826 @return The current value of KR5.
3837 Reads the current value of 64-bit Kernel Register #6 (KR6).
3838 This function is only available on IPF.
3840 @return The current value of KR6.
3851 Reads the current value of 64-bit Kernel Register #7 (KR7).
3852 This function is only available on IPF.
3854 @return The current value of KR7.
3865 Write the current value of 64-bit Kernel Register #0 (KR0).
3866 This function is only available on IPF.
3868 @param Value The 64-bit value to write to KR0.
3870 @return The 64-bit value written to the KR0.
3881 Write the current value of 64-bit Kernel Register #1 (KR1).
3882 This function is only available on IPF.
3884 @param Value The 64-bit value to write to KR1.
3886 @return The 64-bit value written to the KR1.
3897 Write the current value of 64-bit Kernel Register #2 (KR2).
3898 This function is only available on IPF.
3900 @param Value The 64-bit value to write to KR2.
3902 @return The 64-bit value written to the KR2.
3913 Write the current value of 64-bit Kernel Register #3 (KR3).
3914 This function is only available on IPF.
3916 @param Value The 64-bit value to write to KR3.
3918 @return The 64-bit value written to the KR3.
3929 Write the current value of 64-bit Kernel Register #4 (KR4).
3930 This function is only available on IPF.
3932 @param Value The 64-bit value to write to KR4.
3934 @return The 64-bit value written to the KR4.
3945 Write the current value of 64-bit Kernel Register #5 (KR5).
3946 This function is only available on IPF.
3948 @param Value The 64-bit value to write to KR5.
3950 @return The 64-bit value written to the KR5.
3961 Write the current value of 64-bit Kernel Register #6 (KR6).
3962 This function is only available on IPF.
3964 @param Value The 64-bit value to write to KR6.
3966 @return The 64-bit value written to the KR6.
3977 Write the current value of 64-bit Kernel Register #7 (KR7).
3978 This function is only available on IPF.
3980 @param Value The 64-bit value to write to KR7.
3982 @return The 64-bit value written to the KR7.
3993 Reads the current value of Interval Timer Counter Register (ITC).
3994 This function is only available on IPF.
3996 @return The current value of ITC.
4007 Reads the current value of Interval Timer Vector Register (ITV).
4008 This function is only available on IPF.
4010 @return The current value of ITV.
4021 Reads the current value of Interval Timer Match Register (ITM).
4022 This function is only available on IPF.
4024 @return The current value of ITM.
4034 Writes the current value of 64-bit Interval Timer Counter Register (ITC).
4035 This function is only available on IPF.
4037 @param Value The 64-bit value to write to ITC.
4039 @return The 64-bit value written to the ITC.
4050 Writes the current value of 64-bit Interval Timer Match Register (ITM).
4051 This function is only available on IPF.
4053 @param Value The 64-bit value to write to ITM.
4055 @return The 64-bit value written to the ITM.
4066 Writes the current value of 64-bit Interval Timer Vector Register (ITV).
4067 No parameter checking is performed on Value. All bits of Value corresponding to
4068 reserved fields of ITV must be 0 or a Reserved Register/Field fault may occur.
4069 The caller must either guarantee that Value is valid, or the caller must set up
4070 fault handlers to catch the faults.
4071 This function is only available on IPF.
4073 @param Value The 64-bit value to write to ITV.
4075 @return The 64-bit value written to the ITV.
4086 Reads the current value of Default Control Register (DCR).
4087 This function is only available on IPF.
4089 @return The current value of DCR.
4100 Reads the current value of Interruption Vector Address Register (IVA).
4101 This function is only available on IPF.
4103 @return The current value of IVA.
4113 Reads the current value of Page Table Address Register (PTA).
4114 This function is only available on IPF.
4116 @return The current value of PTA.
4127 Writes the current value of 64-bit Default Control Register (DCR).
4128 No parameter checking is performed on Value. All bits of Value corresponding to
4129 reserved fields of DCR must be 0 or a Reserved Register/Field fault may occur.
4130 The caller must either guarantee that Value is valid, or the caller must set up
4131 fault handlers to catch the faults.
4132 This function is only available on IPF.
4134 @param Value The 64-bit value to write to DCR.
4136 @return The 64-bit value written to the DCR.
4147 Writes the current value of 64-bit Interruption Vector Address Register (IVA).
4148 The size of vector table is 32 K bytes and is 32 K bytes aligned
4149 the low 15 bits of Value is ignored when written.
4150 This function is only available on IPF.
4152 @param Value The 64-bit value to write to IVA.
4154 @return The 64-bit value written to the IVA.
4165 Writes the current value of 64-bit Page Table Address Register (PTA).
4166 No parameter checking is performed on Value. All bits of Value corresponding to
4167 reserved fields of DCR must be 0 or a Reserved Register/Field fault may occur.
4168 The caller must either guarantee that Value is valid, or the caller must set up
4169 fault handlers to catch the faults.
4170 This function is only available on IPF.
4172 @param Value The 64-bit value to write to PTA.
4174 @return The 64-bit value written to the PTA.
4184 Reads the current value of Local Interrupt ID Register (LID).
4185 This function is only available on IPF.
4187 @return The current value of LID.
4198 Reads the current value of External Interrupt Vector Register (IVR).
4199 This function is only available on IPF.
4201 @return The current value of IVR.
4212 Reads the current value of Task Priority Register (TPR).
4213 This function is only available on IPF.
4215 @return The current value of TPR.
4226 Reads the current value of External Interrupt Request Register #0 (IRR0).
4227 This function is only available on IPF.
4229 @return The current value of IRR0.
4240 Reads the current value of External Interrupt Request Register #1 (IRR1).
4241 This function is only available on IPF.
4243 @return The current value of IRR1.
4254 Reads the current value of External Interrupt Request Register #2 (IRR2).
4255 This function is only available on IPF.
4257 @return The current value of IRR2.
4268 Reads the current value of External Interrupt Request Register #3 (IRR3).
4269 This function is only available on IPF.
4271 @return The current value of IRR3.
4282 Reads the current value of Performance Monitor Vector Register (PMV).
4283 This function is only available on IPF.
4285 @return The current value of PMV.
4296 Reads the current value of Corrected Machine Check Vector Register (CMCV).
4297 This function is only available on IPF.
4299 @return The current value of CMCV.
4310 Reads the current value of Local Redirection Register #0 (LRR0).
4311 This function is only available on IPF.
4313 @return The current value of LRR0.
4324 Reads the current value of Local Redirection Register #1 (LRR1).
4325 This function is only available on IPF.
4327 @return The current value of LRR1.
4338 Writes the current value of 64-bit Page Local Interrupt ID Register (LID).
4339 No parameter checking is performed on Value. All bits of Value corresponding to
4340 reserved fields of LID must be 0 or a Reserved Register/Field fault may occur.
4341 The caller must either guarantee that Value is valid, or the caller must set up
4342 fault handlers to catch the faults.
4343 This function is only available on IPF.
4345 @param Value The 64-bit value to write to LID.
4347 @return The 64-bit value written to the LID.
4358 Writes the current value of 64-bit Task Priority Register (TPR).
4359 No parameter checking is performed on Value. All bits of Value corresponding to
4360 reserved fields of TPR must be 0 or a Reserved Register/Field fault may occur.
4361 The caller must either guarantee that Value is valid, or the caller must set up
4362 fault handlers to catch the faults.
4363 This function is only available on IPF.
4365 @param Value The 64-bit value to write to TPR.
4367 @return The 64-bit value written to the TPR.
4378 Performs a write operation on End OF External Interrupt Register (EOI).
4379 Writes a value of 0 to the EOI Register. This function is only available on IPF.
4390 Writes the current value of 64-bit Performance Monitor Vector Register (PMV).
4391 No parameter checking is performed on Value. All bits of Value corresponding
4392 to reserved fields of PMV must be 0 or a Reserved Register/Field fault may occur.
4393 The caller must either guarantee that Value is valid, or the caller must set up
4394 fault handlers to catch the faults.
4395 This function is only available on IPF.
4397 @param Value The 64-bit value to write to PMV.
4399 @return The 64-bit value written to the PMV.
4410 Writes the current value of 64-bit Corrected Machine Check Vector Register (CMCV).
4411 No parameter checking is performed on Value. All bits of Value corresponding
4412 to reserved fields of CMCV must be 0 or a Reserved Register/Field fault may occur.
4413 The caller must either guarantee that Value is valid, or the caller must set up
4414 fault handlers to catch the faults.
4415 This function is only available on IPF.
4417 @param Value The 64-bit value to write to CMCV.
4419 @return The 64-bit value written to the CMCV.
4430 Writes the current value of 64-bit Local Redirection Register #0 (LRR0).
4431 No parameter checking is performed on Value. All bits of Value corresponding
4432 to reserved fields of LRR0 must be 0 or a Reserved Register/Field fault may occur.
4433 The caller must either guarantee that Value is valid, or the caller must set up
4434 fault handlers to catch the faults.
4435 This function is only available on IPF.
4437 @param Value The 64-bit value to write to LRR0.
4439 @return The 64-bit value written to the LRR0.
4450 Writes the current value of 64-bit Local Redirection Register #1 (LRR1).
4451 No parameter checking is performed on Value. All bits of Value corresponding
4452 to reserved fields of LRR1 must be 0 or a Reserved Register/Field fault may occur.
4453 The caller must either guarantee that Value is valid, or the caller must
4454 set up fault handlers to catch the faults.
4455 This function is only available on IPF.
4457 @param Value The 64-bit value to write to LRR1.
4459 @return The 64-bit value written to the LRR1.
4470 Reads the current value of Instruction Breakpoint Register (IBR).
4472 The Instruction Breakpoint Registers are used in pairs. The even numbered
4473 registers contain breakpoint addresses, and the odd numbered registers contain
4474 breakpoint mask conditions. At least 4 instruction registers pairs are implemented
4475 on all processor models. Implemented registers are contiguous starting with
4476 register 0. No parameter checking is performed on Index, and if the Index value
4477 is beyond the implemented IBR register range, a Reserved Register/Field fault may
4478 occur. The caller must either guarantee that Index is valid, or the caller must
4479 set up fault handlers to catch the faults.
4480 This function is only available on IPF.
4482 @param Index The 8-bit Instruction Breakpoint Register index to read.
4484 @return The current value of Instruction Breakpoint Register specified by Index.
4495 Reads the current value of Data Breakpoint Register (DBR).
4497 The Data Breakpoint Registers are used in pairs. The even numbered registers
4498 contain breakpoint addresses, and odd numbered registers contain breakpoint
4499 mask conditions. At least 4 data registers pairs are implemented on all processor
4500 models. Implemented registers are contiguous starting with register 0.
4501 No parameter checking is performed on Index. If the Index value is beyond
4502 the implemented DBR register range, a Reserved Register/Field fault may occur.
4503 The caller must either guarantee that Index is valid, or the caller must set up
4504 fault handlers to catch the faults.
4505 This function is only available on IPF.
4507 @param Index The 8-bit Data Breakpoint Register index to read.
4509 @return The current value of Data Breakpoint Register specified by Index.
4520 Reads the current value of Performance Monitor Configuration Register (PMC).
4522 All processor implementations provide at least 4 performance counters
4523 (PMC/PMD [4]...PMC/PMD [7] pairs), and 4 performance monitor counter overflow
4524 status registers (PMC [0]¡ PMC [3]). Processor implementations may provide
4525 additional implementation-dependent PMC and PMD to increase the number of
4526 ¡®generic¡¯ performance counters (PMC/PMD pairs). The remainder of PMC and PMD
4527 register set is implementation dependent. No parameter checking is performed
4528 on Index. If the Index value is beyond the implemented PMC register range,
4529 zero value will be returned.
4530 This function is only available on IPF.
4532 @param Index The 8-bit Performance Monitor Configuration Register index to read.
4534 @return The current value of Performance Monitor Configuration Register
4546 Reads the current value of Performance Monitor Data Register (PMD).
4548 All processor implementations provide at least 4 performance counters
4549 (PMC/PMD [4]...PMC/PMD [7] pairs), and 4 performance monitor counter
4550 overflow status registers (PMC [0]¡ PMC [3]). Processor implementations may
4551 provide additional implementation-dependent PMC and PMD to increase the number
4552 of ¡®generic¡¯ performance counters (PMC/PMD pairs). The remainder of PMC and PMD
4553 register set is implementation dependent. No parameter checking is performed
4554 on Index. If the Index value is beyond the implemented PMD register range,
4555 zero value will be returned.
4556 This function is only available on IPF.
4558 @param Index The 8-bit Performance Monitor Data Register index to read.
4560 @return The current value of Performance Monitor Data Register specified by Index.
4571 Writes the current value of 64-bit Instruction Breakpoint Register (IBR).
4573 Writes current value of Instruction Breakpoint Register specified by Index.
4574 The Instruction Breakpoint Registers are used in pairs. The even numbered
4575 registers contain breakpoint addresses, and odd numbered registers contain
4576 breakpoint mask conditions. At least 4 instruction registers pairs are implemented
4577 on all processor models. Implemented registers are contiguous starting with
4578 register 0. No parameter checking is performed on Index. If the Index value
4579 is beyond the implemented IBR register range, a Reserved Register/Field fault may
4580 occur. The caller must either guarantee that Index is valid, or the caller must
4581 set up fault handlers to catch the faults.
4582 This function is only available on IPF.
4584 @param Index The 8-bit Instruction Breakpoint Register index to write.
4585 @param Value The 64-bit value to write to IBR.
4587 @return The 64-bit value written to the IBR.
4599 Writes the current value of 64-bit Data Breakpoint Register (DBR).
4601 Writes current value of Data Breakpoint Register specified by Index.
4602 The Data Breakpoint Registers are used in pairs. The even numbered registers
4603 contain breakpoint addresses, and odd numbered registers contain breakpoint
4604 mask conditions. At least 4 data registers pairs are implemented on all processor
4605 models. Implemented registers are contiguous starting with register 0. No parameter
4606 checking is performed on Index. If the Index value is beyond the implemented
4607 DBR register range, a Reserved Register/Field fault may occur. The caller must
4608 either guarantee that Index is valid, or the caller must set up fault handlers to
4610 This function is only available on IPF.
4612 @param Index The 8-bit Data Breakpoint Register index to write.
4613 @param Value The 64-bit value to write to DBR.
4615 @return The 64-bit value written to the DBR.
4627 Writes the current value of 64-bit Performance Monitor Configuration Register (PMC).
4629 Writes current value of Performance Monitor Configuration Register specified by Index.
4630 All processor implementations provide at least 4 performance counters
4631 (PMC/PMD [4]...PMC/PMD [7] pairs), and 4 performance monitor counter overflow status
4632 registers (PMC [0]¡ PMC [3]). Processor implementations may provide additional
4633 implementation-dependent PMC and PMD to increase the number of ¡®generic¡¯ performance
4634 counters (PMC/PMD pairs). The remainder of PMC and PMD register set is implementation
4635 dependent. No parameter checking is performed on Index. If the Index value is
4636 beyond the implemented PMC register range, the write is ignored.
4637 This function is only available on IPF.
4639 @param Index The 8-bit Performance Monitor Configuration Register index to write.
4640 @param Value The 64-bit value to write to PMC.
4642 @return The 64-bit value written to the PMC.
4654 Writes the current value of 64-bit Performance Monitor Data Register (PMD).
4656 Writes current value of Performance Monitor Data Register specified by Index.
4657 All processor implementations provide at least 4 performance counters
4658 (PMC/PMD [4]...PMC/PMD [7] pairs), and 4 performance monitor counter overflow
4659 status registers (PMC [0]¡ PMC [3]). Processor implementations may provide
4660 additional implementation-dependent PMC and PMD to increase the number of ¡®generic¡¯
4661 performance counters (PMC/PMD pairs). The remainder of PMC and PMD register set
4662 is implementation dependent. No parameter checking is performed on Index. If the
4663 Index value is beyond the implemented PMD register range, the write is ignored.
4664 This function is only available on IPF.
4666 @param Index The 8-bit Performance Monitor Data Register index to write.
4667 @param Value The 64-bit value to write to PMD.
4669 @return The 64-bit value written to the PMD.
4681 Reads the current value of 64-bit Global Pointer (GP).
4683 Reads and returns the current value of GP.
4684 This function is only available on IPF.
4686 @return The current value of GP.
4697 Write the current value of 64-bit Global Pointer (GP).
4699 Writes the current value of GP. The 64-bit value written to the GP is returned.
4700 No parameter checking is performed on Value.
4701 This function is only available on IPF.
4703 @param Value The 64-bit value to write to GP.
4705 @return The 64-bit value written to the GP.
4716 Reads the current value of 64-bit Stack Pointer (SP).
4718 Reads and returns the current value of SP.
4719 This function is only available on IPF.
4721 @return The current value of SP.
4732 Determines if the CPU is currently executing in virtual, physical, or mixed mode.
4734 Determines the current execution mode of the CPU.
4735 If the CPU is in virtual mode(PSR.RT=1, PSR.DT=1, PSR.IT=1), then 1 is returned.
4736 If the CPU is in physical mode(PSR.RT=0, PSR.DT=0, PSR.IT=0), then 0 is returned.
4737 If the CPU is not in physical mode or virtual mode, then it is in mixed mode,
4739 This function is only available on IPF.
4741 @return 1 The CPU is in virtual mode.
4742 @return 0 The CPU is in physical mode.
4743 @return -1 The CPU is in mixed mode.
4754 Makes a PAL procedure call.
4756 This is a wrapper function to make a PAL procedure call. Based on the Index
4757 value this API will make static or stacked PAL call. The following table
4758 describes the usage of PAL Procedure Index Assignment. Architected procedures
4759 may be designated as required or optional. If a PAL procedure is specified
4760 as optional, a unique return code of 0xFFFFFFFFFFFFFFFF is returned in the
4761 Status field of the PAL_CALL_RETURN structure.
4762 This indicates that the procedure is not present in this PAL implementation.
4763 It is the caller¡¯s responsibility to check for this return code after calling
4764 any optional PAL procedure.
4765 No parameter checking is performed on the 5 input parameters, but there are
4766 some common rules that the caller should follow when making a PAL call. Any
4767 address passed to PAL as buffers for return parameters must be 8-byte aligned.
4768 Unaligned addresses may cause undefined results. For those parameters defined
4769 as reserved or some fields defined as reserved must be zero filled or the invalid
4770 argument return value may be returned or undefined result may occur during the
4771 execution of the procedure. If the PalEntryPoint does not point to a valid
4772 PAL entry point then the system behavior is undefined. This function is only
4775 @param PalEntryPoint The PAL procedure calls entry point.
4776 @param Index The PAL procedure Index number.
4777 @param Arg2 The 2nd parameter for PAL procedure calls.
4778 @param Arg3 The 3rd parameter for PAL procedure calls.
4779 @param Arg4 The 4th parameter for PAL procedure calls.
4781 @return structure returned from the PAL Call procedure, including the status and return value.
4787 IN UINT64 PalEntryPoint
,
4796 Transfers control to a function starting with a new stack.
4798 Transfers control to the function specified by EntryPoint using the new stack
4799 specified by NewStack and passing in the parameters specified by Context1 and
4800 Context2. Context1 and Context2 are optional and may be NULL. The function
4801 EntryPoint must never return.
4803 If EntryPoint is NULL, then ASSERT().
4804 If NewStack is NULL, then ASSERT().
4806 @param EntryPoint A pointer to function to call with the new stack.
4807 @param Context1 A pointer to the context to pass into the EntryPoint
4809 @param Context2 A pointer to the context to pass into the EntryPoint
4811 @param NewStack A pointer to the new stack to use for the EntryPoint
4813 @param NewBsp A pointer to the new memory location for RSE backing
4819 AsmSwitchStackAndBackingStore (
4820 IN SWITCH_STACK_ENTRY_POINT EntryPoint
,
4821 IN VOID
*Context1
, OPTIONAL
4822 IN VOID
*Context2
, OPTIONAL
4829 // Bugbug: This call should be removed after
4830 // the PalCall Instance issue has been fixed.
4833 Performs a PAL call using static calling convention.
4835 An internal function to perform a PAL call using static calling convention.
4837 @param PalEntryPoint The entry point address of PAL. The address in ar.kr5
4838 would be used if this parameter were NULL on input.
4839 @param Arg1 The first argument of a PAL call.
4840 @param Arg1 The second argument of a PAL call.
4841 @param Arg1 The third argument of a PAL call.
4842 @param Arg1 The fourth argument of a PAL call.
4844 @return The values returned in r8, r9, r10 and r11.
4849 IN CONST VOID
*PalEntryPoint
,
4857 #elif defined (MDE_CPU_IA32) || defined (MDE_CPU_X64)
4859 // IA32 and X64 Specific Functions
4862 // Byte packed structure for 16-bit Real Mode EFLAGS
4866 UINT32 CF
:1; // Carry Flag
4867 UINT32 Reserved_0
:1; // Reserved
4868 UINT32 PF
:1; // Parity Flag
4869 UINT32 Reserved_1
:1; // Reserved
4870 UINT32 AF
:1; // Auxiliary Carry Flag
4871 UINT32 Reserved_2
:1; // Reserved
4872 UINT32 ZF
:1; // Zero Flag
4873 UINT32 SF
:1; // Sign Flag
4874 UINT32 TF
:1; // Trap Flag
4875 UINT32 IF
:1; // Interrupt Enable Flag
4876 UINT32 DF
:1; // Direction Flag
4877 UINT32 OF
:1; // Overflow Flag
4878 UINT32 IOPL
:2; // I/O Privilege Level
4879 UINT32 NT
:1; // Nested Task
4880 UINT32 Reserved_3
:1; // Reserved
4886 // Byte packed structure for EFLAGS/RFLAGS
4888 // 64-bits on X64. The upper 32-bits on X64 are reserved
4892 UINT32 CF
:1; // Carry Flag
4893 UINT32 Reserved_0
:1; // Reserved
4894 UINT32 PF
:1; // Parity Flag
4895 UINT32 Reserved_1
:1; // Reserved
4896 UINT32 AF
:1; // Auxiliary Carry Flag
4897 UINT32 Reserved_2
:1; // Reserved
4898 UINT32 ZF
:1; // Zero Flag
4899 UINT32 SF
:1; // Sign Flag
4900 UINT32 TF
:1; // Trap Flag
4901 UINT32 IF
:1; // Interrupt Enable Flag
4902 UINT32 DF
:1; // Direction Flag
4903 UINT32 OF
:1; // Overflow Flag
4904 UINT32 IOPL
:2; // I/O Privilege Level
4905 UINT32 NT
:1; // Nested Task
4906 UINT32 Reserved_3
:1; // Reserved
4907 UINT32 RF
:1; // Resume Flag
4908 UINT32 VM
:1; // Virtual 8086 Mode
4909 UINT32 AC
:1; // Alignment Check
4910 UINT32 VIF
:1; // Virtual Interrupt Flag
4911 UINT32 VIP
:1; // Virtual Interrupt Pending
4912 UINT32 ID
:1; // ID Flag
4913 UINT32 Reserved_4
:10; // Reserved
4919 // Byte packed structure for Control Register 0 (CR0)
4921 // 64-bits on X64. The upper 32-bits on X64 are reserved
4925 UINT32 PE
:1; // Protection Enable
4926 UINT32 MP
:1; // Monitor Coprocessor
4927 UINT32 EM
:1; // Emulation
4928 UINT32 TS
:1; // Task Switched
4929 UINT32 ET
:1; // Extension Type
4930 UINT32 NE
:1; // Numeric Error
4931 UINT32 Reserved_0
:10; // Reserved
4932 UINT32 WP
:1; // Write Protect
4933 UINT32 Reserved_1
:1; // Reserved
4934 UINT32 AM
:1; // Alignment Mask
4935 UINT32 Reserved_2
:10; // Reserved
4936 UINT32 NW
:1; // Mot Write-through
4937 UINT32 CD
:1; // Cache Disable
4938 UINT32 PG
:1; // Paging
4944 // Byte packed structure for Control Register 4 (CR4)
4946 // 64-bits on X64. The upper 32-bits on X64 are reserved
4950 UINT32 VME
:1; // Virtual-8086 Mode Extensions
4951 UINT32 PVI
:1; // Protected-Mode Virtual Interrupts
4952 UINT32 TSD
:1; // Time Stamp Disable
4953 UINT32 DE
:1; // Debugging Extensions
4954 UINT32 PSE
:1; // Page Size Extensions
4955 UINT32 PAE
:1; // Physical Address Extension
4956 UINT32 MCE
:1; // Machine Check Enable
4957 UINT32 PGE
:1; // Page Global Enable
4958 UINT32 PCE
:1; // Performance Monitoring Counter
4960 UINT32 OSFXSR
:1; // Operating System Support for
4961 // FXSAVE and FXRSTOR instructions
4962 UINT32 OSXMMEXCPT
:1; // Operating System Support for
4963 // Unmasked SIMD Floating Point
4965 UINT32 Reserved_0
:2; // Reserved
4966 UINT32 VMXE
:1; // VMX Enable
4967 UINT32 Reserved_1
:18; // Reseved
4973 // Byte packed structure for an IDTR, GDTR, LDTR descriptor
4974 /// @bug How to make this structure byte-packed in a compiler independent way?
4983 #define IA32_IDT_GATE_TYPE_TASK 0x85
4984 #define IA32_IDT_GATE_TYPE_INTERRUPT_16 0x86
4985 #define IA32_IDT_GATE_TYPE_TRAP_16 0x87
4986 #define IA32_IDT_GATE_TYPE_INTERRUPT_32 0x8E
4987 #define IA32_IDT_GATE_TYPE_TRAP_32 0x8F
4990 // Byte packed structure for an Interrupt Gate Descriptor
4994 UINT32 OffsetLow
:16; // Offset bits 15..0
4995 UINT32 Selector
:16; // Selector
4996 UINT32 Reserved_0
:8; // Reserved
4997 UINT32 GateType
:8; // Gate Type. See #defines above
4998 UINT32 OffsetHigh
:16; // Offset bits 31..16
5001 } IA32_IDT_GATE_DESCRIPTOR
;
5004 // Byte packed structure for an FP/SSE/SSE2 context
5011 // Structures for the 16-bit real mode thunks
5064 IA32_EFLAGS32 EFLAGS
;
5074 } IA32_REGISTER_SET
;
5077 // Byte packed structure for an 16-bit real mode thunks
5080 IA32_REGISTER_SET
*RealModeState
;
5081 VOID
*RealModeBuffer
;
5082 UINT32 RealModeBufferSize
;
5083 UINT32 ThunkAttributes
;
5086 #define THUNK_ATTRIBUTE_BIG_REAL_MODE 0x00000001
5087 #define THUNK_ATTRIBUTE_DISABLE_A20_MASK_INT_15 0x00000002
5088 #define THUNK_ATTRIBUTE_DISABLE_A20_MASK_KBD_CTRL 0x00000004
5091 Retrieves CPUID information.
5093 Executes the CPUID instruction with EAX set to the value specified by Index.
5094 This function always returns Index.
5095 If Eax is not NULL, then the value of EAX after CPUID is returned in Eax.
5096 If Ebx is not NULL, then the value of EBX after CPUID is returned in Ebx.
5097 If Ecx is not NULL, then the value of ECX after CPUID is returned in Ecx.
5098 If Edx is not NULL, then the value of EDX after CPUID is returned in Edx.
5099 This function is only available on IA-32 and X64.
5101 @param Index The 32-bit value to load into EAX prior to invoking the CPUID
5103 @param Eax Pointer to the 32-bit EAX value returned by the CPUID
5104 instruction. This is an optional parameter that may be NULL.
5105 @param Ebx Pointer to the 32-bit EBX value returned by the CPUID
5106 instruction. This is an optional parameter that may be NULL.
5107 @param Ecx Pointer to the 32-bit ECX value returned by the CPUID
5108 instruction. This is an optional parameter that may be NULL.
5109 @param Edx Pointer to the 32-bit EDX value returned by the CPUID
5110 instruction. This is an optional parameter that may be NULL.
5119 OUT UINT32
*Eax
, OPTIONAL
5120 OUT UINT32
*Ebx
, OPTIONAL
5121 OUT UINT32
*Ecx
, OPTIONAL
5122 OUT UINT32
*Edx OPTIONAL
5127 Retrieves CPUID information using an extended leaf identifier.
5129 Executes the CPUID instruction with EAX set to the value specified by Index
5130 and ECX set to the value specified by SubIndex. This function always returns
5131 Index. This function is only available on IA-32 and x64.
5133 If Eax is not NULL, then the value of EAX after CPUID is returned in Eax.
5134 If Ebx is not NULL, then the value of EBX after CPUID is returned in Ebx.
5135 If Ecx is not NULL, then the value of ECX after CPUID is returned in Ecx.
5136 If Edx is not NULL, then the value of EDX after CPUID is returned in Edx.
5138 @param Index The 32-bit value to load into EAX prior to invoking the
5140 @param SubIndex The 32-bit value to load into ECX prior to invoking the
5142 @param Eax Pointer to the 32-bit EAX value returned by the CPUID
5143 instruction. This is an optional parameter that may be
5145 @param Ebx Pointer to the 32-bit EBX value returned by the CPUID
5146 instruction. This is an optional parameter that may be
5148 @param Ecx Pointer to the 32-bit ECX value returned by the CPUID
5149 instruction. This is an optional parameter that may be
5151 @param Edx Pointer to the 32-bit EDX value returned by the CPUID
5152 instruction. This is an optional parameter that may be
5163 OUT UINT32
*Eax
, OPTIONAL
5164 OUT UINT32
*Ebx
, OPTIONAL
5165 OUT UINT32
*Ecx
, OPTIONAL
5166 OUT UINT32
*Edx OPTIONAL
5171 Returns the lower 32-bits of a Machine Specific Register(MSR).
5173 Reads and returns the lower 32-bits of the MSR specified by Index.
5174 No parameter checking is performed on Index, and some Index values may cause
5175 CPU exceptions. The caller must either guarantee that Index is valid, or the
5176 caller must set up exception handlers to catch the exceptions. This function
5177 is only available on IA-32 and X64.
5179 @param Index The 32-bit MSR index to read.
5181 @return The lower 32 bits of the MSR identified by Index.
5192 Zero-extend a 32-bit value and writes it to a Machine Specific Register(MSR).
5194 Writes the 32-bit value specified by Value to the MSR specified by Index. The
5195 upper 32-bits of the MSR write are set to zero. The 32-bit value written to
5196 the MSR is returned. No parameter checking is performed on Index or Value,
5197 and some of these may cause CPU exceptions. The caller must either guarantee
5198 that Index and Value are valid, or the caller must establish proper exception
5199 handlers. This function is only available on IA-32 and X64.
5201 @param Index The 32-bit MSR index to write.
5202 @param Value The 32-bit value to write to the MSR.
5216 Reads a 64-bit MSR, performs a bitwise inclusive OR on the lower 32-bits, and
5217 writes the result back to the 64-bit MSR.
5219 Reads the 64-bit MSR specified by Index, performs a bitwise inclusive OR
5220 between the lower 32-bits of the read result and the value specified by
5221 OrData, and writes the result to the 64-bit MSR specified by Index. The lower
5222 32-bits of the value written to the MSR is returned. No parameter checking is
5223 performed on Index or OrData, and some of these may cause CPU exceptions. The
5224 caller must either guarantee that Index and OrData are valid, or the caller
5225 must establish proper exception handlers. This function is only available on
5228 @param Index The 32-bit MSR index to write.
5229 @param OrData The value to OR with the read value from the MSR.
5231 @return The lower 32-bit value written to the MSR.
5243 Reads a 64-bit MSR, performs a bitwise AND on the lower 32-bits, and writes
5244 the result back to the 64-bit MSR.
5246 Reads the 64-bit MSR specified by Index, performs a bitwise AND between the
5247 lower 32-bits of the read result and the value specified by AndData, and
5248 writes the result to the 64-bit MSR specified by Index. The lower 32-bits of
5249 the value written to the MSR is returned. No parameter checking is performed
5250 on Index or AndData, and some of these may cause CPU exceptions. The caller
5251 must either guarantee that Index and AndData are valid, or the caller must
5252 establish proper exception handlers. This function is only available on IA-32
5255 @param Index The 32-bit MSR index to write.
5256 @param AndData The value to AND with the read value from the MSR.
5258 @return The lower 32-bit value written to the MSR.
5270 Reads a 64-bit MSR, performs a bitwise AND followed by a bitwise inclusive OR
5271 on the lower 32-bits, and writes the result back to the 64-bit MSR.
5273 Reads the 64-bit MSR specified by Index, performs a bitwise AND between the
5274 lower 32-bits of the read result and the value specified by AndData
5275 preserving the upper 32-bits, performs a bitwise inclusive OR between the
5276 result of the AND operation and the value specified by OrData, and writes the
5277 result to the 64-bit MSR specified by Address. The lower 32-bits of the value
5278 written to the MSR is returned. No parameter checking is performed on Index,
5279 AndData, or OrData, and some of these may cause CPU exceptions. The caller
5280 must either guarantee that Index, AndData, and OrData are valid, or the
5281 caller must establish proper exception handlers. This function is only
5282 available on IA-32 and X64.
5284 @param Index The 32-bit MSR index to write.
5285 @param AndData The value to AND with the read value from the MSR.
5286 @param OrData The value to OR with the result of the AND operation.
5288 @return The lower 32-bit value written to the MSR.
5301 Reads a bit field of an MSR.
5303 Reads the bit field in the lower 32-bits of a 64-bit MSR. The bit field is
5304 specified by the StartBit and the EndBit. The value of the bit field is
5305 returned. The caller must either guarantee that Index is valid, or the caller
5306 must set up exception handlers to catch the exceptions. This function is only
5307 available on IA-32 and X64.
5309 If StartBit is greater than 31, then ASSERT().
5310 If EndBit is greater than 31, then ASSERT().
5311 If EndBit is less than StartBit, then ASSERT().
5313 @param Index The 32-bit MSR index to read.
5314 @param StartBit The ordinal of the least significant bit in the bit field.
5316 @param EndBit The ordinal of the most significant bit in the bit field.
5319 @return The bit field read from the MSR.
5324 AsmMsrBitFieldRead32 (
5332 Writes a bit field to an MSR.
5334 Writes Value to a bit field in the lower 32-bits of a 64-bit MSR. The bit
5335 field is specified by the StartBit and the EndBit. All other bits in the
5336 destination MSR are preserved. The lower 32-bits of the MSR written is
5337 returned. Extra left bits in Value are stripped. The caller must either
5338 guarantee that Index and the data written is valid, or the caller must set up
5339 exception handlers to catch the exceptions. This function is only available
5342 If StartBit is greater than 31, then ASSERT().
5343 If EndBit is greater than 31, then ASSERT().
5344 If EndBit is less than StartBit, then ASSERT().
5346 @param Index The 32-bit MSR index to write.
5347 @param StartBit The ordinal of the least significant bit in the bit field.
5349 @param EndBit The ordinal of the most significant bit in the bit field.
5351 @param Value New value of the bit field.
5353 @return The lower 32-bit of the value written to the MSR.
5358 AsmMsrBitFieldWrite32 (
5367 Reads a bit field in a 64-bit MSR, performs a bitwise OR, and writes the
5368 result back to the bit field in the 64-bit MSR.
5370 Reads the 64-bit MSR specified by Index, performs a bitwise inclusive OR
5371 between the read result and the value specified by OrData, and writes the
5372 result to the 64-bit MSR specified by Index. The lower 32-bits of the value
5373 written to the MSR are returned. Extra left bits in OrData are stripped. The
5374 caller must either guarantee that Index and the data written is valid, or
5375 the caller must set up exception handlers to catch the exceptions. This
5376 function is only available on IA-32 and X64.
5378 If StartBit is greater than 31, then ASSERT().
5379 If EndBit is greater than 31, then ASSERT().
5380 If EndBit is less than StartBit, then ASSERT().
5382 @param Index The 32-bit MSR index to write.
5383 @param StartBit The ordinal of the least significant bit in the bit field.
5385 @param EndBit The ordinal of the most significant bit in the bit field.
5387 @param OrData The value to OR with the read value from the MSR.
5389 @return The lower 32-bit of the value written to the MSR.
5394 AsmMsrBitFieldOr32 (
5403 Reads a bit field in a 64-bit MSR, performs a bitwise AND, and writes the
5404 result back to the bit field in the 64-bit MSR.
5406 Reads the 64-bit MSR specified by Index, performs a bitwise AND between the
5407 read result and the value specified by AndData, and writes the result to the
5408 64-bit MSR specified by Index. The lower 32-bits of the value written to the
5409 MSR are returned. Extra left bits in AndData are stripped. The caller must
5410 either guarantee that Index and the data written is valid, or the caller must
5411 set up exception handlers to catch the exceptions. This function is only
5412 available on IA-32 and X64.
5414 If StartBit is greater than 31, then ASSERT().
5415 If EndBit is greater than 31, then ASSERT().
5416 If EndBit is less than StartBit, then ASSERT().
5418 @param Index The 32-bit MSR index to write.
5419 @param StartBit The ordinal of the least significant bit in the bit field.
5421 @param EndBit The ordinal of the most significant bit in the bit field.
5423 @param AndData The value to AND with the read value from the MSR.
5425 @return The lower 32-bit of the value written to the MSR.
5430 AsmMsrBitFieldAnd32 (
5439 Reads a bit field in a 64-bit MSR, performs a bitwise AND followed by a
5440 bitwise inclusive OR, and writes the result back to the bit field in the
5443 Reads the 64-bit MSR specified by Index, performs a bitwise AND followed by a
5444 bitwise inclusive OR between the read result and the value specified by
5445 AndData, and writes the result to the 64-bit MSR specified by Index. The
5446 lower 32-bits of the value written to the MSR are returned. Extra left bits
5447 in both AndData and OrData are stripped. The caller must either guarantee
5448 that Index and the data written is valid, or the caller must set up exception
5449 handlers to catch the exceptions. This function is only available on IA-32
5452 If StartBit is greater than 31, then ASSERT().
5453 If EndBit is greater than 31, then ASSERT().
5454 If EndBit is less than StartBit, then ASSERT().
5456 @param Index The 32-bit MSR index to write.
5457 @param StartBit The ordinal of the least significant bit in the bit field.
5459 @param EndBit The ordinal of the most significant bit in the bit field.
5461 @param AndData The value to AND with the read value from the MSR.
5462 @param OrData The value to OR with the result of the AND operation.
5464 @return The lower 32-bit of the value written to the MSR.
5469 AsmMsrBitFieldAndThenOr32 (
5479 Returns a 64-bit Machine Specific Register(MSR).
5481 Reads and returns the 64-bit MSR specified by Index. No parameter checking is
5482 performed on Index, and some Index values may cause CPU exceptions. The
5483 caller must either guarantee that Index is valid, or the caller must set up
5484 exception handlers to catch the exceptions. This function is only available
5487 @param Index The 32-bit MSR index to read.
5489 @return The value of the MSR identified by Index.
5500 Writes a 64-bit value to a Machine Specific Register(MSR), and returns the
5503 Writes the 64-bit value specified by Value to the MSR specified by Index. The
5504 64-bit value written to the MSR is returned. No parameter checking is
5505 performed on Index or Value, and some of these may cause CPU exceptions. The
5506 caller must either guarantee that Index and Value are valid, or the caller
5507 must establish proper exception handlers. This function is only available on
5510 @param Index The 32-bit MSR index to write.
5511 @param Value The 64-bit value to write to the MSR.
5525 Reads a 64-bit MSR, performs a bitwise inclusive OR, and writes the result
5526 back to the 64-bit MSR.
5528 Reads the 64-bit MSR specified by Index, performs a bitwise inclusive OR
5529 between the read result and the value specified by OrData, and writes the
5530 result to the 64-bit MSR specified by Index. The value written to the MSR is
5531 returned. No parameter checking is performed on Index or OrData, and some of
5532 these may cause CPU exceptions. The caller must either guarantee that Index
5533 and OrData are valid, or the caller must establish proper exception handlers.
5534 This function is only available on IA-32 and X64.
5536 @param Index The 32-bit MSR index to write.
5537 @param OrData The value to OR with the read value from the MSR.
5539 @return The value written back to the MSR.
5551 Reads a 64-bit MSR, performs a bitwise AND, and writes the result back to the
5554 Reads the 64-bit MSR specified by Index, performs a bitwise AND between the
5555 read result and the value specified by OrData, and writes the result to the
5556 64-bit MSR specified by Index. The value written to the MSR is returned. No
5557 parameter checking is performed on Index or OrData, and some of these may
5558 cause CPU exceptions. The caller must either guarantee that Index and OrData
5559 are valid, or the caller must establish proper exception handlers. This
5560 function is only available on IA-32 and X64.
5562 @param Index The 32-bit MSR index to write.
5563 @param AndData The value to AND with the read value from the MSR.
5565 @return The value written back to the MSR.
5577 Reads a 64-bit MSR, performs a bitwise AND followed by a bitwise inclusive
5578 OR, and writes the result back to the 64-bit MSR.
5580 Reads the 64-bit MSR specified by Index, performs a bitwise AND between read
5581 result and the value specified by AndData, performs a bitwise inclusive OR
5582 between the result of the AND operation and the value specified by OrData,
5583 and writes the result to the 64-bit MSR specified by Index. The value written
5584 to the MSR is returned. No parameter checking is performed on Index, AndData,
5585 or OrData, and some of these may cause CPU exceptions. The caller must either
5586 guarantee that Index, AndData, and OrData are valid, or the caller must
5587 establish proper exception handlers. This function is only available on IA-32
5590 @param Index The 32-bit MSR index to write.
5591 @param AndData The value to AND with the read value from the MSR.
5592 @param OrData The value to OR with the result of the AND operation.
5594 @return The value written back to the MSR.
5607 Reads a bit field of an MSR.
5609 Reads the bit field in the 64-bit MSR. The bit field is specified by the
5610 StartBit and the EndBit. The value of the bit field is returned. The caller
5611 must either guarantee that Index is valid, or the caller must set up
5612 exception handlers to catch the exceptions. This function is only available
5615 If StartBit is greater than 63, then ASSERT().
5616 If EndBit is greater than 63, then ASSERT().
5617 If EndBit is less than StartBit, then ASSERT().
5619 @param Index The 32-bit MSR index to read.
5620 @param StartBit The ordinal of the least significant bit in the bit field.
5622 @param EndBit The ordinal of the most significant bit in the bit field.
5625 @return The value read from the MSR.
5630 AsmMsrBitFieldRead64 (
5638 Writes a bit field to an MSR.
5640 Writes Value to a bit field in a 64-bit MSR. The bit field is specified by
5641 the StartBit and the EndBit. All other bits in the destination MSR are
5642 preserved. The MSR written is returned. Extra left bits in Value are
5643 stripped. The caller must either guarantee that Index and the data written is
5644 valid, or the caller must set up exception handlers to catch the exceptions.
5645 This function is only available on IA-32 and X64.
5647 If StartBit is greater than 63, then ASSERT().
5648 If EndBit is greater than 63, then ASSERT().
5649 If EndBit is less than StartBit, then ASSERT().
5651 @param Index The 32-bit MSR index to write.
5652 @param StartBit The ordinal of the least significant bit in the bit field.
5654 @param EndBit The ordinal of the most significant bit in the bit field.
5656 @param Value New value of the bit field.
5658 @return The value written back to the MSR.
5663 AsmMsrBitFieldWrite64 (
5672 Reads a bit field in a 64-bit MSR, performs a bitwise inclusive OR, and
5673 writes the result back to the bit field in the 64-bit MSR.
5675 Reads the 64-bit MSR specified by Index, performs a bitwise inclusive OR
5676 between the read result and the value specified by OrData, and writes the
5677 result to the 64-bit MSR specified by Index. The value written to the MSR is
5678 returned. Extra left bits in OrData are stripped. The caller must either
5679 guarantee that Index and the data written is valid, or the caller must set up
5680 exception handlers to catch the exceptions. This function is only available
5683 If StartBit is greater than 63, then ASSERT().
5684 If EndBit is greater than 63, then ASSERT().
5685 If EndBit is less than StartBit, then ASSERT().
5687 @param Index The 32-bit MSR index to write.
5688 @param StartBit The ordinal of the least significant bit in the bit field.
5690 @param EndBit The ordinal of the most significant bit in the bit field.
5692 @param OrData The value to OR with the read value from the bit field.
5694 @return The value written back to the MSR.
5699 AsmMsrBitFieldOr64 (
5708 Reads a bit field in a 64-bit MSR, performs a bitwise AND, and writes the
5709 result back to the bit field in the 64-bit MSR.
5711 Reads the 64-bit MSR specified by Index, performs a bitwise AND between the
5712 read result and the value specified by AndData, and writes the result to the
5713 64-bit MSR specified by Index. The value written to the MSR is returned.
5714 Extra left bits in AndData are stripped. The caller must either guarantee
5715 that Index and the data written is valid, or the caller must set up exception
5716 handlers to catch the exceptions. This function is only available on IA-32
5719 If StartBit is greater than 63, then ASSERT().
5720 If EndBit is greater than 63, then ASSERT().
5721 If EndBit is less than StartBit, then ASSERT().
5723 @param Index The 32-bit MSR index to write.
5724 @param StartBit The ordinal of the least significant bit in the bit field.
5726 @param EndBit The ordinal of the most significant bit in the bit field.
5728 @param AndData The value to AND with the read value from the bit field.
5730 @return The value written back to the MSR.
5735 AsmMsrBitFieldAnd64 (
5744 Reads a bit field in a 64-bit MSR, performs a bitwise AND followed by a
5745 bitwise inclusive OR, and writes the result back to the bit field in the
5748 Reads the 64-bit MSR specified by Index, performs a bitwise AND followed by
5749 a bitwise inclusive OR between the read result and the value specified by
5750 AndData, and writes the result to the 64-bit MSR specified by Index. The
5751 value written to the MSR is returned. Extra left bits in both AndData and
5752 OrData are stripped. The caller must either guarantee that Index and the data
5753 written is valid, or the caller must set up exception handlers to catch the
5754 exceptions. This function is only available on IA-32 and X64.
5756 If StartBit is greater than 63, then ASSERT().
5757 If EndBit is greater than 63, then ASSERT().
5758 If EndBit is less than StartBit, then ASSERT().
5760 @param Index The 32-bit MSR index to write.
5761 @param StartBit The ordinal of the least significant bit in the bit field.
5763 @param EndBit The ordinal of the most significant bit in the bit field.
5765 @param AndData The value to AND with the read value from the bit field.
5766 @param OrData The value to OR with the result of the AND operation.
5768 @return The value written back to the MSR.
5773 AsmMsrBitFieldAndThenOr64 (
5783 Reads the current value of the EFLAGS register.
5785 Reads and returns the current value of the EFLAGS register. This function is
5786 only available on IA-32 and X64. This returns a 32-bit value on IA-32 and a
5787 64-bit value on X64.
5789 @return EFLAGS on IA-32 or RFLAGS on X64.
5800 Reads the current value of the Control Register 0 (CR0).
5802 Reads and returns the current value of CR0. This function is only available
5803 on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on
5806 @return The value of the Control Register 0 (CR0).
5817 Reads the current value of the Control Register 2 (CR2).
5819 Reads and returns the current value of CR2. This function is only available
5820 on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on
5823 @return The value of the Control Register 2 (CR2).
5834 Reads the current value of the Control Register 3 (CR3).
5836 Reads and returns the current value of CR3. This function is only available
5837 on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on
5840 @return The value of the Control Register 3 (CR3).
5851 Reads the current value of the Control Register 4 (CR4).
5853 Reads and returns the current value of CR4. This function is only available
5854 on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on
5857 @return The value of the Control Register 4 (CR4).
5868 Writes a value to Control Register 0 (CR0).
5870 Writes and returns a new value to CR0. This function is only available on
5871 IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.
5873 @param Cr0 The value to write to CR0.
5875 @return The value written to CR0.
5886 Writes a value to Control Register 2 (CR2).
5888 Writes and returns a new value to CR2. This function is only available on
5889 IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.
5891 @param Cr2 The value to write to CR2.
5893 @return The value written to CR2.
5904 Writes a value to Control Register 3 (CR3).
5906 Writes and returns a new value to CR3. This function is only available on
5907 IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.
5909 @param Cr3 The value to write to CR3.
5911 @return The value written to CR3.
5922 Writes a value to Control Register 4 (CR4).
5924 Writes and returns a new value to CR4. This function is only available on
5925 IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.
5927 @param Cr4 The value to write to CR4.
5929 @return The value written to CR4.
5940 Reads the current value of Debug Register 0 (DR0).
5942 Reads and returns the current value of DR0. This function is only available
5943 on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on
5946 @return The value of Debug Register 0 (DR0).
5957 Reads the current value of Debug Register 1 (DR1).
5959 Reads and returns the current value of DR1. This function is only available
5960 on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on
5963 @return The value of Debug Register 1 (DR1).
5974 Reads the current value of Debug Register 2 (DR2).
5976 Reads and returns the current value of DR2. This function is only available
5977 on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on
5980 @return The value of Debug Register 2 (DR2).
5991 Reads the current value of Debug Register 3 (DR3).
5993 Reads and returns the current value of DR3. This function is only available
5994 on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on
5997 @return The value of Debug Register 3 (DR3).
6008 Reads the current value of Debug Register 4 (DR4).
6010 Reads and returns the current value of DR4. This function is only available
6011 on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on
6014 @return The value of Debug Register 4 (DR4).
6025 Reads the current value of Debug Register 5 (DR5).
6027 Reads and returns the current value of DR5. This function is only available
6028 on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on
6031 @return The value of Debug Register 5 (DR5).
6042 Reads the current value of Debug Register 6 (DR6).
6044 Reads and returns the current value of DR6. This function is only available
6045 on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on
6048 @return The value of Debug Register 6 (DR6).
6059 Reads the current value of Debug Register 7 (DR7).
6061 Reads and returns the current value of DR7. This function is only available
6062 on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on
6065 @return The value of Debug Register 7 (DR7).
6076 Writes a value to Debug Register 0 (DR0).
6078 Writes and returns a new value to DR0. This function is only available on
6079 IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.
6081 @param Dr0 The value to write to Dr0.
6083 @return The value written to Debug Register 0 (DR0).
6094 Writes a value to Debug Register 1 (DR1).
6096 Writes and returns a new value to DR1. This function is only available on
6097 IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.
6099 @param Dr1 The value to write to Dr1.
6101 @return The value written to Debug Register 1 (DR1).
6112 Writes a value to Debug Register 2 (DR2).
6114 Writes and returns a new value to DR2. This function is only available on
6115 IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.
6117 @param Dr2 The value to write to Dr2.
6119 @return The value written to Debug Register 2 (DR2).
6130 Writes a value to Debug Register 3 (DR3).
6132 Writes and returns a new value to DR3. This function is only available on
6133 IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.
6135 @param Dr3 The value to write to Dr3.
6137 @return The value written to Debug Register 3 (DR3).
6148 Writes a value to Debug Register 4 (DR4).
6150 Writes and returns a new value to DR4. This function is only available on
6151 IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.
6153 @param Dr4 The value to write to Dr4.
6155 @return The value written to Debug Register 4 (DR4).
6166 Writes a value to Debug Register 5 (DR5).
6168 Writes and returns a new value to DR5. This function is only available on
6169 IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.
6171 @param Dr5 The value to write to Dr5.
6173 @return The value written to Debug Register 5 (DR5).
6184 Writes a value to Debug Register 6 (DR6).
6186 Writes and returns a new value to DR6. This function is only available on
6187 IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.
6189 @param Dr6 The value to write to Dr6.
6191 @return The value written to Debug Register 6 (DR6).
6202 Writes a value to Debug Register 7 (DR7).
6204 Writes and returns a new value to DR7. This function is only available on
6205 IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.
6207 @param Dr7 The value to write to Dr7.
6209 @return The value written to Debug Register 7 (DR7).
6220 Reads the current value of Code Segment Register (CS).
6222 Reads and returns the current value of CS. This function is only available on
6225 @return The current value of CS.
6236 Reads the current value of Data Segment Register (DS).
6238 Reads and returns the current value of DS. This function is only available on
6241 @return The current value of DS.
6252 Reads the current value of Extra Segment Register (ES).
6254 Reads and returns the current value of ES. This function is only available on
6257 @return The current value of ES.
6268 Reads the current value of FS Data Segment Register (FS).
6270 Reads and returns the current value of FS. This function is only available on
6273 @return The current value of FS.
6284 Reads the current value of GS Data Segment Register (GS).
6286 Reads and returns the current value of GS. This function is only available on
6289 @return The current value of GS.
6300 Reads the current value of Stack Segment Register (SS).
6302 Reads and returns the current value of SS. This function is only available on
6305 @return The current value of SS.
6316 Reads the current value of Task Register (TR).
6318 Reads and returns the current value of TR. This function is only available on
6321 @return The current value of TR.
6332 Reads the current Global Descriptor Table Register(GDTR) descriptor.
6334 Reads and returns the current GDTR descriptor and returns it in Gdtr. This
6335 function is only available on IA-32 and X64.
6337 If Gdtr is NULL, then ASSERT().
6339 @param Gdtr Pointer to a GDTR descriptor.
6345 OUT IA32_DESCRIPTOR
*Gdtr
6350 Writes the current Global Descriptor Table Register (GDTR) descriptor.
6352 Writes and the current GDTR descriptor specified by Gdtr. This function is
6353 only available on IA-32 and X64.
6355 If Gdtr is NULL, then ASSERT().
6357 @param Gdtr Pointer to a GDTR descriptor.
6363 IN CONST IA32_DESCRIPTOR
*Gdtr
6368 Reads the current Interrupt Descriptor Table Register(GDTR) descriptor.
6370 Reads and returns the current IDTR descriptor and returns it in Idtr. This
6371 function is only available on IA-32 and X64.
6373 If Idtr is NULL, then ASSERT().
6375 @param Idtr Pointer to a IDTR descriptor.
6381 OUT IA32_DESCRIPTOR
*Idtr
6386 Writes the current Interrupt Descriptor Table Register(GDTR) descriptor.
6388 Writes the current IDTR descriptor and returns it in Idtr. This function is
6389 only available on IA-32 and X64.
6391 If Idtr is NULL, then ASSERT().
6393 @param Idtr Pointer to a IDTR descriptor.
6399 IN CONST IA32_DESCRIPTOR
*Idtr
6404 Reads the current Local Descriptor Table Register(LDTR) selector.
6406 Reads and returns the current 16-bit LDTR descriptor value. This function is
6407 only available on IA-32 and X64.
6409 @return The current selector of LDT.
6420 Writes the current Local Descriptor Table Register (GDTR) selector.
6422 Writes and the current LDTR descriptor specified by Ldtr. This function is
6423 only available on IA-32 and X64.
6425 @param Ldtr 16-bit LDTR selector value.
6436 Save the current floating point/SSE/SSE2 context to a buffer.
6438 Saves the current floating point/SSE/SSE2 state to the buffer specified by
6439 Buffer. Buffer must be aligned on a 16-byte boundary. This function is only
6440 available on IA-32 and X64.
6442 If Buffer is NULL, then ASSERT().
6443 If Buffer is not aligned on a 16-byte boundary, then ASSERT().
6445 @param Buffer Pointer to a buffer to save the floating point/SSE/SSE2 context.
6451 OUT IA32_FX_BUFFER
*Buffer
6456 Restores the current floating point/SSE/SSE2 context from a buffer.
6458 Restores the current floating point/SSE/SSE2 state from the buffer specified
6459 by Buffer. Buffer must be aligned on a 16-byte boundary. This function is
6460 only available on IA-32 and X64.
6462 If Buffer is NULL, then ASSERT().
6463 If Buffer is not aligned on a 16-byte boundary, then ASSERT().
6464 If Buffer was not saved with AsmFxSave(), then ASSERT().
6466 @param Buffer Pointer to a buffer to save the floating point/SSE/SSE2 context.
6472 IN CONST IA32_FX_BUFFER
*Buffer
6477 Reads the current value of 64-bit MMX Register #0 (MM0).
6479 Reads and returns the current value of MM0. This function is only available
6482 @return The current value of MM0.
6493 Reads the current value of 64-bit MMX Register #1 (MM1).
6495 Reads and returns the current value of MM1. This function is only available
6498 @return The current value of MM1.
6509 Reads the current value of 64-bit MMX Register #2 (MM2).
6511 Reads and returns the current value of MM2. This function is only available
6514 @return The current value of MM2.
6525 Reads the current value of 64-bit MMX Register #3 (MM3).
6527 Reads and returns the current value of MM3. This function is only available
6530 @return The current value of MM3.
6541 Reads the current value of 64-bit MMX Register #4 (MM4).
6543 Reads and returns the current value of MM4. This function is only available
6546 @return The current value of MM4.
6557 Reads the current value of 64-bit MMX Register #5 (MM5).
6559 Reads and returns the current value of MM5. This function is only available
6562 @return The current value of MM5.
6573 Reads the current value of 64-bit MMX Register #6 (MM6).
6575 Reads and returns the current value of MM6. This function is only available
6578 @return The current value of MM6.
6589 Reads the current value of 64-bit MMX Register #7 (MM7).
6591 Reads and returns the current value of MM7. This function is only available
6594 @return The current value of MM7.
6605 Writes the current value of 64-bit MMX Register #0 (MM0).
6607 Writes the current value of MM0. This function is only available on IA32 and
6610 @param Value The 64-bit value to write to MM0.
6621 Writes the current value of 64-bit MMX Register #1 (MM1).
6623 Writes the current value of MM1. This function is only available on IA32 and
6626 @param Value The 64-bit value to write to MM1.
6637 Writes the current value of 64-bit MMX Register #2 (MM2).
6639 Writes the current value of MM2. This function is only available on IA32 and
6642 @param Value The 64-bit value to write to MM2.
6653 Writes the current value of 64-bit MMX Register #3 (MM3).
6655 Writes the current value of MM3. This function is only available on IA32 and
6658 @param Value The 64-bit value to write to MM3.
6669 Writes the current value of 64-bit MMX Register #4 (MM4).
6671 Writes the current value of MM4. This function is only available on IA32 and
6674 @param Value The 64-bit value to write to MM4.
6685 Writes the current value of 64-bit MMX Register #5 (MM5).
6687 Writes the current value of MM5. This function is only available on IA32 and
6690 @param Value The 64-bit value to write to MM5.
6701 Writes the current value of 64-bit MMX Register #6 (MM6).
6703 Writes the current value of MM6. This function is only available on IA32 and
6706 @param Value The 64-bit value to write to MM6.
6717 Writes the current value of 64-bit MMX Register #7 (MM7).
6719 Writes the current value of MM7. This function is only available on IA32 and
6722 @param Value The 64-bit value to write to MM7.
6733 Reads the current value of Time Stamp Counter (TSC).
6735 Reads and returns the current value of TSC. This function is only available
6738 @return The current value of TSC
6749 Reads the current value of a Performance Counter (PMC).
6751 Reads and returns the current value of performance counter specified by
6752 Index. This function is only available on IA-32 and X64.
6754 @param Index The 32-bit Performance Counter index to read.
6756 @return The value of the PMC specified by Index.
6767 Sets up a monitor buffer that is used by AsmMwait().
6769 Executes a MONITOR instruction with the register state specified by Eax, Ecx
6770 and Edx. Returns Eax. This function is only available on IA-32 and X64.
6772 @param Eax The value to load into EAX or RAX before executing the MONITOR
6774 @param Ecx The value to load into ECX or RCX before executing the MONITOR
6776 @param Edx The value to load into EDX or RDX before executing the MONITOR
6792 Executes an MWAIT instruction.
6794 Executes an MWAIT instruction with the register state specified by Eax and
6795 Ecx. Returns Eax. This function is only available on IA-32 and X64.
6797 @param Eax The value to load into EAX or RAX before executing the MONITOR
6799 @param Ecx The value to load into ECX or RCX before executing the MONITOR
6814 Executes a WBINVD instruction.
6816 Executes a WBINVD instruction. This function is only available on IA-32 and
6828 Executes a INVD instruction.
6830 Executes a INVD instruction. This function is only available on IA-32 and
6842 Flushes a cache line from all the instruction and data caches within the
6843 coherency domain of the CPU.
6845 Flushed the cache line specified by LinearAddress, and returns LinearAddress.
6846 This function is only available on IA-32 and X64.
6848 @param LinearAddress The address of the cache line to flush. If the CPU is
6849 in a physical addressing mode, then LinearAddress is a
6850 physical address. If the CPU is in a virtual
6851 addressing mode, then LinearAddress is a virtual
6854 @return LinearAddress
6859 IN VOID
*LinearAddress
6864 Enables the 32-bit paging mode on the CPU.
6866 Enables the 32-bit paging mode on the CPU. CR0, CR3, CR4, and the page tables
6867 must be properly initialized prior to calling this service. This function
6868 assumes the current execution mode is 32-bit protected mode. This function is
6869 only available on IA-32. After the 32-bit paging mode is enabled, control is
6870 transferred to the function specified by EntryPoint using the new stack
6871 specified by NewStack and passing in the parameters specified by Context1 and
6872 Context2. Context1 and Context2 are optional and may be NULL. The function
6873 EntryPoint must never return.
6875 If the current execution mode is not 32-bit protected mode, then ASSERT().
6876 If EntryPoint is NULL, then ASSERT().
6877 If NewStack is NULL, then ASSERT().
6879 There are a number of constraints that must be followed before calling this
6881 1) Interrupts must be disabled.
6882 2) The caller must be in 32-bit protected mode with flat descriptors. This
6883 means all descriptors must have a base of 0 and a limit of 4GB.
6884 3) CR0 and CR4 must be compatible with 32-bit protected mode with flat
6886 4) CR3 must point to valid page tables that will be used once the transition
6887 is complete, and those page tables must guarantee that the pages for this
6888 function and the stack are identity mapped.
6890 @param EntryPoint A pointer to function to call with the new stack after
6892 @param Context1 A pointer to the context to pass into the EntryPoint
6893 function as the first parameter after paging is enabled.
6894 @param Context2 A pointer to the context to pass into the EntryPoint
6895 function as the second parameter after paging is enabled.
6896 @param NewStack A pointer to the new stack to use for the EntryPoint
6897 function after paging is enabled.
6903 IN SWITCH_STACK_ENTRY_POINT EntryPoint
,
6904 IN VOID
*Context1
, OPTIONAL
6905 IN VOID
*Context2
, OPTIONAL
6911 Disables the 32-bit paging mode on the CPU.
6913 Disables the 32-bit paging mode on the CPU and returns to 32-bit protected
6914 mode. This function assumes the current execution mode is 32-paged protected
6915 mode. This function is only available on IA-32. After the 32-bit paging mode
6916 is disabled, control is transferred to the function specified by EntryPoint
6917 using the new stack specified by NewStack and passing in the parameters
6918 specified by Context1 and Context2. Context1 and Context2 are optional and
6919 may be NULL. The function EntryPoint must never return.
6921 If the current execution mode is not 32-bit paged mode, then ASSERT().
6922 If EntryPoint is NULL, then ASSERT().
6923 If NewStack is NULL, then ASSERT().
6925 There are a number of constraints that must be followed before calling this
6927 1) Interrupts must be disabled.
6928 2) The caller must be in 32-bit paged mode.
6929 3) CR0, CR3, and CR4 must be compatible with 32-bit paged mode.
6930 4) CR3 must point to valid page tables that guarantee that the pages for
6931 this function and the stack are identity mapped.
6933 @param EntryPoint A pointer to function to call with the new stack after
6935 @param Context1 A pointer to the context to pass into the EntryPoint
6936 function as the first parameter after paging is disabled.
6937 @param Context2 A pointer to the context to pass into the EntryPoint
6938 function as the second parameter after paging is
6940 @param NewStack A pointer to the new stack to use for the EntryPoint
6941 function after paging is disabled.
6946 AsmDisablePaging32 (
6947 IN SWITCH_STACK_ENTRY_POINT EntryPoint
,
6948 IN VOID
*Context1
, OPTIONAL
6949 IN VOID
*Context2
, OPTIONAL
6955 Enables the 64-bit paging mode on the CPU.
6957 Enables the 64-bit paging mode on the CPU. CR0, CR3, CR4, and the page tables
6958 must be properly initialized prior to calling this service. This function
6959 assumes the current execution mode is 32-bit protected mode with flat
6960 descriptors. This function is only available on IA-32. After the 64-bit
6961 paging mode is enabled, control is transferred to the function specified by
6962 EntryPoint using the new stack specified by NewStack and passing in the
6963 parameters specified by Context1 and Context2. Context1 and Context2 are
6964 optional and may be 0. The function EntryPoint must never return.
6966 If the current execution mode is not 32-bit protected mode with flat
6967 descriptors, then ASSERT().
6968 If EntryPoint is 0, then ASSERT().
6969 If NewStack is 0, then ASSERT().
6971 @param Cs The 16-bit selector to load in the CS before EntryPoint
6972 is called. The descriptor in the GDT that this selector
6973 references must be setup for long mode.
6974 @param EntryPoint The 64-bit virtual address of the function to call with
6975 the new stack after paging is enabled.
6976 @param Context1 The 64-bit virtual address of the context to pass into
6977 the EntryPoint function as the first parameter after
6979 @param Context2 The 64-bit virtual address of the context to pass into
6980 the EntryPoint function as the second parameter after
6982 @param NewStack The 64-bit virtual address of the new stack to use for
6983 the EntryPoint function after paging is enabled.
6989 IN UINT16 CodeSelector
,
6990 IN UINT64 EntryPoint
,
6991 IN UINT64 Context1
, OPTIONAL
6992 IN UINT64 Context2
, OPTIONAL
6998 Disables the 64-bit paging mode on the CPU.
7000 Disables the 64-bit paging mode on the CPU and returns to 32-bit protected
7001 mode. This function assumes the current execution mode is 64-paging mode.
7002 This function is only available on X64. After the 64-bit paging mode is
7003 disabled, control is transferred to the function specified by EntryPoint
7004 using the new stack specified by NewStack and passing in the parameters
7005 specified by Context1 and Context2. Context1 and Context2 are optional and
7006 may be 0. The function EntryPoint must never return.
7008 If the current execution mode is not 64-bit paged mode, then ASSERT().
7009 If EntryPoint is 0, then ASSERT().
7010 If NewStack is 0, then ASSERT().
7012 @param Cs The 16-bit selector to load in the CS before EntryPoint
7013 is called. The descriptor in the GDT that this selector
7014 references must be setup for 32-bit protected mode.
7015 @param EntryPoint The 64-bit virtual address of the function to call with
7016 the new stack after paging is disabled.
7017 @param Context1 The 64-bit virtual address of the context to pass into
7018 the EntryPoint function as the first parameter after
7020 @param Context2 The 64-bit virtual address of the context to pass into
7021 the EntryPoint function as the second parameter after
7023 @param NewStack The 64-bit virtual address of the new stack to use for
7024 the EntryPoint function after paging is disabled.
7029 AsmDisablePaging64 (
7030 IN UINT16 CodeSelector
,
7031 IN UINT32 EntryPoint
,
7032 IN UINT32 Context1
, OPTIONAL
7033 IN UINT32 Context2
, OPTIONAL
7039 // 16-bit thunking services
7043 Retrieves the properties for 16-bit thunk functions.
7045 Computes the size of the buffer and stack below 1MB required to use the
7046 AsmPrepareThunk16(), AsmThunk16() and AsmPrepareAndThunk16() functions. This
7047 buffer size is returned in RealModeBufferSize, and the stack size is returned
7048 in ExtraStackSize. If parameters are passed to the 16-bit real mode code,
7049 then the actual minimum stack size is ExtraStackSize plus the maximum number
7050 of bytes that need to be passed to the 16-bit real mode code.
7052 If RealModeBufferSize is NULL, then ASSERT().
7053 If ExtraStackSize is NULL, then ASSERT().
7055 @param RealModeBufferSize A pointer to the size of the buffer below 1MB
7056 required to use the 16-bit thunk functions.
7057 @param ExtraStackSize A pointer to the extra size of stack below 1MB
7058 that the 16-bit thunk functions require for
7059 temporary storage in the transition to and from
7065 AsmGetThunk16Properties (
7066 OUT UINT32
*RealModeBufferSize
,
7067 OUT UINT32
*ExtraStackSize
7072 Prepares all structures a code required to use AsmThunk16().
7074 Prepares all structures and code required to use AsmThunk16().
7076 If ThunkContext is NULL, then ASSERT().
7078 @param ThunkContext A pointer to the context structure that describes the
7079 16-bit real mode code to call.
7085 OUT THUNK_CONTEXT
*ThunkContext
7090 Transfers control to a 16-bit real mode entry point and returns the results.
7092 Transfers control to a 16-bit real mode entry point and returns the results.
7093 AsmPrepareThunk16() must be called with ThunkContext before this function is
7096 If ThunkContext is NULL, then ASSERT().
7097 If AsmPrepareThunk16() was not previously called with ThunkContext, then ASSERT().
7099 @param ThunkContext A pointer to the context structure that describes the
7100 16-bit real mode code to call.
7106 IN OUT THUNK_CONTEXT
*ThunkContext
7111 Prepares all structures and code for a 16-bit real mode thunk, transfers
7112 control to a 16-bit real mode entry point, and returns the results.
7114 Prepares all structures and code for a 16-bit real mode thunk, transfers
7115 control to a 16-bit real mode entry point, and returns the results. If the
7116 caller only need to perform a single 16-bit real mode thunk, then this
7117 service should be used. If the caller intends to make more than one 16-bit
7118 real mode thunk, then it is more efficient if AsmPrepareThunk16() is called
7119 once and AsmThunk16() can be called for each 16-bit real mode thunk.
7121 If ThunkContext is NULL, then ASSERT().
7123 @param ThunkContext A pointer to the context structure that describes the
7124 16-bit real mode code to call.
7129 AsmPrepareAndThunk16 (
7130 IN OUT THUNK_CONTEXT
*ThunkContext