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.
19 // Definitions for architecture specific types
20 // These include SPIN_LOCK and BASE_LIBRARY_JUMP_BUFFER
26 typedef volatile UINTN SPIN_LOCK
;
28 #if defined (MDE_CPU_IA32)
30 // IA32 context buffer used by SetJump() and LongJump()
39 } BASE_LIBRARY_JUMP_BUFFER
;
41 #define BASE_LIBRARY_JUMP_BUFFER_ALIGNMENT 8
43 #elif defined (MDE_CPU_IPF)
46 // IPF context buffer used by SetJump() and LongJump()
81 UINT64 AfterSpillUNAT
;
87 } BASE_LIBRARY_JUMP_BUFFER
;
89 #define BASE_LIBRARY_JUMP_BUFFER_ALIGNMENT 0x10
91 #elif defined (MDE_CPU_X64)
93 // X64 context buffer used by SetJump() and LongJump()
106 } BASE_LIBRARY_JUMP_BUFFER
;
108 #define BASE_LIBRARY_JUMP_BUFFER_ALIGNMENT 8
110 #elif defined (MDE_CPU_EBC)
112 // EBC context buffer used by SetJump() and LongJump()
120 } BASE_LIBRARY_JUMP_BUFFER
;
122 #define BASE_LIBRARY_JUMP_BUFFER_ALIGNMENT 8
125 #error Unknown Processor Type
133 Copies one Null-terminated Unicode string to another Null-terminated Unicode
134 string and returns the new Unicode string.
136 This function copies the contents of the Unicode string Source to the Unicode
137 string Destination, and returns Destination. If Source and Destination
138 overlap, then the results are undefined.
140 If Destination is NULL, then ASSERT().
141 If Destination is not aligned on a 16-bit boundary, then ASSERT().
142 If Source is NULL, then ASSERT().
143 If Source is not aligned on a 16-bit boundary, then ASSERT().
144 If Source and Destination overlap, then ASSERT().
145 If PcdMaximumUnicodeStringLength is not zero, and Source contains more than
146 PcdMaximumUnicodeStringLength Unicode characters not including the
147 Null-terminator, then ASSERT().
149 @param Destination Pointer to a Null-terminated Unicode string.
150 @param Source Pointer to a Null-terminated Unicode string.
158 OUT CHAR16
*Destination
,
159 IN CONST CHAR16
*Source
164 Copies one Null-terminated Unicode string with a maximum length to another
165 Null-terminated Unicode string with a maximum length and returns the new
168 This function copies the contents of the Unicode string Source to the Unicode
169 string Destination, and returns Destination. At most, Length Unicode
170 characters are copied from Source to Destination. If Length is 0, then
171 Destination is returned unmodified. If Length is greater that the number of
172 Unicode characters in Source, then Destination is padded with Null Unicode
173 characters. If Source and Destination overlap, then the results are
176 If Length > 0 and Destination is NULL, then ASSERT().
177 If Length > 0 and Destination is not aligned on a 16-bit boundary, then ASSERT().
178 If Length > 0 and Source is NULL, then ASSERT().
179 If Length > 0 and Source is not aligned on a 16-bit bounadry, then ASSERT().
180 If Source and Destination overlap, then ASSERT().
181 If PcdMaximumUnicodeStringLength is not zero, and Source contains more than
182 PcdMaximumUnicodeStringLength Unicode characters not including the
183 Null-terminator, then ASSERT().
185 @param Destination Pointer to a Null-terminated Unicode string.
186 @param Source Pointer to a Null-terminated Unicode string.
187 @param Length Maximum number of Unicode characters to copy.
195 OUT CHAR16
*Destination
,
196 IN CONST CHAR16
*Source
,
202 Returns the length of a Null-terminated Unicode string.
204 This function returns the number of Unicode characters in the Null-terminated
205 Unicode string specified by String.
207 If String is NULL, then ASSERT().
208 If String is not aligned on a 16-bit boundary, then ASSERT().
209 If PcdMaximumUnicodeStringLength is not zero, and String contains more than
210 PcdMaximumUnicodeStringLength Unicode characters not including the
211 Null-terminator, then ASSERT().
213 @param String Pointer to a Null-terminated Unicode string.
215 @return The length of String.
221 IN CONST CHAR16
*String
226 Returns the size of a Null-terminated Unicode string in bytes, including the
229 This function returns the size, in bytes, of the Null-terminated Unicode
230 string specified by String.
232 If String is NULL, then ASSERT().
233 If String is not aligned on a 16-bit boundary, then ASSERT().
234 If PcdMaximumUnicodeStringLength is not zero, and String contains more than
235 PcdMaximumUnicodeStringLength Unicode characters not including the
236 Null-terminator, then ASSERT().
238 @param String Pointer to a Null-terminated Unicode string.
240 @return The size of String.
246 IN CONST CHAR16
*String
251 Compares two Null-terminated Unicode strings, and returns the difference
252 between the first mismatched Unicode characters.
254 This function compares the Null-terminated Unicode string FirstString to the
255 Null-terminated Unicode string SecondString. If FirstString is identical to
256 SecondString, then 0 is returned. Otherwise, the value returned is the first
257 mismatched Unicode character in SecondString subtracted from the first
258 mismatched Unicode character in FirstString.
260 If FirstString is NULL, then ASSERT().
261 If FirstString is not aligned on a 16-bit boundary, then ASSERT().
262 If SecondString is NULL, then ASSERT().
263 If SecondString is not aligned on a 16-bit boundary, then ASSERT().
264 If PcdMaximumUnicodeStringLength is not zero, and FirstString contains more
265 than PcdMaximumUnicodeStringLength Unicode characters not including the
266 Null-terminator, then ASSERT().
267 If PcdMaximumUnicodeStringLength is not zero, and SecondString contains more
268 than PcdMaximumUnicodeStringLength Unicode characters not including the
269 Null-terminator, then ASSERT().
271 @param FirstString Pointer to a Null-terminated Unicode string.
272 @param SecondString Pointer to a Null-terminated Unicode string.
274 @retval 0 FirstString is identical to SecondString.
275 @retval !=0 FirstString is not identical to SecondString.
281 IN CONST CHAR16
*FirstString
,
282 IN CONST CHAR16
*SecondString
287 Compares two Null-terminated Unicode strings with maximum lengths, and
288 returns the difference between the first mismatched Unicode characters.
290 This function compares the Null-terminated Unicode string FirstString to the
291 Null-terminated Unicode string SecondString. At most, Length Unicode
292 characters will be compared. If Length is 0, then 0 is returned. If
293 FirstString is identical to SecondString, then 0 is returned. Otherwise, the
294 value returned is the first mismatched Unicode character in SecondString
295 subtracted from the first mismatched Unicode character in FirstString.
297 If Length > 0 and FirstString is NULL, then ASSERT().
298 If Length > 0 and FirstString is not aligned on a 16-bit bounadary, then ASSERT().
299 If Length > 0 and SecondString is NULL, then ASSERT().
300 If Length > 0 and SecondString is not aligned on a 16-bit bounadary, then ASSERT().
301 If PcdMaximumUnicodeStringLength is not zero, and FirstString contains more
302 than PcdMaximumUnicodeStringLength Unicode characters not including the
303 Null-terminator, then ASSERT().
304 If PcdMaximumUnicodeStringLength is not zero, and SecondString contains more
305 than PcdMaximumUnicodeStringLength Unicode characters not including the
306 Null-terminator, then ASSERT().
308 @param FirstString Pointer to a Null-terminated Unicode string.
309 @param SecondString Pointer to a Null-terminated Unicode string.
310 @param Length Maximum number of Unicode characters to compare.
312 @retval 0 FirstString is identical to SecondString.
313 @retval !=0 FirstString is not identical to SecondString.
319 IN CONST CHAR16
*FirstString
,
320 IN CONST CHAR16
*SecondString
,
326 Concatenates one Null-terminated Unicode string to another Null-terminated
327 Unicode string, and returns the concatenated Unicode string.
329 This function concatenates two Null-terminated Unicode strings. The contents
330 of Null-terminated Unicode string Source are concatenated to the end of
331 Null-terminated Unicode string Destination. The Null-terminated concatenated
332 Unicode String is returned. If Source and Destination overlap, then the
333 results are undefined.
335 If Destination is NULL, then ASSERT().
336 If Destination is not aligned on a 16-bit bounadary, then ASSERT().
337 If Source is NULL, then ASSERT().
338 If Source is not aligned on a 16-bit bounadary, then ASSERT().
339 If Source and Destination overlap, then ASSERT().
340 If PcdMaximumUnicodeStringLength is not zero, and Destination contains more
341 than PcdMaximumUnicodeStringLength Unicode characters not including the
342 Null-terminator, then ASSERT().
343 If PcdMaximumUnicodeStringLength is not zero, and Source contains more than
344 PcdMaximumUnicodeStringLength Unicode characters not including the
345 Null-terminator, then ASSERT().
346 If PcdMaximumUnicodeStringLength is not zero, and concatenating Destination
347 and Source results in a Unicode string with more than
348 PcdMaximumUnicodeStringLength Unicode characters not including the
349 Null-terminator, then ASSERT().
351 @param Destination Pointer to a Null-terminated Unicode string.
352 @param Source Pointer to a Null-terminated Unicode string.
360 IN OUT CHAR16
*Destination
,
361 IN CONST CHAR16
*Source
366 Concatenates one Null-terminated Unicode string with a maximum length to the
367 end of another Null-terminated Unicode string, and returns the concatenated
370 This function concatenates two Null-terminated Unicode strings. The contents
371 of Null-terminated Unicode string Source are concatenated to the end of
372 Null-terminated Unicode string Destination, and Destination is returned. At
373 most, Length Unicode characters are concatenated from Source to the end of
374 Destination, and Destination is always Null-terminated. If Length is 0, then
375 Destination is returned unmodified. If Source and Destination overlap, then
376 the results are undefined.
378 If Destination is NULL, then ASSERT().
379 If Length > 0 and Destination is not aligned on a 16-bit boundary, then ASSERT().
380 If Length > 0 and Source is NULL, then ASSERT().
381 If Length > 0 and Source is not aligned on a 16-bit boundary, then ASSERT().
382 If Source and Destination overlap, then ASSERT().
383 If PcdMaximumUnicodeStringLength is not zero, and Destination contains more
384 than PcdMaximumUnicodeStringLength Unicode characters not including the
385 Null-terminator, then ASSERT().
386 If PcdMaximumUnicodeStringLength is not zero, and Source contains more than
387 PcdMaximumUnicodeStringLength Unicode characters not including the
388 Null-terminator, then ASSERT().
389 If PcdMaximumUnicodeStringLength is not zero, and concatenating Destination
390 and Source results in a Unicode string with more than
391 PcdMaximumUnicodeStringLength Unicode characters not including the
392 Null-terminator, then ASSERT().
394 @param Destination Pointer to a Null-terminated Unicode string.
395 @param Source Pointer to a Null-terminated Unicode string.
396 @param Length Maximum number of Unicode characters to concatenate from
405 IN OUT CHAR16
*Destination
,
406 IN CONST CHAR16
*Source
,
411 Returns the first occurance of a Null-terminated Unicode sub-string
412 in a Null-terminated Unicode string.
414 This function scans the contents of the Null-terminated Unicode string
415 specified by String and returns the first occurrence of SearchString.
416 If SearchString is not found in String, then NULL is returned. If
417 the length of SearchString is zero, then String is
420 If String is NULL, then ASSERT().
421 If String is not aligned on a 16-bit boundary, then ASSERT().
422 If SearchString is NULL, then ASSERT().
423 If SearchString is not aligned on a 16-bit boundary, then ASSERT().
425 If PcdMaximumUnicodeStringLength is not zero, and SearchString
426 or String contains more than PcdMaximumUnicodeStringLength Unicode
427 characters not including the Null-terminator, then ASSERT().
429 @param String Pointer to a Null-terminated Unicode string.
430 @param SearchString Pointer to a Null-terminated Unicode string to search for.
432 @retval NULL If the SearchString does not appear in String.
433 @retval !NULL If there is a match.
439 IN CONST CHAR16
*String
,
440 IN CONST CHAR16
*SearchString
444 Convert a Null-terminated Unicode decimal string to a value of
447 This function returns a value of type UINTN by interpreting the contents
448 of the Unicode string specified by String as a decimal number. The format
449 of the input Unicode string String is:
451 [spaces] [decimal digits].
453 The valid decimal digit character is in the range [0-9]. The
454 function will ignore the pad space, which includes spaces or
455 tab characters, before [decimal digits]. The running zero in the
456 beginning of [decimal digits] will be ignored. Then, the function
457 stops at the first character that is a not a valid decimal character
458 or a Null-terminator, whichever one comes first.
460 If String is NULL, then ASSERT().
461 If String is not aligned in a 16-bit boundary, then ASSERT().
462 If String has only pad spaces, then 0 is returned.
463 If String has no pad spaces or valid decimal digits,
465 If the number represented by String overflows according
466 to the range defined by UINTN, then ASSERT().
468 If PcdMaximumUnicodeStringLength is not zero, and String contains
469 more than PcdMaximumUnicodeStringLength Unicode characters not including
470 the Null-terminator, then ASSERT().
472 @param String Pointer to a Null-terminated Unicode string.
480 IN CONST CHAR16
*String
484 Convert a Null-terminated Unicode decimal string to a value of
487 This function returns a value of type UINT64 by interpreting the contents
488 of the Unicode string specified by String as a decimal number. The format
489 of the input Unicode string String is:
491 [spaces] [decimal digits].
493 The valid decimal digit character is in the range [0-9]. The
494 function will ignore the pad space, which includes spaces or
495 tab characters, before [decimal digits]. The running zero in the
496 beginning of [decimal digits] will be ignored. Then, the function
497 stops at the first character that is a not a valid decimal character
498 or a Null-terminator, whichever one comes first.
500 If String is NULL, then ASSERT().
501 If String is not aligned in a 16-bit boundary, then ASSERT().
502 If String has only pad spaces, then 0 is returned.
503 If String has no pad spaces or valid decimal digits,
505 If the number represented by String overflows according
506 to the range defined by UINT64, then ASSERT().
508 If PcdMaximumUnicodeStringLength is not zero, and String contains
509 more than PcdMaximumUnicodeStringLength Unicode characters not including
510 the Null-terminator, then ASSERT().
512 @param String Pointer to a Null-terminated Unicode string.
520 IN CONST CHAR16
*String
525 Convert a Null-terminated Unicode hexadecimal string to a value of type UINTN.
527 This function returns a value of type UINTN by interpreting the contents
528 of the Unicode string specified by String as a hexadecimal number.
529 The format of the input Unicode string String is:
531 [spaces][zeros][x][hexadecimal digits].
533 The valid hexadecimal digit character is in the range [0-9], [a-f] and [A-F].
534 The prefix "0x" is optional. Both "x" and "X" is allowed in "0x" prefix.
535 If "x" appears in the input string, it must be prefixed with at least one 0.
536 The function will ignore the pad space, which includes spaces or tab characters,
537 before [zeros], [x] or [hexadecimal digit]. The running zero before [x] or
538 [hexadecimal digit] will be ignored. Then, the decoding starts after [x] or the
539 first valid hexadecimal digit. Then, the function stops at the first character that is
540 a not a valid hexadecimal character or NULL, whichever one comes first.
542 If String is NULL, then ASSERT().
543 If String is not aligned in a 16-bit boundary, then ASSERT().
544 If String has only pad spaces, then zero is returned.
545 If String has no leading pad spaces, leading zeros or valid hexadecimal digits,
546 then zero is returned.
547 If the number represented by String overflows according to the range defined by
548 UINTN, then ASSERT().
550 If PcdMaximumUnicodeStringLength is not zero, and String contains more than
551 PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator,
554 @param String Pointer to a Null-terminated Unicode string.
562 IN CONST CHAR16
*String
567 Convert a Null-terminated Unicode hexadecimal string to a value of type UINT64.
569 This function returns a value of type UINT64 by interpreting the contents
570 of the Unicode string specified by String as a hexadecimal number.
571 The format of the input Unicode string String is
573 [spaces][zeros][x][hexadecimal digits].
575 The valid hexadecimal digit character is in the range [0-9], [a-f] and [A-F].
576 The prefix "0x" is optional. Both "x" and "X" is allowed in "0x" prefix.
577 If "x" appears in the input string, it must be prefixed with at least one 0.
578 The function will ignore the pad space, which includes spaces or tab characters,
579 before [zeros], [x] or [hexadecimal digit]. The running zero before [x] or
580 [hexadecimal digit] will be ignored. Then, the decoding starts after [x] or the
581 first valid hexadecimal digit. Then, the function stops at the first character that is
582 a not a valid hexadecimal character or NULL, whichever one comes first.
584 If String is NULL, then ASSERT().
585 If String is not aligned in a 16-bit boundary, then ASSERT().
586 If String has only pad spaces, then zero is returned.
587 If String has no leading pad spaces, leading zeros or valid hexadecimal digits,
588 then zero is returned.
589 If the number represented by String overflows according to the range defined by
590 UINT64, then ASSERT().
592 If PcdMaximumUnicodeStringLength is not zero, and String contains more than
593 PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator,
596 @param String Pointer to a Null-terminated Unicode string.
604 IN CONST CHAR16
*String
609 Convert one Null-terminated Unicode string to a Null-terminated
610 ASCII string and returns the ASCII string.
612 This function converts the content of the Unicode string Source
613 to the ASCII string Destination by copying the lower 8 bits of
614 each Unicode character. It returns Destination.
616 If any Unicode characters in Source contain non-zero value in
617 the upper 8 bits, then ASSERT().
619 If Destination is NULL, then ASSERT().
620 If Source is NULL, then ASSERT().
621 If Source is not aligned on a 16-bit boundary, then ASSERT().
622 If Source and Destination overlap, then ASSERT().
624 If PcdMaximumUnicodeStringLength is not zero, and Source contains
625 more than PcdMaximumUnicodeStringLength Unicode characters not including
626 the Null-terminator, then ASSERT().
628 If PcdMaximumAsciiStringLength is not zero, and Source contains more
629 than PcdMaximumAsciiStringLength Unicode characters not including the
630 Null-terminator, then ASSERT().
632 @param Source Pointer to a Null-terminated Unicode string.
633 @param Destination Pointer to a Null-terminated ASCII string.
640 UnicodeStrToAsciiStr (
641 IN CONST CHAR16
*Source
,
642 OUT CHAR8
*Destination
647 Copies one Null-terminated ASCII string to another Null-terminated ASCII
648 string and returns the new ASCII string.
650 This function copies the contents of the ASCII string Source to the ASCII
651 string Destination, and returns Destination. If Source and Destination
652 overlap, then the results are undefined.
654 If Destination is NULL, then ASSERT().
655 If Source is NULL, then ASSERT().
656 If Source and Destination overlap, then ASSERT().
657 If PcdMaximumAsciiStringLength is not zero and Source contains more than
658 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
661 @param Destination Pointer to a Null-terminated ASCII string.
662 @param Source Pointer to a Null-terminated ASCII string.
670 OUT CHAR8
*Destination
,
671 IN CONST CHAR8
*Source
676 Copies one Null-terminated ASCII string with a maximum length to another
677 Null-terminated ASCII string with a maximum length and returns the new ASCII
680 This function copies the contents of the ASCII string Source to the ASCII
681 string Destination, and returns Destination. At most, Length ASCII characters
682 are copied from Source to Destination. If Length is 0, then Destination is
683 returned unmodified. If Length is greater that the number of ASCII characters
684 in Source, then Destination is padded with Null ASCII characters. If Source
685 and Destination overlap, then the results are undefined.
687 If Destination is NULL, then ASSERT().
688 If Source is NULL, then ASSERT().
689 If Source and Destination overlap, then ASSERT().
690 If PcdMaximumAsciiStringLength is not zero, and Source contains more than
691 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
694 @param Destination Pointer to a Null-terminated ASCII string.
695 @param Source Pointer to a Null-terminated ASCII string.
696 @param Length Maximum number of ASCII characters to copy.
704 OUT CHAR8
*Destination
,
705 IN CONST CHAR8
*Source
,
711 Returns the length of a Null-terminated ASCII string.
713 This function returns the number of ASCII characters in the Null-terminated
714 ASCII string specified by String.
716 If Length > 0 and Destination is NULL, then ASSERT().
717 If Length > 0 and Source is NULL, then ASSERT().
718 If PcdMaximumAsciiStringLength is not zero and String contains more than
719 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
722 @param String Pointer to a Null-terminated ASCII string.
724 @return The length of String.
730 IN CONST CHAR8
*String
735 Returns the size of a Null-terminated ASCII string in bytes, including the
738 This function returns the size, in bytes, of the Null-terminated ASCII string
741 If String is NULL, then ASSERT().
742 If PcdMaximumAsciiStringLength is not zero and String contains more than
743 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
746 @param String Pointer to a Null-terminated ASCII string.
748 @return The size of String.
754 IN CONST CHAR8
*String
759 Compares two Null-terminated ASCII strings, and returns the difference
760 between the first mismatched ASCII characters.
762 This function compares the Null-terminated ASCII string FirstString to the
763 Null-terminated ASCII string SecondString. If FirstString is identical to
764 SecondString, then 0 is returned. Otherwise, the value returned is the first
765 mismatched ASCII character in SecondString subtracted from the first
766 mismatched ASCII character in FirstString.
768 If FirstString is NULL, then ASSERT().
769 If SecondString is NULL, then ASSERT().
770 If PcdMaximumAsciiStringLength is not zero and FirstString contains more than
771 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
773 If PcdMaximumAsciiStringLength is not zero and SecondString contains more
774 than PcdMaximumAsciiStringLength ASCII characters not including the
775 Null-terminator, then ASSERT().
777 @param FirstString Pointer to a Null-terminated ASCII string.
778 @param SecondString Pointer to a Null-terminated ASCII string.
780 @retval 0 FirstString is identical to SecondString.
781 @retval !=0 FirstString is not identical to SecondString.
787 IN CONST CHAR8
*FirstString
,
788 IN CONST CHAR8
*SecondString
793 Performs a case insensitive comparison of two Null-terminated ASCII strings,
794 and returns the difference between the first mismatched ASCII characters.
796 This function performs a case insensitive comparison of the Null-terminated
797 ASCII string FirstString to the Null-terminated ASCII string SecondString. If
798 FirstString is identical to SecondString, then 0 is returned. Otherwise, the
799 value returned is the first mismatched lower case ASCII character in
800 SecondString subtracted from the first mismatched lower case ASCII character
803 If FirstString is NULL, then ASSERT().
804 If SecondString is NULL, then ASSERT().
805 If PcdMaximumAsciiStringLength is not zero and FirstString contains more than
806 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
808 If PcdMaximumAsciiStringLength is not zero and SecondString contains more
809 than PcdMaximumAsciiStringLength ASCII characters not including the
810 Null-terminator, then ASSERT().
812 @param FirstString Pointer to a Null-terminated ASCII string.
813 @param SecondString Pointer to a Null-terminated ASCII string.
815 @retval 0 FirstString is identical to SecondString using case insensitive
817 @retval !=0 FirstString is not identical to SecondString using case
818 insensitive comparisons.
824 IN CONST CHAR8
*FirstString
,
825 IN CONST CHAR8
*SecondString
830 Compares two Null-terminated ASCII strings with maximum lengths, and returns
831 the difference between the first mismatched ASCII characters.
833 This function compares the Null-terminated ASCII string FirstString to the
834 Null-terminated ASCII string SecondString. At most, Length ASCII characters
835 will be compared. If Length is 0, then 0 is returned. If FirstString is
836 identical to SecondString, then 0 is returned. Otherwise, the value returned
837 is the first mismatched ASCII character in SecondString subtracted from the
838 first mismatched ASCII character in FirstString.
840 If Length > 0 and FirstString is NULL, then ASSERT().
841 If Length > 0 and SecondString is NULL, then ASSERT().
842 If PcdMaximumAsciiStringLength is not zero and FirstString contains more than
843 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
845 If PcdMaximumAsciiStringLength is not zero and SecondString contains more than
846 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
849 @param FirstString Pointer to a Null-terminated ASCII string.
850 @param SecondString Pointer to a Null-terminated ASCII string.
852 @retval 0 FirstString is identical to SecondString.
853 @retval !=0 FirstString is not identical to SecondString.
859 IN CONST CHAR8
*FirstString
,
860 IN CONST CHAR8
*SecondString
,
866 Concatenates one Null-terminated ASCII string to another Null-terminated
867 ASCII string, and returns the concatenated ASCII string.
869 This function concatenates two Null-terminated ASCII strings. The contents of
870 Null-terminated ASCII string Source are concatenated to the end of Null-
871 terminated ASCII string Destination. The Null-terminated concatenated ASCII
874 If Destination is NULL, then ASSERT().
875 If Source is NULL, then ASSERT().
876 If PcdMaximumAsciiStringLength is not zero and Destination contains more than
877 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
879 If PcdMaximumAsciiStringLength is not zero and Source contains more than
880 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
882 If PcdMaximumAsciiStringLength is not zero and concatenating Destination and
883 Source results in a ASCII string with more than PcdMaximumAsciiStringLength
884 ASCII characters, then ASSERT().
886 @param Destination Pointer to a Null-terminated ASCII string.
887 @param Source Pointer to a Null-terminated ASCII string.
895 IN OUT CHAR8
*Destination
,
896 IN CONST CHAR8
*Source
901 Concatenates one Null-terminated ASCII string with a maximum length to the
902 end of another Null-terminated ASCII string, and returns the concatenated
905 This function concatenates two Null-terminated ASCII strings. The contents
906 of Null-terminated ASCII string Source are concatenated to the end of Null-
907 terminated ASCII string Destination, and Destination is returned. At most,
908 Length ASCII characters are concatenated from Source to the end of
909 Destination, and Destination is always Null-terminated. If Length is 0, then
910 Destination is returned unmodified. If Source and Destination overlap, then
911 the results are undefined.
913 If Length > 0 and Destination is NULL, then ASSERT().
914 If Length > 0 and Source is NULL, then ASSERT().
915 If Source and Destination overlap, then ASSERT().
916 If PcdMaximumAsciiStringLength is not zero, and Destination contains more than
917 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
919 If PcdMaximumAsciiStringLength is not zero, and Source contains more than
920 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
922 If PcdMaximumAsciiStringLength is not zero, and concatenating Destination and
923 Source results in a ASCII string with more than PcdMaximumAsciiStringLength
924 ASCII characters not including the Null-terminator, then ASSERT().
926 @param Destination Pointer to a Null-terminated ASCII string.
927 @param Source Pointer to a Null-terminated ASCII string.
928 @param Length Maximum number of ASCII characters to concatenate from
937 IN OUT CHAR8
*Destination
,
938 IN CONST CHAR8
*Source
,
944 Returns the first occurance of a Null-terminated ASCII sub-string
945 in a Null-terminated ASCII string.
947 This function scans the contents of the ASCII string specified by String
948 and returns the first occurrence of SearchString. If SearchString is not
949 found in String, then NULL is returned. If the length of SearchString is zero,
950 then String is returned.
952 If String is NULL, then ASSERT().
953 If SearchString is NULL, then ASSERT().
955 If PcdMaximumAsciiStringLength is not zero, and SearchString or
956 String contains more than PcdMaximumAsciiStringLength Unicode characters
957 not including the Null-terminator, then ASSERT().
959 @param String Pointer to a Null-terminated ASCII string.
960 @param SearchString Pointer to a Null-terminated ASCII string to search for.
962 @retval NULL If the SearchString does not appear in String.
963 @retval !NULL If there is a match.
969 IN CONST CHAR8
*String
,
970 IN CONST CHAR8
*SearchString
975 Convert a Null-terminated ASCII decimal string to a value of type
978 This function returns a value of type UINTN by interpreting the contents
979 of the ASCII string String as a decimal number. The format of the input
980 ASCII string String is:
982 [spaces] [decimal digits].
984 The valid decimal digit character is in the range [0-9]. The function will
985 ignore the pad space, which includes spaces or tab characters, before the digits.
986 The running zero in the beginning of [decimal digits] will be ignored. Then, the
987 function stops at the first character that is a not a valid decimal character or
988 Null-terminator, whichever on comes first.
990 If String has only pad spaces, then 0 is returned.
991 If String has no pad spaces or valid decimal digits, then 0 is returned.
992 If the number represented by String overflows according to the range defined by
993 UINTN, then ASSERT().
994 If String is NULL, then ASSERT().
995 If PcdMaximumAsciiStringLength is not zero, and String contains more than
996 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
999 @param String Pointer to a Null-terminated ASCII string.
1006 AsciiStrDecimalToUintn (
1007 IN CONST CHAR8
*String
1012 Convert a Null-terminated ASCII decimal string to a value of type
1015 This function returns a value of type UINT64 by interpreting the contents
1016 of the ASCII string String as a decimal number. The format of the input
1017 ASCII string String is:
1019 [spaces] [decimal digits].
1021 The valid decimal digit character is in the range [0-9]. The function will
1022 ignore the pad space, which includes spaces or tab characters, before the digits.
1023 The running zero in the beginning of [decimal digits] will be ignored. Then, the
1024 function stops at the first character that is a not a valid decimal character or
1025 Null-terminator, whichever on comes first.
1027 If String has only pad spaces, then 0 is returned.
1028 If String has no pad spaces or valid decimal digits, then 0 is returned.
1029 If the number represented by String overflows according to the range defined by
1030 UINT64, then ASSERT().
1031 If String is NULL, then ASSERT().
1032 If PcdMaximumAsciiStringLength is not zero, and String contains more than
1033 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
1036 @param String Pointer to a Null-terminated ASCII string.
1043 AsciiStrDecimalToUint64 (
1044 IN CONST CHAR8
*String
1049 Convert a Null-terminated ASCII hexadecimal string to a value of type UINTN.
1051 This function returns a value of type UINTN by interpreting the contents of
1052 the ASCII string String as a hexadecimal number. The format of the input ASCII
1055 [spaces][zeros][x][hexadecimal digits].
1057 The valid hexadecimal digit character is in the range [0-9], [a-f] and [A-F].
1058 The prefix "0x" is optional. Both "x" and "X" is allowed in "0x" prefix. If "x"
1059 appears in the input string, it must be prefixed with at least one 0. The function
1060 will ignore the pad space, which includes spaces or tab characters, before [zeros],
1061 [x] or [hexadecimal digits]. The running zero before [x] or [hexadecimal digits]
1062 will be ignored. Then, the decoding starts after [x] or the first valid hexadecimal
1063 digit. Then, the function stops at the first character that is a not a valid
1064 hexadecimal character or Null-terminator, whichever on comes first.
1066 If String has only pad spaces, then 0 is returned.
1067 If String has no leading pad spaces, leading zeros or valid hexadecimal digits, then
1070 If the number represented by String overflows according to the range defined by UINTN,
1072 If String is NULL, then ASSERT().
1073 If PcdMaximumAsciiStringLength is not zero,
1074 and String contains more than PcdMaximumAsciiStringLength ASCII characters not including
1075 the Null-terminator, then ASSERT().
1077 @param String Pointer to a Null-terminated ASCII string.
1084 AsciiStrHexToUintn (
1085 IN CONST CHAR8
*String
1090 Convert a Null-terminated ASCII hexadecimal string to a value of type UINT64.
1092 This function returns a value of type UINT64 by interpreting the contents of
1093 the ASCII string String as a hexadecimal number. The format of the input ASCII
1096 [spaces][zeros][x][hexadecimal digits].
1098 The valid hexadecimal digit character is in the range [0-9], [a-f] and [A-F].
1099 The prefix "0x" is optional. Both "x" and "X" is allowed in "0x" prefix. If "x"
1100 appears in the input string, it must be prefixed with at least one 0. The function
1101 will ignore the pad space, which includes spaces or tab characters, before [zeros],
1102 [x] or [hexadecimal digits]. The running zero before [x] or [hexadecimal digits]
1103 will be ignored. Then, the decoding starts after [x] or the first valid hexadecimal
1104 digit. Then, the function stops at the first character that is a not a valid
1105 hexadecimal character or Null-terminator, whichever on comes first.
1107 If String has only pad spaces, then 0 is returned.
1108 If String has no leading pad spaces, leading zeros or valid hexadecimal digits, then
1111 If the number represented by String overflows according to the range defined by UINT64,
1113 If String is NULL, then ASSERT().
1114 If PcdMaximumAsciiStringLength is not zero,
1115 and String contains more than PcdMaximumAsciiStringLength ASCII characters not including
1116 the Null-terminator, then ASSERT().
1118 @param String Pointer to a Null-terminated ASCII string.
1125 AsciiStrHexToUint64 (
1126 IN CONST CHAR8
*String
1131 Convert one Null-terminated ASCII string to a Null-terminated
1132 Unicode string and returns the Unicode string.
1134 This function converts the contents of the ASCII string Source to the Unicode
1135 string Destination, and returns Destination. The function terminates the
1136 Unicode string Destination by appending a Null-terminator character at the end.
1137 The caller is responsible to make sure Destination points to a buffer with size
1138 equal or greater than ((AsciiStrLen (Source) + 1) * sizeof (CHAR16)) in bytes.
1140 If Destination is NULL, then ASSERT().
1141 If Destination is not aligned on a 16-bit boundary, then ASSERT().
1142 If Source is NULL, then ASSERT().
1143 If Source and Destination overlap, then ASSERT().
1144 If PcdMaximumAsciiStringLength is not zero, and Source contains more than
1145 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
1147 If PcdMaximumUnicodeStringLength is not zero, and Source contains more than
1148 PcdMaximumUnicodeStringLength ASCII characters not including the
1149 Null-terminator, then ASSERT().
1151 @param Source Pointer to a Null-terminated ASCII string.
1152 @param Destination Pointer to a Null-terminated Unicode string.
1159 AsciiStrToUnicodeStr (
1160 IN CONST CHAR8
*Source
,
1161 OUT CHAR16
*Destination
1166 Converts an 8-bit value to an 8-bit BCD value.
1168 Converts the 8-bit value specified by Value to BCD. The BCD value is
1171 If Value >= 100, then ASSERT().
1173 @param Value The 8-bit value to convert to BCD. Range 0..99.
1175 @return The BCD value
1186 Converts an 8-bit BCD value to an 8-bit value.
1188 Converts the 8-bit BCD value specified by Value to an 8-bit value. The 8-bit
1191 If Value >= 0xA0, then ASSERT().
1192 If (Value & 0x0F) >= 0x0A, then ASSERT().
1194 @param Value The 8-bit BCD value to convert to an 8-bit value.
1196 @return The 8-bit value is returned.
1207 // Linked List Functions and Macros
1211 Initializes the head node of a doubly linked list that is declared as a
1212 global variable in a module.
1214 Initializes the forward and backward links of a new linked list. After
1215 initializing a linked list with this macro, the other linked list functions
1216 may be used to add and remove nodes from the linked list. This macro results
1217 in smaller executables by initializing the linked list in the data section,
1218 instead if calling the InitializeListHead() function to perform the
1219 equivalent operation.
1221 @param ListHead The head note of a list to initiailize.
1224 #define INITIALIZE_LIST_HEAD_VARIABLE(ListHead) {&ListHead, &ListHead}
1228 Initializes the head node of a doubly linked list, and returns the pointer to
1229 the head node of the doubly linked list.
1231 Initializes the forward and backward links of a new linked list. After
1232 initializing a linked list with this function, the other linked list
1233 functions may be used to add and remove nodes from the linked list. It is up
1234 to the caller of this function to allocate the memory for ListHead.
1236 If ListHead is NULL, then ASSERT().
1238 @param ListHead A pointer to the head node of a new doubly linked list.
1245 InitializeListHead (
1246 IN LIST_ENTRY
*ListHead
1251 Adds a node to the beginning of a doubly linked list, and returns the pointer
1252 to the head node of the doubly linked list.
1254 Adds the node Entry at the beginning of the doubly linked list denoted by
1255 ListHead, and returns ListHead.
1257 If ListHead is NULL, then ASSERT().
1258 If Entry is NULL, then ASSERT().
1259 If ListHead was not initialized with InitializeListHead(), then ASSERT().
1260 If PcdMaximumLinkedListLenth is not zero, and prior to insertion the number
1261 of nodes in ListHead, including the ListHead node, is greater than or
1262 equal to PcdMaximumLinkedListLength, then ASSERT().
1264 @param ListHead A pointer to the head node of a doubly linked list.
1265 @param Entry A pointer to a node that is to be inserted at the beginning
1266 of a doubly linked list.
1274 IN LIST_ENTRY
*ListHead
,
1275 IN LIST_ENTRY
*Entry
1280 Adds a node to the end of a doubly linked list, and returns the pointer to
1281 the head node of the doubly linked list.
1283 Adds the node Entry to the end of the doubly linked list denoted by ListHead,
1284 and returns ListHead.
1286 If ListHead is NULL, then ASSERT().
1287 If Entry is NULL, then ASSERT().
1288 If ListHead was not initialized with InitializeListHead(), then ASSERT().
1289 If PcdMaximumLinkedListLenth is not zero, and prior to insertion the number
1290 of nodes in ListHead, including the ListHead node, is greater than or
1291 equal to PcdMaximumLinkedListLength, then ASSERT().
1293 @param ListHead A pointer to the head node of a doubly linked list.
1294 @param Entry A pointer to a node that is to be added at the end of the
1303 IN LIST_ENTRY
*ListHead
,
1304 IN LIST_ENTRY
*Entry
1309 Retrieves the first node of a doubly linked list.
1311 Returns the first node of a doubly linked list. List must have been
1312 initialized with InitializeListHead(). If List is empty, then NULL is
1315 If List is NULL, then ASSERT().
1316 If List was not initialized with InitializeListHead(), then ASSERT().
1317 If PcdMaximumLinkedListLenth is not zero, and the number of nodes
1318 in List, including the List node, is greater than or equal to
1319 PcdMaximumLinkedListLength, then ASSERT().
1321 @param List A pointer to the head node of a doubly linked list.
1323 @return The first node of a doubly linked list.
1324 @retval NULL The list is empty.
1330 IN CONST LIST_ENTRY
*List
1335 Retrieves the next node of a doubly linked list.
1337 Returns the node of a doubly linked list that follows Node. List must have
1338 been initialized with InitializeListHead(). If List is empty, then List is
1341 If List is NULL, then ASSERT().
1342 If Node is NULL, then ASSERT().
1343 If List was not initialized with InitializeListHead(), then ASSERT().
1344 If PcdMaximumLinkedListLenth is not zero, and List contains more than
1345 PcdMaximumLinkedListLenth nodes, then ASSERT().
1346 If Node is not a node in List, then ASSERT().
1348 @param List A pointer to the head node of a doubly linked list.
1349 @param Node A pointer to a node in the doubly linked list.
1351 @return Pointer to the next node if one exists. Otherwise a null value which
1352 is actually List is returned.
1358 IN CONST LIST_ENTRY
*List
,
1359 IN CONST LIST_ENTRY
*Node
1364 Checks to see if a doubly linked list is empty or not.
1366 Checks to see if the doubly linked list is empty. If the linked list contains
1367 zero nodes, this function returns TRUE. Otherwise, it returns FALSE.
1369 If ListHead is NULL, then ASSERT().
1370 If ListHead was not initialized with InitializeListHead(), then ASSERT().
1371 If PcdMaximumLinkedListLenth is not zero, and the number of nodes
1372 in List, including the List node, is greater than or equal to
1373 PcdMaximumLinkedListLength, then ASSERT().
1375 @param ListHead A pointer to the head node of a doubly linked list.
1377 @retval TRUE The linked list is empty.
1378 @retval FALSE The linked list is not empty.
1384 IN CONST LIST_ENTRY
*ListHead
1389 Determines if a node in a doubly linked list is null.
1391 Returns FALSE if Node is one of the nodes in the doubly linked list specified
1392 by List. Otherwise, TRUE is returned. List must have been initialized with
1393 InitializeListHead().
1395 If List is NULL, then ASSERT().
1396 If Node is NULL, then ASSERT().
1397 If List was not initialized with InitializeListHead(), then ASSERT().
1398 If PcdMaximumLinkedListLenth is not zero, and the number of nodes
1399 in List, including the List node, is greater than or equal to
1400 PcdMaximumLinkedListLength, then ASSERT().
1401 If Node is not a node in List and Node is not equal to List, then ASSERT().
1403 @param List A pointer to the head node of a doubly linked list.
1404 @param Node A pointer to a node in the doubly linked list.
1406 @retval TRUE Node is one of the nodes in the doubly linked list.
1407 @retval FALSE Node is not one of the nodes in the doubly linked list.
1413 IN CONST LIST_ENTRY
*List
,
1414 IN CONST LIST_ENTRY
*Node
1419 Determines if a node the last node in a doubly linked list.
1421 Returns TRUE if Node is the last node in the doubly linked list specified by
1422 List. Otherwise, FALSE is returned. List must have been initialized with
1423 InitializeListHead().
1425 If List is NULL, then ASSERT().
1426 If Node is NULL, then ASSERT().
1427 If List was not initialized with InitializeListHead(), then ASSERT().
1428 If PcdMaximumLinkedListLenth is not zero, and the number of nodes
1429 in List, including the List node, is greater than or equal to
1430 PcdMaximumLinkedListLength, then ASSERT().
1431 If Node is not a node in List, then ASSERT().
1433 @param List A pointer to the head node of a doubly linked list.
1434 @param Node A pointer to a node in the doubly linked list.
1436 @retval TRUE Node is the last node in the linked list.
1437 @retval FALSE Node is not the last node in the linked list.
1443 IN CONST LIST_ENTRY
*List
,
1444 IN CONST LIST_ENTRY
*Node
1449 Swaps the location of two nodes in a doubly linked list, and returns the
1450 first node after the swap.
1452 If FirstEntry is identical to SecondEntry, then SecondEntry is returned.
1453 Otherwise, the location of the FirstEntry node is swapped with the location
1454 of the SecondEntry node in a doubly linked list. SecondEntry must be in the
1455 same double linked list as FirstEntry and that double linked list must have
1456 been initialized with InitializeListHead(). SecondEntry is returned after the
1459 If FirstEntry is NULL, then ASSERT().
1460 If SecondEntry is NULL, then ASSERT().
1461 If SecondEntry and FirstEntry are not in the same linked list, then ASSERT().
1462 If PcdMaximumLinkedListLength is not zero, and the number of nodes in the
1463 linked list containing the FirstEntry and SecondEntry nodes, including
1464 the FirstEntry and SecondEntry nodes, is greater than or equal to
1465 PcdMaximumLinkedListLength, then ASSERT().
1467 @param FirstEntry A pointer to a node in a linked list.
1468 @param SecondEntry A pointer to another node in the same linked list.
1474 IN LIST_ENTRY
*FirstEntry
,
1475 IN LIST_ENTRY
*SecondEntry
1480 Removes a node from a doubly linked list, and returns the node that follows
1483 Removes the node Entry from a doubly linked list. It is up to the caller of
1484 this function to release the memory used by this node if that is required. On
1485 exit, the node following Entry in the doubly linked list is returned. If
1486 Entry is the only node in the linked list, then the head node of the linked
1489 If Entry is NULL, then ASSERT().
1490 If Entry is the head node of an empty list, then ASSERT().
1491 If PcdMaximumLinkedListLength is not zero, and the number of nodes in the
1492 linked list containing Entry, including the Entry node, is greater than
1493 or equal to PcdMaximumLinkedListLength, then ASSERT().
1495 @param Entry A pointer to a node in a linked list
1503 IN CONST LIST_ENTRY
*Entry
1511 Shifts a 64-bit integer left between 0 and 63 bits. The low bits are filled
1512 with zeros. The shifted value is returned.
1514 This function shifts the 64-bit value Operand to the left by Count bits. The
1515 low Count bits are set to zero. The shifted value is returned.
1517 If Count is greater than 63, then ASSERT().
1519 @param Operand The 64-bit operand to shift left.
1520 @param Count The number of bits to shift left.
1522 @return Operand << Count
1534 Shifts a 64-bit integer right between 0 and 63 bits. This high bits are
1535 filled with zeros. The shifted value is returned.
1537 This function shifts the 64-bit value Operand to the right by Count bits. The
1538 high Count bits are set to zero. The shifted value is returned.
1540 If Count is greater than 63, then ASSERT().
1542 @param Operand The 64-bit operand to shift right.
1543 @param Count The number of bits to shift right.
1545 @return Operand >> Count
1557 Shifts a 64-bit integer right between 0 and 63 bits. The high bits are filled
1558 with original integer's bit 63. The shifted value is returned.
1560 This function shifts the 64-bit value Operand to the right by Count bits. The
1561 high Count bits are set to bit 63 of Operand. The shifted value is returned.
1563 If Count is greater than 63, then ASSERT().
1565 @param Operand The 64-bit operand to shift right.
1566 @param Count The number of bits to shift right.
1568 @return Operand >> Count
1580 Rotates a 32-bit integer left between 0 and 31 bits, filling the low bits
1581 with the high bits that were rotated.
1583 This function rotates the 32-bit value Operand to the left by Count bits. The
1584 low Count bits are fill with the high Count bits of Operand. The rotated
1587 If Count is greater than 31, then ASSERT().
1589 @param Operand The 32-bit operand to rotate left.
1590 @param Count The number of bits to rotate left.
1592 @return Operand <<< Count
1604 Rotates a 32-bit integer right between 0 and 31 bits, filling the high bits
1605 with the low bits that were rotated.
1607 This function rotates the 32-bit value Operand to the right by Count bits.
1608 The high Count bits are fill with the low Count bits of Operand. The rotated
1611 If Count is greater than 31, then ASSERT().
1613 @param Operand The 32-bit operand to rotate right.
1614 @param Count The number of bits to rotate right.
1616 @return Operand >>> Count
1628 Rotates a 64-bit integer left between 0 and 63 bits, filling the low bits
1629 with the high bits that were rotated.
1631 This function rotates the 64-bit value Operand to the left by Count bits. The
1632 low Count bits are fill with the high Count bits of Operand. The rotated
1635 If Count is greater than 63, then ASSERT().
1637 @param Operand The 64-bit operand to rotate left.
1638 @param Count The number of bits to rotate left.
1640 @return Operand <<< Count
1652 Rotates a 64-bit integer right between 0 and 63 bits, filling the high bits
1653 with the high low bits that were rotated.
1655 This function rotates the 64-bit value Operand to the right by Count bits.
1656 The high Count bits are fill with the low Count bits of Operand. The rotated
1659 If Count is greater than 63, then ASSERT().
1661 @param Operand The 64-bit operand to rotate right.
1662 @param Count The number of bits to rotate right.
1664 @return Operand >>> Count
1676 Returns the bit position of the lowest bit set in a 32-bit value.
1678 This function computes the bit position of the lowest bit set in the 32-bit
1679 value specified by Operand. If Operand is zero, then -1 is returned.
1680 Otherwise, a value between 0 and 31 is returned.
1682 @param Operand The 32-bit operand to evaluate.
1684 @return Position of the lowest bit set in Operand if found.
1685 @retval -1 Operand is zero.
1696 Returns the bit position of the lowest bit set in a 64-bit value.
1698 This function computes the bit position of the lowest bit set in the 64-bit
1699 value specified by Operand. If Operand is zero, then -1 is returned.
1700 Otherwise, a value between 0 and 63 is returned.
1702 @param Operand The 64-bit operand to evaluate.
1704 @return Position of the lowest bit set in Operand if found.
1705 @retval -1 Operand is zero.
1716 Returns the bit position of the highest bit set in a 32-bit value. Equivalent
1719 This function computes the bit position of the highest bit set in the 32-bit
1720 value specified by Operand. If Operand is zero, then -1 is returned.
1721 Otherwise, a value between 0 and 31 is returned.
1723 @param Operand The 32-bit operand to evaluate.
1725 @return Position of the highest bit set in Operand if found.
1726 @retval -1 Operand is zero.
1737 Returns the bit position of the highest bit set in a 64-bit value. Equivalent
1740 This function computes the bit position of the highest bit set in the 64-bit
1741 value specified by Operand. If Operand is zero, then -1 is returned.
1742 Otherwise, a value between 0 and 63 is returned.
1744 @param Operand The 64-bit operand to evaluate.
1746 @return Position of the highest bit set in Operand if found.
1747 @retval -1 Operand is zero.
1758 Returns the value of the highest bit set in a 32-bit value. Equivalent to
1759 1 << HighBitSet32(x).
1761 This function computes the value of the highest bit set in the 32-bit value
1762 specified by Operand. If Operand is zero, then zero is returned.
1764 @param Operand The 32-bit operand to evaluate.
1766 @return 1 << HighBitSet32(Operand)
1767 @retval 0 Operand is zero.
1778 Returns the value of the highest bit set in a 64-bit value. Equivalent to
1779 1 << HighBitSet64(x).
1781 This function computes the value of the highest bit set in the 64-bit value
1782 specified by Operand. If Operand is zero, then zero is returned.
1784 @param Operand The 64-bit operand to evaluate.
1786 @return 1 << HighBitSet64(Operand)
1787 @retval 0 Operand is zero.
1798 Switches the endianess of a 16-bit integer.
1800 This function swaps the bytes in a 16-bit unsigned value to switch the value
1801 from little endian to big endian or vice versa. The byte swapped value is
1804 @param Operand A 16-bit unsigned value.
1806 @return The byte swaped Operand.
1817 Switches the endianess of a 32-bit integer.
1819 This function swaps the bytes in a 32-bit unsigned value to switch the value
1820 from little endian to big endian or vice versa. The byte swapped value is
1823 @param Operand A 32-bit unsigned value.
1825 @return The byte swaped Operand.
1836 Switches the endianess of a 64-bit integer.
1838 This function swaps the bytes in a 64-bit unsigned value to switch the value
1839 from little endian to big endian or vice versa. The byte swapped value is
1842 @param Operand A 64-bit unsigned value.
1844 @return The byte swaped Operand.
1855 Multiples a 64-bit unsigned integer by a 32-bit unsigned integer and
1856 generates a 64-bit unsigned result.
1858 This function multiples the 64-bit unsigned value Multiplicand by the 32-bit
1859 unsigned value Multiplier and generates a 64-bit unsigned result. This 64-
1860 bit unsigned result is returned.
1862 If the result overflows, then ASSERT().
1864 @param Multiplicand A 64-bit unsigned value.
1865 @param Multiplier A 32-bit unsigned value.
1867 @return Multiplicand * Multiplier
1873 IN UINT64 Multiplicand
,
1874 IN UINT32 Multiplier
1879 Multiples a 64-bit unsigned integer by a 64-bit unsigned integer and
1880 generates a 64-bit unsigned result.
1882 This function multiples the 64-bit unsigned value Multiplicand by the 64-bit
1883 unsigned value Multiplier and generates a 64-bit unsigned result. This 64-
1884 bit unsigned result is returned.
1886 If the result overflows, then ASSERT().
1888 @param Multiplicand A 64-bit unsigned value.
1889 @param Multiplier A 64-bit unsigned value.
1891 @return Multiplicand * Multiplier
1897 IN UINT64 Multiplicand
,
1898 IN UINT64 Multiplier
1903 Multiples a 64-bit signed integer by a 64-bit signed integer and generates a
1904 64-bit signed result.
1906 This function multiples the 64-bit signed value Multiplicand by the 64-bit
1907 signed value Multiplier and generates a 64-bit signed result. This 64-bit
1908 signed result is returned.
1910 If the result overflows, then ASSERT().
1912 @param Multiplicand A 64-bit signed value.
1913 @param Multiplier A 64-bit signed value.
1915 @return Multiplicand * Multiplier
1921 IN INT64 Multiplicand
,
1927 Divides a 64-bit unsigned integer by a 32-bit unsigned integer and generates
1928 a 64-bit unsigned result.
1930 This function divides the 64-bit unsigned value Dividend by the 32-bit
1931 unsigned value Divisor and generates a 64-bit unsigned quotient. This
1932 function returns the 64-bit unsigned quotient.
1934 If Divisor is 0, then ASSERT().
1936 @param Dividend A 64-bit unsigned value.
1937 @param Divisor A 32-bit unsigned value.
1939 @return Dividend / Divisor
1951 Divides a 64-bit unsigned integer by a 32-bit unsigned integer and generates
1952 a 32-bit unsigned remainder.
1954 This function divides the 64-bit unsigned value Dividend by the 32-bit
1955 unsigned value Divisor and generates a 32-bit remainder. This function
1956 returns the 32-bit unsigned remainder.
1958 If Divisor is 0, then ASSERT().
1960 @param Dividend A 64-bit unsigned value.
1961 @param Divisor A 32-bit unsigned value.
1963 @return Dividend % Divisor
1975 Divides a 64-bit unsigned integer by a 32-bit unsigned integer and generates
1976 a 64-bit unsigned result and an optional 32-bit unsigned remainder.
1978 This function divides the 64-bit unsigned value Dividend by the 32-bit
1979 unsigned value Divisor and generates a 64-bit unsigned quotient. If Remainder
1980 is not NULL, then the 32-bit unsigned remainder is returned in Remainder.
1981 This function returns the 64-bit unsigned quotient.
1983 If Divisor is 0, then ASSERT().
1985 @param Dividend A 64-bit unsigned value.
1986 @param Divisor A 32-bit unsigned value.
1987 @param Remainder A pointer to a 32-bit unsigned value. This parameter is
1988 optional and may be NULL.
1990 @return Dividend / Divisor
1995 DivU64x32Remainder (
1998 OUT UINT32
*Remainder OPTIONAL
2003 Divides a 64-bit unsigned integer by a 64-bit unsigned integer and generates
2004 a 64-bit unsigned result and an optional 64-bit unsigned remainder.
2006 This function divides the 64-bit unsigned value Dividend by the 64-bit
2007 unsigned value Divisor and generates a 64-bit unsigned quotient. If Remainder
2008 is not NULL, then the 64-bit unsigned remainder is returned in Remainder.
2009 This function returns the 64-bit unsigned quotient.
2011 If Divisor is 0, then ASSERT().
2013 @param Dividend A 64-bit unsigned value.
2014 @param Divisor A 64-bit unsigned value.
2015 @param Remainder A pointer to a 64-bit unsigned value. This parameter is
2016 optional and may be NULL.
2018 @return Dividend / Divisor
2023 DivU64x64Remainder (
2026 OUT UINT64
*Remainder OPTIONAL
2031 Divides a 64-bit signed integer by a 64-bit signed integer and generates a
2032 64-bit signed result and a optional 64-bit signed remainder.
2034 This function divides the 64-bit signed value Dividend by the 64-bit signed
2035 value Divisor and generates a 64-bit signed quotient. If Remainder is not
2036 NULL, then the 64-bit signed remainder is returned in Remainder. This
2037 function returns the 64-bit signed quotient.
2039 If Divisor is 0, then ASSERT().
2041 @param Dividend A 64-bit signed value.
2042 @param Divisor A 64-bit signed value.
2043 @param Remainder A pointer to a 64-bit signed value. This parameter is
2044 optional and may be NULL.
2046 @return Dividend / Divisor
2051 DivS64x64Remainder (
2054 OUT INT64
*Remainder OPTIONAL
2059 Reads a 16-bit value from memory that may be unaligned.
2061 This function returns the 16-bit value pointed to by Buffer. The function
2062 guarantees that the read operation does not produce an alignment fault.
2064 If the Buffer is NULL, then ASSERT().
2066 @param Buffer Pointer to a 16-bit value that may be unaligned.
2074 IN CONST UINT16
*Uint16
2079 Writes a 16-bit value to memory that may be unaligned.
2081 This function writes the 16-bit value specified by Value to Buffer. Value is
2082 returned. The function guarantees that the write operation does not produce
2085 If the Buffer is NULL, then ASSERT().
2087 @param Buffer Pointer to a 16-bit value that may be unaligned.
2088 @param Value 16-bit value to write to Buffer.
2102 Reads a 24-bit value from memory that may be unaligned.
2104 This function returns the 24-bit value pointed to by Buffer. The function
2105 guarantees that the read operation does not produce an alignment fault.
2107 If the Buffer is NULL, then ASSERT().
2109 @param Buffer Pointer to a 24-bit value that may be unaligned.
2111 @return The value read.
2117 IN CONST UINT32
*Buffer
2122 Writes a 24-bit value to memory that may be unaligned.
2124 This function writes the 24-bit value specified by Value to Buffer. Value is
2125 returned. The function guarantees that the write operation does not produce
2128 If the Buffer is NULL, then ASSERT().
2130 @param Buffer Pointer to a 24-bit value that may be unaligned.
2131 @param Value 24-bit value to write to Buffer.
2133 @return The value written.
2145 Reads a 32-bit value from memory that may be unaligned.
2147 This function returns the 32-bit value pointed to by Buffer. The function
2148 guarantees that the read operation does not produce an alignment fault.
2150 If the Buffer is NULL, then ASSERT().
2152 @param Buffer Pointer to a 32-bit value that may be unaligned.
2160 IN CONST UINT32
*Uint32
2165 Writes a 32-bit value to memory that may be unaligned.
2167 This function writes the 32-bit value specified by Value to Buffer. Value is
2168 returned. The function guarantees that the write operation does not produce
2171 If the Buffer is NULL, then ASSERT().
2173 @param Buffer Pointer to a 32-bit value that may be unaligned.
2174 @param Value 32-bit value to write to Buffer.
2188 Reads a 64-bit value from memory that may be unaligned.
2190 This function returns the 64-bit value pointed to by Buffer. The function
2191 guarantees that the read operation does not produce an alignment fault.
2193 If the Buffer is NULL, then ASSERT().
2195 @param Buffer Pointer to a 64-bit value that may be unaligned.
2203 IN CONST UINT64
*Uint64
2208 Writes a 64-bit value to memory that may be unaligned.
2210 This function writes the 64-bit value specified by Value to Buffer. Value is
2211 returned. The function guarantees that the write operation does not produce
2214 If the Buffer is NULL, then ASSERT().
2216 @param Buffer Pointer to a 64-bit value that may be unaligned.
2217 @param Value 64-bit value to write to Buffer.
2231 // Bit Field Functions
2235 Returns a bit field from an 8-bit value.
2237 Returns the bitfield specified by the StartBit and the EndBit from Operand.
2239 If 8-bit operations are not supported, then ASSERT().
2240 If StartBit is greater than 7, then ASSERT().
2241 If EndBit is greater than 7, then ASSERT().
2242 If EndBit is less than StartBit, then ASSERT().
2244 @param Operand Operand on which to perform the bitfield operation.
2245 @param StartBit The ordinal of the least significant bit in the bit field.
2247 @param EndBit The ordinal of the most significant bit in the bit field.
2250 @return The bit field read.
2263 Writes a bit field to an 8-bit value, and returns the result.
2265 Writes Value to the bit field specified by the StartBit and the EndBit in
2266 Operand. All other bits in Operand are preserved. The new 8-bit value is
2269 If 8-bit operations are not supported, then ASSERT().
2270 If StartBit is greater than 7, then ASSERT().
2271 If EndBit is greater than 7, then ASSERT().
2272 If EndBit is less than StartBit, then ASSERT().
2274 @param Operand Operand on which to perform the bitfield operation.
2275 @param StartBit The ordinal of the least significant bit in the bit field.
2277 @param EndBit The ordinal of the most significant bit in the bit field.
2279 @param Value New value of the bit field.
2281 @return The new 8-bit value.
2295 Reads a bit field from an 8-bit value, performs a bitwise OR, and returns the
2298 Performs a bitwise inclusive OR between the bit field specified by StartBit
2299 and EndBit in Operand and the value specified by OrData. All other bits in
2300 Operand are preserved. The new 8-bit value is returned.
2302 If 8-bit operations are not supported, then ASSERT().
2303 If StartBit is greater than 7, then ASSERT().
2304 If EndBit is greater than 7, then ASSERT().
2305 If EndBit is less than StartBit, then ASSERT().
2307 @param Operand Operand on which to perform the bitfield operation.
2308 @param StartBit The ordinal of the least significant bit in the bit field.
2310 @param EndBit The ordinal of the most significant bit in the bit field.
2312 @param OrData The value to OR with the read value from the value
2314 @return The new 8-bit value.
2328 Reads a bit field from an 8-bit value, performs a bitwise AND, and returns
2331 Performs a bitwise AND between the bit field specified by StartBit and EndBit
2332 in Operand and the value specified by AndData. All other bits in Operand are
2333 preserved. The new 8-bit value is returned.
2335 If 8-bit operations are not supported, then ASSERT().
2336 If StartBit is greater than 7, then ASSERT().
2337 If EndBit is greater than 7, then ASSERT().
2338 If EndBit is less than StartBit, then ASSERT().
2340 @param Operand Operand on which to perform the bitfield operation.
2341 @param StartBit The ordinal of the least significant bit in the bit field.
2343 @param EndBit The ordinal of the most significant bit in the bit field.
2345 @param AndData The value to AND with the read value from the value.
2347 @return The new 8-bit value.
2361 Reads a bit field from an 8-bit value, performs a bitwise AND followed by a
2362 bitwise OR, and returns the result.
2364 Performs a bitwise AND between the bit field specified by StartBit and EndBit
2365 in Operand and the value specified by AndData, followed by a bitwise
2366 inclusive OR with value specified by OrData. All other bits in Operand are
2367 preserved. The new 8-bit value is returned.
2369 If 8-bit operations are not supported, then ASSERT().
2370 If StartBit is greater than 7, then ASSERT().
2371 If EndBit is greater than 7, then ASSERT().
2372 If EndBit is less than StartBit, then ASSERT().
2374 @param Operand Operand on which to perform the bitfield operation.
2375 @param StartBit The ordinal of the least significant bit in the bit field.
2377 @param EndBit The ordinal of the most significant bit in the bit field.
2379 @param AndData The value to AND with the read value from the value.
2380 @param OrData The value to OR with the result of the AND operation.
2382 @return The new 8-bit value.
2387 BitFieldAndThenOr8 (
2397 Returns a bit field from a 16-bit value.
2399 Returns the bitfield specified by the StartBit and the EndBit from Operand.
2401 If 16-bit operations are not supported, then ASSERT().
2402 If StartBit is greater than 15, then ASSERT().
2403 If EndBit is greater than 15, then ASSERT().
2404 If EndBit is less than StartBit, then ASSERT().
2406 @param Operand Operand on which to perform the bitfield operation.
2407 @param StartBit The ordinal of the least significant bit in the bit field.
2409 @param EndBit The ordinal of the most significant bit in the bit field.
2412 @return The bit field read.
2425 Writes a bit field to a 16-bit value, and returns the result.
2427 Writes Value to the bit field specified by the StartBit and the EndBit in
2428 Operand. All other bits in Operand are preserved. The new 16-bit value is
2431 If 16-bit operations are not supported, then ASSERT().
2432 If StartBit is greater than 15, then ASSERT().
2433 If EndBit is greater than 15, then ASSERT().
2434 If EndBit is less than StartBit, then ASSERT().
2436 @param Operand Operand on which to perform the bitfield operation.
2437 @param StartBit The ordinal of the least significant bit in the bit field.
2439 @param EndBit The ordinal of the most significant bit in the bit field.
2441 @param Value New value of the bit field.
2443 @return The new 16-bit value.
2457 Reads a bit field from a 16-bit value, performs a bitwise OR, and returns the
2460 Performs a bitwise inclusive OR between the bit field specified by StartBit
2461 and EndBit in Operand and the value specified by OrData. All other bits in
2462 Operand are preserved. The new 16-bit value is returned.
2464 If 16-bit operations are not supported, then ASSERT().
2465 If StartBit is greater than 15, then ASSERT().
2466 If EndBit is greater than 15, then ASSERT().
2467 If EndBit is less than StartBit, then ASSERT().
2469 @param Operand Operand on which to perform the bitfield operation.
2470 @param StartBit The ordinal of the least significant bit in the bit field.
2472 @param EndBit The ordinal of the most significant bit in the bit field.
2474 @param OrData The value to OR with the read value from the value
2476 @return The new 16-bit value.
2490 Reads a bit field from a 16-bit value, performs a bitwise AND, and returns
2493 Performs a bitwise AND between the bit field specified by StartBit and EndBit
2494 in Operand and the value specified by AndData. All other bits in Operand are
2495 preserved. The new 16-bit value is returned.
2497 If 16-bit operations are not supported, then ASSERT().
2498 If StartBit is greater than 15, then ASSERT().
2499 If EndBit is greater than 15, then ASSERT().
2500 If EndBit is less than StartBit, then ASSERT().
2502 @param Operand Operand on which to perform the bitfield operation.
2503 @param StartBit The ordinal of the least significant bit in the bit field.
2505 @param EndBit The ordinal of the most significant bit in the bit field.
2507 @param AndData The value to AND with the read value from the value
2509 @return The new 16-bit value.
2523 Reads a bit field from a 16-bit value, performs a bitwise AND followed by a
2524 bitwise OR, and returns the result.
2526 Performs a bitwise AND between the bit field specified by StartBit and EndBit
2527 in Operand and the value specified by AndData, followed by a bitwise
2528 inclusive OR with value specified by OrData. All other bits in Operand are
2529 preserved. The new 16-bit value is returned.
2531 If 16-bit operations are not supported, then ASSERT().
2532 If StartBit is greater than 15, then ASSERT().
2533 If EndBit is greater than 15, then ASSERT().
2534 If EndBit is less than StartBit, then ASSERT().
2536 @param Operand Operand on which to perform the bitfield operation.
2537 @param StartBit The ordinal of the least significant bit in the bit field.
2539 @param EndBit The ordinal of the most significant bit in the bit field.
2541 @param AndData The value to AND with the read value from the value.
2542 @param OrData The value to OR with the result of the AND operation.
2544 @return The new 16-bit value.
2549 BitFieldAndThenOr16 (
2559 Returns a bit field from a 32-bit value.
2561 Returns the bitfield specified by the StartBit and the EndBit from Operand.
2563 If 32-bit operations are not supported, then ASSERT().
2564 If StartBit is greater than 31, then ASSERT().
2565 If EndBit is greater than 31, then ASSERT().
2566 If EndBit is less than StartBit, then ASSERT().
2568 @param Operand Operand on which to perform the bitfield operation.
2569 @param StartBit The ordinal of the least significant bit in the bit field.
2571 @param EndBit The ordinal of the most significant bit in the bit field.
2574 @return The bit field read.
2587 Writes a bit field to a 32-bit value, and returns the result.
2589 Writes Value to the bit field specified by the StartBit and the EndBit in
2590 Operand. All other bits in Operand are preserved. The new 32-bit value is
2593 If 32-bit operations are not supported, then ASSERT().
2594 If StartBit is greater than 31, then ASSERT().
2595 If EndBit is greater than 31, then ASSERT().
2596 If EndBit is less than StartBit, then ASSERT().
2598 @param Operand Operand on which to perform the bitfield operation.
2599 @param StartBit The ordinal of the least significant bit in the bit field.
2601 @param EndBit The ordinal of the most significant bit in the bit field.
2603 @param Value New value of the bit field.
2605 @return The new 32-bit value.
2619 Reads a bit field from a 32-bit value, performs a bitwise OR, and returns the
2622 Performs a bitwise inclusive OR between the bit field specified by StartBit
2623 and EndBit in Operand and the value specified by OrData. All other bits in
2624 Operand are preserved. The new 32-bit value is returned.
2626 If 32-bit operations are not supported, then ASSERT().
2627 If StartBit is greater than 31, then ASSERT().
2628 If EndBit is greater than 31, then ASSERT().
2629 If EndBit is less than StartBit, then ASSERT().
2631 @param Operand Operand on which to perform the bitfield operation.
2632 @param StartBit The ordinal of the least significant bit in the bit field.
2634 @param EndBit The ordinal of the most significant bit in the bit field.
2636 @param OrData The value to OR with the read value from the value
2638 @return The new 32-bit value.
2652 Reads a bit field from a 32-bit value, performs a bitwise AND, and returns
2655 Performs a bitwise AND between the bit field specified by StartBit and EndBit
2656 in Operand and the value specified by AndData. All other bits in Operand are
2657 preserved. The new 32-bit value is returned.
2659 If 32-bit operations are not supported, then ASSERT().
2660 If StartBit is greater than 31, then ASSERT().
2661 If EndBit is greater than 31, then ASSERT().
2662 If EndBit is less than StartBit, then ASSERT().
2664 @param Operand Operand on which to perform the bitfield operation.
2665 @param StartBit The ordinal of the least significant bit in the bit field.
2667 @param EndBit The ordinal of the most significant bit in the bit field.
2669 @param AndData The value to AND with the read value from the value
2671 @return The new 32-bit value.
2685 Reads a bit field from a 32-bit value, performs a bitwise AND followed by a
2686 bitwise OR, and returns the result.
2688 Performs a bitwise AND between the bit field specified by StartBit and EndBit
2689 in Operand and the value specified by AndData, followed by a bitwise
2690 inclusive OR with value specified by OrData. All other bits in Operand are
2691 preserved. The new 32-bit value is returned.
2693 If 32-bit operations are not supported, then ASSERT().
2694 If StartBit is greater than 31, then ASSERT().
2695 If EndBit is greater than 31, then ASSERT().
2696 If EndBit is less than StartBit, then ASSERT().
2698 @param Operand Operand on which to perform the bitfield operation.
2699 @param StartBit The ordinal of the least significant bit in the bit field.
2701 @param EndBit The ordinal of the most significant bit in the bit field.
2703 @param AndData The value to AND with the read value from the value.
2704 @param OrData The value to OR with the result of the AND operation.
2706 @return The new 32-bit value.
2711 BitFieldAndThenOr32 (
2721 Returns a bit field from a 64-bit value.
2723 Returns the bitfield specified by the StartBit and the EndBit from Operand.
2725 If 64-bit operations are not supported, then ASSERT().
2726 If StartBit is greater than 63, then ASSERT().
2727 If EndBit is greater than 63, then ASSERT().
2728 If EndBit is less than StartBit, then ASSERT().
2730 @param Operand Operand on which to perform the bitfield operation.
2731 @param StartBit The ordinal of the least significant bit in the bit field.
2733 @param EndBit The ordinal of the most significant bit in the bit field.
2736 @return The bit field read.
2749 Writes a bit field to a 64-bit value, and returns the result.
2751 Writes Value to the bit field specified by the StartBit and the EndBit in
2752 Operand. All other bits in Operand are preserved. The new 64-bit value is
2755 If 64-bit operations are not supported, then ASSERT().
2756 If StartBit is greater than 63, then ASSERT().
2757 If EndBit is greater than 63, then ASSERT().
2758 If EndBit is less than StartBit, then ASSERT().
2760 @param Operand Operand on which to perform the bitfield operation.
2761 @param StartBit The ordinal of the least significant bit in the bit field.
2763 @param EndBit The ordinal of the most significant bit in the bit field.
2765 @param Value New value of the bit field.
2767 @return The new 64-bit value.
2781 Reads a bit field from a 64-bit value, performs a bitwise OR, and returns the
2784 Performs a bitwise inclusive OR between the bit field specified by StartBit
2785 and EndBit in Operand and the value specified by OrData. All other bits in
2786 Operand are preserved. The new 64-bit value is returned.
2788 If 64-bit operations are not supported, then ASSERT().
2789 If StartBit is greater than 63, then ASSERT().
2790 If EndBit is greater than 63, then ASSERT().
2791 If EndBit is less than StartBit, then ASSERT().
2793 @param Operand Operand on which to perform the bitfield operation.
2794 @param StartBit The ordinal of the least significant bit in the bit field.
2796 @param EndBit The ordinal of the most significant bit in the bit field.
2798 @param OrData The value to OR with the read value from the value
2800 @return The new 64-bit value.
2814 Reads a bit field from a 64-bit value, performs a bitwise AND, and returns
2817 Performs a bitwise AND between the bit field specified by StartBit and EndBit
2818 in Operand and the value specified by AndData. All other bits in Operand are
2819 preserved. The new 64-bit value is returned.
2821 If 64-bit operations are not supported, then ASSERT().
2822 If StartBit is greater than 63, then ASSERT().
2823 If EndBit is greater than 63, then ASSERT().
2824 If EndBit is less than StartBit, then ASSERT().
2826 @param Operand Operand on which to perform the bitfield operation.
2827 @param StartBit The ordinal of the least significant bit in the bit field.
2829 @param EndBit The ordinal of the most significant bit in the bit field.
2831 @param AndData The value to AND with the read value from the value
2833 @return The new 64-bit value.
2847 Reads a bit field from a 64-bit value, performs a bitwise AND followed by a
2848 bitwise OR, and returns the result.
2850 Performs a bitwise AND between the bit field specified by StartBit and EndBit
2851 in Operand and the value specified by AndData, followed by a bitwise
2852 inclusive OR with value specified by OrData. All other bits in Operand are
2853 preserved. The new 64-bit value is returned.
2855 If 64-bit operations are not supported, then ASSERT().
2856 If StartBit is greater than 63, then ASSERT().
2857 If EndBit is greater than 63, then ASSERT().
2858 If EndBit is less than StartBit, then ASSERT().
2860 @param Operand Operand on which to perform the bitfield operation.
2861 @param StartBit The ordinal of the least significant bit in the bit field.
2863 @param EndBit The ordinal of the most significant bit in the bit field.
2865 @param AndData The value to AND with the read value from the value.
2866 @param OrData The value to OR with the result of the AND operation.
2868 @return The new 64-bit value.
2873 BitFieldAndThenOr64 (
2883 // Base Library Synchronization Functions
2887 Retrieves the architecture specific spin lock alignment requirements for
2888 optimal spin lock performance.
2890 This function retrieves the spin lock alignment requirements for optimal
2891 performance on a given CPU architecture. The spin lock alignment must be a
2892 power of two and is returned by this function. If there are no alignment
2893 requirements, then 1 must be returned. The spin lock synchronization
2894 functions must function correctly if the spin lock size and alignment values
2895 returned by this function are not used at all. These values are hints to the
2896 consumers of the spin lock synchronization functions to obtain optimal spin
2899 @return The architecture specific spin lock alignment.
2904 GetSpinLockProperties (
2910 Initializes a spin lock to the released state and returns the spin lock.
2912 This function initializes the spin lock specified by SpinLock to the released
2913 state, and returns SpinLock. Optimal performance can be achieved by calling
2914 GetSpinLockProperties() to determine the size and alignment requirements for
2917 If SpinLock is NULL, then ASSERT().
2919 @param SpinLock A pointer to the spin lock to initialize to the released
2927 InitializeSpinLock (
2928 IN SPIN_LOCK
*SpinLock
2933 Waits until a spin lock can be placed in the acquired state.
2935 This function checks the state of the spin lock specified by SpinLock. If
2936 SpinLock is in the released state, then this function places SpinLock in the
2937 acquired state and returns SpinLock. Otherwise, this function waits
2938 indefinitely for the spin lock to be released, and then places it in the
2939 acquired state and returns SpinLock. All state transitions of SpinLock must
2940 be performed using MP safe mechanisms.
2942 If SpinLock is NULL, then ASSERT().
2943 If SpinLock was not initialized with InitializeSpinLock(), then ASSERT().
2944 If PcdSpinLockTimeout is not zero, and SpinLock is can not be acquired in
2945 PcdSpinLockTimeout microseconds, then ASSERT().
2947 @param SpinLock A pointer to the spin lock to place in the acquired state.
2955 IN SPIN_LOCK
*SpinLock
2960 Attempts to place a spin lock in the acquired state.
2962 This function checks the state of the spin lock specified by SpinLock. If
2963 SpinLock is in the released state, then this function places SpinLock in the
2964 acquired state and returns TRUE. Otherwise, FALSE is returned. All state
2965 transitions of SpinLock must be performed using MP safe mechanisms.
2967 If SpinLock is NULL, then ASSERT().
2968 If SpinLock was not initialized with InitializeSpinLock(), then ASSERT().
2970 @param SpinLock A pointer to the spin lock to place in the acquired state.
2972 @retval TRUE SpinLock was placed in the acquired state.
2973 @retval FALSE SpinLock could not be acquired.
2978 AcquireSpinLockOrFail (
2979 IN SPIN_LOCK
*SpinLock
2984 Releases a spin lock.
2986 This function places the spin lock specified by SpinLock in the release state
2987 and returns SpinLock.
2989 If SpinLock is NULL, then ASSERT().
2990 If SpinLock was not initialized with InitializeSpinLock(), then ASSERT().
2992 @param SpinLock A pointer to the spin lock to release.
3000 IN SPIN_LOCK
*SpinLock
3005 Performs an atomic increment of an 32-bit unsigned integer.
3007 Performs an atomic increment of the 32-bit unsigned integer specified by
3008 Value and returns the incremented value. The increment operation must be
3009 performed using MP safe mechanisms. The state of the return value is not
3010 guaranteed to be MP safe.
3012 If Value is NULL, then ASSERT().
3014 @param Value A pointer to the 32-bit value to increment.
3016 @return The incremented value.
3021 InterlockedIncrement (
3027 Performs an atomic decrement of an 32-bit unsigned integer.
3029 Performs an atomic decrement of the 32-bit unsigned integer specified by
3030 Value and returns the decremented value. The decrement operation must be
3031 performed using MP safe mechanisms. The state of the return value is not
3032 guaranteed to be MP safe.
3034 If Value is NULL, then ASSERT().
3036 @param Value A pointer to the 32-bit value to decrement.
3038 @return The decremented value.
3043 InterlockedDecrement (
3049 Performs an atomic compare exchange operation on a 32-bit unsigned integer.
3051 Performs an atomic compare exchange operation on the 32-bit unsigned integer
3052 specified by Value. If Value is equal to CompareValue, then Value is set to
3053 ExchangeValue and CompareValue is returned. If Value is not equal to CompareValue,
3054 then Value is returned. The compare exchange operation must be performed using
3057 If Value is NULL, then ASSERT().
3059 @param Value A pointer to the 32-bit value for the compare exchange
3061 @param CompareValue 32-bit value used in compare operation.
3062 @param ExchangeValue 32-bit value used in exchange operation.
3064 @return The original *Value before exchange.
3069 InterlockedCompareExchange32 (
3070 IN OUT UINT32
*Value
,
3071 IN UINT32 CompareValue
,
3072 IN UINT32 ExchangeValue
3077 Performs an atomic compare exchange operation on a 64-bit unsigned integer.
3079 Performs an atomic compare exchange operation on the 64-bit unsigned integer specified
3080 by Value. If Value is equal to CompareValue, then Value is set to ExchangeValue and
3081 CompareValue is returned. If Value is not equal to CompareValue, then Value is returned.
3082 The compare exchange operation must be performed using MP safe mechanisms.
3084 If Value is NULL, then ASSERT().
3086 @param Value A pointer to the 64-bit value for the compare exchange
3088 @param CompareValue 64-bit value used in compare operation.
3089 @param ExchangeValue 64-bit value used in exchange operation.
3091 @return The original *Value before exchange.
3096 InterlockedCompareExchange64 (
3097 IN OUT UINT64
*Value
,
3098 IN UINT64 CompareValue
,
3099 IN UINT64 ExchangeValue
3104 Performs an atomic compare exchange operation on a pointer value.
3106 Performs an atomic compare exchange operation on the pointer value specified
3107 by Value. If Value is equal to CompareValue, then Value is set to
3108 ExchangeValue and CompareValue is returned. If Value is not equal to
3109 CompareValue, then Value is returned. The compare exchange operation must be
3110 performed using MP safe mechanisms.
3112 If Value is NULL, then ASSERT().
3114 @param Value A pointer to the pointer value for the compare exchange
3116 @param CompareValue Pointer value used in compare operation.
3117 @param ExchangeValue Pointer value used in exchange operation.
3122 InterlockedCompareExchangePointer (
3123 IN OUT VOID
**Value
,
3124 IN VOID
*CompareValue
,
3125 IN VOID
*ExchangeValue
3130 // Base Library Checksum Functions
3134 Calculate the sum of all elements in a buffer in unit of UINT8.
3135 During calculation, the carry bits are dropped.
3137 This function calculates the sum of all elements in a buffer
3138 in unit of UINT8. The carry bits in result of addition are dropped.
3139 The result is returned as UINT8. If Length is Zero, then Zero is
3142 If Buffer is NULL, then ASSERT().
3143 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
3145 @param Buffer Pointer to the buffer to carry out the sum operation.
3146 @param Length The size, in bytes, of Buffer .
3148 @return Sum The sum of Buffer with carry bits dropped during additions.
3154 IN CONST UINT8
*Buffer
,
3160 Returns the two's complement checksum of all elements in a buffer
3163 This function first calculates the sum of the 8-bit values in the
3164 buffer specified by Buffer and Length. The carry bits in the result
3165 of addition are dropped. Then, the two's complement of the sum is
3166 returned. If Length is 0, then 0 is returned.
3168 If Buffer is NULL, then ASSERT().
3169 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
3172 @param Buffer Pointer to the buffer to carry out the checksum operation.
3173 @param Length The size, in bytes, of Buffer.
3175 @return Checksum The 2's complement checksum of Buffer.
3180 CalculateCheckSum8 (
3181 IN CONST UINT8
*Buffer
,
3187 Returns the sum of all elements in a buffer of 16-bit values. During
3188 calculation, the carry bits are dropped.
3190 This function calculates the sum of the 16-bit values in the buffer
3191 specified by Buffer and Length. The carry bits in result of addition are dropped.
3192 The 16-bit result is returned. If Length is 0, then 0 is returned.
3194 If Buffer is NULL, then ASSERT().
3195 If Buffer is not aligned on a 16-bit boundary, then ASSERT().
3196 If Length is not aligned on a 16-bit boundary, then ASSERT().
3197 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
3199 @param Buffer Pointer to the buffer to carry out the sum operation.
3200 @param Length The size, in bytes, of Buffer.
3202 @return Sum The sum of Buffer with carry bits dropped during additions.
3208 IN CONST UINT16
*Buffer
,
3214 Returns the two's complement checksum of all elements in a buffer of
3217 This function first calculates the sum of the 16-bit values in the buffer
3218 specified by Buffer and Length. The carry bits in the result of addition
3219 are dropped. Then, the two's complement of the sum is returned. If Length
3220 is 0, then 0 is returned.
3222 If Buffer is NULL, then ASSERT().
3223 If Buffer is not aligned on a 16-bit boundary, then ASSERT().
3224 If Length is not aligned on a 16-bit boundary, then ASSERT().
3225 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
3227 @param Buffer Pointer to the buffer to carry out the checksum operation.
3228 @param Length The size, in bytes, of Buffer.
3230 @return Checksum The 2's complement checksum of Buffer.
3235 CalculateCheckSum16 (
3236 IN CONST UINT16
*Buffer
,
3242 Returns the sum of all elements in a buffer of 32-bit values. During
3243 calculation, the carry bits are dropped.
3245 This function calculates the sum of the 32-bit values in the buffer
3246 specified by Buffer and Length. The carry bits in result of addition are dropped.
3247 The 32-bit result is returned. If Length is 0, then 0 is returned.
3249 If Buffer is NULL, then ASSERT().
3250 If Buffer is not aligned on a 32-bit boundary, then ASSERT().
3251 If Length is not aligned on a 32-bit boundary, then ASSERT().
3252 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
3254 @param Buffer Pointer to the buffer to carry out the sum operation.
3255 @param Length The size, in bytes, of Buffer.
3257 @return Sum The sum of Buffer with carry bits dropped during additions.
3263 IN CONST UINT32
*Buffer
,
3269 Returns the two's complement checksum of all elements in a buffer of
3272 This function first calculates the sum of the 32-bit values in the buffer
3273 specified by Buffer and Length. The carry bits in the result of addition
3274 are dropped. Then, the two's complement of the sum is returned. If Length
3275 is 0, then 0 is returned.
3277 If Buffer is NULL, then ASSERT().
3278 If Buffer is not aligned on a 32-bit boundary, then ASSERT().
3279 If Length is not aligned on a 32-bit boundary, then ASSERT().
3280 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
3282 @param Buffer Pointer to the buffer to carry out the checksum operation.
3283 @param Length The size, in bytes, of Buffer.
3285 @return Checksum The 2's complement checksum of Buffer.
3290 CalculateCheckSum32 (
3291 IN CONST UINT32
*Buffer
,
3297 Returns the sum of all elements in a buffer of 64-bit values. During
3298 calculation, the carry bits are dropped.
3300 This function calculates the sum of the 64-bit values in the buffer
3301 specified by Buffer and Length. The carry bits in result of addition are dropped.
3302 The 64-bit result is returned. If Length is 0, then 0 is returned.
3304 If Buffer is NULL, then ASSERT().
3305 If Buffer is not aligned on a 64-bit boundary, then ASSERT().
3306 If Length is not aligned on a 64-bit boundary, then ASSERT().
3307 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
3309 @param Buffer Pointer to the buffer to carry out the sum operation.
3310 @param Length The size, in bytes, of Buffer.
3312 @return Sum The sum of Buffer with carry bits dropped during additions.
3318 IN CONST UINT64
*Buffer
,
3324 Returns the two's complement checksum of all elements in a buffer of
3327 This function first calculates the sum of the 64-bit values in the buffer
3328 specified by Buffer and Length. The carry bits in the result of addition
3329 are dropped. Then, the two's complement of the sum is returned. If Length
3330 is 0, then 0 is returned.
3332 If Buffer is NULL, then ASSERT().
3333 If Buffer is not aligned on a 64-bit boundary, then ASSERT().
3334 If Length is not aligned on a 64-bit boundary, then ASSERT().
3335 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
3337 @param Buffer Pointer to the buffer to carry out the checksum operation.
3338 @param Length The size, in bytes, of Buffer.
3340 @return Checksum The 2's complement checksum of Buffer.
3345 CalculateCheckSum64 (
3346 IN CONST UINT64
*Buffer
,
3352 // Base Library CPU Functions
3356 (EFIAPI
*SWITCH_STACK_ENTRY_POINT
) (
3357 IN VOID
*Context1
, OPTIONAL
3358 IN VOID
*Context2 OPTIONAL
3363 Used to serialize load and store operations.
3365 All loads and stores that proceed calls to this function are guaranteed to be
3366 globally visible when this function returns.
3377 Saves the current CPU context that can be restored with a call to LongJump()
3380 Saves the current CPU context in the buffer specified by JumpBuffer and
3381 returns 0. The initial call to SetJump() must always return 0. Subsequent
3382 calls to LongJump() cause a non-zero value to be returned by SetJump().
3384 If JumpBuffer is NULL, then ASSERT().
3385 For IPF CPUs, if JumpBuffer is not aligned on a 16-byte boundary, then ASSERT().
3387 @param JumpBuffer A pointer to CPU context buffer.
3389 @retval 0 Indicates a return from SetJump().
3395 OUT BASE_LIBRARY_JUMP_BUFFER
*JumpBuffer
3400 Restores the CPU context that was saved with SetJump().
3402 Restores the CPU context from the buffer specified by JumpBuffer. This
3403 function never returns to the caller. Instead is resumes execution based on
3404 the state of JumpBuffer.
3406 If JumpBuffer is NULL, then ASSERT().
3407 For IPF CPUs, if JumpBuffer is not aligned on a 16-byte boundary, then ASSERT().
3408 If Value is 0, then ASSERT().
3410 @param JumpBuffer A pointer to CPU context buffer.
3411 @param Value The value to return when the SetJump() context is
3412 restored and must be non-zero.
3418 IN BASE_LIBRARY_JUMP_BUFFER
*JumpBuffer
,
3424 Enables CPU interrupts.
3426 Enables CPU interrupts.
3437 Disables CPU interrupts.
3439 Disables CPU interrupts.
3450 Disables CPU interrupts and returns the interrupt state prior to the disable
3453 Disables CPU interrupts and returns the interrupt state prior to the disable
3456 @retval TRUE CPU interrupts were enabled on entry to this call.
3457 @retval FALSE CPU interrupts were disabled on entry to this call.
3462 SaveAndDisableInterrupts (
3468 Enables CPU interrupts for the smallest window required to capture any
3471 Enables CPU interrupts for the smallest window required to capture any
3477 EnableDisableInterrupts (
3483 Retrieves the current CPU interrupt state.
3485 Retrieves the current CPU interrupt state. Returns TRUE is interrupts are
3486 currently enabled. Otherwise returns FALSE.
3488 @retval TRUE CPU interrupts are enabled.
3489 @retval FALSE CPU interrupts are disabled.
3500 Set the current CPU interrupt state.
3502 Sets the current CPU interrupt state to the state specified by
3503 InterruptState. If InterruptState is TRUE, then interrupts are enabled. If
3504 InterruptState is FALSE, then interrupts are disabled. InterruptState is
3507 @param InterruptState TRUE if interrupts should enabled. FALSE if
3508 interrupts should be disabled.
3510 @return InterruptState
3516 IN BOOLEAN InterruptState
3521 Places the CPU in a sleep state until an interrupt is received.
3523 Places the CPU in a sleep state until an interrupt is received. If interrupts
3524 are disabled prior to calling this function, then the CPU will be placed in a
3525 sleep state indefinitely.
3536 Requests CPU to pause for a short period of time.
3538 Requests CPU to pause for a short period of time. Typically used in MP
3539 systems to prevent memory starvation while waiting for a spin lock.
3550 Flushes all the Translation Lookaside Buffers(TLB) entries in a CPU.
3552 Flushes all the Translation Lookaside Buffers(TLB) entries in a CPU.
3563 Transfers control to a function starting with a new stack.
3565 Transfers control to the function specified by EntryPoint using the
3566 new stack specified by NewStack and passing in the parameters specified
3567 by Context1 and Context2. Context1 and Context2 are optional and may
3568 be NULL. The function EntryPoint must never return. This function
3569 supports a variable number of arguments following the NewStack parameter.
3570 These additional arguments are ignored on IA-32, x64, and EBC.
3571 IPF CPUs expect one additional parameter of type VOID * that specifies
3572 the new backing store pointer.
3574 If EntryPoint is NULL, then ASSERT().
3575 If NewStack is NULL, then ASSERT().
3577 @param EntryPoint A pointer to function to call with the new stack.
3578 @param Context1 A pointer to the context to pass into the EntryPoint
3580 @param Context2 A pointer to the context to pass into the EntryPoint
3582 @param NewStack A pointer to the new stack to use for the EntryPoint
3589 IN SWITCH_STACK_ENTRY_POINT EntryPoint
,
3590 IN VOID
*Context1
, OPTIONAL
3591 IN VOID
*Context2
, OPTIONAL
3598 Generates a breakpoint on the CPU.
3600 Generates a breakpoint on the CPU. The breakpoint must be implemented such
3601 that code can resume normal execution after the breakpoint.
3612 Executes an infinite loop.
3614 Forces the CPU to execute an infinite loop. A debugger may be used to skip
3615 past the loop and the code that follows the loop must execute properly. This
3616 implies that the infinite loop must not cause the code that follow it to be
3627 #if defined (MDE_CPU_IPF)
3630 Flush a range of cache lines in the cache coherency domain of the calling
3633 Invalidates the cache lines specified by Address and Length. If Address is
3634 not aligned on a cache line boundary, then entire cache line containing
3635 Address is invalidated. If Address + Length is not aligned on a cache line
3636 boundary, then the entire instruction cache line containing Address + Length
3637 -1 is invalidated. This function may choose to invalidate the entire
3638 instruction cache if that is more efficient than invalidating the specified
3639 range. If Length is 0, the no instruction cache lines are invalidated.
3640 Address is returned.
3642 If Length is greater than (MAX_ADDRESS - Address + 1), then ASSERT().
3644 @param Address The base address of the instruction lines to invalidate. If
3645 the CPU is in a physical addressing mode, then Address is a
3646 physical address. If the CPU is in a virtual addressing mode,
3647 then Address is a virtual address.
3649 @param Length The number of bytes to invalidate from the instruction cache.
3656 IpfFlushCacheRange (
3663 Executes a FC instruction
3664 Executes a FC instruction on the cache line specified by Address.
3665 The cache line size affected is at least 32-bytes (aligned on a 32-byte boundary).
3666 An implementation may flush a larger region. This function is only available on IPF.
3668 @param Address The Address of cache line to be flushed.
3670 @return The address of FC instruction executed.
3681 Executes a FC.I instruction.
3682 Executes a FC.I instruction on the cache line specified by Address.
3683 The cache line size affected is at least 32-bytes (aligned on a 32-byte boundary).
3684 An implementation may flush a larger region. This function is only available on IPF.
3686 @param Address The Address of cache line to be flushed.
3688 @return The address of FC.I instruction executed.
3699 Reads the current value of a Processor Identifier Register (CPUID).
3700 The Index of largest implemented CPUID (One less than the number of implemented CPUID
3701 registers) is determined by CPUID [3] bits {7:0}.
3702 No parameter checking is performed on Index. If the Index value is beyond the
3703 implemented CPUID register range, a Reserved Register/Field fault may occur. The caller
3704 must either guarantee that Index is valid, or the caller must set up fault handlers to
3705 catch the faults. This function is only available on IPF.
3707 @param Index The 8-bit Processor Identifier Register index to read.
3709 @return The current value of Processor Identifier Register specified by Index.
3720 Reads the current value of 64-bit Processor Status Register (PSR).
3721 This function is only available on IPF.
3723 @return The current value of PSR.
3734 Writes the current value of 64-bit Processor Status Register (PSR).
3735 No parameter checking is performed on Value. All bits of Value corresponding to
3736 reserved fields of PSR must be 0 or a Reserved Register/Field fault may occur. The caller must either guarantee that Value is valid, or the caller must set up fault handlers to catch the faults.
3737 This function is only available on IPF.
3739 @param Value The 64-bit value to write to PSR.
3741 @return The 64-bit value written to the PSR.
3752 Reads the current value of 64-bit Kernel Register #0 (KR0).
3753 This function is only available on IPF.
3755 @return The current value of KR0.
3766 Reads the current value of 64-bit Kernel Register #1 (KR1).
3767 This function is only available on IPF.
3769 @return The current value of KR1.
3780 Reads the current value of 64-bit Kernel Register #2 (KR2).
3781 This function is only available on IPF.
3783 @return The current value of KR2.
3794 Reads the current value of 64-bit Kernel Register #3 (KR3).
3795 This function is only available on IPF.
3797 @return The current value of KR3.
3808 Reads the current value of 64-bit Kernel Register #4 (KR4).
3809 This function is only available on IPF.
3811 @return The current value of KR4.
3822 Reads the current value of 64-bit Kernel Register #5 (KR5).
3823 This function is only available on IPF.
3825 @return The current value of KR5.
3836 Reads the current value of 64-bit Kernel Register #6 (KR6).
3837 This function is only available on IPF.
3839 @return The current value of KR6.
3850 Reads the current value of 64-bit Kernel Register #7 (KR7).
3851 This function is only available on IPF.
3853 @return The current value of KR7.
3864 Write the current value of 64-bit Kernel Register #0 (KR0).
3865 This function is only available on IPF.
3867 @param Value The 64-bit value to write to KR0.
3869 @return The 64-bit value written to the KR0.
3880 Write the current value of 64-bit Kernel Register #1 (KR1).
3881 This function is only available on IPF.
3883 @param Value The 64-bit value to write to KR1.
3885 @return The 64-bit value written to the KR1.
3896 Write the current value of 64-bit Kernel Register #2 (KR2).
3897 This function is only available on IPF.
3899 @param Value The 64-bit value to write to KR2.
3901 @return The 64-bit value written to the KR2.
3912 Write the current value of 64-bit Kernel Register #3 (KR3).
3913 This function is only available on IPF.
3915 @param Value The 64-bit value to write to KR3.
3917 @return The 64-bit value written to the KR3.
3928 Write the current value of 64-bit Kernel Register #4 (KR4).
3929 This function is only available on IPF.
3931 @param Value The 64-bit value to write to KR4.
3933 @return The 64-bit value written to the KR4.
3944 Write the current value of 64-bit Kernel Register #5 (KR5).
3945 This function is only available on IPF.
3947 @param Value The 64-bit value to write to KR5.
3949 @return The 64-bit value written to the KR5.
3960 Write the current value of 64-bit Kernel Register #6 (KR6).
3961 This function is only available on IPF.
3963 @param Value The 64-bit value to write to KR6.
3965 @return The 64-bit value written to the KR6.
3976 Write the current value of 64-bit Kernel Register #7 (KR7).
3977 This function is only available on IPF.
3979 @param Value The 64-bit value to write to KR7.
3981 @return The 64-bit value written to the KR7.
3992 Reads the current value of Interval Timer Counter Register (ITC).
3993 This function is only available on IPF.
3995 @return The current value of ITC.
4006 Reads the current value of Interval Timer Vector Register (ITV).
4007 This function is only available on IPF.
4009 @return The current value of ITV.
4020 Reads the current value of Interval Timer Match Register (ITM).
4021 This function is only available on IPF.
4023 @return The current value of ITM.
4033 Writes the current value of 64-bit Interval Timer Counter Register (ITC).
4034 This function is only available on IPF.
4036 @param Value The 64-bit value to write to ITC.
4038 @return The 64-bit value written to the ITC.
4049 Writes the current value of 64-bit Interval Timer Match Register (ITM).
4050 This function is only available on IPF.
4052 @param Value The 64-bit value to write to ITM.
4054 @return The 64-bit value written to the ITM.
4065 Writes the current value of 64-bit Interval Timer Vector Register (ITV).
4066 No parameter checking is performed on Value. All bits of Value corresponding to
4067 reserved fields of ITV must be 0 or a Reserved Register/Field fault may occur.
4068 The caller must either guarantee that Value is valid, or the caller must set up
4069 fault handlers to catch the faults.
4070 This function is only available on IPF.
4072 @param Value The 64-bit value to write to ITV.
4074 @return The 64-bit value written to the ITV.
4085 Reads the current value of Default Control Register (DCR).
4086 This function is only available on IPF.
4088 @return The current value of DCR.
4099 Reads the current value of Interruption Vector Address Register (IVA).
4100 This function is only available on IPF.
4102 @return The current value of IVA.
4112 Reads the current value of Page Table Address Register (PTA).
4113 This function is only available on IPF.
4115 @return The current value of PTA.
4126 Writes the current value of 64-bit Default Control Register (DCR).
4127 No parameter checking is performed on Value. All bits of Value corresponding to
4128 reserved fields of DCR must be 0 or a Reserved Register/Field fault may occur.
4129 The caller must either guarantee that Value is valid, or the caller must set up
4130 fault handlers to catch the faults.
4131 This function is only available on IPF.
4133 @param Value The 64-bit value to write to DCR.
4135 @return The 64-bit value written to the DCR.
4146 Writes the current value of 64-bit Interruption Vector Address Register (IVA).
4147 The size of vector table is 32 K bytes and is 32 K bytes aligned
4148 the low 15 bits of Value is ignored when written.
4149 This function is only available on IPF.
4151 @param Value The 64-bit value to write to IVA.
4153 @return The 64-bit value written to the IVA.
4164 Writes the current value of 64-bit Page Table Address Register (PTA).
4165 No parameter checking is performed on Value. All bits of Value corresponding to
4166 reserved fields of DCR must be 0 or a Reserved Register/Field fault may occur.
4167 The caller must either guarantee that Value is valid, or the caller must set up
4168 fault handlers to catch the faults.
4169 This function is only available on IPF.
4171 @param Value The 64-bit value to write to PTA.
4173 @return The 64-bit value written to the PTA.
4183 Reads the current value of Local Interrupt ID Register (LID).
4184 This function is only available on IPF.
4186 @return The current value of LID.
4197 Reads the current value of External Interrupt Vector Register (IVR).
4198 This function is only available on IPF.
4200 @return The current value of IVR.
4211 Reads the current value of Task Priority Register (TPR).
4212 This function is only available on IPF.
4214 @return The current value of TPR.
4225 Reads the current value of External Interrupt Request Register #0 (IRR0).
4226 This function is only available on IPF.
4228 @return The current value of IRR0.
4239 Reads the current value of External Interrupt Request Register #1 (IRR1).
4240 This function is only available on IPF.
4242 @return The current value of IRR1.
4253 Reads the current value of External Interrupt Request Register #2 (IRR2).
4254 This function is only available on IPF.
4256 @return The current value of IRR2.
4267 Reads the current value of External Interrupt Request Register #3 (IRR3).
4268 This function is only available on IPF.
4270 @return The current value of IRR3.
4281 Reads the current value of Performance Monitor Vector Register (PMV).
4282 This function is only available on IPF.
4284 @return The current value of PMV.
4295 Reads the current value of Corrected Machine Check Vector Register (CMCV).
4296 This function is only available on IPF.
4298 @return The current value of CMCV.
4309 Reads the current value of Local Redirection Register #0 (LRR0).
4310 This function is only available on IPF.
4312 @return The current value of LRR0.
4323 Reads the current value of Local Redirection Register #1 (LRR1).
4324 This function is only available on IPF.
4326 @return The current value of LRR1.
4337 Writes the current value of 64-bit Page Local Interrupt ID Register (LID).
4338 No parameter checking is performed on Value. All bits of Value corresponding to
4339 reserved fields of LID must be 0 or a Reserved Register/Field fault may occur.
4340 The caller must either guarantee that Value is valid, or the caller must set up
4341 fault handlers to catch the faults.
4342 This function is only available on IPF.
4344 @param Value The 64-bit value to write to LID.
4346 @return The 64-bit value written to the LID.
4357 Writes the current value of 64-bit Task Priority Register (TPR).
4358 No parameter checking is performed on Value. All bits of Value corresponding to
4359 reserved fields of TPR must be 0 or a Reserved Register/Field fault may occur.
4360 The caller must either guarantee that Value is valid, or the caller must set up
4361 fault handlers to catch the faults.
4362 This function is only available on IPF.
4364 @param Value The 64-bit value to write to TPR.
4366 @return The 64-bit value written to the TPR.
4377 Performs a write operation on End OF External Interrupt Register (EOI).
4378 Writes a value of 0 to the EOI Register. This function is only available on IPF.
4389 Writes the current value of 64-bit Performance Monitor Vector Register (PMV).
4390 No parameter checking is performed on Value. All bits of Value corresponding
4391 to reserved fields of PMV must be 0 or a Reserved Register/Field fault may occur.
4392 The caller must either guarantee that Value is valid, or the caller must set up
4393 fault handlers to catch the faults.
4394 This function is only available on IPF.
4396 @param Value The 64-bit value to write to PMV.
4398 @return The 64-bit value written to the PMV.
4409 Writes the current value of 64-bit Corrected Machine Check Vector Register (CMCV).
4410 No parameter checking is performed on Value. All bits of Value corresponding
4411 to reserved fields of CMCV must be 0 or a Reserved Register/Field fault may occur.
4412 The caller must either guarantee that Value is valid, or the caller must set up
4413 fault handlers to catch the faults.
4414 This function is only available on IPF.
4416 @param Value The 64-bit value to write to CMCV.
4418 @return The 64-bit value written to the CMCV.
4429 Writes the current value of 64-bit Local Redirection Register #0 (LRR0).
4430 No parameter checking is performed on Value. All bits of Value corresponding
4431 to reserved fields of LRR0 must be 0 or a Reserved Register/Field fault may occur.
4432 The caller must either guarantee that Value is valid, or the caller must set up
4433 fault handlers to catch the faults.
4434 This function is only available on IPF.
4436 @param Value The 64-bit value to write to LRR0.
4438 @return The 64-bit value written to the LRR0.
4449 Writes the current value of 64-bit Local Redirection Register #1 (LRR1).
4450 No parameter checking is performed on Value. All bits of Value corresponding
4451 to reserved fields of LRR1 must be 0 or a Reserved Register/Field fault may occur.
4452 The caller must either guarantee that Value is valid, or the caller must
4453 set up fault handlers to catch the faults.
4454 This function is only available on IPF.
4456 @param Value The 64-bit value to write to LRR1.
4458 @return The 64-bit value written to the LRR1.
4469 Reads the current value of Instruction Breakpoint Register (IBR).
4471 The Instruction Breakpoint Registers are used in pairs. The even numbered
4472 registers contain breakpoint addresses, and the odd numbered registers contain
4473 breakpoint mask conditions. At least 4 instruction registers pairs are implemented
4474 on all processor models. Implemented registers are contiguous starting with
4475 register 0. No parameter checking is performed on Index, and if the Index value
4476 is beyond the implemented IBR register range, a Reserved Register/Field fault may
4477 occur. The caller must either guarantee that Index is valid, or the caller must
4478 set up fault handlers to catch the faults.
4479 This function is only available on IPF.
4481 @param Index The 8-bit Instruction Breakpoint Register index to read.
4483 @return The current value of Instruction Breakpoint Register specified by Index.
4494 Reads the current value of Data Breakpoint Register (DBR).
4496 The Data Breakpoint Registers are used in pairs. The even numbered registers
4497 contain breakpoint addresses, and odd numbered registers contain breakpoint
4498 mask conditions. At least 4 data registers pairs are implemented on all processor
4499 models. Implemented registers are contiguous starting with register 0.
4500 No parameter checking is performed on Index. If the Index value is beyond
4501 the implemented DBR register range, a Reserved Register/Field fault may occur.
4502 The caller must either guarantee that Index is valid, or the caller must set up
4503 fault handlers to catch the faults.
4504 This function is only available on IPF.
4506 @param Index The 8-bit Data Breakpoint Register index to read.
4508 @return The current value of Data Breakpoint Register specified by Index.
4519 Reads the current value of Performance Monitor Configuration Register (PMC).
4521 All processor implementations provide at least 4 performance counters
4522 (PMC/PMD [4]...PMC/PMD [7] pairs), and 4 performance monitor counter overflow
4523 status registers (PMC [0]¡ PMC [3]). Processor implementations may provide
4524 additional implementation-dependent PMC and PMD to increase the number of
4525 ¡®generic¡¯ performance counters (PMC/PMD pairs). The remainder of PMC and PMD
4526 register set is implementation dependent. No parameter checking is performed
4527 on Index. If the Index value is beyond the implemented PMC register range,
4528 zero value will be returned.
4529 This function is only available on IPF.
4531 @param Index The 8-bit Performance Monitor Configuration Register index to read.
4533 @return The current value of Performance Monitor Configuration Register
4545 Reads the current value of Performance Monitor Data Register (PMD).
4547 All processor implementations provide at least 4 performance counters
4548 (PMC/PMD [4]...PMC/PMD [7] pairs), and 4 performance monitor counter
4549 overflow status registers (PMC [0]¡ PMC [3]). Processor implementations may
4550 provide additional implementation-dependent PMC and PMD to increase the number
4551 of ¡®generic¡¯ performance counters (PMC/PMD pairs). The remainder of PMC and PMD
4552 register set is implementation dependent. No parameter checking is performed
4553 on Index. If the Index value is beyond the implemented PMD register range,
4554 zero value will be returned.
4555 This function is only available on IPF.
4557 @param Index The 8-bit Performance Monitor Data Register index to read.
4559 @return The current value of Performance Monitor Data Register specified by Index.
4570 Writes the current value of 64-bit Instruction Breakpoint Register (IBR).
4572 Writes current value of Instruction Breakpoint Register specified by Index.
4573 The Instruction Breakpoint Registers are used in pairs. The even numbered
4574 registers contain breakpoint addresses, and odd numbered registers contain
4575 breakpoint mask conditions. At least 4 instruction registers pairs are implemented
4576 on all processor models. Implemented registers are contiguous starting with
4577 register 0. No parameter checking is performed on Index. If the Index value
4578 is beyond the implemented IBR register range, a Reserved Register/Field fault may
4579 occur. The caller must either guarantee that Index is valid, or the caller must
4580 set up fault handlers to catch the faults.
4581 This function is only available on IPF.
4583 @param Index The 8-bit Instruction Breakpoint Register index to write.
4584 @param Value The 64-bit value to write to IBR.
4586 @return The 64-bit value written to the IBR.
4598 Writes the current value of 64-bit Data Breakpoint Register (DBR).
4600 Writes current value of Data Breakpoint Register specified by Index.
4601 The Data Breakpoint Registers are used in pairs. The even numbered registers
4602 contain breakpoint addresses, and odd numbered registers contain breakpoint
4603 mask conditions. At least 4 data registers pairs are implemented on all processor
4604 models. Implemented registers are contiguous starting with register 0. No parameter
4605 checking is performed on Index. If the Index value is beyond the implemented
4606 DBR register range, a Reserved Register/Field fault may occur. The caller must
4607 either guarantee that Index is valid, or the caller must set up fault handlers to
4609 This function is only available on IPF.
4611 @param Index The 8-bit Data Breakpoint Register index to write.
4612 @param Value The 64-bit value to write to DBR.
4614 @return The 64-bit value written to the DBR.
4626 Writes the current value of 64-bit Performance Monitor Configuration Register (PMC).
4628 Writes current value of Performance Monitor Configuration Register specified by Index.
4629 All processor implementations provide at least 4 performance counters
4630 (PMC/PMD [4]...PMC/PMD [7] pairs), and 4 performance monitor counter overflow status
4631 registers (PMC [0]¡ PMC [3]). Processor implementations may provide additional
4632 implementation-dependent PMC and PMD to increase the number of ¡®generic¡¯ performance
4633 counters (PMC/PMD pairs). The remainder of PMC and PMD register set is implementation
4634 dependent. No parameter checking is performed on Index. If the Index value is
4635 beyond the implemented PMC register range, the write is ignored.
4636 This function is only available on IPF.
4638 @param Index The 8-bit Performance Monitor Configuration Register index to write.
4639 @param Value The 64-bit value to write to PMC.
4641 @return The 64-bit value written to the PMC.
4653 Writes the current value of 64-bit Performance Monitor Data Register (PMD).
4655 Writes current value of Performance Monitor Data Register specified by Index.
4656 All processor implementations provide at least 4 performance counters
4657 (PMC/PMD [4]...PMC/PMD [7] pairs), and 4 performance monitor counter overflow
4658 status registers (PMC [0]¡ PMC [3]). Processor implementations may provide
4659 additional implementation-dependent PMC and PMD to increase the number of ¡®generic¡¯
4660 performance counters (PMC/PMD pairs). The remainder of PMC and PMD register set
4661 is implementation dependent. No parameter checking is performed on Index. If the
4662 Index value is beyond the implemented PMD register range, the write is ignored.
4663 This function is only available on IPF.
4665 @param Index The 8-bit Performance Monitor Data Register index to write.
4666 @param Value The 64-bit value to write to PMD.
4668 @return The 64-bit value written to the PMD.
4680 Reads the current value of 64-bit Global Pointer (GP).
4682 Reads and returns the current value of GP.
4683 This function is only available on IPF.
4685 @return The current value of GP.
4696 Write the current value of 64-bit Global Pointer (GP).
4698 Writes the current value of GP. The 64-bit value written to the GP is returned.
4699 No parameter checking is performed on Value.
4700 This function is only available on IPF.
4702 @param Value The 64-bit value to write to GP.
4704 @return The 64-bit value written to the GP.
4715 Reads the current value of 64-bit Stack Pointer (SP).
4717 Reads and returns the current value of SP.
4718 This function is only available on IPF.
4720 @return The current value of SP.
4731 Determines if the CPU is currently executing in virtual, physical, or mixed mode.
4733 Determines the current execution mode of the CPU.
4734 If the CPU is in virtual mode(PSR.RT=1, PSR.DT=1, PSR.IT=1), then 1 is returned.
4735 If the CPU is in physical mode(PSR.RT=0, PSR.DT=0, PSR.IT=0), then 0 is returned.
4736 If the CPU is not in physical mode or virtual mode, then it is in mixed mode,
4738 This function is only available on IPF.
4740 @return 1 The CPU is in virtual mode.
4741 @return 0 The CPU is in physical mode.
4742 @return -1 The CPU is in mixed mode.
4753 Makes a PAL procedure call.
4755 This is a wrapper function to make a PAL procedure call. Based on the Index
4756 value this API will make static or stacked PAL call. The following table
4757 describes the usage of PAL Procedure Index Assignment. Architected procedures
4758 may be designated as required or optional. If a PAL procedure is specified
4759 as optional, a unique return code of 0xFFFFFFFFFFFFFFFF is returned in the
4760 Status field of the PAL_CALL_RETURN structure.
4761 This indicates that the procedure is not present in this PAL implementation.
4762 It is the caller¡¯s responsibility to check for this return code after calling
4763 any optional PAL procedure.
4764 No parameter checking is performed on the 5 input parameters, but there are
4765 some common rules that the caller should follow when making a PAL call. Any
4766 address passed to PAL as buffers for return parameters must be 8-byte aligned.
4767 Unaligned addresses may cause undefined results. For those parameters defined
4768 as reserved or some fields defined as reserved must be zero filled or the invalid
4769 argument return value may be returned or undefined result may occur during the
4770 execution of the procedure. If the PalEntryPoint does not point to a valid
4771 PAL entry point then the system behavior is undefined. This function is only
4774 @param PalEntryPoint The PAL procedure calls entry point.
4775 @param Index The PAL procedure Index number.
4776 @param Arg2 The 2nd parameter for PAL procedure calls.
4777 @param Arg3 The 3rd parameter for PAL procedure calls.
4778 @param Arg4 The 4th parameter for PAL procedure calls.
4780 @return structure returned from the PAL Call procedure, including the status and return value.
4786 IN UINT64 PalEntryPoint
,
4795 Transfers control to a function starting with a new stack.
4797 Transfers control to the function specified by EntryPoint using the new stack
4798 specified by NewStack and passing in the parameters specified by Context1 and
4799 Context2. Context1 and Context2 are optional and may be NULL. The function
4800 EntryPoint must never return.
4802 If EntryPoint is NULL, then ASSERT().
4803 If NewStack is NULL, then ASSERT().
4805 @param EntryPoint A pointer to function to call with the new stack.
4806 @param Context1 A pointer to the context to pass into the EntryPoint
4808 @param Context2 A pointer to the context to pass into the EntryPoint
4810 @param NewStack A pointer to the new stack to use for the EntryPoint
4812 @param NewBsp A pointer to the new memory location for RSE backing
4818 AsmSwitchStackAndBackingStore (
4819 IN SWITCH_STACK_ENTRY_POINT EntryPoint
,
4820 IN VOID
*Context1
, OPTIONAL
4821 IN VOID
*Context2
, OPTIONAL
4828 // Bugbug: This call should be removed after
4829 // the PalCall Instance issue has been fixed.
4832 Performs a PAL call using static calling convention.
4834 An internal function to perform a PAL call using static calling convention.
4836 @param PalEntryPoint The entry point address of PAL. The address in ar.kr5
4837 would be used if this parameter were NULL on input.
4838 @param Arg1 The first argument of a PAL call.
4839 @param Arg1 The second argument of a PAL call.
4840 @param Arg1 The third argument of a PAL call.
4841 @param Arg1 The fourth argument of a PAL call.
4843 @return The values returned in r8, r9, r10 and r11.
4848 IN CONST VOID
*PalEntryPoint
,
4856 #elif defined (MDE_CPU_IA32) || defined (MDE_CPU_X64)
4858 // IA32 and X64 Specific Functions
4861 // Byte packed structure for 16-bit Real Mode EFLAGS
4865 UINT32 CF
:1; // Carry Flag
4866 UINT32 Reserved_0
:1; // Reserved
4867 UINT32 PF
:1; // Parity Flag
4868 UINT32 Reserved_1
:1; // Reserved
4869 UINT32 AF
:1; // Auxiliary Carry Flag
4870 UINT32 Reserved_2
:1; // Reserved
4871 UINT32 ZF
:1; // Zero Flag
4872 UINT32 SF
:1; // Sign Flag
4873 UINT32 TF
:1; // Trap Flag
4874 UINT32 IF
:1; // Interrupt Enable Flag
4875 UINT32 DF
:1; // Direction Flag
4876 UINT32 OF
:1; // Overflow Flag
4877 UINT32 IOPL
:2; // I/O Privilege Level
4878 UINT32 NT
:1; // Nested Task
4879 UINT32 Reserved_3
:1; // Reserved
4885 // Byte packed structure for EFLAGS/RFLAGS
4887 // 64-bits on X64. The upper 32-bits on X64 are reserved
4891 UINT32 CF
:1; // Carry Flag
4892 UINT32 Reserved_0
:1; // Reserved
4893 UINT32 PF
:1; // Parity Flag
4894 UINT32 Reserved_1
:1; // Reserved
4895 UINT32 AF
:1; // Auxiliary Carry Flag
4896 UINT32 Reserved_2
:1; // Reserved
4897 UINT32 ZF
:1; // Zero Flag
4898 UINT32 SF
:1; // Sign Flag
4899 UINT32 TF
:1; // Trap Flag
4900 UINT32 IF
:1; // Interrupt Enable Flag
4901 UINT32 DF
:1; // Direction Flag
4902 UINT32 OF
:1; // Overflow Flag
4903 UINT32 IOPL
:2; // I/O Privilege Level
4904 UINT32 NT
:1; // Nested Task
4905 UINT32 Reserved_3
:1; // Reserved
4906 UINT32 RF
:1; // Resume Flag
4907 UINT32 VM
:1; // Virtual 8086 Mode
4908 UINT32 AC
:1; // Alignment Check
4909 UINT32 VIF
:1; // Virtual Interrupt Flag
4910 UINT32 VIP
:1; // Virtual Interrupt Pending
4911 UINT32 ID
:1; // ID Flag
4912 UINT32 Reserved_4
:10; // Reserved
4918 // Byte packed structure for Control Register 0 (CR0)
4920 // 64-bits on X64. The upper 32-bits on X64 are reserved
4924 UINT32 PE
:1; // Protection Enable
4925 UINT32 MP
:1; // Monitor Coprocessor
4926 UINT32 EM
:1; // Emulation
4927 UINT32 TS
:1; // Task Switched
4928 UINT32 ET
:1; // Extension Type
4929 UINT32 NE
:1; // Numeric Error
4930 UINT32 Reserved_0
:10; // Reserved
4931 UINT32 WP
:1; // Write Protect
4932 UINT32 Reserved_1
:1; // Reserved
4933 UINT32 AM
:1; // Alignment Mask
4934 UINT32 Reserved_2
:10; // Reserved
4935 UINT32 NW
:1; // Mot Write-through
4936 UINT32 CD
:1; // Cache Disable
4937 UINT32 PG
:1; // Paging
4943 // Byte packed structure for Control Register 4 (CR4)
4945 // 64-bits on X64. The upper 32-bits on X64 are reserved
4949 UINT32 VME
:1; // Virtual-8086 Mode Extensions
4950 UINT32 PVI
:1; // Protected-Mode Virtual Interrupts
4951 UINT32 TSD
:1; // Time Stamp Disable
4952 UINT32 DE
:1; // Debugging Extensions
4953 UINT32 PSE
:1; // Page Size Extensions
4954 UINT32 PAE
:1; // Physical Address Extension
4955 UINT32 MCE
:1; // Machine Check Enable
4956 UINT32 PGE
:1; // Page Global Enable
4957 UINT32 PCE
:1; // Performance Monitoring Counter
4959 UINT32 OSFXSR
:1; // Operating System Support for
4960 // FXSAVE and FXRSTOR instructions
4961 UINT32 OSXMMEXCPT
:1; // Operating System Support for
4962 // Unmasked SIMD Floating Point
4964 UINT32 Reserved_0
:2; // Reserved
4965 UINT32 VMXE
:1; // VMX Enable
4966 UINT32 Reserved_1
:18; // Reseved
4972 // Byte packed structure for an IDTR, GDTR, LDTR descriptor
4973 /// @bug How to make this structure byte-packed in a compiler independent way?
4982 #define IA32_IDT_GATE_TYPE_TASK 0x85
4983 #define IA32_IDT_GATE_TYPE_INTERRUPT_16 0x86
4984 #define IA32_IDT_GATE_TYPE_TRAP_16 0x87
4985 #define IA32_IDT_GATE_TYPE_INTERRUPT_32 0x8E
4986 #define IA32_IDT_GATE_TYPE_TRAP_32 0x8F
4989 // Byte packed structure for an Interrupt Gate Descriptor
4993 UINT32 OffsetLow
:16; // Offset bits 15..0
4994 UINT32 Selector
:16; // Selector
4995 UINT32 Reserved_0
:8; // Reserved
4996 UINT32 GateType
:8; // Gate Type. See #defines above
4997 UINT32 OffsetHigh
:16; // Offset bits 31..16
5000 } IA32_IDT_GATE_DESCRIPTOR
;
5003 // Byte packed structure for an FP/SSE/SSE2 context
5010 // Structures for the 16-bit real mode thunks
5063 IA32_EFLAGS32 EFLAGS
;
5073 } IA32_REGISTER_SET
;
5076 // Byte packed structure for an 16-bit real mode thunks
5079 IA32_REGISTER_SET
*RealModeState
;
5080 VOID
*RealModeBuffer
;
5081 UINT32 RealModeBufferSize
;
5082 UINT32 ThunkAttributes
;
5085 #define THUNK_ATTRIBUTE_BIG_REAL_MODE 0x00000001
5086 #define THUNK_ATTRIBUTE_DISABLE_A20_MASK_INT_15 0x00000002
5087 #define THUNK_ATTRIBUTE_DISABLE_A20_MASK_KBD_CTRL 0x00000004
5090 Retrieves CPUID information.
5092 Executes the CPUID instruction with EAX set to the value specified by Index.
5093 This function always returns Index.
5094 If Eax is not NULL, then the value of EAX after CPUID is returned in Eax.
5095 If Ebx is not NULL, then the value of EBX after CPUID is returned in Ebx.
5096 If Ecx is not NULL, then the value of ECX after CPUID is returned in Ecx.
5097 If Edx is not NULL, then the value of EDX after CPUID is returned in Edx.
5098 This function is only available on IA-32 and X64.
5100 @param Index The 32-bit value to load into EAX prior to invoking the CPUID
5102 @param Eax Pointer to the 32-bit EAX value returned by the CPUID
5103 instruction. This is an optional parameter that may be NULL.
5104 @param Ebx Pointer to the 32-bit EBX value returned by the CPUID
5105 instruction. This is an optional parameter that may be NULL.
5106 @param Ecx Pointer to the 32-bit ECX value returned by the CPUID
5107 instruction. This is an optional parameter that may be NULL.
5108 @param Edx Pointer to the 32-bit EDX value returned by the CPUID
5109 instruction. This is an optional parameter that may be NULL.
5118 OUT UINT32
*Eax
, OPTIONAL
5119 OUT UINT32
*Ebx
, OPTIONAL
5120 OUT UINT32
*Ecx
, OPTIONAL
5121 OUT UINT32
*Edx OPTIONAL
5126 Retrieves CPUID information using an extended leaf identifier.
5128 Executes the CPUID instruction with EAX set to the value specified by Index
5129 and ECX set to the value specified by SubIndex. This function always returns
5130 Index. This function is only available on IA-32 and x64.
5132 If Eax is not NULL, then the value of EAX after CPUID is returned in Eax.
5133 If Ebx is not NULL, then the value of EBX after CPUID is returned in Ebx.
5134 If Ecx is not NULL, then the value of ECX after CPUID is returned in Ecx.
5135 If Edx is not NULL, then the value of EDX after CPUID is returned in Edx.
5137 @param Index The 32-bit value to load into EAX prior to invoking the
5139 @param SubIndex The 32-bit value to load into ECX prior to invoking the
5141 @param Eax Pointer to the 32-bit EAX value returned by the CPUID
5142 instruction. This is an optional parameter that may be
5144 @param Ebx Pointer to the 32-bit EBX value returned by the CPUID
5145 instruction. This is an optional parameter that may be
5147 @param Ecx Pointer to the 32-bit ECX value returned by the CPUID
5148 instruction. This is an optional parameter that may be
5150 @param Edx Pointer to the 32-bit EDX value returned by the CPUID
5151 instruction. This is an optional parameter that may be
5162 OUT UINT32
*Eax
, OPTIONAL
5163 OUT UINT32
*Ebx
, OPTIONAL
5164 OUT UINT32
*Ecx
, OPTIONAL
5165 OUT UINT32
*Edx OPTIONAL
5170 Returns the lower 32-bits of a Machine Specific Register(MSR).
5172 Reads and returns the lower 32-bits of the MSR specified by Index.
5173 No parameter checking is performed on Index, and some Index values may cause
5174 CPU exceptions. The caller must either guarantee that Index is valid, or the
5175 caller must set up exception handlers to catch the exceptions. This function
5176 is only available on IA-32 and X64.
5178 @param Index The 32-bit MSR index to read.
5180 @return The lower 32 bits of the MSR identified by Index.
5191 Zero-extend a 32-bit value and writes it to a Machine Specific Register(MSR).
5193 Writes the 32-bit value specified by Value to the MSR specified by Index. The
5194 upper 32-bits of the MSR write are set to zero. The 32-bit value written to
5195 the MSR is returned. No parameter checking is performed on Index or Value,
5196 and some of these may cause CPU exceptions. The caller must either guarantee
5197 that Index and Value are valid, or the caller must establish proper exception
5198 handlers. This function is only available on IA-32 and X64.
5200 @param Index The 32-bit MSR index to write.
5201 @param Value The 32-bit value to write to the MSR.
5215 Reads a 64-bit MSR, performs a bitwise inclusive OR on the lower 32-bits, and
5216 writes the result back to the 64-bit MSR.
5218 Reads the 64-bit MSR specified by Index, performs a bitwise inclusive OR
5219 between the lower 32-bits of the read result and the value specified by
5220 OrData, and writes the result to the 64-bit MSR specified by Index. The lower
5221 32-bits of the value written to the MSR is returned. No parameter checking is
5222 performed on Index or OrData, and some of these may cause CPU exceptions. The
5223 caller must either guarantee that Index and OrData are valid, or the caller
5224 must establish proper exception handlers. This function is only available on
5227 @param Index The 32-bit MSR index to write.
5228 @param OrData The value to OR with the read value from the MSR.
5230 @return The lower 32-bit value written to the MSR.
5242 Reads a 64-bit MSR, performs a bitwise AND on the lower 32-bits, and writes
5243 the result back to the 64-bit MSR.
5245 Reads the 64-bit MSR specified by Index, performs a bitwise AND between the
5246 lower 32-bits of the read result and the value specified by AndData, and
5247 writes the result to the 64-bit MSR specified by Index. The lower 32-bits of
5248 the value written to the MSR is returned. No parameter checking is performed
5249 on Index or AndData, and some of these may cause CPU exceptions. The caller
5250 must either guarantee that Index and AndData are valid, or the caller must
5251 establish proper exception handlers. This function is only available on IA-32
5254 @param Index The 32-bit MSR index to write.
5255 @param AndData The value to AND with the read value from the MSR.
5257 @return The lower 32-bit value written to the MSR.
5269 Reads a 64-bit MSR, performs a bitwise AND followed by a bitwise inclusive OR
5270 on the lower 32-bits, and writes the result back to the 64-bit MSR.
5272 Reads the 64-bit MSR specified by Index, performs a bitwise AND between the
5273 lower 32-bits of the read result and the value specified by AndData
5274 preserving the upper 32-bits, performs a bitwise inclusive OR between the
5275 result of the AND operation and the value specified by OrData, and writes the
5276 result to the 64-bit MSR specified by Address. The lower 32-bits of the value
5277 written to the MSR is returned. No parameter checking is performed on Index,
5278 AndData, or OrData, and some of these may cause CPU exceptions. The caller
5279 must either guarantee that Index, AndData, and OrData are valid, or the
5280 caller must establish proper exception handlers. This function is only
5281 available on IA-32 and X64.
5283 @param Index The 32-bit MSR index to write.
5284 @param AndData The value to AND with the read value from the MSR.
5285 @param OrData The value to OR with the result of the AND operation.
5287 @return The lower 32-bit value written to the MSR.
5300 Reads a bit field of an MSR.
5302 Reads the bit field in the lower 32-bits of a 64-bit MSR. The bit field is
5303 specified by the StartBit and the EndBit. The value of the bit field is
5304 returned. The caller must either guarantee that Index is valid, or the caller
5305 must set up exception handlers to catch the exceptions. This function is only
5306 available on IA-32 and X64.
5308 If StartBit is greater than 31, then ASSERT().
5309 If EndBit is greater than 31, then ASSERT().
5310 If EndBit is less than StartBit, then ASSERT().
5312 @param Index The 32-bit MSR index to read.
5313 @param StartBit The ordinal of the least significant bit in the bit field.
5315 @param EndBit The ordinal of the most significant bit in the bit field.
5318 @return The bit field read from the MSR.
5323 AsmMsrBitFieldRead32 (
5331 Writes a bit field to an MSR.
5333 Writes Value to a bit field in the lower 32-bits of a 64-bit MSR. The bit
5334 field is specified by the StartBit and the EndBit. All other bits in the
5335 destination MSR are preserved. The lower 32-bits of the MSR written is
5336 returned. Extra left bits in Value are stripped. The caller must either
5337 guarantee that Index and the data written is valid, or the caller must set up
5338 exception handlers to catch the exceptions. This function is only available
5341 If StartBit is greater than 31, then ASSERT().
5342 If EndBit is greater than 31, then ASSERT().
5343 If EndBit is less than StartBit, then ASSERT().
5345 @param Index The 32-bit MSR index to write.
5346 @param StartBit The ordinal of the least significant bit in the bit field.
5348 @param EndBit The ordinal of the most significant bit in the bit field.
5350 @param Value New value of the bit field.
5352 @return The lower 32-bit of the value written to the MSR.
5357 AsmMsrBitFieldWrite32 (
5366 Reads a bit field in a 64-bit MSR, performs a bitwise OR, and writes the
5367 result back to the bit field in the 64-bit MSR.
5369 Reads the 64-bit MSR specified by Index, performs a bitwise inclusive OR
5370 between the read result and the value specified by OrData, and writes the
5371 result to the 64-bit MSR specified by Index. The lower 32-bits of the value
5372 written to the MSR are returned. Extra left bits in OrData are stripped. The
5373 caller must either guarantee that Index and the data written is valid, or
5374 the caller must set up exception handlers to catch the exceptions. This
5375 function is only available on IA-32 and X64.
5377 If StartBit is greater than 31, then ASSERT().
5378 If EndBit is greater than 31, then ASSERT().
5379 If EndBit is less than StartBit, then ASSERT().
5381 @param Index The 32-bit MSR index to write.
5382 @param StartBit The ordinal of the least significant bit in the bit field.
5384 @param EndBit The ordinal of the most significant bit in the bit field.
5386 @param OrData The value to OR with the read value from the MSR.
5388 @return The lower 32-bit of the value written to the MSR.
5393 AsmMsrBitFieldOr32 (
5402 Reads a bit field in a 64-bit MSR, performs a bitwise AND, and writes the
5403 result back to the bit field in the 64-bit MSR.
5405 Reads the 64-bit MSR specified by Index, performs a bitwise AND between the
5406 read result and the value specified by AndData, and writes the result to the
5407 64-bit MSR specified by Index. The lower 32-bits of the value written to the
5408 MSR are returned. Extra left bits in AndData are stripped. The caller must
5409 either guarantee that Index and the data written is valid, or the caller must
5410 set up exception handlers to catch the exceptions. This function is only
5411 available on IA-32 and X64.
5413 If StartBit is greater than 31, then ASSERT().
5414 If EndBit is greater than 31, then ASSERT().
5415 If EndBit is less than StartBit, then ASSERT().
5417 @param Index The 32-bit MSR index to write.
5418 @param StartBit The ordinal of the least significant bit in the bit field.
5420 @param EndBit The ordinal of the most significant bit in the bit field.
5422 @param AndData The value to AND with the read value from the MSR.
5424 @return The lower 32-bit of the value written to the MSR.
5429 AsmMsrBitFieldAnd32 (
5438 Reads a bit field in a 64-bit MSR, performs a bitwise AND followed by a
5439 bitwise inclusive OR, and writes the result back to the bit field in the
5442 Reads the 64-bit MSR specified by Index, performs a bitwise AND followed by a
5443 bitwise inclusive OR between the read result and the value specified by
5444 AndData, and writes the result to the 64-bit MSR specified by Index. The
5445 lower 32-bits of the value written to the MSR are returned. Extra left bits
5446 in both AndData and OrData are stripped. The caller must either guarantee
5447 that Index and the data written is valid, or the caller must set up exception
5448 handlers to catch the exceptions. This function is only available on IA-32
5451 If StartBit is greater than 31, then ASSERT().
5452 If EndBit is greater than 31, then ASSERT().
5453 If EndBit is less than StartBit, then ASSERT().
5455 @param Index The 32-bit MSR index to write.
5456 @param StartBit The ordinal of the least significant bit in the bit field.
5458 @param EndBit The ordinal of the most significant bit in the bit field.
5460 @param AndData The value to AND with the read value from the MSR.
5461 @param OrData The value to OR with the result of the AND operation.
5463 @return The lower 32-bit of the value written to the MSR.
5468 AsmMsrBitFieldAndThenOr32 (
5478 Returns a 64-bit Machine Specific Register(MSR).
5480 Reads and returns the 64-bit MSR specified by Index. No parameter checking is
5481 performed on Index, and some Index values may cause CPU exceptions. The
5482 caller must either guarantee that Index is valid, or the caller must set up
5483 exception handlers to catch the exceptions. This function is only available
5486 @param Index The 32-bit MSR index to read.
5488 @return The value of the MSR identified by Index.
5499 Writes a 64-bit value to a Machine Specific Register(MSR), and returns the
5502 Writes the 64-bit value specified by Value to the MSR specified by Index. The
5503 64-bit value written to the MSR is returned. No parameter checking is
5504 performed on Index or Value, and some of these may cause CPU exceptions. The
5505 caller must either guarantee that Index and Value are valid, or the caller
5506 must establish proper exception handlers. This function is only available on
5509 @param Index The 32-bit MSR index to write.
5510 @param Value The 64-bit value to write to the MSR.
5524 Reads a 64-bit MSR, performs a bitwise inclusive OR, and writes the result
5525 back to the 64-bit MSR.
5527 Reads the 64-bit MSR specified by Index, performs a bitwise inclusive OR
5528 between the read result and the value specified by OrData, and writes the
5529 result to the 64-bit MSR specified by Index. The value written to the MSR is
5530 returned. No parameter checking is performed on Index or OrData, and some of
5531 these may cause CPU exceptions. The caller must either guarantee that Index
5532 and OrData are valid, or the caller must establish proper exception handlers.
5533 This function is only available on IA-32 and X64.
5535 @param Index The 32-bit MSR index to write.
5536 @param OrData The value to OR with the read value from the MSR.
5538 @return The value written back to the MSR.
5550 Reads a 64-bit MSR, performs a bitwise AND, and writes the result back to the
5553 Reads the 64-bit MSR specified by Index, performs a bitwise AND between the
5554 read result and the value specified by OrData, and writes the result to the
5555 64-bit MSR specified by Index. The value written to the MSR is returned. No
5556 parameter checking is performed on Index or OrData, and some of these may
5557 cause CPU exceptions. The caller must either guarantee that Index and OrData
5558 are valid, or the caller must establish proper exception handlers. This
5559 function is only available on IA-32 and X64.
5561 @param Index The 32-bit MSR index to write.
5562 @param AndData The value to AND with the read value from the MSR.
5564 @return The value written back to the MSR.
5576 Reads a 64-bit MSR, performs a bitwise AND followed by a bitwise inclusive
5577 OR, and writes the result back to the 64-bit MSR.
5579 Reads the 64-bit MSR specified by Index, performs a bitwise AND between read
5580 result and the value specified by AndData, performs a bitwise inclusive OR
5581 between the result of the AND operation and the value specified by OrData,
5582 and writes the result to the 64-bit MSR specified by Index. The value written
5583 to the MSR is returned. No parameter checking is performed on Index, AndData,
5584 or OrData, and some of these may cause CPU exceptions. The caller must either
5585 guarantee that Index, AndData, and OrData are valid, or the caller must
5586 establish proper exception handlers. This function is only available on IA-32
5589 @param Index The 32-bit MSR index to write.
5590 @param AndData The value to AND with the read value from the MSR.
5591 @param OrData The value to OR with the result of the AND operation.
5593 @return The value written back to the MSR.
5606 Reads a bit field of an MSR.
5608 Reads the bit field in the 64-bit MSR. The bit field is specified by the
5609 StartBit and the EndBit. The value of the bit field is returned. The caller
5610 must either guarantee that Index is valid, or the caller must set up
5611 exception handlers to catch the exceptions. This function is only available
5614 If StartBit is greater than 63, then ASSERT().
5615 If EndBit is greater than 63, then ASSERT().
5616 If EndBit is less than StartBit, then ASSERT().
5618 @param Index The 32-bit MSR index to read.
5619 @param StartBit The ordinal of the least significant bit in the bit field.
5621 @param EndBit The ordinal of the most significant bit in the bit field.
5624 @return The value read from the MSR.
5629 AsmMsrBitFieldRead64 (
5637 Writes a bit field to an MSR.
5639 Writes Value to a bit field in a 64-bit MSR. The bit field is specified by
5640 the StartBit and the EndBit. All other bits in the destination MSR are
5641 preserved. The MSR written is returned. Extra left bits in Value are
5642 stripped. The caller must either guarantee that Index and the data written is
5643 valid, or the caller must set up exception handlers to catch the exceptions.
5644 This function is only available on IA-32 and X64.
5646 If StartBit is greater than 63, then ASSERT().
5647 If EndBit is greater than 63, then ASSERT().
5648 If EndBit is less than StartBit, then ASSERT().
5650 @param Index The 32-bit MSR index to write.
5651 @param StartBit The ordinal of the least significant bit in the bit field.
5653 @param EndBit The ordinal of the most significant bit in the bit field.
5655 @param Value New value of the bit field.
5657 @return The value written back to the MSR.
5662 AsmMsrBitFieldWrite64 (
5671 Reads a bit field in a 64-bit MSR, performs a bitwise inclusive OR, and
5672 writes the result back to the bit field in the 64-bit MSR.
5674 Reads the 64-bit MSR specified by Index, performs a bitwise inclusive OR
5675 between the read result and the value specified by OrData, and writes the
5676 result to the 64-bit MSR specified by Index. The value written to the MSR is
5677 returned. Extra left bits in OrData are stripped. The caller must either
5678 guarantee that Index and the data written is valid, or the caller must set up
5679 exception handlers to catch the exceptions. This function is only available
5682 If StartBit is greater than 63, then ASSERT().
5683 If EndBit is greater than 63, then ASSERT().
5684 If EndBit is less than StartBit, then ASSERT().
5686 @param Index The 32-bit MSR index to write.
5687 @param StartBit The ordinal of the least significant bit in the bit field.
5689 @param EndBit The ordinal of the most significant bit in the bit field.
5691 @param OrData The value to OR with the read value from the bit field.
5693 @return The value written back to the MSR.
5698 AsmMsrBitFieldOr64 (
5707 Reads a bit field in a 64-bit MSR, performs a bitwise AND, and writes the
5708 result back to the bit field in the 64-bit MSR.
5710 Reads the 64-bit MSR specified by Index, performs a bitwise AND between the
5711 read result and the value specified by AndData, and writes the result to the
5712 64-bit MSR specified by Index. The value written to the MSR is returned.
5713 Extra left bits in AndData are stripped. The caller must either guarantee
5714 that Index and the data written is valid, or the caller must set up exception
5715 handlers to catch the exceptions. This function is only available on IA-32
5718 If StartBit is greater than 63, then ASSERT().
5719 If EndBit is greater than 63, then ASSERT().
5720 If EndBit is less than StartBit, then ASSERT().
5722 @param Index The 32-bit MSR index to write.
5723 @param StartBit The ordinal of the least significant bit in the bit field.
5725 @param EndBit The ordinal of the most significant bit in the bit field.
5727 @param AndData The value to AND with the read value from the bit field.
5729 @return The value written back to the MSR.
5734 AsmMsrBitFieldAnd64 (
5743 Reads a bit field in a 64-bit MSR, performs a bitwise AND followed by a
5744 bitwise inclusive OR, and writes the result back to the bit field in the
5747 Reads the 64-bit MSR specified by Index, performs a bitwise AND followed by
5748 a bitwise inclusive OR between the read result and the value specified by
5749 AndData, and writes the result to the 64-bit MSR specified by Index. The
5750 value written to the MSR is returned. Extra left bits in both AndData and
5751 OrData are stripped. The caller must either guarantee that Index and the data
5752 written is valid, or the caller must set up exception handlers to catch the
5753 exceptions. This function is only available on IA-32 and X64.
5755 If StartBit is greater than 63, then ASSERT().
5756 If EndBit is greater than 63, then ASSERT().
5757 If EndBit is less than StartBit, then ASSERT().
5759 @param Index The 32-bit MSR index to write.
5760 @param StartBit The ordinal of the least significant bit in the bit field.
5762 @param EndBit The ordinal of the most significant bit in the bit field.
5764 @param AndData The value to AND with the read value from the bit field.
5765 @param OrData The value to OR with the result of the AND operation.
5767 @return The value written back to the MSR.
5772 AsmMsrBitFieldAndThenOr64 (
5782 Reads the current value of the EFLAGS register.
5784 Reads and returns the current value of the EFLAGS register. This function is
5785 only available on IA-32 and X64. This returns a 32-bit value on IA-32 and a
5786 64-bit value on X64.
5788 @return EFLAGS on IA-32 or RFLAGS on X64.
5799 Reads the current value of the Control Register 0 (CR0).
5801 Reads and returns the current value of CR0. This function is only available
5802 on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on
5805 @return The value of the Control Register 0 (CR0).
5816 Reads the current value of the Control Register 2 (CR2).
5818 Reads and returns the current value of CR2. This function is only available
5819 on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on
5822 @return The value of the Control Register 2 (CR2).
5833 Reads the current value of the Control Register 3 (CR3).
5835 Reads and returns the current value of CR3. This function is only available
5836 on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on
5839 @return The value of the Control Register 3 (CR3).
5850 Reads the current value of the Control Register 4 (CR4).
5852 Reads and returns the current value of CR4. This function is only available
5853 on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on
5856 @return The value of the Control Register 4 (CR4).
5867 Writes a value to Control Register 0 (CR0).
5869 Writes and returns a new value to CR0. This function is only available on
5870 IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.
5872 @param Cr0 The value to write to CR0.
5874 @return The value written to CR0.
5885 Writes a value to Control Register 2 (CR2).
5887 Writes and returns a new value to CR2. This function is only available on
5888 IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.
5890 @param Cr2 The value to write to CR2.
5892 @return The value written to CR2.
5903 Writes a value to Control Register 3 (CR3).
5905 Writes and returns a new value to CR3. This function is only available on
5906 IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.
5908 @param Cr3 The value to write to CR3.
5910 @return The value written to CR3.
5921 Writes a value to Control Register 4 (CR4).
5923 Writes and returns a new value to CR4. This function is only available on
5924 IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.
5926 @param Cr4 The value to write to CR4.
5928 @return The value written to CR4.
5939 Reads the current value of Debug Register 0 (DR0).
5941 Reads and returns the current value of DR0. This function is only available
5942 on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on
5945 @return The value of Debug Register 0 (DR0).
5956 Reads the current value of Debug Register 1 (DR1).
5958 Reads and returns the current value of DR1. This function is only available
5959 on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on
5962 @return The value of Debug Register 1 (DR1).
5973 Reads the current value of Debug Register 2 (DR2).
5975 Reads and returns the current value of DR2. This function is only available
5976 on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on
5979 @return The value of Debug Register 2 (DR2).
5990 Reads the current value of Debug Register 3 (DR3).
5992 Reads and returns the current value of DR3. This function is only available
5993 on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on
5996 @return The value of Debug Register 3 (DR3).
6007 Reads the current value of Debug Register 4 (DR4).
6009 Reads and returns the current value of DR4. This function is only available
6010 on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on
6013 @return The value of Debug Register 4 (DR4).
6024 Reads the current value of Debug Register 5 (DR5).
6026 Reads and returns the current value of DR5. This function is only available
6027 on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on
6030 @return The value of Debug Register 5 (DR5).
6041 Reads the current value of Debug Register 6 (DR6).
6043 Reads and returns the current value of DR6. This function is only available
6044 on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on
6047 @return The value of Debug Register 6 (DR6).
6058 Reads the current value of Debug Register 7 (DR7).
6060 Reads and returns the current value of DR7. This function is only available
6061 on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on
6064 @return The value of Debug Register 7 (DR7).
6075 Writes a value to Debug Register 0 (DR0).
6077 Writes and returns a new value to DR0. This function is only available on
6078 IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.
6080 @param Dr0 The value to write to Dr0.
6082 @return The value written to Debug Register 0 (DR0).
6093 Writes a value to Debug Register 1 (DR1).
6095 Writes and returns a new value to DR1. This function is only available on
6096 IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.
6098 @param Dr1 The value to write to Dr1.
6100 @return The value written to Debug Register 1 (DR1).
6111 Writes a value to Debug Register 2 (DR2).
6113 Writes and returns a new value to DR2. This function is only available on
6114 IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.
6116 @param Dr2 The value to write to Dr2.
6118 @return The value written to Debug Register 2 (DR2).
6129 Writes a value to Debug Register 3 (DR3).
6131 Writes and returns a new value to DR3. This function is only available on
6132 IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.
6134 @param Dr3 The value to write to Dr3.
6136 @return The value written to Debug Register 3 (DR3).
6147 Writes a value to Debug Register 4 (DR4).
6149 Writes and returns a new value to DR4. This function is only available on
6150 IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.
6152 @param Dr4 The value to write to Dr4.
6154 @return The value written to Debug Register 4 (DR4).
6165 Writes a value to Debug Register 5 (DR5).
6167 Writes and returns a new value to DR5. This function is only available on
6168 IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.
6170 @param Dr5 The value to write to Dr5.
6172 @return The value written to Debug Register 5 (DR5).
6183 Writes a value to Debug Register 6 (DR6).
6185 Writes and returns a new value to DR6. This function is only available on
6186 IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.
6188 @param Dr6 The value to write to Dr6.
6190 @return The value written to Debug Register 6 (DR6).
6201 Writes a value to Debug Register 7 (DR7).
6203 Writes and returns a new value to DR7. This function is only available on
6204 IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.
6206 @param Dr7 The value to write to Dr7.
6208 @return The value written to Debug Register 7 (DR7).
6219 Reads the current value of Code Segment Register (CS).
6221 Reads and returns the current value of CS. This function is only available on
6224 @return The current value of CS.
6235 Reads the current value of Data Segment Register (DS).
6237 Reads and returns the current value of DS. This function is only available on
6240 @return The current value of DS.
6251 Reads the current value of Extra Segment Register (ES).
6253 Reads and returns the current value of ES. This function is only available on
6256 @return The current value of ES.
6267 Reads the current value of FS Data Segment Register (FS).
6269 Reads and returns the current value of FS. This function is only available on
6272 @return The current value of FS.
6283 Reads the current value of GS Data Segment Register (GS).
6285 Reads and returns the current value of GS. This function is only available on
6288 @return The current value of GS.
6299 Reads the current value of Stack Segment Register (SS).
6301 Reads and returns the current value of SS. This function is only available on
6304 @return The current value of SS.
6315 Reads the current value of Task Register (TR).
6317 Reads and returns the current value of TR. This function is only available on
6320 @return The current value of TR.
6331 Reads the current Global Descriptor Table Register(GDTR) descriptor.
6333 Reads and returns the current GDTR descriptor and returns it in Gdtr. This
6334 function is only available on IA-32 and X64.
6336 If Gdtr is NULL, then ASSERT().
6338 @param Gdtr Pointer to a GDTR descriptor.
6344 OUT IA32_DESCRIPTOR
*Gdtr
6349 Writes the current Global Descriptor Table Register (GDTR) descriptor.
6351 Writes and the current GDTR descriptor specified by Gdtr. This function is
6352 only available on IA-32 and X64.
6354 If Gdtr is NULL, then ASSERT().
6356 @param Gdtr Pointer to a GDTR descriptor.
6362 IN CONST IA32_DESCRIPTOR
*Gdtr
6367 Reads the current Interrupt Descriptor Table Register(GDTR) descriptor.
6369 Reads and returns the current IDTR descriptor and returns it in Idtr. This
6370 function is only available on IA-32 and X64.
6372 If Idtr is NULL, then ASSERT().
6374 @param Idtr Pointer to a IDTR descriptor.
6380 OUT IA32_DESCRIPTOR
*Idtr
6385 Writes the current Interrupt Descriptor Table Register(GDTR) descriptor.
6387 Writes the current IDTR descriptor and returns it in Idtr. This function is
6388 only available on IA-32 and X64.
6390 If Idtr is NULL, then ASSERT().
6392 @param Idtr Pointer to a IDTR descriptor.
6398 IN CONST IA32_DESCRIPTOR
*Idtr
6403 Reads the current Local Descriptor Table Register(LDTR) selector.
6405 Reads and returns the current 16-bit LDTR descriptor value. This function is
6406 only available on IA-32 and X64.
6408 @return The current selector of LDT.
6419 Writes the current Local Descriptor Table Register (GDTR) selector.
6421 Writes and the current LDTR descriptor specified by Ldtr. This function is
6422 only available on IA-32 and X64.
6424 @param Ldtr 16-bit LDTR selector value.
6435 Save the current floating point/SSE/SSE2 context to a buffer.
6437 Saves the current floating point/SSE/SSE2 state to the buffer specified by
6438 Buffer. Buffer must be aligned on a 16-byte boundary. This function is only
6439 available on IA-32 and X64.
6441 If Buffer is NULL, then ASSERT().
6442 If Buffer is not aligned on a 16-byte boundary, then ASSERT().
6444 @param Buffer Pointer to a buffer to save the floating point/SSE/SSE2 context.
6450 OUT IA32_FX_BUFFER
*Buffer
6455 Restores the current floating point/SSE/SSE2 context from a buffer.
6457 Restores the current floating point/SSE/SSE2 state from the buffer specified
6458 by Buffer. Buffer must be aligned on a 16-byte boundary. This function is
6459 only available on IA-32 and X64.
6461 If Buffer is NULL, then ASSERT().
6462 If Buffer is not aligned on a 16-byte boundary, then ASSERT().
6463 If Buffer was not saved with AsmFxSave(), then ASSERT().
6465 @param Buffer Pointer to a buffer to save the floating point/SSE/SSE2 context.
6471 IN CONST IA32_FX_BUFFER
*Buffer
6476 Reads the current value of 64-bit MMX Register #0 (MM0).
6478 Reads and returns the current value of MM0. This function is only available
6481 @return The current value of MM0.
6492 Reads the current value of 64-bit MMX Register #1 (MM1).
6494 Reads and returns the current value of MM1. This function is only available
6497 @return The current value of MM1.
6508 Reads the current value of 64-bit MMX Register #2 (MM2).
6510 Reads and returns the current value of MM2. This function is only available
6513 @return The current value of MM2.
6524 Reads the current value of 64-bit MMX Register #3 (MM3).
6526 Reads and returns the current value of MM3. This function is only available
6529 @return The current value of MM3.
6540 Reads the current value of 64-bit MMX Register #4 (MM4).
6542 Reads and returns the current value of MM4. This function is only available
6545 @return The current value of MM4.
6556 Reads the current value of 64-bit MMX Register #5 (MM5).
6558 Reads and returns the current value of MM5. This function is only available
6561 @return The current value of MM5.
6572 Reads the current value of 64-bit MMX Register #6 (MM6).
6574 Reads and returns the current value of MM6. This function is only available
6577 @return The current value of MM6.
6588 Reads the current value of 64-bit MMX Register #7 (MM7).
6590 Reads and returns the current value of MM7. This function is only available
6593 @return The current value of MM7.
6604 Writes the current value of 64-bit MMX Register #0 (MM0).
6606 Writes the current value of MM0. This function is only available on IA32 and
6609 @param Value The 64-bit value to write to MM0.
6620 Writes the current value of 64-bit MMX Register #1 (MM1).
6622 Writes the current value of MM1. This function is only available on IA32 and
6625 @param Value The 64-bit value to write to MM1.
6636 Writes the current value of 64-bit MMX Register #2 (MM2).
6638 Writes the current value of MM2. This function is only available on IA32 and
6641 @param Value The 64-bit value to write to MM2.
6652 Writes the current value of 64-bit MMX Register #3 (MM3).
6654 Writes the current value of MM3. This function is only available on IA32 and
6657 @param Value The 64-bit value to write to MM3.
6668 Writes the current value of 64-bit MMX Register #4 (MM4).
6670 Writes the current value of MM4. This function is only available on IA32 and
6673 @param Value The 64-bit value to write to MM4.
6684 Writes the current value of 64-bit MMX Register #5 (MM5).
6686 Writes the current value of MM5. This function is only available on IA32 and
6689 @param Value The 64-bit value to write to MM5.
6700 Writes the current value of 64-bit MMX Register #6 (MM6).
6702 Writes the current value of MM6. This function is only available on IA32 and
6705 @param Value The 64-bit value to write to MM6.
6716 Writes the current value of 64-bit MMX Register #7 (MM7).
6718 Writes the current value of MM7. This function is only available on IA32 and
6721 @param Value The 64-bit value to write to MM7.
6732 Reads the current value of Time Stamp Counter (TSC).
6734 Reads and returns the current value of TSC. This function is only available
6737 @return The current value of TSC
6748 Reads the current value of a Performance Counter (PMC).
6750 Reads and returns the current value of performance counter specified by
6751 Index. This function is only available on IA-32 and X64.
6753 @param Index The 32-bit Performance Counter index to read.
6755 @return The value of the PMC specified by Index.
6766 Sets up a monitor buffer that is used by AsmMwait().
6768 Executes a MONITOR instruction with the register state specified by Eax, Ecx
6769 and Edx. Returns Eax. This function is only available on IA-32 and X64.
6771 @param Eax The value to load into EAX or RAX before executing the MONITOR
6773 @param Ecx The value to load into ECX or RCX before executing the MONITOR
6775 @param Edx The value to load into EDX or RDX before executing the MONITOR
6791 Executes an MWAIT instruction.
6793 Executes an MWAIT instruction with the register state specified by Eax and
6794 Ecx. Returns Eax. This function is only available on IA-32 and X64.
6796 @param Eax The value to load into EAX or RAX before executing the MONITOR
6798 @param Ecx The value to load into ECX or RCX before executing the MONITOR
6813 Executes a WBINVD instruction.
6815 Executes a WBINVD instruction. This function is only available on IA-32 and
6827 Executes a INVD instruction.
6829 Executes a INVD instruction. This function is only available on IA-32 and
6841 Flushes a cache line from all the instruction and data caches within the
6842 coherency domain of the CPU.
6844 Flushed the cache line specified by LinearAddress, and returns LinearAddress.
6845 This function is only available on IA-32 and X64.
6847 @param LinearAddress The address of the cache line to flush. If the CPU is
6848 in a physical addressing mode, then LinearAddress is a
6849 physical address. If the CPU is in a virtual
6850 addressing mode, then LinearAddress is a virtual
6853 @return LinearAddress
6858 IN VOID
*LinearAddress
6863 Enables the 32-bit paging mode on the CPU.
6865 Enables the 32-bit paging mode on the CPU. CR0, CR3, CR4, and the page tables
6866 must be properly initialized prior to calling this service. This function
6867 assumes the current execution mode is 32-bit protected mode. This function is
6868 only available on IA-32. After the 32-bit paging mode is enabled, control is
6869 transferred to the function specified by EntryPoint using the new stack
6870 specified by NewStack and passing in the parameters specified by Context1 and
6871 Context2. Context1 and Context2 are optional and may be NULL. The function
6872 EntryPoint must never return.
6874 If the current execution mode is not 32-bit protected mode, then ASSERT().
6875 If EntryPoint is NULL, then ASSERT().
6876 If NewStack is NULL, then ASSERT().
6878 There are a number of constraints that must be followed before calling this
6880 1) Interrupts must be disabled.
6881 2) The caller must be in 32-bit protected mode with flat descriptors. This
6882 means all descriptors must have a base of 0 and a limit of 4GB.
6883 3) CR0 and CR4 must be compatible with 32-bit protected mode with flat
6885 4) CR3 must point to valid page tables that will be used once the transition
6886 is complete, and those page tables must guarantee that the pages for this
6887 function and the stack are identity mapped.
6889 @param EntryPoint A pointer to function to call with the new stack after
6891 @param Context1 A pointer to the context to pass into the EntryPoint
6892 function as the first parameter after paging is enabled.
6893 @param Context2 A pointer to the context to pass into the EntryPoint
6894 function as the second parameter after paging is enabled.
6895 @param NewStack A pointer to the new stack to use for the EntryPoint
6896 function after paging is enabled.
6902 IN SWITCH_STACK_ENTRY_POINT EntryPoint
,
6903 IN VOID
*Context1
, OPTIONAL
6904 IN VOID
*Context2
, OPTIONAL
6910 Disables the 32-bit paging mode on the CPU.
6912 Disables the 32-bit paging mode on the CPU and returns to 32-bit protected
6913 mode. This function assumes the current execution mode is 32-paged protected
6914 mode. This function is only available on IA-32. After the 32-bit paging mode
6915 is disabled, control is transferred to the function specified by EntryPoint
6916 using the new stack specified by NewStack and passing in the parameters
6917 specified by Context1 and Context2. Context1 and Context2 are optional and
6918 may be NULL. The function EntryPoint must never return.
6920 If the current execution mode is not 32-bit paged mode, then ASSERT().
6921 If EntryPoint is NULL, then ASSERT().
6922 If NewStack is NULL, then ASSERT().
6924 There are a number of constraints that must be followed before calling this
6926 1) Interrupts must be disabled.
6927 2) The caller must be in 32-bit paged mode.
6928 3) CR0, CR3, and CR4 must be compatible with 32-bit paged mode.
6929 4) CR3 must point to valid page tables that guarantee that the pages for
6930 this function and the stack are identity mapped.
6932 @param EntryPoint A pointer to function to call with the new stack after
6934 @param Context1 A pointer to the context to pass into the EntryPoint
6935 function as the first parameter after paging is disabled.
6936 @param Context2 A pointer to the context to pass into the EntryPoint
6937 function as the second parameter after paging is
6939 @param NewStack A pointer to the new stack to use for the EntryPoint
6940 function after paging is disabled.
6945 AsmDisablePaging32 (
6946 IN SWITCH_STACK_ENTRY_POINT EntryPoint
,
6947 IN VOID
*Context1
, OPTIONAL
6948 IN VOID
*Context2
, OPTIONAL
6954 Enables the 64-bit paging mode on the CPU.
6956 Enables the 64-bit paging mode on the CPU. CR0, CR3, CR4, and the page tables
6957 must be properly initialized prior to calling this service. This function
6958 assumes the current execution mode is 32-bit protected mode with flat
6959 descriptors. This function is only available on IA-32. After the 64-bit
6960 paging mode is enabled, control is transferred to the function specified by
6961 EntryPoint using the new stack specified by NewStack and passing in the
6962 parameters specified by Context1 and Context2. Context1 and Context2 are
6963 optional and may be 0. The function EntryPoint must never return.
6965 If the current execution mode is not 32-bit protected mode with flat
6966 descriptors, then ASSERT().
6967 If EntryPoint is 0, then ASSERT().
6968 If NewStack is 0, then ASSERT().
6970 @param Cs The 16-bit selector to load in the CS before EntryPoint
6971 is called. The descriptor in the GDT that this selector
6972 references must be setup for long mode.
6973 @param EntryPoint The 64-bit virtual address of the function to call with
6974 the new stack after paging is enabled.
6975 @param Context1 The 64-bit virtual address of the context to pass into
6976 the EntryPoint function as the first parameter after
6978 @param Context2 The 64-bit virtual address of the context to pass into
6979 the EntryPoint function as the second parameter after
6981 @param NewStack The 64-bit virtual address of the new stack to use for
6982 the EntryPoint function after paging is enabled.
6988 IN UINT16 CodeSelector
,
6989 IN UINT64 EntryPoint
,
6990 IN UINT64 Context1
, OPTIONAL
6991 IN UINT64 Context2
, OPTIONAL
6997 Disables the 64-bit paging mode on the CPU.
6999 Disables the 64-bit paging mode on the CPU and returns to 32-bit protected
7000 mode. This function assumes the current execution mode is 64-paging mode.
7001 This function is only available on X64. After the 64-bit paging mode is
7002 disabled, control is transferred to the function specified by EntryPoint
7003 using the new stack specified by NewStack and passing in the parameters
7004 specified by Context1 and Context2. Context1 and Context2 are optional and
7005 may be 0. The function EntryPoint must never return.
7007 If the current execution mode is not 64-bit paged mode, then ASSERT().
7008 If EntryPoint is 0, then ASSERT().
7009 If NewStack is 0, then ASSERT().
7011 @param Cs The 16-bit selector to load in the CS before EntryPoint
7012 is called. The descriptor in the GDT that this selector
7013 references must be setup for 32-bit protected mode.
7014 @param EntryPoint The 64-bit virtual address of the function to call with
7015 the new stack after paging is disabled.
7016 @param Context1 The 64-bit virtual address of the context to pass into
7017 the EntryPoint function as the first parameter after
7019 @param Context2 The 64-bit virtual address of the context to pass into
7020 the EntryPoint function as the second parameter after
7022 @param NewStack The 64-bit virtual address of the new stack to use for
7023 the EntryPoint function after paging is disabled.
7028 AsmDisablePaging64 (
7029 IN UINT16 CodeSelector
,
7030 IN UINT32 EntryPoint
,
7031 IN UINT32 Context1
, OPTIONAL
7032 IN UINT32 Context2
, OPTIONAL
7038 // 16-bit thunking services
7042 Retrieves the properties for 16-bit thunk functions.
7044 Computes the size of the buffer and stack below 1MB required to use the
7045 AsmPrepareThunk16(), AsmThunk16() and AsmPrepareAndThunk16() functions. This
7046 buffer size is returned in RealModeBufferSize, and the stack size is returned
7047 in ExtraStackSize. If parameters are passed to the 16-bit real mode code,
7048 then the actual minimum stack size is ExtraStackSize plus the maximum number
7049 of bytes that need to be passed to the 16-bit real mode code.
7051 If RealModeBufferSize is NULL, then ASSERT().
7052 If ExtraStackSize is NULL, then ASSERT().
7054 @param RealModeBufferSize A pointer to the size of the buffer below 1MB
7055 required to use the 16-bit thunk functions.
7056 @param ExtraStackSize A pointer to the extra size of stack below 1MB
7057 that the 16-bit thunk functions require for
7058 temporary storage in the transition to and from
7064 AsmGetThunk16Properties (
7065 OUT UINT32
*RealModeBufferSize
,
7066 OUT UINT32
*ExtraStackSize
7071 Prepares all structures a code required to use AsmThunk16().
7073 Prepares all structures and code required to use AsmThunk16().
7075 If ThunkContext is NULL, then ASSERT().
7077 @param ThunkContext A pointer to the context structure that describes the
7078 16-bit real mode code to call.
7084 OUT THUNK_CONTEXT
*ThunkContext
7089 Transfers control to a 16-bit real mode entry point and returns the results.
7091 Transfers control to a 16-bit real mode entry point and returns the results.
7092 AsmPrepareThunk16() must be called with ThunkContext before this function is
7095 If ThunkContext is NULL, then ASSERT().
7096 If AsmPrepareThunk16() was not previously called with ThunkContext, then ASSERT().
7098 @param ThunkContext A pointer to the context structure that describes the
7099 16-bit real mode code to call.
7105 IN OUT THUNK_CONTEXT
*ThunkContext
7110 Prepares all structures and code for a 16-bit real mode thunk, transfers
7111 control to a 16-bit real mode entry point, and returns the results.
7113 Prepares all structures and code for a 16-bit real mode thunk, transfers
7114 control to a 16-bit real mode entry point, and returns the results. If the
7115 caller only need to perform a single 16-bit real mode thunk, then this
7116 service should be used. If the caller intends to make more than one 16-bit
7117 real mode thunk, then it is more efficient if AsmPrepareThunk16() is called
7118 once and AsmThunk16() can be called for each 16-bit real mode thunk.
7120 If ThunkContext is NULL, then ASSERT().
7122 @param ThunkContext A pointer to the context structure that describes the
7123 16-bit real mode code to call.
7128 AsmPrepareAndThunk16 (
7129 IN OUT THUNK_CONTEXT
*ThunkContext