2 Memory-only library functions with no library constructor/destructor
4 Copyright (c) 2006 - 2007, Intel Corporation
5 All rights reserved. This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
13 Module Name: BaseLib.h
21 // Definitions for architecture specific types
22 // These include SPIN_LOCK and BASE_LIBRARY_JUMP_BUFFER
28 typedef UINTN SPIN_LOCK
;
30 #if defined (MDE_CPU_IA32)
32 // IA32 context buffer used by SetJump() and LongJump()
41 } BASE_LIBRARY_JUMP_BUFFER
;
43 #define BASE_LIBRARY_JUMP_BUFFER_ALIGNMENT 8
45 #elif defined (MDE_CPU_IPF)
47 // IPF context buffer used by SetJump() and LongJump()
82 UINT64 AfterSpillUNAT
;
88 } BASE_LIBRARY_JUMP_BUFFER
;
90 #define BASE_LIBRARY_JUMP_BUFFER_ALIGNMENT 0x10
92 #elif defined (MDE_CPU_X64)
94 // X64 context buffer used by SetJump() and LongJump()
107 } BASE_LIBRARY_JUMP_BUFFER
;
109 #define BASE_LIBRARY_JUMP_BUFFER_ALIGNMENT 8
111 #elif defined (MDE_CPU_EBC)
113 // EBC context buffer used by SetJump() and LongJump()
121 } BASE_LIBRARY_JUMP_BUFFER
;
123 #define BASE_LIBRARY_JUMP_BUFFER_ALIGNMENT 8
126 #error Unknown Processor Type
134 Copies one Null-terminated Unicode string to another Null-terminated Unicode
135 string and returns the new Unicode string.
137 This function copies the contents of the Unicode string Source to the Unicode
138 string Destination, and returns Destination. If Source and Destination
139 overlap, then the results are undefined.
141 If Destination is NULL, then ASSERT().
142 If Source is NULL, then ASSERT().
143 If Source and Destination overlap, then ASSERT().
144 If PcdMaximumUnicodeStringLength is not zero, and Source contains more than
145 PcdMaximumUnicodeStringLength Unicode characters not including the
146 Null-terminator, then ASSERT().
148 @param Destination Pointer to a Null-terminated Unicode string.
149 @param Source Pointer to a Null-terminated Unicode string.
157 OUT CHAR16
*Destination
,
158 IN CONST CHAR16
*Source
161 Copies one Null-terminated Unicode string with a maximum length to another
162 Null-terminated Unicode string with a maximum length and returns the new
165 This function copies the contents of the Unicode string Source to the Unicode
166 string Destination, and returns Destination. At most, Length Unicode
167 characters are copied from Source to Destination. If Length is 0, then
168 Destination is returned unmodified. If Length is greater that the number of
169 Unicode characters in Source, then Destination is padded with Null Unicode
170 characters. If Source and Destination overlap, then the results are
173 If Destination is NULL, then ASSERT().
174 If Source is NULL, then ASSERT().
175 If Source and Destination overlap, then ASSERT().
176 If PcdMaximumUnicodeStringLength is not zero, and Source contains more than
177 PcdMaximumUnicodeStringLength Unicode characters not including the
178 Null-terminator, then ASSERT().
180 @param Destination Pointer to a Null-terminated Unicode string.
181 @param Source Pointer to a Null-terminated Unicode string.
182 @param Length Maximum number of Unicode characters to copy.
190 OUT CHAR16
*Destination
,
191 IN CONST CHAR16
*Source
,
195 Returns the length of a Null-terminated Unicode string.
197 This function returns the number of Unicode characters in the Null-terminated
198 Unicode string specified by String.
200 If String is NULL, then ASSERT().
201 If PcdMaximumUnicodeStringLength is not zero, and String contains more than
202 PcdMaximumUnicodeStringLength Unicode characters not including the
203 Null-terminator, then ASSERT().
205 @param String Pointer to a Null-terminated Unicode string.
207 @return The length of String.
213 IN CONST CHAR16
*String
216 Returns the size of a Null-terminated Unicode string in bytes, including the
219 This function returns the size, in bytes, of the Null-terminated Unicode
220 string specified by String.
222 If String is NULL, then ASSERT().
223 If PcdMaximumUnicodeStringLength is not zero, and String contains more than
224 PcdMaximumUnicodeStringLength Unicode characters not including the
225 Null-terminator, then ASSERT().
227 @param String Pointer to a Null-terminated Unicode string.
229 @return The size of String.
235 IN CONST CHAR16
*String
238 Compares two Null-terminated Unicode strings, and returns the difference
239 between the first mismatched Unicode characters.
241 This function compares the Null-terminated Unicode string FirstString to the
242 Null-terminated Unicode string SecondString. If FirstString is identical to
243 SecondString, then 0 is returned. Otherwise, the value returned is the first
244 mismatched Unicode character in SecondString subtracted from the first
245 mismatched Unicode character in FirstString.
247 If FirstString is NULL, then ASSERT().
248 If SecondString is NULL, then ASSERT().
249 If PcdMaximumUnicodeStringLength is not zero, and FirstString contains more
250 than PcdMaximumUnicodeStringLength Unicode characters not including the
251 Null-terminator, then ASSERT().
252 If PcdMaximumUnicodeStringLength is not zero, and SecondString contains more
253 than PcdMaximumUnicodeStringLength Unicode characters not including the
254 Null-terminator, then ASSERT().
256 @param FirstString Pointer to a Null-terminated Unicode string.
257 @param SecondString Pointer to a Null-terminated Unicode string.
259 @retval 0 FirstString is identical to SecondString.
260 @retval !=0 FirstString is not identical to SecondString.
266 IN CONST CHAR16
*FirstString
,
267 IN CONST CHAR16
*SecondString
270 Compares two Null-terminated Unicode strings with maximum lengths, and
271 returns the difference between the first mismatched Unicode characters.
273 This function compares the Null-terminated Unicode string FirstString to the
274 Null-terminated Unicode string SecondString. At most, Length Unicode
275 characters will be compared. If Length is 0, then 0 is returned. If
276 FirstString is identical to SecondString, then 0 is returned. Otherwise, the
277 value returned is the first mismatched Unicode character in SecondString
278 subtracted from the first mismatched Unicode character in FirstString.
280 If FirstString is NULL, then ASSERT().
281 If SecondString is NULL, then ASSERT().
282 If PcdMaximumUnicodeStringLength is not zero, and FirstString contains more
283 than PcdMaximumUnicodeStringLength Unicode characters not including the
284 Null-terminator, then ASSERT().
285 If PcdMaximumUnicodeStringLength is not zero, and SecondString contains more
286 than PcdMaximumUnicodeStringLength Unicode characters not including the
287 Null-terminator, then ASSERT().
289 @param FirstString Pointer to a Null-terminated Unicode string.
290 @param SecondString Pointer to a Null-terminated Unicode string.
291 @param Length Maximum number of Unicode characters to compare.
293 @retval 0 FirstString is identical to SecondString.
294 @retval !=0 FirstString is not identical to SecondString.
300 IN CONST CHAR16
*FirstString
,
301 IN CONST CHAR16
*SecondString
,
305 Concatenates one Null-terminated Unicode string to another Null-terminated
306 Unicode string, and returns the concatenated Unicode string.
308 This function concatenates two Null-terminated Unicode strings. The contents
309 of Null-terminated Unicode string Source are concatenated to the end of
310 Null-terminated Unicode string Destination. The Null-terminated concatenated
311 Unicode String is returned. If Source and Destination overlap, then the
312 results are undefined.
314 If Destination is NULL, then ASSERT().
315 If Source is NULL, then ASSERT().
316 If Source and Destination overlap, then ASSERT().
317 If PcdMaximumUnicodeStringLength is not zero, and Destination contains more
318 than PcdMaximumUnicodeStringLength Unicode characters not including the
319 Null-terminator, then ASSERT().
320 If PcdMaximumUnicodeStringLength is not zero, and Source contains more than
321 PcdMaximumUnicodeStringLength Unicode characters not including the
322 Null-terminator, then ASSERT().
323 If PcdMaximumUnicodeStringLength is not zero, and concatenating Destination
324 and Source results in a Unicode string with more than
325 PcdMaximumUnicodeStringLength Unicode characters not including the
326 Null-terminator, then ASSERT().
328 @param Destination Pointer to a Null-terminated Unicode string.
329 @param Source Pointer to a Null-terminated Unicode string.
337 IN OUT CHAR16
*Destination
,
338 IN CONST CHAR16
*Source
341 Concatenates one Null-terminated Unicode string with a maximum length to the
342 end of another Null-terminated Unicode string, and returns the concatenated
345 This function concatenates two Null-terminated Unicode strings. The contents
346 of Null-terminated Unicode string Source are concatenated to the end of
347 Null-terminated Unicode string Destination, and Destination is returned. At
348 most, Length Unicode characters are concatenated from Source to the end of
349 Destination, and Destination is always Null-terminated. If Length is 0, then
350 Destination is returned unmodified. If Source and Destination overlap, then
351 the results are undefined.
353 If Destination is NULL, then ASSERT().
354 If Source is NULL, then ASSERT().
355 If Source and Destination overlap, then ASSERT().
356 If PcdMaximumUnicodeStringLength is not zero, and Destination contains more
357 than PcdMaximumUnicodeStringLength Unicode characters not including the
358 Null-terminator, then ASSERT().
359 If PcdMaximumUnicodeStringLength is not zero, and Source contains more than
360 PcdMaximumUnicodeStringLength Unicode characters not including the
361 Null-terminator, then ASSERT().
362 If PcdMaximumUnicodeStringLength is not zero, and concatenating Destination
363 and Source results in a Unicode string with more than
364 PcdMaximumUnicodeStringLength Unicode characters not including the
365 Null-terminator, then ASSERT().
367 @param Destination Pointer to a Null-terminated Unicode string.
368 @param Source Pointer to a Null-terminated Unicode string.
369 @param Length Maximum number of Unicode characters to concatenate from
378 IN OUT CHAR16
*Destination
,
379 IN CONST CHAR16
*Source
,
384 Returns the first occurance of a Null-terminated Unicode sub-string
385 in a Null-terminated Unicode string.
387 This function scans the contents of the Null-terminated Unicode string
388 specified by String and returns the first occurrence of SearchString.
389 If SearchString is not found in String, then NULL is returned. If
390 the length of SearchString is zero, then String is
393 If String is NULL, then ASSERT().
394 If String is not aligned on a 16-bit boundary, then ASSERT().
395 If SearchString is NULL, then ASSERT().
396 If SearchString is not aligned on a 16-bit boundary, then ASSERT().
398 If PcdMaximumUnicodeStringLength is not zero, and SearchString
399 or String contains more than PcdMaximumUnicodeStringLength Unicode
400 characters not including the Null-terminator, then ASSERT().
402 @param String Pointer to a Null-terminated Unicode string.
403 @param SearchString Pointer to a Null-terminated Unicode string to search for.
405 @retval NULL If the SearchString does not appear in String.
406 @retval !NULL If there is a match.
412 IN CONST CHAR16
*String
,
413 IN CONST CHAR16
*SearchString
417 Convert a Null-terminated Unicode decimal string to a value of
420 This function returns a value of type UINTN by interpreting the contents
421 of the Unicode string specified by String as a decimal number. The format
422 of the input Unicode string String is:
424 [spaces] [decimal digits].
426 The valid decimal digit character is in the range [0-9]. The
427 function will ignore the pad space, which includes spaces or
428 tab characters, before [decimal digits]. The running zero in the
429 beginning of [decimal digits] will be ignored. Then, the function
430 stops at the first character that is a not a valid decimal character
431 or a Null-terminator, whichever one comes first.
433 If String is NULL, then ASSERT().
434 If String is not aligned in a 16-bit boundary, then ASSERT().
435 If String has only pad spaces, then 0 is returned.
436 If String has no pad spaces or valid decimal digits,
438 If the number represented by String overflows according
439 to the range defined by UINTN, then ASSERT().
441 If PcdMaximumUnicodeStringLength is not zero, and String contains
442 more than PcdMaximumUnicodeStringLength Unicode characters not including
443 the Null-terminator, then ASSERT().
445 @param String Pointer to a Null-terminated Unicode string.
453 IN CONST CHAR16
*String
457 Convert a Null-terminated Unicode decimal string to a value of
460 This function returns a value of type UINT64 by interpreting the contents
461 of the Unicode string specified by String as a decimal number. The format
462 of the input Unicode string String is:
464 [spaces] [decimal digits].
466 The valid decimal digit character is in the range [0-9]. The
467 function will ignore the pad space, which includes spaces or
468 tab characters, before [decimal digits]. The running zero in the
469 beginning of [decimal digits] will be ignored. Then, the function
470 stops at the first character that is a not a valid decimal character
471 or a Null-terminator, whichever one comes first.
473 If String is NULL, then ASSERT().
474 If String is not aligned in a 16-bit boundary, then ASSERT().
475 If String has only pad spaces, then 0 is returned.
476 If String has no pad spaces or valid decimal digits,
478 If the number represented by String overflows according
479 to the range defined by UINT64, then ASSERT().
481 If PcdMaximumUnicodeStringLength is not zero, and String contains
482 more than PcdMaximumUnicodeStringLength Unicode characters not including
483 the Null-terminator, then ASSERT().
485 @param String Pointer to a Null-terminated Unicode string.
493 IN CONST CHAR16
*String
497 Convert a Null-terminated Unicode hexadecimal string to a value of type UINTN.
499 This function returns a value of type UINTN by interpreting the contents
500 of the Unicode string specified by String as a hexadecimal number.
501 The format of the input Unicode string String is:
503 [spaces][zeros][x][hexadecimal digits].
505 The valid hexadecimal digit character is in the range [0-9], [a-f] and [A-F].
506 The prefix "0x" is optional. Both "x" and "X" is allowed in "0x" prefix.
507 If "x" appears in the input string, it must be prefixed with at least one 0.
508 The function will ignore the pad space, which includes spaces or tab characters,
509 before [zeros], [x] or [hexadecimal digit]. The running zero before [x] or
510 [hexadecimal digit] will be ignored. Then, the decoding starts after [x] or the
511 first valid hexadecimal digit. Then, the function stops at the first character that is
512 a not a valid hexadecimal character or NULL, whichever one comes first.
514 If String is NULL, then ASSERT().
515 If String is not aligned in a 16-bit boundary, then ASSERT().
516 If String has only pad spaces, then zero is returned.
517 If String has no leading pad spaces, leading zeros or valid hexadecimal digits,
518 then zero is returned.
519 If the number represented by String overflows according to the range defined by
520 UINTN, then ASSERT().
522 If PcdMaximumUnicodeStringLength is not zero, and String contains more than
523 PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator,
526 @param String Pointer to a Null-terminated Unicode string.
534 IN CONST CHAR16
*String
538 Convert a Null-terminated Unicode hexadecimal string to a value of type UINT64.
540 This function returns a value of type UINT64 by interpreting the contents
541 of the Unicode string specified by String as a hexadecimal number.
542 The format of the input Unicode string String is
544 [spaces][zeros][x][hexadecimal digits].
546 The valid hexadecimal digit character is in the range [0-9], [a-f] and [A-F].
547 The prefix "0x" is optional. Both "x" and "X" is allowed in "0x" prefix.
548 If "x" appears in the input string, it must be prefixed with at least one 0.
549 The function will ignore the pad space, which includes spaces or tab characters,
550 before [zeros], [x] or [hexadecimal digit]. The running zero before [x] or
551 [hexadecimal digit] will be ignored. Then, the decoding starts after [x] or the
552 first valid hexadecimal digit. Then, the function stops at the first character that is
553 a not a valid hexadecimal character or NULL, whichever one comes first.
555 If String is NULL, then ASSERT().
556 If String is not aligned in a 16-bit boundary, then ASSERT().
557 If String has only pad spaces, then zero is returned.
558 If String has no leading pad spaces, leading zeros or valid hexadecimal digits,
559 then zero is returned.
560 If the number represented by String overflows according to the range defined by
561 UINT64, then ASSERT().
563 If PcdMaximumUnicodeStringLength is not zero, and String contains more than
564 PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator,
567 @param String Pointer to a Null-terminated Unicode string.
575 IN CONST CHAR16
*String
579 Convert one Null-terminated Unicode string to a Null-terminated
580 ASCII string and returns the ASCII string.
582 This function converts the content of the Unicode string Source
583 to the ASCII string Destination by copying the lower 8 bits of
584 each Unicode character. It returns Destination.
586 If any Unicode characters in Source contain non-zero value in
587 the upper 8 bits, then ASSERT().
589 If Destination is NULL, then ASSERT().
590 If Source is NULL, then ASSERT().
591 If Source and Destination overlap, then ASSERT().
593 If PcdMaximumUnicodeStringLength is not zero, and Source contains
594 more than PcdMaximumUnicodeStringLength Unicode characters not including
595 the Null-terminator, then ASSERT().
597 If PcdMaximumAsciiStringLength is not zero, and Source contains more
598 than PcdMaximumAsciiStringLength Unicode characters not including the
599 Null-terminator, then ASSERT().
601 @param Source Pointer to a Null-terminated Unicode string.
602 @param Destination Pointer to a Null-terminated ASCII string.
609 UnicodeStrToAsciiStr (
610 IN CONST CHAR16
*Source
,
611 OUT CHAR8
*Destination
615 Copies one Null-terminated ASCII string to another Null-terminated ASCII
616 string and returns the new ASCII string.
618 This function copies the contents of the ASCII string Source to the ASCII
619 string Destination, and returns Destination. If Source and Destination
620 overlap, then the results are undefined.
622 If Destination is NULL, then ASSERT().
623 If Source is NULL, then ASSERT().
624 If Source and Destination overlap, then ASSERT().
625 If PcdMaximumAsciiStringLength is not zero and Source contains more than
626 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
629 @param Destination Pointer to a Null-terminated ASCII string.
630 @param Source Pointer to a Null-terminated ASCII string.
638 OUT CHAR8
*Destination
,
639 IN CONST CHAR8
*Source
642 Copies one Null-terminated ASCII string with a maximum length to another
643 Null-terminated ASCII string with a maximum length and returns the new ASCII
646 This function copies the contents of the ASCII string Source to the ASCII
647 string Destination, and returns Destination. At most, Length ASCII characters
648 are copied from Source to Destination. If Length is 0, then Destination is
649 returned unmodified. If Length is greater that the number of ASCII characters
650 in Source, then Destination is padded with Null ASCII characters. If Source
651 and Destination overlap, then the results are undefined.
653 If Destination is NULL, then ASSERT().
654 If Source is NULL, then ASSERT().
655 If Source and Destination overlap, then ASSERT().
656 If PcdMaximumAsciiStringLength is not zero, and Source contains more than
657 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
660 @param Destination Pointer to a Null-terminated ASCII string.
661 @param Source Pointer to a Null-terminated ASCII string.
662 @param Length Maximum number of ASCII characters to copy.
670 OUT CHAR8
*Destination
,
671 IN CONST CHAR8
*Source
,
675 Returns the length of a Null-terminated ASCII string.
677 This function returns the number of ASCII characters in the Null-terminated
678 ASCII string specified by String.
680 If String is NULL, then ASSERT().
681 If PcdMaximumAsciiStringLength is not zero and String contains more than
682 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
685 @param String Pointer to a Null-terminated ASCII string.
687 @return The length of String.
693 IN CONST CHAR8
*String
696 Returns the size of a Null-terminated ASCII string in bytes, including the
699 This function returns the size, in bytes, of the Null-terminated ASCII string
702 If String is NULL, then ASSERT().
703 If PcdMaximumAsciiStringLength is not zero and String contains more than
704 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
707 @param String Pointer to a Null-terminated ASCII string.
709 @return The size of String.
715 IN CONST CHAR8
*String
718 Compares two Null-terminated ASCII strings, and returns the difference
719 between the first mismatched ASCII characters.
721 This function compares the Null-terminated ASCII string FirstString to the
722 Null-terminated ASCII string SecondString. If FirstString is identical to
723 SecondString, then 0 is returned. Otherwise, the value returned is the first
724 mismatched ASCII character in SecondString subtracted from the first
725 mismatched ASCII character in FirstString.
727 If FirstString is NULL, then ASSERT().
728 If SecondString is NULL, then ASSERT().
729 If PcdMaximumAsciiStringLength is not zero and FirstString contains more than
730 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
732 If PcdMaximumAsciiStringLength is not zero and SecondString contains more
733 than PcdMaximumAsciiStringLength ASCII characters not including the
734 Null-terminator, then ASSERT().
736 @param FirstString Pointer to a Null-terminated ASCII string.
737 @param SecondString Pointer to a Null-terminated ASCII string.
739 @retval 0 FirstString is identical to SecondString.
740 @retval !=0 FirstString is not identical to SecondString.
746 IN CONST CHAR8
*FirstString
,
747 IN CONST CHAR8
*SecondString
750 Performs a case insensitive comparison of two Null-terminated ASCII strings,
751 and returns the difference between the first mismatched ASCII characters.
753 This function performs a case insensitive comparison of the Null-terminated
754 ASCII string FirstString to the Null-terminated ASCII string SecondString. If
755 FirstString is identical to SecondString, then 0 is returned. Otherwise, the
756 value returned is the first mismatched lower case ASCII character in
757 SecondString subtracted from the first mismatched lower case ASCII character
760 If FirstString is NULL, then ASSERT().
761 If SecondString is NULL, then ASSERT().
762 If PcdMaximumAsciiStringLength is not zero and FirstString contains more than
763 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
765 If PcdMaximumAsciiStringLength is not zero and SecondString contains more
766 than PcdMaximumAsciiStringLength ASCII characters not including the
767 Null-terminator, then ASSERT().
769 @param FirstString Pointer to a Null-terminated ASCII string.
770 @param SecondString Pointer to a Null-terminated ASCII string.
772 @retval 0 FirstString is identical to SecondString using case insensitive
774 @retval !=0 FirstString is not identical to SecondString using case
775 insensitive comparisons.
781 IN CONST CHAR8
*FirstString
,
782 IN CONST CHAR8
*SecondString
785 Compares two Null-terminated ASCII strings with maximum lengths, and returns
786 the difference between the first mismatched ASCII characters.
788 This function compares the Null-terminated ASCII string FirstString to the
789 Null-terminated ASCII string SecondString. At most, Length ASCII characters
790 will be compared. If Length is 0, then 0 is returned. If FirstString is
791 identical to SecondString, then 0 is returned. Otherwise, the value returned
792 is the first mismatched ASCII character in SecondString subtracted from the
793 first mismatched ASCII character in FirstString.
795 If FirstString is NULL, then ASSERT().
796 If SecondString is NULL, then ASSERT().
797 If PcdMaximumAsciiStringLength is not zero and FirstString contains more than
798 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
800 If PcdMaximumAsciiStringLength is not zero and SecondString contains more than
801 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
804 @param FirstString Pointer to a Null-terminated ASCII string.
805 @param SecondString Pointer to a Null-terminated ASCII string.
807 @retval 0 FirstString is identical to SecondString.
808 @retval !=0 FirstString is not identical to SecondString.
814 IN CONST CHAR8
*FirstString
,
815 IN CONST CHAR8
*SecondString
,
819 Concatenates one Null-terminated ASCII string to another Null-terminated
820 ASCII string, and returns the concatenated ASCII string.
822 This function concatenates two Null-terminated ASCII strings. The contents of
823 Null-terminated ASCII string Source are concatenated to the end of Null-
824 terminated ASCII string Destination. The Null-terminated concatenated ASCII
827 If Destination is NULL, then ASSERT().
828 If Source is NULL, then ASSERT().
829 If PcdMaximumAsciiStringLength is not zero and Destination contains more than
830 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
832 If PcdMaximumAsciiStringLength is not zero and Source contains more than
833 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
835 If PcdMaximumAsciiStringLength is not zero and concatenating Destination and
836 Source results in a ASCII string with more than PcdMaximumAsciiStringLength
837 ASCII characters, then ASSERT().
839 @param Destination Pointer to a Null-terminated ASCII string.
840 @param Source Pointer to a Null-terminated ASCII string.
848 IN OUT CHAR8
*Destination
,
849 IN CONST CHAR8
*Source
852 Concatenates one Null-terminated ASCII string with a maximum length to the
853 end of another Null-terminated ASCII string, and returns the concatenated
856 This function concatenates two Null-terminated ASCII strings. The contents
857 of Null-terminated ASCII string Source are concatenated to the end of Null-
858 terminated ASCII string Destination, and Destination is returned. At most,
859 Length ASCII characters are concatenated from Source to the end of
860 Destination, and Destination is always Null-terminated. If Length is 0, then
861 Destination is returned unmodified. If Source and Destination overlap, then
862 the results are undefined.
864 If Destination is NULL, then ASSERT().
865 If Source is NULL, then ASSERT().
866 If Source and Destination overlap, then ASSERT().
867 If PcdMaximumAsciiStringLength is not zero, and Destination contains more than
868 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
870 If PcdMaximumAsciiStringLength is not zero, and Source contains more than
871 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
873 If PcdMaximumAsciiStringLength is not zero, and concatenating Destination and
874 Source results in a ASCII string with more than PcdMaximumAsciiStringLength
875 ASCII characters not including the Null-terminator, then ASSERT().
877 @param Destination Pointer to a Null-terminated ASCII string.
878 @param Source Pointer to a Null-terminated ASCII string.
879 @param Length Maximum number of ASCII characters to concatenate from
888 IN OUT CHAR8
*Destination
,
889 IN CONST CHAR8
*Source
,
894 Returns the first occurance of a Null-terminated ASCII sub-string
895 in a Null-terminated ASCII string.
897 This function scans the contents of the ASCII string specified by String
898 and returns the first occurrence of SearchString. If SearchString is not
899 found in String, then NULL is returned. If the length of SearchString is zero,
900 then String is returned.
902 If String is NULL, then ASSERT().
903 If SearchString is NULL, then ASSERT().
905 If PcdMaximumAsciiStringLength is not zero, and SearchString or
906 String contains more than PcdMaximumAsciiStringLength Unicode characters
907 not including the Null-terminator, then ASSERT().
909 @param String Pointer to a Null-terminated ASCII string.
910 @param SearchString Pointer to a Null-terminated ASCII string to search for.
912 @retval NULL If the SearchString does not appear in String.
913 @retval !NULL If there is a match.
919 IN CONST CHAR8
*String
,
920 IN CONST CHAR8
*SearchString
924 Convert a Null-terminated ASCII decimal string to a value of type
927 This function returns a value of type UINTN by interpreting the contents
928 of the ASCII string String as a decimal number. The format of the input
929 ASCII string String is:
931 [spaces] [decimal digits].
933 The valid decimal digit character is in the range [0-9]. The function will
934 ignore the pad space, which includes spaces or tab characters, before the digits.
935 The running zero in the beginning of [decimal digits] will be ignored. Then, the
936 function stops at the first character that is a not a valid decimal character or
937 Null-terminator, whichever on comes first.
939 If String has only pad spaces, then 0 is returned.
940 If String has no pad spaces or valid decimal digits, then 0 is returned.
941 If the number represented by String overflows according to the range defined by
942 UINTN, then ASSERT().
943 If String is NULL, then ASSERT().
944 If PcdMaximumAsciiStringLength is not zero, and String contains more than
945 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
948 @param String Pointer to a Null-terminated ASCII string.
955 AsciiStrDecimalToUintn (
956 IN CONST CHAR8
*String
960 Convert a Null-terminated ASCII decimal string to a value of type
963 This function returns a value of type UINT64 by interpreting the contents
964 of the ASCII string String as a decimal number. The format of the input
965 ASCII string String is:
967 [spaces] [decimal digits].
969 The valid decimal digit character is in the range [0-9]. The function will
970 ignore the pad space, which includes spaces or tab characters, before the digits.
971 The running zero in the beginning of [decimal digits] will be ignored. Then, the
972 function stops at the first character that is a not a valid decimal character or
973 Null-terminator, whichever on comes first.
975 If String has only pad spaces, then 0 is returned.
976 If String has no pad spaces or valid decimal digits, then 0 is returned.
977 If the number represented by String overflows according to the range defined by
978 UINT64, then ASSERT().
979 If String is NULL, then ASSERT().
980 If PcdMaximumAsciiStringLength is not zero, and String contains more than
981 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
984 @param String Pointer to a Null-terminated ASCII string.
991 AsciiStrDecimalToUint64 (
992 IN CONST CHAR8
*String
996 Convert a Null-terminated ASCII hexadecimal string to a value of type UINTN.
998 This function returns a value of type UINTN by interpreting the contents of
999 the ASCII string String as a hexadecimal number. The format of the input ASCII
1002 [spaces][zeros][x][hexadecimal digits].
1004 The valid hexadecimal digit character is in the range [0-9], [a-f] and [A-F].
1005 The prefix "0x" is optional. Both "x" and "X" is allowed in "0x" prefix. If "x"
1006 appears in the input string, it must be prefixed with at least one 0. The function
1007 will ignore the pad space, which includes spaces or tab characters, before [zeros],
1008 [x] or [hexadecimal digits]. The running zero before [x] or [hexadecimal digits]
1009 will be ignored. Then, the decoding starts after [x] or the first valid hexadecimal
1010 digit. Then, the function stops at the first character that is a not a valid
1011 hexadecimal character or Null-terminator, whichever on comes first.
1013 If String has only pad spaces, then 0 is returned.
1014 If String has no leading pad spaces, leading zeros or valid hexadecimal digits, then
1017 If the number represented by String overflows according to the range defined by UINTN,
1019 If String is NULL, then ASSERT().
1020 If PcdMaximumAsciiStringLength is not zero,
1021 and String contains more than PcdMaximumAsciiStringLength ASCII characters not including
1022 the Null-terminator, then ASSERT().
1024 @param String Pointer to a Null-terminated ASCII string.
1031 AsciiStrHexToUintn (
1032 IN CONST CHAR8
*String
1036 Convert a Null-terminated ASCII hexadecimal string to a value of type UINT64.
1038 This function returns a value of type UINT64 by interpreting the contents of
1039 the ASCII string String as a hexadecimal number. The format of the input ASCII
1042 [spaces][zeros][x][hexadecimal digits].
1044 The valid hexadecimal digit character is in the range [0-9], [a-f] and [A-F].
1045 The prefix "0x" is optional. Both "x" and "X" is allowed in "0x" prefix. If "x"
1046 appears in the input string, it must be prefixed with at least one 0. The function
1047 will ignore the pad space, which includes spaces or tab characters, before [zeros],
1048 [x] or [hexadecimal digits]. The running zero before [x] or [hexadecimal digits]
1049 will be ignored. Then, the decoding starts after [x] or the first valid hexadecimal
1050 digit. Then, the function stops at the first character that is a not a valid
1051 hexadecimal character or Null-terminator, whichever on comes first.
1053 If String has only pad spaces, then 0 is returned.
1054 If String has no leading pad spaces, leading zeros or valid hexadecimal digits, then
1057 If the number represented by String overflows according to the range defined by UINT64,
1059 If String is NULL, then ASSERT().
1060 If PcdMaximumAsciiStringLength is not zero,
1061 and String contains more than PcdMaximumAsciiStringLength ASCII characters not including
1062 the Null-terminator, then ASSERT().
1064 @param String Pointer to a Null-terminated ASCII string.
1071 AsciiStrHexToUint64 (
1072 IN CONST CHAR8
*String
1076 Convert one Null-terminated ASCII string to a Null-terminated
1077 Unicode string and returns the Unicode string.
1079 This function converts the contents of the ASCII string Source to the Unicode
1080 string Destination, and returns Destination. The function terminates the
1081 Unicode string Destination by appending a Null-terminator character at the end.
1082 The caller is responsible to make sure Destination points to a buffer with size
1083 equal or greater than ((AsciiStrLen (Source) + 1) * sizeof (CHAR16)) in bytes.
1085 If Destination is NULL, then ASSERT().
1086 If Destination is not aligned on a 16-bit boundary, then ASSERT().
1087 If Source is NULL, then ASSERT().
1088 If Source and Destination overlap, then ASSERT().
1089 If PcdMaximumAsciiStringLength is not zero, and Source contains more than
1090 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
1092 If PcdMaximumUnicodeStringLength is not zero, and Source contains more than
1093 PcdMaximumUnicodeStringLength ASCII characters not including the
1094 Null-terminator, then ASSERT().
1096 @param Source Pointer to a Null-terminated ASCII string.
1097 @param Destination Pointer to a Null-terminated Unicode string.
1104 AsciiStrToUnicodeStr (
1105 IN CONST CHAR8
*Source
,
1106 OUT CHAR16
*Destination
1110 Converts an 8-bit value to an 8-bit BCD value.
1112 Converts the 8-bit value specified by Value to BCD. The BCD value is
1115 If Value >= 100, then ASSERT().
1117 @param Value The 8-bit value to convert to BCD. Range 0..99.
1119 @return The BCD value
1129 Converts an 8-bit BCD value to an 8-bit value.
1131 Converts the 8-bit BCD value specified by Value to an 8-bit value. The 8-bit
1134 If Value >= 0xA0, then ASSERT().
1135 If (Value & 0x0F) >= 0x0A, then ASSERT().
1137 @param Value The 8-bit BCD value to convert to an 8-bit value.
1139 @return The 8-bit value is returned.
1150 // Linked List Functions and Macros
1154 Initializes the head node of a doubly linked list that is declared as a
1155 global variable in a module.
1157 Initializes the forward and backward links of a new linked list. After
1158 initializing a linked list with this macro, the other linked list functions
1159 may be used to add and remove nodes from the linked list. This macro results
1160 in smaller executables by initializing the linked list in the data section,
1161 instead if calling the InitializeListHead() function to perform the
1162 equivalent operation.
1164 @param ListHead The head note of a list to initiailize.
1167 #define INITIALIZE_LIST_HEAD_VARIABLE(ListHead) {&ListHead, &ListHead}
1170 Initializes the head node of a doubly linked list, and returns the pointer to
1171 the head node of the doubly linked list.
1173 Initializes the forward and backward links of a new linked list. After
1174 initializing a linked list with this function, the other linked list
1175 functions may be used to add and remove nodes from the linked list. It is up
1176 to the caller of this function to allocate the memory for ListHead.
1178 If ListHead is NULL, then ASSERT().
1180 @param ListHead A pointer to the head node of a new doubly linked list.
1187 InitializeListHead (
1188 IN LIST_ENTRY
*ListHead
1192 Adds a node to the beginning of a doubly linked list, and returns the pointer
1193 to the head node of the doubly linked list.
1195 Adds the node Entry at the beginning of the doubly linked list denoted by
1196 ListHead, and returns ListHead.
1198 If ListHead is NULL, then ASSERT().
1199 If Entry is NULL, then ASSERT().
1200 If ListHead was not initialized with InitializeListHead(), then ASSERT().
1201 If PcdMaximumLinkedListLenth is not zero, and prior to insertion the number
1202 of nodes in ListHead, including the ListHead node, is greater than or
1203 equal to PcdMaximumLinkedListLength, then ASSERT().
1205 @param ListHead A pointer to the head node of a doubly linked list.
1206 @param Entry A pointer to a node that is to be inserted at the beginning
1207 of a doubly linked list.
1215 IN LIST_ENTRY
*ListHead
,
1216 IN LIST_ENTRY
*Entry
1220 Adds a node to the end of a doubly linked list, and returns the pointer to
1221 the head node of the doubly linked list.
1223 Adds the node Entry to the end of the doubly linked list denoted by ListHead,
1224 and returns ListHead.
1226 If ListHead is NULL, then ASSERT().
1227 If Entry is NULL, then ASSERT().
1228 If ListHead was not initialized with InitializeListHead(), then ASSERT().
1229 If PcdMaximumLinkedListLenth is not zero, and prior to insertion the number
1230 of nodes in ListHead, including the ListHead node, is greater than or
1231 equal to PcdMaximumLinkedListLength, then ASSERT().
1233 @param ListHead A pointer to the head node of a doubly linked list.
1234 @param Entry A pointer to a node that is to be added at the end of the
1243 IN LIST_ENTRY
*ListHead
,
1244 IN LIST_ENTRY
*Entry
1248 Retrieves the first node of a doubly linked list.
1250 Returns the first node of a doubly linked list. List must have been
1251 initialized with InitializeListHead(). If List is empty, then NULL is
1254 If List is NULL, then ASSERT().
1255 If List was not initialized with InitializeListHead(), then ASSERT().
1256 If PcdMaximumLinkedListLenth is not zero, and the number of nodes
1257 in List, including the List node, is greater than or equal to
1258 PcdMaximumLinkedListLength, then ASSERT().
1260 @param List A pointer to the head node of a doubly linked list.
1262 @return The first node of a doubly linked list.
1263 @retval NULL The list is empty.
1269 IN CONST LIST_ENTRY
*List
1273 Retrieves the next node of a doubly linked list.
1275 Returns the node of a doubly linked list that follows Node. List must have
1276 been initialized with InitializeListHead(). If List is empty, then List is
1279 If List is NULL, then ASSERT().
1280 If Node is NULL, then ASSERT().
1281 If List was not initialized with InitializeListHead(), then ASSERT().
1282 If PcdMaximumLinkedListLenth is not zero, and List contains more than
1283 PcdMaximumLinkedListLenth nodes, then ASSERT().
1284 If Node is not a node in List, then ASSERT().
1286 @param List A pointer to the head node of a doubly linked list.
1287 @param Node A pointer to a node in the doubly linked list.
1289 @return Pointer to the next node if one exists. Otherwise a null value which
1290 is actually List is returned.
1296 IN CONST LIST_ENTRY
*List
,
1297 IN CONST LIST_ENTRY
*Node
1301 Checks to see if a doubly linked list is empty or not.
1303 Checks to see if the doubly linked list is empty. If the linked list contains
1304 zero nodes, this function returns TRUE. Otherwise, it returns FALSE.
1306 If ListHead is NULL, then ASSERT().
1307 If ListHead was not initialized with InitializeListHead(), then ASSERT().
1308 If PcdMaximumLinkedListLenth is not zero, and the number of nodes
1309 in List, including the List node, is greater than or equal to
1310 PcdMaximumLinkedListLength, then ASSERT().
1312 @param ListHead A pointer to the head node of a doubly linked list.
1314 @retval TRUE The linked list is empty.
1315 @retval FALSE The linked list is not empty.
1321 IN CONST LIST_ENTRY
*ListHead
1325 Determines if a node in a doubly linked list is null.
1327 Returns FALSE if Node is one of the nodes in the doubly linked list specified
1328 by List. Otherwise, TRUE is returned. List must have been initialized with
1329 InitializeListHead().
1331 If List is NULL, then ASSERT().
1332 If Node is NULL, then ASSERT().
1333 If List was not initialized with InitializeListHead(), then ASSERT().
1334 If PcdMaximumLinkedListLenth is not zero, and the number of nodes
1335 in List, including the List node, is greater than or equal to
1336 PcdMaximumLinkedListLength, then ASSERT().
1337 If Node is not a node in List and Node is not equal to List, then ASSERT().
1339 @param List A pointer to the head node of a doubly linked list.
1340 @param Node A pointer to a node in the doubly linked list.
1342 @retval TRUE Node is one of the nodes in the doubly linked list.
1343 @retval FALSE Node is not one of the nodes in the doubly linked list.
1349 IN CONST LIST_ENTRY
*List
,
1350 IN CONST LIST_ENTRY
*Node
1354 Determines if a node the last node in a doubly linked list.
1356 Returns TRUE if Node is the last node in the doubly linked list specified by
1357 List. Otherwise, FALSE is returned. List must have been initialized with
1358 InitializeListHead().
1360 If List is NULL, then ASSERT().
1361 If Node is NULL, then ASSERT().
1362 If List was not initialized with InitializeListHead(), then ASSERT().
1363 If PcdMaximumLinkedListLenth is not zero, and the number of nodes
1364 in List, including the List node, is greater than or equal to
1365 PcdMaximumLinkedListLength, then ASSERT().
1366 If Node is not a node in List, then ASSERT().
1368 @param List A pointer to the head node of a doubly linked list.
1369 @param Node A pointer to a node in the doubly linked list.
1371 @retval TRUE Node is the last node in the linked list.
1372 @retval FALSE Node is not the last node in the linked list.
1378 IN CONST LIST_ENTRY
*List
,
1379 IN CONST LIST_ENTRY
*Node
1383 Swaps the location of two nodes in a doubly linked list, and returns the
1384 first node after the swap.
1386 If FirstEntry is identical to SecondEntry, then SecondEntry is returned.
1387 Otherwise, the location of the FirstEntry node is swapped with the location
1388 of the SecondEntry node in a doubly linked list. SecondEntry must be in the
1389 same double linked list as FirstEntry and that double linked list must have
1390 been initialized with InitializeListHead(). SecondEntry is returned after the
1393 If FirstEntry is NULL, then ASSERT().
1394 If SecondEntry is NULL, then ASSERT().
1395 If SecondEntry and FirstEntry are not in the same linked list, then ASSERT().
1396 If PcdMaximumLinkedListLength is not zero, and the number of nodes in the
1397 linked list containing the FirstEntry and SecondEntry nodes, including
1398 the FirstEntry and SecondEntry nodes, is greater than or equal to
1399 PcdMaximumLinkedListLength, then ASSERT().
1401 @param FirstEntry A pointer to a node in a linked list.
1402 @param SecondEntry A pointer to another node in the same linked list.
1408 IN LIST_ENTRY
*FirstEntry
,
1409 IN LIST_ENTRY
*SecondEntry
1413 Removes a node from a doubly linked list, and returns the node that follows
1416 Removes the node Entry from a doubly linked list. It is up to the caller of
1417 this function to release the memory used by this node if that is required. On
1418 exit, the node following Entry in the doubly linked list is returned. If
1419 Entry is the only node in the linked list, then the head node of the linked
1422 If Entry is NULL, then ASSERT().
1423 If Entry is the head node of an empty list, then ASSERT().
1424 If PcdMaximumLinkedListLength is not zero, and the number of nodes in the
1425 linked list containing Entry, including the Entry node, is greater than
1426 or equal to PcdMaximumLinkedListLength, then ASSERT().
1428 @param Entry A pointer to a node in a linked list
1436 IN CONST LIST_ENTRY
*Entry
1444 Shifts a 64-bit integer left between 0 and 63 bits. The low bits are filled
1445 with zeros. The shifted value is returned.
1447 This function shifts the 64-bit value Operand to the left by Count bits. The
1448 low Count bits are set to zero. The shifted value is returned.
1450 If Count is greater than 63, then ASSERT().
1452 @param Operand The 64-bit operand to shift left.
1453 @param Count The number of bits to shift left.
1455 @return Operand << Count
1466 Shifts a 64-bit integer right between 0 and 63 bits. This high bits are
1467 filled with zeros. The shifted value is returned.
1469 This function shifts the 64-bit value Operand to the right by Count bits. The
1470 high Count bits are set to zero. The shifted value is returned.
1472 If Count is greater than 63, then ASSERT().
1474 @param Operand The 64-bit operand to shift right.
1475 @param Count The number of bits to shift right.
1477 @return Operand >> Count
1488 Shifts a 64-bit integer right between 0 and 63 bits. The high bits are filled
1489 with original integer's bit 63. The shifted value is returned.
1491 This function shifts the 64-bit value Operand to the right by Count bits. The
1492 high Count bits are set to bit 63 of Operand. The shifted value is returned.
1494 If Count is greater than 63, then ASSERT().
1496 @param Operand The 64-bit operand to shift right.
1497 @param Count The number of bits to shift right.
1499 @return Operand >> Count
1510 Rotates a 32-bit integer left between 0 and 31 bits, filling the low bits
1511 with the high bits that were rotated.
1513 This function rotates the 32-bit value Operand to the left by Count bits. The
1514 low Count bits are fill with the high Count bits of Operand. The rotated
1517 If Count is greater than 31, then ASSERT().
1519 @param Operand The 32-bit operand to rotate left.
1520 @param Count The number of bits to rotate left.
1522 @return Operand <<< Count
1533 Rotates a 32-bit integer right between 0 and 31 bits, filling the high bits
1534 with the low bits that were rotated.
1536 This function rotates the 32-bit value Operand to the right by Count bits.
1537 The high Count bits are fill with the low Count bits of Operand. The rotated
1540 If Count is greater than 31, then ASSERT().
1542 @param Operand The 32-bit operand to rotate right.
1543 @param Count The number of bits to rotate right.
1545 @return Operand >>> Count
1556 Rotates a 64-bit integer left between 0 and 63 bits, filling the low bits
1557 with the high bits that were rotated.
1559 This function rotates the 64-bit value Operand to the left by Count bits. The
1560 low Count bits are fill with the high Count bits of Operand. The rotated
1563 If Count is greater than 63, then ASSERT().
1565 @param Operand The 64-bit operand to rotate left.
1566 @param Count The number of bits to rotate left.
1568 @return Operand <<< Count
1579 Rotates a 64-bit integer right between 0 and 63 bits, filling the high bits
1580 with the high low bits that were rotated.
1582 This function rotates the 64-bit value Operand to the right by Count bits.
1583 The high Count bits are fill with the low Count bits of Operand. The rotated
1586 If Count is greater than 63, then ASSERT().
1588 @param Operand The 64-bit operand to rotate right.
1589 @param Count The number of bits to rotate right.
1591 @return Operand >>> Count
1602 Returns the bit position of the lowest bit set in a 32-bit value.
1604 This function computes the bit position of the lowest bit set in the 32-bit
1605 value specified by Operand. If Operand is zero, then -1 is returned.
1606 Otherwise, a value between 0 and 31 is returned.
1608 @param Operand The 32-bit operand to evaluate.
1610 @return Position of the lowest bit set in Operand if found.
1611 @retval -1 Operand is zero.
1621 Returns the bit position of the lowest bit set in a 64-bit value.
1623 This function computes the bit position of the lowest bit set in the 64-bit
1624 value specified by Operand. If Operand is zero, then -1 is returned.
1625 Otherwise, a value between 0 and 63 is returned.
1627 @param Operand The 64-bit operand to evaluate.
1629 @return Position of the lowest bit set in Operand if found.
1630 @retval -1 Operand is zero.
1640 Returns the bit position of the highest bit set in a 32-bit value. Equivalent
1643 This function computes the bit position of the highest bit set in the 32-bit
1644 value specified by Operand. If Operand is zero, then -1 is returned.
1645 Otherwise, a value between 0 and 31 is returned.
1647 @param Operand The 32-bit operand to evaluate.
1649 @return Position of the highest bit set in Operand if found.
1650 @retval -1 Operand is zero.
1660 Returns the bit position of the highest bit set in a 64-bit value. Equivalent
1663 This function computes the bit position of the highest bit set in the 64-bit
1664 value specified by Operand. If Operand is zero, then -1 is returned.
1665 Otherwise, a value between 0 and 63 is returned.
1667 @param Operand The 64-bit operand to evaluate.
1669 @return Position of the highest bit set in Operand if found.
1670 @retval -1 Operand is zero.
1680 Returns the value of the highest bit set in a 32-bit value. Equivalent to
1681 1 << HighBitSet32(x).
1683 This function computes the value of the highest bit set in the 32-bit value
1684 specified by Operand. If Operand is zero, then zero is returned.
1686 @param Operand The 32-bit operand to evaluate.
1688 @return 1 << HighBitSet32(Operand)
1689 @retval 0 Operand is zero.
1699 Returns the value of the highest bit set in a 64-bit value. Equivalent to
1700 1 << HighBitSet64(x).
1702 This function computes the value of the highest bit set in the 64-bit value
1703 specified by Operand. If Operand is zero, then zero is returned.
1705 @param Operand The 64-bit operand to evaluate.
1707 @return 1 << HighBitSet64(Operand)
1708 @retval 0 Operand is zero.
1718 Switches the endianess of a 16-bit integer.
1720 This function swaps the bytes in a 16-bit unsigned value to switch the value
1721 from little endian to big endian or vice versa. The byte swapped value is
1724 @param Operand A 16-bit unsigned value.
1726 @return The byte swaped Operand.
1736 Switches the endianess of a 32-bit integer.
1738 This function swaps the bytes in a 32-bit unsigned value to switch the value
1739 from little endian to big endian or vice versa. The byte swapped value is
1742 @param Operand A 32-bit unsigned value.
1744 @return The byte swaped Operand.
1754 Switches the endianess of a 64-bit integer.
1756 This function swaps the bytes in a 64-bit unsigned value to switch the value
1757 from little endian to big endian or vice versa. The byte swapped value is
1760 @param Operand A 64-bit unsigned value.
1762 @return The byte swaped Operand.
1772 Multiples a 64-bit unsigned integer by a 32-bit unsigned integer and
1773 generates a 64-bit unsigned result.
1775 This function multiples the 64-bit unsigned value Multiplicand by the 32-bit
1776 unsigned value Multiplier and generates a 64-bit unsigned result. This 64-
1777 bit unsigned result is returned.
1779 If the result overflows, then ASSERT().
1781 @param Multiplicand A 64-bit unsigned value.
1782 @param Multiplier A 32-bit unsigned value.
1784 @return Multiplicand * Multiplier
1790 IN UINT64 Multiplicand
,
1791 IN UINT32 Multiplier
1795 Multiples a 64-bit unsigned integer by a 64-bit unsigned integer and
1796 generates a 64-bit unsigned result.
1798 This function multiples the 64-bit unsigned value Multiplicand by the 64-bit
1799 unsigned value Multiplier and generates a 64-bit unsigned result. This 64-
1800 bit unsigned result is returned.
1802 If the result overflows, then ASSERT().
1804 @param Multiplicand A 64-bit unsigned value.
1805 @param Multiplier A 64-bit unsigned value.
1807 @return Multiplicand * Multiplier
1813 IN UINT64 Multiplicand
,
1814 IN UINT64 Multiplier
1818 Multiples a 64-bit signed integer by a 64-bit signed integer and generates a
1819 64-bit signed result.
1821 This function multiples the 64-bit signed value Multiplicand by the 64-bit
1822 signed value Multiplier and generates a 64-bit signed result. This 64-bit
1823 signed result is returned.
1825 If the result overflows, then ASSERT().
1827 @param Multiplicand A 64-bit signed value.
1828 @param Multiplier A 64-bit signed value.
1830 @return Multiplicand * Multiplier
1836 IN INT64 Multiplicand
,
1841 Divides a 64-bit unsigned integer by a 32-bit unsigned integer and generates
1842 a 64-bit unsigned result.
1844 This function divides the 64-bit unsigned value Dividend by the 32-bit
1845 unsigned value Divisor and generates a 64-bit unsigned quotient. This
1846 function returns the 64-bit unsigned quotient.
1848 If Divisor is 0, then ASSERT().
1850 @param Dividend A 64-bit unsigned value.
1851 @param Divisor A 32-bit unsigned value.
1853 @return Dividend / Divisor
1864 Divides a 64-bit unsigned integer by a 32-bit unsigned integer and generates
1865 a 32-bit unsigned remainder.
1867 This function divides the 64-bit unsigned value Dividend by the 32-bit
1868 unsigned value Divisor and generates a 32-bit remainder. This function
1869 returns the 32-bit unsigned remainder.
1871 If Divisor is 0, then ASSERT().
1873 @param Dividend A 64-bit unsigned value.
1874 @param Divisor A 32-bit unsigned value.
1876 @return Dividend % Divisor
1887 Divides a 64-bit unsigned integer by a 32-bit unsigned integer and generates
1888 a 64-bit unsigned result and an optional 32-bit unsigned remainder.
1890 This function divides the 64-bit unsigned value Dividend by the 32-bit
1891 unsigned value Divisor and generates a 64-bit unsigned quotient. If Remainder
1892 is not NULL, then the 32-bit unsigned remainder is returned in Remainder.
1893 This function returns the 64-bit unsigned quotient.
1895 If Divisor is 0, then ASSERT().
1897 @param Dividend A 64-bit unsigned value.
1898 @param Divisor A 32-bit unsigned value.
1899 @param Remainder A pointer to a 32-bit unsigned value. This parameter is
1900 optional and may be NULL.
1902 @return Dividend / Divisor
1907 DivU64x32Remainder (
1910 OUT UINT32
*Remainder OPTIONAL
1914 Divides a 64-bit unsigned integer by a 64-bit unsigned integer and generates
1915 a 64-bit unsigned result and an optional 64-bit unsigned remainder.
1917 This function divides the 64-bit unsigned value Dividend by the 64-bit
1918 unsigned value Divisor and generates a 64-bit unsigned quotient. If Remainder
1919 is not NULL, then the 64-bit unsigned remainder is returned in Remainder.
1920 This function returns the 64-bit unsigned quotient.
1922 If Divisor is 0, then ASSERT().
1924 @param Dividend A 64-bit unsigned value.
1925 @param Divisor A 64-bit unsigned value.
1926 @param Remainder A pointer to a 64-bit unsigned value. This parameter is
1927 optional and may be NULL.
1929 @return Dividend / Divisor
1934 DivU64x64Remainder (
1937 OUT UINT64
*Remainder OPTIONAL
1941 Divides a 64-bit signed integer by a 64-bit signed integer and generates a
1942 64-bit signed result and a optional 64-bit signed remainder.
1944 This function divides the 64-bit signed value Dividend by the 64-bit signed
1945 value Divisor and generates a 64-bit signed quotient. If Remainder is not
1946 NULL, then the 64-bit signed remainder is returned in Remainder. This
1947 function returns the 64-bit signed quotient.
1949 If Divisor is 0, then ASSERT().
1951 @param Dividend A 64-bit signed value.
1952 @param Divisor A 64-bit signed value.
1953 @param Remainder A pointer to a 64-bit signed value. This parameter is
1954 optional and may be NULL.
1956 @return Dividend / Divisor
1961 DivS64x64Remainder (
1964 OUT INT64
*Remainder OPTIONAL
1968 Reads a 16-bit value from memory that may be unaligned.
1970 This function returns the 16-bit value pointed to by Buffer. The function
1971 guarantees that the read operation does not produce an alignment fault.
1973 If the Buffer is NULL, then ASSERT().
1975 @param Buffer Pointer to a 16-bit value that may be unaligned.
1983 IN CONST UINT16
*Uint16
1987 Writes a 16-bit value to memory that may be unaligned.
1989 This function writes the 16-bit value specified by Value to Buffer. Value is
1990 returned. The function guarantees that the write operation does not produce
1993 If the Buffer is NULL, then ASSERT().
1995 @param Buffer Pointer to a 16-bit value that may be unaligned.
1996 @param Value 16-bit value to write to Buffer.
2009 Reads a 24-bit value from memory that may be unaligned.
2011 This function returns the 24-bit value pointed to by Buffer. The function
2012 guarantees that the read operation does not produce an alignment fault.
2014 If the Buffer is NULL, then ASSERT().
2016 @param Buffer Pointer to a 24-bit value that may be unaligned.
2018 @return The value read.
2024 IN CONST UINT32
*Buffer
2028 Writes a 24-bit value to memory that may be unaligned.
2030 This function writes the 24-bit value specified by Value to Buffer. Value is
2031 returned. The function guarantees that the write operation does not produce
2034 If the Buffer is NULL, then ASSERT().
2036 @param Buffer Pointer to a 24-bit value that may be unaligned.
2037 @param Value 24-bit value to write to Buffer.
2039 @return The value written.
2050 Reads a 32-bit value from memory that may be unaligned.
2052 This function returns the 32-bit value pointed to by Buffer. The function
2053 guarantees that the read operation does not produce an alignment fault.
2055 If the Buffer is NULL, then ASSERT().
2057 @param Buffer Pointer to a 32-bit value that may be unaligned.
2065 IN CONST UINT32
*Uint32
2069 Writes a 32-bit value to memory that may be unaligned.
2071 This function writes the 32-bit value specified by Value to Buffer. Value is
2072 returned. The function guarantees that the write operation does not produce
2075 If the Buffer is NULL, then ASSERT().
2077 @param Buffer Pointer to a 32-bit value that may be unaligned.
2078 @param Value 32-bit value to write to Buffer.
2091 Reads a 64-bit value from memory that may be unaligned.
2093 This function returns the 64-bit value pointed to by Buffer. The function
2094 guarantees that the read operation does not produce an alignment fault.
2096 If the Buffer is NULL, then ASSERT().
2098 @param Buffer Pointer to a 64-bit value that may be unaligned.
2106 IN CONST UINT64
*Uint64
2110 Writes a 64-bit value to memory that may be unaligned.
2112 This function writes the 64-bit value specified by Value to Buffer. Value is
2113 returned. The function guarantees that the write operation does not produce
2116 If the Buffer is NULL, then ASSERT().
2118 @param Buffer Pointer to a 64-bit value that may be unaligned.
2119 @param Value 64-bit value to write to Buffer.
2132 // Bit Field Functions
2136 Returns a bit field from an 8-bit value.
2138 Returns the bitfield specified by the StartBit and the EndBit from Operand.
2140 If 8-bit operations are not supported, then ASSERT().
2141 If StartBit is greater than 7, then ASSERT().
2142 If EndBit is greater than 7, then ASSERT().
2143 If EndBit is less than StartBit, then ASSERT().
2145 @param Operand Operand on which to perform the bitfield operation.
2146 @param StartBit The ordinal of the least significant bit in the bit field.
2148 @param EndBit The ordinal of the most significant bit in the bit field.
2151 @return The bit field read.
2163 Writes a bit field to an 8-bit value, and returns the result.
2165 Writes Value to the bit field specified by the StartBit and the EndBit in
2166 Operand. All other bits in Operand are preserved. The new 8-bit value is
2169 If 8-bit operations are not supported, then ASSERT().
2170 If StartBit is greater than 7, then ASSERT().
2171 If EndBit is greater than 7, then ASSERT().
2172 If EndBit is less than StartBit, then ASSERT().
2174 @param Operand Operand on which to perform the bitfield operation.
2175 @param StartBit The ordinal of the least significant bit in the bit field.
2177 @param EndBit The ordinal of the most significant bit in the bit field.
2179 @param Value New value of the bit field.
2181 @return The new 8-bit value.
2194 Reads a bit field from an 8-bit value, performs a bitwise OR, and returns the
2197 Performs a bitwise inclusive OR between the bit field specified by StartBit
2198 and EndBit in Operand and the value specified by OrData. All other bits in
2199 Operand are preserved. The new 8-bit value is returned.
2201 If 8-bit operations are not supported, then ASSERT().
2202 If StartBit is greater than 7, then ASSERT().
2203 If EndBit is greater than 7, then ASSERT().
2204 If EndBit is less than StartBit, then ASSERT().
2206 @param Operand Operand on which to perform the bitfield operation.
2207 @param StartBit The ordinal of the least significant bit in the bit field.
2209 @param EndBit The ordinal of the most significant bit in the bit field.
2211 @param OrData The value to OR with the read value from the value
2213 @return The new 8-bit value.
2226 Reads a bit field from an 8-bit value, performs a bitwise AND, and returns
2229 Performs a bitwise AND between the bit field specified by StartBit and EndBit
2230 in Operand and the value specified by AndData. All other bits in Operand are
2231 preserved. The new 8-bit value is returned.
2233 If 8-bit operations are not supported, then ASSERT().
2234 If StartBit is greater than 7, then ASSERT().
2235 If EndBit is greater than 7, then ASSERT().
2236 If EndBit is less than StartBit, then ASSERT().
2238 @param Operand Operand on which to perform the bitfield operation.
2239 @param StartBit The ordinal of the least significant bit in the bit field.
2241 @param EndBit The ordinal of the most significant bit in the bit field.
2243 @param AndData The value to AND with the read value from the value.
2245 @return The new 8-bit value.
2258 Reads a bit field from an 8-bit value, performs a bitwise AND followed by a
2259 bitwise OR, and returns the result.
2261 Performs a bitwise AND between the bit field specified by StartBit and EndBit
2262 in Operand and the value specified by AndData, followed by a bitwise
2263 inclusive OR with value specified by OrData. All other bits in Operand are
2264 preserved. The new 8-bit value is returned.
2266 If 8-bit operations are not supported, then ASSERT().
2267 If StartBit is greater than 7, then ASSERT().
2268 If EndBit is greater than 7, then ASSERT().
2269 If EndBit is less than StartBit, then ASSERT().
2271 @param Operand Operand on which to perform the bitfield operation.
2272 @param StartBit The ordinal of the least significant bit in the bit field.
2274 @param EndBit The ordinal of the most significant bit in the bit field.
2276 @param AndData The value to AND with the read value from the value.
2277 @param OrData The value to OR with the result of the AND operation.
2279 @return The new 8-bit value.
2284 BitFieldAndThenOr8 (
2293 Returns a bit field from a 16-bit value.
2295 Returns the bitfield specified by the StartBit and the EndBit from Operand.
2297 If 16-bit operations are not supported, then ASSERT().
2298 If StartBit is greater than 15, then ASSERT().
2299 If EndBit is greater than 15, then ASSERT().
2300 If EndBit is less than StartBit, then ASSERT().
2302 @param Operand Operand on which to perform the bitfield operation.
2303 @param StartBit The ordinal of the least significant bit in the bit field.
2305 @param EndBit The ordinal of the most significant bit in the bit field.
2308 @return The bit field read.
2320 Writes a bit field to a 16-bit value, and returns the result.
2322 Writes Value to the bit field specified by the StartBit and the EndBit in
2323 Operand. All other bits in Operand are preserved. The new 16-bit value is
2326 If 16-bit operations are not supported, then ASSERT().
2327 If StartBit is greater than 15, then ASSERT().
2328 If EndBit is greater than 15, then ASSERT().
2329 If EndBit is less than StartBit, then ASSERT().
2331 @param Operand Operand on which to perform the bitfield operation.
2332 @param StartBit The ordinal of the least significant bit in the bit field.
2334 @param EndBit The ordinal of the most significant bit in the bit field.
2336 @param Value New value of the bit field.
2338 @return The new 16-bit value.
2351 Reads a bit field from a 16-bit value, performs a bitwise OR, and returns the
2354 Performs a bitwise inclusive OR between the bit field specified by StartBit
2355 and EndBit in Operand and the value specified by OrData. All other bits in
2356 Operand are preserved. The new 16-bit value is returned.
2358 If 16-bit operations are not supported, then ASSERT().
2359 If StartBit is greater than 15, then ASSERT().
2360 If EndBit is greater than 15, then ASSERT().
2361 If EndBit is less than StartBit, then ASSERT().
2363 @param Operand Operand on which to perform the bitfield operation.
2364 @param StartBit The ordinal of the least significant bit in the bit field.
2366 @param EndBit The ordinal of the most significant bit in the bit field.
2368 @param OrData The value to OR with the read value from the value
2370 @return The new 16-bit value.
2383 Reads a bit field from a 16-bit value, performs a bitwise AND, and returns
2386 Performs a bitwise AND between the bit field specified by StartBit and EndBit
2387 in Operand and the value specified by AndData. All other bits in Operand are
2388 preserved. The new 16-bit value is returned.
2390 If 16-bit operations are not supported, then ASSERT().
2391 If StartBit is greater than 15, then ASSERT().
2392 If EndBit is greater than 15, then ASSERT().
2393 If EndBit is less than StartBit, then ASSERT().
2395 @param Operand Operand on which to perform the bitfield operation.
2396 @param StartBit The ordinal of the least significant bit in the bit field.
2398 @param EndBit The ordinal of the most significant bit in the bit field.
2400 @param AndData The value to AND with the read value from the value
2402 @return The new 16-bit value.
2415 Reads a bit field from a 16-bit value, performs a bitwise AND followed by a
2416 bitwise OR, and returns the result.
2418 Performs a bitwise AND between the bit field specified by StartBit and EndBit
2419 in Operand and the value specified by AndData, followed by a bitwise
2420 inclusive OR with value specified by OrData. All other bits in Operand are
2421 preserved. The new 16-bit value is returned.
2423 If 16-bit operations are not supported, then ASSERT().
2424 If StartBit is greater than 15, then ASSERT().
2425 If EndBit is greater than 15, then ASSERT().
2426 If EndBit is less than StartBit, then ASSERT().
2428 @param Operand Operand on which to perform the bitfield operation.
2429 @param StartBit The ordinal of the least significant bit in the bit field.
2431 @param EndBit The ordinal of the most significant bit in the bit field.
2433 @param AndData The value to AND with the read value from the value.
2434 @param OrData The value to OR with the result of the AND operation.
2436 @return The new 16-bit value.
2441 BitFieldAndThenOr16 (
2450 Returns a bit field from a 32-bit value.
2452 Returns the bitfield specified by the StartBit and the EndBit from Operand.
2454 If 32-bit operations are not supported, then ASSERT().
2455 If StartBit is greater than 31, then ASSERT().
2456 If EndBit is greater than 31, then ASSERT().
2457 If EndBit is less than StartBit, then ASSERT().
2459 @param Operand Operand on which to perform the bitfield operation.
2460 @param StartBit The ordinal of the least significant bit in the bit field.
2462 @param EndBit The ordinal of the most significant bit in the bit field.
2465 @return The bit field read.
2477 Writes a bit field to a 32-bit value, and returns the result.
2479 Writes Value to the bit field specified by the StartBit and the EndBit in
2480 Operand. All other bits in Operand are preserved. The new 32-bit value is
2483 If 32-bit operations are not supported, then ASSERT().
2484 If StartBit is greater than 31, then ASSERT().
2485 If EndBit is greater than 31, then ASSERT().
2486 If EndBit is less than StartBit, then ASSERT().
2488 @param Operand Operand on which to perform the bitfield operation.
2489 @param StartBit The ordinal of the least significant bit in the bit field.
2491 @param EndBit The ordinal of the most significant bit in the bit field.
2493 @param Value New value of the bit field.
2495 @return The new 32-bit value.
2508 Reads a bit field from a 32-bit value, performs a bitwise OR, and returns the
2511 Performs a bitwise inclusive OR between the bit field specified by StartBit
2512 and EndBit in Operand and the value specified by OrData. All other bits in
2513 Operand are preserved. The new 32-bit value is returned.
2515 If 32-bit operations are not supported, then ASSERT().
2516 If StartBit is greater than 31, then ASSERT().
2517 If EndBit is greater than 31, then ASSERT().
2518 If EndBit is less than StartBit, then ASSERT().
2520 @param Operand Operand on which to perform the bitfield operation.
2521 @param StartBit The ordinal of the least significant bit in the bit field.
2523 @param EndBit The ordinal of the most significant bit in the bit field.
2525 @param OrData The value to OR with the read value from the value
2527 @return The new 32-bit value.
2540 Reads a bit field from a 32-bit value, performs a bitwise AND, and returns
2543 Performs a bitwise AND between the bit field specified by StartBit and EndBit
2544 in Operand and the value specified by AndData. All other bits in Operand are
2545 preserved. The new 32-bit value is returned.
2547 If 32-bit operations are not supported, then ASSERT().
2548 If StartBit is greater than 31, then ASSERT().
2549 If EndBit is greater than 31, then ASSERT().
2550 If EndBit is less than StartBit, then ASSERT().
2552 @param Operand Operand on which to perform the bitfield operation.
2553 @param StartBit The ordinal of the least significant bit in the bit field.
2555 @param EndBit The ordinal of the most significant bit in the bit field.
2557 @param AndData The value to AND with the read value from the value
2559 @return The new 32-bit value.
2572 Reads a bit field from a 32-bit value, performs a bitwise AND followed by a
2573 bitwise OR, and returns the result.
2575 Performs a bitwise AND between the bit field specified by StartBit and EndBit
2576 in Operand and the value specified by AndData, followed by a bitwise
2577 inclusive OR with value specified by OrData. All other bits in Operand are
2578 preserved. The new 32-bit value is returned.
2580 If 32-bit operations are not supported, then ASSERT().
2581 If StartBit is greater than 31, then ASSERT().
2582 If EndBit is greater than 31, then ASSERT().
2583 If EndBit is less than StartBit, then ASSERT().
2585 @param Operand Operand on which to perform the bitfield operation.
2586 @param StartBit The ordinal of the least significant bit in the bit field.
2588 @param EndBit The ordinal of the most significant bit in the bit field.
2590 @param AndData The value to AND with the read value from the value.
2591 @param OrData The value to OR with the result of the AND operation.
2593 @return The new 32-bit value.
2598 BitFieldAndThenOr32 (
2607 Returns a bit field from a 64-bit value.
2609 Returns the bitfield specified by the StartBit and the EndBit from Operand.
2611 If 64-bit operations are not supported, then ASSERT().
2612 If StartBit is greater than 63, then ASSERT().
2613 If EndBit is greater than 63, then ASSERT().
2614 If EndBit is less than StartBit, then ASSERT().
2616 @param Operand Operand on which to perform the bitfield operation.
2617 @param StartBit The ordinal of the least significant bit in the bit field.
2619 @param EndBit The ordinal of the most significant bit in the bit field.
2622 @return The bit field read.
2634 Writes a bit field to a 64-bit value, and returns the result.
2636 Writes Value to the bit field specified by the StartBit and the EndBit in
2637 Operand. All other bits in Operand are preserved. The new 64-bit value is
2640 If 64-bit operations are not supported, then ASSERT().
2641 If StartBit is greater than 63, then ASSERT().
2642 If EndBit is greater than 63, then ASSERT().
2643 If EndBit is less than StartBit, then ASSERT().
2645 @param Operand Operand on which to perform the bitfield operation.
2646 @param StartBit The ordinal of the least significant bit in the bit field.
2648 @param EndBit The ordinal of the most significant bit in the bit field.
2650 @param Value New value of the bit field.
2652 @return The new 64-bit value.
2665 Reads a bit field from a 64-bit value, performs a bitwise OR, and returns the
2668 Performs a bitwise inclusive OR between the bit field specified by StartBit
2669 and EndBit in Operand and the value specified by OrData. All other bits in
2670 Operand are preserved. The new 64-bit value is returned.
2672 If 64-bit operations are not supported, then ASSERT().
2673 If StartBit is greater than 63, then ASSERT().
2674 If EndBit is greater than 63, then ASSERT().
2675 If EndBit is less than StartBit, then ASSERT().
2677 @param Operand Operand on which to perform the bitfield operation.
2678 @param StartBit The ordinal of the least significant bit in the bit field.
2680 @param EndBit The ordinal of the most significant bit in the bit field.
2682 @param OrData The value to OR with the read value from the value
2684 @return The new 64-bit value.
2697 Reads a bit field from a 64-bit value, performs a bitwise AND, and returns
2700 Performs a bitwise AND between the bit field specified by StartBit and EndBit
2701 in Operand and the value specified by AndData. All other bits in Operand are
2702 preserved. The new 64-bit value is returned.
2704 If 64-bit operations are not supported, then ASSERT().
2705 If StartBit is greater than 63, then ASSERT().
2706 If EndBit is greater than 63, then ASSERT().
2707 If EndBit is less than StartBit, then ASSERT().
2709 @param Operand Operand on which to perform the bitfield operation.
2710 @param StartBit The ordinal of the least significant bit in the bit field.
2712 @param EndBit The ordinal of the most significant bit in the bit field.
2714 @param AndData The value to AND with the read value from the value
2716 @return The new 64-bit value.
2729 Reads a bit field from a 64-bit value, performs a bitwise AND followed by a
2730 bitwise OR, and returns the result.
2732 Performs a bitwise AND between the bit field specified by StartBit and EndBit
2733 in Operand and the value specified by AndData, followed by a bitwise
2734 inclusive OR with value specified by OrData. All other bits in Operand are
2735 preserved. The new 64-bit value is returned.
2737 If 64-bit operations are not supported, then ASSERT().
2738 If StartBit is greater than 63, then ASSERT().
2739 If EndBit is greater than 63, then ASSERT().
2740 If EndBit is less than StartBit, then ASSERT().
2742 @param Operand Operand on which to perform the bitfield operation.
2743 @param StartBit The ordinal of the least significant bit in the bit field.
2745 @param EndBit The ordinal of the most significant bit in the bit field.
2747 @param AndData The value to AND with the read value from the value.
2748 @param OrData The value to OR with the result of the AND operation.
2750 @return The new 64-bit value.
2755 BitFieldAndThenOr64 (
2764 // Base Library Synchronization Functions
2768 Retrieves the architecture specific spin lock alignment requirements for
2769 optimal spin lock performance.
2771 This function retrieves the spin lock alignment requirements for optimal
2772 performance on a given CPU architecture. The spin lock alignment must be a
2773 power of two and is returned by this function. If there are no alignment
2774 requirements, then 1 must be returned. The spin lock synchronization
2775 functions must function correctly if the spin lock size and alignment values
2776 returned by this function are not used at all. These values are hints to the
2777 consumers of the spin lock synchronization functions to obtain optimal spin
2780 @return The architecture specific spin lock alignment.
2785 GetSpinLockProperties (
2790 Initializes a spin lock to the released state and returns the spin lock.
2792 This function initializes the spin lock specified by SpinLock to the released
2793 state, and returns SpinLock. Optimal performance can be achieved by calling
2794 GetSpinLockProperties() to determine the size and alignment requirements for
2797 If SpinLock is NULL, then ASSERT().
2799 @param SpinLock A pointer to the spin lock to initialize to the released
2807 InitializeSpinLock (
2808 IN SPIN_LOCK
*SpinLock
2812 Waits until a spin lock can be placed in the acquired state.
2814 This function checks the state of the spin lock specified by SpinLock. If
2815 SpinLock is in the released state, then this function places SpinLock in the
2816 acquired state and returns SpinLock. Otherwise, this function waits
2817 indefinitely for the spin lock to be released, and then places it in the
2818 acquired state and returns SpinLock. All state transitions of SpinLock must
2819 be performed using MP safe mechanisms.
2821 If SpinLock is NULL, then ASSERT().
2822 If SpinLock was not initialized with InitializeSpinLock(), then ASSERT().
2823 If PcdSpinLockTimeout is not zero, and SpinLock is can not be acquired in
2824 PcdSpinLockTimeout microseconds, then ASSERT().
2826 @param SpinLock A pointer to the spin lock to place in the acquired state.
2834 IN SPIN_LOCK
*SpinLock
2838 Attempts to place a spin lock in the acquired state.
2840 This function checks the state of the spin lock specified by SpinLock. If
2841 SpinLock is in the released state, then this function places SpinLock in the
2842 acquired state and returns TRUE. Otherwise, FALSE is returned. All state
2843 transitions of SpinLock must be performed using MP safe mechanisms.
2845 If SpinLock is NULL, then ASSERT().
2846 If SpinLock was not initialized with InitializeSpinLock(), then ASSERT().
2848 @param SpinLock A pointer to the spin lock to place in the acquired state.
2850 @retval TRUE SpinLock was placed in the acquired state.
2851 @retval FALSE SpinLock could not be acquired.
2856 AcquireSpinLockOrFail (
2857 IN SPIN_LOCK
*SpinLock
2861 Releases a spin lock.
2863 This function places the spin lock specified by SpinLock in the release state
2864 and returns SpinLock.
2866 If SpinLock is NULL, then ASSERT().
2867 If SpinLock was not initialized with InitializeSpinLock(), then ASSERT().
2869 @param SpinLock A pointer to the spin lock to release.
2877 IN SPIN_LOCK
*SpinLock
2881 Performs an atomic increment of an 32-bit unsigned integer.
2883 Performs an atomic increment of the 32-bit unsigned integer specified by
2884 Value and returns the incremented value. The increment operation must be
2885 performed using MP safe mechanisms. The state of the return value is not
2886 guaranteed to be MP safe.
2888 If Value is NULL, then ASSERT().
2890 @param Value A pointer to the 32-bit value to increment.
2892 @return The incremented value.
2897 InterlockedIncrement (
2902 Performs an atomic decrement of an 32-bit unsigned integer.
2904 Performs an atomic decrement of the 32-bit unsigned integer specified by
2905 Value and returns the decremented value. The decrement operation must be
2906 performed using MP safe mechanisms. The state of the return value is not
2907 guaranteed to be MP safe.
2909 If Value is NULL, then ASSERT().
2911 @param Value A pointer to the 32-bit value to decrement.
2913 @return The decremented value.
2918 InterlockedDecrement (
2923 Performs an atomic compare exchange operation on a 32-bit unsigned integer.
2925 Performs an atomic compare exchange operation on the 32-bit unsigned integer
2926 specified by Value. If Value is equal to CompareValue, then Value is set to
2927 ExchangeValue and CompareValue is returned. If Value is not equal to CompareValue,
2928 then Value is returned. The compare exchange operation must be performed using
2931 If Value is NULL, then ASSERT().
2933 @param Value A pointer to the 32-bit value for the compare exchange
2935 @param CompareValue 32-bit value used in compare operation.
2936 @param ExchangeValue 32-bit value used in exchange operation.
2938 @return The original *Value before exchange.
2943 InterlockedCompareExchange32 (
2944 IN OUT UINT32
*Value
,
2945 IN UINT32 CompareValue
,
2946 IN UINT32 ExchangeValue
2950 Performs an atomic compare exchange operation on a 64-bit unsigned integer.
2952 Performs an atomic compare exchange operation on the 64-bit unsigned integer specified
2953 by Value. If Value is equal to CompareValue, then Value is set to ExchangeValue and
2954 CompareValue is returned. If Value is not equal to CompareValue, then Value is returned.
2955 The compare exchange operation must be performed using MP safe mechanisms.
2957 If Value is NULL, then ASSERT().
2959 @param Value A pointer to the 64-bit value for the compare exchange
2961 @param CompareValue 64-bit value used in compare operation.
2962 @param ExchangeValue 64-bit value used in exchange operation.
2964 @return The original *Value before exchange.
2969 InterlockedCompareExchange64 (
2970 IN OUT UINT64
*Value
,
2971 IN UINT64 CompareValue
,
2972 IN UINT64 ExchangeValue
2976 Performs an atomic compare exchange operation on a pointer value.
2978 Performs an atomic compare exchange operation on the pointer value specified
2979 by Value. If Value is equal to CompareValue, then Value is set to
2980 ExchangeValue and CompareValue is returned. If Value is not equal to
2981 CompareValue, then Value is returned. The compare exchange operation must be
2982 performed using MP safe mechanisms.
2984 If Value is NULL, then ASSERT().
2986 @param Value A pointer to the pointer value for the compare exchange
2988 @param CompareValue Pointer value used in compare operation.
2989 @param ExchangeValue Pointer value used in exchange operation.
2994 InterlockedCompareExchangePointer (
2995 IN OUT VOID
**Value
,
2996 IN VOID
*CompareValue
,
2997 IN VOID
*ExchangeValue
3001 // Base Library Checksum Functions
3005 Calculate the sum of all elements in a buffer in unit of UINT8.
3006 During calculation, the carry bits are dropped.
3008 This function calculates the sum of all elements in a buffer
3009 in unit of UINT8. The carry bits in result of addition are dropped.
3010 The result is returned as UINT8. If Length is Zero, then Zero is
3013 If Buffer is NULL, then ASSERT().
3014 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
3016 @param Buffer Pointer to the buffer to carry out the sum operation.
3017 @param Length The size, in bytes, of Buffer .
3019 @return Sum The sum of Buffer with carry bits dropped during additions.
3025 IN CONST UINT8
*Buffer
,
3031 Returns the two's complement checksum of all elements in a buffer
3034 This function first calculates the sum of the 8-bit values in the
3035 buffer specified by Buffer and Length. The carry bits in the result
3036 of addition are dropped. Then, the two's complement of the sum is
3037 returned. If Length is 0, then 0 is returned.
3039 If Buffer is NULL, then ASSERT().
3040 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
3043 @param Buffer Pointer to the buffer to carry out the checksum operation.
3044 @param Length The size, in bytes, of Buffer.
3046 @return Checksum The 2's complement checksum of Buffer.
3051 CalculateCheckSum8 (
3052 IN CONST UINT8
*Buffer
,
3057 Returns the sum of all elements in a buffer of 16-bit values. During
3058 calculation, the carry bits are dropped.
3060 This function calculates the sum of the 16-bit values in the buffer
3061 specified by Buffer and Length. The carry bits in result of addition are dropped.
3062 The 16-bit result is returned. If Length is 0, then 0 is returned.
3064 If Buffer is NULL, then ASSERT().
3065 If Buffer is not aligned on a 16-bit boundary, then ASSERT().
3066 If Length is not aligned on a 16-bit boundary, then ASSERT().
3067 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
3069 @param Buffer Pointer to the buffer to carry out the sum operation.
3070 @param Length The size, in bytes, of Buffer.
3072 @return Sum The sum of Buffer with carry bits dropped during additions.
3078 IN CONST UINT16
*Buffer
,
3083 Returns the two's complement checksum of all elements in a buffer of
3086 This function first calculates the sum of the 16-bit values in the buffer
3087 specified by Buffer and Length. The carry bits in the result of addition
3088 are dropped. Then, the two's complement of the sum is returned. If Length
3089 is 0, then 0 is returned.
3091 If Buffer is NULL, then ASSERT().
3092 If Buffer is not aligned on a 16-bit boundary, then ASSERT().
3093 If Length is not aligned on a 16-bit boundary, then ASSERT().
3094 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
3096 @param Buffer Pointer to the buffer to carry out the checksum operation.
3097 @param Length The size, in bytes, of Buffer.
3099 @return Checksum The 2's complement checksum of Buffer.
3104 CalculateCheckSum16 (
3105 IN CONST UINT16
*Buffer
,
3110 Returns the sum of all elements in a buffer of 32-bit values. During
3111 calculation, the carry bits are dropped.
3113 This function calculates the sum of the 32-bit values in the buffer
3114 specified by Buffer and Length. The carry bits in result of addition are dropped.
3115 The 32-bit result is returned. If Length is 0, then 0 is returned.
3117 If Buffer is NULL, then ASSERT().
3118 If Buffer is not aligned on a 32-bit boundary, then ASSERT().
3119 If Length is not aligned on a 32-bit boundary, then ASSERT().
3120 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
3122 @param Buffer Pointer to the buffer to carry out the sum operation.
3123 @param Length The size, in bytes, of Buffer.
3125 @return Sum The sum of Buffer with carry bits dropped during additions.
3131 IN CONST UINT32
*Buffer
,
3136 Returns the two's complement checksum of all elements in a buffer of
3139 This function first calculates the sum of the 32-bit values in the buffer
3140 specified by Buffer and Length. The carry bits in the result of addition
3141 are dropped. Then, the two's complement of the sum is returned. If Length
3142 is 0, then 0 is returned.
3144 If Buffer is NULL, then ASSERT().
3145 If Buffer is not aligned on a 32-bit boundary, then ASSERT().
3146 If Length is not aligned on a 32-bit boundary, then ASSERT().
3147 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
3149 @param Buffer Pointer to the buffer to carry out the checksum operation.
3150 @param Length The size, in bytes, of Buffer.
3152 @return Checksum The 2's complement checksum of Buffer.
3157 CalculateCheckSum32 (
3158 IN CONST UINT32
*Buffer
,
3163 Returns the sum of all elements in a buffer of 64-bit values. During
3164 calculation, the carry bits are dropped.
3166 This function calculates the sum of the 64-bit values in the buffer
3167 specified by Buffer and Length. The carry bits in result of addition are dropped.
3168 The 64-bit result is returned. If Length is 0, then 0 is returned.
3170 If Buffer is NULL, then ASSERT().
3171 If Buffer is not aligned on a 64-bit boundary, then ASSERT().
3172 If Length is not aligned on a 64-bit boundary, then ASSERT().
3173 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
3175 @param Buffer Pointer to the buffer to carry out the sum operation.
3176 @param Length The size, in bytes, of Buffer.
3178 @return Sum The sum of Buffer with carry bits dropped during additions.
3184 IN CONST UINT64
*Buffer
,
3189 Returns the two's complement checksum of all elements in a buffer of
3192 This function first calculates the sum of the 64-bit values in the buffer
3193 specified by Buffer and Length. The carry bits in the result of addition
3194 are dropped. Then, the two's complement of the sum is returned. If Length
3195 is 0, then 0 is returned.
3197 If Buffer is NULL, then ASSERT().
3198 If Buffer is not aligned on a 64-bit boundary, then ASSERT().
3199 If Length is not aligned on a 64-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 checksum operation.
3203 @param Length The size, in bytes, of Buffer.
3205 @return Checksum The 2's complement checksum of Buffer.
3210 CalculateCheckSum64 (
3211 IN CONST UINT64
*Buffer
,
3216 // Base Library CPU Functions
3220 (EFIAPI
*SWITCH_STACK_ENTRY_POINT
) (
3221 IN VOID
*Context1
, OPTIONAL
3222 IN VOID
*Context2 OPTIONAL
3226 Used to serialize load and store operations.
3228 All loads and stores that proceed calls to this function are guaranteed to be
3229 globally visible when this function returns.
3239 Saves the current CPU context that can be restored with a call to LongJump()
3242 Saves the current CPU context in the buffer specified by JumpBuffer and
3243 returns 0. The initial call to SetJump() must always return 0. Subsequent
3244 calls to LongJump() cause a non-zero value to be returned by SetJump().
3246 If JumpBuffer is NULL, then ASSERT().
3247 For IPF CPUs, if JumpBuffer is not aligned on a 16-byte boundary, then ASSERT().
3249 @param JumpBuffer A pointer to CPU context buffer.
3251 @retval 0 Indicates a return from SetJump().
3257 OUT BASE_LIBRARY_JUMP_BUFFER
*JumpBuffer
3261 Restores the CPU context that was saved with SetJump().
3263 Restores the CPU context from the buffer specified by JumpBuffer. This
3264 function never returns to the caller. Instead is resumes execution based on
3265 the state of JumpBuffer.
3267 If JumpBuffer is NULL, then ASSERT().
3268 For IPF CPUs, if JumpBuffer is not aligned on a 16-byte boundary, then ASSERT().
3269 If Value is 0, then ASSERT().
3271 @param JumpBuffer A pointer to CPU context buffer.
3272 @param Value The value to return when the SetJump() context is
3273 restored and must be non-zero.
3279 IN BASE_LIBRARY_JUMP_BUFFER
*JumpBuffer
,
3284 Enables CPU interrupts.
3286 Enables CPU interrupts.
3296 Disables CPU interrupts.
3298 Disables CPU interrupts.
3308 Disables CPU interrupts and returns the interrupt state prior to the disable
3311 Disables CPU interrupts and returns the interrupt state prior to the disable
3314 @retval TRUE CPU interrupts were enabled on entry to this call.
3315 @retval FALSE CPU interrupts were disabled on entry to this call.
3320 SaveAndDisableInterrupts (
3325 Enables CPU interrupts for the smallest window required to capture any
3328 Enables CPU interrupts for the smallest window required to capture any
3334 EnableDisableInterrupts (
3339 Retrieves the current CPU interrupt state.
3341 Retrieves the current CPU interrupt state. Returns TRUE is interrupts are
3342 currently enabled. Otherwise returns FALSE.
3344 @retval TRUE CPU interrupts are enabled.
3345 @retval FALSE CPU interrupts are disabled.
3355 Set the current CPU interrupt state.
3357 Sets the current CPU interrupt state to the state specified by
3358 InterruptState. If InterruptState is TRUE, then interrupts are enabled. If
3359 InterruptState is FALSE, then interrupts are disabled. InterruptState is
3362 @param InterruptState TRUE if interrupts should enabled. FALSE if
3363 interrupts should be disabled.
3365 @return InterruptState
3371 IN BOOLEAN InterruptState
3375 Places the CPU in a sleep state until an interrupt is received.
3377 Places the CPU in a sleep state until an interrupt is received. If interrupts
3378 are disabled prior to calling this function, then the CPU will be placed in a
3379 sleep state indefinitely.
3389 Requests CPU to pause for a short period of time.
3391 Requests CPU to pause for a short period of time. Typically used in MP
3392 systems to prevent memory starvation while waiting for a spin lock.
3402 Flushes all the Translation Lookaside Buffers(TLB) entries in a CPU.
3404 Flushes all the Translation Lookaside Buffers(TLB) entries in a CPU.
3414 Transfers control to a function starting with a new stack.
3416 Transfers control to the function specified by EntryPoint using the new stack
3417 specified by NewStack and passing in the parameters specified by Context1 and
3418 Context2. Context1 and Context2 are optional and may be NULL. The function
3419 EntryPoint must never return.
3421 If EntryPoint is NULL, then ASSERT().
3422 If NewStack is NULL, then ASSERT().
3424 @param EntryPoint A pointer to function to call with the new stack.
3425 @param Context1 A pointer to the context to pass into the EntryPoint
3427 @param Context2 A pointer to the context to pass into the EntryPoint
3429 @param NewStack A pointer to the new stack to use for the EntryPoint
3436 IN SWITCH_STACK_ENTRY_POINT EntryPoint
,
3437 IN VOID
*Context1
, OPTIONAL
3438 IN VOID
*Context2
, OPTIONAL
3443 Generates a breakpoint on the CPU.
3445 Generates a breakpoint on the CPU. The breakpoint must be implemented such
3446 that code can resume normal execution after the breakpoint.
3456 Executes an infinite loop.
3458 Forces the CPU to execute an infinite loop. A debugger may be used to skip
3459 past the loop and the code that follows the loop must execute properly. This
3460 implies that the infinite loop must not cause the code that follow it to be
3471 // IA32 and X64 Specific Functions
3474 // Byte packed structure for 16-bit Real Mode EFLAGS
3478 UINT32 CF
:1; // Carry Flag
3479 UINT32 Reserved_0
:1; // Reserved
3480 UINT32 PF
:1; // Parity Flag
3481 UINT32 Reserved_1
:1; // Reserved
3482 UINT32 AF
:1; // Auxiliary Carry Flag
3483 UINT32 Reserved_2
:1; // Reserved
3484 UINT32 ZF
:1; // Zero Flag
3485 UINT32 SF
:1; // Sign Flag
3486 UINT32 TF
:1; // Trap Flag
3487 UINT32 IF
:1; // Interrupt Enable Flag
3488 UINT32 DF
:1; // Direction Flag
3489 UINT32 OF
:1; // Overflow Flag
3490 UINT32 IOPL
:2; // I/O Privilege Level
3491 UINT32 NT
:1; // Nested Task
3492 UINT32 Reserved_3
:1; // Reserved
3498 // Byte packed structure for EFLAGS/RFLAGS
3500 // 64-bits on X64. The upper 32-bits on X64 are reserved
3504 UINT32 CF
:1; // Carry Flag
3505 UINT32 Reserved_0
:1; // Reserved
3506 UINT32 PF
:1; // Parity Flag
3507 UINT32 Reserved_1
:1; // Reserved
3508 UINT32 AF
:1; // Auxiliary Carry Flag
3509 UINT32 Reserved_2
:1; // Reserved
3510 UINT32 ZF
:1; // Zero Flag
3511 UINT32 SF
:1; // Sign Flag
3512 UINT32 TF
:1; // Trap Flag
3513 UINT32 IF
:1; // Interrupt Enable Flag
3514 UINT32 DF
:1; // Direction Flag
3515 UINT32 OF
:1; // Overflow Flag
3516 UINT32 IOPL
:2; // I/O Privilege Level
3517 UINT32 NT
:1; // Nested Task
3518 UINT32 Reserved_3
:1; // Reserved
3519 UINT32 RF
:1; // Resume Flag
3520 UINT32 VM
:1; // Virtual 8086 Mode
3521 UINT32 AC
:1; // Alignment Check
3522 UINT32 VIF
:1; // Virtual Interrupt Flag
3523 UINT32 VIP
:1; // Virtual Interrupt Pending
3524 UINT32 ID
:1; // ID Flag
3525 UINT32 Reserved_4
:10; // Reserved
3531 // Byte packed structure for Control Register 0 (CR0)
3533 // 64-bits on X64. The upper 32-bits on X64 are reserved
3537 UINT32 PE
:1; // Protection Enable
3538 UINT32 MP
:1; // Monitor Coprocessor
3539 UINT32 EM
:1; // Emulation
3540 UINT32 TS
:1; // Task Switched
3541 UINT32 ET
:1; // Extension Type
3542 UINT32 NE
:1; // Numeric Error
3543 UINT32 Reserved_0
:10; // Reserved
3544 UINT32 WP
:1; // Write Protect
3545 UINT32 Reserved_1
:1; // Reserved
3546 UINT32 AM
:1; // Alignment Mask
3547 UINT32 Reserved_2
:10; // Reserved
3548 UINT32 NW
:1; // Mot Write-through
3549 UINT32 CD
:1; // Cache Disable
3550 UINT32 PG
:1; // Paging
3556 // Byte packed structure for Control Register 4 (CR4)
3558 // 64-bits on X64. The upper 32-bits on X64 are reserved
3562 UINT32 VME
:1; // Virtual-8086 Mode Extensions
3563 UINT32 PVI
:1; // Protected-Mode Virtual Interrupts
3564 UINT32 TSD
:1; // Time Stamp Disable
3565 UINT32 DE
:1; // Debugging Extensions
3566 UINT32 PSE
:1; // Page Size Extensions
3567 UINT32 PAE
:1; // Physical Address Extension
3568 UINT32 MCE
:1; // Machine Check Enable
3569 UINT32 PGE
:1; // Page Global Enable
3570 UINT32 PCE
:1; // Performance Monitoring Counter
3572 UINT32 OSFXSR
:1; // Operating System Support for
3573 // FXSAVE and FXRSTOR instructions
3574 UINT32 OSXMMEXCPT
:1; // Operating System Support for
3575 // Unmasked SIMD Floating Point
3577 UINT32 Reserved_0
:2; // Reserved
3578 UINT32 VMXE
:1; // VMX Enable
3579 UINT32 Reserved_1
:18; // Reseved
3585 // Byte packed structure for an IDTR, GDTR, LDTR descriptor
3586 /// @bug How to make this structure byte-packed in a compiler independent way?
3595 #define IA32_IDT_GATE_TYPE_TASK 0x85
3596 #define IA32_IDT_GATE_TYPE_INTERRUPT_16 0x86
3597 #define IA32_IDT_GATE_TYPE_TRAP_16 0x87
3598 #define IA32_IDT_GATE_TYPE_INTERRUPT_32 0x8E
3599 #define IA32_IDT_GATE_TYPE_TRAP_32 0x8F
3602 // Byte packed structure for an Interrupt Gate Descriptor
3606 UINT32 OffsetLow
:16; // Offset bits 15..0
3607 UINT32 Selector
:16; // Selector
3608 UINT32 Reserved_0
:8; // Reserved
3609 UINT32 GateType
:8; // Gate Type. See #defines above
3610 UINT32 OffsetHigh
:16; // Offset bits 31..16
3613 } IA32_IDT_GATE_DESCRIPTOR
;
3616 // Byte packed structure for an FP/SSE/SSE2 context
3623 // Structures for the 16-bit real mode thunks
3676 IA32_EFLAGS32 EFLAGS
;
3686 } IA32_REGISTER_SET
;
3689 // Byte packed structure for an 16-bit real mode thunks
3692 IA32_REGISTER_SET
*RealModeState
;
3693 VOID
*RealModeBuffer
;
3694 UINT32 RealModeBufferSize
;
3695 UINT32 ThunkAttributes
;
3698 #define THUNK_ATTRIBUTE_BIG_REAL_MODE 0x00000001
3699 #define THUNK_ATTRIBUTE_DISABLE_A20_MASK_INT_15 0x00000002
3700 #define THUNK_ATTRIBUTE_DISABLE_A20_MASK_KBD_CTRL 0x00000004
3703 Retrieves CPUID information.
3705 Executes the CPUID instruction with EAX set to the value specified by Index.
3706 This function always returns Index.
3707 If Eax is not NULL, then the value of EAX after CPUID is returned in Eax.
3708 If Ebx is not NULL, then the value of EBX after CPUID is returned in Ebx.
3709 If Ecx is not NULL, then the value of ECX after CPUID is returned in Ecx.
3710 If Edx is not NULL, then the value of EDX after CPUID is returned in Edx.
3711 This function is only available on IA-32 and X64.
3713 @param Index The 32-bit value to load into EAX prior to invoking the CPUID
3715 @param Eax Pointer to the 32-bit EAX value returned by the CPUID
3716 instruction. This is an optional parameter that may be NULL.
3717 @param Ebx Pointer to the 32-bit EBX value returned by the CPUID
3718 instruction. This is an optional parameter that may be NULL.
3719 @param Ecx Pointer to the 32-bit ECX value returned by the CPUID
3720 instruction. This is an optional parameter that may be NULL.
3721 @param Edx Pointer to the 32-bit EDX value returned by the CPUID
3722 instruction. This is an optional parameter that may be NULL.
3731 OUT UINT32
*Eax
, OPTIONAL
3732 OUT UINT32
*Ebx
, OPTIONAL
3733 OUT UINT32
*Ecx
, OPTIONAL
3734 OUT UINT32
*Edx OPTIONAL
3738 Retrieves CPUID information using an extended leaf identifier.
3740 Executes the CPUID instruction with EAX set to the value specified by Index
3741 and ECX set to the value specified by SubIndex. This function always returns
3742 Index. This function is only available on IA-32 and x64.
3744 If Eax is not NULL, then the value of EAX after CPUID is returned in Eax.
3745 If Ebx is not NULL, then the value of EBX after CPUID is returned in Ebx.
3746 If Ecx is not NULL, then the value of ECX after CPUID is returned in Ecx.
3747 If Edx is not NULL, then the value of EDX after CPUID is returned in Edx.
3749 @param Index The 32-bit value to load into EAX prior to invoking the
3751 @param SubIndex The 32-bit value to load into ECX prior to invoking the
3753 @param Eax Pointer to the 32-bit EAX value returned by the CPUID
3754 instruction. This is an optional parameter that may be
3756 @param Ebx Pointer to the 32-bit EBX value returned by the CPUID
3757 instruction. This is an optional parameter that may be
3759 @param Ecx Pointer to the 32-bit ECX value returned by the CPUID
3760 instruction. This is an optional parameter that may be
3762 @param Edx Pointer to the 32-bit EDX value returned by the CPUID
3763 instruction. This is an optional parameter that may be
3774 OUT UINT32
*Eax
, OPTIONAL
3775 OUT UINT32
*Ebx
, OPTIONAL
3776 OUT UINT32
*Ecx
, OPTIONAL
3777 OUT UINT32
*Edx OPTIONAL
3781 Returns the lower 32-bits of a Machine Specific Register(MSR).
3783 Reads and returns the lower 32-bits of the MSR specified by Index.
3784 No parameter checking is performed on Index, and some Index values may cause
3785 CPU exceptions. The caller must either guarantee that Index is valid, or the
3786 caller must set up exception handlers to catch the exceptions. This function
3787 is only available on IA-32 and X64.
3789 @param Index The 32-bit MSR index to read.
3791 @return The lower 32 bits of the MSR identified by Index.
3801 Zero-extend a 32-bit value and writes it to a Machine Specific Register(MSR).
3803 Writes the 32-bit value specified by Value to the MSR specified by Index. The
3804 upper 32-bits of the MSR write are set to zero. The 32-bit value written to
3805 the MSR is returned. No parameter checking is performed on Index or Value,
3806 and some of these may cause CPU exceptions. The caller must either guarantee
3807 that Index and Value are valid, or the caller must establish proper exception
3808 handlers. This function is only available on IA-32 and X64.
3810 @param Index The 32-bit MSR index to write.
3811 @param Value The 32-bit value to write to the MSR.
3824 Reads a 64-bit MSR, performs a bitwise inclusive OR on the lower 32-bits, and
3825 writes the result back to the 64-bit MSR.
3827 Reads the 64-bit MSR specified by Index, performs a bitwise inclusive OR
3828 between the lower 32-bits of the read result and the value specified by
3829 OrData, and writes the result to the 64-bit MSR specified by Index. The lower
3830 32-bits of the value written to the MSR is returned. No parameter checking is
3831 performed on Index or OrData, and some of these may cause CPU exceptions. The
3832 caller must either guarantee that Index and OrData are valid, or the caller
3833 must establish proper exception handlers. This function is only available on
3836 @param Index The 32-bit MSR index to write.
3837 @param OrData The value to OR with the read value from the MSR.
3839 @return The lower 32-bit value written to the MSR.
3850 Reads a 64-bit MSR, performs a bitwise AND on the lower 32-bits, and writes
3851 the result back to the 64-bit MSR.
3853 Reads the 64-bit MSR specified by Index, performs a bitwise AND between the
3854 lower 32-bits of the read result and the value specified by AndData, and
3855 writes the result to the 64-bit MSR specified by Index. The lower 32-bits of
3856 the value written to the MSR is returned. No parameter checking is performed
3857 on Index or AndData, and some of these may cause CPU exceptions. The caller
3858 must either guarantee that Index and AndData are valid, or the caller must
3859 establish proper exception handlers. This function is only available on IA-32
3862 @param Index The 32-bit MSR index to write.
3863 @param AndData The value to AND with the read value from the MSR.
3865 @return The lower 32-bit value written to the MSR.
3876 Reads a 64-bit MSR, performs a bitwise AND followed by a bitwise inclusive OR
3877 on the lower 32-bits, and writes the result back to the 64-bit MSR.
3879 Reads the 64-bit MSR specified by Index, performs a bitwise AND between the
3880 lower 32-bits of the read result and the value specified by AndData
3881 preserving the upper 32-bits, performs a bitwise inclusive OR between the
3882 result of the AND operation and the value specified by OrData, and writes the
3883 result to the 64-bit MSR specified by Address. The lower 32-bits of the value
3884 written to the MSR is returned. No parameter checking is performed on Index,
3885 AndData, or OrData, and some of these may cause CPU exceptions. The caller
3886 must either guarantee that Index, AndData, and OrData are valid, or the
3887 caller must establish proper exception handlers. This function is only
3888 available on IA-32 and X64.
3890 @param Index The 32-bit MSR index to write.
3891 @param AndData The value to AND with the read value from the MSR.
3892 @param OrData The value to OR with the result of the AND operation.
3894 @return The lower 32-bit value written to the MSR.
3906 Reads a bit field of an MSR.
3908 Reads the bit field in the lower 32-bits of a 64-bit MSR. The bit field is
3909 specified by the StartBit and the EndBit. The value of the bit field is
3910 returned. The caller must either guarantee that Index is valid, or the caller
3911 must set up exception handlers to catch the exceptions. This function is only
3912 available on IA-32 and X64.
3914 If StartBit is greater than 31, then ASSERT().
3915 If EndBit is greater than 31, then ASSERT().
3916 If EndBit is less than StartBit, then ASSERT().
3918 @param Index The 32-bit MSR index to read.
3919 @param StartBit The ordinal of the least significant bit in the bit field.
3921 @param EndBit The ordinal of the most significant bit in the bit field.
3924 @return The bit field read from the MSR.
3929 AsmMsrBitFieldRead32 (
3936 Writes a bit field to an MSR.
3938 Writes Value to a bit field in the lower 32-bits of a 64-bit MSR. The bit
3939 field is specified by the StartBit and the EndBit. All other bits in the
3940 destination MSR are preserved. The lower 32-bits of the MSR written is
3941 returned. Extra left bits in Value are stripped. The caller must either
3942 guarantee that Index and the data written is valid, or the caller must set up
3943 exception handlers to catch the exceptions. This function is only available
3946 If StartBit is greater than 31, then ASSERT().
3947 If EndBit is greater than 31, then ASSERT().
3948 If EndBit is less than StartBit, then ASSERT().
3950 @param Index The 32-bit MSR index to write.
3951 @param StartBit The ordinal of the least significant bit in the bit field.
3953 @param EndBit The ordinal of the most significant bit in the bit field.
3955 @param Value New value of the bit field.
3957 @return The lower 32-bit of the value written to the MSR.
3962 AsmMsrBitFieldWrite32 (
3970 Reads a bit field in a 64-bit MSR, performs a bitwise OR, and writes the
3971 result back to the bit field in the 64-bit MSR.
3973 Reads the 64-bit MSR specified by Index, performs a bitwise inclusive OR
3974 between the read result and the value specified by OrData, and writes the
3975 result to the 64-bit MSR specified by Index. The lower 32-bits of the value
3976 written to the MSR are returned. Extra left bits in OrData are stripped. The
3977 caller must either guarantee that Index and the data written is valid, or
3978 the caller must set up exception handlers to catch the exceptions. This
3979 function is only available on IA-32 and X64.
3981 If StartBit is greater than 31, then ASSERT().
3982 If EndBit is greater than 31, then ASSERT().
3983 If EndBit is less than StartBit, then ASSERT().
3985 @param Index The 32-bit MSR index to write.
3986 @param StartBit The ordinal of the least significant bit in the bit field.
3988 @param EndBit The ordinal of the most significant bit in the bit field.
3990 @param OrData The value to OR with the read value from the MSR.
3992 @return The lower 32-bit of the value written to the MSR.
3997 AsmMsrBitFieldOr32 (
4005 Reads a bit field in a 64-bit MSR, performs a bitwise AND, and writes the
4006 result back to the bit field in the 64-bit MSR.
4008 Reads the 64-bit MSR specified by Index, performs a bitwise AND between the
4009 read result and the value specified by AndData, and writes the result to the
4010 64-bit MSR specified by Index. The lower 32-bits of the value written to the
4011 MSR are returned. Extra left bits in AndData are stripped. The caller must
4012 either guarantee that Index and the data written is valid, or the caller must
4013 set up exception handlers to catch the exceptions. This function is only
4014 available on IA-32 and X64.
4016 If StartBit is greater than 31, then ASSERT().
4017 If EndBit is greater than 31, then ASSERT().
4018 If EndBit is less than StartBit, then ASSERT().
4020 @param Index The 32-bit MSR index to write.
4021 @param StartBit The ordinal of the least significant bit in the bit field.
4023 @param EndBit The ordinal of the most significant bit in the bit field.
4025 @param AndData The value to AND with the read value from the MSR.
4027 @return The lower 32-bit of the value written to the MSR.
4032 AsmMsrBitFieldAnd32 (
4040 Reads a bit field in a 64-bit MSR, performs a bitwise AND followed by a
4041 bitwise inclusive OR, and writes the result back to the bit field in the
4044 Reads the 64-bit MSR specified by Index, performs a bitwise AND followed by a
4045 bitwise inclusive OR between the read result and the value specified by
4046 AndData, and writes the result to the 64-bit MSR specified by Index. The
4047 lower 32-bits of the value written to the MSR are returned. Extra left bits
4048 in both AndData and OrData are stripped. The caller must either guarantee
4049 that Index and the data written is valid, or the caller must set up exception
4050 handlers to catch the exceptions. This function is only available on IA-32
4053 If StartBit is greater than 31, then ASSERT().
4054 If EndBit is greater than 31, then ASSERT().
4055 If EndBit is less than StartBit, then ASSERT().
4057 @param Index The 32-bit MSR index to write.
4058 @param StartBit The ordinal of the least significant bit in the bit field.
4060 @param EndBit The ordinal of the most significant bit in the bit field.
4062 @param AndData The value to AND with the read value from the MSR.
4063 @param OrData The value to OR with the result of the AND operation.
4065 @return The lower 32-bit of the value written to the MSR.
4070 AsmMsrBitFieldAndThenOr32 (
4079 Returns a 64-bit Machine Specific Register(MSR).
4081 Reads and returns the 64-bit MSR specified by Index. No parameter checking is
4082 performed on Index, and some Index values may cause CPU exceptions. The
4083 caller must either guarantee that Index is valid, or the caller must set up
4084 exception handlers to catch the exceptions. This function is only available
4087 @param Index The 32-bit MSR index to read.
4089 @return The value of the MSR identified by Index.
4099 Writes a 64-bit value to a Machine Specific Register(MSR), and returns the
4102 Writes the 64-bit value specified by Value to the MSR specified by Index. The
4103 64-bit value written to the MSR is returned. No parameter checking is
4104 performed on Index or Value, and some of these may cause CPU exceptions. The
4105 caller must either guarantee that Index and Value are valid, or the caller
4106 must establish proper exception handlers. This function is only available on
4109 @param Index The 32-bit MSR index to write.
4110 @param Value The 64-bit value to write to the MSR.
4123 Reads a 64-bit MSR, performs a bitwise inclusive OR, and writes the result
4124 back to the 64-bit MSR.
4126 Reads the 64-bit MSR specified by Index, performs a bitwise inclusive OR
4127 between the read result and the value specified by OrData, and writes the
4128 result to the 64-bit MSR specified by Index. The value written to the MSR is
4129 returned. No parameter checking is performed on Index or OrData, and some of
4130 these may cause CPU exceptions. The caller must either guarantee that Index
4131 and OrData are valid, or the caller must establish proper exception handlers.
4132 This function is only available on IA-32 and X64.
4134 @param Index The 32-bit MSR index to write.
4135 @param OrData The value to OR with the read value from the MSR.
4137 @return The value written back to the MSR.
4148 Reads a 64-bit MSR, performs a bitwise AND, and writes the result back to the
4151 Reads the 64-bit MSR specified by Index, performs a bitwise AND between the
4152 read result and the value specified by OrData, and writes the result to the
4153 64-bit MSR specified by Index. The value written to the MSR is returned. No
4154 parameter checking is performed on Index or OrData, and some of these may
4155 cause CPU exceptions. The caller must either guarantee that Index and OrData
4156 are valid, or the caller must establish proper exception handlers. This
4157 function is only available on IA-32 and X64.
4159 @param Index The 32-bit MSR index to write.
4160 @param AndData The value to AND with the read value from the MSR.
4162 @return The value written back to the MSR.
4173 Reads a 64-bit MSR, performs a bitwise AND followed by a bitwise inclusive
4174 OR, and writes the result back to the 64-bit MSR.
4176 Reads the 64-bit MSR specified by Index, performs a bitwise AND between read
4177 result and the value specified by AndData, performs a bitwise inclusive OR
4178 between the result of the AND operation and the value specified by OrData,
4179 and writes the result to the 64-bit MSR specified by Index. The value written
4180 to the MSR is returned. No parameter checking is performed on Index, AndData,
4181 or OrData, and some of these may cause CPU exceptions. The caller must either
4182 guarantee that Index, AndData, and OrData are valid, or the caller must
4183 establish proper exception handlers. This function is only available on IA-32
4186 @param Index The 32-bit MSR index to write.
4187 @param AndData The value to AND with the read value from the MSR.
4188 @param OrData The value to OR with the result of the AND operation.
4190 @return The value written back to the MSR.
4202 Reads a bit field of an MSR.
4204 Reads the bit field in the 64-bit MSR. The bit field is specified by the
4205 StartBit and the EndBit. The value of the bit field is returned. The caller
4206 must either guarantee that Index is valid, or the caller must set up
4207 exception handlers to catch the exceptions. This function is only available
4210 If StartBit is greater than 63, then ASSERT().
4211 If EndBit is greater than 63, then ASSERT().
4212 If EndBit is less than StartBit, then ASSERT().
4214 @param Index The 32-bit MSR index to read.
4215 @param StartBit The ordinal of the least significant bit in the bit field.
4217 @param EndBit The ordinal of the most significant bit in the bit field.
4220 @return The value read from the MSR.
4225 AsmMsrBitFieldRead64 (
4232 Writes a bit field to an MSR.
4234 Writes Value to a bit field in a 64-bit MSR. The bit field is specified by
4235 the StartBit and the EndBit. All other bits in the destination MSR are
4236 preserved. The MSR written is returned. Extra left bits in Value are
4237 stripped. The caller must either guarantee that Index and the data written is
4238 valid, or the caller must set up exception handlers to catch the exceptions.
4239 This function is only available on IA-32 and X64.
4241 If StartBit is greater than 63, then ASSERT().
4242 If EndBit is greater than 63, then ASSERT().
4243 If EndBit is less than StartBit, then ASSERT().
4245 @param Index The 32-bit MSR index to write.
4246 @param StartBit The ordinal of the least significant bit in the bit field.
4248 @param EndBit The ordinal of the most significant bit in the bit field.
4250 @param Value New value of the bit field.
4252 @return The value written back to the MSR.
4257 AsmMsrBitFieldWrite64 (
4265 Reads a bit field in a 64-bit MSR, performs a bitwise inclusive OR, and
4266 writes the result back to the bit field in the 64-bit MSR.
4268 Reads the 64-bit MSR specified by Index, performs a bitwise inclusive OR
4269 between the read result and the value specified by OrData, and writes the
4270 result to the 64-bit MSR specified by Index. The value written to the MSR is
4271 returned. Extra left bits in OrData are stripped. The caller must either
4272 guarantee that Index and the data written is valid, or the caller must set up
4273 exception handlers to catch the exceptions. This function is only available
4276 If StartBit is greater than 63, then ASSERT().
4277 If EndBit is greater than 63, then ASSERT().
4278 If EndBit is less than StartBit, then ASSERT().
4280 @param Index The 32-bit MSR index to write.
4281 @param StartBit The ordinal of the least significant bit in the bit field.
4283 @param EndBit The ordinal of the most significant bit in the bit field.
4285 @param OrData The value to OR with the read value from the bit field.
4287 @return The value written back to the MSR.
4292 AsmMsrBitFieldOr64 (
4300 Reads a bit field in a 64-bit MSR, performs a bitwise AND, and writes the
4301 result back to the bit field in the 64-bit MSR.
4303 Reads the 64-bit MSR specified by Index, performs a bitwise AND between the
4304 read result and the value specified by AndData, and writes the result to the
4305 64-bit MSR specified by Index. The value written to the MSR is returned.
4306 Extra left bits in AndData are stripped. The caller must either guarantee
4307 that Index and the data written is valid, or the caller must set up exception
4308 handlers to catch the exceptions. This function is only available on IA-32
4311 If StartBit is greater than 63, then ASSERT().
4312 If EndBit is greater than 63, then ASSERT().
4313 If EndBit is less than StartBit, then ASSERT().
4315 @param Index The 32-bit MSR index to write.
4316 @param StartBit The ordinal of the least significant bit in the bit field.
4318 @param EndBit The ordinal of the most significant bit in the bit field.
4320 @param AndData The value to AND with the read value from the bit field.
4322 @return The value written back to the MSR.
4327 AsmMsrBitFieldAnd64 (
4335 Reads a bit field in a 64-bit MSR, performs a bitwise AND followed by a
4336 bitwise inclusive OR, and writes the result back to the bit field in the
4339 Reads the 64-bit MSR specified by Index, performs a bitwise AND followed by
4340 a bitwise inclusive OR between the read result and the value specified by
4341 AndData, and writes the result to the 64-bit MSR specified by Index. The
4342 value written to the MSR is returned. Extra left bits in both AndData and
4343 OrData are stripped. The caller must either guarantee that Index and the data
4344 written is valid, or the caller must set up exception handlers to catch the
4345 exceptions. This function is only available on IA-32 and X64.
4347 If StartBit is greater than 63, then ASSERT().
4348 If EndBit is greater than 63, then ASSERT().
4349 If EndBit is less than StartBit, then ASSERT().
4351 @param Index The 32-bit MSR index to write.
4352 @param StartBit The ordinal of the least significant bit in the bit field.
4354 @param EndBit The ordinal of the most significant bit in the bit field.
4356 @param AndData The value to AND with the read value from the bit field.
4357 @param OrData The value to OR with the result of the AND operation.
4359 @return The value written back to the MSR.
4364 AsmMsrBitFieldAndThenOr64 (
4373 Reads the current value of the EFLAGS register.
4375 Reads and returns the current value of the EFLAGS register. This function is
4376 only available on IA-32 and X64. This returns a 32-bit value on IA-32 and a
4377 64-bit value on X64.
4379 @return EFLAGS on IA-32 or RFLAGS on X64.
4389 Reads the current value of the Control Register 0 (CR0).
4391 Reads and returns the current value of CR0. This function is only available
4392 on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on
4395 @return The value of the Control Register 0 (CR0).
4405 Reads the current value of the Control Register 2 (CR2).
4407 Reads and returns the current value of CR2. This function is only available
4408 on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on
4411 @return The value of the Control Register 2 (CR2).
4421 Reads the current value of the Control Register 3 (CR3).
4423 Reads and returns the current value of CR3. This function is only available
4424 on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on
4427 @return The value of the Control Register 3 (CR3).
4437 Reads the current value of the Control Register 4 (CR4).
4439 Reads and returns the current value of CR4. This function is only available
4440 on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on
4443 @return The value of the Control Register 4 (CR4).
4453 Writes a value to Control Register 0 (CR0).
4455 Writes and returns a new value to CR0. This function is only available on
4456 IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.
4458 @param Cr0 The value to write to CR0.
4460 @return The value written to CR0.
4470 Writes a value to Control Register 2 (CR2).
4472 Writes and returns a new value to CR2. This function is only available on
4473 IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.
4475 @param Cr2 The value to write to CR2.
4477 @return The value written to CR2.
4487 Writes a value to Control Register 3 (CR3).
4489 Writes and returns a new value to CR3. This function is only available on
4490 IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.
4492 @param Cr3 The value to write to CR3.
4494 @return The value written to CR3.
4504 Writes a value to Control Register 4 (CR4).
4506 Writes and returns a new value to CR4. This function is only available on
4507 IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.
4509 @param Cr4 The value to write to CR4.
4511 @return The value written to CR4.
4521 Reads the current value of Debug Register 0 (DR0).
4523 Reads and returns the current value of DR0. This function is only available
4524 on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on
4527 @return The value of Debug Register 0 (DR0).
4537 Reads the current value of Debug Register 1 (DR1).
4539 Reads and returns the current value of DR1. This function is only available
4540 on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on
4543 @return The value of Debug Register 1 (DR1).
4553 Reads the current value of Debug Register 2 (DR2).
4555 Reads and returns the current value of DR2. This function is only available
4556 on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on
4559 @return The value of Debug Register 2 (DR2).
4569 Reads the current value of Debug Register 3 (DR3).
4571 Reads and returns the current value of DR3. This function is only available
4572 on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on
4575 @return The value of Debug Register 3 (DR3).
4585 Reads the current value of Debug Register 4 (DR4).
4587 Reads and returns the current value of DR4. This function is only available
4588 on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on
4591 @return The value of Debug Register 4 (DR4).
4601 Reads the current value of Debug Register 5 (DR5).
4603 Reads and returns the current value of DR5. This function is only available
4604 on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on
4607 @return The value of Debug Register 5 (DR5).
4617 Reads the current value of Debug Register 6 (DR6).
4619 Reads and returns the current value of DR6. This function is only available
4620 on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on
4623 @return The value of Debug Register 6 (DR6).
4633 Reads the current value of Debug Register 7 (DR7).
4635 Reads and returns the current value of DR7. This function is only available
4636 on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on
4639 @return The value of Debug Register 7 (DR7).
4649 Writes a value to Debug Register 0 (DR0).
4651 Writes and returns a new value to DR0. This function is only available on
4652 IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.
4654 @param Dr0 The value to write to Dr0.
4656 @return The value written to Debug Register 0 (DR0).
4666 Writes a value to Debug Register 1 (DR1).
4668 Writes and returns a new value to DR1. This function is only available on
4669 IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.
4671 @param Dr1 The value to write to Dr1.
4673 @return The value written to Debug Register 1 (DR1).
4683 Writes a value to Debug Register 2 (DR2).
4685 Writes and returns a new value to DR2. This function is only available on
4686 IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.
4688 @param Dr2 The value to write to Dr2.
4690 @return The value written to Debug Register 2 (DR2).
4700 Writes a value to Debug Register 3 (DR3).
4702 Writes and returns a new value to DR3. This function is only available on
4703 IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.
4705 @param Dr3 The value to write to Dr3.
4707 @return The value written to Debug Register 3 (DR3).
4717 Writes a value to Debug Register 4 (DR4).
4719 Writes and returns a new value to DR4. This function is only available on
4720 IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.
4722 @param Dr4 The value to write to Dr4.
4724 @return The value written to Debug Register 4 (DR4).
4734 Writes a value to Debug Register 5 (DR5).
4736 Writes and returns a new value to DR5. This function is only available on
4737 IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.
4739 @param Dr5 The value to write to Dr5.
4741 @return The value written to Debug Register 5 (DR5).
4751 Writes a value to Debug Register 6 (DR6).
4753 Writes and returns a new value to DR6. This function is only available on
4754 IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.
4756 @param Dr6 The value to write to Dr6.
4758 @return The value written to Debug Register 6 (DR6).
4768 Writes a value to Debug Register 7 (DR7).
4770 Writes and returns a new value to DR7. This function is only available on
4771 IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.
4773 @param Dr7 The value to write to Dr7.
4775 @return The value written to Debug Register 7 (DR7).
4785 Reads the current value of Code Segment Register (CS).
4787 Reads and returns the current value of CS. This function is only available on
4790 @return The current value of CS.
4800 Reads the current value of Data Segment Register (DS).
4802 Reads and returns the current value of DS. This function is only available on
4805 @return The current value of DS.
4815 Reads the current value of Extra Segment Register (ES).
4817 Reads and returns the current value of ES. This function is only available on
4820 @return The current value of ES.
4830 Reads the current value of FS Data Segment Register (FS).
4832 Reads and returns the current value of FS. This function is only available on
4835 @return The current value of FS.
4845 Reads the current value of GS Data Segment Register (GS).
4847 Reads and returns the current value of GS. This function is only available on
4850 @return The current value of GS.
4860 Reads the current value of Stack Segment Register (SS).
4862 Reads and returns the current value of SS. This function is only available on
4865 @return The current value of SS.
4875 Reads the current value of Task Register (TR).
4877 Reads and returns the current value of TR. This function is only available on
4880 @return The current value of TR.
4890 Reads the current Global Descriptor Table Register(GDTR) descriptor.
4892 Reads and returns the current GDTR descriptor and returns it in Gdtr. This
4893 function is only available on IA-32 and X64.
4895 If Gdtr is NULL, then ASSERT().
4897 @param Gdtr Pointer to a GDTR descriptor.
4903 OUT IA32_DESCRIPTOR
*Gdtr
4907 Writes the current Global Descriptor Table Register (GDTR) descriptor.
4909 Writes and the current GDTR descriptor specified by Gdtr. This function is
4910 only available on IA-32 and X64.
4912 If Gdtr is NULL, then ASSERT().
4914 @param Gdtr Pointer to a GDTR descriptor.
4920 IN CONST IA32_DESCRIPTOR
*Gdtr
4924 Reads the current Interrupt Descriptor Table Register(GDTR) descriptor.
4926 Reads and returns the current IDTR descriptor and returns it in Idtr. This
4927 function is only available on IA-32 and X64.
4929 If Idtr is NULL, then ASSERT().
4931 @param Idtr Pointer to a IDTR descriptor.
4937 OUT IA32_DESCRIPTOR
*Idtr
4941 Writes the current Interrupt Descriptor Table Register(GDTR) descriptor.
4943 Writes the current IDTR descriptor and returns it in Idtr. This function is
4944 only available on IA-32 and X64.
4946 If Idtr is NULL, then ASSERT().
4948 @param Idtr Pointer to a IDTR descriptor.
4954 IN CONST IA32_DESCRIPTOR
*Idtr
4958 Reads the current Local Descriptor Table Register(LDTR) selector.
4960 Reads and returns the current 16-bit LDTR descriptor value. This function is
4961 only available on IA-32 and X64.
4963 @return The current selector of LDT.
4973 Writes the current Local Descriptor Table Register (GDTR) selector.
4975 Writes and the current LDTR descriptor specified by Ldtr. This function is
4976 only available on IA-32 and X64.
4978 @param Ldtr 16-bit LDTR selector value.
4988 Save the current floating point/SSE/SSE2 context to a buffer.
4990 Saves the current floating point/SSE/SSE2 state to the buffer specified by
4991 Buffer. Buffer must be aligned on a 16-byte boundary. This function is only
4992 available on IA-32 and X64.
4994 If Buffer is NULL, then ASSERT().
4995 If Buffer is not aligned on a 16-byte boundary, then ASSERT().
4997 @param Buffer Pointer to a buffer to save the floating point/SSE/SSE2 context.
5003 OUT IA32_FX_BUFFER
*Buffer
5007 Restores the current floating point/SSE/SSE2 context from a buffer.
5009 Restores the current floating point/SSE/SSE2 state from the buffer specified
5010 by Buffer. Buffer must be aligned on a 16-byte boundary. This function is
5011 only available on IA-32 and X64.
5013 If Buffer is NULL, then ASSERT().
5014 If Buffer is not aligned on a 16-byte boundary, then ASSERT().
5015 If Buffer was not saved with AsmFxSave(), then ASSERT().
5017 @param Buffer Pointer to a buffer to save the floating point/SSE/SSE2 context.
5023 IN CONST IA32_FX_BUFFER
*Buffer
5027 Reads the current value of 64-bit MMX Register #0 (MM0).
5029 Reads and returns the current value of MM0. This function is only available
5032 @return The current value of MM0.
5042 Reads the current value of 64-bit MMX Register #1 (MM1).
5044 Reads and returns the current value of MM1. This function is only available
5047 @return The current value of MM1.
5057 Reads the current value of 64-bit MMX Register #2 (MM2).
5059 Reads and returns the current value of MM2. This function is only available
5062 @return The current value of MM2.
5072 Reads the current value of 64-bit MMX Register #3 (MM3).
5074 Reads and returns the current value of MM3. This function is only available
5077 @return The current value of MM3.
5087 Reads the current value of 64-bit MMX Register #4 (MM4).
5089 Reads and returns the current value of MM4. This function is only available
5092 @return The current value of MM4.
5102 Reads the current value of 64-bit MMX Register #5 (MM5).
5104 Reads and returns the current value of MM5. This function is only available
5107 @return The current value of MM5.
5117 Reads the current value of 64-bit MMX Register #6 (MM6).
5119 Reads and returns the current value of MM6. This function is only available
5122 @return The current value of MM6.
5132 Reads the current value of 64-bit MMX Register #7 (MM7).
5134 Reads and returns the current value of MM7. This function is only available
5137 @return The current value of MM7.
5147 Writes the current value of 64-bit MMX Register #0 (MM0).
5149 Writes the current value of MM0. This function is only available on IA32 and
5152 @param Value The 64-bit value to write to MM0.
5162 Writes the current value of 64-bit MMX Register #1 (MM1).
5164 Writes the current value of MM1. This function is only available on IA32 and
5167 @param Value The 64-bit value to write to MM1.
5177 Writes the current value of 64-bit MMX Register #2 (MM2).
5179 Writes the current value of MM2. This function is only available on IA32 and
5182 @param Value The 64-bit value to write to MM2.
5192 Writes the current value of 64-bit MMX Register #3 (MM3).
5194 Writes the current value of MM3. This function is only available on IA32 and
5197 @param Value The 64-bit value to write to MM3.
5207 Writes the current value of 64-bit MMX Register #4 (MM4).
5209 Writes the current value of MM4. This function is only available on IA32 and
5212 @param Value The 64-bit value to write to MM4.
5222 Writes the current value of 64-bit MMX Register #5 (MM5).
5224 Writes the current value of MM5. This function is only available on IA32 and
5227 @param Value The 64-bit value to write to MM5.
5237 Writes the current value of 64-bit MMX Register #6 (MM6).
5239 Writes the current value of MM6. This function is only available on IA32 and
5242 @param Value The 64-bit value to write to MM6.
5252 Writes the current value of 64-bit MMX Register #7 (MM7).
5254 Writes the current value of MM7. This function is only available on IA32 and
5257 @param Value The 64-bit value to write to MM7.
5267 Reads the current value of Time Stamp Counter (TSC).
5269 Reads and returns the current value of TSC. This function is only available
5272 @return The current value of TSC
5282 Reads the current value of a Performance Counter (PMC).
5284 Reads and returns the current value of performance counter specified by
5285 Index. This function is only available on IA-32 and X64.
5287 @param Index The 32-bit Performance Counter index to read.
5289 @return The value of the PMC specified by Index.
5299 Sets up a monitor buffer that is used by AsmMwait().
5301 Executes a MONITOR instruction with the register state specified by Eax, Ecx
5302 and Edx. Returns Eax. This function is only available on IA-32 and X64.
5304 @param Eax The value to load into EAX or RAX before executing the MONITOR
5306 @param Ecx The value to load into ECX or RCX before executing the MONITOR
5308 @param Edx The value to load into EDX or RDX before executing the MONITOR
5323 Executes an MWAIT instruction.
5325 Executes an MWAIT instruction with the register state specified by Eax and
5326 Ecx. Returns Eax. This function is only available on IA-32 and X64.
5328 @param Eax The value to load into EAX or RAX before executing the MONITOR
5330 @param Ecx The value to load into ECX or RCX before executing the MONITOR
5344 Executes a WBINVD instruction.
5346 Executes a WBINVD instruction. This function is only available on IA-32 and
5357 Executes a INVD instruction.
5359 Executes a INVD instruction. This function is only available on IA-32 and
5370 Flushes a cache line from all the instruction and data caches within the
5371 coherency domain of the CPU.
5373 Flushed the cache line specified by LinearAddress, and returns LinearAddress.
5374 This function is only available on IA-32 and X64.
5376 @param LinearAddress The address of the cache line to flush. If the CPU is
5377 in a physical addressing mode, then LinearAddress is a
5378 physical address. If the CPU is in a virtual
5379 addressing mode, then LinearAddress is a virtual
5382 @return LinearAddress
5387 IN VOID
*LinearAddress
5391 Enables the 32-bit paging mode on the CPU.
5393 Enables the 32-bit paging mode on the CPU. CR0, CR3, CR4, and the page tables
5394 must be properly initialized prior to calling this service. This function
5395 assumes the current execution mode is 32-bit protected mode. This function is
5396 only available on IA-32. After the 32-bit paging mode is enabled, control is
5397 transferred to the function specified by EntryPoint using the new stack
5398 specified by NewStack and passing in the parameters specified by Context1 and
5399 Context2. Context1 and Context2 are optional and may be NULL. The function
5400 EntryPoint must never return.
5402 If the current execution mode is not 32-bit protected mode, then ASSERT().
5403 If EntryPoint is NULL, then ASSERT().
5404 If NewStack is NULL, then ASSERT().
5406 There are a number of constraints that must be followed before calling this
5408 1) Interrupts must be disabled.
5409 2) The caller must be in 32-bit protected mode with flat descriptors. This
5410 means all descriptors must have a base of 0 and a limit of 4GB.
5411 3) CR0 and CR4 must be compatible with 32-bit protected mode with flat
5413 4) CR3 must point to valid page tables that will be used once the transition
5414 is complete, and those page tables must guarantee that the pages for this
5415 function and the stack are identity mapped.
5417 @param EntryPoint A pointer to function to call with the new stack after
5419 @param Context1 A pointer to the context to pass into the EntryPoint
5420 function as the first parameter after paging is enabled.
5421 @param Context2 A pointer to the context to pass into the EntryPoint
5422 function as the second parameter after paging is enabled.
5423 @param NewStack A pointer to the new stack to use for the EntryPoint
5424 function after paging is enabled.
5430 IN SWITCH_STACK_ENTRY_POINT EntryPoint
,
5431 IN VOID
*Context1
, OPTIONAL
5432 IN VOID
*Context2
, OPTIONAL
5437 Disables the 32-bit paging mode on the CPU.
5439 Disables the 32-bit paging mode on the CPU and returns to 32-bit protected
5440 mode. This function assumes the current execution mode is 32-paged protected
5441 mode. This function is only available on IA-32. After the 32-bit paging mode
5442 is disabled, control is transferred to the function specified by EntryPoint
5443 using the new stack specified by NewStack and passing in the parameters
5444 specified by Context1 and Context2. Context1 and Context2 are optional and
5445 may be NULL. The function EntryPoint must never return.
5447 If the current execution mode is not 32-bit paged mode, then ASSERT().
5448 If EntryPoint is NULL, then ASSERT().
5449 If NewStack is NULL, then ASSERT().
5451 There are a number of constraints that must be followed before calling this
5453 1) Interrupts must be disabled.
5454 2) The caller must be in 32-bit paged mode.
5455 3) CR0, CR3, and CR4 must be compatible with 32-bit paged mode.
5456 4) CR3 must point to valid page tables that guarantee that the pages for
5457 this function and the stack are identity mapped.
5459 @param EntryPoint A pointer to function to call with the new stack after
5461 @param Context1 A pointer to the context to pass into the EntryPoint
5462 function as the first parameter after paging is disabled.
5463 @param Context2 A pointer to the context to pass into the EntryPoint
5464 function as the second parameter after paging is
5466 @param NewStack A pointer to the new stack to use for the EntryPoint
5467 function after paging is disabled.
5472 AsmDisablePaging32 (
5473 IN SWITCH_STACK_ENTRY_POINT EntryPoint
,
5474 IN VOID
*Context1
, OPTIONAL
5475 IN VOID
*Context2
, OPTIONAL
5480 Enables the 64-bit paging mode on the CPU.
5482 Enables the 64-bit paging mode on the CPU. CR0, CR3, CR4, and the page tables
5483 must be properly initialized prior to calling this service. This function
5484 assumes the current execution mode is 32-bit protected mode with flat
5485 descriptors. This function is only available on IA-32. After the 64-bit
5486 paging mode is enabled, control is transferred to the function specified by
5487 EntryPoint using the new stack specified by NewStack and passing in the
5488 parameters specified by Context1 and Context2. Context1 and Context2 are
5489 optional and may be 0. The function EntryPoint must never return.
5491 If the current execution mode is not 32-bit protected mode with flat
5492 descriptors, then ASSERT().
5493 If EntryPoint is 0, then ASSERT().
5494 If NewStack is 0, then ASSERT().
5496 @param Cs The 16-bit selector to load in the CS before EntryPoint
5497 is called. The descriptor in the GDT that this selector
5498 references must be setup for long mode.
5499 @param EntryPoint The 64-bit virtual address of the function to call with
5500 the new stack after paging is enabled.
5501 @param Context1 The 64-bit virtual address of the context to pass into
5502 the EntryPoint function as the first parameter after
5504 @param Context2 The 64-bit virtual address of the context to pass into
5505 the EntryPoint function as the second parameter after
5507 @param NewStack The 64-bit virtual address of the new stack to use for
5508 the EntryPoint function after paging is enabled.
5514 IN UINT16 CodeSelector
,
5515 IN UINT64 EntryPoint
,
5516 IN UINT64 Context1
, OPTIONAL
5517 IN UINT64 Context2
, OPTIONAL
5522 Disables the 64-bit paging mode on the CPU.
5524 Disables the 64-bit paging mode on the CPU and returns to 32-bit protected
5525 mode. This function assumes the current execution mode is 64-paging mode.
5526 This function is only available on X64. After the 64-bit paging mode is
5527 disabled, control is transferred to the function specified by EntryPoint
5528 using the new stack specified by NewStack and passing in the parameters
5529 specified by Context1 and Context2. Context1 and Context2 are optional and
5530 may be 0. The function EntryPoint must never return.
5532 If the current execution mode is not 64-bit paged mode, then ASSERT().
5533 If EntryPoint is 0, then ASSERT().
5534 If NewStack is 0, then ASSERT().
5536 @param Cs The 16-bit selector to load in the CS before EntryPoint
5537 is called. The descriptor in the GDT that this selector
5538 references must be setup for 32-bit protected mode.
5539 @param EntryPoint The 64-bit virtual address of the function to call with
5540 the new stack after paging is disabled.
5541 @param Context1 The 64-bit virtual address of the context to pass into
5542 the EntryPoint function as the first parameter after
5544 @param Context2 The 64-bit virtual address of the context to pass into
5545 the EntryPoint function as the second parameter after
5547 @param NewStack The 64-bit virtual address of the new stack to use for
5548 the EntryPoint function after paging is disabled.
5553 AsmDisablePaging64 (
5554 IN UINT16 CodeSelector
,
5555 IN UINT32 EntryPoint
,
5556 IN UINT32 Context1
, OPTIONAL
5557 IN UINT32 Context2
, OPTIONAL
5562 // 16-bit thunking services
5566 Retrieves the properties for 16-bit thunk functions.
5568 Computes the size of the buffer and stack below 1MB required to use the
5569 AsmPrepareThunk16(), AsmThunk16() and AsmPrepareAndThunk16() functions. This
5570 buffer size is returned in RealModeBufferSize, and the stack size is returned
5571 in ExtraStackSize. If parameters are passed to the 16-bit real mode code,
5572 then the actual minimum stack size is ExtraStackSize plus the maximum number
5573 of bytes that need to be passed to the 16-bit real mode code.
5575 If RealModeBufferSize is NULL, then ASSERT().
5576 If ExtraStackSize is NULL, then ASSERT().
5578 @param RealModeBufferSize A pointer to the size of the buffer below 1MB
5579 required to use the 16-bit thunk functions.
5580 @param ExtraStackSize A pointer to the extra size of stack below 1MB
5581 that the 16-bit thunk functions require for
5582 temporary storage in the transition to and from
5588 AsmGetThunk16Properties (
5589 OUT UINT32
*RealModeBufferSize
,
5590 OUT UINT32
*ExtraStackSize
5594 Prepares all structures a code required to use AsmThunk16().
5596 Prepares all structures and code required to use AsmThunk16().
5598 If ThunkContext is NULL, then ASSERT().
5600 @param ThunkContext A pointer to the context structure that describes the
5601 16-bit real mode code to call.
5607 OUT THUNK_CONTEXT
*ThunkContext
5611 Transfers control to a 16-bit real mode entry point and returns the results.
5613 Transfers control to a 16-bit real mode entry point and returns the results.
5614 AsmPrepareThunk16() must be called with ThunkContext before this function is
5617 If ThunkContext is NULL, then ASSERT().
5618 If AsmPrepareThunk16() was not previously called with ThunkContext, then ASSERT().
5620 @param ThunkContext A pointer to the context structure that describes the
5621 16-bit real mode code to call.
5627 IN OUT THUNK_CONTEXT
*ThunkContext
5631 Prepares all structures and code for a 16-bit real mode thunk, transfers
5632 control to a 16-bit real mode entry point, and returns the results.
5634 Prepares all structures and code for a 16-bit real mode thunk, transfers
5635 control to a 16-bit real mode entry point, and returns the results. If the
5636 caller only need to perform a single 16-bit real mode thunk, then this
5637 service should be used. If the caller intends to make more than one 16-bit
5638 real mode thunk, then it is more efficient if AsmPrepareThunk16() is called
5639 once and AsmThunk16() can be called for each 16-bit real mode thunk.
5641 If ThunkContext is NULL, then ASSERT().
5643 @param ThunkContext A pointer to the context structure that describes the
5644 16-bit real mode code to call.
5649 AsmPrepareAndThunk16 (
5650 IN OUT THUNK_CONTEXT
*ThunkContext
5654 Transfers control to a function starting with a new stack.
5656 Transfers control to the function specified by EntryPoint using the new stack
5657 specified by NewStack and passing in the parameters specified by Context1 and
5658 Context2. Context1 and Context2 are optional and may be NULL. The function
5659 EntryPoint must never return.
5661 If EntryPoint is NULL, then ASSERT().
5662 If NewStack is NULL, then ASSERT().
5664 @param EntryPoint A pointer to function to call with the new stack.
5665 @param Context1 A pointer to the context to pass into the EntryPoint
5667 @param Context2 A pointer to the context to pass into the EntryPoint
5669 @param NewStack A pointer to the new stack to use for the EntryPoint
5671 @param NewBsp A pointer to the new memory location for RSE backing
5677 AsmSwitchStackAndBackingStore (
5678 IN SWITCH_STACK_ENTRY_POINT EntryPoint
,
5679 IN VOID
*Context1
, OPTIONAL
5680 IN VOID
*Context2
, OPTIONAL
5693 // IPF Specific functions
5698 Performs a PAL call using static calling convention.
5700 An internal function to perform a PAL call using static calling convention.
5702 @param PalEntryPoint The entry point address of PAL. The address in ar.kr5
5703 would be used if this parameter were NULL on input.
5704 @param Arg1 The first argument of a PAL call.
5705 @param Arg1 The second argument of a PAL call.
5706 @param Arg1 The third argument of a PAL call.
5707 @param Arg1 The fourth argument of a PAL call.
5709 @return The values returned in r8, r9, r10 and r11.
5714 IN CONST VOID
*PalEntryPoint
,
5723 Returns the current value of ar.itc.
5725 An internal function to return the current value of ar.itc, which is the
5728 @return The currect value of ar.itc
5738 Flush a range of cache lines in the cache coherency domain of the calling
5741 Invalidates the cache lines specified by Address and Length. If Address is
5742 not aligned on a cache line boundary, then entire cache line containing
5743 Address is invalidated. If Address + Length is not aligned on a cache line
5744 boundary, then the entire instruction cache line containing Address + Length
5745 -1 is invalidated. This function may choose to invalidate the entire
5746 instruction cache if that is more efficient than invalidating the specified
5747 range. If Length is 0, the no instruction cache lines are invalidated.
5748 Address is returned.
5750 If Length is greater than (MAX_ADDRESS - Address + 1), then ASSERT().
5752 @param Address The base address of the instruction lines to invalidate. If
5753 the CPU is in a physical addressing mode, then Address is a
5754 physical address. If the CPU is in a virtual addressing mode,
5755 then Address is a virtual address.
5757 @param Length The number of bytes to invalidate from the instruction cache.
5764 IpfFlushCacheRange (