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
20 #include <IndustryStandard/Pal.h>
23 // Definitions for architecture specific types
24 // These include SPIN_LOCK and BASE_LIBRARY_JUMP_BUFFER
30 typedef volatile UINTN SPIN_LOCK
;
32 #if defined (MDE_CPU_IA32)
34 // IA32 context buffer used by SetJump() and LongJump()
43 } BASE_LIBRARY_JUMP_BUFFER
;
45 #define BASE_LIBRARY_JUMP_BUFFER_ALIGNMENT 8
47 #elif defined (MDE_CPU_IPF)
49 // IPF context buffer used by SetJump() and LongJump()
84 UINT64 AfterSpillUNAT
;
90 } BASE_LIBRARY_JUMP_BUFFER
;
92 #define BASE_LIBRARY_JUMP_BUFFER_ALIGNMENT 0x10
94 #elif defined (MDE_CPU_X64)
96 // X64 context buffer used by SetJump() and LongJump()
109 } BASE_LIBRARY_JUMP_BUFFER
;
111 #define BASE_LIBRARY_JUMP_BUFFER_ALIGNMENT 8
113 #elif defined (MDE_CPU_EBC)
115 // EBC context buffer used by SetJump() and LongJump()
123 } BASE_LIBRARY_JUMP_BUFFER
;
125 #define BASE_LIBRARY_JUMP_BUFFER_ALIGNMENT 8
128 #error Unknown Processor Type
136 Copies one Null-terminated Unicode string to another Null-terminated Unicode
137 string and returns the new Unicode string.
139 This function copies the contents of the Unicode string Source to the Unicode
140 string Destination, and returns Destination. If Source and Destination
141 overlap, then the results are undefined.
143 If Destination is NULL, then ASSERT().
144 If Destination is not aligned on a 16-bit boundary, then ASSERT().
145 If Source is NULL, then ASSERT().
146 If Source is not aligned on a 16-bit boundary, then ASSERT().
147 If Source and Destination overlap, then ASSERT().
148 If PcdMaximumUnicodeStringLength is not zero, and Source contains more than
149 PcdMaximumUnicodeStringLength Unicode characters not including the
150 Null-terminator, then ASSERT().
152 @param Destination Pointer to a Null-terminated Unicode string.
153 @param Source Pointer to a Null-terminated Unicode string.
161 OUT CHAR16
*Destination
,
162 IN CONST CHAR16
*Source
167 Copies one Null-terminated Unicode string with a maximum length to another
168 Null-terminated Unicode string with a maximum length and returns the new
171 This function copies the contents of the Unicode string Source to the Unicode
172 string Destination, and returns Destination. At most, Length Unicode
173 characters are copied from Source to Destination. If Length is 0, then
174 Destination is returned unmodified. If Length is greater that the number of
175 Unicode characters in Source, then Destination is padded with Null Unicode
176 characters. If Source and Destination overlap, then the results are
179 If Length > 0 and Destination is NULL, then ASSERT().
180 If Length > 0 and Destination is not aligned on a 16-bit boundary, then ASSERT().
181 If Length > 0 and Source is NULL, then ASSERT().
182 If Length > 0 and Source is not aligned on a 16-bit bounadry, then ASSERT().
183 If Source and Destination overlap, then ASSERT().
184 If PcdMaximumUnicodeStringLength is not zero, and Source contains more than
185 PcdMaximumUnicodeStringLength Unicode characters not including the
186 Null-terminator, then ASSERT().
188 @param Destination Pointer to a Null-terminated Unicode string.
189 @param Source Pointer to a Null-terminated Unicode string.
190 @param Length Maximum number of Unicode characters to copy.
198 OUT CHAR16
*Destination
,
199 IN CONST CHAR16
*Source
,
205 Returns the length of a Null-terminated Unicode string.
207 This function returns the number of Unicode characters in the Null-terminated
208 Unicode string specified by String.
210 If String is NULL, then ASSERT().
211 If String is not aligned on a 16-bit boundary, then ASSERT().
212 If PcdMaximumUnicodeStringLength is not zero, and String contains more than
213 PcdMaximumUnicodeStringLength Unicode characters not including the
214 Null-terminator, then ASSERT().
216 @param String Pointer to a Null-terminated Unicode string.
218 @return The length of String.
224 IN CONST CHAR16
*String
229 Returns the size of a Null-terminated Unicode string in bytes, including the
232 This function returns the size, in bytes, of the Null-terminated Unicode
233 string specified by String.
235 If String is NULL, then ASSERT().
236 If String is not aligned on a 16-bit boundary, then ASSERT().
237 If PcdMaximumUnicodeStringLength is not zero, and String contains more than
238 PcdMaximumUnicodeStringLength Unicode characters not including the
239 Null-terminator, then ASSERT().
241 @param String Pointer to a Null-terminated Unicode string.
243 @return The size of String.
249 IN CONST CHAR16
*String
254 Compares two Null-terminated Unicode strings, and returns the difference
255 between the first mismatched Unicode characters.
257 This function compares the Null-terminated Unicode string FirstString to the
258 Null-terminated Unicode string SecondString. If FirstString is identical to
259 SecondString, then 0 is returned. Otherwise, the value returned is the first
260 mismatched Unicode character in SecondString subtracted from the first
261 mismatched Unicode character in FirstString.
263 If FirstString is NULL, then ASSERT().
264 If FirstString is not aligned on a 16-bit boundary, then ASSERT().
265 If SecondString is NULL, then ASSERT().
266 If SecondString is not aligned on a 16-bit boundary, then ASSERT().
267 If PcdMaximumUnicodeStringLength is not zero, and FirstString contains more
268 than PcdMaximumUnicodeStringLength Unicode characters not including the
269 Null-terminator, then ASSERT().
270 If PcdMaximumUnicodeStringLength is not zero, and SecondString contains more
271 than PcdMaximumUnicodeStringLength Unicode characters not including the
272 Null-terminator, then ASSERT().
274 @param FirstString Pointer to a Null-terminated Unicode string.
275 @param SecondString Pointer to a Null-terminated Unicode string.
277 @retval 0 FirstString is identical to SecondString.
278 @retval !=0 FirstString is not identical to SecondString.
284 IN CONST CHAR16
*FirstString
,
285 IN CONST CHAR16
*SecondString
290 Compares two Null-terminated Unicode strings with maximum lengths, and
291 returns the difference between the first mismatched Unicode characters.
293 This function compares the Null-terminated Unicode string FirstString to the
294 Null-terminated Unicode string SecondString. At most, Length Unicode
295 characters will be compared. If Length is 0, then 0 is returned. If
296 FirstString is identical to SecondString, then 0 is returned. Otherwise, the
297 value returned is the first mismatched Unicode character in SecondString
298 subtracted from the first mismatched Unicode character in FirstString.
300 If Length > 0 and FirstString is NULL, then ASSERT().
301 If Length > 0 and FirstString is not aligned on a 16-bit bounadary, then ASSERT().
302 If Length > 0 and SecondString is NULL, then ASSERT().
303 If Length > 0 and SecondString is not aligned on a 16-bit bounadary, then ASSERT().
304 If PcdMaximumUnicodeStringLength is not zero, and FirstString contains more
305 than PcdMaximumUnicodeStringLength Unicode characters not including the
306 Null-terminator, then ASSERT().
307 If PcdMaximumUnicodeStringLength is not zero, and SecondString contains more
308 than PcdMaximumUnicodeStringLength Unicode characters not including the
309 Null-terminator, then ASSERT().
311 @param FirstString Pointer to a Null-terminated Unicode string.
312 @param SecondString Pointer to a Null-terminated Unicode string.
313 @param Length Maximum number of Unicode characters to compare.
315 @retval 0 FirstString is identical to SecondString.
316 @retval !=0 FirstString is not identical to SecondString.
322 IN CONST CHAR16
*FirstString
,
323 IN CONST CHAR16
*SecondString
,
329 Concatenates one Null-terminated Unicode string to another Null-terminated
330 Unicode string, and returns the concatenated Unicode string.
332 This function concatenates two Null-terminated Unicode strings. The contents
333 of Null-terminated Unicode string Source are concatenated to the end of
334 Null-terminated Unicode string Destination. The Null-terminated concatenated
335 Unicode String is returned. If Source and Destination overlap, then the
336 results are undefined.
338 If Destination is NULL, then ASSERT().
339 If Destination is not aligned on a 16-bit bounadary, then ASSERT().
340 If Source is NULL, then ASSERT().
341 If Source is not aligned on a 16-bit bounadary, then ASSERT().
342 If Source and Destination overlap, then ASSERT().
343 If PcdMaximumUnicodeStringLength is not zero, and Destination contains more
344 than PcdMaximumUnicodeStringLength Unicode characters not including the
345 Null-terminator, then ASSERT().
346 If PcdMaximumUnicodeStringLength is not zero, and Source contains more than
347 PcdMaximumUnicodeStringLength Unicode characters not including the
348 Null-terminator, then ASSERT().
349 If PcdMaximumUnicodeStringLength is not zero, and concatenating Destination
350 and Source results in a Unicode string with more than
351 PcdMaximumUnicodeStringLength Unicode characters not including the
352 Null-terminator, then ASSERT().
354 @param Destination Pointer to a Null-terminated Unicode string.
355 @param Source Pointer to a Null-terminated Unicode string.
363 IN OUT CHAR16
*Destination
,
364 IN CONST CHAR16
*Source
369 Concatenates one Null-terminated Unicode string with a maximum length to the
370 end of another Null-terminated Unicode string, and returns the concatenated
373 This function concatenates two Null-terminated Unicode strings. The contents
374 of Null-terminated Unicode string Source are concatenated to the end of
375 Null-terminated Unicode string Destination, and Destination is returned. At
376 most, Length Unicode characters are concatenated from Source to the end of
377 Destination, and Destination is always Null-terminated. If Length is 0, then
378 Destination is returned unmodified. If Source and Destination overlap, then
379 the results are undefined.
381 If Destination is NULL, then ASSERT().
382 If Length > 0 and Destination is not aligned on a 16-bit boundary, then ASSERT().
383 If Length > 0 and Source is NULL, then ASSERT().
384 If Length > 0 and Source is not aligned on a 16-bit boundary, then ASSERT().
385 If Source and Destination overlap, then ASSERT().
386 If PcdMaximumUnicodeStringLength is not zero, and Destination contains more
387 than PcdMaximumUnicodeStringLength Unicode characters not including the
388 Null-terminator, then ASSERT().
389 If PcdMaximumUnicodeStringLength is not zero, and Source contains more than
390 PcdMaximumUnicodeStringLength Unicode characters not including the
391 Null-terminator, then ASSERT().
392 If PcdMaximumUnicodeStringLength is not zero, and concatenating Destination
393 and Source results in a Unicode string with more than
394 PcdMaximumUnicodeStringLength Unicode characters not including the
395 Null-terminator, then ASSERT().
397 @param Destination Pointer to a Null-terminated Unicode string.
398 @param Source Pointer to a Null-terminated Unicode string.
399 @param Length Maximum number of Unicode characters to concatenate from
408 IN OUT CHAR16
*Destination
,
409 IN CONST CHAR16
*Source
,
414 Returns the first occurance of a Null-terminated Unicode sub-string
415 in a Null-terminated Unicode string.
417 This function scans the contents of the Null-terminated Unicode string
418 specified by String and returns the first occurrence of SearchString.
419 If SearchString is not found in String, then NULL is returned. If
420 the length of SearchString is zero, then String is
423 If String is NULL, then ASSERT().
424 If String is not aligned on a 16-bit boundary, then ASSERT().
425 If SearchString is NULL, then ASSERT().
426 If SearchString is not aligned on a 16-bit boundary, then ASSERT().
428 If PcdMaximumUnicodeStringLength is not zero, and SearchString
429 or String contains more than PcdMaximumUnicodeStringLength Unicode
430 characters not including the Null-terminator, then ASSERT().
432 @param String Pointer to a Null-terminated Unicode string.
433 @param SearchString Pointer to a Null-terminated Unicode string to search for.
435 @retval NULL If the SearchString does not appear in String.
436 @retval !NULL If there is a match.
442 IN CONST CHAR16
*String
,
443 IN CONST CHAR16
*SearchString
447 Convert a Null-terminated Unicode decimal string to a value of
450 This function returns a value of type UINTN by interpreting the contents
451 of the Unicode string specified by String as a decimal number. The format
452 of the input Unicode string String is:
454 [spaces] [decimal digits].
456 The valid decimal digit character is in the range [0-9]. The
457 function will ignore the pad space, which includes spaces or
458 tab characters, before [decimal digits]. The running zero in the
459 beginning of [decimal digits] will be ignored. Then, the function
460 stops at the first character that is a not a valid decimal character
461 or a Null-terminator, whichever one comes first.
463 If String is NULL, then ASSERT().
464 If String is not aligned in a 16-bit boundary, then ASSERT().
465 If String has only pad spaces, then 0 is returned.
466 If String has no pad spaces or valid decimal digits,
468 If the number represented by String overflows according
469 to the range defined by UINTN, then ASSERT().
471 If PcdMaximumUnicodeStringLength is not zero, and String contains
472 more than PcdMaximumUnicodeStringLength Unicode characters not including
473 the Null-terminator, then ASSERT().
475 @param String Pointer to a Null-terminated Unicode string.
483 IN CONST CHAR16
*String
487 Convert a Null-terminated Unicode decimal string to a value of
490 This function returns a value of type UINT64 by interpreting the contents
491 of the Unicode string specified by String as a decimal number. The format
492 of the input Unicode string String is:
494 [spaces] [decimal digits].
496 The valid decimal digit character is in the range [0-9]. The
497 function will ignore the pad space, which includes spaces or
498 tab characters, before [decimal digits]. The running zero in the
499 beginning of [decimal digits] will be ignored. Then, the function
500 stops at the first character that is a not a valid decimal character
501 or a Null-terminator, whichever one comes first.
503 If String is NULL, then ASSERT().
504 If String is not aligned in a 16-bit boundary, then ASSERT().
505 If String has only pad spaces, then 0 is returned.
506 If String has no pad spaces or valid decimal digits,
508 If the number represented by String overflows according
509 to the range defined by UINT64, then ASSERT().
511 If PcdMaximumUnicodeStringLength is not zero, and String contains
512 more than PcdMaximumUnicodeStringLength Unicode characters not including
513 the Null-terminator, then ASSERT().
515 @param String Pointer to a Null-terminated Unicode string.
523 IN CONST CHAR16
*String
528 Convert a Null-terminated Unicode hexadecimal string to a value of type UINTN.
530 This function returns a value of type UINTN by interpreting the contents
531 of the Unicode string specified by String as a hexadecimal number.
532 The format of the input Unicode string String is:
534 [spaces][zeros][x][hexadecimal digits].
536 The valid hexadecimal digit character is in the range [0-9], [a-f] and [A-F].
537 The prefix "0x" is optional. Both "x" and "X" is allowed in "0x" prefix.
538 If "x" appears in the input string, it must be prefixed with at least one 0.
539 The function will ignore the pad space, which includes spaces or tab characters,
540 before [zeros], [x] or [hexadecimal digit]. The running zero before [x] or
541 [hexadecimal digit] will be ignored. Then, the decoding starts after [x] or the
542 first valid hexadecimal digit. Then, the function stops at the first character that is
543 a not a valid hexadecimal character or NULL, whichever one comes first.
545 If String is NULL, then ASSERT().
546 If String is not aligned in a 16-bit boundary, then ASSERT().
547 If String has only pad spaces, then zero is returned.
548 If String has no leading pad spaces, leading zeros or valid hexadecimal digits,
549 then zero is returned.
550 If the number represented by String overflows according to the range defined by
551 UINTN, then ASSERT().
553 If PcdMaximumUnicodeStringLength is not zero, and String contains more than
554 PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator,
557 @param String Pointer to a Null-terminated Unicode string.
565 IN CONST CHAR16
*String
570 Convert a Null-terminated Unicode hexadecimal string to a value of type UINT64.
572 This function returns a value of type UINT64 by interpreting the contents
573 of the Unicode string specified by String as a hexadecimal number.
574 The format of the input Unicode string String is
576 [spaces][zeros][x][hexadecimal digits].
578 The valid hexadecimal digit character is in the range [0-9], [a-f] and [A-F].
579 The prefix "0x" is optional. Both "x" and "X" is allowed in "0x" prefix.
580 If "x" appears in the input string, it must be prefixed with at least one 0.
581 The function will ignore the pad space, which includes spaces or tab characters,
582 before [zeros], [x] or [hexadecimal digit]. The running zero before [x] or
583 [hexadecimal digit] will be ignored. Then, the decoding starts after [x] or the
584 first valid hexadecimal digit. Then, the function stops at the first character that is
585 a not a valid hexadecimal character or NULL, whichever one comes first.
587 If String is NULL, then ASSERT().
588 If String is not aligned in a 16-bit boundary, then ASSERT().
589 If String has only pad spaces, then zero is returned.
590 If String has no leading pad spaces, leading zeros or valid hexadecimal digits,
591 then zero is returned.
592 If the number represented by String overflows according to the range defined by
593 UINT64, then ASSERT().
595 If PcdMaximumUnicodeStringLength is not zero, and String contains more than
596 PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator,
599 @param String Pointer to a Null-terminated Unicode string.
607 IN CONST CHAR16
*String
612 Convert one Null-terminated Unicode string to a Null-terminated
613 ASCII string and returns the ASCII string.
615 This function converts the content of the Unicode string Source
616 to the ASCII string Destination by copying the lower 8 bits of
617 each Unicode character. It returns Destination.
619 If any Unicode characters in Source contain non-zero value in
620 the upper 8 bits, then ASSERT().
622 If Destination is NULL, then ASSERT().
623 If Source is NULL, then ASSERT().
624 If Source is not aligned on a 16-bit boundary, then ASSERT().
625 If Source and Destination overlap, then ASSERT().
627 If PcdMaximumUnicodeStringLength is not zero, and Source contains
628 more than PcdMaximumUnicodeStringLength Unicode characters not including
629 the Null-terminator, then ASSERT().
631 If PcdMaximumAsciiStringLength is not zero, and Source contains more
632 than PcdMaximumAsciiStringLength Unicode characters not including the
633 Null-terminator, then ASSERT().
635 @param Source Pointer to a Null-terminated Unicode string.
636 @param Destination Pointer to a Null-terminated ASCII string.
643 UnicodeStrToAsciiStr (
644 IN CONST CHAR16
*Source
,
645 OUT CHAR8
*Destination
650 Copies one Null-terminated ASCII string to another Null-terminated ASCII
651 string and returns the new ASCII string.
653 This function copies the contents of the ASCII string Source to the ASCII
654 string Destination, and returns Destination. If Source and Destination
655 overlap, then the results are undefined.
657 If Destination is NULL, then ASSERT().
658 If Source is NULL, then ASSERT().
659 If Source and Destination overlap, then ASSERT().
660 If PcdMaximumAsciiStringLength is not zero and Source contains more than
661 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
664 @param Destination Pointer to a Null-terminated ASCII string.
665 @param Source Pointer to a Null-terminated ASCII string.
673 OUT CHAR8
*Destination
,
674 IN CONST CHAR8
*Source
679 Copies one Null-terminated ASCII string with a maximum length to another
680 Null-terminated ASCII string with a maximum length and returns the new ASCII
683 This function copies the contents of the ASCII string Source to the ASCII
684 string Destination, and returns Destination. At most, Length ASCII characters
685 are copied from Source to Destination. If Length is 0, then Destination is
686 returned unmodified. If Length is greater that the number of ASCII characters
687 in Source, then Destination is padded with Null ASCII characters. If Source
688 and Destination overlap, then the results are undefined.
690 If Destination is NULL, then ASSERT().
691 If Source is NULL, then ASSERT().
692 If Source and Destination overlap, then ASSERT().
693 If PcdMaximumAsciiStringLength is not zero, and Source contains more than
694 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
697 @param Destination Pointer to a Null-terminated ASCII string.
698 @param Source Pointer to a Null-terminated ASCII string.
699 @param Length Maximum number of ASCII characters to copy.
707 OUT CHAR8
*Destination
,
708 IN CONST CHAR8
*Source
,
714 Returns the length of a Null-terminated ASCII string.
716 This function returns the number of ASCII characters in the Null-terminated
717 ASCII string specified by String.
719 If Length > 0 and Destination is NULL, then ASSERT().
720 If Length > 0 and Source is NULL, then ASSERT().
721 If PcdMaximumAsciiStringLength is not zero and String contains more than
722 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
725 @param String Pointer to a Null-terminated ASCII string.
727 @return The length of String.
733 IN CONST CHAR8
*String
738 Returns the size of a Null-terminated ASCII string in bytes, including the
741 This function returns the size, in bytes, of the Null-terminated ASCII string
744 If String is NULL, then ASSERT().
745 If PcdMaximumAsciiStringLength is not zero and String contains more than
746 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
749 @param String Pointer to a Null-terminated ASCII string.
751 @return The size of String.
757 IN CONST CHAR8
*String
762 Compares two Null-terminated ASCII strings, and returns the difference
763 between the first mismatched ASCII characters.
765 This function compares the Null-terminated ASCII string FirstString to the
766 Null-terminated ASCII string SecondString. If FirstString is identical to
767 SecondString, then 0 is returned. Otherwise, the value returned is the first
768 mismatched ASCII character in SecondString subtracted from the first
769 mismatched ASCII character in FirstString.
771 If FirstString is NULL, then ASSERT().
772 If SecondString is NULL, then ASSERT().
773 If PcdMaximumAsciiStringLength is not zero and FirstString contains more than
774 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
776 If PcdMaximumAsciiStringLength is not zero and SecondString contains more
777 than PcdMaximumAsciiStringLength ASCII characters not including the
778 Null-terminator, then ASSERT().
780 @param FirstString Pointer to a Null-terminated ASCII string.
781 @param SecondString Pointer to a Null-terminated ASCII string.
783 @retval 0 FirstString is identical to SecondString.
784 @retval !=0 FirstString is not identical to SecondString.
790 IN CONST CHAR8
*FirstString
,
791 IN CONST CHAR8
*SecondString
796 Performs a case insensitive comparison of two Null-terminated ASCII strings,
797 and returns the difference between the first mismatched ASCII characters.
799 This function performs a case insensitive comparison of the Null-terminated
800 ASCII string FirstString to the Null-terminated ASCII string SecondString. If
801 FirstString is identical to SecondString, then 0 is returned. Otherwise, the
802 value returned is the first mismatched lower case ASCII character in
803 SecondString subtracted from the first mismatched lower case ASCII character
806 If FirstString is NULL, then ASSERT().
807 If SecondString is NULL, then ASSERT().
808 If PcdMaximumAsciiStringLength is not zero and FirstString contains more than
809 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
811 If PcdMaximumAsciiStringLength is not zero and SecondString contains more
812 than PcdMaximumAsciiStringLength ASCII characters not including the
813 Null-terminator, then ASSERT().
815 @param FirstString Pointer to a Null-terminated ASCII string.
816 @param SecondString Pointer to a Null-terminated ASCII string.
818 @retval 0 FirstString is identical to SecondString using case insensitive
820 @retval !=0 FirstString is not identical to SecondString using case
821 insensitive comparisons.
827 IN CONST CHAR8
*FirstString
,
828 IN CONST CHAR8
*SecondString
833 Compares two Null-terminated ASCII strings with maximum lengths, and returns
834 the difference between the first mismatched ASCII characters.
836 This function compares the Null-terminated ASCII string FirstString to the
837 Null-terminated ASCII string SecondString. At most, Length ASCII characters
838 will be compared. If Length is 0, then 0 is returned. If FirstString is
839 identical to SecondString, then 0 is returned. Otherwise, the value returned
840 is the first mismatched ASCII character in SecondString subtracted from the
841 first mismatched ASCII character in FirstString.
843 If Length > 0 and FirstString is NULL, then ASSERT().
844 If Length > 0 and SecondString is NULL, then ASSERT().
845 If PcdMaximumAsciiStringLength is not zero and FirstString contains more than
846 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
848 If PcdMaximumAsciiStringLength is not zero and SecondString contains more than
849 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
852 @param FirstString Pointer to a Null-terminated ASCII string.
853 @param SecondString Pointer to a Null-terminated ASCII string.
855 @retval 0 FirstString is identical to SecondString.
856 @retval !=0 FirstString is not identical to SecondString.
862 IN CONST CHAR8
*FirstString
,
863 IN CONST CHAR8
*SecondString
,
869 Concatenates one Null-terminated ASCII string to another Null-terminated
870 ASCII string, and returns the concatenated ASCII string.
872 This function concatenates two Null-terminated ASCII strings. The contents of
873 Null-terminated ASCII string Source are concatenated to the end of Null-
874 terminated ASCII string Destination. The Null-terminated concatenated ASCII
877 If Destination is NULL, then ASSERT().
878 If Source is NULL, then ASSERT().
879 If PcdMaximumAsciiStringLength is not zero and Destination contains more than
880 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
882 If PcdMaximumAsciiStringLength is not zero and Source contains more than
883 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
885 If PcdMaximumAsciiStringLength is not zero and concatenating Destination and
886 Source results in a ASCII string with more than PcdMaximumAsciiStringLength
887 ASCII characters, then ASSERT().
889 @param Destination Pointer to a Null-terminated ASCII string.
890 @param Source Pointer to a Null-terminated ASCII string.
898 IN OUT CHAR8
*Destination
,
899 IN CONST CHAR8
*Source
904 Concatenates one Null-terminated ASCII string with a maximum length to the
905 end of another Null-terminated ASCII string, and returns the concatenated
908 This function concatenates two Null-terminated ASCII strings. The contents
909 of Null-terminated ASCII string Source are concatenated to the end of Null-
910 terminated ASCII string Destination, and Destination is returned. At most,
911 Length ASCII characters are concatenated from Source to the end of
912 Destination, and Destination is always Null-terminated. If Length is 0, then
913 Destination is returned unmodified. If Source and Destination overlap, then
914 the results are undefined.
916 If Length > 0 and Destination is NULL, then ASSERT().
917 If Length > 0 and Source is NULL, then ASSERT().
918 If Source and Destination overlap, then ASSERT().
919 If PcdMaximumAsciiStringLength is not zero, and Destination contains more than
920 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
922 If PcdMaximumAsciiStringLength is not zero, and Source contains more than
923 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
925 If PcdMaximumAsciiStringLength is not zero, and concatenating Destination and
926 Source results in a ASCII string with more than PcdMaximumAsciiStringLength
927 ASCII characters not including the Null-terminator, then ASSERT().
929 @param Destination Pointer to a Null-terminated ASCII string.
930 @param Source Pointer to a Null-terminated ASCII string.
931 @param Length Maximum number of ASCII characters to concatenate from
940 IN OUT CHAR8
*Destination
,
941 IN CONST CHAR8
*Source
,
947 Returns the first occurance of a Null-terminated ASCII sub-string
948 in a Null-terminated ASCII string.
950 This function scans the contents of the ASCII string specified by String
951 and returns the first occurrence of SearchString. If SearchString is not
952 found in String, then NULL is returned. If the length of SearchString is zero,
953 then String is returned.
955 If String is NULL, then ASSERT().
956 If SearchString is NULL, then ASSERT().
958 If PcdMaximumAsciiStringLength is not zero, and SearchString or
959 String contains more than PcdMaximumAsciiStringLength Unicode characters
960 not including the Null-terminator, then ASSERT().
962 @param String Pointer to a Null-terminated ASCII string.
963 @param SearchString Pointer to a Null-terminated ASCII string to search for.
965 @retval NULL If the SearchString does not appear in String.
966 @retval !NULL If there is a match.
972 IN CONST CHAR8
*String
,
973 IN CONST CHAR8
*SearchString
978 Convert a Null-terminated ASCII decimal string to a value of type
981 This function returns a value of type UINTN by interpreting the contents
982 of the ASCII string String as a decimal number. The format of the input
983 ASCII string String is:
985 [spaces] [decimal digits].
987 The valid decimal digit character is in the range [0-9]. The function will
988 ignore the pad space, which includes spaces or tab characters, before the digits.
989 The running zero in the beginning of [decimal digits] will be ignored. Then, the
990 function stops at the first character that is a not a valid decimal character or
991 Null-terminator, whichever on comes first.
993 If String has only pad spaces, then 0 is returned.
994 If String has no pad spaces or valid decimal digits, then 0 is returned.
995 If the number represented by String overflows according to the range defined by
996 UINTN, then ASSERT().
997 If String is NULL, then ASSERT().
998 If PcdMaximumAsciiStringLength is not zero, and String contains more than
999 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
1002 @param String Pointer to a Null-terminated ASCII string.
1009 AsciiStrDecimalToUintn (
1010 IN CONST CHAR8
*String
1015 Convert a Null-terminated ASCII decimal string to a value of type
1018 This function returns a value of type UINT64 by interpreting the contents
1019 of the ASCII string String as a decimal number. The format of the input
1020 ASCII string String is:
1022 [spaces] [decimal digits].
1024 The valid decimal digit character is in the range [0-9]. The function will
1025 ignore the pad space, which includes spaces or tab characters, before the digits.
1026 The running zero in the beginning of [decimal digits] will be ignored. Then, the
1027 function stops at the first character that is a not a valid decimal character or
1028 Null-terminator, whichever on comes first.
1030 If String has only pad spaces, then 0 is returned.
1031 If String has no pad spaces or valid decimal digits, then 0 is returned.
1032 If the number represented by String overflows according to the range defined by
1033 UINT64, then ASSERT().
1034 If String is NULL, then ASSERT().
1035 If PcdMaximumAsciiStringLength is not zero, and String contains more than
1036 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
1039 @param String Pointer to a Null-terminated ASCII string.
1046 AsciiStrDecimalToUint64 (
1047 IN CONST CHAR8
*String
1052 Convert a Null-terminated ASCII hexadecimal string to a value of type UINTN.
1054 This function returns a value of type UINTN by interpreting the contents of
1055 the ASCII string String as a hexadecimal number. The format of the input ASCII
1058 [spaces][zeros][x][hexadecimal digits].
1060 The valid hexadecimal digit character is in the range [0-9], [a-f] and [A-F].
1061 The prefix "0x" is optional. Both "x" and "X" is allowed in "0x" prefix. If "x"
1062 appears in the input string, it must be prefixed with at least one 0. The function
1063 will ignore the pad space, which includes spaces or tab characters, before [zeros],
1064 [x] or [hexadecimal digits]. The running zero before [x] or [hexadecimal digits]
1065 will be ignored. Then, the decoding starts after [x] or the first valid hexadecimal
1066 digit. Then, the function stops at the first character that is a not a valid
1067 hexadecimal character or Null-terminator, whichever on comes first.
1069 If String has only pad spaces, then 0 is returned.
1070 If String has no leading pad spaces, leading zeros or valid hexadecimal digits, then
1073 If the number represented by String overflows according to the range defined by UINTN,
1075 If String is NULL, then ASSERT().
1076 If PcdMaximumAsciiStringLength is not zero,
1077 and String contains more than PcdMaximumAsciiStringLength ASCII characters not including
1078 the Null-terminator, then ASSERT().
1080 @param String Pointer to a Null-terminated ASCII string.
1087 AsciiStrHexToUintn (
1088 IN CONST CHAR8
*String
1093 Convert a Null-terminated ASCII hexadecimal string to a value of type UINT64.
1095 This function returns a value of type UINT64 by interpreting the contents of
1096 the ASCII string String as a hexadecimal number. The format of the input ASCII
1099 [spaces][zeros][x][hexadecimal digits].
1101 The valid hexadecimal digit character is in the range [0-9], [a-f] and [A-F].
1102 The prefix "0x" is optional. Both "x" and "X" is allowed in "0x" prefix. If "x"
1103 appears in the input string, it must be prefixed with at least one 0. The function
1104 will ignore the pad space, which includes spaces or tab characters, before [zeros],
1105 [x] or [hexadecimal digits]. The running zero before [x] or [hexadecimal digits]
1106 will be ignored. Then, the decoding starts after [x] or the first valid hexadecimal
1107 digit. Then, the function stops at the first character that is a not a valid
1108 hexadecimal character or Null-terminator, whichever on comes first.
1110 If String has only pad spaces, then 0 is returned.
1111 If String has no leading pad spaces, leading zeros or valid hexadecimal digits, then
1114 If the number represented by String overflows according to the range defined by UINT64,
1116 If String is NULL, then ASSERT().
1117 If PcdMaximumAsciiStringLength is not zero,
1118 and String contains more than PcdMaximumAsciiStringLength ASCII characters not including
1119 the Null-terminator, then ASSERT().
1121 @param String Pointer to a Null-terminated ASCII string.
1128 AsciiStrHexToUint64 (
1129 IN CONST CHAR8
*String
1134 Convert one Null-terminated ASCII string to a Null-terminated
1135 Unicode string and returns the Unicode string.
1137 This function converts the contents of the ASCII string Source to the Unicode
1138 string Destination, and returns Destination. The function terminates the
1139 Unicode string Destination by appending a Null-terminator character at the end.
1140 The caller is responsible to make sure Destination points to a buffer with size
1141 equal or greater than ((AsciiStrLen (Source) + 1) * sizeof (CHAR16)) in bytes.
1143 If Destination is NULL, then ASSERT().
1144 If Destination is not aligned on a 16-bit boundary, then ASSERT().
1145 If Source is NULL, then ASSERT().
1146 If Source and Destination overlap, then ASSERT().
1147 If PcdMaximumAsciiStringLength is not zero, and Source contains more than
1148 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
1150 If PcdMaximumUnicodeStringLength is not zero, and Source contains more than
1151 PcdMaximumUnicodeStringLength ASCII characters not including the
1152 Null-terminator, then ASSERT().
1154 @param Source Pointer to a Null-terminated ASCII string.
1155 @param Destination Pointer to a Null-terminated Unicode string.
1162 AsciiStrToUnicodeStr (
1163 IN CONST CHAR8
*Source
,
1164 OUT CHAR16
*Destination
1169 Converts an 8-bit value to an 8-bit BCD value.
1171 Converts the 8-bit value specified by Value to BCD. The BCD value is
1174 If Value >= 100, then ASSERT().
1176 @param Value The 8-bit value to convert to BCD. Range 0..99.
1178 @return The BCD value
1189 Converts an 8-bit BCD value to an 8-bit value.
1191 Converts the 8-bit BCD value specified by Value to an 8-bit value. The 8-bit
1194 If Value >= 0xA0, then ASSERT().
1195 If (Value & 0x0F) >= 0x0A, then ASSERT().
1197 @param Value The 8-bit BCD value to convert to an 8-bit value.
1199 @return The 8-bit value is returned.
1210 // Linked List Functions and Macros
1214 Initializes the head node of a doubly linked list that is declared as a
1215 global variable in a module.
1217 Initializes the forward and backward links of a new linked list. After
1218 initializing a linked list with this macro, the other linked list functions
1219 may be used to add and remove nodes from the linked list. This macro results
1220 in smaller executables by initializing the linked list in the data section,
1221 instead if calling the InitializeListHead() function to perform the
1222 equivalent operation.
1224 @param ListHead The head note of a list to initiailize.
1227 #define INITIALIZE_LIST_HEAD_VARIABLE(ListHead) {&ListHead, &ListHead}
1231 Initializes the head node of a doubly linked list, and returns the pointer to
1232 the head node of the doubly linked list.
1234 Initializes the forward and backward links of a new linked list. After
1235 initializing a linked list with this function, the other linked list
1236 functions may be used to add and remove nodes from the linked list. It is up
1237 to the caller of this function to allocate the memory for ListHead.
1239 If ListHead is NULL, then ASSERT().
1241 @param ListHead A pointer to the head node of a new doubly linked list.
1248 InitializeListHead (
1249 IN LIST_ENTRY
*ListHead
1254 Adds a node to the beginning of a doubly linked list, and returns the pointer
1255 to the head node of the doubly linked list.
1257 Adds the node Entry at the beginning of the doubly linked list denoted by
1258 ListHead, and returns ListHead.
1260 If ListHead is NULL, then ASSERT().
1261 If Entry is NULL, then ASSERT().
1262 If ListHead was not initialized with InitializeListHead(), then ASSERT().
1263 If PcdMaximumLinkedListLenth is not zero, and prior to insertion the number
1264 of nodes in ListHead, including the ListHead node, is greater than or
1265 equal to PcdMaximumLinkedListLength, then ASSERT().
1267 @param ListHead A pointer to the head node of a doubly linked list.
1268 @param Entry A pointer to a node that is to be inserted at the beginning
1269 of a doubly linked list.
1277 IN LIST_ENTRY
*ListHead
,
1278 IN LIST_ENTRY
*Entry
1283 Adds a node to the end of a doubly linked list, and returns the pointer to
1284 the head node of the doubly linked list.
1286 Adds the node Entry to the end of the doubly linked list denoted by ListHead,
1287 and returns ListHead.
1289 If ListHead is NULL, then ASSERT().
1290 If Entry is NULL, then ASSERT().
1291 If ListHead was not initialized with InitializeListHead(), then ASSERT().
1292 If PcdMaximumLinkedListLenth is not zero, and prior to insertion the number
1293 of nodes in ListHead, including the ListHead node, is greater than or
1294 equal to PcdMaximumLinkedListLength, then ASSERT().
1296 @param ListHead A pointer to the head node of a doubly linked list.
1297 @param Entry A pointer to a node that is to be added at the end of the
1306 IN LIST_ENTRY
*ListHead
,
1307 IN LIST_ENTRY
*Entry
1312 Retrieves the first node of a doubly linked list.
1314 Returns the first node of a doubly linked list. List must have been
1315 initialized with InitializeListHead(). If List is empty, then NULL is
1318 If List is NULL, then ASSERT().
1319 If List was not initialized with InitializeListHead(), then ASSERT().
1320 If PcdMaximumLinkedListLenth is not zero, and the number of nodes
1321 in List, including the List node, is greater than or equal to
1322 PcdMaximumLinkedListLength, then ASSERT().
1324 @param List A pointer to the head node of a doubly linked list.
1326 @return The first node of a doubly linked list.
1327 @retval NULL The list is empty.
1333 IN CONST LIST_ENTRY
*List
1338 Retrieves the next node of a doubly linked list.
1340 Returns the node of a doubly linked list that follows Node. List must have
1341 been initialized with InitializeListHead(). If List is empty, then List is
1344 If List is NULL, then ASSERT().
1345 If Node is NULL, then ASSERT().
1346 If List was not initialized with InitializeListHead(), then ASSERT().
1347 If PcdMaximumLinkedListLenth is not zero, and List contains more than
1348 PcdMaximumLinkedListLenth nodes, then ASSERT().
1349 If Node is not a node in List, then ASSERT().
1351 @param List A pointer to the head node of a doubly linked list.
1352 @param Node A pointer to a node in the doubly linked list.
1354 @return Pointer to the next node if one exists. Otherwise a null value which
1355 is actually List is returned.
1361 IN CONST LIST_ENTRY
*List
,
1362 IN CONST LIST_ENTRY
*Node
1367 Checks to see if a doubly linked list is empty or not.
1369 Checks to see if the doubly linked list is empty. If the linked list contains
1370 zero nodes, this function returns TRUE. Otherwise, it returns FALSE.
1372 If ListHead is NULL, then ASSERT().
1373 If ListHead was not initialized with InitializeListHead(), then ASSERT().
1374 If PcdMaximumLinkedListLenth is not zero, and the number of nodes
1375 in List, including the List node, is greater than or equal to
1376 PcdMaximumLinkedListLength, then ASSERT().
1378 @param ListHead A pointer to the head node of a doubly linked list.
1380 @retval TRUE The linked list is empty.
1381 @retval FALSE The linked list is not empty.
1387 IN CONST LIST_ENTRY
*ListHead
1392 Determines if a node in a doubly linked list is null.
1394 Returns FALSE if Node is one of the nodes in the doubly linked list specified
1395 by List. Otherwise, TRUE is returned. List must have been initialized with
1396 InitializeListHead().
1398 If List is NULL, then ASSERT().
1399 If Node is NULL, then ASSERT().
1400 If List was not initialized with InitializeListHead(), then ASSERT().
1401 If PcdMaximumLinkedListLenth is not zero, and the number of nodes
1402 in List, including the List node, is greater than or equal to
1403 PcdMaximumLinkedListLength, then ASSERT().
1404 If Node is not a node in List and Node is not equal to List, then ASSERT().
1406 @param List A pointer to the head node of a doubly linked list.
1407 @param Node A pointer to a node in the doubly linked list.
1409 @retval TRUE Node is one of the nodes in the doubly linked list.
1410 @retval FALSE Node is not one of the nodes in the doubly linked list.
1416 IN CONST LIST_ENTRY
*List
,
1417 IN CONST LIST_ENTRY
*Node
1422 Determines if a node the last node in a doubly linked list.
1424 Returns TRUE if Node is the last node in the doubly linked list specified by
1425 List. Otherwise, FALSE is returned. List must have been initialized with
1426 InitializeListHead().
1428 If List is NULL, then ASSERT().
1429 If Node is NULL, then ASSERT().
1430 If List was not initialized with InitializeListHead(), then ASSERT().
1431 If PcdMaximumLinkedListLenth is not zero, and the number of nodes
1432 in List, including the List node, is greater than or equal to
1433 PcdMaximumLinkedListLength, then ASSERT().
1434 If Node is not a node in List, then ASSERT().
1436 @param List A pointer to the head node of a doubly linked list.
1437 @param Node A pointer to a node in the doubly linked list.
1439 @retval TRUE Node is the last node in the linked list.
1440 @retval FALSE Node is not the last node in the linked list.
1446 IN CONST LIST_ENTRY
*List
,
1447 IN CONST LIST_ENTRY
*Node
1452 Swaps the location of two nodes in a doubly linked list, and returns the
1453 first node after the swap.
1455 If FirstEntry is identical to SecondEntry, then SecondEntry is returned.
1456 Otherwise, the location of the FirstEntry node is swapped with the location
1457 of the SecondEntry node in a doubly linked list. SecondEntry must be in the
1458 same double linked list as FirstEntry and that double linked list must have
1459 been initialized with InitializeListHead(). SecondEntry is returned after the
1462 If FirstEntry is NULL, then ASSERT().
1463 If SecondEntry is NULL, then ASSERT().
1464 If SecondEntry and FirstEntry are not in the same linked list, then ASSERT().
1465 If PcdMaximumLinkedListLength is not zero, and the number of nodes in the
1466 linked list containing the FirstEntry and SecondEntry nodes, including
1467 the FirstEntry and SecondEntry nodes, is greater than or equal to
1468 PcdMaximumLinkedListLength, then ASSERT().
1470 @param FirstEntry A pointer to a node in a linked list.
1471 @param SecondEntry A pointer to another node in the same linked list.
1477 IN LIST_ENTRY
*FirstEntry
,
1478 IN LIST_ENTRY
*SecondEntry
1483 Removes a node from a doubly linked list, and returns the node that follows
1486 Removes the node Entry from a doubly linked list. It is up to the caller of
1487 this function to release the memory used by this node if that is required. On
1488 exit, the node following Entry in the doubly linked list is returned. If
1489 Entry is the only node in the linked list, then the head node of the linked
1492 If Entry is NULL, then ASSERT().
1493 If Entry is the head node of an empty list, then ASSERT().
1494 If PcdMaximumLinkedListLength is not zero, and the number of nodes in the
1495 linked list containing Entry, including the Entry node, is greater than
1496 or equal to PcdMaximumLinkedListLength, then ASSERT().
1498 @param Entry A pointer to a node in a linked list
1506 IN CONST LIST_ENTRY
*Entry
1514 Shifts a 64-bit integer left between 0 and 63 bits. The low bits are filled
1515 with zeros. The shifted value is returned.
1517 This function shifts the 64-bit value Operand to the left by Count bits. The
1518 low Count bits are set to zero. The shifted value is returned.
1520 If Count is greater than 63, then ASSERT().
1522 @param Operand The 64-bit operand to shift left.
1523 @param Count The number of bits to shift left.
1525 @return Operand << Count
1537 Shifts a 64-bit integer right between 0 and 63 bits. This high bits are
1538 filled with zeros. The shifted value is returned.
1540 This function shifts the 64-bit value Operand to the right by Count bits. The
1541 high Count bits are set to zero. The shifted value is returned.
1543 If Count is greater than 63, then ASSERT().
1545 @param Operand The 64-bit operand to shift right.
1546 @param Count The number of bits to shift right.
1548 @return Operand >> Count
1560 Shifts a 64-bit integer right between 0 and 63 bits. The high bits are filled
1561 with original integer's bit 63. The shifted value is returned.
1563 This function shifts the 64-bit value Operand to the right by Count bits. The
1564 high Count bits are set to bit 63 of Operand. The shifted value is returned.
1566 If Count is greater than 63, then ASSERT().
1568 @param Operand The 64-bit operand to shift right.
1569 @param Count The number of bits to shift right.
1571 @return Operand >> Count
1583 Rotates a 32-bit integer left between 0 and 31 bits, filling the low bits
1584 with the high bits that were rotated.
1586 This function rotates the 32-bit value Operand to the left by Count bits. The
1587 low Count bits are fill with the high Count bits of Operand. The rotated
1590 If Count is greater than 31, then ASSERT().
1592 @param Operand The 32-bit operand to rotate left.
1593 @param Count The number of bits to rotate left.
1595 @return Operand <<< Count
1607 Rotates a 32-bit integer right between 0 and 31 bits, filling the high bits
1608 with the low bits that were rotated.
1610 This function rotates the 32-bit value Operand to the right by Count bits.
1611 The high Count bits are fill with the low Count bits of Operand. The rotated
1614 If Count is greater than 31, then ASSERT().
1616 @param Operand The 32-bit operand to rotate right.
1617 @param Count The number of bits to rotate right.
1619 @return Operand >>> Count
1631 Rotates a 64-bit integer left between 0 and 63 bits, filling the low bits
1632 with the high bits that were rotated.
1634 This function rotates the 64-bit value Operand to the left by Count bits. The
1635 low Count bits are fill with the high Count bits of Operand. The rotated
1638 If Count is greater than 63, then ASSERT().
1640 @param Operand The 64-bit operand to rotate left.
1641 @param Count The number of bits to rotate left.
1643 @return Operand <<< Count
1655 Rotates a 64-bit integer right between 0 and 63 bits, filling the high bits
1656 with the high low bits that were rotated.
1658 This function rotates the 64-bit value Operand to the right by Count bits.
1659 The high Count bits are fill with the low Count bits of Operand. The rotated
1662 If Count is greater than 63, then ASSERT().
1664 @param Operand The 64-bit operand to rotate right.
1665 @param Count The number of bits to rotate right.
1667 @return Operand >>> Count
1679 Returns the bit position of the lowest bit set in a 32-bit value.
1681 This function computes the bit position of the lowest bit set in the 32-bit
1682 value specified by Operand. If Operand is zero, then -1 is returned.
1683 Otherwise, a value between 0 and 31 is returned.
1685 @param Operand The 32-bit operand to evaluate.
1687 @return Position of the lowest bit set in Operand if found.
1688 @retval -1 Operand is zero.
1699 Returns the bit position of the lowest bit set in a 64-bit value.
1701 This function computes the bit position of the lowest bit set in the 64-bit
1702 value specified by Operand. If Operand is zero, then -1 is returned.
1703 Otherwise, a value between 0 and 63 is returned.
1705 @param Operand The 64-bit operand to evaluate.
1707 @return Position of the lowest bit set in Operand if found.
1708 @retval -1 Operand is zero.
1719 Returns the bit position of the highest bit set in a 32-bit value. Equivalent
1722 This function computes the bit position of the highest bit set in the 32-bit
1723 value specified by Operand. If Operand is zero, then -1 is returned.
1724 Otherwise, a value between 0 and 31 is returned.
1726 @param Operand The 32-bit operand to evaluate.
1728 @return Position of the highest bit set in Operand if found.
1729 @retval -1 Operand is zero.
1740 Returns the bit position of the highest bit set in a 64-bit value. Equivalent
1743 This function computes the bit position of the highest bit set in the 64-bit
1744 value specified by Operand. If Operand is zero, then -1 is returned.
1745 Otherwise, a value between 0 and 63 is returned.
1747 @param Operand The 64-bit operand to evaluate.
1749 @return Position of the highest bit set in Operand if found.
1750 @retval -1 Operand is zero.
1761 Returns the value of the highest bit set in a 32-bit value. Equivalent to
1762 1 << HighBitSet32(x).
1764 This function computes the value of the highest bit set in the 32-bit value
1765 specified by Operand. If Operand is zero, then zero is returned.
1767 @param Operand The 32-bit operand to evaluate.
1769 @return 1 << HighBitSet32(Operand)
1770 @retval 0 Operand is zero.
1781 Returns the value of the highest bit set in a 64-bit value. Equivalent to
1782 1 << HighBitSet64(x).
1784 This function computes the value of the highest bit set in the 64-bit value
1785 specified by Operand. If Operand is zero, then zero is returned.
1787 @param Operand The 64-bit operand to evaluate.
1789 @return 1 << HighBitSet64(Operand)
1790 @retval 0 Operand is zero.
1801 Switches the endianess of a 16-bit integer.
1803 This function swaps the bytes in a 16-bit unsigned value to switch the value
1804 from little endian to big endian or vice versa. The byte swapped value is
1807 @param Operand A 16-bit unsigned value.
1809 @return The byte swaped Operand.
1820 Switches the endianess of a 32-bit integer.
1822 This function swaps the bytes in a 32-bit unsigned value to switch the value
1823 from little endian to big endian or vice versa. The byte swapped value is
1826 @param Operand A 32-bit unsigned value.
1828 @return The byte swaped Operand.
1839 Switches the endianess of a 64-bit integer.
1841 This function swaps the bytes in a 64-bit unsigned value to switch the value
1842 from little endian to big endian or vice versa. The byte swapped value is
1845 @param Operand A 64-bit unsigned value.
1847 @return The byte swaped Operand.
1858 Multiples a 64-bit unsigned integer by a 32-bit unsigned integer and
1859 generates a 64-bit unsigned result.
1861 This function multiples the 64-bit unsigned value Multiplicand by the 32-bit
1862 unsigned value Multiplier and generates a 64-bit unsigned result. This 64-
1863 bit unsigned result is returned.
1865 If the result overflows, then ASSERT().
1867 @param Multiplicand A 64-bit unsigned value.
1868 @param Multiplier A 32-bit unsigned value.
1870 @return Multiplicand * Multiplier
1876 IN UINT64 Multiplicand
,
1877 IN UINT32 Multiplier
1882 Multiples a 64-bit unsigned integer by a 64-bit unsigned integer and
1883 generates a 64-bit unsigned result.
1885 This function multiples the 64-bit unsigned value Multiplicand by the 64-bit
1886 unsigned value Multiplier and generates a 64-bit unsigned result. This 64-
1887 bit unsigned result is returned.
1889 If the result overflows, then ASSERT().
1891 @param Multiplicand A 64-bit unsigned value.
1892 @param Multiplier A 64-bit unsigned value.
1894 @return Multiplicand * Multiplier
1900 IN UINT64 Multiplicand
,
1901 IN UINT64 Multiplier
1906 Multiples a 64-bit signed integer by a 64-bit signed integer and generates a
1907 64-bit signed result.
1909 This function multiples the 64-bit signed value Multiplicand by the 64-bit
1910 signed value Multiplier and generates a 64-bit signed result. This 64-bit
1911 signed result is returned.
1913 If the result overflows, then ASSERT().
1915 @param Multiplicand A 64-bit signed value.
1916 @param Multiplier A 64-bit signed value.
1918 @return Multiplicand * Multiplier
1924 IN INT64 Multiplicand
,
1930 Divides a 64-bit unsigned integer by a 32-bit unsigned integer and generates
1931 a 64-bit unsigned result.
1933 This function divides the 64-bit unsigned value Dividend by the 32-bit
1934 unsigned value Divisor and generates a 64-bit unsigned quotient. This
1935 function returns the 64-bit unsigned quotient.
1937 If Divisor is 0, then ASSERT().
1939 @param Dividend A 64-bit unsigned value.
1940 @param Divisor A 32-bit unsigned value.
1942 @return Dividend / Divisor
1954 Divides a 64-bit unsigned integer by a 32-bit unsigned integer and generates
1955 a 32-bit unsigned remainder.
1957 This function divides the 64-bit unsigned value Dividend by the 32-bit
1958 unsigned value Divisor and generates a 32-bit remainder. This function
1959 returns the 32-bit unsigned remainder.
1961 If Divisor is 0, then ASSERT().
1963 @param Dividend A 64-bit unsigned value.
1964 @param Divisor A 32-bit unsigned value.
1966 @return Dividend % Divisor
1978 Divides a 64-bit unsigned integer by a 32-bit unsigned integer and generates
1979 a 64-bit unsigned result and an optional 32-bit unsigned remainder.
1981 This function divides the 64-bit unsigned value Dividend by the 32-bit
1982 unsigned value Divisor and generates a 64-bit unsigned quotient. If Remainder
1983 is not NULL, then the 32-bit unsigned remainder is returned in Remainder.
1984 This function returns the 64-bit unsigned quotient.
1986 If Divisor is 0, then ASSERT().
1988 @param Dividend A 64-bit unsigned value.
1989 @param Divisor A 32-bit unsigned value.
1990 @param Remainder A pointer to a 32-bit unsigned value. This parameter is
1991 optional and may be NULL.
1993 @return Dividend / Divisor
1998 DivU64x32Remainder (
2001 OUT UINT32
*Remainder OPTIONAL
2006 Divides a 64-bit unsigned integer by a 64-bit unsigned integer and generates
2007 a 64-bit unsigned result and an optional 64-bit unsigned remainder.
2009 This function divides the 64-bit unsigned value Dividend by the 64-bit
2010 unsigned value Divisor and generates a 64-bit unsigned quotient. If Remainder
2011 is not NULL, then the 64-bit unsigned remainder is returned in Remainder.
2012 This function returns the 64-bit unsigned quotient.
2014 If Divisor is 0, then ASSERT().
2016 @param Dividend A 64-bit unsigned value.
2017 @param Divisor A 64-bit unsigned value.
2018 @param Remainder A pointer to a 64-bit unsigned value. This parameter is
2019 optional and may be NULL.
2021 @return Dividend / Divisor
2026 DivU64x64Remainder (
2029 OUT UINT64
*Remainder OPTIONAL
2034 Divides a 64-bit signed integer by a 64-bit signed integer and generates a
2035 64-bit signed result and a optional 64-bit signed remainder.
2037 This function divides the 64-bit signed value Dividend by the 64-bit signed
2038 value Divisor and generates a 64-bit signed quotient. If Remainder is not
2039 NULL, then the 64-bit signed remainder is returned in Remainder. This
2040 function returns the 64-bit signed quotient.
2042 If Divisor is 0, then ASSERT().
2044 @param Dividend A 64-bit signed value.
2045 @param Divisor A 64-bit signed value.
2046 @param Remainder A pointer to a 64-bit signed value. This parameter is
2047 optional and may be NULL.
2049 @return Dividend / Divisor
2054 DivS64x64Remainder (
2057 OUT INT64
*Remainder OPTIONAL
2062 Reads a 16-bit value from memory that may be unaligned.
2064 This function returns the 16-bit value pointed to by Buffer. The function
2065 guarantees that the read operation does not produce an alignment fault.
2067 If the Buffer is NULL, then ASSERT().
2069 @param Buffer Pointer to a 16-bit value that may be unaligned.
2077 IN CONST UINT16
*Uint16
2082 Writes a 16-bit value to memory that may be unaligned.
2084 This function writes the 16-bit value specified by Value to Buffer. Value is
2085 returned. The function guarantees that the write operation does not produce
2088 If the Buffer is NULL, then ASSERT().
2090 @param Buffer Pointer to a 16-bit value that may be unaligned.
2091 @param Value 16-bit value to write to Buffer.
2105 Reads a 24-bit value from memory that may be unaligned.
2107 This function returns the 24-bit value pointed to by Buffer. The function
2108 guarantees that the read operation does not produce an alignment fault.
2110 If the Buffer is NULL, then ASSERT().
2112 @param Buffer Pointer to a 24-bit value that may be unaligned.
2114 @return The value read.
2120 IN CONST UINT32
*Buffer
2125 Writes a 24-bit value to memory that may be unaligned.
2127 This function writes the 24-bit value specified by Value to Buffer. Value is
2128 returned. The function guarantees that the write operation does not produce
2131 If the Buffer is NULL, then ASSERT().
2133 @param Buffer Pointer to a 24-bit value that may be unaligned.
2134 @param Value 24-bit value to write to Buffer.
2136 @return The value written.
2148 Reads a 32-bit value from memory that may be unaligned.
2150 This function returns the 32-bit value pointed to by Buffer. The function
2151 guarantees that the read operation does not produce an alignment fault.
2153 If the Buffer is NULL, then ASSERT().
2155 @param Buffer Pointer to a 32-bit value that may be unaligned.
2163 IN CONST UINT32
*Uint32
2168 Writes a 32-bit value to memory that may be unaligned.
2170 This function writes the 32-bit value specified by Value to Buffer. Value is
2171 returned. The function guarantees that the write operation does not produce
2174 If the Buffer is NULL, then ASSERT().
2176 @param Buffer Pointer to a 32-bit value that may be unaligned.
2177 @param Value 32-bit value to write to Buffer.
2191 Reads a 64-bit value from memory that may be unaligned.
2193 This function returns the 64-bit value pointed to by Buffer. The function
2194 guarantees that the read operation does not produce an alignment fault.
2196 If the Buffer is NULL, then ASSERT().
2198 @param Buffer Pointer to a 64-bit value that may be unaligned.
2206 IN CONST UINT64
*Uint64
2211 Writes a 64-bit value to memory that may be unaligned.
2213 This function writes the 64-bit value specified by Value to Buffer. Value is
2214 returned. The function guarantees that the write operation does not produce
2217 If the Buffer is NULL, then ASSERT().
2219 @param Buffer Pointer to a 64-bit value that may be unaligned.
2220 @param Value 64-bit value to write to Buffer.
2234 // Bit Field Functions
2238 Returns a bit field from an 8-bit value.
2240 Returns the bitfield specified by the StartBit and the EndBit from Operand.
2242 If 8-bit operations are not supported, then ASSERT().
2243 If StartBit is greater than 7, then ASSERT().
2244 If EndBit is greater than 7, then ASSERT().
2245 If EndBit is less than StartBit, then ASSERT().
2247 @param Operand Operand on which to perform the bitfield operation.
2248 @param StartBit The ordinal of the least significant bit in the bit field.
2250 @param EndBit The ordinal of the most significant bit in the bit field.
2253 @return The bit field read.
2266 Writes a bit field to an 8-bit value, and returns the result.
2268 Writes Value to the bit field specified by the StartBit and the EndBit in
2269 Operand. All other bits in Operand are preserved. The new 8-bit value is
2272 If 8-bit operations are not supported, then ASSERT().
2273 If StartBit is greater than 7, then ASSERT().
2274 If EndBit is greater than 7, then ASSERT().
2275 If EndBit is less than StartBit, then ASSERT().
2277 @param Operand Operand on which to perform the bitfield operation.
2278 @param StartBit The ordinal of the least significant bit in the bit field.
2280 @param EndBit The ordinal of the most significant bit in the bit field.
2282 @param Value New value of the bit field.
2284 @return The new 8-bit value.
2298 Reads a bit field from an 8-bit value, performs a bitwise OR, and returns the
2301 Performs a bitwise inclusive OR between the bit field specified by StartBit
2302 and EndBit in Operand and the value specified by OrData. All other bits in
2303 Operand are preserved. The new 8-bit value is returned.
2305 If 8-bit operations are not supported, then ASSERT().
2306 If StartBit is greater than 7, then ASSERT().
2307 If EndBit is greater than 7, then ASSERT().
2308 If EndBit is less than StartBit, then ASSERT().
2310 @param Operand Operand on which to perform the bitfield operation.
2311 @param StartBit The ordinal of the least significant bit in the bit field.
2313 @param EndBit The ordinal of the most significant bit in the bit field.
2315 @param OrData The value to OR with the read value from the value
2317 @return The new 8-bit value.
2331 Reads a bit field from an 8-bit value, performs a bitwise AND, and returns
2334 Performs a bitwise AND between the bit field specified by StartBit and EndBit
2335 in Operand and the value specified by AndData. All other bits in Operand are
2336 preserved. The new 8-bit value is returned.
2338 If 8-bit operations are not supported, then ASSERT().
2339 If StartBit is greater than 7, then ASSERT().
2340 If EndBit is greater than 7, then ASSERT().
2341 If EndBit is less than StartBit, then ASSERT().
2343 @param Operand Operand on which to perform the bitfield operation.
2344 @param StartBit The ordinal of the least significant bit in the bit field.
2346 @param EndBit The ordinal of the most significant bit in the bit field.
2348 @param AndData The value to AND with the read value from the value.
2350 @return The new 8-bit value.
2364 Reads a bit field from an 8-bit value, performs a bitwise AND followed by a
2365 bitwise OR, and returns the result.
2367 Performs a bitwise AND between the bit field specified by StartBit and EndBit
2368 in Operand and the value specified by AndData, followed by a bitwise
2369 inclusive OR with value specified by OrData. All other bits in Operand are
2370 preserved. The new 8-bit value is returned.
2372 If 8-bit operations are not supported, then ASSERT().
2373 If StartBit is greater than 7, then ASSERT().
2374 If EndBit is greater than 7, then ASSERT().
2375 If EndBit is less than StartBit, then ASSERT().
2377 @param Operand Operand on which to perform the bitfield operation.
2378 @param StartBit The ordinal of the least significant bit in the bit field.
2380 @param EndBit The ordinal of the most significant bit in the bit field.
2382 @param AndData The value to AND with the read value from the value.
2383 @param OrData The value to OR with the result of the AND operation.
2385 @return The new 8-bit value.
2390 BitFieldAndThenOr8 (
2400 Returns a bit field from a 16-bit value.
2402 Returns the bitfield specified by the StartBit and the EndBit from Operand.
2404 If 16-bit operations are not supported, then ASSERT().
2405 If StartBit is greater than 15, then ASSERT().
2406 If EndBit is greater than 15, then ASSERT().
2407 If EndBit is less than StartBit, then ASSERT().
2409 @param Operand Operand on which to perform the bitfield operation.
2410 @param StartBit The ordinal of the least significant bit in the bit field.
2412 @param EndBit The ordinal of the most significant bit in the bit field.
2415 @return The bit field read.
2428 Writes a bit field to a 16-bit value, and returns the result.
2430 Writes Value to the bit field specified by the StartBit and the EndBit in
2431 Operand. All other bits in Operand are preserved. The new 16-bit value is
2434 If 16-bit operations are not supported, then ASSERT().
2435 If StartBit is greater than 15, then ASSERT().
2436 If EndBit is greater than 15, then ASSERT().
2437 If EndBit is less than StartBit, then ASSERT().
2439 @param Operand Operand on which to perform the bitfield operation.
2440 @param StartBit The ordinal of the least significant bit in the bit field.
2442 @param EndBit The ordinal of the most significant bit in the bit field.
2444 @param Value New value of the bit field.
2446 @return The new 16-bit value.
2460 Reads a bit field from a 16-bit value, performs a bitwise OR, and returns the
2463 Performs a bitwise inclusive OR between the bit field specified by StartBit
2464 and EndBit in Operand and the value specified by OrData. All other bits in
2465 Operand are preserved. The new 16-bit value is returned.
2467 If 16-bit operations are not supported, then ASSERT().
2468 If StartBit is greater than 15, then ASSERT().
2469 If EndBit is greater than 15, then ASSERT().
2470 If EndBit is less than StartBit, then ASSERT().
2472 @param Operand Operand on which to perform the bitfield operation.
2473 @param StartBit The ordinal of the least significant bit in the bit field.
2475 @param EndBit The ordinal of the most significant bit in the bit field.
2477 @param OrData The value to OR with the read value from the value
2479 @return The new 16-bit value.
2493 Reads a bit field from a 16-bit value, performs a bitwise AND, and returns
2496 Performs a bitwise AND between the bit field specified by StartBit and EndBit
2497 in Operand and the value specified by AndData. All other bits in Operand are
2498 preserved. The new 16-bit value is returned.
2500 If 16-bit operations are not supported, then ASSERT().
2501 If StartBit is greater than 15, then ASSERT().
2502 If EndBit is greater than 15, then ASSERT().
2503 If EndBit is less than StartBit, then ASSERT().
2505 @param Operand Operand on which to perform the bitfield operation.
2506 @param StartBit The ordinal of the least significant bit in the bit field.
2508 @param EndBit The ordinal of the most significant bit in the bit field.
2510 @param AndData The value to AND with the read value from the value
2512 @return The new 16-bit value.
2526 Reads a bit field from a 16-bit value, performs a bitwise AND followed by a
2527 bitwise OR, and returns the result.
2529 Performs a bitwise AND between the bit field specified by StartBit and EndBit
2530 in Operand and the value specified by AndData, followed by a bitwise
2531 inclusive OR with value specified by OrData. All other bits in Operand are
2532 preserved. The new 16-bit value is returned.
2534 If 16-bit operations are not supported, then ASSERT().
2535 If StartBit is greater than 15, then ASSERT().
2536 If EndBit is greater than 15, then ASSERT().
2537 If EndBit is less than StartBit, then ASSERT().
2539 @param Operand Operand on which to perform the bitfield operation.
2540 @param StartBit The ordinal of the least significant bit in the bit field.
2542 @param EndBit The ordinal of the most significant bit in the bit field.
2544 @param AndData The value to AND with the read value from the value.
2545 @param OrData The value to OR with the result of the AND operation.
2547 @return The new 16-bit value.
2552 BitFieldAndThenOr16 (
2562 Returns a bit field from a 32-bit value.
2564 Returns the bitfield specified by the StartBit and the EndBit from Operand.
2566 If 32-bit operations are not supported, then ASSERT().
2567 If StartBit is greater than 31, then ASSERT().
2568 If EndBit is greater than 31, then ASSERT().
2569 If EndBit is less than StartBit, then ASSERT().
2571 @param Operand Operand on which to perform the bitfield operation.
2572 @param StartBit The ordinal of the least significant bit in the bit field.
2574 @param EndBit The ordinal of the most significant bit in the bit field.
2577 @return The bit field read.
2590 Writes a bit field to a 32-bit value, and returns the result.
2592 Writes Value to the bit field specified by the StartBit and the EndBit in
2593 Operand. All other bits in Operand are preserved. The new 32-bit value is
2596 If 32-bit operations are not supported, then ASSERT().
2597 If StartBit is greater than 31, then ASSERT().
2598 If EndBit is greater than 31, then ASSERT().
2599 If EndBit is less than StartBit, then ASSERT().
2601 @param Operand Operand on which to perform the bitfield operation.
2602 @param StartBit The ordinal of the least significant bit in the bit field.
2604 @param EndBit The ordinal of the most significant bit in the bit field.
2606 @param Value New value of the bit field.
2608 @return The new 32-bit value.
2622 Reads a bit field from a 32-bit value, performs a bitwise OR, and returns the
2625 Performs a bitwise inclusive OR between the bit field specified by StartBit
2626 and EndBit in Operand and the value specified by OrData. All other bits in
2627 Operand are preserved. The new 32-bit value is returned.
2629 If 32-bit operations are not supported, then ASSERT().
2630 If StartBit is greater than 31, then ASSERT().
2631 If EndBit is greater than 31, then ASSERT().
2632 If EndBit is less than StartBit, then ASSERT().
2634 @param Operand Operand on which to perform the bitfield operation.
2635 @param StartBit The ordinal of the least significant bit in the bit field.
2637 @param EndBit The ordinal of the most significant bit in the bit field.
2639 @param OrData The value to OR with the read value from the value
2641 @return The new 32-bit value.
2655 Reads a bit field from a 32-bit value, performs a bitwise AND, and returns
2658 Performs a bitwise AND between the bit field specified by StartBit and EndBit
2659 in Operand and the value specified by AndData. All other bits in Operand are
2660 preserved. The new 32-bit value is returned.
2662 If 32-bit operations are not supported, then ASSERT().
2663 If StartBit is greater than 31, then ASSERT().
2664 If EndBit is greater than 31, then ASSERT().
2665 If EndBit is less than StartBit, then ASSERT().
2667 @param Operand Operand on which to perform the bitfield operation.
2668 @param StartBit The ordinal of the least significant bit in the bit field.
2670 @param EndBit The ordinal of the most significant bit in the bit field.
2672 @param AndData The value to AND with the read value from the value
2674 @return The new 32-bit value.
2688 Reads a bit field from a 32-bit value, performs a bitwise AND followed by a
2689 bitwise OR, and returns the result.
2691 Performs a bitwise AND between the bit field specified by StartBit and EndBit
2692 in Operand and the value specified by AndData, followed by a bitwise
2693 inclusive OR with value specified by OrData. All other bits in Operand are
2694 preserved. The new 32-bit value is returned.
2696 If 32-bit operations are not supported, then ASSERT().
2697 If StartBit is greater than 31, then ASSERT().
2698 If EndBit is greater than 31, then ASSERT().
2699 If EndBit is less than StartBit, then ASSERT().
2701 @param Operand Operand on which to perform the bitfield operation.
2702 @param StartBit The ordinal of the least significant bit in the bit field.
2704 @param EndBit The ordinal of the most significant bit in the bit field.
2706 @param AndData The value to AND with the read value from the value.
2707 @param OrData The value to OR with the result of the AND operation.
2709 @return The new 32-bit value.
2714 BitFieldAndThenOr32 (
2724 Returns a bit field from a 64-bit value.
2726 Returns the bitfield specified by the StartBit and the EndBit from Operand.
2728 If 64-bit operations are not supported, then ASSERT().
2729 If StartBit is greater than 63, then ASSERT().
2730 If EndBit is greater than 63, then ASSERT().
2731 If EndBit is less than StartBit, then ASSERT().
2733 @param Operand Operand on which to perform the bitfield operation.
2734 @param StartBit The ordinal of the least significant bit in the bit field.
2736 @param EndBit The ordinal of the most significant bit in the bit field.
2739 @return The bit field read.
2752 Writes a bit field to a 64-bit value, and returns the result.
2754 Writes Value to the bit field specified by the StartBit and the EndBit in
2755 Operand. All other bits in Operand are preserved. The new 64-bit value is
2758 If 64-bit operations are not supported, then ASSERT().
2759 If StartBit is greater than 63, then ASSERT().
2760 If EndBit is greater than 63, then ASSERT().
2761 If EndBit is less than StartBit, then ASSERT().
2763 @param Operand Operand on which to perform the bitfield operation.
2764 @param StartBit The ordinal of the least significant bit in the bit field.
2766 @param EndBit The ordinal of the most significant bit in the bit field.
2768 @param Value New value of the bit field.
2770 @return The new 64-bit value.
2784 Reads a bit field from a 64-bit value, performs a bitwise OR, and returns the
2787 Performs a bitwise inclusive OR between the bit field specified by StartBit
2788 and EndBit in Operand and the value specified by OrData. All other bits in
2789 Operand are preserved. The new 64-bit value is returned.
2791 If 64-bit operations are not supported, then ASSERT().
2792 If StartBit is greater than 63, then ASSERT().
2793 If EndBit is greater than 63, then ASSERT().
2794 If EndBit is less than StartBit, then ASSERT().
2796 @param Operand Operand on which to perform the bitfield operation.
2797 @param StartBit The ordinal of the least significant bit in the bit field.
2799 @param EndBit The ordinal of the most significant bit in the bit field.
2801 @param OrData The value to OR with the read value from the value
2803 @return The new 64-bit value.
2817 Reads a bit field from a 64-bit value, performs a bitwise AND, and returns
2820 Performs a bitwise AND between the bit field specified by StartBit and EndBit
2821 in Operand and the value specified by AndData. All other bits in Operand are
2822 preserved. The new 64-bit value is returned.
2824 If 64-bit operations are not supported, then ASSERT().
2825 If StartBit is greater than 63, then ASSERT().
2826 If EndBit is greater than 63, then ASSERT().
2827 If EndBit is less than StartBit, then ASSERT().
2829 @param Operand Operand on which to perform the bitfield operation.
2830 @param StartBit The ordinal of the least significant bit in the bit field.
2832 @param EndBit The ordinal of the most significant bit in the bit field.
2834 @param AndData The value to AND with the read value from the value
2836 @return The new 64-bit value.
2850 Reads a bit field from a 64-bit value, performs a bitwise AND followed by a
2851 bitwise OR, and returns the result.
2853 Performs a bitwise AND between the bit field specified by StartBit and EndBit
2854 in Operand and the value specified by AndData, followed by a bitwise
2855 inclusive OR with value specified by OrData. All other bits in Operand are
2856 preserved. The new 64-bit value is returned.
2858 If 64-bit operations are not supported, then ASSERT().
2859 If StartBit is greater than 63, then ASSERT().
2860 If EndBit is greater than 63, then ASSERT().
2861 If EndBit is less than StartBit, then ASSERT().
2863 @param Operand Operand on which to perform the bitfield operation.
2864 @param StartBit The ordinal of the least significant bit in the bit field.
2866 @param EndBit The ordinal of the most significant bit in the bit field.
2868 @param AndData The value to AND with the read value from the value.
2869 @param OrData The value to OR with the result of the AND operation.
2871 @return The new 64-bit value.
2876 BitFieldAndThenOr64 (
2886 // Base Library Synchronization Functions
2890 Retrieves the architecture specific spin lock alignment requirements for
2891 optimal spin lock performance.
2893 This function retrieves the spin lock alignment requirements for optimal
2894 performance on a given CPU architecture. The spin lock alignment must be a
2895 power of two and is returned by this function. If there are no alignment
2896 requirements, then 1 must be returned. The spin lock synchronization
2897 functions must function correctly if the spin lock size and alignment values
2898 returned by this function are not used at all. These values are hints to the
2899 consumers of the spin lock synchronization functions to obtain optimal spin
2902 @return The architecture specific spin lock alignment.
2907 GetSpinLockProperties (
2913 Initializes a spin lock to the released state and returns the spin lock.
2915 This function initializes the spin lock specified by SpinLock to the released
2916 state, and returns SpinLock. Optimal performance can be achieved by calling
2917 GetSpinLockProperties() to determine the size and alignment requirements for
2920 If SpinLock is NULL, then ASSERT().
2922 @param SpinLock A pointer to the spin lock to initialize to the released
2930 InitializeSpinLock (
2931 IN SPIN_LOCK
*SpinLock
2936 Waits until a spin lock can be placed in the acquired state.
2938 This function checks the state of the spin lock specified by SpinLock. If
2939 SpinLock is in the released state, then this function places SpinLock in the
2940 acquired state and returns SpinLock. Otherwise, this function waits
2941 indefinitely for the spin lock to be released, and then places it in the
2942 acquired state and returns SpinLock. All state transitions of SpinLock must
2943 be performed using MP safe mechanisms.
2945 If SpinLock is NULL, then ASSERT().
2946 If SpinLock was not initialized with InitializeSpinLock(), then ASSERT().
2947 If PcdSpinLockTimeout is not zero, and SpinLock is can not be acquired in
2948 PcdSpinLockTimeout microseconds, then ASSERT().
2950 @param SpinLock A pointer to the spin lock to place in the acquired state.
2958 IN SPIN_LOCK
*SpinLock
2963 Attempts to place a spin lock in the acquired state.
2965 This function checks the state of the spin lock specified by SpinLock. If
2966 SpinLock is in the released state, then this function places SpinLock in the
2967 acquired state and returns TRUE. Otherwise, FALSE is returned. All state
2968 transitions of SpinLock must be performed using MP safe mechanisms.
2970 If SpinLock is NULL, then ASSERT().
2971 If SpinLock was not initialized with InitializeSpinLock(), then ASSERT().
2973 @param SpinLock A pointer to the spin lock to place in the acquired state.
2975 @retval TRUE SpinLock was placed in the acquired state.
2976 @retval FALSE SpinLock could not be acquired.
2981 AcquireSpinLockOrFail (
2982 IN SPIN_LOCK
*SpinLock
2987 Releases a spin lock.
2989 This function places the spin lock specified by SpinLock in the release state
2990 and returns SpinLock.
2992 If SpinLock is NULL, then ASSERT().
2993 If SpinLock was not initialized with InitializeSpinLock(), then ASSERT().
2995 @param SpinLock A pointer to the spin lock to release.
3003 IN SPIN_LOCK
*SpinLock
3008 Performs an atomic increment of an 32-bit unsigned integer.
3010 Performs an atomic increment of the 32-bit unsigned integer specified by
3011 Value and returns the incremented value. The increment operation must be
3012 performed using MP safe mechanisms. The state of the return value is not
3013 guaranteed to be MP safe.
3015 If Value is NULL, then ASSERT().
3017 @param Value A pointer to the 32-bit value to increment.
3019 @return The incremented value.
3024 InterlockedIncrement (
3030 Performs an atomic decrement of an 32-bit unsigned integer.
3032 Performs an atomic decrement of the 32-bit unsigned integer specified by
3033 Value and returns the decremented value. The decrement operation must be
3034 performed using MP safe mechanisms. The state of the return value is not
3035 guaranteed to be MP safe.
3037 If Value is NULL, then ASSERT().
3039 @param Value A pointer to the 32-bit value to decrement.
3041 @return The decremented value.
3046 InterlockedDecrement (
3052 Performs an atomic compare exchange operation on a 32-bit unsigned integer.
3054 Performs an atomic compare exchange operation on the 32-bit unsigned integer
3055 specified by Value. If Value is equal to CompareValue, then Value is set to
3056 ExchangeValue and CompareValue is returned. If Value is not equal to CompareValue,
3057 then Value is returned. The compare exchange operation must be performed using
3060 If Value is NULL, then ASSERT().
3062 @param Value A pointer to the 32-bit value for the compare exchange
3064 @param CompareValue 32-bit value used in compare operation.
3065 @param ExchangeValue 32-bit value used in exchange operation.
3067 @return The original *Value before exchange.
3072 InterlockedCompareExchange32 (
3073 IN OUT UINT32
*Value
,
3074 IN UINT32 CompareValue
,
3075 IN UINT32 ExchangeValue
3080 Performs an atomic compare exchange operation on a 64-bit unsigned integer.
3082 Performs an atomic compare exchange operation on the 64-bit unsigned integer specified
3083 by Value. If Value is equal to CompareValue, then Value is set to ExchangeValue and
3084 CompareValue is returned. If Value is not equal to CompareValue, then Value is returned.
3085 The compare exchange operation must be performed using MP safe mechanisms.
3087 If Value is NULL, then ASSERT().
3089 @param Value A pointer to the 64-bit value for the compare exchange
3091 @param CompareValue 64-bit value used in compare operation.
3092 @param ExchangeValue 64-bit value used in exchange operation.
3094 @return The original *Value before exchange.
3099 InterlockedCompareExchange64 (
3100 IN OUT UINT64
*Value
,
3101 IN UINT64 CompareValue
,
3102 IN UINT64 ExchangeValue
3107 Performs an atomic compare exchange operation on a pointer value.
3109 Performs an atomic compare exchange operation on the pointer value specified
3110 by Value. If Value is equal to CompareValue, then Value is set to
3111 ExchangeValue and CompareValue is returned. If Value is not equal to
3112 CompareValue, then Value is returned. The compare exchange operation must be
3113 performed using MP safe mechanisms.
3115 If Value is NULL, then ASSERT().
3117 @param Value A pointer to the pointer value for the compare exchange
3119 @param CompareValue Pointer value used in compare operation.
3120 @param ExchangeValue Pointer value used in exchange operation.
3125 InterlockedCompareExchangePointer (
3126 IN OUT VOID
**Value
,
3127 IN VOID
*CompareValue
,
3128 IN VOID
*ExchangeValue
3133 // Base Library Checksum Functions
3137 Calculate the sum of all elements in a buffer in unit of UINT8.
3138 During calculation, the carry bits are dropped.
3140 This function calculates the sum of all elements in a buffer
3141 in unit of UINT8. The carry bits in result of addition are dropped.
3142 The result is returned as UINT8. If Length is Zero, then Zero is
3145 If Buffer is NULL, then ASSERT().
3146 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
3148 @param Buffer Pointer to the buffer to carry out the sum operation.
3149 @param Length The size, in bytes, of Buffer .
3151 @return Sum The sum of Buffer with carry bits dropped during additions.
3157 IN CONST UINT8
*Buffer
,
3163 Returns the two's complement checksum of all elements in a buffer
3166 This function first calculates the sum of the 8-bit values in the
3167 buffer specified by Buffer and Length. The carry bits in the result
3168 of addition are dropped. Then, the two's complement of the sum is
3169 returned. If Length is 0, then 0 is returned.
3171 If Buffer is NULL, then ASSERT().
3172 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
3175 @param Buffer Pointer to the buffer to carry out the checksum operation.
3176 @param Length The size, in bytes, of Buffer.
3178 @return Checksum The 2's complement checksum of Buffer.
3183 CalculateCheckSum8 (
3184 IN CONST UINT8
*Buffer
,
3190 Returns the sum of all elements in a buffer of 16-bit values. During
3191 calculation, the carry bits are dropped.
3193 This function calculates the sum of the 16-bit values in the buffer
3194 specified by Buffer and Length. The carry bits in result of addition are dropped.
3195 The 16-bit result is returned. If Length is 0, then 0 is returned.
3197 If Buffer is NULL, then ASSERT().
3198 If Buffer is not aligned on a 16-bit boundary, then ASSERT().
3199 If Length is not aligned on a 16-bit boundary, then ASSERT().
3200 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
3202 @param Buffer Pointer to the buffer to carry out the sum operation.
3203 @param Length The size, in bytes, of Buffer.
3205 @return Sum The sum of Buffer with carry bits dropped during additions.
3211 IN CONST UINT16
*Buffer
,
3217 Returns the two's complement checksum of all elements in a buffer of
3220 This function first calculates the sum of the 16-bit values in the buffer
3221 specified by Buffer and Length. The carry bits in the result of addition
3222 are dropped. Then, the two's complement of the sum is returned. If Length
3223 is 0, then 0 is returned.
3225 If Buffer is NULL, then ASSERT().
3226 If Buffer is not aligned on a 16-bit boundary, then ASSERT().
3227 If Length is not aligned on a 16-bit boundary, then ASSERT().
3228 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
3230 @param Buffer Pointer to the buffer to carry out the checksum operation.
3231 @param Length The size, in bytes, of Buffer.
3233 @return Checksum The 2's complement checksum of Buffer.
3238 CalculateCheckSum16 (
3239 IN CONST UINT16
*Buffer
,
3245 Returns the sum of all elements in a buffer of 32-bit values. During
3246 calculation, the carry bits are dropped.
3248 This function calculates the sum of the 32-bit values in the buffer
3249 specified by Buffer and Length. The carry bits in result of addition are dropped.
3250 The 32-bit result is returned. If Length is 0, then 0 is returned.
3252 If Buffer is NULL, then ASSERT().
3253 If Buffer is not aligned on a 32-bit boundary, then ASSERT().
3254 If Length is not aligned on a 32-bit boundary, then ASSERT().
3255 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
3257 @param Buffer Pointer to the buffer to carry out the sum operation.
3258 @param Length The size, in bytes, of Buffer.
3260 @return Sum The sum of Buffer with carry bits dropped during additions.
3266 IN CONST UINT32
*Buffer
,
3272 Returns the two's complement checksum of all elements in a buffer of
3275 This function first calculates the sum of the 32-bit values in the buffer
3276 specified by Buffer and Length. The carry bits in the result of addition
3277 are dropped. Then, the two's complement of the sum is returned. If Length
3278 is 0, then 0 is returned.
3280 If Buffer is NULL, then ASSERT().
3281 If Buffer is not aligned on a 32-bit boundary, then ASSERT().
3282 If Length is not aligned on a 32-bit boundary, then ASSERT().
3283 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
3285 @param Buffer Pointer to the buffer to carry out the checksum operation.
3286 @param Length The size, in bytes, of Buffer.
3288 @return Checksum The 2's complement checksum of Buffer.
3293 CalculateCheckSum32 (
3294 IN CONST UINT32
*Buffer
,
3300 Returns the sum of all elements in a buffer of 64-bit values. During
3301 calculation, the carry bits are dropped.
3303 This function calculates the sum of the 64-bit values in the buffer
3304 specified by Buffer and Length. The carry bits in result of addition are dropped.
3305 The 64-bit result is returned. If Length is 0, then 0 is returned.
3307 If Buffer is NULL, then ASSERT().
3308 If Buffer is not aligned on a 64-bit boundary, then ASSERT().
3309 If Length is not aligned on a 64-bit boundary, then ASSERT().
3310 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
3312 @param Buffer Pointer to the buffer to carry out the sum operation.
3313 @param Length The size, in bytes, of Buffer.
3315 @return Sum The sum of Buffer with carry bits dropped during additions.
3321 IN CONST UINT64
*Buffer
,
3327 Returns the two's complement checksum of all elements in a buffer of
3330 This function first calculates the sum of the 64-bit values in the buffer
3331 specified by Buffer and Length. The carry bits in the result of addition
3332 are dropped. Then, the two's complement of the sum is returned. If Length
3333 is 0, then 0 is returned.
3335 If Buffer is NULL, then ASSERT().
3336 If Buffer is not aligned on a 64-bit boundary, then ASSERT().
3337 If Length is not aligned on a 64-bit boundary, then ASSERT().
3338 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
3340 @param Buffer Pointer to the buffer to carry out the checksum operation.
3341 @param Length The size, in bytes, of Buffer.
3343 @return Checksum The 2's complement checksum of Buffer.
3348 CalculateCheckSum64 (
3349 IN CONST UINT64
*Buffer
,
3355 // Base Library CPU Functions
3359 (EFIAPI
*SWITCH_STACK_ENTRY_POINT
) (
3360 IN VOID
*Context1
, OPTIONAL
3361 IN VOID
*Context2 OPTIONAL
3366 Used to serialize load and store operations.
3368 All loads and stores that proceed calls to this function are guaranteed to be
3369 globally visible when this function returns.
3380 Saves the current CPU context that can be restored with a call to LongJump()
3383 Saves the current CPU context in the buffer specified by JumpBuffer and
3384 returns 0. The initial call to SetJump() must always return 0. Subsequent
3385 calls to LongJump() cause a non-zero value to be returned by SetJump().
3387 If JumpBuffer is NULL, then ASSERT().
3388 For IPF CPUs, if JumpBuffer is not aligned on a 16-byte boundary, then ASSERT().
3390 @param JumpBuffer A pointer to CPU context buffer.
3392 @retval 0 Indicates a return from SetJump().
3398 OUT BASE_LIBRARY_JUMP_BUFFER
*JumpBuffer
3403 Restores the CPU context that was saved with SetJump().
3405 Restores the CPU context from the buffer specified by JumpBuffer. This
3406 function never returns to the caller. Instead is resumes execution based on
3407 the state of JumpBuffer.
3409 If JumpBuffer is NULL, then ASSERT().
3410 For IPF CPUs, if JumpBuffer is not aligned on a 16-byte boundary, then ASSERT().
3411 If Value is 0, then ASSERT().
3413 @param JumpBuffer A pointer to CPU context buffer.
3414 @param Value The value to return when the SetJump() context is
3415 restored and must be non-zero.
3421 IN BASE_LIBRARY_JUMP_BUFFER
*JumpBuffer
,
3427 Enables CPU interrupts.
3429 Enables CPU interrupts.
3440 Disables CPU interrupts.
3442 Disables CPU interrupts.
3453 Disables CPU interrupts and returns the interrupt state prior to the disable
3456 Disables CPU interrupts and returns the interrupt state prior to the disable
3459 @retval TRUE CPU interrupts were enabled on entry to this call.
3460 @retval FALSE CPU interrupts were disabled on entry to this call.
3465 SaveAndDisableInterrupts (
3471 Enables CPU interrupts for the smallest window required to capture any
3474 Enables CPU interrupts for the smallest window required to capture any
3480 EnableDisableInterrupts (
3486 Retrieves the current CPU interrupt state.
3488 Retrieves the current CPU interrupt state. Returns TRUE is interrupts are
3489 currently enabled. Otherwise returns FALSE.
3491 @retval TRUE CPU interrupts are enabled.
3492 @retval FALSE CPU interrupts are disabled.
3503 Set the current CPU interrupt state.
3505 Sets the current CPU interrupt state to the state specified by
3506 InterruptState. If InterruptState is TRUE, then interrupts are enabled. If
3507 InterruptState is FALSE, then interrupts are disabled. InterruptState is
3510 @param InterruptState TRUE if interrupts should enabled. FALSE if
3511 interrupts should be disabled.
3513 @return InterruptState
3519 IN BOOLEAN InterruptState
3524 Places the CPU in a sleep state until an interrupt is received.
3526 Places the CPU in a sleep state until an interrupt is received. If interrupts
3527 are disabled prior to calling this function, then the CPU will be placed in a
3528 sleep state indefinitely.
3539 Requests CPU to pause for a short period of time.
3541 Requests CPU to pause for a short period of time. Typically used in MP
3542 systems to prevent memory starvation while waiting for a spin lock.
3553 Flushes all the Translation Lookaside Buffers(TLB) entries in a CPU.
3555 Flushes all the Translation Lookaside Buffers(TLB) entries in a CPU.
3566 Transfers control to a function starting with a new stack.
3568 Transfers control to the function specified by EntryPoint using the
3569 new stack specified by NewStack and passing in the parameters specified
3570 by Context1 and Context2. Context1 and Context2 are optional and may
3571 be NULL. The function EntryPoint must never return. This function
3572 supports a variable number of arguments following the NewStack parameter.
3573 These additional arguments are ignored on IA-32, x64, and EBC.
3574 IPF CPUs expect one additional parameter of type VOID * that specifies
3575 the new backing store pointer.
3577 If EntryPoint is NULL, then ASSERT().
3578 If NewStack is NULL, then ASSERT().
3580 @param EntryPoint A pointer to function to call with the new stack.
3581 @param Context1 A pointer to the context to pass into the EntryPoint
3583 @param Context2 A pointer to the context to pass into the EntryPoint
3585 @param NewStack A pointer to the new stack to use for the EntryPoint
3592 IN SWITCH_STACK_ENTRY_POINT EntryPoint
,
3593 IN VOID
*Context1
, OPTIONAL
3594 IN VOID
*Context2
, OPTIONAL
3601 Generates a breakpoint on the CPU.
3603 Generates a breakpoint on the CPU. The breakpoint must be implemented such
3604 that code can resume normal execution after the breakpoint.
3615 Executes an infinite loop.
3617 Forces the CPU to execute an infinite loop. A debugger may be used to skip
3618 past the loop and the code that follows the loop must execute properly. This
3619 implies that the infinite loop must not cause the code that follow it to be
3630 #if defined (MDE_CPU_IPF)
3633 Flush a range of cache lines in the cache coherency domain of the calling
3636 Invalidates the cache lines specified by Address and Length. If Address is
3637 not aligned on a cache line boundary, then entire cache line containing
3638 Address is invalidated. If Address + Length is not aligned on a cache line
3639 boundary, then the entire instruction cache line containing Address + Length
3640 -1 is invalidated. This function may choose to invalidate the entire
3641 instruction cache if that is more efficient than invalidating the specified
3642 range. If Length is 0, the no instruction cache lines are invalidated.
3643 Address is returned.
3645 If Length is greater than (MAX_ADDRESS - Address + 1), then ASSERT().
3647 @param Address The base address of the instruction lines to invalidate. If
3648 the CPU is in a physical addressing mode, then Address is a
3649 physical address. If the CPU is in a virtual addressing mode,
3650 then Address is a virtual address.
3652 @param Length The number of bytes to invalidate from the instruction cache.
3659 IpfFlushCacheRange (
3666 Executes a FC instruction
3667 Executes a FC instruction on the cache line specified by Address.
3668 The cache line size affected is at least 32-bytes (aligned on a 32-byte boundary).
3669 An implementation may flush a larger region. This function is only available on IPF.
3671 @param Address The Address of cache line to be flushed.
3673 @return The address of FC instruction executed.
3684 Executes a FC.I instruction.
3685 Executes a FC.I instruction on the cache line specified by Address.
3686 The cache line size affected is at least 32-bytes (aligned on a 32-byte boundary).
3687 An implementation may flush a larger region. This function is only available on IPF.
3689 @param Address The Address of cache line to be flushed.
3691 @return The address of FC.I instruction executed.
3702 Reads the current value of a Processor Identifier Register (CPUID).
3703 The Index of largest implemented CPUID (One less than the number of implemented CPUID
3704 registers) is determined by CPUID [3] bits {7:0}.
3705 No parameter checking is performed on Index. If the Index value is beyond the
3706 implemented CPUID register range, a Reserved Register/Field fault may occur. The caller
3707 must either guarantee that Index is valid, or the caller must set up fault handlers to
3708 catch the faults. This function is only available on IPF.
3710 @param Index The 8-bit Processor Identifier Register index to read.
3712 @return The current value of Processor Identifier Register specified by Index.
3723 Reads the current value of 64-bit Processor Status Register (PSR).
3724 This function is only available on IPF.
3726 @return The current value of PSR.
3737 Writes the current value of 64-bit Processor Status Register (PSR).
3738 No parameter checking is performed on Value. All bits of Value corresponding to
3739 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.
3740 This function is only available on IPF.
3742 @param Value The 64-bit value to write to PSR.
3744 @return The 64-bit value written to the PSR.
3755 Reads the current value of 64-bit Kernel Register #0 (KR0).
3756 This function is only available on IPF.
3758 @return The current value of KR0.
3769 Reads the current value of 64-bit Kernel Register #1 (KR1).
3770 This function is only available on IPF.
3772 @return The current value of KR1.
3783 Reads the current value of 64-bit Kernel Register #2 (KR2).
3784 This function is only available on IPF.
3786 @return The current value of KR2.
3797 Reads the current value of 64-bit Kernel Register #3 (KR3).
3798 This function is only available on IPF.
3800 @return The current value of KR3.
3811 Reads the current value of 64-bit Kernel Register #4 (KR4).
3812 This function is only available on IPF.
3814 @return The current value of KR4.
3825 Reads the current value of 64-bit Kernel Register #5 (KR5).
3826 This function is only available on IPF.
3828 @return The current value of KR5.
3839 Reads the current value of 64-bit Kernel Register #6 (KR6).
3840 This function is only available on IPF.
3842 @return The current value of KR6.
3853 Reads the current value of 64-bit Kernel Register #7 (KR7).
3854 This function is only available on IPF.
3856 @return The current value of KR7.
3867 Write the current value of 64-bit Kernel Register #0 (KR0).
3868 This function is only available on IPF.
3870 @param Value The 64-bit value to write to KR0.
3872 @return The 64-bit value written to the KR0.
3883 Write the current value of 64-bit Kernel Register #1 (KR1).
3884 This function is only available on IPF.
3886 @param Value The 64-bit value to write to KR1.
3888 @return The 64-bit value written to the KR1.
3899 Write the current value of 64-bit Kernel Register #2 (KR2).
3900 This function is only available on IPF.
3902 @param Value The 64-bit value to write to KR2.
3904 @return The 64-bit value written to the KR2.
3915 Write the current value of 64-bit Kernel Register #3 (KR3).
3916 This function is only available on IPF.
3918 @param Value The 64-bit value to write to KR3.
3920 @return The 64-bit value written to the KR3.
3931 Write the current value of 64-bit Kernel Register #4 (KR4).
3932 This function is only available on IPF.
3934 @param Value The 64-bit value to write to KR4.
3936 @return The 64-bit value written to the KR4.
3947 Write the current value of 64-bit Kernel Register #5 (KR5).
3948 This function is only available on IPF.
3950 @param Value The 64-bit value to write to KR5.
3952 @return The 64-bit value written to the KR5.
3963 Write the current value of 64-bit Kernel Register #6 (KR6).
3964 This function is only available on IPF.
3966 @param Value The 64-bit value to write to KR6.
3968 @return The 64-bit value written to the KR6.
3979 Write the current value of 64-bit Kernel Register #7 (KR7).
3980 This function is only available on IPF.
3982 @param Value The 64-bit value to write to KR7.
3984 @return The 64-bit value written to the KR7.
3995 Reads the current value of Interval Timer Counter Register (ITC).
3996 This function is only available on IPF.
3998 @return The current value of ITC.
4009 Reads the current value of Interval Timer Vector Register (ITV).
4010 This function is only available on IPF.
4012 @return The current value of ITV.
4023 Reads the current value of Interval Timer Match Register (ITM).
4024 This function is only available on IPF.
4026 @return The current value of ITM.
4036 Writes the current value of 64-bit Interval Timer Counter Register (ITC).
4037 This function is only available on IPF.
4039 @param Value The 64-bit value to write to ITC.
4041 @return The 64-bit value written to the ITC.
4052 Writes the current value of 64-bit Interval Timer Match Register (ITM).
4053 This function is only available on IPF.
4055 @param Value The 64-bit value to write to ITM.
4057 @return The 64-bit value written to the ITM.
4068 Writes the current value of 64-bit Interval Timer Vector Register (ITV).
4069 No parameter checking is performed on Value. All bits of Value corresponding to
4070 reserved fields of ITV must be 0 or a Reserved Register/Field fault may occur.
4071 The caller must either guarantee that Value is valid, or the caller must set up
4072 fault handlers to catch the faults.
4073 This function is only available on IPF.
4075 @param Value The 64-bit value to write to ITV.
4077 @return The 64-bit value written to the ITV.
4088 Reads the current value of Default Control Register (DCR).
4089 This function is only available on IPF.
4091 @return The current value of DCR.
4102 Reads the current value of Interruption Vector Address Register (IVA).
4103 This function is only available on IPF.
4105 @return The current value of IVA.
4115 Reads the current value of Page Table Address Register (PTA).
4116 This function is only available on IPF.
4118 @return The current value of PTA.
4129 Writes the current value of 64-bit Default Control Register (DCR).
4130 No parameter checking is performed on Value. All bits of Value corresponding to
4131 reserved fields of DCR must be 0 or a Reserved Register/Field fault may occur.
4132 The caller must either guarantee that Value is valid, or the caller must set up
4133 fault handlers to catch the faults.
4134 This function is only available on IPF.
4136 @param Value The 64-bit value to write to DCR.
4138 @return The 64-bit value written to the DCR.
4149 Writes the current value of 64-bit Interruption Vector Address Register (IVA).
4150 The size of vector table is 32 K bytes and is 32 K bytes aligned
4151 the low 15 bits of Value is ignored when written.
4152 This function is only available on IPF.
4154 @param Value The 64-bit value to write to IVA.
4156 @return The 64-bit value written to the IVA.
4167 Writes the current value of 64-bit Page Table Address Register (PTA).
4168 No parameter checking is performed on Value. All bits of Value corresponding to
4169 reserved fields of DCR must be 0 or a Reserved Register/Field fault may occur.
4170 The caller must either guarantee that Value is valid, or the caller must set up
4171 fault handlers to catch the faults.
4172 This function is only available on IPF.
4174 @param Value The 64-bit value to write to PTA.
4176 @return The 64-bit value written to the PTA.
4186 Reads the current value of Local Interrupt ID Register (LID).
4187 This function is only available on IPF.
4189 @return The current value of LID.
4200 Reads the current value of External Interrupt Vector Register (IVR).
4201 This function is only available on IPF.
4203 @return The current value of IVR.
4214 Reads the current value of Task Priority Register (TPR).
4215 This function is only available on IPF.
4217 @return The current value of TPR.
4228 Reads the current value of External Interrupt Request Register #0 (IRR0).
4229 This function is only available on IPF.
4231 @return The current value of IRR0.
4242 Reads the current value of External Interrupt Request Register #1 (IRR1).
4243 This function is only available on IPF.
4245 @return The current value of IRR1.
4256 Reads the current value of External Interrupt Request Register #2 (IRR2).
4257 This function is only available on IPF.
4259 @return The current value of IRR2.
4270 Reads the current value of External Interrupt Request Register #3 (IRR3).
4271 This function is only available on IPF.
4273 @return The current value of IRR3.
4284 Reads the current value of Performance Monitor Vector Register (PMV).
4285 This function is only available on IPF.
4287 @return The current value of PMV.
4298 Reads the current value of Corrected Machine Check Vector Register (CMCV).
4299 This function is only available on IPF.
4301 @return The current value of CMCV.
4312 Reads the current value of Local Redirection Register #0 (LRR0).
4313 This function is only available on IPF.
4315 @return The current value of LRR0.
4326 Reads the current value of Local Redirection Register #1 (LRR1).
4327 This function is only available on IPF.
4329 @return The current value of LRR1.
4340 Writes the current value of 64-bit Page Local Interrupt ID Register (LID).
4341 No parameter checking is performed on Value. All bits of Value corresponding to
4342 reserved fields of LID must be 0 or a Reserved Register/Field fault may occur.
4343 The caller must either guarantee that Value is valid, or the caller must set up
4344 fault handlers to catch the faults.
4345 This function is only available on IPF.
4347 @param Value The 64-bit value to write to LID.
4349 @return The 64-bit value written to the LID.
4360 Writes the current value of 64-bit Task Priority Register (TPR).
4361 No parameter checking is performed on Value. All bits of Value corresponding to
4362 reserved fields of TPR must be 0 or a Reserved Register/Field fault may occur.
4363 The caller must either guarantee that Value is valid, or the caller must set up
4364 fault handlers to catch the faults.
4365 This function is only available on IPF.
4367 @param Value The 64-bit value to write to TPR.
4369 @return The 64-bit value written to the TPR.
4380 Performs a write operation on End OF External Interrupt Register (EOI).
4381 Writes a value of 0 to the EOI Register. This function is only available on IPF.
4392 Writes the current value of 64-bit Performance Monitor Vector Register (PMV).
4393 No parameter checking is performed on Value. All bits of Value corresponding
4394 to reserved fields of PMV must be 0 or a Reserved Register/Field fault may occur.
4395 The caller must either guarantee that Value is valid, or the caller must set up
4396 fault handlers to catch the faults.
4397 This function is only available on IPF.
4399 @param Value The 64-bit value to write to PMV.
4401 @return The 64-bit value written to the PMV.
4412 Writes the current value of 64-bit Corrected Machine Check Vector Register (CMCV).
4413 No parameter checking is performed on Value. All bits of Value corresponding
4414 to reserved fields of CMCV must be 0 or a Reserved Register/Field fault may occur.
4415 The caller must either guarantee that Value is valid, or the caller must set up
4416 fault handlers to catch the faults.
4417 This function is only available on IPF.
4419 @param Value The 64-bit value to write to CMCV.
4421 @return The 64-bit value written to the CMCV.
4432 Writes the current value of 64-bit Local Redirection Register #0 (LRR0).
4433 No parameter checking is performed on Value. All bits of Value corresponding
4434 to reserved fields of LRR0 must be 0 or a Reserved Register/Field fault may occur.
4435 The caller must either guarantee that Value is valid, or the caller must set up
4436 fault handlers to catch the faults.
4437 This function is only available on IPF.
4439 @param Value The 64-bit value to write to LRR0.
4441 @return The 64-bit value written to the LRR0.
4452 Writes the current value of 64-bit Local Redirection Register #1 (LRR1).
4453 No parameter checking is performed on Value. All bits of Value corresponding
4454 to reserved fields of LRR1 must be 0 or a Reserved Register/Field fault may occur.
4455 The caller must either guarantee that Value is valid, or the caller must
4456 set up fault handlers to catch the faults.
4457 This function is only available on IPF.
4459 @param Value The 64-bit value to write to LRR1.
4461 @return The 64-bit value written to the LRR1.
4472 Reads the current value of Instruction Breakpoint Register (IBR).
4474 The Instruction Breakpoint Registers are used in pairs. The even numbered
4475 registers contain breakpoint addresses, and the odd numbered registers contain
4476 breakpoint mask conditions. At least 4 instruction registers pairs are implemented
4477 on all processor models. Implemented registers are contiguous starting with
4478 register 0. No parameter checking is performed on Index, and if the Index value
4479 is beyond the implemented IBR register range, a Reserved Register/Field fault may
4480 occur. The caller must either guarantee that Index is valid, or the caller must
4481 set up fault handlers to catch the faults.
4482 This function is only available on IPF.
4484 @param Index The 8-bit Instruction Breakpoint Register index to read.
4486 @return The current value of Instruction Breakpoint Register specified by Index.
4497 Reads the current value of Data Breakpoint Register (DBR).
4499 The Data Breakpoint Registers are used in pairs. The even numbered registers
4500 contain breakpoint addresses, and odd numbered registers contain breakpoint
4501 mask conditions. At least 4 data registers pairs are implemented on all processor
4502 models. Implemented registers are contiguous starting with register 0.
4503 No parameter checking is performed on Index. If the Index value is beyond
4504 the implemented DBR register range, a Reserved Register/Field fault may occur.
4505 The caller must either guarantee that Index is valid, or the caller must set up
4506 fault handlers to catch the faults.
4507 This function is only available on IPF.
4509 @param Index The 8-bit Data Breakpoint Register index to read.
4511 @return The current value of Data Breakpoint Register specified by Index.
4522 Reads the current value of Performance Monitor Configuration Register (PMC).
4524 All processor implementations provide at least 4 performance counters
4525 (PMC/PMD [4]...PMC/PMD [7] pairs), and 4 performance monitor counter overflow
4526 status registers (PMC [0]¡ PMC [3]). Processor implementations may provide
4527 additional implementation-dependent PMC and PMD to increase the number of
4528 ¡®generic¡¯ performance counters (PMC/PMD pairs). The remainder of PMC and PMD
4529 register set is implementation dependent. No parameter checking is performed
4530 on Index. If the Index value is beyond the implemented PMC register range,
4531 zero value will be returned.
4532 This function is only available on IPF.
4534 @param Index The 8-bit Performance Monitor Configuration Register index to read.
4536 @return The current value of Performance Monitor Configuration Register
4548 Reads the current value of Performance Monitor Data Register (PMD).
4550 All processor implementations provide at least 4 performance counters
4551 (PMC/PMD [4]...PMC/PMD [7] pairs), and 4 performance monitor counter
4552 overflow status registers (PMC [0]¡ PMC [3]). Processor implementations may
4553 provide additional implementation-dependent PMC and PMD to increase the number
4554 of ¡®generic¡¯ performance counters (PMC/PMD pairs). The remainder of PMC and PMD
4555 register set is implementation dependent. No parameter checking is performed
4556 on Index. If the Index value is beyond the implemented PMD register range,
4557 zero value will be returned.
4558 This function is only available on IPF.
4560 @param Index The 8-bit Performance Monitor Data Register index to read.
4562 @return The current value of Performance Monitor Data Register specified by Index.
4573 Writes the current value of 64-bit Instruction Breakpoint Register (IBR).
4575 Writes current value of Instruction Breakpoint Register specified by Index.
4576 The Instruction Breakpoint Registers are used in pairs. The even numbered
4577 registers contain breakpoint addresses, and odd numbered registers contain
4578 breakpoint mask conditions. At least 4 instruction registers pairs are implemented
4579 on all processor models. Implemented registers are contiguous starting with
4580 register 0. No parameter checking is performed on Index. If the Index value
4581 is beyond the implemented IBR register range, a Reserved Register/Field fault may
4582 occur. The caller must either guarantee that Index is valid, or the caller must
4583 set up fault handlers to catch the faults.
4584 This function is only available on IPF.
4586 @param Index The 8-bit Instruction Breakpoint Register index to write.
4587 @param Value The 64-bit value to write to IBR.
4589 @return The 64-bit value written to the IBR.
4601 Writes the current value of 64-bit Data Breakpoint Register (DBR).
4603 Writes current value of Data Breakpoint Register specified by Index.
4604 The Data Breakpoint Registers are used in pairs. The even numbered registers
4605 contain breakpoint addresses, and odd numbered registers contain breakpoint
4606 mask conditions. At least 4 data registers pairs are implemented on all processor
4607 models. Implemented registers are contiguous starting with register 0. No parameter
4608 checking is performed on Index. If the Index value is beyond the implemented
4609 DBR register range, a Reserved Register/Field fault may occur. The caller must
4610 either guarantee that Index is valid, or the caller must set up fault handlers to
4612 This function is only available on IPF.
4614 @param Index The 8-bit Data Breakpoint Register index to write.
4615 @param Value The 64-bit value to write to DBR.
4617 @return The 64-bit value written to the DBR.
4629 Writes the current value of 64-bit Performance Monitor Configuration Register (PMC).
4631 Writes current value of Performance Monitor Configuration Register specified by Index.
4632 All processor implementations provide at least 4 performance counters
4633 (PMC/PMD [4]...PMC/PMD [7] pairs), and 4 performance monitor counter overflow status
4634 registers (PMC [0]¡ PMC [3]). Processor implementations may provide additional
4635 implementation-dependent PMC and PMD to increase the number of ¡®generic¡¯ performance
4636 counters (PMC/PMD pairs). The remainder of PMC and PMD register set is implementation
4637 dependent. No parameter checking is performed on Index. If the Index value is
4638 beyond the implemented PMC register range, the write is ignored.
4639 This function is only available on IPF.
4641 @param Index The 8-bit Performance Monitor Configuration Register index to write.
4642 @param Value The 64-bit value to write to PMC.
4644 @return The 64-bit value written to the PMC.
4656 Writes the current value of 64-bit Performance Monitor Data Register (PMD).
4658 Writes current value of Performance Monitor Data Register specified by Index.
4659 All processor implementations provide at least 4 performance counters
4660 (PMC/PMD [4]...PMC/PMD [7] pairs), and 4 performance monitor counter overflow
4661 status registers (PMC [0]¡ PMC [3]). Processor implementations may provide
4662 additional implementation-dependent PMC and PMD to increase the number of ¡®generic¡¯
4663 performance counters (PMC/PMD pairs). The remainder of PMC and PMD register set
4664 is implementation dependent. No parameter checking is performed on Index. If the
4665 Index value is beyond the implemented PMD register range, the write is ignored.
4666 This function is only available on IPF.
4668 @param Index The 8-bit Performance Monitor Data Register index to write.
4669 @param Value The 64-bit value to write to PMD.
4671 @return The 64-bit value written to the PMD.
4683 Reads the current value of 64-bit Global Pointer (GP).
4685 Reads and returns the current value of GP.
4686 This function is only available on IPF.
4688 @return The current value of GP.
4699 Write the current value of 64-bit Global Pointer (GP).
4701 Writes the current value of GP. The 64-bit value written to the GP is returned.
4702 No parameter checking is performed on Value.
4703 This function is only available on IPF.
4705 @param Value The 64-bit value to write to GP.
4707 @return The 64-bit value written to the GP.
4718 Reads the current value of 64-bit Stack Pointer (SP).
4720 Reads and returns the current value of SP.
4721 This function is only available on IPF.
4723 @return The current value of SP.
4734 Determines if the CPU is currently executing in virtual, physical, or mixed mode.
4736 Determines the current execution mode of the CPU.
4737 If the CPU is in virtual mode(PSR.RT=1, PSR.DT=1, PSR.IT=1), then 1 is returned.
4738 If the CPU is in physical mode(PSR.RT=0, PSR.DT=0, PSR.IT=0), then 0 is returned.
4739 If the CPU is not in physical mode or virtual mode, then it is in mixed mode,
4741 This function is only available on IPF.
4743 @return 1 The CPU is in virtual mode.
4744 @return 0 The CPU is in physical mode.
4745 @return -1 The CPU is in mixed mode.
4756 Makes a PAL procedure call.
4758 This is a wrapper function to make a PAL procedure call. Based on the Index
4759 value this API will make static or stacked PAL call. The following table
4760 describes the usage of PAL Procedure Index Assignment. Architected procedures
4761 may be designated as required or optional. If a PAL procedure is specified
4762 as optional, a unique return code of 0xFFFFFFFFFFFFFFFF is returned in the
4763 Status field of the PAL_CALL_RETURN structure.
4764 This indicates that the procedure is not present in this PAL implementation.
4765 It is the caller¡¯s responsibility to check for this return code after calling
4766 any optional PAL procedure.
4767 No parameter checking is performed on the 5 input parameters, but there are
4768 some common rules that the caller should follow when making a PAL call. Any
4769 address passed to PAL as buffers for return parameters must be 8-byte aligned.
4770 Unaligned addresses may cause undefined results. For those parameters defined
4771 as reserved or some fields defined as reserved must be zero filled or the invalid
4772 argument return value may be returned or undefined result may occur during the
4773 execution of the procedure. If the PalEntryPoint does not point to a valid
4774 PAL entry point then the system behavior is undefined. This function is only
4777 @param PalEntryPoint The PAL procedure calls entry point.
4778 @param Index The PAL procedure Index number.
4779 @param Arg2 The 2nd parameter for PAL procedure calls.
4780 @param Arg3 The 3rd parameter for PAL procedure calls.
4781 @param Arg4 The 4th parameter for PAL procedure calls.
4783 @return structure returned from the PAL Call procedure, including the status and return value.
4789 IN UINT64 PalEntryPoint
,
4798 Transfers control to a function starting with a new stack.
4800 Transfers control to the function specified by EntryPoint using the new stack
4801 specified by NewStack and passing in the parameters specified by Context1 and
4802 Context2. Context1 and Context2 are optional and may be NULL. The function
4803 EntryPoint must never return.
4805 If EntryPoint is NULL, then ASSERT().
4806 If NewStack is NULL, then ASSERT().
4808 @param EntryPoint A pointer to function to call with the new stack.
4809 @param Context1 A pointer to the context to pass into the EntryPoint
4811 @param Context2 A pointer to the context to pass into the EntryPoint
4813 @param NewStack A pointer to the new stack to use for the EntryPoint
4815 @param NewBsp A pointer to the new memory location for RSE backing
4821 AsmSwitchStackAndBackingStore (
4822 IN SWITCH_STACK_ENTRY_POINT EntryPoint
,
4823 IN VOID
*Context1
, OPTIONAL
4824 IN VOID
*Context2
, OPTIONAL
4831 // Bugbug: This call should be removed after
4832 // the PalCall Instance issue has been fixed.
4835 Performs a PAL call using static calling convention.
4837 An internal function to perform a PAL call using static calling convention.
4839 @param PalEntryPoint The entry point address of PAL. The address in ar.kr5
4840 would be used if this parameter were NULL on input.
4841 @param Arg1 The first argument of a PAL call.
4842 @param Arg1 The second argument of a PAL call.
4843 @param Arg1 The third argument of a PAL call.
4844 @param Arg1 The fourth argument of a PAL call.
4846 @return The values returned in r8, r9, r10 and r11.
4851 IN CONST VOID
*PalEntryPoint
,
4859 #elif defined (MDE_CPU_IA32) || defined (MDE_CPU_X64)
4861 // IA32 and X64 Specific Functions
4864 // Byte packed structure for 16-bit Real Mode EFLAGS
4868 UINT32 CF
:1; // Carry Flag
4869 UINT32 Reserved_0
:1; // Reserved
4870 UINT32 PF
:1; // Parity Flag
4871 UINT32 Reserved_1
:1; // Reserved
4872 UINT32 AF
:1; // Auxiliary Carry Flag
4873 UINT32 Reserved_2
:1; // Reserved
4874 UINT32 ZF
:1; // Zero Flag
4875 UINT32 SF
:1; // Sign Flag
4876 UINT32 TF
:1; // Trap Flag
4877 UINT32 IF
:1; // Interrupt Enable Flag
4878 UINT32 DF
:1; // Direction Flag
4879 UINT32 OF
:1; // Overflow Flag
4880 UINT32 IOPL
:2; // I/O Privilege Level
4881 UINT32 NT
:1; // Nested Task
4882 UINT32 Reserved_3
:1; // Reserved
4888 // Byte packed structure for EFLAGS/RFLAGS
4890 // 64-bits on X64. The upper 32-bits on X64 are reserved
4894 UINT32 CF
:1; // Carry Flag
4895 UINT32 Reserved_0
:1; // Reserved
4896 UINT32 PF
:1; // Parity Flag
4897 UINT32 Reserved_1
:1; // Reserved
4898 UINT32 AF
:1; // Auxiliary Carry Flag
4899 UINT32 Reserved_2
:1; // Reserved
4900 UINT32 ZF
:1; // Zero Flag
4901 UINT32 SF
:1; // Sign Flag
4902 UINT32 TF
:1; // Trap Flag
4903 UINT32 IF
:1; // Interrupt Enable Flag
4904 UINT32 DF
:1; // Direction Flag
4905 UINT32 OF
:1; // Overflow Flag
4906 UINT32 IOPL
:2; // I/O Privilege Level
4907 UINT32 NT
:1; // Nested Task
4908 UINT32 Reserved_3
:1; // Reserved
4909 UINT32 RF
:1; // Resume Flag
4910 UINT32 VM
:1; // Virtual 8086 Mode
4911 UINT32 AC
:1; // Alignment Check
4912 UINT32 VIF
:1; // Virtual Interrupt Flag
4913 UINT32 VIP
:1; // Virtual Interrupt Pending
4914 UINT32 ID
:1; // ID Flag
4915 UINT32 Reserved_4
:10; // Reserved
4921 // Byte packed structure for Control Register 0 (CR0)
4923 // 64-bits on X64. The upper 32-bits on X64 are reserved
4927 UINT32 PE
:1; // Protection Enable
4928 UINT32 MP
:1; // Monitor Coprocessor
4929 UINT32 EM
:1; // Emulation
4930 UINT32 TS
:1; // Task Switched
4931 UINT32 ET
:1; // Extension Type
4932 UINT32 NE
:1; // Numeric Error
4933 UINT32 Reserved_0
:10; // Reserved
4934 UINT32 WP
:1; // Write Protect
4935 UINT32 Reserved_1
:1; // Reserved
4936 UINT32 AM
:1; // Alignment Mask
4937 UINT32 Reserved_2
:10; // Reserved
4938 UINT32 NW
:1; // Mot Write-through
4939 UINT32 CD
:1; // Cache Disable
4940 UINT32 PG
:1; // Paging
4946 // Byte packed structure for Control Register 4 (CR4)
4948 // 64-bits on X64. The upper 32-bits on X64 are reserved
4952 UINT32 VME
:1; // Virtual-8086 Mode Extensions
4953 UINT32 PVI
:1; // Protected-Mode Virtual Interrupts
4954 UINT32 TSD
:1; // Time Stamp Disable
4955 UINT32 DE
:1; // Debugging Extensions
4956 UINT32 PSE
:1; // Page Size Extensions
4957 UINT32 PAE
:1; // Physical Address Extension
4958 UINT32 MCE
:1; // Machine Check Enable
4959 UINT32 PGE
:1; // Page Global Enable
4960 UINT32 PCE
:1; // Performance Monitoring Counter
4962 UINT32 OSFXSR
:1; // Operating System Support for
4963 // FXSAVE and FXRSTOR instructions
4964 UINT32 OSXMMEXCPT
:1; // Operating System Support for
4965 // Unmasked SIMD Floating Point
4967 UINT32 Reserved_0
:2; // Reserved
4968 UINT32 VMXE
:1; // VMX Enable
4969 UINT32 Reserved_1
:18; // Reseved
4975 // Byte packed structure for an IDTR, GDTR, LDTR descriptor
4976 /// @bug How to make this structure byte-packed in a compiler independent way?
4985 #define IA32_IDT_GATE_TYPE_TASK 0x85
4986 #define IA32_IDT_GATE_TYPE_INTERRUPT_16 0x86
4987 #define IA32_IDT_GATE_TYPE_TRAP_16 0x87
4988 #define IA32_IDT_GATE_TYPE_INTERRUPT_32 0x8E
4989 #define IA32_IDT_GATE_TYPE_TRAP_32 0x8F
4992 // Byte packed structure for an Interrupt Gate Descriptor
4996 UINT32 OffsetLow
:16; // Offset bits 15..0
4997 UINT32 Selector
:16; // Selector
4998 UINT32 Reserved_0
:8; // Reserved
4999 UINT32 GateType
:8; // Gate Type. See #defines above
5000 UINT32 OffsetHigh
:16; // Offset bits 31..16
5003 } IA32_IDT_GATE_DESCRIPTOR
;
5006 // Byte packed structure for an FP/SSE/SSE2 context
5013 // Structures for the 16-bit real mode thunks
5066 IA32_EFLAGS32 EFLAGS
;
5076 } IA32_REGISTER_SET
;
5079 // Byte packed structure for an 16-bit real mode thunks
5082 IA32_REGISTER_SET
*RealModeState
;
5083 VOID
*RealModeBuffer
;
5084 UINT32 RealModeBufferSize
;
5085 UINT32 ThunkAttributes
;
5088 #define THUNK_ATTRIBUTE_BIG_REAL_MODE 0x00000001
5089 #define THUNK_ATTRIBUTE_DISABLE_A20_MASK_INT_15 0x00000002
5090 #define THUNK_ATTRIBUTE_DISABLE_A20_MASK_KBD_CTRL 0x00000004
5093 Retrieves CPUID information.
5095 Executes the CPUID instruction with EAX set to the value specified by Index.
5096 This function always returns Index.
5097 If Eax is not NULL, then the value of EAX after CPUID is returned in Eax.
5098 If Ebx is not NULL, then the value of EBX after CPUID is returned in Ebx.
5099 If Ecx is not NULL, then the value of ECX after CPUID is returned in Ecx.
5100 If Edx is not NULL, then the value of EDX after CPUID is returned in Edx.
5101 This function is only available on IA-32 and X64.
5103 @param Index The 32-bit value to load into EAX prior to invoking the CPUID
5105 @param Eax Pointer to the 32-bit EAX value returned by the CPUID
5106 instruction. This is an optional parameter that may be NULL.
5107 @param Ebx Pointer to the 32-bit EBX value returned by the CPUID
5108 instruction. This is an optional parameter that may be NULL.
5109 @param Ecx Pointer to the 32-bit ECX value returned by the CPUID
5110 instruction. This is an optional parameter that may be NULL.
5111 @param Edx Pointer to the 32-bit EDX value returned by the CPUID
5112 instruction. This is an optional parameter that may be NULL.
5121 OUT UINT32
*Eax
, OPTIONAL
5122 OUT UINT32
*Ebx
, OPTIONAL
5123 OUT UINT32
*Ecx
, OPTIONAL
5124 OUT UINT32
*Edx OPTIONAL
5129 Retrieves CPUID information using an extended leaf identifier.
5131 Executes the CPUID instruction with EAX set to the value specified by Index
5132 and ECX set to the value specified by SubIndex. This function always returns
5133 Index. This function is only available on IA-32 and x64.
5135 If Eax is not NULL, then the value of EAX after CPUID is returned in Eax.
5136 If Ebx is not NULL, then the value of EBX after CPUID is returned in Ebx.
5137 If Ecx is not NULL, then the value of ECX after CPUID is returned in Ecx.
5138 If Edx is not NULL, then the value of EDX after CPUID is returned in Edx.
5140 @param Index The 32-bit value to load into EAX prior to invoking the
5142 @param SubIndex The 32-bit value to load into ECX prior to invoking the
5144 @param Eax Pointer to the 32-bit EAX value returned by the CPUID
5145 instruction. This is an optional parameter that may be
5147 @param Ebx Pointer to the 32-bit EBX value returned by the CPUID
5148 instruction. This is an optional parameter that may be
5150 @param Ecx Pointer to the 32-bit ECX value returned by the CPUID
5151 instruction. This is an optional parameter that may be
5153 @param Edx Pointer to the 32-bit EDX value returned by the CPUID
5154 instruction. This is an optional parameter that may be
5165 OUT UINT32
*Eax
, OPTIONAL
5166 OUT UINT32
*Ebx
, OPTIONAL
5167 OUT UINT32
*Ecx
, OPTIONAL
5168 OUT UINT32
*Edx OPTIONAL
5173 Returns the lower 32-bits of a Machine Specific Register(MSR).
5175 Reads and returns the lower 32-bits of the MSR specified by Index.
5176 No parameter checking is performed on Index, and some Index values may cause
5177 CPU exceptions. The caller must either guarantee that Index is valid, or the
5178 caller must set up exception handlers to catch the exceptions. This function
5179 is only available on IA-32 and X64.
5181 @param Index The 32-bit MSR index to read.
5183 @return The lower 32 bits of the MSR identified by Index.
5194 Zero-extend a 32-bit value and writes it to a Machine Specific Register(MSR).
5196 Writes the 32-bit value specified by Value to the MSR specified by Index. The
5197 upper 32-bits of the MSR write are set to zero. The 32-bit value written to
5198 the MSR is returned. No parameter checking is performed on Index or Value,
5199 and some of these may cause CPU exceptions. The caller must either guarantee
5200 that Index and Value are valid, or the caller must establish proper exception
5201 handlers. This function is only available on IA-32 and X64.
5203 @param Index The 32-bit MSR index to write.
5204 @param Value The 32-bit value to write to the MSR.
5218 Reads a 64-bit MSR, performs a bitwise inclusive OR on the lower 32-bits, and
5219 writes the result back to the 64-bit MSR.
5221 Reads the 64-bit MSR specified by Index, performs a bitwise inclusive OR
5222 between the lower 32-bits of the read result and the value specified by
5223 OrData, and writes the result to the 64-bit MSR specified by Index. The lower
5224 32-bits of the value written to the MSR is returned. No parameter checking is
5225 performed on Index or OrData, and some of these may cause CPU exceptions. The
5226 caller must either guarantee that Index and OrData are valid, or the caller
5227 must establish proper exception handlers. This function is only available on
5230 @param Index The 32-bit MSR index to write.
5231 @param OrData The value to OR with the read value from the MSR.
5233 @return The lower 32-bit value written to the MSR.
5245 Reads a 64-bit MSR, performs a bitwise AND on the lower 32-bits, and writes
5246 the result back to the 64-bit MSR.
5248 Reads the 64-bit MSR specified by Index, performs a bitwise AND between the
5249 lower 32-bits of the read result and the value specified by AndData, and
5250 writes the result to the 64-bit MSR specified by Index. The lower 32-bits of
5251 the value written to the MSR is returned. No parameter checking is performed
5252 on Index or AndData, and some of these may cause CPU exceptions. The caller
5253 must either guarantee that Index and AndData are valid, or the caller must
5254 establish proper exception handlers. This function is only available on IA-32
5257 @param Index The 32-bit MSR index to write.
5258 @param AndData The value to AND with the read value from the MSR.
5260 @return The lower 32-bit value written to the MSR.
5272 Reads a 64-bit MSR, performs a bitwise AND followed by a bitwise inclusive OR
5273 on the lower 32-bits, and writes the result back to the 64-bit MSR.
5275 Reads the 64-bit MSR specified by Index, performs a bitwise AND between the
5276 lower 32-bits of the read result and the value specified by AndData
5277 preserving the upper 32-bits, performs a bitwise inclusive OR between the
5278 result of the AND operation and the value specified by OrData, and writes the
5279 result to the 64-bit MSR specified by Address. The lower 32-bits of the value
5280 written to the MSR is returned. No parameter checking is performed on Index,
5281 AndData, or OrData, and some of these may cause CPU exceptions. The caller
5282 must either guarantee that Index, AndData, and OrData are valid, or the
5283 caller must establish proper exception handlers. This function is only
5284 available on IA-32 and X64.
5286 @param Index The 32-bit MSR index to write.
5287 @param AndData The value to AND with the read value from the MSR.
5288 @param OrData The value to OR with the result of the AND operation.
5290 @return The lower 32-bit value written to the MSR.
5303 Reads a bit field of an MSR.
5305 Reads the bit field in the lower 32-bits of a 64-bit MSR. The bit field is
5306 specified by the StartBit and the EndBit. The value of the bit field is
5307 returned. The caller must either guarantee that Index is valid, or the caller
5308 must set up exception handlers to catch the exceptions. This function is only
5309 available on IA-32 and X64.
5311 If StartBit is greater than 31, then ASSERT().
5312 If EndBit is greater than 31, then ASSERT().
5313 If EndBit is less than StartBit, then ASSERT().
5315 @param Index The 32-bit MSR index to read.
5316 @param StartBit The ordinal of the least significant bit in the bit field.
5318 @param EndBit The ordinal of the most significant bit in the bit field.
5321 @return The bit field read from the MSR.
5326 AsmMsrBitFieldRead32 (
5334 Writes a bit field to an MSR.
5336 Writes Value to a bit field in the lower 32-bits of a 64-bit MSR. The bit
5337 field is specified by the StartBit and the EndBit. All other bits in the
5338 destination MSR are preserved. The lower 32-bits of the MSR written is
5339 returned. Extra left bits in Value are stripped. The caller must either
5340 guarantee that Index and the data written is valid, or the caller must set up
5341 exception handlers to catch the exceptions. This function is only available
5344 If StartBit is greater than 31, then ASSERT().
5345 If EndBit is greater than 31, then ASSERT().
5346 If EndBit is less than StartBit, then ASSERT().
5348 @param Index The 32-bit MSR index to write.
5349 @param StartBit The ordinal of the least significant bit in the bit field.
5351 @param EndBit The ordinal of the most significant bit in the bit field.
5353 @param Value New value of the bit field.
5355 @return The lower 32-bit of the value written to the MSR.
5360 AsmMsrBitFieldWrite32 (
5369 Reads a bit field in a 64-bit MSR, performs a bitwise OR, and writes the
5370 result back to the bit field in the 64-bit MSR.
5372 Reads the 64-bit MSR specified by Index, performs a bitwise inclusive OR
5373 between the read result and the value specified by OrData, and writes the
5374 result to the 64-bit MSR specified by Index. The lower 32-bits of the value
5375 written to the MSR are returned. Extra left bits in OrData are stripped. The
5376 caller must either guarantee that Index and the data written is valid, or
5377 the caller must set up exception handlers to catch the exceptions. This
5378 function is only available on IA-32 and X64.
5380 If StartBit is greater than 31, then ASSERT().
5381 If EndBit is greater than 31, then ASSERT().
5382 If EndBit is less than StartBit, then ASSERT().
5384 @param Index The 32-bit MSR index to write.
5385 @param StartBit The ordinal of the least significant bit in the bit field.
5387 @param EndBit The ordinal of the most significant bit in the bit field.
5389 @param OrData The value to OR with the read value from the MSR.
5391 @return The lower 32-bit of the value written to the MSR.
5396 AsmMsrBitFieldOr32 (
5405 Reads a bit field in a 64-bit MSR, performs a bitwise AND, and writes the
5406 result back to the bit field in the 64-bit MSR.
5408 Reads the 64-bit MSR specified by Index, performs a bitwise AND between the
5409 read result and the value specified by AndData, and writes the result to the
5410 64-bit MSR specified by Index. The lower 32-bits of the value written to the
5411 MSR are returned. Extra left bits in AndData are stripped. The caller must
5412 either guarantee that Index and the data written is valid, or the caller must
5413 set up exception handlers to catch the exceptions. This function is only
5414 available on IA-32 and X64.
5416 If StartBit is greater than 31, then ASSERT().
5417 If EndBit is greater than 31, then ASSERT().
5418 If EndBit is less than StartBit, then ASSERT().
5420 @param Index The 32-bit MSR index to write.
5421 @param StartBit The ordinal of the least significant bit in the bit field.
5423 @param EndBit The ordinal of the most significant bit in the bit field.
5425 @param AndData The value to AND with the read value from the MSR.
5427 @return The lower 32-bit of the value written to the MSR.
5432 AsmMsrBitFieldAnd32 (
5441 Reads a bit field in a 64-bit MSR, performs a bitwise AND followed by a
5442 bitwise inclusive OR, and writes the result back to the bit field in the
5445 Reads the 64-bit MSR specified by Index, performs a bitwise AND followed by a
5446 bitwise inclusive OR between the read result and the value specified by
5447 AndData, and writes the result to the 64-bit MSR specified by Index. The
5448 lower 32-bits of the value written to the MSR are returned. Extra left bits
5449 in both AndData and OrData are stripped. The caller must either guarantee
5450 that Index and the data written is valid, or the caller must set up exception
5451 handlers to catch the exceptions. This function is only available on IA-32
5454 If StartBit is greater than 31, then ASSERT().
5455 If EndBit is greater than 31, then ASSERT().
5456 If EndBit is less than StartBit, then ASSERT().
5458 @param Index The 32-bit MSR index to write.
5459 @param StartBit The ordinal of the least significant bit in the bit field.
5461 @param EndBit The ordinal of the most significant bit in the bit field.
5463 @param AndData The value to AND with the read value from the MSR.
5464 @param OrData The value to OR with the result of the AND operation.
5466 @return The lower 32-bit of the value written to the MSR.
5471 AsmMsrBitFieldAndThenOr32 (
5481 Returns a 64-bit Machine Specific Register(MSR).
5483 Reads and returns the 64-bit MSR specified by Index. No parameter checking is
5484 performed on Index, and some Index values may cause CPU exceptions. The
5485 caller must either guarantee that Index is valid, or the caller must set up
5486 exception handlers to catch the exceptions. This function is only available
5489 @param Index The 32-bit MSR index to read.
5491 @return The value of the MSR identified by Index.
5502 Writes a 64-bit value to a Machine Specific Register(MSR), and returns the
5505 Writes the 64-bit value specified by Value to the MSR specified by Index. The
5506 64-bit value written to the MSR is returned. No parameter checking is
5507 performed on Index or Value, and some of these may cause CPU exceptions. The
5508 caller must either guarantee that Index and Value are valid, or the caller
5509 must establish proper exception handlers. This function is only available on
5512 @param Index The 32-bit MSR index to write.
5513 @param Value The 64-bit value to write to the MSR.
5527 Reads a 64-bit MSR, performs a bitwise inclusive OR, and writes the result
5528 back to the 64-bit MSR.
5530 Reads the 64-bit MSR specified by Index, performs a bitwise inclusive OR
5531 between the read result and the value specified by OrData, and writes the
5532 result to the 64-bit MSR specified by Index. The value written to the MSR is
5533 returned. No parameter checking is performed on Index or OrData, and some of
5534 these may cause CPU exceptions. The caller must either guarantee that Index
5535 and OrData are valid, or the caller must establish proper exception handlers.
5536 This function is only available on IA-32 and X64.
5538 @param Index The 32-bit MSR index to write.
5539 @param OrData The value to OR with the read value from the MSR.
5541 @return The value written back to the MSR.
5553 Reads a 64-bit MSR, performs a bitwise AND, and writes the result back to the
5556 Reads the 64-bit MSR specified by Index, performs a bitwise AND between the
5557 read result and the value specified by OrData, and writes the result to the
5558 64-bit MSR specified by Index. The value written to the MSR is returned. No
5559 parameter checking is performed on Index or OrData, and some of these may
5560 cause CPU exceptions. The caller must either guarantee that Index and OrData
5561 are valid, or the caller must establish proper exception handlers. This
5562 function is only available on IA-32 and X64.
5564 @param Index The 32-bit MSR index to write.
5565 @param AndData The value to AND with the read value from the MSR.
5567 @return The value written back to the MSR.
5579 Reads a 64-bit MSR, performs a bitwise AND followed by a bitwise inclusive
5580 OR, and writes the result back to the 64-bit MSR.
5582 Reads the 64-bit MSR specified by Index, performs a bitwise AND between read
5583 result and the value specified by AndData, performs a bitwise inclusive OR
5584 between the result of the AND operation and the value specified by OrData,
5585 and writes the result to the 64-bit MSR specified by Index. The value written
5586 to the MSR is returned. No parameter checking is performed on Index, AndData,
5587 or OrData, and some of these may cause CPU exceptions. The caller must either
5588 guarantee that Index, AndData, and OrData are valid, or the caller must
5589 establish proper exception handlers. This function is only available on IA-32
5592 @param Index The 32-bit MSR index to write.
5593 @param AndData The value to AND with the read value from the MSR.
5594 @param OrData The value to OR with the result of the AND operation.
5596 @return The value written back to the MSR.
5609 Reads a bit field of an MSR.
5611 Reads the bit field in the 64-bit MSR. The bit field is specified by the
5612 StartBit and the EndBit. The value of the bit field is returned. The caller
5613 must either guarantee that Index is valid, or the caller must set up
5614 exception handlers to catch the exceptions. This function is only available
5617 If StartBit is greater than 63, then ASSERT().
5618 If EndBit is greater than 63, then ASSERT().
5619 If EndBit is less than StartBit, then ASSERT().
5621 @param Index The 32-bit MSR index to read.
5622 @param StartBit The ordinal of the least significant bit in the bit field.
5624 @param EndBit The ordinal of the most significant bit in the bit field.
5627 @return The value read from the MSR.
5632 AsmMsrBitFieldRead64 (
5640 Writes a bit field to an MSR.
5642 Writes Value to a bit field in a 64-bit MSR. The bit field is specified by
5643 the StartBit and the EndBit. All other bits in the destination MSR are
5644 preserved. The MSR written is returned. Extra left bits in Value are
5645 stripped. The caller must either guarantee that Index and the data written is
5646 valid, or the caller must set up exception handlers to catch the exceptions.
5647 This function is only available on IA-32 and X64.
5649 If StartBit is greater than 63, then ASSERT().
5650 If EndBit is greater than 63, then ASSERT().
5651 If EndBit is less than StartBit, then ASSERT().
5653 @param Index The 32-bit MSR index to write.
5654 @param StartBit The ordinal of the least significant bit in the bit field.
5656 @param EndBit The ordinal of the most significant bit in the bit field.
5658 @param Value New value of the bit field.
5660 @return The value written back to the MSR.
5665 AsmMsrBitFieldWrite64 (
5674 Reads a bit field in a 64-bit MSR, performs a bitwise inclusive OR, and
5675 writes the result back to the bit field in the 64-bit MSR.
5677 Reads the 64-bit MSR specified by Index, performs a bitwise inclusive OR
5678 between the read result and the value specified by OrData, and writes the
5679 result to the 64-bit MSR specified by Index. The value written to the MSR is
5680 returned. Extra left bits in OrData are stripped. The caller must either
5681 guarantee that Index and the data written is valid, or the caller must set up
5682 exception handlers to catch the exceptions. This function is only available
5685 If StartBit is greater than 63, then ASSERT().
5686 If EndBit is greater than 63, then ASSERT().
5687 If EndBit is less than StartBit, then ASSERT().
5689 @param Index The 32-bit MSR index to write.
5690 @param StartBit The ordinal of the least significant bit in the bit field.
5692 @param EndBit The ordinal of the most significant bit in the bit field.
5694 @param OrData The value to OR with the read value from the bit field.
5696 @return The value written back to the MSR.
5701 AsmMsrBitFieldOr64 (
5710 Reads a bit field in a 64-bit MSR, performs a bitwise AND, and writes the
5711 result back to the bit field in the 64-bit MSR.
5713 Reads the 64-bit MSR specified by Index, performs a bitwise AND between the
5714 read result and the value specified by AndData, and writes the result to the
5715 64-bit MSR specified by Index. The value written to the MSR is returned.
5716 Extra left bits in AndData are stripped. The caller must either guarantee
5717 that Index and the data written is valid, or the caller must set up exception
5718 handlers to catch the exceptions. This function is only available on IA-32
5721 If StartBit is greater than 63, then ASSERT().
5722 If EndBit is greater than 63, then ASSERT().
5723 If EndBit is less than StartBit, then ASSERT().
5725 @param Index The 32-bit MSR index to write.
5726 @param StartBit The ordinal of the least significant bit in the bit field.
5728 @param EndBit The ordinal of the most significant bit in the bit field.
5730 @param AndData The value to AND with the read value from the bit field.
5732 @return The value written back to the MSR.
5737 AsmMsrBitFieldAnd64 (
5746 Reads a bit field in a 64-bit MSR, performs a bitwise AND followed by a
5747 bitwise inclusive OR, and writes the result back to the bit field in the
5750 Reads the 64-bit MSR specified by Index, performs a bitwise AND followed by
5751 a bitwise inclusive OR between the read result and the value specified by
5752 AndData, and writes the result to the 64-bit MSR specified by Index. The
5753 value written to the MSR is returned. Extra left bits in both AndData and
5754 OrData are stripped. The caller must either guarantee that Index and the data
5755 written is valid, or the caller must set up exception handlers to catch the
5756 exceptions. This function is only available on IA-32 and X64.
5758 If StartBit is greater than 63, then ASSERT().
5759 If EndBit is greater than 63, then ASSERT().
5760 If EndBit is less than StartBit, then ASSERT().
5762 @param Index The 32-bit MSR index to write.
5763 @param StartBit The ordinal of the least significant bit in the bit field.
5765 @param EndBit The ordinal of the most significant bit in the bit field.
5767 @param AndData The value to AND with the read value from the bit field.
5768 @param OrData The value to OR with the result of the AND operation.
5770 @return The value written back to the MSR.
5775 AsmMsrBitFieldAndThenOr64 (
5785 Reads the current value of the EFLAGS register.
5787 Reads and returns the current value of the EFLAGS register. This function is
5788 only available on IA-32 and X64. This returns a 32-bit value on IA-32 and a
5789 64-bit value on X64.
5791 @return EFLAGS on IA-32 or RFLAGS on X64.
5802 Reads the current value of the Control Register 0 (CR0).
5804 Reads and returns the current value of CR0. This function is only available
5805 on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on
5808 @return The value of the Control Register 0 (CR0).
5819 Reads the current value of the Control Register 2 (CR2).
5821 Reads and returns the current value of CR2. This function is only available
5822 on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on
5825 @return The value of the Control Register 2 (CR2).
5836 Reads the current value of the Control Register 3 (CR3).
5838 Reads and returns the current value of CR3. This function is only available
5839 on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on
5842 @return The value of the Control Register 3 (CR3).
5853 Reads the current value of the Control Register 4 (CR4).
5855 Reads and returns the current value of CR4. This function is only available
5856 on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on
5859 @return The value of the Control Register 4 (CR4).
5870 Writes a value to Control Register 0 (CR0).
5872 Writes and returns a new value to CR0. This function is only available on
5873 IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.
5875 @param Cr0 The value to write to CR0.
5877 @return The value written to CR0.
5888 Writes a value to Control Register 2 (CR2).
5890 Writes and returns a new value to CR2. This function is only available on
5891 IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.
5893 @param Cr2 The value to write to CR2.
5895 @return The value written to CR2.
5906 Writes a value to Control Register 3 (CR3).
5908 Writes and returns a new value to CR3. This function is only available on
5909 IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.
5911 @param Cr3 The value to write to CR3.
5913 @return The value written to CR3.
5924 Writes a value to Control Register 4 (CR4).
5926 Writes and returns a new value to CR4. This function is only available on
5927 IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.
5929 @param Cr4 The value to write to CR4.
5931 @return The value written to CR4.
5942 Reads the current value of Debug Register 0 (DR0).
5944 Reads and returns the current value of DR0. This function is only available
5945 on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on
5948 @return The value of Debug Register 0 (DR0).
5959 Reads the current value of Debug Register 1 (DR1).
5961 Reads and returns the current value of DR1. This function is only available
5962 on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on
5965 @return The value of Debug Register 1 (DR1).
5976 Reads the current value of Debug Register 2 (DR2).
5978 Reads and returns the current value of DR2. This function is only available
5979 on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on
5982 @return The value of Debug Register 2 (DR2).
5993 Reads the current value of Debug Register 3 (DR3).
5995 Reads and returns the current value of DR3. This function is only available
5996 on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on
5999 @return The value of Debug Register 3 (DR3).
6010 Reads the current value of Debug Register 4 (DR4).
6012 Reads and returns the current value of DR4. This function is only available
6013 on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on
6016 @return The value of Debug Register 4 (DR4).
6027 Reads the current value of Debug Register 5 (DR5).
6029 Reads and returns the current value of DR5. This function is only available
6030 on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on
6033 @return The value of Debug Register 5 (DR5).
6044 Reads the current value of Debug Register 6 (DR6).
6046 Reads and returns the current value of DR6. This function is only available
6047 on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on
6050 @return The value of Debug Register 6 (DR6).
6061 Reads the current value of Debug Register 7 (DR7).
6063 Reads and returns the current value of DR7. This function is only available
6064 on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on
6067 @return The value of Debug Register 7 (DR7).
6078 Writes a value to Debug Register 0 (DR0).
6080 Writes and returns a new value to DR0. This function is only available on
6081 IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.
6083 @param Dr0 The value to write to Dr0.
6085 @return The value written to Debug Register 0 (DR0).
6096 Writes a value to Debug Register 1 (DR1).
6098 Writes and returns a new value to DR1. This function is only available on
6099 IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.
6101 @param Dr1 The value to write to Dr1.
6103 @return The value written to Debug Register 1 (DR1).
6114 Writes a value to Debug Register 2 (DR2).
6116 Writes and returns a new value to DR2. This function is only available on
6117 IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.
6119 @param Dr2 The value to write to Dr2.
6121 @return The value written to Debug Register 2 (DR2).
6132 Writes a value to Debug Register 3 (DR3).
6134 Writes and returns a new value to DR3. This function is only available on
6135 IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.
6137 @param Dr3 The value to write to Dr3.
6139 @return The value written to Debug Register 3 (DR3).
6150 Writes a value to Debug Register 4 (DR4).
6152 Writes and returns a new value to DR4. This function is only available on
6153 IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.
6155 @param Dr4 The value to write to Dr4.
6157 @return The value written to Debug Register 4 (DR4).
6168 Writes a value to Debug Register 5 (DR5).
6170 Writes and returns a new value to DR5. This function is only available on
6171 IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.
6173 @param Dr5 The value to write to Dr5.
6175 @return The value written to Debug Register 5 (DR5).
6186 Writes a value to Debug Register 6 (DR6).
6188 Writes and returns a new value to DR6. This function is only available on
6189 IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.
6191 @param Dr6 The value to write to Dr6.
6193 @return The value written to Debug Register 6 (DR6).
6204 Writes a value to Debug Register 7 (DR7).
6206 Writes and returns a new value to DR7. This function is only available on
6207 IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.
6209 @param Dr7 The value to write to Dr7.
6211 @return The value written to Debug Register 7 (DR7).
6222 Reads the current value of Code Segment Register (CS).
6224 Reads and returns the current value of CS. This function is only available on
6227 @return The current value of CS.
6238 Reads the current value of Data Segment Register (DS).
6240 Reads and returns the current value of DS. This function is only available on
6243 @return The current value of DS.
6254 Reads the current value of Extra Segment Register (ES).
6256 Reads and returns the current value of ES. This function is only available on
6259 @return The current value of ES.
6270 Reads the current value of FS Data Segment Register (FS).
6272 Reads and returns the current value of FS. This function is only available on
6275 @return The current value of FS.
6286 Reads the current value of GS Data Segment Register (GS).
6288 Reads and returns the current value of GS. This function is only available on
6291 @return The current value of GS.
6302 Reads the current value of Stack Segment Register (SS).
6304 Reads and returns the current value of SS. This function is only available on
6307 @return The current value of SS.
6318 Reads the current value of Task Register (TR).
6320 Reads and returns the current value of TR. This function is only available on
6323 @return The current value of TR.
6334 Reads the current Global Descriptor Table Register(GDTR) descriptor.
6336 Reads and returns the current GDTR descriptor and returns it in Gdtr. This
6337 function is only available on IA-32 and X64.
6339 If Gdtr is NULL, then ASSERT().
6341 @param Gdtr Pointer to a GDTR descriptor.
6347 OUT IA32_DESCRIPTOR
*Gdtr
6352 Writes the current Global Descriptor Table Register (GDTR) descriptor.
6354 Writes and the current GDTR descriptor specified by Gdtr. This function is
6355 only available on IA-32 and X64.
6357 If Gdtr is NULL, then ASSERT().
6359 @param Gdtr Pointer to a GDTR descriptor.
6365 IN CONST IA32_DESCRIPTOR
*Gdtr
6370 Reads the current Interrupt Descriptor Table Register(GDTR) descriptor.
6372 Reads and returns the current IDTR descriptor and returns it in Idtr. This
6373 function is only available on IA-32 and X64.
6375 If Idtr is NULL, then ASSERT().
6377 @param Idtr Pointer to a IDTR descriptor.
6383 OUT IA32_DESCRIPTOR
*Idtr
6388 Writes the current Interrupt Descriptor Table Register(GDTR) descriptor.
6390 Writes the current IDTR descriptor and returns it in Idtr. This function is
6391 only available on IA-32 and X64.
6393 If Idtr is NULL, then ASSERT().
6395 @param Idtr Pointer to a IDTR descriptor.
6401 IN CONST IA32_DESCRIPTOR
*Idtr
6406 Reads the current Local Descriptor Table Register(LDTR) selector.
6408 Reads and returns the current 16-bit LDTR descriptor value. This function is
6409 only available on IA-32 and X64.
6411 @return The current selector of LDT.
6422 Writes the current Local Descriptor Table Register (GDTR) selector.
6424 Writes and the current LDTR descriptor specified by Ldtr. This function is
6425 only available on IA-32 and X64.
6427 @param Ldtr 16-bit LDTR selector value.
6438 Save the current floating point/SSE/SSE2 context to a buffer.
6440 Saves the current floating point/SSE/SSE2 state to the buffer specified by
6441 Buffer. Buffer must be aligned on a 16-byte boundary. This function is only
6442 available on IA-32 and X64.
6444 If Buffer is NULL, then ASSERT().
6445 If Buffer is not aligned on a 16-byte boundary, then ASSERT().
6447 @param Buffer Pointer to a buffer to save the floating point/SSE/SSE2 context.
6453 OUT IA32_FX_BUFFER
*Buffer
6458 Restores the current floating point/SSE/SSE2 context from a buffer.
6460 Restores the current floating point/SSE/SSE2 state from the buffer specified
6461 by Buffer. Buffer must be aligned on a 16-byte boundary. This function is
6462 only available on IA-32 and X64.
6464 If Buffer is NULL, then ASSERT().
6465 If Buffer is not aligned on a 16-byte boundary, then ASSERT().
6466 If Buffer was not saved with AsmFxSave(), then ASSERT().
6468 @param Buffer Pointer to a buffer to save the floating point/SSE/SSE2 context.
6474 IN CONST IA32_FX_BUFFER
*Buffer
6479 Reads the current value of 64-bit MMX Register #0 (MM0).
6481 Reads and returns the current value of MM0. This function is only available
6484 @return The current value of MM0.
6495 Reads the current value of 64-bit MMX Register #1 (MM1).
6497 Reads and returns the current value of MM1. This function is only available
6500 @return The current value of MM1.
6511 Reads the current value of 64-bit MMX Register #2 (MM2).
6513 Reads and returns the current value of MM2. This function is only available
6516 @return The current value of MM2.
6527 Reads the current value of 64-bit MMX Register #3 (MM3).
6529 Reads and returns the current value of MM3. This function is only available
6532 @return The current value of MM3.
6543 Reads the current value of 64-bit MMX Register #4 (MM4).
6545 Reads and returns the current value of MM4. This function is only available
6548 @return The current value of MM4.
6559 Reads the current value of 64-bit MMX Register #5 (MM5).
6561 Reads and returns the current value of MM5. This function is only available
6564 @return The current value of MM5.
6575 Reads the current value of 64-bit MMX Register #6 (MM6).
6577 Reads and returns the current value of MM6. This function is only available
6580 @return The current value of MM6.
6591 Reads the current value of 64-bit MMX Register #7 (MM7).
6593 Reads and returns the current value of MM7. This function is only available
6596 @return The current value of MM7.
6607 Writes the current value of 64-bit MMX Register #0 (MM0).
6609 Writes the current value of MM0. This function is only available on IA32 and
6612 @param Value The 64-bit value to write to MM0.
6623 Writes the current value of 64-bit MMX Register #1 (MM1).
6625 Writes the current value of MM1. This function is only available on IA32 and
6628 @param Value The 64-bit value to write to MM1.
6639 Writes the current value of 64-bit MMX Register #2 (MM2).
6641 Writes the current value of MM2. This function is only available on IA32 and
6644 @param Value The 64-bit value to write to MM2.
6655 Writes the current value of 64-bit MMX Register #3 (MM3).
6657 Writes the current value of MM3. This function is only available on IA32 and
6660 @param Value The 64-bit value to write to MM3.
6671 Writes the current value of 64-bit MMX Register #4 (MM4).
6673 Writes the current value of MM4. This function is only available on IA32 and
6676 @param Value The 64-bit value to write to MM4.
6687 Writes the current value of 64-bit MMX Register #5 (MM5).
6689 Writes the current value of MM5. This function is only available on IA32 and
6692 @param Value The 64-bit value to write to MM5.
6703 Writes the current value of 64-bit MMX Register #6 (MM6).
6705 Writes the current value of MM6. This function is only available on IA32 and
6708 @param Value The 64-bit value to write to MM6.
6719 Writes the current value of 64-bit MMX Register #7 (MM7).
6721 Writes the current value of MM7. This function is only available on IA32 and
6724 @param Value The 64-bit value to write to MM7.
6735 Reads the current value of Time Stamp Counter (TSC).
6737 Reads and returns the current value of TSC. This function is only available
6740 @return The current value of TSC
6751 Reads the current value of a Performance Counter (PMC).
6753 Reads and returns the current value of performance counter specified by
6754 Index. This function is only available on IA-32 and X64.
6756 @param Index The 32-bit Performance Counter index to read.
6758 @return The value of the PMC specified by Index.
6769 Sets up a monitor buffer that is used by AsmMwait().
6771 Executes a MONITOR instruction with the register state specified by Eax, Ecx
6772 and Edx. Returns Eax. This function is only available on IA-32 and X64.
6774 @param Eax The value to load into EAX or RAX before executing the MONITOR
6776 @param Ecx The value to load into ECX or RCX before executing the MONITOR
6778 @param Edx The value to load into EDX or RDX before executing the MONITOR
6794 Executes an MWAIT instruction.
6796 Executes an MWAIT instruction with the register state specified by Eax and
6797 Ecx. Returns Eax. This function is only available on IA-32 and X64.
6799 @param Eax The value to load into EAX or RAX before executing the MONITOR
6801 @param Ecx The value to load into ECX or RCX before executing the MONITOR
6816 Executes a WBINVD instruction.
6818 Executes a WBINVD instruction. This function is only available on IA-32 and
6830 Executes a INVD instruction.
6832 Executes a INVD instruction. This function is only available on IA-32 and
6844 Flushes a cache line from all the instruction and data caches within the
6845 coherency domain of the CPU.
6847 Flushed the cache line specified by LinearAddress, and returns LinearAddress.
6848 This function is only available on IA-32 and X64.
6850 @param LinearAddress The address of the cache line to flush. If the CPU is
6851 in a physical addressing mode, then LinearAddress is a
6852 physical address. If the CPU is in a virtual
6853 addressing mode, then LinearAddress is a virtual
6856 @return LinearAddress
6861 IN VOID
*LinearAddress
6866 Enables the 32-bit paging mode on the CPU.
6868 Enables the 32-bit paging mode on the CPU. CR0, CR3, CR4, and the page tables
6869 must be properly initialized prior to calling this service. This function
6870 assumes the current execution mode is 32-bit protected mode. This function is
6871 only available on IA-32. After the 32-bit paging mode is enabled, control is
6872 transferred to the function specified by EntryPoint using the new stack
6873 specified by NewStack and passing in the parameters specified by Context1 and
6874 Context2. Context1 and Context2 are optional and may be NULL. The function
6875 EntryPoint must never return.
6877 If the current execution mode is not 32-bit protected mode, then ASSERT().
6878 If EntryPoint is NULL, then ASSERT().
6879 If NewStack is NULL, then ASSERT().
6881 There are a number of constraints that must be followed before calling this
6883 1) Interrupts must be disabled.
6884 2) The caller must be in 32-bit protected mode with flat descriptors. This
6885 means all descriptors must have a base of 0 and a limit of 4GB.
6886 3) CR0 and CR4 must be compatible with 32-bit protected mode with flat
6888 4) CR3 must point to valid page tables that will be used once the transition
6889 is complete, and those page tables must guarantee that the pages for this
6890 function and the stack are identity mapped.
6892 @param EntryPoint A pointer to function to call with the new stack after
6894 @param Context1 A pointer to the context to pass into the EntryPoint
6895 function as the first parameter after paging is enabled.
6896 @param Context2 A pointer to the context to pass into the EntryPoint
6897 function as the second parameter after paging is enabled.
6898 @param NewStack A pointer to the new stack to use for the EntryPoint
6899 function after paging is enabled.
6905 IN SWITCH_STACK_ENTRY_POINT EntryPoint
,
6906 IN VOID
*Context1
, OPTIONAL
6907 IN VOID
*Context2
, OPTIONAL
6913 Disables the 32-bit paging mode on the CPU.
6915 Disables the 32-bit paging mode on the CPU and returns to 32-bit protected
6916 mode. This function assumes the current execution mode is 32-paged protected
6917 mode. This function is only available on IA-32. After the 32-bit paging mode
6918 is disabled, control is transferred to the function specified by EntryPoint
6919 using the new stack specified by NewStack and passing in the parameters
6920 specified by Context1 and Context2. Context1 and Context2 are optional and
6921 may be NULL. The function EntryPoint must never return.
6923 If the current execution mode is not 32-bit paged mode, then ASSERT().
6924 If EntryPoint is NULL, then ASSERT().
6925 If NewStack is NULL, then ASSERT().
6927 There are a number of constraints that must be followed before calling this
6929 1) Interrupts must be disabled.
6930 2) The caller must be in 32-bit paged mode.
6931 3) CR0, CR3, and CR4 must be compatible with 32-bit paged mode.
6932 4) CR3 must point to valid page tables that guarantee that the pages for
6933 this function and the stack are identity mapped.
6935 @param EntryPoint A pointer to function to call with the new stack after
6937 @param Context1 A pointer to the context to pass into the EntryPoint
6938 function as the first parameter after paging is disabled.
6939 @param Context2 A pointer to the context to pass into the EntryPoint
6940 function as the second parameter after paging is
6942 @param NewStack A pointer to the new stack to use for the EntryPoint
6943 function after paging is disabled.
6948 AsmDisablePaging32 (
6949 IN SWITCH_STACK_ENTRY_POINT EntryPoint
,
6950 IN VOID
*Context1
, OPTIONAL
6951 IN VOID
*Context2
, OPTIONAL
6957 Enables the 64-bit paging mode on the CPU.
6959 Enables the 64-bit paging mode on the CPU. CR0, CR3, CR4, and the page tables
6960 must be properly initialized prior to calling this service. This function
6961 assumes the current execution mode is 32-bit protected mode with flat
6962 descriptors. This function is only available on IA-32. After the 64-bit
6963 paging mode is enabled, control is transferred to the function specified by
6964 EntryPoint using the new stack specified by NewStack and passing in the
6965 parameters specified by Context1 and Context2. Context1 and Context2 are
6966 optional and may be 0. The function EntryPoint must never return.
6968 If the current execution mode is not 32-bit protected mode with flat
6969 descriptors, then ASSERT().
6970 If EntryPoint is 0, then ASSERT().
6971 If NewStack is 0, then ASSERT().
6973 @param Cs The 16-bit selector to load in the CS before EntryPoint
6974 is called. The descriptor in the GDT that this selector
6975 references must be setup for long mode.
6976 @param EntryPoint The 64-bit virtual address of the function to call with
6977 the new stack after paging is enabled.
6978 @param Context1 The 64-bit virtual address of the context to pass into
6979 the EntryPoint function as the first parameter after
6981 @param Context2 The 64-bit virtual address of the context to pass into
6982 the EntryPoint function as the second parameter after
6984 @param NewStack The 64-bit virtual address of the new stack to use for
6985 the EntryPoint function after paging is enabled.
6991 IN UINT16 CodeSelector
,
6992 IN UINT64 EntryPoint
,
6993 IN UINT64 Context1
, OPTIONAL
6994 IN UINT64 Context2
, OPTIONAL
7000 Disables the 64-bit paging mode on the CPU.
7002 Disables the 64-bit paging mode on the CPU and returns to 32-bit protected
7003 mode. This function assumes the current execution mode is 64-paging mode.
7004 This function is only available on X64. After the 64-bit paging mode is
7005 disabled, control is transferred to the function specified by EntryPoint
7006 using the new stack specified by NewStack and passing in the parameters
7007 specified by Context1 and Context2. Context1 and Context2 are optional and
7008 may be 0. The function EntryPoint must never return.
7010 If the current execution mode is not 64-bit paged mode, then ASSERT().
7011 If EntryPoint is 0, then ASSERT().
7012 If NewStack is 0, then ASSERT().
7014 @param Cs The 16-bit selector to load in the CS before EntryPoint
7015 is called. The descriptor in the GDT that this selector
7016 references must be setup for 32-bit protected mode.
7017 @param EntryPoint The 64-bit virtual address of the function to call with
7018 the new stack after paging is disabled.
7019 @param Context1 The 64-bit virtual address of the context to pass into
7020 the EntryPoint function as the first parameter after
7022 @param Context2 The 64-bit virtual address of the context to pass into
7023 the EntryPoint function as the second parameter after
7025 @param NewStack The 64-bit virtual address of the new stack to use for
7026 the EntryPoint function after paging is disabled.
7031 AsmDisablePaging64 (
7032 IN UINT16 CodeSelector
,
7033 IN UINT32 EntryPoint
,
7034 IN UINT32 Context1
, OPTIONAL
7035 IN UINT32 Context2
, OPTIONAL
7041 // 16-bit thunking services
7045 Retrieves the properties for 16-bit thunk functions.
7047 Computes the size of the buffer and stack below 1MB required to use the
7048 AsmPrepareThunk16(), AsmThunk16() and AsmPrepareAndThunk16() functions. This
7049 buffer size is returned in RealModeBufferSize, and the stack size is returned
7050 in ExtraStackSize. If parameters are passed to the 16-bit real mode code,
7051 then the actual minimum stack size is ExtraStackSize plus the maximum number
7052 of bytes that need to be passed to the 16-bit real mode code.
7054 If RealModeBufferSize is NULL, then ASSERT().
7055 If ExtraStackSize is NULL, then ASSERT().
7057 @param RealModeBufferSize A pointer to the size of the buffer below 1MB
7058 required to use the 16-bit thunk functions.
7059 @param ExtraStackSize A pointer to the extra size of stack below 1MB
7060 that the 16-bit thunk functions require for
7061 temporary storage in the transition to and from
7067 AsmGetThunk16Properties (
7068 OUT UINT32
*RealModeBufferSize
,
7069 OUT UINT32
*ExtraStackSize
7074 Prepares all structures a code required to use AsmThunk16().
7076 Prepares all structures and code required to use AsmThunk16().
7078 If ThunkContext is NULL, then ASSERT().
7080 @param ThunkContext A pointer to the context structure that describes the
7081 16-bit real mode code to call.
7087 OUT THUNK_CONTEXT
*ThunkContext
7092 Transfers control to a 16-bit real mode entry point and returns the results.
7094 Transfers control to a 16-bit real mode entry point and returns the results.
7095 AsmPrepareThunk16() must be called with ThunkContext before this function is
7098 If ThunkContext is NULL, then ASSERT().
7099 If AsmPrepareThunk16() was not previously called with ThunkContext, then ASSERT().
7101 @param ThunkContext A pointer to the context structure that describes the
7102 16-bit real mode code to call.
7108 IN OUT THUNK_CONTEXT
*ThunkContext
7113 Prepares all structures and code for a 16-bit real mode thunk, transfers
7114 control to a 16-bit real mode entry point, and returns the results.
7116 Prepares all structures and code for a 16-bit real mode thunk, transfers
7117 control to a 16-bit real mode entry point, and returns the results. If the
7118 caller only need to perform a single 16-bit real mode thunk, then this
7119 service should be used. If the caller intends to make more than one 16-bit
7120 real mode thunk, then it is more efficient if AsmPrepareThunk16() is called
7121 once and AsmThunk16() can be called for each 16-bit real mode thunk.
7123 If ThunkContext is NULL, then ASSERT().
7125 @param ThunkContext A pointer to the context structure that describes the
7126 16-bit real mode code to call.
7131 AsmPrepareAndThunk16 (
7132 IN OUT THUNK_CONTEXT
*ThunkContext