2 Provides string functions, linked list functions, math functions, synchronization
3 functions, file path functions, and CPU architecture-specific functions.
5 Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
6 Portions copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>
7 This program and the accompanying materials
8 are licensed and made available under the terms and conditions of the BSD License
9 which accompanies this distribution. The full text of the license may be found at
10 http://opensource.org/licenses/bsd-license.php.
12 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
13 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
21 // Definitions for architecture-specific types
23 #if defined (MDE_CPU_IA32)
25 /// The IA-32 architecture context buffer used by SetJump() and LongJump().
34 } BASE_LIBRARY_JUMP_BUFFER
;
36 #define BASE_LIBRARY_JUMP_BUFFER_ALIGNMENT 4
38 #endif // defined (MDE_CPU_IA32)
40 #if defined (MDE_CPU_IPF)
43 /// The Itanium architecture context buffer used by SetJump() and LongJump().
78 UINT64 AfterSpillUNAT
;
84 } BASE_LIBRARY_JUMP_BUFFER
;
86 #define BASE_LIBRARY_JUMP_BUFFER_ALIGNMENT 0x10
88 #endif // defined (MDE_CPU_IPF)
90 #if defined (MDE_CPU_X64)
92 /// The x64 architecture context buffer used by SetJump() and LongJump().
106 UINT8 XmmBuffer
[160]; ///< XMM6-XMM15.
107 } BASE_LIBRARY_JUMP_BUFFER
;
109 #define BASE_LIBRARY_JUMP_BUFFER_ALIGNMENT 8
111 #endif // defined (MDE_CPU_X64)
113 #if defined (MDE_CPU_EBC)
115 /// The EBC context buffer used by SetJump() and LongJump().
123 } BASE_LIBRARY_JUMP_BUFFER
;
125 #define BASE_LIBRARY_JUMP_BUFFER_ALIGNMENT 8
127 #endif // defined (MDE_CPU_EBC)
129 #if defined (MDE_CPU_ARM)
132 UINT32 R3
; ///< A copy of R13.
143 } BASE_LIBRARY_JUMP_BUFFER
;
145 #define BASE_LIBRARY_JUMP_BUFFER_ALIGNMENT 4
147 #endif // defined (MDE_CPU_ARM)
149 #if defined (MDE_CPU_AARCH64)
175 } BASE_LIBRARY_JUMP_BUFFER
;
177 #define BASE_LIBRARY_JUMP_BUFFER_ALIGNMENT 8
179 #endif // defined (MDE_CPU_AARCH64)
188 Returns the length of a Null-terminated Unicode string.
190 This function is similar as strlen_s defined in C11.
192 If String is not aligned on a 16-bit boundary, then ASSERT().
194 @param String A pointer to a Null-terminated Unicode string.
195 @param MaxSize The maximum number of Destination Unicode
196 char, including terminating null char.
198 @retval 0 If String is NULL.
199 @retval MaxSize If there is no null character in the first MaxSize characters of String.
200 @return The number of characters that percede the terminating null character.
206 IN CONST CHAR16
*String
,
211 Returns the size of a Null-terminated Unicode string in bytes, including the
214 This function returns the size of the Null-terminated Unicode string
215 specified by String in bytes, including the Null terminator.
217 If String is not aligned on a 16-bit boundary, then ASSERT().
219 @param String A pointer to a Null-terminated Unicode string.
220 @param MaxSize The maximum number of Destination Unicode
221 char, including the Null terminator.
223 @retval 0 If String is NULL.
224 @retval (sizeof (CHAR16) * (MaxSize + 1))
225 If there is no Null terminator in the first MaxSize characters of
227 @return The size of the Null-terminated Unicode string in bytes, including
234 IN CONST CHAR16
*String
,
239 Copies the string pointed to by Source (including the terminating null char)
240 to the array pointed to by Destination.
242 This function is similar as strcpy_s defined in C11.
244 If Destination is not aligned on a 16-bit boundary, then ASSERT().
245 If Source is not aligned on a 16-bit boundary, then ASSERT().
246 If an error would be returned, then the function will also ASSERT().
248 If an error is returned, then the Destination is unmodified.
250 @param Destination A pointer to a Null-terminated Unicode string.
251 @param DestMax The maximum number of Destination Unicode
252 char, including terminating null char.
253 @param Source A pointer to a Null-terminated Unicode string.
255 @retval RETURN_SUCCESS String is copied.
256 @retval RETURN_BUFFER_TOO_SMALL If DestMax is NOT greater than StrLen(Source).
257 @retval RETURN_INVALID_PARAMETER If Destination is NULL.
259 If PcdMaximumUnicodeStringLength is not zero,
260 and DestMax is greater than
261 PcdMaximumUnicodeStringLength.
263 @retval RETURN_ACCESS_DENIED If Source and Destination overlap.
268 OUT CHAR16
*Destination
,
270 IN CONST CHAR16
*Source
274 Copies not more than Length successive char from the string pointed to by
275 Source to the array pointed to by Destination. If no null char is copied from
276 Source, then Destination[Length] is always set to null.
278 This function is similar as strncpy_s defined in C11.
280 If Length > 0 and Destination is not aligned on a 16-bit boundary, then ASSERT().
281 If Length > 0 and Source is not aligned on a 16-bit boundary, then ASSERT().
282 If an error would be returned, then the function will also ASSERT().
284 If an error is returned, then the Destination is unmodified.
286 @param Destination A pointer to a Null-terminated Unicode string.
287 @param DestMax The maximum number of Destination Unicode
288 char, including terminating null char.
289 @param Source A pointer to a Null-terminated Unicode string.
290 @param Length The maximum number of Unicode characters to copy.
292 @retval RETURN_SUCCESS String is copied.
293 @retval RETURN_BUFFER_TOO_SMALL If DestMax is NOT greater than
294 MIN(StrLen(Source), Length).
295 @retval RETURN_INVALID_PARAMETER If Destination is NULL.
297 If PcdMaximumUnicodeStringLength is not zero,
298 and DestMax is greater than
299 PcdMaximumUnicodeStringLength.
301 @retval RETURN_ACCESS_DENIED If Source and Destination overlap.
306 OUT CHAR16
*Destination
,
308 IN CONST CHAR16
*Source
,
313 Appends a copy of the string pointed to by Source (including the terminating
314 null char) to the end of the string pointed to by Destination.
316 This function is similar as strcat_s defined in C11.
318 If Destination is not aligned on a 16-bit boundary, then ASSERT().
319 If Source is not aligned on a 16-bit boundary, then ASSERT().
320 If an error would be returned, then the function will also ASSERT().
322 If an error is returned, then the Destination is unmodified.
324 @param Destination A pointer to a Null-terminated Unicode string.
325 @param DestMax The maximum number of Destination Unicode
326 char, including terminating null char.
327 @param Source A pointer to a Null-terminated Unicode string.
329 @retval RETURN_SUCCESS String is appended.
330 @retval RETURN_BAD_BUFFER_SIZE If DestMax is NOT greater than
332 @retval RETURN_BUFFER_TOO_SMALL If (DestMax - StrLen(Destination)) is NOT
333 greater than StrLen(Source).
334 @retval RETURN_INVALID_PARAMETER If Destination is NULL.
336 If PcdMaximumUnicodeStringLength is not zero,
337 and DestMax is greater than
338 PcdMaximumUnicodeStringLength.
340 @retval RETURN_ACCESS_DENIED If Source and Destination overlap.
345 IN OUT CHAR16
*Destination
,
347 IN CONST CHAR16
*Source
351 Appends not more than Length successive char from the string pointed to by
352 Source to the end of the string pointed to by Destination. If no null char is
353 copied from Source, then Destination[StrLen(Destination) + Length] is always
356 This function is similar as strncat_s defined in C11.
358 If Destination is not aligned on a 16-bit boundary, then ASSERT().
359 If Source is not aligned on a 16-bit boundary, then ASSERT().
360 If an error would be returned, then the function will also ASSERT().
362 If an error is returned, then the Destination is unmodified.
364 @param Destination A pointer to a Null-terminated Unicode string.
365 @param DestMax The maximum number of Destination Unicode
366 char, including terminating null char.
367 @param Source A pointer to a Null-terminated Unicode string.
368 @param Length The maximum number of Unicode characters to copy.
370 @retval RETURN_SUCCESS String is appended.
371 @retval RETURN_BAD_BUFFER_SIZE If DestMax is NOT greater than
373 @retval RETURN_BUFFER_TOO_SMALL If (DestMax - StrLen(Destination)) is NOT
374 greater than MIN(StrLen(Source), Length).
375 @retval RETURN_INVALID_PARAMETER If Destination is NULL.
377 If PcdMaximumUnicodeStringLength is not zero,
378 and DestMax is greater than
379 PcdMaximumUnicodeStringLength.
381 @retval RETURN_ACCESS_DENIED If Source and Destination overlap.
386 IN OUT CHAR16
*Destination
,
388 IN CONST CHAR16
*Source
,
393 Convert a Null-terminated Unicode decimal string to a value of type UINTN.
395 This function outputs a value of type UINTN by interpreting the contents of
396 the Unicode string specified by String as a decimal number. The format of the
397 input Unicode string String is:
399 [spaces] [decimal digits].
401 The valid decimal digit character is in the range [0-9]. The function will
402 ignore the pad space, which includes spaces or tab characters, before
403 [decimal digits]. The running zero in the beginning of [decimal digits] will
404 be ignored. Then, the function stops at the first character that is a not a
405 valid decimal character or a Null-terminator, whichever one comes first.
407 If String is NULL, then ASSERT().
408 If Data is NULL, then ASSERT().
409 If String is not aligned in a 16-bit boundary, then ASSERT().
410 If PcdMaximumUnicodeStringLength is not zero, and String contains more than
411 PcdMaximumUnicodeStringLength Unicode characters, not including the
412 Null-terminator, then ASSERT().
414 If String has no valid decimal digits in the above format, then 0 is stored
415 at the location pointed to by Data.
416 If the number represented by String exceeds the range defined by UINTN, then
417 MAX_UINTN is stored at the location pointed to by Data.
419 If EndPointer is not NULL, a pointer to the character that stopped the scan
420 is stored at the location pointed to by EndPointer. If String has no valid
421 decimal digits right after the optional pad spaces, the value of String is
422 stored at the location pointed to by EndPointer.
424 @param String Pointer to a Null-terminated Unicode string.
425 @param EndPointer Pointer to character that stops scan.
426 @param Data Pointer to the converted value.
428 @retval RETURN_SUCCESS Value is translated from String.
429 @retval RETURN_INVALID_PARAMETER If String is NULL.
431 If PcdMaximumUnicodeStringLength is not
432 zero, and String contains more than
433 PcdMaximumUnicodeStringLength Unicode
434 characters, not including the
436 @retval RETURN_UNSUPPORTED If the number represented by String exceeds
437 the range defined by UINTN.
443 IN CONST CHAR16
*String
,
444 OUT CHAR16
**EndPointer
, OPTIONAL
449 Convert a Null-terminated Unicode decimal string to a value of type UINT64.
451 This function outputs a value of type UINT64 by interpreting the contents of
452 the Unicode string specified by String as a decimal number. The format of the
453 input Unicode string String is:
455 [spaces] [decimal digits].
457 The valid decimal digit character is in the range [0-9]. The function will
458 ignore the pad space, which includes spaces or tab characters, before
459 [decimal digits]. The running zero in the beginning of [decimal digits] will
460 be ignored. Then, the function stops at the first character that is a not a
461 valid decimal character or a Null-terminator, whichever one comes first.
463 If String is NULL, then ASSERT().
464 If Data is NULL, then ASSERT().
465 If String is not aligned in a 16-bit boundary, then ASSERT().
466 If PcdMaximumUnicodeStringLength is not zero, and String contains more than
467 PcdMaximumUnicodeStringLength Unicode characters, not including the
468 Null-terminator, then ASSERT().
470 If String has no valid decimal digits in the above format, then 0 is stored
471 at the location pointed to by Data.
472 If the number represented by String exceeds the range defined by UINT64, then
473 MAX_UINT64 is stored at the location pointed to by Data.
475 If EndPointer is not NULL, a pointer to the character that stopped the scan
476 is stored at the location pointed to by EndPointer. If String has no valid
477 decimal digits right after the optional pad spaces, the value of String is
478 stored at the location pointed to by EndPointer.
480 @param String Pointer to a Null-terminated Unicode string.
481 @param EndPointer Pointer to character that stops scan.
482 @param Data Pointer to the converted value.
484 @retval RETURN_SUCCESS Value is translated from String.
485 @retval RETURN_INVALID_PARAMETER If String is NULL.
487 If PcdMaximumUnicodeStringLength is not
488 zero, and String contains more than
489 PcdMaximumUnicodeStringLength Unicode
490 characters, not including the
492 @retval RETURN_UNSUPPORTED If the number represented by String exceeds
493 the range defined by UINT64.
498 StrDecimalToUint64S (
499 IN CONST CHAR16
*String
,
500 OUT CHAR16
**EndPointer
, OPTIONAL
505 Convert a Null-terminated Unicode hexadecimal string to a value of type
508 This function outputs a value of type UINTN by interpreting the contents of
509 the Unicode string specified by String as a hexadecimal number. The format of
510 the input Unicode string String is:
512 [spaces][zeros][x][hexadecimal digits].
514 The valid hexadecimal digit character is in the range [0-9], [a-f] and [A-F].
515 The prefix "0x" is optional. Both "x" and "X" is allowed in "0x" prefix.
516 If "x" appears in the input string, it must be prefixed with at least one 0.
517 The function will ignore the pad space, which includes spaces or tab
518 characters, before [zeros], [x] or [hexadecimal digit]. The running zero
519 before [x] or [hexadecimal digit] will be ignored. Then, the decoding starts
520 after [x] or the first valid hexadecimal digit. Then, the function stops at
521 the first character that is a not a valid hexadecimal character or NULL,
522 whichever one comes first.
524 If String is NULL, then ASSERT().
525 If Data is NULL, then ASSERT().
526 If String is not aligned in a 16-bit boundary, then ASSERT().
527 If PcdMaximumUnicodeStringLength is not zero, and String contains more than
528 PcdMaximumUnicodeStringLength Unicode characters, not including the
529 Null-terminator, then ASSERT().
531 If String has no valid hexadecimal digits in the above format, then 0 is
532 stored at the location pointed to by Data.
533 If the number represented by String exceeds the range defined by UINTN, then
534 MAX_UINTN is stored at the location pointed to by Data.
536 If EndPointer is not NULL, a pointer to the character that stopped the scan
537 is stored at the location pointed to by EndPointer. If String has no valid
538 hexadecimal digits right after the optional pad spaces, the value of String
539 is stored at the location pointed to by EndPointer.
541 @param String Pointer to a Null-terminated Unicode string.
542 @param EndPointer Pointer to character that stops scan.
543 @param Data Pointer to the converted value.
545 @retval RETURN_SUCCESS Value is translated from String.
546 @retval RETURN_INVALID_PARAMETER If String is NULL.
548 If PcdMaximumUnicodeStringLength is not
549 zero, and String contains more than
550 PcdMaximumUnicodeStringLength Unicode
551 characters, not including the
553 @retval RETURN_UNSUPPORTED If the number represented by String exceeds
554 the range defined by UINTN.
560 IN CONST CHAR16
*String
,
561 OUT CHAR16
**EndPointer
, OPTIONAL
566 Convert a Null-terminated Unicode hexadecimal string to a value of type
569 This function outputs a value of type UINT64 by interpreting the contents of
570 the Unicode string specified by String as a hexadecimal number. The format of
571 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
579 characters, before [zeros], [x] or [hexadecimal digit]. The running zero
580 before [x] or [hexadecimal digit] will be ignored. Then, the decoding starts
581 after [x] or the first valid hexadecimal digit. Then, the function stops at
582 the first character that is a not a valid hexadecimal character or NULL,
583 whichever one comes first.
585 If String is NULL, then ASSERT().
586 If Data is NULL, then ASSERT().
587 If String is not aligned in a 16-bit boundary, then ASSERT().
588 If PcdMaximumUnicodeStringLength is not zero, and String contains more than
589 PcdMaximumUnicodeStringLength Unicode characters, not including the
590 Null-terminator, then ASSERT().
592 If String has no valid hexadecimal digits in the above format, then 0 is
593 stored at the location pointed to by Data.
594 If the number represented by String exceeds the range defined by UINT64, then
595 MAX_UINT64 is stored at the location pointed to by Data.
597 If EndPointer is not NULL, a pointer to the character that stopped the scan
598 is stored at the location pointed to by EndPointer. If String has no valid
599 hexadecimal digits right after the optional pad spaces, the value of String
600 is stored at the location pointed to by EndPointer.
602 @param String Pointer to a Null-terminated Unicode string.
603 @param EndPointer Pointer to character that stops scan.
604 @param Data Pointer to the converted value.
606 @retval RETURN_SUCCESS Value is translated from String.
607 @retval RETURN_INVALID_PARAMETER If String is NULL.
609 If PcdMaximumUnicodeStringLength is not
610 zero, and String contains more than
611 PcdMaximumUnicodeStringLength Unicode
612 characters, not including the
614 @retval RETURN_UNSUPPORTED If the number represented by String exceeds
615 the range defined by UINT64.
621 IN CONST CHAR16
*String
,
622 OUT CHAR16
**EndPointer
, OPTIONAL
627 Returns the length of a Null-terminated Ascii string.
629 This function is similar as strlen_s defined in C11.
631 @param String A pointer to a Null-terminated Ascii string.
632 @param MaxSize The maximum number of Destination Ascii
633 char, including terminating null char.
635 @retval 0 If String is NULL.
636 @retval MaxSize If there is no null character in the first MaxSize characters of String.
637 @return The number of characters that percede the terminating null character.
643 IN CONST CHAR8
*String
,
648 Returns the size of a Null-terminated Ascii string in bytes, including the
651 This function returns the size of the Null-terminated Ascii string specified
652 by String in bytes, including the Null terminator.
654 @param String A pointer to a Null-terminated Ascii string.
655 @param MaxSize The maximum number of Destination Ascii
656 char, including the Null terminator.
658 @retval 0 If String is NULL.
659 @retval (sizeof (CHAR8) * (MaxSize + 1))
660 If there is no Null terminator in the first MaxSize characters of
662 @return The size of the Null-terminated Ascii string in bytes, including the
669 IN CONST CHAR8
*String
,
674 Copies the string pointed to by Source (including the terminating null char)
675 to the array pointed to by Destination.
677 This function is similar as strcpy_s defined in C11.
679 If an error would be returned, then the function will also ASSERT().
681 If an error is returned, then the Destination is unmodified.
683 @param Destination A pointer to a Null-terminated Ascii string.
684 @param DestMax The maximum number of Destination Ascii
685 char, including terminating null char.
686 @param Source A pointer to a Null-terminated Ascii string.
688 @retval RETURN_SUCCESS String is copied.
689 @retval RETURN_BUFFER_TOO_SMALL If DestMax is NOT greater than StrLen(Source).
690 @retval RETURN_INVALID_PARAMETER If Destination is NULL.
692 If PcdMaximumAsciiStringLength is not zero,
693 and DestMax is greater than
694 PcdMaximumAsciiStringLength.
696 @retval RETURN_ACCESS_DENIED If Source and Destination overlap.
701 OUT CHAR8
*Destination
,
703 IN CONST CHAR8
*Source
707 Copies not more than Length successive char from the string pointed to by
708 Source to the array pointed to by Destination. If no null char is copied from
709 Source, then Destination[Length] is always set to null.
711 This function is similar as strncpy_s defined in C11.
713 If an error would be returned, then the function will also ASSERT().
715 If an error is returned, then the Destination is unmodified.
717 @param Destination A pointer to a Null-terminated Ascii string.
718 @param DestMax The maximum number of Destination Ascii
719 char, including terminating null char.
720 @param Source A pointer to a Null-terminated Ascii string.
721 @param Length The maximum number of Ascii characters to copy.
723 @retval RETURN_SUCCESS String is copied.
724 @retval RETURN_BUFFER_TOO_SMALL If DestMax is NOT greater than
725 MIN(StrLen(Source), Length).
726 @retval RETURN_INVALID_PARAMETER If Destination is NULL.
728 If PcdMaximumAsciiStringLength is not zero,
729 and DestMax is greater than
730 PcdMaximumAsciiStringLength.
732 @retval RETURN_ACCESS_DENIED If Source and Destination overlap.
737 OUT CHAR8
*Destination
,
739 IN CONST CHAR8
*Source
,
744 Appends a copy of the string pointed to by Source (including the terminating
745 null char) to the end of the string pointed to by Destination.
747 This function is similar as strcat_s defined in C11.
749 If an error would be returned, then the function will also ASSERT().
751 If an error is returned, then the Destination is unmodified.
753 @param Destination A pointer to a Null-terminated Ascii string.
754 @param DestMax The maximum number of Destination Ascii
755 char, including terminating null char.
756 @param Source A pointer to a Null-terminated Ascii string.
758 @retval RETURN_SUCCESS String is appended.
759 @retval RETURN_BAD_BUFFER_SIZE If DestMax is NOT greater than
761 @retval RETURN_BUFFER_TOO_SMALL If (DestMax - StrLen(Destination)) is NOT
762 greater than StrLen(Source).
763 @retval RETURN_INVALID_PARAMETER If Destination is NULL.
765 If PcdMaximumAsciiStringLength is not zero,
766 and DestMax is greater than
767 PcdMaximumAsciiStringLength.
769 @retval RETURN_ACCESS_DENIED If Source and Destination overlap.
774 IN OUT CHAR8
*Destination
,
776 IN CONST CHAR8
*Source
780 Appends not more than Length successive char from the string pointed to by
781 Source to the end of the string pointed to by Destination. If no null char is
782 copied from Source, then Destination[StrLen(Destination) + Length] is always
785 This function is similar as strncat_s defined in C11.
787 If an error would be returned, then the function will also ASSERT().
789 If an error is returned, then the Destination is unmodified.
791 @param Destination A pointer to a Null-terminated Ascii string.
792 @param DestMax The maximum number of Destination Ascii
793 char, including terminating null char.
794 @param Source A pointer to a Null-terminated Ascii string.
795 @param Length The maximum number of Ascii characters to copy.
797 @retval RETURN_SUCCESS String is appended.
798 @retval RETURN_BAD_BUFFER_SIZE If DestMax is NOT greater than
800 @retval RETURN_BUFFER_TOO_SMALL If (DestMax - StrLen(Destination)) is NOT
801 greater than MIN(StrLen(Source), Length).
802 @retval RETURN_INVALID_PARAMETER If Destination is NULL.
804 If PcdMaximumAsciiStringLength is not zero,
805 and DestMax is greater than
806 PcdMaximumAsciiStringLength.
808 @retval RETURN_ACCESS_DENIED If Source and Destination overlap.
813 IN OUT CHAR8
*Destination
,
815 IN CONST CHAR8
*Source
,
820 Convert a Null-terminated Ascii decimal string to a value of type UINTN.
822 This function outputs a value of type UINTN by interpreting the contents of
823 the Ascii string specified by String as a decimal number. The format of the
824 input Ascii string String is:
826 [spaces] [decimal digits].
828 The valid decimal digit character is in the range [0-9]. The function will
829 ignore the pad space, which includes spaces or tab characters, before
830 [decimal digits]. The running zero in the beginning of [decimal digits] will
831 be ignored. Then, the function stops at the first character that is a not a
832 valid decimal character or a Null-terminator, whichever one comes first.
834 If String is NULL, then ASSERT().
835 If Data is NULL, then ASSERT().
836 If PcdMaximumAsciiStringLength is not zero, and String contains more than
837 PcdMaximumAsciiStringLength Ascii characters, not including the
838 Null-terminator, then ASSERT().
840 If String has no valid decimal digits in the above format, then 0 is stored
841 at the location pointed to by Data.
842 If the number represented by String exceeds the range defined by UINTN, then
843 MAX_UINTN is stored at the location pointed to by Data.
845 If EndPointer is not NULL, a pointer to the character that stopped the scan
846 is stored at the location pointed to by EndPointer. If String has no valid
847 decimal digits right after the optional pad spaces, the value of String is
848 stored at the location pointed to by EndPointer.
850 @param String Pointer to a Null-terminated Ascii string.
851 @param EndPointer Pointer to character that stops scan.
852 @param Data Pointer to the converted value.
854 @retval RETURN_SUCCESS Value is translated from String.
855 @retval RETURN_INVALID_PARAMETER If String is NULL.
857 If PcdMaximumAsciiStringLength is not zero,
858 and String contains more than
859 PcdMaximumAsciiStringLength Ascii
860 characters, not including the
862 @retval RETURN_UNSUPPORTED If the number represented by String exceeds
863 the range defined by UINTN.
868 AsciiStrDecimalToUintnS (
869 IN CONST CHAR8
*String
,
870 OUT CHAR8
**EndPointer
, OPTIONAL
875 Convert a Null-terminated Ascii decimal string to a value of type UINT64.
877 This function outputs a value of type UINT64 by interpreting the contents of
878 the Ascii string specified by String as a decimal number. The format of the
879 input Ascii string String is:
881 [spaces] [decimal digits].
883 The valid decimal digit character is in the range [0-9]. The function will
884 ignore the pad space, which includes spaces or tab characters, before
885 [decimal digits]. The running zero in the beginning of [decimal digits] will
886 be ignored. Then, the function stops at the first character that is a not a
887 valid decimal character or a Null-terminator, whichever one comes first.
889 If String is NULL, then ASSERT().
890 If Data is NULL, then ASSERT().
891 If PcdMaximumAsciiStringLength is not zero, and String contains more than
892 PcdMaximumAsciiStringLength Ascii characters, not including the
893 Null-terminator, then ASSERT().
895 If String has no valid decimal digits in the above format, then 0 is stored
896 at the location pointed to by Data.
897 If the number represented by String exceeds the range defined by UINT64, then
898 MAX_UINT64 is stored at the location pointed to by Data.
900 If EndPointer is not NULL, a pointer to the character that stopped the scan
901 is stored at the location pointed to by EndPointer. If String has no valid
902 decimal digits right after the optional pad spaces, the value of String is
903 stored at the location pointed to by EndPointer.
905 @param String Pointer to a Null-terminated Ascii string.
906 @param EndPointer Pointer to character that stops scan.
907 @param Data Pointer to the converted value.
909 @retval RETURN_SUCCESS Value is translated from String.
910 @retval RETURN_INVALID_PARAMETER If String is NULL.
912 If PcdMaximumAsciiStringLength is not zero,
913 and String contains more than
914 PcdMaximumAsciiStringLength Ascii
915 characters, not including the
917 @retval RETURN_UNSUPPORTED If the number represented by String exceeds
918 the range defined by UINT64.
923 AsciiStrDecimalToUint64S (
924 IN CONST CHAR8
*String
,
925 OUT CHAR8
**EndPointer
, OPTIONAL
930 Convert a Null-terminated Ascii hexadecimal string to a value of type UINTN.
932 This function outputs a value of type UINTN by interpreting the contents of
933 the Ascii string specified by String as a hexadecimal number. The format of
934 the input Ascii string String is:
936 [spaces][zeros][x][hexadecimal digits].
938 The valid hexadecimal digit character is in the range [0-9], [a-f] and [A-F].
939 The prefix "0x" is optional. Both "x" and "X" is allowed in "0x" prefix. If
940 "x" appears in the input string, it must be prefixed with at least one 0. The
941 function will ignore the pad space, which includes spaces or tab characters,
942 before [zeros], [x] or [hexadecimal digits]. The running zero before [x] or
943 [hexadecimal digits] will be ignored. Then, the decoding starts after [x] or
944 the first valid hexadecimal digit. Then, the function stops at the first
945 character that is a not a valid hexadecimal character or Null-terminator,
946 whichever on comes first.
948 If String is NULL, then ASSERT().
949 If Data is NULL, then ASSERT().
950 If PcdMaximumAsciiStringLength is not zero, and String contains more than
951 PcdMaximumAsciiStringLength Ascii characters, not including the
952 Null-terminator, then ASSERT().
954 If String has no valid hexadecimal digits in the above format, then 0 is
955 stored at the location pointed to by Data.
956 If the number represented by String exceeds the range defined by UINTN, then
957 MAX_UINTN is stored at the location pointed to by Data.
959 If EndPointer is not NULL, a pointer to the character that stopped the scan
960 is stored at the location pointed to by EndPointer. If String has no valid
961 hexadecimal digits right after the optional pad spaces, the value of String
962 is stored at the location pointed to by EndPointer.
964 @param String Pointer to a Null-terminated Ascii string.
965 @param EndPointer Pointer to character that stops scan.
966 @param Data Pointer to the converted value.
968 @retval RETURN_SUCCESS Value is translated from String.
969 @retval RETURN_INVALID_PARAMETER If String is NULL.
971 If PcdMaximumAsciiStringLength is not zero,
972 and String contains more than
973 PcdMaximumAsciiStringLength Ascii
974 characters, not including the
976 @retval RETURN_UNSUPPORTED If the number represented by String exceeds
977 the range defined by UINTN.
982 AsciiStrHexToUintnS (
983 IN CONST CHAR8
*String
,
984 OUT CHAR8
**EndPointer
, OPTIONAL
989 Convert a Null-terminated Ascii hexadecimal string to a value of type UINT64.
991 This function outputs a value of type UINT64 by interpreting the contents of
992 the Ascii string specified by String as a hexadecimal number. The format of
993 the input Ascii string String is:
995 [spaces][zeros][x][hexadecimal digits].
997 The valid hexadecimal digit character is in the range [0-9], [a-f] and [A-F].
998 The prefix "0x" is optional. Both "x" and "X" is allowed in "0x" prefix. If
999 "x" appears in the input string, it must be prefixed with at least one 0. The
1000 function will ignore the pad space, which includes spaces or tab characters,
1001 before [zeros], [x] or [hexadecimal digits]. The running zero before [x] or
1002 [hexadecimal digits] will be ignored. Then, the decoding starts after [x] or
1003 the first valid hexadecimal digit. Then, the function stops at the first
1004 character that is a not a valid hexadecimal character or Null-terminator,
1005 whichever on comes first.
1007 If String is NULL, then ASSERT().
1008 If Data is NULL, then ASSERT().
1009 If PcdMaximumAsciiStringLength is not zero, and String contains more than
1010 PcdMaximumAsciiStringLength Ascii characters, not including the
1011 Null-terminator, then ASSERT().
1013 If String has no valid hexadecimal digits in the above format, then 0 is
1014 stored at the location pointed to by Data.
1015 If the number represented by String exceeds the range defined by UINT64, then
1016 MAX_UINT64 is stored at the location pointed to by Data.
1018 If EndPointer is not NULL, a pointer to the character that stopped the scan
1019 is stored at the location pointed to by EndPointer. If String has no valid
1020 hexadecimal digits right after the optional pad spaces, the value of String
1021 is stored at the location pointed to by EndPointer.
1023 @param String Pointer to a Null-terminated Ascii string.
1024 @param EndPointer Pointer to character that stops scan.
1025 @param Data Pointer to the converted value.
1027 @retval RETURN_SUCCESS Value is translated from String.
1028 @retval RETURN_INVALID_PARAMETER If String is NULL.
1030 If PcdMaximumAsciiStringLength is not zero,
1031 and String contains more than
1032 PcdMaximumAsciiStringLength Ascii
1033 characters, not including the
1035 @retval RETURN_UNSUPPORTED If the number represented by String exceeds
1036 the range defined by UINT64.
1041 AsciiStrHexToUint64S (
1042 IN CONST CHAR8
*String
,
1043 OUT CHAR8
**EndPointer
, OPTIONAL
1048 #ifndef DISABLE_NEW_DEPRECATED_INTERFACES
1051 [ATTENTION] This function is deprecated for security reason.
1053 Copies one Null-terminated Unicode string to another Null-terminated Unicode
1054 string and returns the new Unicode string.
1056 This function copies the contents of the Unicode string Source to the Unicode
1057 string Destination, and returns Destination. If Source and Destination
1058 overlap, then the results are undefined.
1060 If Destination is NULL, then ASSERT().
1061 If Destination is not aligned on a 16-bit boundary, then ASSERT().
1062 If Source is NULL, then ASSERT().
1063 If Source is not aligned on a 16-bit boundary, then ASSERT().
1064 If Source and Destination overlap, then ASSERT().
1065 If PcdMaximumUnicodeStringLength is not zero, and Source contains more than
1066 PcdMaximumUnicodeStringLength Unicode characters not including the
1067 Null-terminator, then ASSERT().
1069 @param Destination The pointer to a Null-terminated Unicode string.
1070 @param Source The pointer to a Null-terminated Unicode string.
1072 @return Destination.
1078 OUT CHAR16
*Destination
,
1079 IN CONST CHAR16
*Source
1084 [ATTENTION] This function is deprecated for security reason.
1086 Copies up to a specified length from one Null-terminated Unicode string to
1087 another Null-terminated Unicode string and returns the new Unicode string.
1089 This function copies the contents of the Unicode string Source to the Unicode
1090 string Destination, and returns Destination. At most, Length Unicode
1091 characters are copied from Source to Destination. If Length is 0, then
1092 Destination is returned unmodified. If Length is greater that the number of
1093 Unicode characters in Source, then Destination is padded with Null Unicode
1094 characters. If Source and Destination overlap, then the results are
1097 If Length > 0 and Destination is NULL, then ASSERT().
1098 If Length > 0 and Destination is not aligned on a 16-bit boundary, then ASSERT().
1099 If Length > 0 and Source is NULL, then ASSERT().
1100 If Length > 0 and Source is not aligned on a 16-bit boundary, then ASSERT().
1101 If Source and Destination overlap, then ASSERT().
1102 If PcdMaximumUnicodeStringLength is not zero, and Length is greater than
1103 PcdMaximumUnicodeStringLength, then ASSERT().
1104 If PcdMaximumUnicodeStringLength is not zero, and Source contains more than
1105 PcdMaximumUnicodeStringLength Unicode characters, not including the Null-terminator,
1108 @param Destination The pointer to a Null-terminated Unicode string.
1109 @param Source The pointer to a Null-terminated Unicode string.
1110 @param Length The maximum number of Unicode characters to copy.
1112 @return Destination.
1118 OUT CHAR16
*Destination
,
1119 IN CONST CHAR16
*Source
,
1122 #endif // !defined (DISABLE_NEW_DEPRECATED_INTERFACES)
1125 Returns the length of a Null-terminated Unicode string.
1127 This function returns the number of Unicode characters in the Null-terminated
1128 Unicode string specified by String.
1130 If String is NULL, then ASSERT().
1131 If String is not aligned on a 16-bit boundary, then ASSERT().
1132 If PcdMaximumUnicodeStringLength is not zero, and String contains more than
1133 PcdMaximumUnicodeStringLength Unicode characters not including the
1134 Null-terminator, then ASSERT().
1136 @param String Pointer to a Null-terminated Unicode string.
1138 @return The length of String.
1144 IN CONST CHAR16
*String
1149 Returns the size of a Null-terminated Unicode string in bytes, including the
1152 This function returns the size, in bytes, of the Null-terminated Unicode string
1153 specified by String.
1155 If String is NULL, then ASSERT().
1156 If String is not aligned on a 16-bit boundary, then ASSERT().
1157 If PcdMaximumUnicodeStringLength is not zero, and String contains more than
1158 PcdMaximumUnicodeStringLength Unicode characters not including the
1159 Null-terminator, then ASSERT().
1161 @param String The pointer to a Null-terminated Unicode string.
1163 @return The size of String.
1169 IN CONST CHAR16
*String
1174 Compares two Null-terminated Unicode strings, and returns the difference
1175 between the first mismatched Unicode characters.
1177 This function compares the Null-terminated Unicode string FirstString to the
1178 Null-terminated Unicode string SecondString. If FirstString is identical to
1179 SecondString, then 0 is returned. Otherwise, the value returned is the first
1180 mismatched Unicode character in SecondString subtracted from the first
1181 mismatched Unicode character in FirstString.
1183 If FirstString is NULL, then ASSERT().
1184 If FirstString is not aligned on a 16-bit boundary, then ASSERT().
1185 If SecondString is NULL, then ASSERT().
1186 If SecondString is not aligned on a 16-bit boundary, then ASSERT().
1187 If PcdMaximumUnicodeStringLength is not zero, and FirstString contains more
1188 than PcdMaximumUnicodeStringLength Unicode characters not including the
1189 Null-terminator, then ASSERT().
1190 If PcdMaximumUnicodeStringLength is not zero, and SecondString contains more
1191 than PcdMaximumUnicodeStringLength Unicode characters, not including the
1192 Null-terminator, then ASSERT().
1194 @param FirstString The pointer to a Null-terminated Unicode string.
1195 @param SecondString The pointer to a Null-terminated Unicode string.
1197 @retval 0 FirstString is identical to SecondString.
1198 @return others FirstString is not identical to SecondString.
1204 IN CONST CHAR16
*FirstString
,
1205 IN CONST CHAR16
*SecondString
1210 Compares up to a specified length the contents of two Null-terminated Unicode strings,
1211 and returns the difference between the first mismatched Unicode characters.
1213 This function compares the Null-terminated Unicode string FirstString to the
1214 Null-terminated Unicode string SecondString. At most, Length Unicode
1215 characters will be compared. If Length is 0, then 0 is returned. If
1216 FirstString is identical to SecondString, then 0 is returned. Otherwise, the
1217 value returned is the first mismatched Unicode character in SecondString
1218 subtracted from the first mismatched Unicode character in FirstString.
1220 If Length > 0 and FirstString is NULL, then ASSERT().
1221 If Length > 0 and FirstString is not aligned on a 16-bit boundary, then ASSERT().
1222 If Length > 0 and SecondString is NULL, then ASSERT().
1223 If Length > 0 and SecondString is not aligned on a 16-bit boundary, then ASSERT().
1224 If PcdMaximumUnicodeStringLength is not zero, and Length is greater than
1225 PcdMaximumUnicodeStringLength, then ASSERT().
1226 If PcdMaximumUnicodeStringLength is not zero, and FirstString contains more than
1227 PcdMaximumUnicodeStringLength Unicode characters, not including the Null-terminator,
1229 If PcdMaximumUnicodeStringLength is not zero, and SecondString contains more than
1230 PcdMaximumUnicodeStringLength Unicode characters, not including the Null-terminator,
1233 @param FirstString The pointer to a Null-terminated Unicode string.
1234 @param SecondString The pointer to a Null-terminated Unicode string.
1235 @param Length The maximum number of Unicode characters to compare.
1237 @retval 0 FirstString is identical to SecondString.
1238 @return others FirstString is not identical to SecondString.
1244 IN CONST CHAR16
*FirstString
,
1245 IN CONST CHAR16
*SecondString
,
1250 #ifndef DISABLE_NEW_DEPRECATED_INTERFACES
1253 [ATTENTION] This function is deprecated for security reason.
1255 Concatenates one Null-terminated Unicode string to another Null-terminated
1256 Unicode string, and returns the concatenated Unicode string.
1258 This function concatenates two Null-terminated Unicode strings. The contents
1259 of Null-terminated Unicode string Source are concatenated to the end of
1260 Null-terminated Unicode string Destination. The Null-terminated concatenated
1261 Unicode String is returned. If Source and Destination overlap, then the
1262 results are undefined.
1264 If Destination is NULL, then ASSERT().
1265 If Destination is not aligned on a 16-bit boundary, then ASSERT().
1266 If Source is NULL, then ASSERT().
1267 If Source is not aligned on a 16-bit boundary, then ASSERT().
1268 If Source and Destination overlap, then ASSERT().
1269 If PcdMaximumUnicodeStringLength is not zero, and Destination contains more
1270 than PcdMaximumUnicodeStringLength Unicode characters, not including the
1271 Null-terminator, then ASSERT().
1272 If PcdMaximumUnicodeStringLength is not zero, and Source contains more than
1273 PcdMaximumUnicodeStringLength Unicode characters, not including the
1274 Null-terminator, then ASSERT().
1275 If PcdMaximumUnicodeStringLength is not zero, and concatenating Destination
1276 and Source results in a Unicode string with more than
1277 PcdMaximumUnicodeStringLength Unicode characters, not including the
1278 Null-terminator, then ASSERT().
1280 @param Destination The pointer to a Null-terminated Unicode string.
1281 @param Source The pointer to a Null-terminated Unicode string.
1283 @return Destination.
1289 IN OUT CHAR16
*Destination
,
1290 IN CONST CHAR16
*Source
1295 [ATTENTION] This function is deprecated for security reason.
1297 Concatenates up to a specified length one Null-terminated Unicode to the end
1298 of another Null-terminated Unicode string, and returns the concatenated
1301 This function concatenates two Null-terminated Unicode strings. The contents
1302 of Null-terminated Unicode string Source are concatenated to the end of
1303 Null-terminated Unicode string Destination, and Destination is returned. At
1304 most, Length Unicode characters are concatenated from Source to the end of
1305 Destination, and Destination is always Null-terminated. If Length is 0, then
1306 Destination is returned unmodified. If Source and Destination overlap, then
1307 the results are undefined.
1309 If Destination is NULL, then ASSERT().
1310 If Length > 0 and Destination is not aligned on a 16-bit boundary, then ASSERT().
1311 If Length > 0 and Source is NULL, then ASSERT().
1312 If Length > 0 and Source is not aligned on a 16-bit boundary, then ASSERT().
1313 If Source and Destination overlap, then ASSERT().
1314 If PcdMaximumUnicodeStringLength is not zero, and Length is greater than
1315 PcdMaximumUnicodeStringLength, then ASSERT().
1316 If PcdMaximumUnicodeStringLength is not zero, and Destination contains more
1317 than PcdMaximumUnicodeStringLength Unicode characters, not including the
1318 Null-terminator, then ASSERT().
1319 If PcdMaximumUnicodeStringLength is not zero, and Source contains more than
1320 PcdMaximumUnicodeStringLength Unicode characters, not including the
1321 Null-terminator, then ASSERT().
1322 If PcdMaximumUnicodeStringLength is not zero, and concatenating Destination
1323 and Source results in a Unicode string with more than PcdMaximumUnicodeStringLength
1324 Unicode characters, not including the Null-terminator, then ASSERT().
1326 @param Destination The pointer to a Null-terminated Unicode string.
1327 @param Source The pointer to a Null-terminated Unicode string.
1328 @param Length The maximum number of Unicode characters to concatenate from
1331 @return Destination.
1337 IN OUT CHAR16
*Destination
,
1338 IN CONST CHAR16
*Source
,
1341 #endif // !defined (DISABLE_NEW_DEPRECATED_INTERFACES)
1344 Returns the first occurrence of a Null-terminated Unicode sub-string
1345 in a Null-terminated Unicode string.
1347 This function scans the contents of the Null-terminated Unicode string
1348 specified by String and returns the first occurrence of SearchString.
1349 If SearchString is not found in String, then NULL is returned. If
1350 the length of SearchString is zero, then String is returned.
1352 If String is NULL, then ASSERT().
1353 If String is not aligned on a 16-bit boundary, then ASSERT().
1354 If SearchString is NULL, then ASSERT().
1355 If SearchString is not aligned on a 16-bit boundary, then ASSERT().
1357 If PcdMaximumUnicodeStringLength is not zero, and SearchString
1358 or String contains more than PcdMaximumUnicodeStringLength Unicode
1359 characters, not including the Null-terminator, then ASSERT().
1361 @param String The pointer to a Null-terminated Unicode string.
1362 @param SearchString The pointer to a Null-terminated Unicode string to search for.
1364 @retval NULL If the SearchString does not appear in String.
1365 @return others If there is a match.
1371 IN CONST CHAR16
*String
,
1372 IN CONST CHAR16
*SearchString
1376 Convert a Null-terminated Unicode decimal string to a value of
1379 This function returns a value of type UINTN by interpreting the contents
1380 of the Unicode string specified by String as a decimal number. The format
1381 of the input Unicode string String is:
1383 [spaces] [decimal digits].
1385 The valid decimal digit character is in the range [0-9]. The
1386 function will ignore the pad space, which includes spaces or
1387 tab characters, before [decimal digits]. The running zero in the
1388 beginning of [decimal digits] will be ignored. Then, the function
1389 stops at the first character that is a not a valid decimal character
1390 or a Null-terminator, whichever one comes first.
1392 If String is NULL, then ASSERT().
1393 If String is not aligned in a 16-bit boundary, then ASSERT().
1394 If String has only pad spaces, then 0 is returned.
1395 If String has no pad spaces or valid decimal digits,
1397 If the number represented by String overflows according
1398 to the range defined by UINTN, then MAX_UINTN is returned.
1400 If PcdMaximumUnicodeStringLength is not zero, and String contains
1401 more than PcdMaximumUnicodeStringLength Unicode characters not including
1402 the Null-terminator, then ASSERT().
1404 @param String The pointer to a Null-terminated Unicode string.
1406 @retval Value translated from String.
1412 IN CONST CHAR16
*String
1416 Convert a Null-terminated Unicode decimal string to a value of
1419 This function returns a value of type UINT64 by interpreting the contents
1420 of the Unicode string specified by String as a decimal number. The format
1421 of the input Unicode string String is:
1423 [spaces] [decimal digits].
1425 The valid decimal digit character is in the range [0-9]. The
1426 function will ignore the pad space, which includes spaces or
1427 tab characters, before [decimal digits]. The running zero in the
1428 beginning of [decimal digits] will be ignored. Then, the function
1429 stops at the first character that is a not a valid decimal character
1430 or a Null-terminator, whichever one comes first.
1432 If String is NULL, then ASSERT().
1433 If String is not aligned in a 16-bit boundary, then ASSERT().
1434 If String has only pad spaces, then 0 is returned.
1435 If String has no pad spaces or valid decimal digits,
1437 If the number represented by String overflows according
1438 to the range defined by UINT64, then MAX_UINT64 is returned.
1440 If PcdMaximumUnicodeStringLength is not zero, and String contains
1441 more than PcdMaximumUnicodeStringLength Unicode characters not including
1442 the Null-terminator, then ASSERT().
1444 @param String The pointer to a Null-terminated Unicode string.
1446 @retval Value translated from String.
1451 StrDecimalToUint64 (
1452 IN CONST CHAR16
*String
1457 Convert a Null-terminated Unicode hexadecimal string to a value of type UINTN.
1459 This function returns a value of type UINTN by interpreting the contents
1460 of the Unicode string specified by String as a hexadecimal number.
1461 The format of the input Unicode string String is:
1463 [spaces][zeros][x][hexadecimal digits].
1465 The valid hexadecimal digit character is in the range [0-9], [a-f] and [A-F].
1466 The prefix "0x" is optional. Both "x" and "X" is allowed in "0x" prefix.
1467 If "x" appears in the input string, it must be prefixed with at least one 0.
1468 The function will ignore the pad space, which includes spaces or tab characters,
1469 before [zeros], [x] or [hexadecimal digit]. The running zero before [x] or
1470 [hexadecimal digit] will be ignored. Then, the decoding starts after [x] or the
1471 first valid hexadecimal digit. Then, the function stops at the first character
1472 that is a not a valid hexadecimal character or NULL, whichever one comes first.
1474 If String is NULL, then ASSERT().
1475 If String is not aligned in a 16-bit boundary, then ASSERT().
1476 If String has only pad spaces, then zero is returned.
1477 If String has no leading pad spaces, leading zeros or valid hexadecimal digits,
1478 then zero is returned.
1479 If the number represented by String overflows according to the range defined by
1480 UINTN, then MAX_UINTN is returned.
1482 If PcdMaximumUnicodeStringLength is not zero, and String contains more than
1483 PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator,
1486 @param String The pointer to a Null-terminated Unicode string.
1488 @retval Value translated from String.
1494 IN CONST CHAR16
*String
1499 Convert a Null-terminated Unicode hexadecimal string to a value of type UINT64.
1501 This function returns a value of type UINT64 by interpreting the contents
1502 of the Unicode string specified by String as a hexadecimal number.
1503 The format of the input Unicode string String is
1505 [spaces][zeros][x][hexadecimal digits].
1507 The valid hexadecimal digit character is in the range [0-9], [a-f] and [A-F].
1508 The prefix "0x" is optional. Both "x" and "X" is allowed in "0x" prefix.
1509 If "x" appears in the input string, it must be prefixed with at least one 0.
1510 The function will ignore the pad space, which includes spaces or tab characters,
1511 before [zeros], [x] or [hexadecimal digit]. The running zero before [x] or
1512 [hexadecimal digit] will be ignored. Then, the decoding starts after [x] or the
1513 first valid hexadecimal digit. Then, the function stops at the first character that is
1514 a not a valid hexadecimal character or NULL, whichever one comes first.
1516 If String is NULL, then ASSERT().
1517 If String is not aligned in a 16-bit boundary, then ASSERT().
1518 If String has only pad spaces, then zero is returned.
1519 If String has no leading pad spaces, leading zeros or valid hexadecimal digits,
1520 then zero is returned.
1521 If the number represented by String overflows according to the range defined by
1522 UINT64, then MAX_UINT64 is returned.
1524 If PcdMaximumUnicodeStringLength is not zero, and String contains more than
1525 PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator,
1528 @param String The pointer to a Null-terminated Unicode string.
1530 @retval Value translated from String.
1536 IN CONST CHAR16
*String
1540 Convert a Null-terminated Unicode string to IPv6 address and prefix length.
1542 This function outputs a value of type IPv6_ADDRESS and may output a value
1543 of type UINT8 by interpreting the contents of the Unicode string specified
1544 by String. The format of the input Unicode string String is as follows:
1548 X contains one to four hexadecimal digit characters in the range [0-9], [a-f] and
1549 [A-F]. X is converted to a value of type UINT16, whose low byte is stored in low
1550 memory address and high byte is stored in high memory address. P contains decimal
1551 digit characters in the range [0-9]. The running zero in the beginning of P will
1552 be ignored. /P is optional.
1554 When /P is not in the String, the function stops at the first character that is
1555 not a valid hexadecimal digit character after eight X's are converted.
1557 When /P is in the String, the function stops at the first character that is not
1558 a valid decimal digit character after P is converted.
1560 "::" can be used to compress one or more groups of X when X contains only 0.
1561 The "::" can only appear once in the String.
1563 If String is NULL, then ASSERT().
1565 If Address is NULL, then ASSERT().
1567 If String is not aligned in a 16-bit boundary, then ASSERT().
1569 If PcdMaximumUnicodeStringLength is not zero, and String contains more than
1570 PcdMaximumUnicodeStringLength Unicode characters, not including the
1571 Null-terminator, then ASSERT().
1573 If EndPointer is not NULL and Address is translated from String, a pointer
1574 to the character that stopped the scan is stored at the location pointed to
1577 @param String Pointer to a Null-terminated Unicode string.
1578 @param EndPointer Pointer to character that stops scan.
1579 @param Address Pointer to the converted IPv6 address.
1580 @param PrefixLength Pointer to the converted IPv6 address prefix
1581 length. MAX_UINT8 is returned when /P is
1584 @retval RETURN_SUCCESS Address is translated from String.
1585 @retval RETURN_INVALID_PARAMETER If String is NULL.
1587 @retval RETURN_UNSUPPORTED If X contains more than four hexadecimal
1589 If String contains "::" and number of X
1591 If P starts with character that is not a
1592 valid decimal digit character.
1593 If the decimal number converted from P
1600 IN CONST CHAR16
*String
,
1601 OUT CHAR16
**EndPointer
, OPTIONAL
1602 OUT IPv6_ADDRESS
*Address
,
1603 OUT UINT8
*PrefixLength OPTIONAL
1607 Convert a Null-terminated Unicode string to IPv4 address and prefix length.
1609 This function outputs a value of type IPv4_ADDRESS and may output a value
1610 of type UINT8 by interpreting the contents of the Unicode string specified
1611 by String. The format of the input Unicode string String is as follows:
1615 D and P are decimal digit characters in the range [0-9]. The running zero in
1616 the beginning of D and P will be ignored. /P is optional.
1618 When /P is not in the String, the function stops at the first character that is
1619 not a valid decimal digit character after four D's are converted.
1621 When /P is in the String, the function stops at the first character that is not
1622 a valid decimal digit character after P is converted.
1624 If String is NULL, then ASSERT().
1626 If Address is NULL, then ASSERT().
1628 If String is not aligned in a 16-bit boundary, then ASSERT().
1630 If PcdMaximumUnicodeStringLength is not zero, and String contains more than
1631 PcdMaximumUnicodeStringLength Unicode characters, not including the
1632 Null-terminator, then ASSERT().
1634 If EndPointer is not NULL and Address is translated from String, a pointer
1635 to the character that stopped the scan is stored at the location pointed to
1638 @param String Pointer to a Null-terminated Unicode string.
1639 @param EndPointer Pointer to character that stops scan.
1640 @param Address Pointer to the converted IPv4 address.
1641 @param PrefixLength Pointer to the converted IPv4 address prefix
1642 length. MAX_UINT8 is returned when /P is
1645 @retval RETURN_SUCCESS Address is translated from String.
1646 @retval RETURN_INVALID_PARAMETER If String is NULL.
1648 @retval RETURN_UNSUPPORTED If String is not in the correct format.
1649 If any decimal number converted from D
1651 If the decimal number converted from P
1658 IN CONST CHAR16
*String
,
1659 OUT CHAR16
**EndPointer
, OPTIONAL
1660 OUT IPv4_ADDRESS
*Address
,
1661 OUT UINT8
*PrefixLength OPTIONAL
1664 #define GUID_STRING_LENGTH 36
1667 Convert a Null-terminated Unicode GUID string to a value of type
1670 This function outputs a GUID value by interpreting the contents of
1671 the Unicode string specified by String. The format of the input
1672 Unicode string String consists of 36 characters, as follows:
1674 aabbccdd-eeff-gghh-iijj-kkllmmnnoopp
1676 The pairs aa - pp are two characters in the range [0-9], [a-f] and
1677 [A-F], with each pair representing a single byte hexadecimal value.
1679 The mapping between String and the EFI_GUID structure is as follows:
1697 If String is NULL, then ASSERT().
1698 If Guid is NULL, then ASSERT().
1699 If String is not aligned in a 16-bit boundary, then ASSERT().
1701 @param String Pointer to a Null-terminated Unicode string.
1702 @param Guid Pointer to the converted GUID.
1704 @retval RETURN_SUCCESS Guid is translated from String.
1705 @retval RETURN_INVALID_PARAMETER If String is NULL.
1707 @retval RETURN_UNSUPPORTED If String is not as the above format.
1713 IN CONST CHAR16
*String
,
1718 Convert a Null-terminated Unicode hexadecimal string to a byte array.
1720 This function outputs a byte array by interpreting the contents of
1721 the Unicode string specified by String in hexadecimal format. The format of
1722 the input Unicode string String is:
1726 X is a hexadecimal digit character in the range [0-9], [a-f] and [A-F].
1727 The function decodes every two hexadecimal digit characters as one byte. The
1728 decoding stops after Length of characters and outputs Buffer containing
1731 If String is not aligned in a 16-bit boundary, then ASSERT().
1733 If String is NULL, then ASSERT().
1735 If Buffer is NULL, then ASSERT().
1737 If Length is not multiple of 2, then ASSERT().
1739 If PcdMaximumUnicodeStringLength is not zero and Length is greater than
1740 PcdMaximumUnicodeStringLength, then ASSERT().
1742 If MaxBufferSize is less than (Length / 2), then ASSERT().
1744 @param String Pointer to a Null-terminated Unicode string.
1745 @param Length The number of Unicode characters to decode.
1746 @param Buffer Pointer to the converted bytes array.
1747 @param MaxBufferSize The maximum size of Buffer.
1749 @retval RETURN_SUCCESS Buffer is translated from String.
1750 @retval RETURN_INVALID_PARAMETER If String is NULL.
1752 If Length is not multiple of 2.
1753 If PcdMaximumUnicodeStringLength is not zero,
1754 and Length is greater than
1755 PcdMaximumUnicodeStringLength.
1756 @retval RETURN_UNSUPPORTED If Length of characters from String contain
1757 a character that is not valid hexadecimal
1758 digit characters, or a Null-terminator.
1759 @retval RETURN_BUFFER_TOO_SMALL If MaxBufferSize is less than (Length / 2).
1764 IN CONST CHAR16
*String
,
1767 IN UINTN MaxBufferSize
1770 #ifndef DISABLE_NEW_DEPRECATED_INTERFACES
1773 [ATTENTION] This function is deprecated for security reason.
1775 Convert a Null-terminated Unicode string to a Null-terminated
1776 ASCII string and returns the ASCII string.
1778 This function converts the content of the Unicode string Source
1779 to the ASCII string Destination by copying the lower 8 bits of
1780 each Unicode character. It returns Destination.
1782 The caller is responsible to make sure Destination points to a buffer with size
1783 equal or greater than ((StrLen (Source) + 1) * sizeof (CHAR8)) in bytes.
1785 If any Unicode characters in Source contain non-zero value in
1786 the upper 8 bits, then ASSERT().
1788 If Destination is NULL, then ASSERT().
1789 If Source is NULL, then ASSERT().
1790 If Source is not aligned on a 16-bit boundary, then ASSERT().
1791 If Source and Destination overlap, then ASSERT().
1793 If PcdMaximumUnicodeStringLength is not zero, and Source contains
1794 more than PcdMaximumUnicodeStringLength Unicode characters not including
1795 the Null-terminator, then ASSERT().
1797 If PcdMaximumAsciiStringLength is not zero, and Source contains more
1798 than PcdMaximumAsciiStringLength Unicode characters not including the
1799 Null-terminator, then ASSERT().
1801 @param Source The pointer to a Null-terminated Unicode string.
1802 @param Destination The pointer to a Null-terminated ASCII string.
1804 @return Destination.
1809 UnicodeStrToAsciiStr (
1810 IN CONST CHAR16
*Source
,
1811 OUT CHAR8
*Destination
1814 #endif // !defined (DISABLE_NEW_DEPRECATED_INTERFACES)
1817 Convert a Null-terminated Unicode string to a Null-terminated
1820 This function is similar to AsciiStrCpyS.
1822 This function converts the content of the Unicode string Source
1823 to the ASCII string Destination by copying the lower 8 bits of
1824 each Unicode character. The function terminates the ASCII string
1825 Destination by appending a Null-terminator character at the end.
1827 The caller is responsible to make sure Destination points to a buffer with size
1828 equal or greater than ((StrLen (Source) + 1) * sizeof (CHAR8)) in bytes.
1830 If any Unicode characters in Source contain non-zero value in
1831 the upper 8 bits, then ASSERT().
1833 If Source is not aligned on a 16-bit boundary, then ASSERT().
1834 If an error would be returned, then the function will also ASSERT().
1836 If an error is returned, then the Destination is unmodified.
1838 @param Source The pointer to a Null-terminated Unicode string.
1839 @param Destination The pointer to a Null-terminated ASCII string.
1840 @param DestMax The maximum number of Destination Ascii
1841 char, including terminating null char.
1843 @retval RETURN_SUCCESS String is converted.
1844 @retval RETURN_BUFFER_TOO_SMALL If DestMax is NOT greater than StrLen(Source).
1845 @retval RETURN_INVALID_PARAMETER If Destination is NULL.
1847 If PcdMaximumAsciiStringLength is not zero,
1848 and DestMax is greater than
1849 PcdMaximumAsciiStringLength.
1850 If PcdMaximumUnicodeStringLength is not zero,
1851 and DestMax is greater than
1852 PcdMaximumUnicodeStringLength.
1854 @retval RETURN_ACCESS_DENIED If Source and Destination overlap.
1859 UnicodeStrToAsciiStrS (
1860 IN CONST CHAR16
*Source
,
1861 OUT CHAR8
*Destination
,
1866 Convert not more than Length successive characters from a Null-terminated
1867 Unicode string to a Null-terminated Ascii string. If no null char is copied
1868 from Source, then Destination[Length] is always set to null.
1870 This function converts not more than Length successive characters from the
1871 Unicode string Source to the Ascii string Destination by copying the lower 8
1872 bits of each Unicode character. The function terminates the Ascii string
1873 Destination by appending a Null-terminator character at the end.
1875 The caller is responsible to make sure Destination points to a buffer with size
1876 equal or greater than ((StrLen (Source) + 1) * sizeof (CHAR8)) in bytes.
1878 If any Unicode characters in Source contain non-zero value in the upper 8
1879 bits, then ASSERT().
1880 If Source is not aligned on a 16-bit boundary, then ASSERT().
1881 If an error would be returned, then the function will also ASSERT().
1883 If an error is returned, then the Destination is unmodified.
1885 @param Source The pointer to a Null-terminated Unicode string.
1886 @param Length The maximum number of Unicode characters to
1888 @param Destination The pointer to a Null-terminated Ascii string.
1889 @param DestMax The maximum number of Destination Ascii
1890 char, including terminating null char.
1891 @param DestinationLength The number of Unicode characters converted.
1893 @retval RETURN_SUCCESS String is converted.
1894 @retval RETURN_INVALID_PARAMETER If Destination is NULL.
1896 If DestinationLength is NULL.
1897 If PcdMaximumAsciiStringLength is not zero,
1898 and Length or DestMax is greater than
1899 PcdMaximumAsciiStringLength.
1900 If PcdMaximumUnicodeStringLength is not
1901 zero, and Length or DestMax is greater than
1902 PcdMaximumUnicodeStringLength.
1904 @retval RETURN_BUFFER_TOO_SMALL If DestMax is NOT greater than
1905 MIN(StrLen(Source), Length).
1906 @retval RETURN_ACCESS_DENIED If Source and Destination overlap.
1911 UnicodeStrnToAsciiStrS (
1912 IN CONST CHAR16
*Source
,
1914 OUT CHAR8
*Destination
,
1916 OUT UINTN
*DestinationLength
1919 #ifndef DISABLE_NEW_DEPRECATED_INTERFACES
1922 [ATTENTION] This function is deprecated for security reason.
1924 Copies one Null-terminated ASCII string to another Null-terminated ASCII
1925 string and returns the new ASCII string.
1927 This function copies the contents of the ASCII string Source to the ASCII
1928 string Destination, and returns Destination. If Source and Destination
1929 overlap, then the results are undefined.
1931 If Destination is NULL, then ASSERT().
1932 If Source is NULL, then ASSERT().
1933 If Source and Destination overlap, then ASSERT().
1934 If PcdMaximumAsciiStringLength is not zero and Source contains more than
1935 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
1938 @param Destination The pointer to a Null-terminated ASCII string.
1939 @param Source The pointer to a Null-terminated ASCII string.
1947 OUT CHAR8
*Destination
,
1948 IN CONST CHAR8
*Source
1953 [ATTENTION] This function is deprecated for security reason.
1955 Copies up to a specified length one Null-terminated ASCII string to another
1956 Null-terminated ASCII string and returns the new ASCII string.
1958 This function copies the contents of the ASCII string Source to the ASCII
1959 string Destination, and returns Destination. At most, Length ASCII characters
1960 are copied from Source to Destination. If Length is 0, then Destination is
1961 returned unmodified. If Length is greater that the number of ASCII characters
1962 in Source, then Destination is padded with Null ASCII characters. If Source
1963 and Destination overlap, then the results are undefined.
1965 If Destination is NULL, then ASSERT().
1966 If Source is NULL, then ASSERT().
1967 If Source and Destination overlap, then ASSERT().
1968 If PcdMaximumAsciiStringLength is not zero, and Length is greater than
1969 PcdMaximumAsciiStringLength, then ASSERT().
1970 If PcdMaximumAsciiStringLength is not zero, and Source contains more than
1971 PcdMaximumAsciiStringLength ASCII characters, not including the Null-terminator,
1974 @param Destination The pointer to a Null-terminated ASCII string.
1975 @param Source The pointer to a Null-terminated ASCII string.
1976 @param Length The maximum number of ASCII characters to copy.
1984 OUT CHAR8
*Destination
,
1985 IN CONST CHAR8
*Source
,
1988 #endif // !defined (DISABLE_NEW_DEPRECATED_INTERFACES)
1991 Returns the length of a Null-terminated ASCII string.
1993 This function returns the number of ASCII characters in the Null-terminated
1994 ASCII string specified by String.
1996 If Length > 0 and Destination is NULL, then ASSERT().
1997 If Length > 0 and Source is NULL, then ASSERT().
1998 If PcdMaximumAsciiStringLength is not zero and String contains more than
1999 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
2002 @param String The pointer to a Null-terminated ASCII string.
2004 @return The length of String.
2010 IN CONST CHAR8
*String
2015 Returns the size of a Null-terminated ASCII string in bytes, including the
2018 This function returns the size, in bytes, of the Null-terminated ASCII string
2019 specified by String.
2021 If String is NULL, then ASSERT().
2022 If PcdMaximumAsciiStringLength is not zero and String contains more than
2023 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
2026 @param String The pointer to a Null-terminated ASCII string.
2028 @return The size of String.
2034 IN CONST CHAR8
*String
2039 Compares two Null-terminated ASCII strings, and returns the difference
2040 between the first mismatched ASCII characters.
2042 This function compares the Null-terminated ASCII string FirstString to the
2043 Null-terminated ASCII string SecondString. If FirstString is identical to
2044 SecondString, then 0 is returned. Otherwise, the value returned is the first
2045 mismatched ASCII character in SecondString subtracted from the first
2046 mismatched ASCII character in FirstString.
2048 If FirstString is NULL, then ASSERT().
2049 If SecondString is NULL, then ASSERT().
2050 If PcdMaximumAsciiStringLength is not zero and FirstString contains more than
2051 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
2053 If PcdMaximumAsciiStringLength is not zero and SecondString contains more
2054 than PcdMaximumAsciiStringLength ASCII characters not including the
2055 Null-terminator, then ASSERT().
2057 @param FirstString The pointer to a Null-terminated ASCII string.
2058 @param SecondString The pointer to a Null-terminated ASCII string.
2060 @retval ==0 FirstString is identical to SecondString.
2061 @retval !=0 FirstString is not identical to SecondString.
2067 IN CONST CHAR8
*FirstString
,
2068 IN CONST CHAR8
*SecondString
2073 Performs a case insensitive comparison of two Null-terminated ASCII strings,
2074 and returns the difference between the first mismatched ASCII characters.
2076 This function performs a case insensitive comparison of the Null-terminated
2077 ASCII string FirstString to the Null-terminated ASCII string SecondString. If
2078 FirstString is identical to SecondString, then 0 is returned. Otherwise, the
2079 value returned is the first mismatched lower case ASCII character in
2080 SecondString subtracted from the first mismatched lower case ASCII character
2083 If FirstString is NULL, then ASSERT().
2084 If SecondString is NULL, then ASSERT().
2085 If PcdMaximumAsciiStringLength is not zero and FirstString contains more than
2086 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
2088 If PcdMaximumAsciiStringLength is not zero and SecondString contains more
2089 than PcdMaximumAsciiStringLength ASCII characters not including the
2090 Null-terminator, then ASSERT().
2092 @param FirstString The pointer to a Null-terminated ASCII string.
2093 @param SecondString The pointer to a Null-terminated ASCII string.
2095 @retval ==0 FirstString is identical to SecondString using case insensitive
2097 @retval !=0 FirstString is not identical to SecondString using case
2098 insensitive comparisons.
2104 IN CONST CHAR8
*FirstString
,
2105 IN CONST CHAR8
*SecondString
2110 Compares two Null-terminated ASCII strings with maximum lengths, and returns
2111 the difference between the first mismatched ASCII characters.
2113 This function compares the Null-terminated ASCII string FirstString to the
2114 Null-terminated ASCII string SecondString. At most, Length ASCII characters
2115 will be compared. If Length is 0, then 0 is returned. If FirstString is
2116 identical to SecondString, then 0 is returned. Otherwise, the value returned
2117 is the first mismatched ASCII character in SecondString subtracted from the
2118 first mismatched ASCII character in FirstString.
2120 If Length > 0 and FirstString is NULL, then ASSERT().
2121 If Length > 0 and SecondString is NULL, then ASSERT().
2122 If PcdMaximumAsciiStringLength is not zero, and Length is greater than
2123 PcdMaximumAsciiStringLength, then ASSERT().
2124 If PcdMaximumAsciiStringLength is not zero, and FirstString contains more than
2125 PcdMaximumAsciiStringLength ASCII characters, not including the Null-terminator,
2127 If PcdMaximumAsciiStringLength is not zero, and SecondString contains more than
2128 PcdMaximumAsciiStringLength ASCII characters, not including the Null-terminator,
2131 @param FirstString The pointer to a Null-terminated ASCII string.
2132 @param SecondString The pointer to a Null-terminated ASCII string.
2133 @param Length The maximum number of ASCII characters for compare.
2135 @retval ==0 FirstString is identical to SecondString.
2136 @retval !=0 FirstString is not identical to SecondString.
2142 IN CONST CHAR8
*FirstString
,
2143 IN CONST CHAR8
*SecondString
,
2148 #ifndef DISABLE_NEW_DEPRECATED_INTERFACES
2151 [ATTENTION] This function is deprecated for security reason.
2153 Concatenates one Null-terminated ASCII string to another Null-terminated
2154 ASCII string, and returns the concatenated ASCII string.
2156 This function concatenates two Null-terminated ASCII strings. The contents of
2157 Null-terminated ASCII string Source are concatenated to the end of Null-
2158 terminated ASCII string Destination. The Null-terminated concatenated ASCII
2161 If Destination is NULL, then ASSERT().
2162 If Source is NULL, then ASSERT().
2163 If PcdMaximumAsciiStringLength is not zero and Destination contains more than
2164 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
2166 If PcdMaximumAsciiStringLength is not zero and Source contains more than
2167 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
2169 If PcdMaximumAsciiStringLength is not zero and concatenating Destination and
2170 Source results in a ASCII string with more than PcdMaximumAsciiStringLength
2171 ASCII characters, then ASSERT().
2173 @param Destination The pointer to a Null-terminated ASCII string.
2174 @param Source The pointer to a Null-terminated ASCII string.
2182 IN OUT CHAR8
*Destination
,
2183 IN CONST CHAR8
*Source
2188 [ATTENTION] This function is deprecated for security reason.
2190 Concatenates up to a specified length one Null-terminated ASCII string to
2191 the end of another Null-terminated ASCII string, and returns the
2192 concatenated ASCII string.
2194 This function concatenates two Null-terminated ASCII strings. The contents
2195 of Null-terminated ASCII string Source are concatenated to the end of Null-
2196 terminated ASCII string Destination, and Destination is returned. At most,
2197 Length ASCII characters are concatenated from Source to the end of
2198 Destination, and Destination is always Null-terminated. If Length is 0, then
2199 Destination is returned unmodified. If Source and Destination overlap, then
2200 the results are undefined.
2202 If Length > 0 and Destination is NULL, then ASSERT().
2203 If Length > 0 and Source is NULL, then ASSERT().
2204 If Source and Destination overlap, then ASSERT().
2205 If PcdMaximumAsciiStringLength is not zero, and Length is greater than
2206 PcdMaximumAsciiStringLength, then ASSERT().
2207 If PcdMaximumAsciiStringLength is not zero, and Destination contains more than
2208 PcdMaximumAsciiStringLength ASCII characters, not including the Null-terminator,
2210 If PcdMaximumAsciiStringLength is not zero, and Source contains more than
2211 PcdMaximumAsciiStringLength ASCII characters, not including the Null-terminator,
2213 If PcdMaximumAsciiStringLength is not zero, and concatenating Destination and
2214 Source results in a ASCII string with more than PcdMaximumAsciiStringLength
2215 ASCII characters, not including the Null-terminator, then ASSERT().
2217 @param Destination The pointer to a Null-terminated ASCII string.
2218 @param Source The pointer to a Null-terminated ASCII string.
2219 @param Length The maximum number of ASCII characters to concatenate from
2228 IN OUT CHAR8
*Destination
,
2229 IN CONST CHAR8
*Source
,
2232 #endif // !defined (DISABLE_NEW_DEPRECATED_INTERFACES)
2235 Returns the first occurrence of a Null-terminated ASCII sub-string
2236 in a Null-terminated ASCII string.
2238 This function scans the contents of the ASCII string specified by String
2239 and returns the first occurrence of SearchString. If SearchString is not
2240 found in String, then NULL is returned. If the length of SearchString is zero,
2241 then String is returned.
2243 If String is NULL, then ASSERT().
2244 If SearchString is NULL, then ASSERT().
2246 If PcdMaximumAsciiStringLength is not zero, and SearchString or
2247 String contains more than PcdMaximumAsciiStringLength Unicode characters
2248 not including the Null-terminator, then ASSERT().
2250 @param String The pointer to a Null-terminated ASCII string.
2251 @param SearchString The pointer to a Null-terminated ASCII string to search for.
2253 @retval NULL If the SearchString does not appear in String.
2254 @retval others If there is a match return the first occurrence of SearchingString.
2255 If the length of SearchString is zero,return String.
2261 IN CONST CHAR8
*String
,
2262 IN CONST CHAR8
*SearchString
2267 Convert a Null-terminated ASCII decimal string to a value of type
2270 This function returns a value of type UINTN by interpreting the contents
2271 of the ASCII string String as a decimal number. The format of the input
2272 ASCII string String is:
2274 [spaces] [decimal digits].
2276 The valid decimal digit character is in the range [0-9]. The function will
2277 ignore the pad space, which includes spaces or tab characters, before the digits.
2278 The running zero in the beginning of [decimal digits] will be ignored. Then, the
2279 function stops at the first character that is a not a valid decimal character or
2280 Null-terminator, whichever on comes first.
2282 If String has only pad spaces, then 0 is returned.
2283 If String has no pad spaces or valid decimal digits, then 0 is returned.
2284 If the number represented by String overflows according to the range defined by
2285 UINTN, then MAX_UINTN is returned.
2286 If String is NULL, then ASSERT().
2287 If PcdMaximumAsciiStringLength is not zero, and String contains more than
2288 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
2291 @param String The pointer to a Null-terminated ASCII string.
2293 @retval The value translated from String.
2298 AsciiStrDecimalToUintn (
2299 IN CONST CHAR8
*String
2304 Convert a Null-terminated ASCII decimal string to a value of type
2307 This function returns a value of type UINT64 by interpreting the contents
2308 of the ASCII string String as a decimal number. The format of the input
2309 ASCII string String is:
2311 [spaces] [decimal digits].
2313 The valid decimal digit character is in the range [0-9]. The function will
2314 ignore the pad space, which includes spaces or tab characters, before the digits.
2315 The running zero in the beginning of [decimal digits] will be ignored. Then, the
2316 function stops at the first character that is a not a valid decimal character or
2317 Null-terminator, whichever on comes first.
2319 If String has only pad spaces, then 0 is returned.
2320 If String has no pad spaces or valid decimal digits, then 0 is returned.
2321 If the number represented by String overflows according to the range defined by
2322 UINT64, then MAX_UINT64 is returned.
2323 If String is NULL, then ASSERT().
2324 If PcdMaximumAsciiStringLength is not zero, and String contains more than
2325 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
2328 @param String The pointer to a Null-terminated ASCII string.
2330 @retval Value translated from String.
2335 AsciiStrDecimalToUint64 (
2336 IN CONST CHAR8
*String
2341 Convert a Null-terminated ASCII hexadecimal string to a value of type UINTN.
2343 This function returns a value of type UINTN by interpreting the contents of
2344 the ASCII string String as a hexadecimal number. The format of the input ASCII
2347 [spaces][zeros][x][hexadecimal digits].
2349 The valid hexadecimal digit character is in the range [0-9], [a-f] and [A-F].
2350 The prefix "0x" is optional. Both "x" and "X" is allowed in "0x" prefix. If "x"
2351 appears in the input string, it must be prefixed with at least one 0. The function
2352 will ignore the pad space, which includes spaces or tab characters, before [zeros],
2353 [x] or [hexadecimal digits]. The running zero before [x] or [hexadecimal digits]
2354 will be ignored. Then, the decoding starts after [x] or the first valid hexadecimal
2355 digit. Then, the function stops at the first character that is a not a valid
2356 hexadecimal character or Null-terminator, whichever on comes first.
2358 If String has only pad spaces, then 0 is returned.
2359 If String has no leading pad spaces, leading zeros or valid hexadecimal digits, then
2362 If the number represented by String overflows according to the range defined by UINTN,
2363 then MAX_UINTN is returned.
2364 If String is NULL, then ASSERT().
2365 If PcdMaximumAsciiStringLength is not zero,
2366 and String contains more than PcdMaximumAsciiStringLength ASCII characters not including
2367 the Null-terminator, then ASSERT().
2369 @param String The pointer to a Null-terminated ASCII string.
2371 @retval Value translated from String.
2376 AsciiStrHexToUintn (
2377 IN CONST CHAR8
*String
2382 Convert a Null-terminated ASCII hexadecimal string to a value of type UINT64.
2384 This function returns a value of type UINT64 by interpreting the contents of
2385 the ASCII string String as a hexadecimal number. The format of the input ASCII
2388 [spaces][zeros][x][hexadecimal digits].
2390 The valid hexadecimal digit character is in the range [0-9], [a-f] and [A-F].
2391 The prefix "0x" is optional. Both "x" and "X" is allowed in "0x" prefix. If "x"
2392 appears in the input string, it must be prefixed with at least one 0. The function
2393 will ignore the pad space, which includes spaces or tab characters, before [zeros],
2394 [x] or [hexadecimal digits]. The running zero before [x] or [hexadecimal digits]
2395 will be ignored. Then, the decoding starts after [x] or the first valid hexadecimal
2396 digit. Then, the function stops at the first character that is a not a valid
2397 hexadecimal character or Null-terminator, whichever on comes first.
2399 If String has only pad spaces, then 0 is returned.
2400 If String has no leading pad spaces, leading zeros or valid hexadecimal digits, then
2403 If the number represented by String overflows according to the range defined by UINT64,
2404 then MAX_UINT64 is returned.
2405 If String is NULL, then ASSERT().
2406 If PcdMaximumAsciiStringLength is not zero,
2407 and String contains more than PcdMaximumAsciiStringLength ASCII characters not including
2408 the Null-terminator, then ASSERT().
2410 @param String The pointer to a Null-terminated ASCII string.
2412 @retval Value translated from String.
2417 AsciiStrHexToUint64 (
2418 IN CONST CHAR8
*String
2422 Convert a Null-terminated ASCII string to IPv6 address and prefix length.
2424 This function outputs a value of type IPv6_ADDRESS and may output a value
2425 of type UINT8 by interpreting the contents of the ASCII string specified
2426 by String. The format of the input ASCII string String is as follows:
2430 X contains one to four hexadecimal digit characters in the range [0-9], [a-f] and
2431 [A-F]. X is converted to a value of type UINT16, whose low byte is stored in low
2432 memory address and high byte is stored in high memory address. P contains decimal
2433 digit characters in the range [0-9]. The running zero in the beginning of P will
2434 be ignored. /P is optional.
2436 When /P is not in the String, the function stops at the first character that is
2437 not a valid hexadecimal digit character after eight X's are converted.
2439 When /P is in the String, the function stops at the first character that is not
2440 a valid decimal digit character after P is converted.
2442 "::" can be used to compress one or more groups of X when X contains only 0.
2443 The "::" can only appear once in the String.
2445 If String is NULL, then ASSERT().
2447 If Address is NULL, then ASSERT().
2449 If EndPointer is not NULL and Address is translated from String, a pointer
2450 to the character that stopped the scan is stored at the location pointed to
2453 @param String Pointer to a Null-terminated ASCII string.
2454 @param EndPointer Pointer to character that stops scan.
2455 @param Address Pointer to the converted IPv6 address.
2456 @param PrefixLength Pointer to the converted IPv6 address prefix
2457 length. MAX_UINT8 is returned when /P is
2460 @retval RETURN_SUCCESS Address is translated from String.
2461 @retval RETURN_INVALID_PARAMETER If String is NULL.
2463 @retval RETURN_UNSUPPORTED If X contains more than four hexadecimal
2465 If String contains "::" and number of X
2467 If P starts with character that is not a
2468 valid decimal digit character.
2469 If the decimal number converted from P
2475 AsciiStrToIpv6Address (
2476 IN CONST CHAR8
*String
,
2477 OUT CHAR8
**EndPointer
, OPTIONAL
2478 OUT IPv6_ADDRESS
*Address
,
2479 OUT UINT8
*PrefixLength OPTIONAL
2483 Convert a Null-terminated ASCII string to IPv4 address and prefix length.
2485 This function outputs a value of type IPv4_ADDRESS and may output a value
2486 of type UINT8 by interpreting the contents of the ASCII string specified
2487 by String. The format of the input ASCII string String is as follows:
2491 D and P are decimal digit characters in the range [0-9]. The running zero in
2492 the beginning of D and P will be ignored. /P is optional.
2494 When /P is not in the String, the function stops at the first character that is
2495 not a valid decimal digit character after four D's are converted.
2497 When /P is in the String, the function stops at the first character that is not
2498 a valid decimal digit character after P is converted.
2500 If String is NULL, then ASSERT().
2502 If Address is NULL, then ASSERT().
2504 If EndPointer is not NULL and Address is translated from String, a pointer
2505 to the character that stopped the scan is stored at the location pointed to
2508 @param String Pointer to a Null-terminated ASCII string.
2509 @param EndPointer Pointer to character that stops scan.
2510 @param Address Pointer to the converted IPv4 address.
2511 @param PrefixLength Pointer to the converted IPv4 address prefix
2512 length. MAX_UINT8 is returned when /P is
2515 @retval RETURN_SUCCESS Address is translated from String.
2516 @retval RETURN_INVALID_PARAMETER If String is NULL.
2518 @retval RETURN_UNSUPPORTED If String is not in the correct format.
2519 If any decimal number converted from D
2521 If the decimal number converted from P
2527 AsciiStrToIpv4Address (
2528 IN CONST CHAR8
*String
,
2529 OUT CHAR8
**EndPointer
, OPTIONAL
2530 OUT IPv4_ADDRESS
*Address
,
2531 OUT UINT8
*PrefixLength OPTIONAL
2535 Convert a Null-terminated ASCII GUID string to a value of type
2538 This function outputs a GUID value by interpreting the contents of
2539 the ASCII string specified by String. The format of the input
2540 ASCII string String consists of 36 characters, as follows:
2542 aabbccdd-eeff-gghh-iijj-kkllmmnnoopp
2544 The pairs aa - pp are two characters in the range [0-9], [a-f] and
2545 [A-F], with each pair representing a single byte hexadecimal value.
2547 The mapping between String and the EFI_GUID structure is as follows:
2565 If String is NULL, then ASSERT().
2566 If Guid is NULL, then ASSERT().
2568 @param String Pointer to a Null-terminated ASCII string.
2569 @param Guid Pointer to the converted GUID.
2571 @retval RETURN_SUCCESS Guid is translated from String.
2572 @retval RETURN_INVALID_PARAMETER If String is NULL.
2574 @retval RETURN_UNSUPPORTED If String is not as the above format.
2580 IN CONST CHAR8
*String
,
2585 Convert a Null-terminated ASCII hexadecimal string to a byte array.
2587 This function outputs a byte array by interpreting the contents of
2588 the ASCII string specified by String in hexadecimal format. The format of
2589 the input ASCII string String is:
2593 X is a hexadecimal digit character in the range [0-9], [a-f] and [A-F].
2594 The function decodes every two hexadecimal digit characters as one byte. The
2595 decoding stops after Length of characters and outputs Buffer containing
2598 If String is NULL, then ASSERT().
2600 If Buffer is NULL, then ASSERT().
2602 If Length is not multiple of 2, then ASSERT().
2604 If PcdMaximumAsciiStringLength is not zero and Length is greater than
2605 PcdMaximumAsciiStringLength, then ASSERT().
2607 If MaxBufferSize is less than (Length / 2), then ASSERT().
2609 @param String Pointer to a Null-terminated ASCII string.
2610 @param Length The number of ASCII characters to decode.
2611 @param Buffer Pointer to the converted bytes array.
2612 @param MaxBufferSize The maximum size of Buffer.
2614 @retval RETURN_SUCCESS Buffer is translated from String.
2615 @retval RETURN_INVALID_PARAMETER If String is NULL.
2617 If Length is not multiple of 2.
2618 If PcdMaximumAsciiStringLength is not zero,
2619 and Length is greater than
2620 PcdMaximumAsciiStringLength.
2621 @retval RETURN_UNSUPPORTED If Length of characters from String contain
2622 a character that is not valid hexadecimal
2623 digit characters, or a Null-terminator.
2624 @retval RETURN_BUFFER_TOO_SMALL If MaxBufferSize is less than (Length / 2).
2628 AsciiStrHexToBytes (
2629 IN CONST CHAR8
*String
,
2632 IN UINTN MaxBufferSize
2635 #ifndef DISABLE_NEW_DEPRECATED_INTERFACES
2638 [ATTENTION] This function is deprecated for security reason.
2640 Convert one Null-terminated ASCII string to a Null-terminated
2641 Unicode string and returns the Unicode string.
2643 This function converts the contents of the ASCII string Source to the Unicode
2644 string Destination, and returns Destination. The function terminates the
2645 Unicode string Destination by appending a Null-terminator character at the end.
2646 The caller is responsible to make sure Destination points to a buffer with size
2647 equal or greater than ((AsciiStrLen (Source) + 1) * sizeof (CHAR16)) in bytes.
2649 If Destination is NULL, then ASSERT().
2650 If Destination is not aligned on a 16-bit boundary, then ASSERT().
2651 If Source is NULL, then ASSERT().
2652 If Source and Destination overlap, then ASSERT().
2653 If PcdMaximumAsciiStringLength is not zero, and Source contains more than
2654 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
2656 If PcdMaximumUnicodeStringLength is not zero, and Source contains more than
2657 PcdMaximumUnicodeStringLength ASCII characters not including the
2658 Null-terminator, then ASSERT().
2660 @param Source The pointer to a Null-terminated ASCII string.
2661 @param Destination The pointer to a Null-terminated Unicode string.
2663 @return Destination.
2668 AsciiStrToUnicodeStr (
2669 IN CONST CHAR8
*Source
,
2670 OUT CHAR16
*Destination
2673 #endif // !defined (DISABLE_NEW_DEPRECATED_INTERFACES)
2676 Convert one Null-terminated ASCII string to a Null-terminated
2679 This function is similar to StrCpyS.
2681 This function converts the contents of the ASCII string Source to the Unicode
2682 string Destination. The function terminates the Unicode string Destination by
2683 appending a Null-terminator character at the end.
2685 The caller is responsible to make sure Destination points to a buffer with size
2686 equal or greater than ((AsciiStrLen (Source) + 1) * sizeof (CHAR16)) in bytes.
2688 If Destination is not aligned on a 16-bit boundary, then ASSERT().
2689 If an error would be returned, then the function will also ASSERT().
2691 If an error is returned, then the Destination is unmodified.
2693 @param Source The pointer to a Null-terminated ASCII string.
2694 @param Destination The pointer to a Null-terminated Unicode string.
2695 @param DestMax The maximum number of Destination Unicode
2696 char, including terminating null char.
2698 @retval RETURN_SUCCESS String is converted.
2699 @retval RETURN_BUFFER_TOO_SMALL If DestMax is NOT greater than StrLen(Source).
2700 @retval RETURN_INVALID_PARAMETER If Destination is NULL.
2702 If PcdMaximumUnicodeStringLength is not zero,
2703 and DestMax is greater than
2704 PcdMaximumUnicodeStringLength.
2705 If PcdMaximumAsciiStringLength is not zero,
2706 and DestMax is greater than
2707 PcdMaximumAsciiStringLength.
2709 @retval RETURN_ACCESS_DENIED If Source and Destination overlap.
2714 AsciiStrToUnicodeStrS (
2715 IN CONST CHAR8
*Source
,
2716 OUT CHAR16
*Destination
,
2721 Convert not more than Length successive characters from a Null-terminated
2722 Ascii string to a Null-terminated Unicode string. If no null char is copied
2723 from Source, then Destination[Length] is always set to null.
2725 This function converts not more than Length successive characters from the
2726 Ascii string Source to the Unicode string Destination. The function
2727 terminates the Unicode string Destination by appending a Null-terminator
2728 character at the end.
2730 The caller is responsible to make sure Destination points to a buffer with
2731 size not smaller than
2732 ((MIN(AsciiStrLen(Source), Length) + 1) * sizeof (CHAR8)) in bytes.
2734 If Destination is not aligned on a 16-bit boundary, then ASSERT().
2735 If an error would be returned, then the function will also ASSERT().
2737 If an error is returned, then Destination and DestinationLength are
2740 @param Source The pointer to a Null-terminated Ascii string.
2741 @param Length The maximum number of Ascii characters to convert.
2742 @param Destination The pointer to a Null-terminated Unicode string.
2743 @param DestMax The maximum number of Destination Unicode char,
2744 including terminating null char.
2745 @param DestinationLength The number of Ascii characters converted.
2747 @retval RETURN_SUCCESS String is converted.
2748 @retval RETURN_INVALID_PARAMETER If Destination is NULL.
2750 If DestinationLength is NULL.
2751 If PcdMaximumUnicodeStringLength is not
2752 zero, and Length or DestMax is greater than
2753 PcdMaximumUnicodeStringLength.
2754 If PcdMaximumAsciiStringLength is not zero,
2755 and Length or DestMax is greater than
2756 PcdMaximumAsciiStringLength.
2758 @retval RETURN_BUFFER_TOO_SMALL If DestMax is NOT greater than
2759 MIN(AsciiStrLen(Source), Length).
2760 @retval RETURN_ACCESS_DENIED If Source and Destination overlap.
2765 AsciiStrnToUnicodeStrS (
2766 IN CONST CHAR8
*Source
,
2768 OUT CHAR16
*Destination
,
2770 OUT UINTN
*DestinationLength
2774 Converts an 8-bit value to an 8-bit BCD value.
2776 Converts the 8-bit value specified by Value to BCD. The BCD value is
2779 If Value >= 100, then ASSERT().
2781 @param Value The 8-bit value to convert to BCD. Range 0..99.
2783 @return The BCD value.
2794 Converts an 8-bit BCD value to an 8-bit value.
2796 Converts the 8-bit BCD value specified by Value to an 8-bit value. The 8-bit
2799 If Value >= 0xA0, then ASSERT().
2800 If (Value & 0x0F) >= 0x0A, then ASSERT().
2802 @param Value The 8-bit BCD value to convert to an 8-bit value.
2804 @return The 8-bit value is returned.
2814 // File Path Manipulation Functions
2818 Removes the last directory or file entry in a path.
2820 @param[in, out] Path The pointer to the path to modify.
2822 @retval FALSE Nothing was found to remove.
2823 @retval TRUE A directory or file was removed.
2832 Function to clean up paths.
2833 - Single periods in the path are removed.
2834 - Double periods in the path are removed along with a single parent directory.
2835 - Forward slashes L'/' are converted to backward slashes L'\'.
2837 This will be done inline and the existing buffer may be larger than required
2840 @param[in] Path The pointer to the string containing the path.
2842 @return Returns Path, otherwise returns NULL to indicate that an error has occurred.
2846 PathCleanUpDirectories(
2851 // Linked List Functions and Macros
2855 Initializes the head node of a doubly linked list that is declared as a
2856 global variable in a module.
2858 Initializes the forward and backward links of a new linked list. After
2859 initializing a linked list with this macro, the other linked list functions
2860 may be used to add and remove nodes from the linked list. This macro results
2861 in smaller executables by initializing the linked list in the data section,
2862 instead if calling the InitializeListHead() function to perform the
2863 equivalent operation.
2865 @param ListHead The head note of a list to initialize.
2868 #define INITIALIZE_LIST_HEAD_VARIABLE(ListHead) {&(ListHead), &(ListHead)}
2872 Checks whether FirstEntry and SecondEntry are part of the same doubly-linked
2875 If FirstEntry is NULL, then ASSERT().
2876 If FirstEntry->ForwardLink is NULL, then ASSERT().
2877 If FirstEntry->BackLink is NULL, then ASSERT().
2878 If SecondEntry is NULL, then ASSERT();
2879 If PcdMaximumLinkedListLength is not zero, and List contains more than
2880 PcdMaximumLinkedListLength nodes, then ASSERT().
2882 @param FirstEntry A pointer to a node in a linked list.
2883 @param SecondEntry A pointer to the node to locate.
2885 @retval TRUE SecondEntry is in the same doubly-linked list as FirstEntry.
2886 @retval FALSE SecondEntry isn't in the same doubly-linked list as FirstEntry,
2887 or FirstEntry is invalid.
2893 IN CONST LIST_ENTRY
*FirstEntry
,
2894 IN CONST LIST_ENTRY
*SecondEntry
2899 Initializes the head node of a doubly linked list, and returns the pointer to
2900 the head node of the doubly linked list.
2902 Initializes the forward and backward links of a new linked list. After
2903 initializing a linked list with this function, the other linked list
2904 functions may be used to add and remove nodes from the linked list. It is up
2905 to the caller of this function to allocate the memory for ListHead.
2907 If ListHead is NULL, then ASSERT().
2909 @param ListHead A pointer to the head node of a new doubly linked list.
2916 InitializeListHead (
2917 IN OUT LIST_ENTRY
*ListHead
2922 Adds a node to the beginning of a doubly linked list, and returns the pointer
2923 to the head node of the doubly linked list.
2925 Adds the node Entry at the beginning of the doubly linked list denoted by
2926 ListHead, and returns ListHead.
2928 If ListHead is NULL, then ASSERT().
2929 If Entry is NULL, then ASSERT().
2930 If ListHead was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or
2931 InitializeListHead(), then ASSERT().
2932 If PcdMaximumLinkedListLength is not zero, and prior to insertion the number
2933 of nodes in ListHead, including the ListHead node, is greater than or
2934 equal to PcdMaximumLinkedListLength, then ASSERT().
2936 @param ListHead A pointer to the head node of a doubly linked list.
2937 @param Entry A pointer to a node that is to be inserted at the beginning
2938 of a doubly linked list.
2946 IN OUT LIST_ENTRY
*ListHead
,
2947 IN OUT LIST_ENTRY
*Entry
2952 Adds a node to the end of a doubly linked list, and returns the pointer to
2953 the head node of the doubly linked list.
2955 Adds the node Entry to the end of the doubly linked list denoted by ListHead,
2956 and returns ListHead.
2958 If ListHead is NULL, then ASSERT().
2959 If Entry is NULL, then ASSERT().
2960 If ListHead was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or
2961 InitializeListHead(), then ASSERT().
2962 If PcdMaximumLinkedListLength is not zero, and prior to insertion the number
2963 of nodes in ListHead, including the ListHead node, is greater than or
2964 equal to PcdMaximumLinkedListLength, then ASSERT().
2966 @param ListHead A pointer to the head node of a doubly linked list.
2967 @param Entry A pointer to a node that is to be added at the end of the
2976 IN OUT LIST_ENTRY
*ListHead
,
2977 IN OUT LIST_ENTRY
*Entry
2982 Retrieves the first node of a doubly linked list.
2984 Returns the first node of a doubly linked list. List must have been
2985 initialized with INTIALIZE_LIST_HEAD_VARIABLE() or InitializeListHead().
2986 If List is empty, then List is returned.
2988 If List is NULL, then ASSERT().
2989 If List was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or
2990 InitializeListHead(), then ASSERT().
2991 If PcdMaximumLinkedListLength is not zero, and the number of nodes
2992 in List, including the List node, is greater than or equal to
2993 PcdMaximumLinkedListLength, then ASSERT().
2995 @param List A pointer to the head node of a doubly linked list.
2997 @return The first node of a doubly linked list.
2998 @retval List The list is empty.
3004 IN CONST LIST_ENTRY
*List
3009 Retrieves the next node of a doubly linked list.
3011 Returns the node of a doubly linked list that follows Node.
3012 List must have been initialized with INTIALIZE_LIST_HEAD_VARIABLE()
3013 or InitializeListHead(). If List is empty, then List is returned.
3015 If List is NULL, then ASSERT().
3016 If Node is NULL, then ASSERT().
3017 If List was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or
3018 InitializeListHead(), then ASSERT().
3019 If PcdMaximumLinkedListLength is not zero, and List contains more than
3020 PcdMaximumLinkedListLength nodes, then ASSERT().
3021 If PcdVerifyNodeInList is TRUE and Node is not a node in List, then ASSERT().
3023 @param List A pointer to the head node of a doubly linked list.
3024 @param Node A pointer to a node in the doubly linked list.
3026 @return The pointer to the next node if one exists. Otherwise List is returned.
3032 IN CONST LIST_ENTRY
*List
,
3033 IN CONST LIST_ENTRY
*Node
3038 Retrieves the previous node of a doubly linked list.
3040 Returns the node of a doubly linked list that precedes Node.
3041 List must have been initialized with INTIALIZE_LIST_HEAD_VARIABLE()
3042 or InitializeListHead(). If List is empty, then List is returned.
3044 If List is NULL, then ASSERT().
3045 If Node is NULL, then ASSERT().
3046 If List was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or
3047 InitializeListHead(), then ASSERT().
3048 If PcdMaximumLinkedListLength is not zero, and List contains more than
3049 PcdMaximumLinkedListLength nodes, then ASSERT().
3050 If PcdVerifyNodeInList is TRUE and Node is not a node in List, then ASSERT().
3052 @param List A pointer to the head node of a doubly linked list.
3053 @param Node A pointer to a node in the doubly linked list.
3055 @return The pointer to the previous node if one exists. Otherwise List is returned.
3061 IN CONST LIST_ENTRY
*List
,
3062 IN CONST LIST_ENTRY
*Node
3067 Checks to see if a doubly linked list is empty or not.
3069 Checks to see if the doubly linked list is empty. If the linked list contains
3070 zero nodes, this function returns TRUE. Otherwise, it returns FALSE.
3072 If ListHead is NULL, then ASSERT().
3073 If ListHead was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or
3074 InitializeListHead(), then ASSERT().
3075 If PcdMaximumLinkedListLength is not zero, and the number of nodes
3076 in List, including the List node, is greater than or equal to
3077 PcdMaximumLinkedListLength, then ASSERT().
3079 @param ListHead A pointer to the head node of a doubly linked list.
3081 @retval TRUE The linked list is empty.
3082 @retval FALSE The linked list is not empty.
3088 IN CONST LIST_ENTRY
*ListHead
3093 Determines if a node in a doubly linked list is the head node of a the same
3094 doubly linked list. This function is typically used to terminate a loop that
3095 traverses all the nodes in a doubly linked list starting with the head node.
3097 Returns TRUE if Node is equal to List. Returns FALSE if Node is one of the
3098 nodes in the doubly linked list specified by List. List must have been
3099 initialized with INTIALIZE_LIST_HEAD_VARIABLE() or InitializeListHead().
3101 If List is NULL, then ASSERT().
3102 If Node is NULL, then ASSERT().
3103 If List was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or InitializeListHead(),
3105 If PcdMaximumLinkedListLength is not zero, and the number of nodes
3106 in List, including the List node, is greater than or equal to
3107 PcdMaximumLinkedListLength, then ASSERT().
3108 If PcdVerifyNodeInList is TRUE and Node is not a node in List the and Node is not equal
3109 to List, then ASSERT().
3111 @param List A pointer to the head node of a doubly linked list.
3112 @param Node A pointer to a node in the doubly linked list.
3114 @retval TRUE Node is the head of the doubly-linked list pointed by List.
3115 @retval FALSE Node is not the head of the doubly-linked list pointed by List.
3121 IN CONST LIST_ENTRY
*List
,
3122 IN CONST LIST_ENTRY
*Node
3127 Determines if a node the last node in a doubly linked list.
3129 Returns TRUE if Node is the last node in the doubly linked list specified by
3130 List. Otherwise, FALSE is returned. List must have been initialized with
3131 INTIALIZE_LIST_HEAD_VARIABLE() or InitializeListHead().
3133 If List is NULL, then ASSERT().
3134 If Node is NULL, then ASSERT().
3135 If List was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or
3136 InitializeListHead(), then ASSERT().
3137 If PcdMaximumLinkedListLength is not zero, and the number of nodes
3138 in List, including the List node, is greater than or equal to
3139 PcdMaximumLinkedListLength, then ASSERT().
3140 If PcdVerifyNodeInList is TRUE and Node is not a node in List, then ASSERT().
3142 @param List A pointer to the head node of a doubly linked list.
3143 @param Node A pointer to a node in the doubly linked list.
3145 @retval TRUE Node is the last node in the linked list.
3146 @retval FALSE Node is not the last node in the linked list.
3152 IN CONST LIST_ENTRY
*List
,
3153 IN CONST LIST_ENTRY
*Node
3158 Swaps the location of two nodes in a doubly linked list, and returns the
3159 first node after the swap.
3161 If FirstEntry is identical to SecondEntry, then SecondEntry is returned.
3162 Otherwise, the location of the FirstEntry node is swapped with the location
3163 of the SecondEntry node in a doubly linked list. SecondEntry must be in the
3164 same double linked list as FirstEntry and that double linked list must have
3165 been initialized with INTIALIZE_LIST_HEAD_VARIABLE() or InitializeListHead().
3166 SecondEntry is returned after the nodes are swapped.
3168 If FirstEntry is NULL, then ASSERT().
3169 If SecondEntry is NULL, then ASSERT().
3170 If PcdVerifyNodeInList is TRUE and SecondEntry and FirstEntry are not in the
3171 same linked list, then ASSERT().
3172 If PcdMaximumLinkedListLength is not zero, and the number of nodes in the
3173 linked list containing the FirstEntry and SecondEntry nodes, including
3174 the FirstEntry and SecondEntry nodes, is greater than or equal to
3175 PcdMaximumLinkedListLength, then ASSERT().
3177 @param FirstEntry A pointer to a node in a linked list.
3178 @param SecondEntry A pointer to another node in the same linked list.
3180 @return SecondEntry.
3186 IN OUT LIST_ENTRY
*FirstEntry
,
3187 IN OUT LIST_ENTRY
*SecondEntry
3192 Removes a node from a doubly linked list, and returns the node that follows
3195 Removes the node Entry from a doubly linked list. It is up to the caller of
3196 this function to release the memory used by this node if that is required. On
3197 exit, the node following Entry in the doubly linked list is returned. If
3198 Entry is the only node in the linked list, then the head node of the linked
3201 If Entry is NULL, then ASSERT().
3202 If Entry is the head node of an empty list, then ASSERT().
3203 If PcdMaximumLinkedListLength is not zero, and the number of nodes in the
3204 linked list containing Entry, including the Entry node, is greater than
3205 or equal to PcdMaximumLinkedListLength, then ASSERT().
3207 @param Entry A pointer to a node in a linked list.
3215 IN CONST LIST_ENTRY
*Entry
3223 Shifts a 64-bit integer left between 0 and 63 bits. The low bits are filled
3224 with zeros. The shifted value is returned.
3226 This function shifts the 64-bit value Operand to the left by Count bits. The
3227 low Count bits are set to zero. The shifted value is returned.
3229 If Count is greater than 63, then ASSERT().
3231 @param Operand The 64-bit operand to shift left.
3232 @param Count The number of bits to shift left.
3234 @return Operand << Count.
3246 Shifts a 64-bit integer right between 0 and 63 bits. This high bits are
3247 filled with zeros. The shifted value is returned.
3249 This function shifts the 64-bit value Operand to the right by Count bits. The
3250 high Count bits are set to zero. The shifted value is returned.
3252 If Count is greater than 63, then ASSERT().
3254 @param Operand The 64-bit operand to shift right.
3255 @param Count The number of bits to shift right.
3257 @return Operand >> Count
3269 Shifts a 64-bit integer right between 0 and 63 bits. The high bits are filled
3270 with original integer's bit 63. The shifted value is returned.
3272 This function shifts the 64-bit value Operand to the right by Count bits. The
3273 high Count bits are set to bit 63 of Operand. The shifted value is returned.
3275 If Count is greater than 63, then ASSERT().
3277 @param Operand The 64-bit operand to shift right.
3278 @param Count The number of bits to shift right.
3280 @return Operand >> Count
3292 Rotates a 32-bit integer left between 0 and 31 bits, filling the low bits
3293 with the high bits that were rotated.
3295 This function rotates the 32-bit value Operand to the left by Count bits. The
3296 low Count bits are fill with the high Count bits of Operand. The rotated
3299 If Count is greater than 31, then ASSERT().
3301 @param Operand The 32-bit operand to rotate left.
3302 @param Count The number of bits to rotate left.
3304 @return Operand << Count
3316 Rotates a 32-bit integer right between 0 and 31 bits, filling the high bits
3317 with the low bits that were rotated.
3319 This function rotates the 32-bit value Operand to the right by Count bits.
3320 The high Count bits are fill with the low Count bits of Operand. The rotated
3323 If Count is greater than 31, then ASSERT().
3325 @param Operand The 32-bit operand to rotate right.
3326 @param Count The number of bits to rotate right.
3328 @return Operand >> Count
3340 Rotates a 64-bit integer left between 0 and 63 bits, filling the low bits
3341 with the high bits that were rotated.
3343 This function rotates the 64-bit value Operand to the left by Count bits. The
3344 low Count bits are fill with the high Count bits of Operand. The rotated
3347 If Count is greater than 63, then ASSERT().
3349 @param Operand The 64-bit operand to rotate left.
3350 @param Count The number of bits to rotate left.
3352 @return Operand << Count
3364 Rotates a 64-bit integer right between 0 and 63 bits, filling the high bits
3365 with the high low bits that were rotated.
3367 This function rotates the 64-bit value Operand to the right by Count bits.
3368 The high Count bits are fill with the low Count bits of Operand. The rotated
3371 If Count is greater than 63, then ASSERT().
3373 @param Operand The 64-bit operand to rotate right.
3374 @param Count The number of bits to rotate right.
3376 @return Operand >> Count
3388 Returns the bit position of the lowest bit set in a 32-bit value.
3390 This function computes the bit position of the lowest bit set in the 32-bit
3391 value specified by Operand. If Operand is zero, then -1 is returned.
3392 Otherwise, a value between 0 and 31 is returned.
3394 @param Operand The 32-bit operand to evaluate.
3396 @retval 0..31 The lowest bit set in Operand was found.
3397 @retval -1 Operand is zero.
3408 Returns the bit position of the lowest bit set in a 64-bit value.
3410 This function computes the bit position of the lowest bit set in the 64-bit
3411 value specified by Operand. If Operand is zero, then -1 is returned.
3412 Otherwise, a value between 0 and 63 is returned.
3414 @param Operand The 64-bit operand to evaluate.
3416 @retval 0..63 The lowest bit set in Operand was found.
3417 @retval -1 Operand is zero.
3429 Returns the bit position of the highest bit set in a 32-bit value. Equivalent
3432 This function computes the bit position of the highest bit set in the 32-bit
3433 value specified by Operand. If Operand is zero, then -1 is returned.
3434 Otherwise, a value between 0 and 31 is returned.
3436 @param Operand The 32-bit operand to evaluate.
3438 @retval 0..31 Position of the highest bit set in Operand if found.
3439 @retval -1 Operand is zero.
3450 Returns the bit position of the highest bit set in a 64-bit value. Equivalent
3453 This function computes the bit position of the highest bit set in the 64-bit
3454 value specified by Operand. If Operand is zero, then -1 is returned.
3455 Otherwise, a value between 0 and 63 is returned.
3457 @param Operand The 64-bit operand to evaluate.
3459 @retval 0..63 Position of the highest bit set in Operand if found.
3460 @retval -1 Operand is zero.
3471 Returns the value of the highest bit set in a 32-bit value. Equivalent to
3474 This function computes the value of the highest bit set in the 32-bit value
3475 specified by Operand. If Operand is zero, then zero is returned.
3477 @param Operand The 32-bit operand to evaluate.
3479 @return 1 << HighBitSet32(Operand)
3480 @retval 0 Operand is zero.
3491 Returns the value of the highest bit set in a 64-bit value. Equivalent to
3494 This function computes the value of the highest bit set in the 64-bit value
3495 specified by Operand. If Operand is zero, then zero is returned.
3497 @param Operand The 64-bit operand to evaluate.
3499 @return 1 << HighBitSet64(Operand)
3500 @retval 0 Operand is zero.
3511 Switches the endianness of a 16-bit integer.
3513 This function swaps the bytes in a 16-bit unsigned value to switch the value
3514 from little endian to big endian or vice versa. The byte swapped value is
3517 @param Value A 16-bit unsigned value.
3519 @return The byte swapped Value.
3530 Switches the endianness of a 32-bit integer.
3532 This function swaps the bytes in a 32-bit unsigned value to switch the value
3533 from little endian to big endian or vice versa. The byte swapped value is
3536 @param Value A 32-bit unsigned value.
3538 @return The byte swapped Value.
3549 Switches the endianness of a 64-bit integer.
3551 This function swaps the bytes in a 64-bit unsigned value to switch the value
3552 from little endian to big endian or vice versa. The byte swapped value is
3555 @param Value A 64-bit unsigned value.
3557 @return The byte swapped Value.
3568 Multiples a 64-bit unsigned integer by a 32-bit unsigned integer and
3569 generates a 64-bit unsigned result.
3571 This function multiples the 64-bit unsigned value Multiplicand by the 32-bit
3572 unsigned value Multiplier and generates a 64-bit unsigned result. This 64-
3573 bit unsigned result is returned.
3575 @param Multiplicand A 64-bit unsigned value.
3576 @param Multiplier A 32-bit unsigned value.
3578 @return Multiplicand * Multiplier
3584 IN UINT64 Multiplicand
,
3585 IN UINT32 Multiplier
3590 Multiples a 64-bit unsigned integer by a 64-bit unsigned integer and
3591 generates a 64-bit unsigned result.
3593 This function multiples the 64-bit unsigned value Multiplicand by the 64-bit
3594 unsigned value Multiplier and generates a 64-bit unsigned result. This 64-
3595 bit unsigned result is returned.
3597 @param Multiplicand A 64-bit unsigned value.
3598 @param Multiplier A 64-bit unsigned value.
3600 @return Multiplicand * Multiplier.
3606 IN UINT64 Multiplicand
,
3607 IN UINT64 Multiplier
3612 Multiples a 64-bit signed integer by a 64-bit signed integer and generates a
3613 64-bit signed result.
3615 This function multiples the 64-bit signed value Multiplicand by the 64-bit
3616 signed value Multiplier and generates a 64-bit signed result. This 64-bit
3617 signed result is returned.
3619 @param Multiplicand A 64-bit signed value.
3620 @param Multiplier A 64-bit signed value.
3622 @return Multiplicand * Multiplier
3628 IN INT64 Multiplicand
,
3634 Divides a 64-bit unsigned integer by a 32-bit unsigned integer and generates
3635 a 64-bit unsigned result.
3637 This function divides the 64-bit unsigned value Dividend by the 32-bit
3638 unsigned value Divisor and generates a 64-bit unsigned quotient. This
3639 function returns the 64-bit unsigned quotient.
3641 If Divisor is 0, then ASSERT().
3643 @param Dividend A 64-bit unsigned value.
3644 @param Divisor A 32-bit unsigned value.
3646 @return Dividend / Divisor.
3658 Divides a 64-bit unsigned integer by a 32-bit unsigned integer and generates
3659 a 32-bit unsigned remainder.
3661 This function divides the 64-bit unsigned value Dividend by the 32-bit
3662 unsigned value Divisor and generates a 32-bit remainder. This function
3663 returns the 32-bit unsigned remainder.
3665 If Divisor is 0, then ASSERT().
3667 @param Dividend A 64-bit unsigned value.
3668 @param Divisor A 32-bit unsigned value.
3670 @return Dividend % Divisor.
3682 Divides a 64-bit unsigned integer by a 32-bit unsigned integer and generates
3683 a 64-bit unsigned result and an optional 32-bit unsigned remainder.
3685 This function divides the 64-bit unsigned value Dividend by the 32-bit
3686 unsigned value Divisor and generates a 64-bit unsigned quotient. If Remainder
3687 is not NULL, then the 32-bit unsigned remainder is returned in Remainder.
3688 This function returns the 64-bit unsigned quotient.
3690 If Divisor is 0, then ASSERT().
3692 @param Dividend A 64-bit unsigned value.
3693 @param Divisor A 32-bit unsigned value.
3694 @param Remainder A pointer to a 32-bit unsigned value. This parameter is
3695 optional and may be NULL.
3697 @return Dividend / Divisor.
3702 DivU64x32Remainder (
3705 OUT UINT32
*Remainder OPTIONAL
3710 Divides a 64-bit unsigned integer by a 64-bit unsigned integer and generates
3711 a 64-bit unsigned result and an optional 64-bit unsigned remainder.
3713 This function divides the 64-bit unsigned value Dividend by the 64-bit
3714 unsigned value Divisor and generates a 64-bit unsigned quotient. If Remainder
3715 is not NULL, then the 64-bit unsigned remainder is returned in Remainder.
3716 This function returns the 64-bit unsigned quotient.
3718 If Divisor is 0, then ASSERT().
3720 @param Dividend A 64-bit unsigned value.
3721 @param Divisor A 64-bit unsigned value.
3722 @param Remainder A pointer to a 64-bit unsigned value. This parameter is
3723 optional and may be NULL.
3725 @return Dividend / Divisor.
3730 DivU64x64Remainder (
3733 OUT UINT64
*Remainder OPTIONAL
3738 Divides a 64-bit signed integer by a 64-bit signed integer and generates a
3739 64-bit signed result and a optional 64-bit signed remainder.
3741 This function divides the 64-bit signed value Dividend by the 64-bit signed
3742 value Divisor and generates a 64-bit signed quotient. If Remainder is not
3743 NULL, then the 64-bit signed remainder is returned in Remainder. This
3744 function returns the 64-bit signed quotient.
3746 It is the caller's responsibility to not call this function with a Divisor of 0.
3747 If Divisor is 0, then the quotient and remainder should be assumed to be
3748 the largest negative integer.
3750 If Divisor is 0, then ASSERT().
3752 @param Dividend A 64-bit signed value.
3753 @param Divisor A 64-bit signed value.
3754 @param Remainder A pointer to a 64-bit signed value. This parameter is
3755 optional and may be NULL.
3757 @return Dividend / Divisor.
3762 DivS64x64Remainder (
3765 OUT INT64
*Remainder OPTIONAL
3770 Reads a 16-bit value from memory that may be unaligned.
3772 This function returns the 16-bit value pointed to by Buffer. The function
3773 guarantees that the read operation does not produce an alignment fault.
3775 If the Buffer is NULL, then ASSERT().
3777 @param Buffer The pointer to a 16-bit value that may be unaligned.
3779 @return The 16-bit value read from Buffer.
3785 IN CONST UINT16
*Buffer
3790 Writes a 16-bit value to memory that may be unaligned.
3792 This function writes the 16-bit value specified by Value to Buffer. Value is
3793 returned. The function guarantees that the write operation does not produce
3796 If the Buffer is NULL, then ASSERT().
3798 @param Buffer The pointer to a 16-bit value that may be unaligned.
3799 @param Value 16-bit value to write to Buffer.
3801 @return The 16-bit value to write to Buffer.
3813 Reads a 24-bit value from memory that may be unaligned.
3815 This function returns the 24-bit value pointed to by Buffer. The function
3816 guarantees that the read operation does not produce an alignment fault.
3818 If the Buffer is NULL, then ASSERT().
3820 @param Buffer The pointer to a 24-bit value that may be unaligned.
3822 @return The 24-bit value read from Buffer.
3828 IN CONST UINT32
*Buffer
3833 Writes a 24-bit value to memory that may be unaligned.
3835 This function writes the 24-bit value specified by Value to Buffer. Value is
3836 returned. The function guarantees that the write operation does not produce
3839 If the Buffer is NULL, then ASSERT().
3841 @param Buffer The pointer to a 24-bit value that may be unaligned.
3842 @param Value 24-bit value to write to Buffer.
3844 @return The 24-bit value to write to Buffer.
3856 Reads a 32-bit value from memory that may be unaligned.
3858 This function returns the 32-bit value pointed to by Buffer. The function
3859 guarantees that the read operation does not produce an alignment fault.
3861 If the Buffer is NULL, then ASSERT().
3863 @param Buffer The pointer to a 32-bit value that may be unaligned.
3865 @return The 32-bit value read from Buffer.
3871 IN CONST UINT32
*Buffer
3876 Writes a 32-bit value to memory that may be unaligned.
3878 This function writes the 32-bit value specified by Value to Buffer. Value is
3879 returned. The function guarantees that the write operation does not produce
3882 If the Buffer is NULL, then ASSERT().
3884 @param Buffer The pointer to a 32-bit value that may be unaligned.
3885 @param Value 32-bit value to write to Buffer.
3887 @return The 32-bit value to write to Buffer.
3899 Reads a 64-bit value from memory that may be unaligned.
3901 This function returns the 64-bit value pointed to by Buffer. The function
3902 guarantees that the read operation does not produce an alignment fault.
3904 If the Buffer is NULL, then ASSERT().
3906 @param Buffer The pointer to a 64-bit value that may be unaligned.
3908 @return The 64-bit value read from Buffer.
3914 IN CONST UINT64
*Buffer
3919 Writes a 64-bit value to memory that may be unaligned.
3921 This function writes the 64-bit value specified by Value to Buffer. Value is
3922 returned. The function guarantees that the write operation does not produce
3925 If the Buffer is NULL, then ASSERT().
3927 @param Buffer The pointer to a 64-bit value that may be unaligned.
3928 @param Value 64-bit value to write to Buffer.
3930 @return The 64-bit value to write to Buffer.
3942 // Bit Field Functions
3946 Returns a bit field from an 8-bit value.
3948 Returns the bitfield specified by the StartBit and the EndBit from Operand.
3950 If 8-bit operations are not supported, then ASSERT().
3951 If StartBit is greater than 7, then ASSERT().
3952 If EndBit is greater than 7, then ASSERT().
3953 If EndBit is less than StartBit, then ASSERT().
3955 @param Operand Operand on which to perform the bitfield operation.
3956 @param StartBit The ordinal of the least significant bit in the bit field.
3958 @param EndBit The ordinal of the most significant bit in the bit field.
3961 @return The bit field read.
3974 Writes a bit field to an 8-bit value, and returns the result.
3976 Writes Value to the bit field specified by the StartBit and the EndBit in
3977 Operand. All other bits in Operand are preserved. The new 8-bit value is
3980 If 8-bit operations are not supported, then ASSERT().
3981 If StartBit is greater than 7, then ASSERT().
3982 If EndBit is greater than 7, then ASSERT().
3983 If EndBit is less than StartBit, then ASSERT().
3984 If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
3986 @param Operand Operand on which to perform the bitfield operation.
3987 @param StartBit The ordinal of the least significant bit in the bit field.
3989 @param EndBit The ordinal of the most significant bit in the bit field.
3991 @param Value New value of the bit field.
3993 @return The new 8-bit value.
4007 Reads a bit field from an 8-bit value, performs a bitwise OR, and returns the
4010 Performs a bitwise OR between the bit field specified by StartBit
4011 and EndBit in Operand and the value specified by OrData. All other bits in
4012 Operand are preserved. The new 8-bit value is returned.
4014 If 8-bit operations are not supported, then ASSERT().
4015 If StartBit is greater than 7, then ASSERT().
4016 If EndBit is greater than 7, then ASSERT().
4017 If EndBit is less than StartBit, then ASSERT().
4018 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
4020 @param Operand Operand on which to perform the bitfield operation.
4021 @param StartBit The ordinal of the least significant bit in the bit field.
4023 @param EndBit The ordinal of the most significant bit in the bit field.
4025 @param OrData The value to OR with the read value from the value
4027 @return The new 8-bit value.
4041 Reads a bit field from an 8-bit value, performs a bitwise AND, and returns
4044 Performs a bitwise AND between the bit field specified by StartBit and EndBit
4045 in Operand and the value specified by AndData. All other bits in Operand are
4046 preserved. The new 8-bit value is returned.
4048 If 8-bit operations are not supported, then ASSERT().
4049 If StartBit is greater than 7, then ASSERT().
4050 If EndBit is greater than 7, then ASSERT().
4051 If EndBit is less than StartBit, then ASSERT().
4052 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
4054 @param Operand Operand on which to perform the bitfield operation.
4055 @param StartBit The ordinal of the least significant bit in the bit field.
4057 @param EndBit The ordinal of the most significant bit in the bit field.
4059 @param AndData The value to AND with the read value from the value.
4061 @return The new 8-bit value.
4075 Reads a bit field from an 8-bit value, performs a bitwise AND followed by a
4076 bitwise OR, and returns the result.
4078 Performs a bitwise AND between the bit field specified by StartBit and EndBit
4079 in Operand and the value specified by AndData, followed by a bitwise
4080 OR with value specified by OrData. All other bits in Operand are
4081 preserved. The new 8-bit value is returned.
4083 If 8-bit operations are not supported, then ASSERT().
4084 If StartBit is greater than 7, then ASSERT().
4085 If EndBit is greater than 7, then ASSERT().
4086 If EndBit is less than StartBit, then ASSERT().
4087 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
4088 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
4090 @param Operand Operand on which to perform the bitfield operation.
4091 @param StartBit The ordinal of the least significant bit in the bit field.
4093 @param EndBit The ordinal of the most significant bit in the bit field.
4095 @param AndData The value to AND with the read value from the value.
4096 @param OrData The value to OR with the result of the AND operation.
4098 @return The new 8-bit value.
4103 BitFieldAndThenOr8 (
4113 Returns a bit field from a 16-bit value.
4115 Returns the bitfield specified by the StartBit and the EndBit from Operand.
4117 If 16-bit operations are not supported, then ASSERT().
4118 If StartBit is greater than 15, then ASSERT().
4119 If EndBit is greater than 15, then ASSERT().
4120 If EndBit is less than StartBit, then ASSERT().
4122 @param Operand Operand on which to perform the bitfield operation.
4123 @param StartBit The ordinal of the least significant bit in the bit field.
4125 @param EndBit The ordinal of the most significant bit in the bit field.
4128 @return The bit field read.
4141 Writes a bit field to a 16-bit value, and returns the result.
4143 Writes Value to the bit field specified by the StartBit and the EndBit in
4144 Operand. All other bits in Operand are preserved. The new 16-bit value is
4147 If 16-bit operations are not supported, then ASSERT().
4148 If StartBit is greater than 15, then ASSERT().
4149 If EndBit is greater than 15, then ASSERT().
4150 If EndBit is less than StartBit, then ASSERT().
4151 If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
4153 @param Operand Operand on which to perform the bitfield operation.
4154 @param StartBit The ordinal of the least significant bit in the bit field.
4156 @param EndBit The ordinal of the most significant bit in the bit field.
4158 @param Value New value of the bit field.
4160 @return The new 16-bit value.
4174 Reads a bit field from a 16-bit value, performs a bitwise OR, and returns the
4177 Performs a bitwise OR between the bit field specified by StartBit
4178 and EndBit in Operand and the value specified by OrData. All other bits in
4179 Operand are preserved. The new 16-bit value is returned.
4181 If 16-bit operations are not supported, then ASSERT().
4182 If StartBit is greater than 15, then ASSERT().
4183 If EndBit is greater than 15, then ASSERT().
4184 If EndBit is less than StartBit, then ASSERT().
4185 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
4187 @param Operand Operand on which to perform the bitfield operation.
4188 @param StartBit The ordinal of the least significant bit in the bit field.
4190 @param EndBit The ordinal of the most significant bit in the bit field.
4192 @param OrData The value to OR with the read value from the value
4194 @return The new 16-bit value.
4208 Reads a bit field from a 16-bit value, performs a bitwise AND, and returns
4211 Performs a bitwise AND between the bit field specified by StartBit and EndBit
4212 in Operand and the value specified by AndData. All other bits in Operand are
4213 preserved. The new 16-bit value is returned.
4215 If 16-bit operations are not supported, then ASSERT().
4216 If StartBit is greater than 15, then ASSERT().
4217 If EndBit is greater than 15, then ASSERT().
4218 If EndBit is less than StartBit, then ASSERT().
4219 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
4221 @param Operand Operand on which to perform the bitfield operation.
4222 @param StartBit The ordinal of the least significant bit in the bit field.
4224 @param EndBit The ordinal of the most significant bit in the bit field.
4226 @param AndData The value to AND with the read value from the value
4228 @return The new 16-bit value.
4242 Reads a bit field from a 16-bit value, performs a bitwise AND followed by a
4243 bitwise OR, and returns the result.
4245 Performs a bitwise AND between the bit field specified by StartBit and EndBit
4246 in Operand and the value specified by AndData, followed by a bitwise
4247 OR with value specified by OrData. All other bits in Operand are
4248 preserved. The new 16-bit value is returned.
4250 If 16-bit operations are not supported, then ASSERT().
4251 If StartBit is greater than 15, then ASSERT().
4252 If EndBit is greater than 15, then ASSERT().
4253 If EndBit is less than StartBit, then ASSERT().
4254 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
4255 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
4257 @param Operand Operand on which to perform the bitfield operation.
4258 @param StartBit The ordinal of the least significant bit in the bit field.
4260 @param EndBit The ordinal of the most significant bit in the bit field.
4262 @param AndData The value to AND with the read value from the value.
4263 @param OrData The value to OR with the result of the AND operation.
4265 @return The new 16-bit value.
4270 BitFieldAndThenOr16 (
4280 Returns a bit field from a 32-bit value.
4282 Returns the bitfield specified by the StartBit and the EndBit from Operand.
4284 If 32-bit operations are not supported, then ASSERT().
4285 If StartBit is greater than 31, then ASSERT().
4286 If EndBit is greater than 31, then ASSERT().
4287 If EndBit is less than StartBit, then ASSERT().
4289 @param Operand Operand on which to perform the bitfield operation.
4290 @param StartBit The ordinal of the least significant bit in the bit field.
4292 @param EndBit The ordinal of the most significant bit in the bit field.
4295 @return The bit field read.
4308 Writes a bit field to a 32-bit value, and returns the result.
4310 Writes Value to the bit field specified by the StartBit and the EndBit in
4311 Operand. All other bits in Operand are preserved. The new 32-bit value is
4314 If 32-bit operations are not supported, then ASSERT().
4315 If StartBit is greater than 31, then ASSERT().
4316 If EndBit is greater than 31, then ASSERT().
4317 If EndBit is less than StartBit, then ASSERT().
4318 If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
4320 @param Operand Operand on which to perform the bitfield operation.
4321 @param StartBit The ordinal of the least significant bit in the bit field.
4323 @param EndBit The ordinal of the most significant bit in the bit field.
4325 @param Value New value of the bit field.
4327 @return The new 32-bit value.
4341 Reads a bit field from a 32-bit value, performs a bitwise OR, and returns the
4344 Performs a bitwise OR between the bit field specified by StartBit
4345 and EndBit in Operand and the value specified by OrData. All other bits in
4346 Operand are preserved. The new 32-bit value is returned.
4348 If 32-bit operations are not supported, then ASSERT().
4349 If StartBit is greater than 31, then ASSERT().
4350 If EndBit is greater than 31, then ASSERT().
4351 If EndBit is less than StartBit, then ASSERT().
4352 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
4354 @param Operand Operand on which to perform the bitfield operation.
4355 @param StartBit The ordinal of the least significant bit in the bit field.
4357 @param EndBit The ordinal of the most significant bit in the bit field.
4359 @param OrData The value to OR with the read value from the value.
4361 @return The new 32-bit value.
4375 Reads a bit field from a 32-bit value, performs a bitwise AND, and returns
4378 Performs a bitwise AND between the bit field specified by StartBit and EndBit
4379 in Operand and the value specified by AndData. All other bits in Operand are
4380 preserved. The new 32-bit value is returned.
4382 If 32-bit operations are not supported, then ASSERT().
4383 If StartBit is greater than 31, then ASSERT().
4384 If EndBit is greater than 31, then ASSERT().
4385 If EndBit is less than StartBit, then ASSERT().
4386 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
4388 @param Operand Operand on which to perform the bitfield operation.
4389 @param StartBit The ordinal of the least significant bit in the bit field.
4391 @param EndBit The ordinal of the most significant bit in the bit field.
4393 @param AndData The value to AND with the read value from the value
4395 @return The new 32-bit value.
4409 Reads a bit field from a 32-bit value, performs a bitwise AND followed by a
4410 bitwise OR, and returns the result.
4412 Performs a bitwise AND between the bit field specified by StartBit and EndBit
4413 in Operand and the value specified by AndData, followed by a bitwise
4414 OR with value specified by OrData. All other bits in Operand are
4415 preserved. The new 32-bit value is returned.
4417 If 32-bit operations are not supported, then ASSERT().
4418 If StartBit is greater than 31, then ASSERT().
4419 If EndBit is greater than 31, then ASSERT().
4420 If EndBit is less than StartBit, then ASSERT().
4421 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
4422 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
4424 @param Operand Operand on which to perform the bitfield operation.
4425 @param StartBit The ordinal of the least significant bit in the bit field.
4427 @param EndBit The ordinal of the most significant bit in the bit field.
4429 @param AndData The value to AND with the read value from the value.
4430 @param OrData The value to OR with the result of the AND operation.
4432 @return The new 32-bit value.
4437 BitFieldAndThenOr32 (
4447 Returns a bit field from a 64-bit value.
4449 Returns the bitfield specified by the StartBit and the EndBit from Operand.
4451 If 64-bit operations are not supported, then ASSERT().
4452 If StartBit is greater than 63, then ASSERT().
4453 If EndBit is greater than 63, then ASSERT().
4454 If EndBit is less than StartBit, then ASSERT().
4456 @param Operand Operand on which to perform the bitfield operation.
4457 @param StartBit The ordinal of the least significant bit in the bit field.
4459 @param EndBit The ordinal of the most significant bit in the bit field.
4462 @return The bit field read.
4475 Writes a bit field to a 64-bit value, and returns the result.
4477 Writes Value to the bit field specified by the StartBit and the EndBit in
4478 Operand. All other bits in Operand are preserved. The new 64-bit value is
4481 If 64-bit operations are not supported, then ASSERT().
4482 If StartBit is greater than 63, then ASSERT().
4483 If EndBit is greater than 63, then ASSERT().
4484 If EndBit is less than StartBit, then ASSERT().
4485 If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
4487 @param Operand Operand on which to perform the bitfield operation.
4488 @param StartBit The ordinal of the least significant bit in the bit field.
4490 @param EndBit The ordinal of the most significant bit in the bit field.
4492 @param Value New value of the bit field.
4494 @return The new 64-bit value.
4508 Reads a bit field from a 64-bit value, performs a bitwise OR, and returns the
4511 Performs a bitwise OR between the bit field specified by StartBit
4512 and EndBit in Operand and the value specified by OrData. All other bits in
4513 Operand are preserved. The new 64-bit value is returned.
4515 If 64-bit operations are not supported, then ASSERT().
4516 If StartBit is greater than 63, then ASSERT().
4517 If EndBit is greater than 63, then ASSERT().
4518 If EndBit is less than StartBit, then ASSERT().
4519 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
4521 @param Operand Operand on which to perform the bitfield operation.
4522 @param StartBit The ordinal of the least significant bit in the bit field.
4524 @param EndBit The ordinal of the most significant bit in the bit field.
4526 @param OrData The value to OR with the read value from the value
4528 @return The new 64-bit value.
4542 Reads a bit field from a 64-bit value, performs a bitwise AND, and returns
4545 Performs a bitwise AND between the bit field specified by StartBit and EndBit
4546 in Operand and the value specified by AndData. All other bits in Operand are
4547 preserved. The new 64-bit value is returned.
4549 If 64-bit operations are not supported, then ASSERT().
4550 If StartBit is greater than 63, then ASSERT().
4551 If EndBit is greater than 63, then ASSERT().
4552 If EndBit is less than StartBit, then ASSERT().
4553 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
4555 @param Operand Operand on which to perform the bitfield operation.
4556 @param StartBit The ordinal of the least significant bit in the bit field.
4558 @param EndBit The ordinal of the most significant bit in the bit field.
4560 @param AndData The value to AND with the read value from the value
4562 @return The new 64-bit value.
4576 Reads a bit field from a 64-bit value, performs a bitwise AND followed by a
4577 bitwise OR, and returns the result.
4579 Performs a bitwise AND between the bit field specified by StartBit and EndBit
4580 in Operand and the value specified by AndData, followed by a bitwise
4581 OR with value specified by OrData. All other bits in Operand are
4582 preserved. The new 64-bit value is returned.
4584 If 64-bit operations are not supported, then ASSERT().
4585 If StartBit is greater than 63, then ASSERT().
4586 If EndBit is greater than 63, then ASSERT().
4587 If EndBit is less than StartBit, then ASSERT().
4588 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
4589 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
4591 @param Operand Operand on which to perform the bitfield operation.
4592 @param StartBit The ordinal of the least significant bit in the bit field.
4594 @param EndBit The ordinal of the most significant bit in the bit field.
4596 @param AndData The value to AND with the read value from the value.
4597 @param OrData The value to OR with the result of the AND operation.
4599 @return The new 64-bit value.
4604 BitFieldAndThenOr64 (
4613 Reads a bit field from a 32-bit value, counts and returns
4614 the number of set bits.
4616 Counts the number of set bits in the bit field specified by
4617 StartBit and EndBit in Operand. The count is returned.
4619 If StartBit is greater than 31, then ASSERT().
4620 If EndBit is greater than 31, then ASSERT().
4621 If EndBit is less than StartBit, then ASSERT().
4623 @param Operand Operand on which to perform the bitfield operation.
4624 @param StartBit The ordinal of the least significant bit in the bit field.
4626 @param EndBit The ordinal of the most significant bit in the bit field.
4629 @return The number of bits set between StartBit and EndBit.
4634 BitFieldCountOnes32 (
4641 Reads a bit field from a 64-bit value, counts and returns
4642 the number of set bits.
4644 Counts the number of set bits in the bit field specified by
4645 StartBit and EndBit in Operand. The count is returned.
4647 If StartBit is greater than 63, then ASSERT().
4648 If EndBit is greater than 63, then ASSERT().
4649 If EndBit is less than StartBit, then ASSERT().
4651 @param Operand Operand on which to perform the bitfield operation.
4652 @param StartBit The ordinal of the least significant bit in the bit field.
4654 @param EndBit The ordinal of the most significant bit in the bit field.
4657 @return The number of bits set between StartBit and EndBit.
4662 BitFieldCountOnes64 (
4669 // Base Library Checksum Functions
4673 Returns the sum of all elements in a buffer in unit of UINT8.
4674 During calculation, the carry bits are dropped.
4676 This function calculates the sum of all elements in a buffer
4677 in unit of UINT8. The carry bits in result of addition are dropped.
4678 The result is returned as UINT8. If Length is Zero, then Zero is
4681 If Buffer is NULL, then ASSERT().
4682 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
4684 @param Buffer The pointer to the buffer to carry out the sum operation.
4685 @param Length The size, in bytes, of Buffer.
4687 @return Sum The sum of Buffer with carry bits dropped during additions.
4693 IN CONST UINT8
*Buffer
,
4699 Returns the two's complement checksum of all elements in a buffer
4702 This function first calculates the sum of the 8-bit values in the
4703 buffer specified by Buffer and Length. The carry bits in the result
4704 of addition are dropped. Then, the two's complement of the sum is
4705 returned. If Length is 0, then 0 is returned.
4707 If Buffer is NULL, then ASSERT().
4708 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
4710 @param Buffer The pointer to the buffer to carry out the checksum operation.
4711 @param Length The size, in bytes, of Buffer.
4713 @return Checksum The two's complement checksum of Buffer.
4718 CalculateCheckSum8 (
4719 IN CONST UINT8
*Buffer
,
4725 Returns the sum of all elements in a buffer of 16-bit values. During
4726 calculation, the carry bits are dropped.
4728 This function calculates the sum of the 16-bit values in the buffer
4729 specified by Buffer and Length. The carry bits in result of addition are dropped.
4730 The 16-bit result is returned. If Length is 0, then 0 is returned.
4732 If Buffer is NULL, then ASSERT().
4733 If Buffer is not aligned on a 16-bit boundary, then ASSERT().
4734 If Length is not aligned on a 16-bit boundary, then ASSERT().
4735 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
4737 @param Buffer The pointer to the buffer to carry out the sum operation.
4738 @param Length The size, in bytes, of Buffer.
4740 @return Sum The sum of Buffer with carry bits dropped during additions.
4746 IN CONST UINT16
*Buffer
,
4752 Returns the two's complement checksum of all elements in a buffer of
4755 This function first calculates the sum of the 16-bit values in the buffer
4756 specified by Buffer and Length. The carry bits in the result of addition
4757 are dropped. Then, the two's complement of the sum is returned. If Length
4758 is 0, then 0 is returned.
4760 If Buffer is NULL, then ASSERT().
4761 If Buffer is not aligned on a 16-bit boundary, then ASSERT().
4762 If Length is not aligned on a 16-bit boundary, then ASSERT().
4763 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
4765 @param Buffer The pointer to the buffer to carry out the checksum operation.
4766 @param Length The size, in bytes, of Buffer.
4768 @return Checksum The two's complement checksum of Buffer.
4773 CalculateCheckSum16 (
4774 IN CONST UINT16
*Buffer
,
4780 Returns the sum of all elements in a buffer of 32-bit values. During
4781 calculation, the carry bits are dropped.
4783 This function calculates the sum of the 32-bit values in the buffer
4784 specified by Buffer and Length. The carry bits in result of addition are dropped.
4785 The 32-bit result is returned. If Length is 0, then 0 is returned.
4787 If Buffer is NULL, then ASSERT().
4788 If Buffer is not aligned on a 32-bit boundary, then ASSERT().
4789 If Length is not aligned on a 32-bit boundary, then ASSERT().
4790 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
4792 @param Buffer The pointer to the buffer to carry out the sum operation.
4793 @param Length The size, in bytes, of Buffer.
4795 @return Sum The sum of Buffer with carry bits dropped during additions.
4801 IN CONST UINT32
*Buffer
,
4807 Returns the two's complement checksum of all elements in a buffer of
4810 This function first calculates the sum of the 32-bit values in the buffer
4811 specified by Buffer and Length. The carry bits in the result of addition
4812 are dropped. Then, the two's complement of the sum is returned. If Length
4813 is 0, then 0 is returned.
4815 If Buffer is NULL, then ASSERT().
4816 If Buffer is not aligned on a 32-bit boundary, then ASSERT().
4817 If Length is not aligned on a 32-bit boundary, then ASSERT().
4818 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
4820 @param Buffer The pointer to the buffer to carry out the checksum operation.
4821 @param Length The size, in bytes, of Buffer.
4823 @return Checksum The two's complement checksum of Buffer.
4828 CalculateCheckSum32 (
4829 IN CONST UINT32
*Buffer
,
4835 Returns the sum of all elements in a buffer of 64-bit values. During
4836 calculation, the carry bits are dropped.
4838 This function calculates the sum of the 64-bit values in the buffer
4839 specified by Buffer and Length. The carry bits in result of addition are dropped.
4840 The 64-bit result is returned. If Length is 0, then 0 is returned.
4842 If Buffer is NULL, then ASSERT().
4843 If Buffer is not aligned on a 64-bit boundary, then ASSERT().
4844 If Length is not aligned on a 64-bit boundary, then ASSERT().
4845 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
4847 @param Buffer The pointer to the buffer to carry out the sum operation.
4848 @param Length The size, in bytes, of Buffer.
4850 @return Sum The sum of Buffer with carry bits dropped during additions.
4856 IN CONST UINT64
*Buffer
,
4862 Returns the two's complement checksum of all elements in a buffer of
4865 This function first calculates the sum of the 64-bit values in the buffer
4866 specified by Buffer and Length. The carry bits in the result of addition
4867 are dropped. Then, the two's complement of the sum is returned. If Length
4868 is 0, then 0 is returned.
4870 If Buffer is NULL, then ASSERT().
4871 If Buffer is not aligned on a 64-bit boundary, then ASSERT().
4872 If Length is not aligned on a 64-bit boundary, then ASSERT().
4873 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
4875 @param Buffer The pointer to the buffer to carry out the checksum operation.
4876 @param Length The size, in bytes, of Buffer.
4878 @return Checksum The two's complement checksum of Buffer.
4883 CalculateCheckSum64 (
4884 IN CONST UINT64
*Buffer
,
4889 Computes and returns a 32-bit CRC for a data buffer.
4890 CRC32 value bases on ITU-T V.42.
4892 If Buffer is NULL, then ASSERT().
4893 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
4895 @param[in] Buffer A pointer to the buffer on which the 32-bit CRC is to be computed.
4896 @param[in] Length The number of bytes in the buffer Data.
4898 @retval Crc32 The 32-bit CRC was computed for the data buffer.
4909 // Base Library CPU Functions
4913 Function entry point used when a stack switch is requested with SwitchStack()
4915 @param Context1 Context1 parameter passed into SwitchStack().
4916 @param Context2 Context2 parameter passed into SwitchStack().
4921 (EFIAPI
*SWITCH_STACK_ENTRY_POINT
)(
4922 IN VOID
*Context1
, OPTIONAL
4923 IN VOID
*Context2 OPTIONAL
4928 Used to serialize load and store operations.
4930 All loads and stores that proceed calls to this function are guaranteed to be
4931 globally visible when this function returns.
4942 Saves the current CPU context that can be restored with a call to LongJump()
4945 Saves the current CPU context in the buffer specified by JumpBuffer and
4946 returns 0. The initial call to SetJump() must always return 0. Subsequent
4947 calls to LongJump() cause a non-zero value to be returned by SetJump().
4949 If JumpBuffer is NULL, then ASSERT().
4950 For Itanium processors, if JumpBuffer is not aligned on a 16-byte boundary, then ASSERT().
4952 NOTE: The structure BASE_LIBRARY_JUMP_BUFFER is CPU architecture specific.
4953 The same structure must never be used for more than one CPU architecture context.
4954 For example, a BASE_LIBRARY_JUMP_BUFFER allocated by an IA-32 module must never be used from an x64 module.
4955 SetJump()/LongJump() is not currently supported for the EBC processor type.
4957 @param JumpBuffer A pointer to CPU context buffer.
4959 @retval 0 Indicates a return from SetJump().
4966 OUT BASE_LIBRARY_JUMP_BUFFER
*JumpBuffer
4971 Restores the CPU context that was saved with SetJump().
4973 Restores the CPU context from the buffer specified by JumpBuffer. This
4974 function never returns to the caller. Instead is resumes execution based on
4975 the state of JumpBuffer.
4977 If JumpBuffer is NULL, then ASSERT().
4978 For Itanium processors, if JumpBuffer is not aligned on a 16-byte boundary, then ASSERT().
4979 If Value is 0, then ASSERT().
4981 @param JumpBuffer A pointer to CPU context buffer.
4982 @param Value The value to return when the SetJump() context is
4983 restored and must be non-zero.
4989 IN BASE_LIBRARY_JUMP_BUFFER
*JumpBuffer
,
4995 Enables CPU interrupts.
5006 Disables CPU interrupts.
5017 Disables CPU interrupts and returns the interrupt state prior to the disable
5020 @retval TRUE CPU interrupts were enabled on entry to this call.
5021 @retval FALSE CPU interrupts were disabled on entry to this call.
5026 SaveAndDisableInterrupts (
5032 Enables CPU interrupts for the smallest window required to capture any
5038 EnableDisableInterrupts (
5044 Retrieves the current CPU interrupt state.
5046 Returns TRUE if interrupts are currently enabled. Otherwise
5049 @retval TRUE CPU interrupts are enabled.
5050 @retval FALSE CPU interrupts are disabled.
5061 Set the current CPU interrupt state.
5063 Sets the current CPU interrupt state to the state specified by
5064 InterruptState. If InterruptState is TRUE, then interrupts are enabled. If
5065 InterruptState is FALSE, then interrupts are disabled. InterruptState is
5068 @param InterruptState TRUE if interrupts should enabled. FALSE if
5069 interrupts should be disabled.
5071 @return InterruptState
5077 IN BOOLEAN InterruptState
5082 Requests CPU to pause for a short period of time.
5084 Requests CPU to pause for a short period of time. Typically used in MP
5085 systems to prevent memory starvation while waiting for a spin lock.
5096 Transfers control to a function starting with a new stack.
5098 Transfers control to the function specified by EntryPoint using the
5099 new stack specified by NewStack and passing in the parameters specified
5100 by Context1 and Context2. Context1 and Context2 are optional and may
5101 be NULL. The function EntryPoint must never return. This function
5102 supports a variable number of arguments following the NewStack parameter.
5103 These additional arguments are ignored on IA-32, x64, and EBC architectures.
5104 Itanium processors expect one additional parameter of type VOID * that specifies
5105 the new backing store pointer.
5107 If EntryPoint is NULL, then ASSERT().
5108 If NewStack is NULL, then ASSERT().
5110 @param EntryPoint A pointer to function to call with the new stack.
5111 @param Context1 A pointer to the context to pass into the EntryPoint
5113 @param Context2 A pointer to the context to pass into the EntryPoint
5115 @param NewStack A pointer to the new stack to use for the EntryPoint
5117 @param ... This variable argument list is ignored for IA-32, x64, and
5118 EBC architectures. For Itanium processors, this variable
5119 argument list is expected to contain a single parameter of
5120 type VOID * that specifies the new backing store pointer.
5127 IN SWITCH_STACK_ENTRY_POINT EntryPoint
,
5128 IN VOID
*Context1
, OPTIONAL
5129 IN VOID
*Context2
, OPTIONAL
5136 Generates a breakpoint on the CPU.
5138 Generates a breakpoint on the CPU. The breakpoint must be implemented such
5139 that code can resume normal execution after the breakpoint.
5150 Executes an infinite loop.
5152 Forces the CPU to execute an infinite loop. A debugger may be used to skip
5153 past the loop and the code that follows the loop must execute properly. This
5154 implies that the infinite loop must not cause the code that follow it to be
5164 #if defined (MDE_CPU_IPF)
5167 Flush a range of cache lines in the cache coherency domain of the calling
5170 Flushes the cache lines specified by Address and Length. If Address is not aligned
5171 on a cache line boundary, then entire cache line containing Address is flushed.
5172 If Address + Length is not aligned on a cache line boundary, then the entire cache
5173 line containing Address + Length - 1 is flushed. This function may choose to flush
5174 the entire cache if that is more efficient than flushing the specified range. If
5175 Length is 0, the no cache lines are flushed. Address is returned.
5176 This function is only available on Itanium processors.
5178 If Length is greater than (MAX_ADDRESS - Address + 1), then ASSERT().
5180 @param Address The base address of the instruction lines to invalidate. If
5181 the CPU is in a physical addressing mode, then Address is a
5182 physical address. If the CPU is in a virtual addressing mode,
5183 then Address is a virtual address.
5185 @param Length The number of bytes to invalidate from the instruction cache.
5192 AsmFlushCacheRange (
5199 Executes an FC instruction.
5200 Executes an FC instruction on the cache line specified by Address.
5201 The cache line size affected is at least 32-bytes (aligned on a 32-byte boundary).
5202 An implementation may flush a larger region. This function is only available on Itanium processors.
5204 @param Address The Address of cache line to be flushed.
5206 @return The address of FC instruction executed.
5217 Executes an FC.I instruction.
5218 Executes an FC.I instruction on the cache line specified by Address.
5219 The cache line size affected is at least 32-bytes (aligned on a 32-byte boundary).
5220 An implementation may flush a larger region. This function is only available on Itanium processors.
5222 @param Address The Address of cache line to be flushed.
5224 @return The address of the FC.I instruction executed.
5235 Reads the current value of a Processor Identifier Register (CPUID).
5237 Reads and returns the current value of Processor Identifier Register specified by Index.
5238 The Index of largest implemented CPUID (One less than the number of implemented CPUID
5239 registers) is determined by CPUID [3] bits {7:0}.
5240 No parameter checking is performed on Index. If the Index value is beyond the
5241 implemented CPUID register range, a Reserved Register/Field fault may occur. The caller
5242 must either guarantee that Index is valid, or the caller must set up fault handlers to
5243 catch the faults. This function is only available on Itanium processors.
5245 @param Index The 8-bit Processor Identifier Register index to read.
5247 @return The current value of Processor Identifier Register specified by Index.
5258 Reads the current value of 64-bit Processor Status Register (PSR).
5259 This function is only available on Itanium processors.
5261 @return The current value of PSR.
5272 Writes the current value of 64-bit Processor Status Register (PSR).
5274 No parameter checking is performed on Value. All bits of Value corresponding to
5275 reserved fields of PSR must be 0 or a Reserved Register/Field fault may occur.
5276 The caller must either guarantee that Value is valid, or the caller must set up
5277 fault handlers to catch the faults. This function is only available on Itanium processors.
5279 @param Value The 64-bit value to write to PSR.
5281 @return The 64-bit value written to the PSR.
5292 Reads the current value of 64-bit Kernel Register #0 (KR0).
5294 Reads and returns the current value of KR0.
5295 This function is only available on Itanium processors.
5297 @return The current value of KR0.
5308 Reads the current value of 64-bit Kernel Register #1 (KR1).
5310 Reads and returns the current value of KR1.
5311 This function is only available on Itanium processors.
5313 @return The current value of KR1.
5324 Reads the current value of 64-bit Kernel Register #2 (KR2).
5326 Reads and returns the current value of KR2.
5327 This function is only available on Itanium processors.
5329 @return The current value of KR2.
5340 Reads the current value of 64-bit Kernel Register #3 (KR3).
5342 Reads and returns the current value of KR3.
5343 This function is only available on Itanium processors.
5345 @return The current value of KR3.
5356 Reads the current value of 64-bit Kernel Register #4 (KR4).
5358 Reads and returns the current value of KR4.
5359 This function is only available on Itanium processors.
5361 @return The current value of KR4.
5372 Reads the current value of 64-bit Kernel Register #5 (KR5).
5374 Reads and returns the current value of KR5.
5375 This function is only available on Itanium processors.
5377 @return The current value of KR5.
5388 Reads the current value of 64-bit Kernel Register #6 (KR6).
5390 Reads and returns the current value of KR6.
5391 This function is only available on Itanium processors.
5393 @return The current value of KR6.
5404 Reads the current value of 64-bit Kernel Register #7 (KR7).
5406 Reads and returns the current value of KR7.
5407 This function is only available on Itanium processors.
5409 @return The current value of KR7.
5420 Write the current value of 64-bit Kernel Register #0 (KR0).
5422 Writes the current value of KR0. The 64-bit value written to
5423 the KR0 is returned. This function is only available on Itanium processors.
5425 @param Value The 64-bit value to write to KR0.
5427 @return The 64-bit value written to the KR0.
5438 Write the current value of 64-bit Kernel Register #1 (KR1).
5440 Writes the current value of KR1. The 64-bit value written to
5441 the KR1 is returned. This function is only available on Itanium processors.
5443 @param Value The 64-bit value to write to KR1.
5445 @return The 64-bit value written to the KR1.
5456 Write the current value of 64-bit Kernel Register #2 (KR2).
5458 Writes the current value of KR2. The 64-bit value written to
5459 the KR2 is returned. This function is only available on Itanium processors.
5461 @param Value The 64-bit value to write to KR2.
5463 @return The 64-bit value written to the KR2.
5474 Write the current value of 64-bit Kernel Register #3 (KR3).
5476 Writes the current value of KR3. The 64-bit value written to
5477 the KR3 is returned. This function is only available on Itanium processors.
5479 @param Value The 64-bit value to write to KR3.
5481 @return The 64-bit value written to the KR3.
5492 Write the current value of 64-bit Kernel Register #4 (KR4).
5494 Writes the current value of KR4. The 64-bit value written to
5495 the KR4 is returned. This function is only available on Itanium processors.
5497 @param Value The 64-bit value to write to KR4.
5499 @return The 64-bit value written to the KR4.
5510 Write the current value of 64-bit Kernel Register #5 (KR5).
5512 Writes the current value of KR5. The 64-bit value written to
5513 the KR5 is returned. This function is only available on Itanium processors.
5515 @param Value The 64-bit value to write to KR5.
5517 @return The 64-bit value written to the KR5.
5528 Write the current value of 64-bit Kernel Register #6 (KR6).
5530 Writes the current value of KR6. The 64-bit value written to
5531 the KR6 is returned. This function is only available on Itanium processors.
5533 @param Value The 64-bit value to write to KR6.
5535 @return The 64-bit value written to the KR6.
5546 Write the current value of 64-bit Kernel Register #7 (KR7).
5548 Writes the current value of KR7. The 64-bit value written to
5549 the KR7 is returned. This function is only available on Itanium processors.
5551 @param Value The 64-bit value to write to KR7.
5553 @return The 64-bit value written to the KR7.
5564 Reads the current value of Interval Timer Counter Register (ITC).
5566 Reads and returns the current value of ITC.
5567 This function is only available on Itanium processors.
5569 @return The current value of ITC.
5580 Reads the current value of Interval Timer Vector Register (ITV).
5582 Reads and returns the current value of ITV.
5583 This function is only available on Itanium processors.
5585 @return The current value of ITV.
5596 Reads the current value of Interval Timer Match Register (ITM).
5598 Reads and returns the current value of ITM.
5599 This function is only available on Itanium processors.
5601 @return The current value of ITM.
5611 Writes the current value of 64-bit Interval Timer Counter Register (ITC).
5613 Writes the current value of ITC. The 64-bit value written to the ITC is returned.
5614 This function is only available on Itanium processors.
5616 @param Value The 64-bit value to write to ITC.
5618 @return The 64-bit value written to the ITC.
5629 Writes the current value of 64-bit Interval Timer Match Register (ITM).
5631 Writes the current value of ITM. The 64-bit value written to the ITM is returned.
5632 This function is only available on Itanium processors.
5634 @param Value The 64-bit value to write to ITM.
5636 @return The 64-bit value written to the ITM.
5647 Writes the current value of 64-bit Interval Timer Vector Register (ITV).
5649 Writes the current value of ITV. The 64-bit value written to the ITV is returned.
5650 No parameter checking is performed on Value. All bits of Value corresponding to
5651 reserved fields of ITV must be 0 or a Reserved Register/Field fault may occur.
5652 The caller must either guarantee that Value is valid, or the caller must set up
5653 fault handlers to catch the faults.
5654 This function is only available on Itanium processors.
5656 @param Value The 64-bit value to write to ITV.
5658 @return The 64-bit value written to the ITV.
5669 Reads the current value of Default Control Register (DCR).
5671 Reads and returns the current value of DCR. This function is only available on Itanium processors.
5673 @return The current value of DCR.
5684 Reads the current value of Interruption Vector Address Register (IVA).
5686 Reads and returns the current value of IVA. This function is only available on Itanium processors.
5688 @return The current value of IVA.
5698 Reads the current value of Page Table Address Register (PTA).
5700 Reads and returns the current value of PTA. This function is only available on Itanium processors.
5702 @return The current value of PTA.
5713 Writes the current value of 64-bit Default Control Register (DCR).
5715 Writes the current value of DCR. The 64-bit value written to the DCR is returned.
5716 No parameter checking is performed on Value. All bits of Value corresponding to
5717 reserved fields of DCR must be 0 or a Reserved Register/Field fault may occur.
5718 The caller must either guarantee that Value is valid, or the caller must set up
5719 fault handlers to catch the faults.
5720 This function is only available on Itanium processors.
5722 @param Value The 64-bit value to write to DCR.
5724 @return The 64-bit value written to the DCR.
5735 Writes the current value of 64-bit Interruption Vector Address Register (IVA).
5737 Writes the current value of IVA. The 64-bit value written to the IVA is returned.
5738 The size of vector table is 32 K bytes and is 32 K bytes aligned
5739 the low 15 bits of Value is ignored when written.
5740 This function is only available on Itanium processors.
5742 @param Value The 64-bit value to write to IVA.
5744 @return The 64-bit value written to the IVA.
5755 Writes the current value of 64-bit Page Table Address Register (PTA).
5757 Writes the current value of PTA. The 64-bit value written to the PTA is returned.
5758 No parameter checking is performed on Value. All bits of Value corresponding to
5759 reserved fields of DCR must be 0 or a Reserved Register/Field fault may occur.
5760 The caller must either guarantee that Value is valid, or the caller must set up
5761 fault handlers to catch the faults.
5762 This function is only available on Itanium processors.
5764 @param Value The 64-bit value to write to PTA.
5766 @return The 64-bit value written to the PTA.
5776 Reads the current value of Local Interrupt ID Register (LID).
5778 Reads and returns the current value of LID. This function is only available on Itanium processors.
5780 @return The current value of LID.
5791 Reads the current value of External Interrupt Vector Register (IVR).
5793 Reads and returns the current value of IVR. This function is only available on Itanium processors.
5795 @return The current value of IVR.
5806 Reads the current value of Task Priority Register (TPR).
5808 Reads and returns the current value of TPR. This function is only available on Itanium processors.
5810 @return The current value of TPR.
5821 Reads the current value of External Interrupt Request Register #0 (IRR0).
5823 Reads and returns the current value of IRR0. This function is only available on Itanium processors.
5825 @return The current value of IRR0.
5836 Reads the current value of External Interrupt Request Register #1 (IRR1).
5838 Reads and returns the current value of IRR1. This function is only available on Itanium processors.
5840 @return The current value of IRR1.
5851 Reads the current value of External Interrupt Request Register #2 (IRR2).
5853 Reads and returns the current value of IRR2. This function is only available on Itanium processors.
5855 @return The current value of IRR2.
5866 Reads the current value of External Interrupt Request Register #3 (IRR3).
5868 Reads and returns the current value of IRR3. This function is only available on Itanium processors.
5870 @return The current value of IRR3.
5881 Reads the current value of Performance Monitor Vector Register (PMV).
5883 Reads and returns the current value of PMV. This function is only available on Itanium processors.
5885 @return The current value of PMV.
5896 Reads the current value of Corrected Machine Check Vector Register (CMCV).
5898 Reads and returns the current value of CMCV. This function is only available on Itanium processors.
5900 @return The current value of CMCV.
5911 Reads the current value of Local Redirection Register #0 (LRR0).
5913 Reads and returns the current value of LRR0. This function is only available on Itanium processors.
5915 @return The current value of LRR0.
5926 Reads the current value of Local Redirection Register #1 (LRR1).
5928 Reads and returns the current value of LRR1. This function is only available on Itanium processors.
5930 @return The current value of LRR1.
5941 Writes the current value of 64-bit Page Local Interrupt ID Register (LID).
5943 Writes the current value of LID. The 64-bit value written to the LID is returned.
5944 No parameter checking is performed on Value. All bits of Value corresponding to
5945 reserved fields of LID must be 0 or a Reserved Register/Field fault may occur.
5946 The caller must either guarantee that Value is valid, or the caller must set up
5947 fault handlers to catch the faults.
5948 This function is only available on Itanium processors.
5950 @param Value The 64-bit value to write to LID.
5952 @return The 64-bit value written to the LID.
5963 Writes the current value of 64-bit Task Priority Register (TPR).
5965 Writes the current value of TPR. The 64-bit value written to the TPR is returned.
5966 No parameter checking is performed on Value. All bits of Value corresponding to
5967 reserved fields of TPR must be 0 or a Reserved Register/Field fault may occur.
5968 The caller must either guarantee that Value is valid, or the caller must set up
5969 fault handlers to catch the faults.
5970 This function is only available on Itanium processors.
5972 @param Value The 64-bit value to write to TPR.
5974 @return The 64-bit value written to the TPR.
5985 Performs a write operation on End OF External Interrupt Register (EOI).
5987 Writes a value of 0 to the EOI Register. This function is only available on Itanium processors.
5998 Writes the current value of 64-bit Performance Monitor Vector Register (PMV).
6000 Writes the current value of PMV. The 64-bit value written to the PMV is returned.
6001 No parameter checking is performed on Value. All bits of Value corresponding
6002 to reserved fields of PMV must be 0 or a Reserved Register/Field fault may occur.
6003 The caller must either guarantee that Value is valid, or the caller must set up
6004 fault handlers to catch the faults.
6005 This function is only available on Itanium processors.
6007 @param Value The 64-bit value to write to PMV.
6009 @return The 64-bit value written to the PMV.
6020 Writes the current value of 64-bit Corrected Machine Check Vector Register (CMCV).
6022 Writes the current value of CMCV. The 64-bit value written to the CMCV is returned.
6023 No parameter checking is performed on Value. All bits of Value corresponding
6024 to reserved fields of CMCV must be 0 or a Reserved Register/Field fault may occur.
6025 The caller must either guarantee that Value is valid, or the caller must set up
6026 fault handlers to catch the faults.
6027 This function is only available on Itanium processors.
6029 @param Value The 64-bit value to write to CMCV.
6031 @return The 64-bit value written to the CMCV.
6042 Writes the current value of 64-bit Local Redirection Register #0 (LRR0).
6044 Writes the current value of LRR0. The 64-bit value written to the LRR0 is returned.
6045 No parameter checking is performed on Value. All bits of Value corresponding
6046 to reserved fields of LRR0 must be 0 or a Reserved Register/Field fault may occur.
6047 The caller must either guarantee that Value is valid, or the caller must set up
6048 fault handlers to catch the faults.
6049 This function is only available on Itanium processors.
6051 @param Value The 64-bit value to write to LRR0.
6053 @return The 64-bit value written to the LRR0.
6064 Writes the current value of 64-bit Local Redirection Register #1 (LRR1).
6066 Writes the current value of LRR1. The 64-bit value written to the LRR1 is returned.
6067 No parameter checking is performed on Value. All bits of Value corresponding
6068 to reserved fields of LRR1 must be 0 or a Reserved Register/Field fault may occur.
6069 The caller must either guarantee that Value is valid, or the caller must
6070 set up fault handlers to catch the faults.
6071 This function is only available on Itanium processors.
6073 @param Value The 64-bit value to write to LRR1.
6075 @return The 64-bit value written to the LRR1.
6086 Reads the current value of Instruction Breakpoint Register (IBR).
6088 The Instruction Breakpoint Registers are used in pairs. The even numbered
6089 registers contain breakpoint addresses, and the odd numbered registers contain
6090 breakpoint mask conditions. At least four instruction registers pairs are implemented
6091 on all processor models. Implemented registers are contiguous starting with
6092 register 0. No parameter checking is performed on Index, and if the Index value
6093 is beyond the implemented IBR register range, a Reserved Register/Field fault may
6094 occur. The caller must either guarantee that Index is valid, or the caller must
6095 set up fault handlers to catch the faults.
6096 This function is only available on Itanium processors.
6098 @param Index The 8-bit Instruction Breakpoint Register index to read.
6100 @return The current value of Instruction Breakpoint Register specified by Index.
6111 Reads the current value of Data Breakpoint Register (DBR).
6113 The Data Breakpoint Registers are used in pairs. The even numbered registers
6114 contain breakpoint addresses, and odd numbered registers contain breakpoint
6115 mask conditions. At least four data registers pairs are implemented on all processor
6116 models. Implemented registers are contiguous starting with register 0.
6117 No parameter checking is performed on Index. If the Index value is beyond
6118 the implemented DBR register range, a Reserved Register/Field fault may occur.
6119 The caller must either guarantee that Index is valid, or the caller must set up
6120 fault handlers to catch the faults.
6121 This function is only available on Itanium processors.
6123 @param Index The 8-bit Data Breakpoint Register index to read.
6125 @return The current value of Data Breakpoint Register specified by Index.
6136 Reads the current value of Performance Monitor Configuration Register (PMC).
6138 All processor implementations provide at least four performance counters
6139 (PMC/PMD [4]...PMC/PMD [7] pairs), and four performance monitor counter overflow
6140 status registers (PMC [0]... PMC [3]). Processor implementations may provide
6141 additional implementation-dependent PMC and PMD to increase the number of
6142 'generic' performance counters (PMC/PMD pairs). The remainder of PMC and PMD
6143 register set is implementation dependent. No parameter checking is performed
6144 on Index. If the Index value is beyond the implemented PMC register range,
6145 zero value will be returned.
6146 This function is only available on Itanium processors.
6148 @param Index The 8-bit Performance Monitor Configuration Register index to read.
6150 @return The current value of Performance Monitor Configuration Register
6162 Reads the current value of Performance Monitor Data Register (PMD).
6164 All processor implementations provide at least 4 performance counters
6165 (PMC/PMD [4]...PMC/PMD [7] pairs), and 4 performance monitor counter
6166 overflow status registers (PMC [0]... PMC [3]). Processor implementations may
6167 provide additional implementation-dependent PMC and PMD to increase the number
6168 of 'generic' performance counters (PMC/PMD pairs). The remainder of PMC and PMD
6169 register set is implementation dependent. No parameter checking is performed
6170 on Index. If the Index value is beyond the implemented PMD register range,
6171 zero value will be returned.
6172 This function is only available on Itanium processors.
6174 @param Index The 8-bit Performance Monitor Data Register index to read.
6176 @return The current value of Performance Monitor Data Register specified by Index.
6187 Writes the current value of 64-bit Instruction Breakpoint Register (IBR).
6189 Writes current value of Instruction Breakpoint Register specified by Index.
6190 The Instruction Breakpoint Registers are used in pairs. The even numbered
6191 registers contain breakpoint addresses, and odd numbered registers contain
6192 breakpoint mask conditions. At least four instruction registers pairs are implemented
6193 on all processor models. Implemented registers are contiguous starting with
6194 register 0. No parameter checking is performed on Index. If the Index value
6195 is beyond the implemented IBR register range, a Reserved Register/Field fault may
6196 occur. The caller must either guarantee that Index is valid, or the caller must
6197 set up fault handlers to catch the faults.
6198 This function is only available on Itanium processors.
6200 @param Index The 8-bit Instruction Breakpoint Register index to write.
6201 @param Value The 64-bit value to write to IBR.
6203 @return The 64-bit value written to the IBR.
6215 Writes the current value of 64-bit Data Breakpoint Register (DBR).
6217 Writes current value of Data Breakpoint Register specified by Index.
6218 The Data Breakpoint Registers are used in pairs. The even numbered registers
6219 contain breakpoint addresses, and odd numbered registers contain breakpoint
6220 mask conditions. At least four data registers pairs are implemented on all processor
6221 models. Implemented registers are contiguous starting with register 0. No parameter
6222 checking is performed on Index. If the Index value is beyond the implemented
6223 DBR register range, a Reserved Register/Field fault may occur. The caller must
6224 either guarantee that Index is valid, or the caller must set up fault handlers to
6226 This function is only available on Itanium processors.
6228 @param Index The 8-bit Data Breakpoint Register index to write.
6229 @param Value The 64-bit value to write to DBR.
6231 @return The 64-bit value written to the DBR.
6243 Writes the current value of 64-bit Performance Monitor Configuration Register (PMC).
6245 Writes current value of Performance Monitor Configuration Register specified by Index.
6246 All processor implementations provide at least four performance counters
6247 (PMC/PMD [4]...PMC/PMD [7] pairs), and four performance monitor counter overflow status
6248 registers (PMC [0]... PMC [3]). Processor implementations may provide additional
6249 implementation-dependent PMC and PMD to increase the number of 'generic' performance
6250 counters (PMC/PMD pairs). The remainder of PMC and PMD register set is implementation
6251 dependent. No parameter checking is performed on Index. If the Index value is
6252 beyond the implemented PMC register range, the write is ignored.
6253 This function is only available on Itanium processors.
6255 @param Index The 8-bit Performance Monitor Configuration Register index to write.
6256 @param Value The 64-bit value to write to PMC.
6258 @return The 64-bit value written to the PMC.
6270 Writes the current value of 64-bit Performance Monitor Data Register (PMD).
6272 Writes current value of Performance Monitor Data Register specified by Index.
6273 All processor implementations provide at least four performance counters
6274 (PMC/PMD [4]...PMC/PMD [7] pairs), and four performance monitor counter overflow
6275 status registers (PMC [0]... PMC [3]). Processor implementations may provide
6276 additional implementation-dependent PMC and PMD to increase the number of 'generic'
6277 performance counters (PMC/PMD pairs). The remainder of PMC and PMD register set
6278 is implementation dependent. No parameter checking is performed on Index. If the
6279 Index value is beyond the implemented PMD register range, the write is ignored.
6280 This function is only available on Itanium processors.
6282 @param Index The 8-bit Performance Monitor Data Register index to write.
6283 @param Value The 64-bit value to write to PMD.
6285 @return The 64-bit value written to the PMD.
6297 Reads the current value of 64-bit Global Pointer (GP).
6299 Reads and returns the current value of GP.
6300 This function is only available on Itanium processors.
6302 @return The current value of GP.
6313 Write the current value of 64-bit Global Pointer (GP).
6315 Writes the current value of GP. The 64-bit value written to the GP is returned.
6316 No parameter checking is performed on Value.
6317 This function is only available on Itanium processors.
6319 @param Value The 64-bit value to write to GP.
6321 @return The 64-bit value written to the GP.
6332 Reads the current value of 64-bit Stack Pointer (SP).
6334 Reads and returns the current value of SP.
6335 This function is only available on Itanium processors.
6337 @return The current value of SP.
6348 /// Valid Index value for AsmReadControlRegister().
6350 #define IPF_CONTROL_REGISTER_DCR 0
6351 #define IPF_CONTROL_REGISTER_ITM 1
6352 #define IPF_CONTROL_REGISTER_IVA 2
6353 #define IPF_CONTROL_REGISTER_PTA 8
6354 #define IPF_CONTROL_REGISTER_IPSR 16
6355 #define IPF_CONTROL_REGISTER_ISR 17
6356 #define IPF_CONTROL_REGISTER_IIP 19
6357 #define IPF_CONTROL_REGISTER_IFA 20
6358 #define IPF_CONTROL_REGISTER_ITIR 21
6359 #define IPF_CONTROL_REGISTER_IIPA 22
6360 #define IPF_CONTROL_REGISTER_IFS 23
6361 #define IPF_CONTROL_REGISTER_IIM 24
6362 #define IPF_CONTROL_REGISTER_IHA 25
6363 #define IPF_CONTROL_REGISTER_LID 64
6364 #define IPF_CONTROL_REGISTER_IVR 65
6365 #define IPF_CONTROL_REGISTER_TPR 66
6366 #define IPF_CONTROL_REGISTER_EOI 67
6367 #define IPF_CONTROL_REGISTER_IRR0 68
6368 #define IPF_CONTROL_REGISTER_IRR1 69
6369 #define IPF_CONTROL_REGISTER_IRR2 70
6370 #define IPF_CONTROL_REGISTER_IRR3 71
6371 #define IPF_CONTROL_REGISTER_ITV 72
6372 #define IPF_CONTROL_REGISTER_PMV 73
6373 #define IPF_CONTROL_REGISTER_CMCV 74
6374 #define IPF_CONTROL_REGISTER_LRR0 80
6375 #define IPF_CONTROL_REGISTER_LRR1 81
6378 Reads a 64-bit control register.
6380 Reads and returns the control register specified by Index. The valid Index valued
6381 are defined above in "Related Definitions".
6382 If Index is invalid then 0xFFFFFFFFFFFFFFFF is returned. This function is only
6383 available on Itanium processors.
6385 @param Index The index of the control register to read.
6387 @return The control register specified by Index.
6392 AsmReadControlRegister (
6398 /// Valid Index value for AsmReadApplicationRegister().
6400 #define IPF_APPLICATION_REGISTER_K0 0
6401 #define IPF_APPLICATION_REGISTER_K1 1
6402 #define IPF_APPLICATION_REGISTER_K2 2
6403 #define IPF_APPLICATION_REGISTER_K3 3
6404 #define IPF_APPLICATION_REGISTER_K4 4
6405 #define IPF_APPLICATION_REGISTER_K5 5
6406 #define IPF_APPLICATION_REGISTER_K6 6
6407 #define IPF_APPLICATION_REGISTER_K7 7
6408 #define IPF_APPLICATION_REGISTER_RSC 16
6409 #define IPF_APPLICATION_REGISTER_BSP 17
6410 #define IPF_APPLICATION_REGISTER_BSPSTORE 18
6411 #define IPF_APPLICATION_REGISTER_RNAT 19
6412 #define IPF_APPLICATION_REGISTER_FCR 21
6413 #define IPF_APPLICATION_REGISTER_EFLAG 24
6414 #define IPF_APPLICATION_REGISTER_CSD 25
6415 #define IPF_APPLICATION_REGISTER_SSD 26
6416 #define IPF_APPLICATION_REGISTER_CFLG 27
6417 #define IPF_APPLICATION_REGISTER_FSR 28
6418 #define IPF_APPLICATION_REGISTER_FIR 29
6419 #define IPF_APPLICATION_REGISTER_FDR 30
6420 #define IPF_APPLICATION_REGISTER_CCV 32
6421 #define IPF_APPLICATION_REGISTER_UNAT 36
6422 #define IPF_APPLICATION_REGISTER_FPSR 40
6423 #define IPF_APPLICATION_REGISTER_ITC 44
6424 #define IPF_APPLICATION_REGISTER_PFS 64
6425 #define IPF_APPLICATION_REGISTER_LC 65
6426 #define IPF_APPLICATION_REGISTER_EC 66
6429 Reads a 64-bit application register.
6431 Reads and returns the application register specified by Index. The valid Index
6432 valued are defined above in "Related Definitions".
6433 If Index is invalid then 0xFFFFFFFFFFFFFFFF is returned. This function is only
6434 available on Itanium processors.
6436 @param Index The index of the application register to read.
6438 @return The application register specified by Index.
6443 AsmReadApplicationRegister (
6449 Reads the current value of a Machine Specific Register (MSR).
6451 Reads and returns the current value of the Machine Specific Register specified by Index. No
6452 parameter checking is performed on Index, and if the Index value is beyond the implemented MSR
6453 register range, a Reserved Register/Field fault may occur. The caller must either guarantee that
6454 Index is valid, or the caller must set up fault handlers to catch the faults. This function is
6455 only available on Itanium processors.
6457 @param Index The 8-bit Machine Specific Register index to read.
6459 @return The current value of the Machine Specific Register specified by Index.
6470 Writes the current value of a Machine Specific Register (MSR).
6472 Writes Value to the Machine Specific Register specified by Index. Value is returned. No
6473 parameter checking is performed on Index, and if the Index value is beyond the implemented MSR
6474 register range, a Reserved Register/Field fault may occur. The caller must either guarantee that
6475 Index is valid, or the caller must set up fault handlers to catch the faults. This function is
6476 only available on Itanium processors.
6478 @param Index The 8-bit Machine Specific Register index to write.
6479 @param Value The 64-bit value to write to the Machine Specific Register.
6481 @return The 64-bit value to write to the Machine Specific Register.
6493 Determines if the CPU is currently executing in virtual, physical, or mixed mode.
6495 Determines the current execution mode of the CPU.
6496 If the CPU is in virtual mode(PSR.RT=1, PSR.DT=1, PSR.IT=1), then 1 is returned.
6497 If the CPU is in physical mode(PSR.RT=0, PSR.DT=0, PSR.IT=0), then 0 is returned.
6498 If the CPU is not in physical mode or virtual mode, then it is in mixed mode,
6500 This function is only available on Itanium processors.
6502 @retval 1 The CPU is in virtual mode.
6503 @retval 0 The CPU is in physical mode.
6504 @retval -1 The CPU is in mixed mode.
6515 Makes a PAL procedure call.
6517 This is a wrapper function to make a PAL procedure call. Based on the Index
6518 value this API will make static or stacked PAL call. The following table
6519 describes the usage of PAL Procedure Index Assignment. Architected procedures
6520 may be designated as required or optional. If a PAL procedure is specified
6521 as optional, a unique return code of 0xFFFFFFFFFFFFFFFF is returned in the
6522 Status field of the PAL_CALL_RETURN structure.
6523 This indicates that the procedure is not present in this PAL implementation.
6524 It is the caller's responsibility to check for this return code after calling
6525 any optional PAL procedure.
6526 No parameter checking is performed on the 5 input parameters, but there are
6527 some common rules that the caller should follow when making a PAL call. Any
6528 address passed to PAL as buffers for return parameters must be 8-byte aligned.
6529 Unaligned addresses may cause undefined results. For those parameters defined
6530 as reserved or some fields defined as reserved must be zero filled or the invalid
6531 argument return value may be returned or undefined result may occur during the
6532 execution of the procedure. If the PalEntryPoint does not point to a valid
6533 PAL entry point then the system behavior is undefined. This function is only
6534 available on Itanium processors.
6536 @param PalEntryPoint The PAL procedure calls entry point.
6537 @param Index The PAL procedure Index number.
6538 @param Arg2 The 2nd parameter for PAL procedure calls.
6539 @param Arg3 The 3rd parameter for PAL procedure calls.
6540 @param Arg4 The 4th parameter for PAL procedure calls.
6542 @return structure returned from the PAL Call procedure, including the status and return value.
6548 IN UINT64 PalEntryPoint
,
6554 #endif // defined (MDE_CPU_IPF)
6556 #if defined (MDE_CPU_IA32) || defined (MDE_CPU_X64)
6558 /// IA32 and x64 Specific Functions.
6559 /// Byte packed structure for 16-bit Real Mode EFLAGS.
6563 UINT32 CF
:1; ///< Carry Flag.
6564 UINT32 Reserved_0
:1; ///< Reserved.
6565 UINT32 PF
:1; ///< Parity Flag.
6566 UINT32 Reserved_1
:1; ///< Reserved.
6567 UINT32 AF
:1; ///< Auxiliary Carry Flag.
6568 UINT32 Reserved_2
:1; ///< Reserved.
6569 UINT32 ZF
:1; ///< Zero Flag.
6570 UINT32 SF
:1; ///< Sign Flag.
6571 UINT32 TF
:1; ///< Trap Flag.
6572 UINT32 IF
:1; ///< Interrupt Enable Flag.
6573 UINT32 DF
:1; ///< Direction Flag.
6574 UINT32 OF
:1; ///< Overflow Flag.
6575 UINT32 IOPL
:2; ///< I/O Privilege Level.
6576 UINT32 NT
:1; ///< Nested Task.
6577 UINT32 Reserved_3
:1; ///< Reserved.
6583 /// Byte packed structure for EFLAGS/RFLAGS.
6584 /// 32-bits on IA-32.
6585 /// 64-bits on x64. The upper 32-bits on x64 are reserved.
6589 UINT32 CF
:1; ///< Carry Flag.
6590 UINT32 Reserved_0
:1; ///< Reserved.
6591 UINT32 PF
:1; ///< Parity Flag.
6592 UINT32 Reserved_1
:1; ///< Reserved.
6593 UINT32 AF
:1; ///< Auxiliary Carry Flag.
6594 UINT32 Reserved_2
:1; ///< Reserved.
6595 UINT32 ZF
:1; ///< Zero Flag.
6596 UINT32 SF
:1; ///< Sign Flag.
6597 UINT32 TF
:1; ///< Trap Flag.
6598 UINT32 IF
:1; ///< Interrupt Enable Flag.
6599 UINT32 DF
:1; ///< Direction Flag.
6600 UINT32 OF
:1; ///< Overflow Flag.
6601 UINT32 IOPL
:2; ///< I/O Privilege Level.
6602 UINT32 NT
:1; ///< Nested Task.
6603 UINT32 Reserved_3
:1; ///< Reserved.
6604 UINT32 RF
:1; ///< Resume Flag.
6605 UINT32 VM
:1; ///< Virtual 8086 Mode.
6606 UINT32 AC
:1; ///< Alignment Check.
6607 UINT32 VIF
:1; ///< Virtual Interrupt Flag.
6608 UINT32 VIP
:1; ///< Virtual Interrupt Pending.
6609 UINT32 ID
:1; ///< ID Flag.
6610 UINT32 Reserved_4
:10; ///< Reserved.
6616 /// Byte packed structure for Control Register 0 (CR0).
6617 /// 32-bits on IA-32.
6618 /// 64-bits on x64. The upper 32-bits on x64 are reserved.
6622 UINT32 PE
:1; ///< Protection Enable.
6623 UINT32 MP
:1; ///< Monitor Coprocessor.
6624 UINT32 EM
:1; ///< Emulation.
6625 UINT32 TS
:1; ///< Task Switched.
6626 UINT32 ET
:1; ///< Extension Type.
6627 UINT32 NE
:1; ///< Numeric Error.
6628 UINT32 Reserved_0
:10; ///< Reserved.
6629 UINT32 WP
:1; ///< Write Protect.
6630 UINT32 Reserved_1
:1; ///< Reserved.
6631 UINT32 AM
:1; ///< Alignment Mask.
6632 UINT32 Reserved_2
:10; ///< Reserved.
6633 UINT32 NW
:1; ///< Mot Write-through.
6634 UINT32 CD
:1; ///< Cache Disable.
6635 UINT32 PG
:1; ///< Paging.
6641 /// Byte packed structure for Control Register 4 (CR4).
6642 /// 32-bits on IA-32.
6643 /// 64-bits on x64. The upper 32-bits on x64 are reserved.
6647 UINT32 VME
:1; ///< Virtual-8086 Mode Extensions.
6648 UINT32 PVI
:1; ///< Protected-Mode Virtual Interrupts.
6649 UINT32 TSD
:1; ///< Time Stamp Disable.
6650 UINT32 DE
:1; ///< Debugging Extensions.
6651 UINT32 PSE
:1; ///< Page Size Extensions.
6652 UINT32 PAE
:1; ///< Physical Address Extension.
6653 UINT32 MCE
:1; ///< Machine Check Enable.
6654 UINT32 PGE
:1; ///< Page Global Enable.
6655 UINT32 PCE
:1; ///< Performance Monitoring Counter
6657 UINT32 OSFXSR
:1; ///< Operating System Support for
6658 ///< FXSAVE and FXRSTOR instructions
6659 UINT32 OSXMMEXCPT
:1; ///< Operating System Support for
6660 ///< Unmasked SIMD Floating Point
6662 UINT32 Reserved_0
:2; ///< Reserved.
6663 UINT32 VMXE
:1; ///< VMX Enable
6664 UINT32 Reserved_1
:18; ///< Reserved.
6670 /// Byte packed structure for a segment descriptor in a GDT/LDT.
6689 } IA32_SEGMENT_DESCRIPTOR
;
6692 /// Byte packed structure for an IDTR, GDTR, LDTR descriptor.
6701 #define IA32_IDT_GATE_TYPE_TASK 0x85
6702 #define IA32_IDT_GATE_TYPE_INTERRUPT_16 0x86
6703 #define IA32_IDT_GATE_TYPE_TRAP_16 0x87
6704 #define IA32_IDT_GATE_TYPE_INTERRUPT_32 0x8E
6705 #define IA32_IDT_GATE_TYPE_TRAP_32 0x8F
6707 #define IA32_GDT_TYPE_TSS 0x9
6708 #define IA32_GDT_ALIGNMENT 8
6710 #if defined (MDE_CPU_IA32)
6712 /// Byte packed structure for an IA-32 Interrupt Gate Descriptor.
6716 UINT32 OffsetLow
:16; ///< Offset bits 15..0.
6717 UINT32 Selector
:16; ///< Selector.
6718 UINT32 Reserved_0
:8; ///< Reserved.
6719 UINT32 GateType
:8; ///< Gate Type. See #defines above.
6720 UINT32 OffsetHigh
:16; ///< Offset bits 31..16.
6723 } IA32_IDT_GATE_DESCRIPTOR
;
6727 // IA32 Task-State Segment Definition
6730 UINT16 PreviousTaskLink
;
6764 UINT16 LDTSegmentSelector
;
6767 UINT16 IOMapBaseAddress
;
6768 } IA32_TASK_STATE_SEGMENT
;
6772 UINT32 LimitLow
:16; ///< Segment Limit 15..00
6773 UINT32 BaseLow
:16; ///< Base Address 15..00
6774 UINT32 BaseMid
:8; ///< Base Address 23..16
6775 UINT32 Type
:4; ///< Type (1 0 B 1)
6776 UINT32 Reserved_43
:1; ///< 0
6777 UINT32 DPL
:2; ///< Descriptor Privilege Level
6778 UINT32 P
:1; ///< Segment Present
6779 UINT32 LimitHigh
:4; ///< Segment Limit 19..16
6780 UINT32 AVL
:1; ///< Available for use by system software
6781 UINT32 Reserved_52
:2; ///< 0 0
6782 UINT32 G
:1; ///< Granularity
6783 UINT32 BaseHigh
:8; ///< Base Address 31..24
6786 } IA32_TSS_DESCRIPTOR
;
6789 #endif // defined (MDE_CPU_IA32)
6791 #if defined (MDE_CPU_X64)
6793 /// Byte packed structure for an x64 Interrupt Gate Descriptor.
6797 UINT32 OffsetLow
:16; ///< Offset bits 15..0.
6798 UINT32 Selector
:16; ///< Selector.
6799 UINT32 Reserved_0
:8; ///< Reserved.
6800 UINT32 GateType
:8; ///< Gate Type. See #defines above.
6801 UINT32 OffsetHigh
:16; ///< Offset bits 31..16.
6802 UINT32 OffsetUpper
:32; ///< Offset bits 63..32.
6803 UINT32 Reserved_1
:32; ///< Reserved.
6809 } IA32_IDT_GATE_DESCRIPTOR
;
6813 // IA32 Task-State Segment Definition
6823 UINT16 Reserved_100
;
6824 UINT16 IOMapBaseAddress
;
6825 } IA32_TASK_STATE_SEGMENT
;
6829 UINT32 LimitLow
:16; ///< Segment Limit 15..00
6830 UINT32 BaseLow
:16; ///< Base Address 15..00
6831 UINT32 BaseMidl
:8; ///< Base Address 23..16
6832 UINT32 Type
:4; ///< Type (1 0 B 1)
6833 UINT32 Reserved_43
:1; ///< 0
6834 UINT32 DPL
:2; ///< Descriptor Privilege Level
6835 UINT32 P
:1; ///< Segment Present
6836 UINT32 LimitHigh
:4; ///< Segment Limit 19..16
6837 UINT32 AVL
:1; ///< Available for use by system software
6838 UINT32 Reserved_52
:2; ///< 0 0
6839 UINT32 G
:1; ///< Granularity
6840 UINT32 BaseMidh
:8; ///< Base Address 31..24
6841 UINT32 BaseHigh
:32; ///< Base Address 63..32
6842 UINT32 Reserved_96
:32; ///< Reserved
6848 } IA32_TSS_DESCRIPTOR
;
6851 #endif // defined (MDE_CPU_X64)
6854 /// Byte packed structure for an FP/SSE/SSE2 context.
6861 /// Structures for the 16-bit real mode thunks.
6914 IA32_EFLAGS32 EFLAGS
;
6924 } IA32_REGISTER_SET
;
6927 /// Byte packed structure for an 16-bit real mode thunks.
6930 IA32_REGISTER_SET
*RealModeState
;
6931 VOID
*RealModeBuffer
;
6932 UINT32 RealModeBufferSize
;
6933 UINT32 ThunkAttributes
;
6936 #define THUNK_ATTRIBUTE_BIG_REAL_MODE 0x00000001
6937 #define THUNK_ATTRIBUTE_DISABLE_A20_MASK_INT_15 0x00000002
6938 #define THUNK_ATTRIBUTE_DISABLE_A20_MASK_KBD_CTRL 0x00000004
6941 /// Type definition for representing labels in NASM source code that allow for
6942 /// the patching of immediate operands of IA32 and X64 instructions.
6944 /// While the type is technically defined as a function type (note: not a
6945 /// pointer-to-function type), such labels in NASM source code never stand for
6946 /// actual functions, and identifiers declared with this function type should
6947 /// never be called. This is also why the EFIAPI calling convention specifier
6948 /// is missing from the typedef, and why the typedef does not follow the usual
6949 /// edk2 coding style for function (or pointer-to-function) typedefs. The VOID
6950 /// return type and the VOID argument list are merely artifacts.
6952 typedef VOID (X86_ASSEMBLY_PATCH_LABEL
) (VOID
);
6955 Retrieves CPUID information.
6957 Executes the CPUID instruction with EAX set to the value specified by Index.
6958 This function always returns Index.
6959 If Eax is not NULL, then the value of EAX after CPUID is returned in Eax.
6960 If Ebx is not NULL, then the value of EBX after CPUID is returned in Ebx.
6961 If Ecx is not NULL, then the value of ECX after CPUID is returned in Ecx.
6962 If Edx is not NULL, then the value of EDX after CPUID is returned in Edx.
6963 This function is only available on IA-32 and x64.
6965 @param Index The 32-bit value to load into EAX prior to invoking the CPUID
6967 @param Eax The pointer to the 32-bit EAX value returned by the CPUID
6968 instruction. This is an optional parameter that may be NULL.
6969 @param Ebx The pointer to the 32-bit EBX value returned by the CPUID
6970 instruction. This is an optional parameter that may be NULL.
6971 @param Ecx The pointer to the 32-bit ECX value returned by the CPUID
6972 instruction. This is an optional parameter that may be NULL.
6973 @param Edx The pointer to the 32-bit EDX value returned by the CPUID
6974 instruction. This is an optional parameter that may be NULL.
6983 OUT UINT32
*Eax
, OPTIONAL
6984 OUT UINT32
*Ebx
, OPTIONAL
6985 OUT UINT32
*Ecx
, OPTIONAL
6986 OUT UINT32
*Edx OPTIONAL
6991 Retrieves CPUID information using an extended leaf identifier.
6993 Executes the CPUID instruction with EAX set to the value specified by Index
6994 and ECX set to the value specified by SubIndex. This function always returns
6995 Index. This function is only available on IA-32 and x64.
6997 If Eax is not NULL, then the value of EAX after CPUID is returned in Eax.
6998 If Ebx is not NULL, then the value of EBX after CPUID is returned in Ebx.
6999 If Ecx is not NULL, then the value of ECX after CPUID is returned in Ecx.
7000 If Edx is not NULL, then the value of EDX after CPUID is returned in Edx.
7002 @param Index The 32-bit value to load into EAX prior to invoking the
7004 @param SubIndex The 32-bit value to load into ECX prior to invoking the
7006 @param Eax The pointer to the 32-bit EAX value returned by the CPUID
7007 instruction. This is an optional parameter that may be
7009 @param Ebx The pointer to the 32-bit EBX value returned by the CPUID
7010 instruction. This is an optional parameter that may be
7012 @param Ecx The pointer to the 32-bit ECX value returned by the CPUID
7013 instruction. This is an optional parameter that may be
7015 @param Edx The pointer to the 32-bit EDX value returned by the CPUID
7016 instruction. This is an optional parameter that may be
7027 OUT UINT32
*Eax
, OPTIONAL
7028 OUT UINT32
*Ebx
, OPTIONAL
7029 OUT UINT32
*Ecx
, OPTIONAL
7030 OUT UINT32
*Edx OPTIONAL
7035 Set CD bit and clear NW bit of CR0 followed by a WBINVD.
7037 Disables the caches by setting the CD bit of CR0 to 1, clearing the NW bit of CR0 to 0,
7038 and executing a WBINVD instruction. This function is only available on IA-32 and x64.
7049 Perform a WBINVD and clear both the CD and NW bits of CR0.
7051 Enables the caches by executing a WBINVD instruction and then clear both the CD and NW
7052 bits of CR0 to 0. This function is only available on IA-32 and x64.
7063 Returns the lower 32-bits of a Machine Specific Register(MSR).
7065 Reads and returns the lower 32-bits of the MSR specified by Index.
7066 No parameter checking is performed on Index, and some Index values may cause
7067 CPU exceptions. The caller must either guarantee that Index is valid, or the
7068 caller must set up exception handlers to catch the exceptions. This function
7069 is only available on IA-32 and x64.
7071 @param Index The 32-bit MSR index to read.
7073 @return The lower 32 bits of the MSR identified by Index.
7084 Writes a 32-bit value to a Machine Specific Register(MSR), and returns the value.
7085 The upper 32-bits of the MSR are set to zero.
7087 Writes the 32-bit value specified by Value to the MSR specified by Index. The
7088 upper 32-bits of the MSR write are set to zero. The 32-bit value written to
7089 the MSR is returned. No parameter checking is performed on Index or Value,
7090 and some of these may cause CPU exceptions. The caller must either guarantee
7091 that Index and Value are valid, or the caller must establish proper exception
7092 handlers. This function is only available on IA-32 and x64.
7094 @param Index The 32-bit MSR index to write.
7095 @param Value The 32-bit value to write to the MSR.
7109 Reads a 64-bit MSR, performs a bitwise OR on the lower 32-bits, and
7110 writes the result back to the 64-bit MSR.
7112 Reads the 64-bit MSR specified by Index, performs a bitwise OR
7113 between the lower 32-bits of the read result and the value specified by
7114 OrData, and writes the result to the 64-bit MSR specified by Index. The lower
7115 32-bits of the value written to the MSR is returned. No parameter checking is
7116 performed on Index or OrData, and some of these may cause CPU exceptions. The
7117 caller must either guarantee that Index and OrData are valid, or the caller
7118 must establish proper exception handlers. This function is only available on
7121 @param Index The 32-bit MSR index to write.
7122 @param OrData The value to OR with the read value from the MSR.
7124 @return The lower 32-bit value written to the MSR.
7136 Reads a 64-bit MSR, performs a bitwise AND on the lower 32-bits, and writes
7137 the result back to the 64-bit MSR.
7139 Reads the 64-bit MSR specified by Index, performs a bitwise AND between the
7140 lower 32-bits of the read result and the value specified by AndData, and
7141 writes the result to the 64-bit MSR specified by Index. The lower 32-bits of
7142 the value written to the MSR is returned. No parameter checking is performed
7143 on Index or AndData, and some of these may cause CPU exceptions. The caller
7144 must either guarantee that Index and AndData are valid, or the caller must
7145 establish proper exception handlers. This function is only available on IA-32
7148 @param Index The 32-bit MSR index to write.
7149 @param AndData The value to AND with the read value from the MSR.
7151 @return The lower 32-bit value written to the MSR.
7163 Reads a 64-bit MSR, performs a bitwise AND followed by a bitwise OR
7164 on the lower 32-bits, and writes the result back to the 64-bit MSR.
7166 Reads the 64-bit MSR specified by Index, performs a bitwise AND between the
7167 lower 32-bits of the read result and the value specified by AndData
7168 preserving the upper 32-bits, performs a bitwise OR between the
7169 result of the AND operation and the value specified by OrData, and writes the
7170 result to the 64-bit MSR specified by Address. The lower 32-bits of the value
7171 written to the MSR is returned. No parameter checking is performed on Index,
7172 AndData, or OrData, and some of these may cause CPU exceptions. The caller
7173 must either guarantee that Index, AndData, and OrData are valid, or the
7174 caller must establish proper exception handlers. This function is only
7175 available on IA-32 and x64.
7177 @param Index The 32-bit MSR index to write.
7178 @param AndData The value to AND with the read value from the MSR.
7179 @param OrData The value to OR with the result of the AND operation.
7181 @return The lower 32-bit value written to the MSR.
7194 Reads a bit field of an MSR.
7196 Reads the bit field in the lower 32-bits of a 64-bit MSR. The bit field is
7197 specified by the StartBit and the EndBit. The value of the bit field is
7198 returned. The caller must either guarantee that Index is valid, or the caller
7199 must set up exception handlers to catch the exceptions. This function is only
7200 available on IA-32 and x64.
7202 If StartBit is greater than 31, then ASSERT().
7203 If EndBit is greater than 31, then ASSERT().
7204 If EndBit is less than StartBit, then ASSERT().
7206 @param Index The 32-bit MSR index to read.
7207 @param StartBit The ordinal of the least significant bit in the bit field.
7209 @param EndBit The ordinal of the most significant bit in the bit field.
7212 @return The bit field read from the MSR.
7217 AsmMsrBitFieldRead32 (
7225 Writes a bit field to an MSR.
7227 Writes Value to a bit field in the lower 32-bits of a 64-bit MSR. The bit
7228 field is specified by the StartBit and the EndBit. All other bits in the
7229 destination MSR are preserved. The lower 32-bits of the MSR written is
7230 returned. The caller must either guarantee that Index and the data written
7231 is valid, or the caller must set up exception handlers to catch the exceptions.
7232 This function is only available on IA-32 and x64.
7234 If StartBit is greater than 31, then ASSERT().
7235 If EndBit is greater than 31, then ASSERT().
7236 If EndBit is less than StartBit, then ASSERT().
7237 If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
7239 @param Index The 32-bit MSR index to write.
7240 @param StartBit The ordinal of the least significant bit in the bit field.
7242 @param EndBit The ordinal of the most significant bit in the bit field.
7244 @param Value New value of the bit field.
7246 @return The lower 32-bit of the value written to the MSR.
7251 AsmMsrBitFieldWrite32 (
7260 Reads a bit field in a 64-bit MSR, performs a bitwise OR, and writes the
7261 result back to the bit field in the 64-bit MSR.
7263 Reads the 64-bit MSR specified by Index, performs a bitwise OR
7264 between the read result and the value specified by OrData, and writes the
7265 result to the 64-bit MSR specified by Index. The lower 32-bits of the value
7266 written to the MSR are returned. Extra left bits in OrData are stripped. The
7267 caller must either guarantee that Index and the data written is valid, or
7268 the caller must set up exception handlers to catch the exceptions. This
7269 function is only available on IA-32 and x64.
7271 If StartBit is greater than 31, then ASSERT().
7272 If EndBit is greater than 31, then ASSERT().
7273 If EndBit is less than StartBit, then ASSERT().
7274 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
7276 @param Index The 32-bit MSR index to write.
7277 @param StartBit The ordinal of the least significant bit in the bit field.
7279 @param EndBit The ordinal of the most significant bit in the bit field.
7281 @param OrData The value to OR with the read value from the MSR.
7283 @return The lower 32-bit of the value written to the MSR.
7288 AsmMsrBitFieldOr32 (
7297 Reads a bit field in a 64-bit MSR, performs a bitwise AND, and writes the
7298 result back to the bit field in the 64-bit MSR.
7300 Reads the 64-bit MSR specified by Index, performs a bitwise AND between the
7301 read result and the value specified by AndData, and writes the result to the
7302 64-bit MSR specified by Index. The lower 32-bits of the value written to the
7303 MSR are returned. Extra left bits in AndData are stripped. The caller must
7304 either guarantee that Index and the data written is valid, or the caller must
7305 set up exception handlers to catch the exceptions. This function is only
7306 available on IA-32 and x64.
7308 If StartBit is greater than 31, then ASSERT().
7309 If EndBit is greater than 31, then ASSERT().
7310 If EndBit is less than StartBit, then ASSERT().
7311 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
7313 @param Index The 32-bit MSR index to write.
7314 @param StartBit The ordinal of the least significant bit in the bit field.
7316 @param EndBit The ordinal of the most significant bit in the bit field.
7318 @param AndData The value to AND with the read value from the MSR.
7320 @return The lower 32-bit of the value written to the MSR.
7325 AsmMsrBitFieldAnd32 (
7334 Reads a bit field in a 64-bit MSR, performs a bitwise AND followed by a
7335 bitwise OR, and writes the result back to the bit field in the
7338 Reads the 64-bit MSR specified by Index, performs a bitwise AND followed by a
7339 bitwise OR between the read result and the value specified by
7340 AndData, and writes the result to the 64-bit MSR specified by Index. The
7341 lower 32-bits of the value written to the MSR are returned. Extra left bits
7342 in both AndData and OrData are stripped. The caller must either guarantee
7343 that Index and the data written is valid, or the caller must set up exception
7344 handlers to catch the exceptions. This function is only available on IA-32
7347 If StartBit is greater than 31, then ASSERT().
7348 If EndBit is greater than 31, then ASSERT().
7349 If EndBit is less than StartBit, then ASSERT().
7350 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
7351 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
7353 @param Index The 32-bit MSR index to write.
7354 @param StartBit The ordinal of the least significant bit in the bit field.
7356 @param EndBit The ordinal of the most significant bit in the bit field.
7358 @param AndData The value to AND with the read value from the MSR.
7359 @param OrData The value to OR with the result of the AND operation.
7361 @return The lower 32-bit of the value written to the MSR.
7366 AsmMsrBitFieldAndThenOr32 (
7376 Returns a 64-bit Machine Specific Register(MSR).
7378 Reads and returns the 64-bit MSR specified by Index. No parameter checking is
7379 performed on Index, and some Index values may cause CPU exceptions. The
7380 caller must either guarantee that Index is valid, or the caller must set up
7381 exception handlers to catch the exceptions. This function is only available
7384 @param Index The 32-bit MSR index to read.
7386 @return The value of the MSR identified by Index.
7397 Writes a 64-bit value to a Machine Specific Register(MSR), and returns the
7400 Writes the 64-bit value specified by Value to the MSR specified by Index. The
7401 64-bit value written to the MSR is returned. No parameter checking is
7402 performed on Index or Value, and some of these may cause CPU exceptions. The
7403 caller must either guarantee that Index and Value are valid, or the caller
7404 must establish proper exception handlers. This function is only available on
7407 @param Index The 32-bit MSR index to write.
7408 @param Value The 64-bit value to write to the MSR.
7422 Reads a 64-bit MSR, performs a bitwise OR, and writes the result
7423 back to the 64-bit MSR.
7425 Reads the 64-bit MSR specified by Index, performs a bitwise OR
7426 between the read result and the value specified by OrData, and writes the
7427 result to the 64-bit MSR specified by Index. The value written to the MSR is
7428 returned. No parameter checking is performed on Index or OrData, and some of
7429 these may cause CPU exceptions. The caller must either guarantee that Index
7430 and OrData are valid, or the caller must establish proper exception handlers.
7431 This function is only available on IA-32 and x64.
7433 @param Index The 32-bit MSR index to write.
7434 @param OrData The value to OR with the read value from the MSR.
7436 @return The value written back to the MSR.
7448 Reads a 64-bit MSR, performs a bitwise AND, and writes the result back to the
7451 Reads the 64-bit MSR specified by Index, performs a bitwise AND between the
7452 read result and the value specified by OrData, and writes the result to the
7453 64-bit MSR specified by Index. The value written to the MSR is returned. No
7454 parameter checking is performed on Index or OrData, and some of these may
7455 cause CPU exceptions. The caller must either guarantee that Index and OrData
7456 are valid, or the caller must establish proper exception handlers. This
7457 function is only available on IA-32 and x64.
7459 @param Index The 32-bit MSR index to write.
7460 @param AndData The value to AND with the read value from the MSR.
7462 @return The value written back to the MSR.
7474 Reads a 64-bit MSR, performs a bitwise AND followed by a bitwise
7475 OR, and writes the result back to the 64-bit MSR.
7477 Reads the 64-bit MSR specified by Index, performs a bitwise AND between read
7478 result and the value specified by AndData, performs a bitwise OR
7479 between the result of the AND operation and the value specified by OrData,
7480 and writes the result to the 64-bit MSR specified by Index. The value written
7481 to the MSR is returned. No parameter checking is performed on Index, AndData,
7482 or OrData, and some of these may cause CPU exceptions. The caller must either
7483 guarantee that Index, AndData, and OrData are valid, or the caller must
7484 establish proper exception handlers. This function is only available on IA-32
7487 @param Index The 32-bit MSR index to write.
7488 @param AndData The value to AND with the read value from the MSR.
7489 @param OrData The value to OR with the result of the AND operation.
7491 @return The value written back to the MSR.
7504 Reads a bit field of an MSR.
7506 Reads the bit field in the 64-bit MSR. The bit field is specified by the
7507 StartBit and the EndBit. The value of the bit field is returned. The caller
7508 must either guarantee that Index is valid, or the caller must set up
7509 exception handlers to catch the exceptions. This function is only available
7512 If StartBit is greater than 63, then ASSERT().
7513 If EndBit is greater than 63, then ASSERT().
7514 If EndBit is less than StartBit, then ASSERT().
7516 @param Index The 32-bit MSR index to read.
7517 @param StartBit The ordinal of the least significant bit in the bit field.
7519 @param EndBit The ordinal of the most significant bit in the bit field.
7522 @return The value read from the MSR.
7527 AsmMsrBitFieldRead64 (
7535 Writes a bit field to an MSR.
7537 Writes Value to a bit field in a 64-bit MSR. The bit field is specified by
7538 the StartBit and the EndBit. All other bits in the destination MSR are
7539 preserved. The MSR written is returned. The caller must either guarantee
7540 that Index and the data written is valid, or the caller must set up exception
7541 handlers to catch the exceptions. This function is only available on IA-32 and x64.
7543 If StartBit is greater than 63, then ASSERT().
7544 If EndBit is greater than 63, then ASSERT().
7545 If EndBit is less than StartBit, then ASSERT().
7546 If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
7548 @param Index The 32-bit MSR index to write.
7549 @param StartBit The ordinal of the least significant bit in the bit field.
7551 @param EndBit The ordinal of the most significant bit in the bit field.
7553 @param Value New value of the bit field.
7555 @return The value written back to the MSR.
7560 AsmMsrBitFieldWrite64 (
7569 Reads a bit field in a 64-bit MSR, performs a bitwise OR, and
7570 writes the result back to the bit field in the 64-bit MSR.
7572 Reads the 64-bit MSR specified by Index, performs a bitwise OR
7573 between the read result and the value specified by OrData, and writes the
7574 result to the 64-bit MSR specified by Index. The value written to the MSR is
7575 returned. Extra left bits in OrData are stripped. The caller must either
7576 guarantee that Index and the data written is valid, or the caller must set up
7577 exception handlers to catch the exceptions. This function is only available
7580 If StartBit is greater than 63, then ASSERT().
7581 If EndBit is greater than 63, then ASSERT().
7582 If EndBit is less than StartBit, then ASSERT().
7583 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
7585 @param Index The 32-bit MSR index to write.
7586 @param StartBit The ordinal of the least significant bit in the bit field.
7588 @param EndBit The ordinal of the most significant bit in the bit field.
7590 @param OrData The value to OR with the read value from the bit field.
7592 @return The value written back to the MSR.
7597 AsmMsrBitFieldOr64 (
7606 Reads a bit field in a 64-bit MSR, performs a bitwise AND, and writes the
7607 result back to the bit field in the 64-bit MSR.
7609 Reads the 64-bit MSR specified by Index, performs a bitwise AND between the
7610 read result and the value specified by AndData, and writes the result to the
7611 64-bit MSR specified by Index. The value written to the MSR is returned.
7612 Extra left bits in AndData are stripped. The caller must either guarantee
7613 that Index and the data written is valid, or the caller must set up exception
7614 handlers to catch the exceptions. This function is only available on IA-32
7617 If StartBit is greater than 63, then ASSERT().
7618 If EndBit is greater than 63, then ASSERT().
7619 If EndBit is less than StartBit, then ASSERT().
7620 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
7622 @param Index The 32-bit MSR index to write.
7623 @param StartBit The ordinal of the least significant bit in the bit field.
7625 @param EndBit The ordinal of the most significant bit in the bit field.
7627 @param AndData The value to AND with the read value from the bit field.
7629 @return The value written back to the MSR.
7634 AsmMsrBitFieldAnd64 (
7643 Reads a bit field in a 64-bit MSR, performs a bitwise AND followed by a
7644 bitwise OR, and writes the result back to the bit field in the
7647 Reads the 64-bit MSR specified by Index, performs a bitwise AND followed by
7648 a bitwise OR between the read result and the value specified by
7649 AndData, and writes the result to the 64-bit MSR specified by Index. The
7650 value written to the MSR is returned. Extra left bits in both AndData and
7651 OrData are stripped. The caller must either guarantee that Index and the data
7652 written is valid, or the caller must set up exception handlers to catch the
7653 exceptions. This function is only available on IA-32 and x64.
7655 If StartBit is greater than 63, then ASSERT().
7656 If EndBit is greater than 63, then ASSERT().
7657 If EndBit is less than StartBit, then ASSERT().
7658 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
7659 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
7661 @param Index The 32-bit MSR index to write.
7662 @param StartBit The ordinal of the least significant bit in the bit field.
7664 @param EndBit The ordinal of the most significant bit in the bit field.
7666 @param AndData The value to AND with the read value from the bit field.
7667 @param OrData The value to OR with the result of the AND operation.
7669 @return The value written back to the MSR.
7674 AsmMsrBitFieldAndThenOr64 (
7684 Reads the current value of the EFLAGS register.
7686 Reads and returns the current value of the EFLAGS register. This function is
7687 only available on IA-32 and x64. This returns a 32-bit value on IA-32 and a
7688 64-bit value on x64.
7690 @return EFLAGS on IA-32 or RFLAGS on x64.
7701 Reads the current value of the Control Register 0 (CR0).
7703 Reads and returns the current value of CR0. This function is only available
7704 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
7707 @return The value of the Control Register 0 (CR0).
7718 Reads the current value of the Control Register 2 (CR2).
7720 Reads and returns the current value of CR2. This function is only available
7721 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
7724 @return The value of the Control Register 2 (CR2).
7735 Reads the current value of the Control Register 3 (CR3).
7737 Reads and returns the current value of CR3. This function is only available
7738 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
7741 @return The value of the Control Register 3 (CR3).
7752 Reads the current value of the Control Register 4 (CR4).
7754 Reads and returns the current value of CR4. This function is only available
7755 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
7758 @return The value of the Control Register 4 (CR4).
7769 Writes a value to Control Register 0 (CR0).
7771 Writes and returns a new value to CR0. This function is only available on
7772 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
7774 @param Cr0 The value to write to CR0.
7776 @return The value written to CR0.
7787 Writes a value to Control Register 2 (CR2).
7789 Writes and returns a new value to CR2. This function is only available on
7790 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
7792 @param Cr2 The value to write to CR2.
7794 @return The value written to CR2.
7805 Writes a value to Control Register 3 (CR3).
7807 Writes and returns a new value to CR3. This function is only available on
7808 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
7810 @param Cr3 The value to write to CR3.
7812 @return The value written to CR3.
7823 Writes a value to Control Register 4 (CR4).
7825 Writes and returns a new value to CR4. This function is only available on
7826 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
7828 @param Cr4 The value to write to CR4.
7830 @return The value written to CR4.
7841 Reads the current value of Debug Register 0 (DR0).
7843 Reads and returns the current value of DR0. This function is only available
7844 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
7847 @return The value of Debug Register 0 (DR0).
7858 Reads the current value of Debug Register 1 (DR1).
7860 Reads and returns the current value of DR1. This function is only available
7861 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
7864 @return The value of Debug Register 1 (DR1).
7875 Reads the current value of Debug Register 2 (DR2).
7877 Reads and returns the current value of DR2. This function is only available
7878 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
7881 @return The value of Debug Register 2 (DR2).
7892 Reads the current value of Debug Register 3 (DR3).
7894 Reads and returns the current value of DR3. This function is only available
7895 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
7898 @return The value of Debug Register 3 (DR3).
7909 Reads the current value of Debug Register 4 (DR4).
7911 Reads and returns the current value of DR4. This function is only available
7912 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
7915 @return The value of Debug Register 4 (DR4).
7926 Reads the current value of Debug Register 5 (DR5).
7928 Reads and returns the current value of DR5. This function is only available
7929 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
7932 @return The value of Debug Register 5 (DR5).
7943 Reads the current value of Debug Register 6 (DR6).
7945 Reads and returns the current value of DR6. This function is only available
7946 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
7949 @return The value of Debug Register 6 (DR6).
7960 Reads the current value of Debug Register 7 (DR7).
7962 Reads and returns the current value of DR7. This function is only available
7963 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
7966 @return The value of Debug Register 7 (DR7).
7977 Writes a value to Debug Register 0 (DR0).
7979 Writes and returns a new value to DR0. This function is only available on
7980 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
7982 @param Dr0 The value to write to Dr0.
7984 @return The value written to Debug Register 0 (DR0).
7995 Writes a value to Debug Register 1 (DR1).
7997 Writes and returns a new value to DR1. This function is only available on
7998 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
8000 @param Dr1 The value to write to Dr1.
8002 @return The value written to Debug Register 1 (DR1).
8013 Writes a value to Debug Register 2 (DR2).
8015 Writes and returns a new value to DR2. This function is only available on
8016 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
8018 @param Dr2 The value to write to Dr2.
8020 @return The value written to Debug Register 2 (DR2).
8031 Writes a value to Debug Register 3 (DR3).
8033 Writes and returns a new value to DR3. This function is only available on
8034 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
8036 @param Dr3 The value to write to Dr3.
8038 @return The value written to Debug Register 3 (DR3).
8049 Writes a value to Debug Register 4 (DR4).
8051 Writes and returns a new value to DR4. This function is only available on
8052 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
8054 @param Dr4 The value to write to Dr4.
8056 @return The value written to Debug Register 4 (DR4).
8067 Writes a value to Debug Register 5 (DR5).
8069 Writes and returns a new value to DR5. This function is only available on
8070 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
8072 @param Dr5 The value to write to Dr5.
8074 @return The value written to Debug Register 5 (DR5).
8085 Writes a value to Debug Register 6 (DR6).
8087 Writes and returns a new value to DR6. This function is only available on
8088 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
8090 @param Dr6 The value to write to Dr6.
8092 @return The value written to Debug Register 6 (DR6).
8103 Writes a value to Debug Register 7 (DR7).
8105 Writes and returns a new value to DR7. This function is only available on
8106 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
8108 @param Dr7 The value to write to Dr7.
8110 @return The value written to Debug Register 7 (DR7).
8121 Reads the current value of Code Segment Register (CS).
8123 Reads and returns the current value of CS. This function is only available on
8126 @return The current value of CS.
8137 Reads the current value of Data Segment Register (DS).
8139 Reads and returns the current value of DS. This function is only available on
8142 @return The current value of DS.
8153 Reads the current value of Extra Segment Register (ES).
8155 Reads and returns the current value of ES. This function is only available on
8158 @return The current value of ES.
8169 Reads the current value of FS Data Segment Register (FS).
8171 Reads and returns the current value of FS. This function is only available on
8174 @return The current value of FS.
8185 Reads the current value of GS Data Segment Register (GS).
8187 Reads and returns the current value of GS. This function is only available on
8190 @return The current value of GS.
8201 Reads the current value of Stack Segment Register (SS).
8203 Reads and returns the current value of SS. This function is only available on
8206 @return The current value of SS.
8217 Reads the current value of Task Register (TR).
8219 Reads and returns the current value of TR. This function is only available on
8222 @return The current value of TR.
8233 Reads the current Global Descriptor Table Register(GDTR) descriptor.
8235 Reads and returns the current GDTR descriptor and returns it in Gdtr. This
8236 function is only available on IA-32 and x64.
8238 If Gdtr is NULL, then ASSERT().
8240 @param Gdtr The pointer to a GDTR descriptor.
8246 OUT IA32_DESCRIPTOR
*Gdtr
8251 Writes the current Global Descriptor Table Register (GDTR) descriptor.
8253 Writes and the current GDTR descriptor specified by Gdtr. This function is
8254 only available on IA-32 and x64.
8256 If Gdtr is NULL, then ASSERT().
8258 @param Gdtr The pointer to a GDTR descriptor.
8264 IN CONST IA32_DESCRIPTOR
*Gdtr
8269 Reads the current Interrupt Descriptor Table Register(IDTR) descriptor.
8271 Reads and returns the current IDTR descriptor and returns it in Idtr. This
8272 function is only available on IA-32 and x64.
8274 If Idtr is NULL, then ASSERT().
8276 @param Idtr The pointer to a IDTR descriptor.
8282 OUT IA32_DESCRIPTOR
*Idtr
8287 Writes the current Interrupt Descriptor Table Register(IDTR) descriptor.
8289 Writes the current IDTR descriptor and returns it in Idtr. This function is
8290 only available on IA-32 and x64.
8292 If Idtr is NULL, then ASSERT().
8294 @param Idtr The pointer to a IDTR descriptor.
8300 IN CONST IA32_DESCRIPTOR
*Idtr
8305 Reads the current Local Descriptor Table Register(LDTR) selector.
8307 Reads and returns the current 16-bit LDTR descriptor value. This function is
8308 only available on IA-32 and x64.
8310 @return The current selector of LDT.
8321 Writes the current Local Descriptor Table Register (LDTR) selector.
8323 Writes and the current LDTR descriptor specified by Ldtr. This function is
8324 only available on IA-32 and x64.
8326 @param Ldtr 16-bit LDTR selector value.
8337 Save the current floating point/SSE/SSE2 context to a buffer.
8339 Saves the current floating point/SSE/SSE2 state to the buffer specified by
8340 Buffer. Buffer must be aligned on a 16-byte boundary. This function is only
8341 available on IA-32 and x64.
8343 If Buffer is NULL, then ASSERT().
8344 If Buffer is not aligned on a 16-byte boundary, then ASSERT().
8346 @param Buffer The pointer to a buffer to save the floating point/SSE/SSE2 context.
8352 OUT IA32_FX_BUFFER
*Buffer
8357 Restores the current floating point/SSE/SSE2 context from a buffer.
8359 Restores the current floating point/SSE/SSE2 state from the buffer specified
8360 by Buffer. Buffer must be aligned on a 16-byte boundary. This function is
8361 only available on IA-32 and x64.
8363 If Buffer is NULL, then ASSERT().
8364 If Buffer is not aligned on a 16-byte boundary, then ASSERT().
8365 If Buffer was not saved with AsmFxSave(), then ASSERT().
8367 @param Buffer The pointer to a buffer to save the floating point/SSE/SSE2 context.
8373 IN CONST IA32_FX_BUFFER
*Buffer
8378 Reads the current value of 64-bit MMX Register #0 (MM0).
8380 Reads and returns the current value of MM0. This function is only available
8383 @return The current value of MM0.
8394 Reads the current value of 64-bit MMX Register #1 (MM1).
8396 Reads and returns the current value of MM1. This function is only available
8399 @return The current value of MM1.
8410 Reads the current value of 64-bit MMX Register #2 (MM2).
8412 Reads and returns the current value of MM2. This function is only available
8415 @return The current value of MM2.
8426 Reads the current value of 64-bit MMX Register #3 (MM3).
8428 Reads and returns the current value of MM3. This function is only available
8431 @return The current value of MM3.
8442 Reads the current value of 64-bit MMX Register #4 (MM4).
8444 Reads and returns the current value of MM4. This function is only available
8447 @return The current value of MM4.
8458 Reads the current value of 64-bit MMX Register #5 (MM5).
8460 Reads and returns the current value of MM5. This function is only available
8463 @return The current value of MM5.
8474 Reads the current value of 64-bit MMX Register #6 (MM6).
8476 Reads and returns the current value of MM6. This function is only available
8479 @return The current value of MM6.
8490 Reads the current value of 64-bit MMX Register #7 (MM7).
8492 Reads and returns the current value of MM7. This function is only available
8495 @return The current value of MM7.
8506 Writes the current value of 64-bit MMX Register #0 (MM0).
8508 Writes the current value of MM0. This function is only available on IA32 and
8511 @param Value The 64-bit value to write to MM0.
8522 Writes the current value of 64-bit MMX Register #1 (MM1).
8524 Writes the current value of MM1. This function is only available on IA32 and
8527 @param Value The 64-bit value to write to MM1.
8538 Writes the current value of 64-bit MMX Register #2 (MM2).
8540 Writes the current value of MM2. This function is only available on IA32 and
8543 @param Value The 64-bit value to write to MM2.
8554 Writes the current value of 64-bit MMX Register #3 (MM3).
8556 Writes the current value of MM3. This function is only available on IA32 and
8559 @param Value The 64-bit value to write to MM3.
8570 Writes the current value of 64-bit MMX Register #4 (MM4).
8572 Writes the current value of MM4. This function is only available on IA32 and
8575 @param Value The 64-bit value to write to MM4.
8586 Writes the current value of 64-bit MMX Register #5 (MM5).
8588 Writes the current value of MM5. This function is only available on IA32 and
8591 @param Value The 64-bit value to write to MM5.
8602 Writes the current value of 64-bit MMX Register #6 (MM6).
8604 Writes the current value of MM6. This function is only available on IA32 and
8607 @param Value The 64-bit value to write to MM6.
8618 Writes the current value of 64-bit MMX Register #7 (MM7).
8620 Writes the current value of MM7. This function is only available on IA32 and
8623 @param Value The 64-bit value to write to MM7.
8634 Reads the current value of Time Stamp Counter (TSC).
8636 Reads and returns the current value of TSC. This function is only available
8639 @return The current value of TSC
8650 Reads the current value of a Performance Counter (PMC).
8652 Reads and returns the current value of performance counter specified by
8653 Index. This function is only available on IA-32 and x64.
8655 @param Index The 32-bit Performance Counter index to read.
8657 @return The value of the PMC specified by Index.
8668 Sets up a monitor buffer that is used by AsmMwait().
8670 Executes a MONITOR instruction with the register state specified by Eax, Ecx
8671 and Edx. Returns Eax. This function is only available on IA-32 and x64.
8673 @param Eax The value to load into EAX or RAX before executing the MONITOR
8675 @param Ecx The value to load into ECX or RCX before executing the MONITOR
8677 @param Edx The value to load into EDX or RDX before executing the MONITOR
8693 Executes an MWAIT instruction.
8695 Executes an MWAIT instruction with the register state specified by Eax and
8696 Ecx. Returns Eax. This function is only available on IA-32 and x64.
8698 @param Eax The value to load into EAX or RAX before executing the MONITOR
8700 @param Ecx The value to load into ECX or RCX before executing the MONITOR
8715 Executes a WBINVD instruction.
8717 Executes a WBINVD instruction. This function is only available on IA-32 and
8729 Executes a INVD instruction.
8731 Executes a INVD instruction. This function is only available on IA-32 and
8743 Flushes a cache line from all the instruction and data caches within the
8744 coherency domain of the CPU.
8746 Flushed the cache line specified by LinearAddress, and returns LinearAddress.
8747 This function is only available on IA-32 and x64.
8749 @param LinearAddress The address of the cache line to flush. If the CPU is
8750 in a physical addressing mode, then LinearAddress is a
8751 physical address. If the CPU is in a virtual
8752 addressing mode, then LinearAddress is a virtual
8755 @return LinearAddress.
8760 IN VOID
*LinearAddress
8765 Enables the 32-bit paging mode on the CPU.
8767 Enables the 32-bit paging mode on the CPU. CR0, CR3, CR4, and the page tables
8768 must be properly initialized prior to calling this service. This function
8769 assumes the current execution mode is 32-bit protected mode. This function is
8770 only available on IA-32. After the 32-bit paging mode is enabled, control is
8771 transferred to the function specified by EntryPoint using the new stack
8772 specified by NewStack and passing in the parameters specified by Context1 and
8773 Context2. Context1 and Context2 are optional and may be NULL. The function
8774 EntryPoint must never return.
8776 If the current execution mode is not 32-bit protected mode, then ASSERT().
8777 If EntryPoint is NULL, then ASSERT().
8778 If NewStack is NULL, then ASSERT().
8780 There are a number of constraints that must be followed before calling this
8782 1) Interrupts must be disabled.
8783 2) The caller must be in 32-bit protected mode with flat descriptors. This
8784 means all descriptors must have a base of 0 and a limit of 4GB.
8785 3) CR0 and CR4 must be compatible with 32-bit protected mode with flat
8787 4) CR3 must point to valid page tables that will be used once the transition
8788 is complete, and those page tables must guarantee that the pages for this
8789 function and the stack are identity mapped.
8791 @param EntryPoint A pointer to function to call with the new stack after
8793 @param Context1 A pointer to the context to pass into the EntryPoint
8794 function as the first parameter after paging is enabled.
8795 @param Context2 A pointer to the context to pass into the EntryPoint
8796 function as the second parameter after paging is enabled.
8797 @param NewStack A pointer to the new stack to use for the EntryPoint
8798 function after paging is enabled.
8804 IN SWITCH_STACK_ENTRY_POINT EntryPoint
,
8805 IN VOID
*Context1
, OPTIONAL
8806 IN VOID
*Context2
, OPTIONAL
8812 Disables the 32-bit paging mode on the CPU.
8814 Disables the 32-bit paging mode on the CPU and returns to 32-bit protected
8815 mode. This function assumes the current execution mode is 32-paged protected
8816 mode. This function is only available on IA-32. After the 32-bit paging mode
8817 is disabled, control is transferred to the function specified by EntryPoint
8818 using the new stack specified by NewStack and passing in the parameters
8819 specified by Context1 and Context2. Context1 and Context2 are optional and
8820 may be NULL. The function EntryPoint must never return.
8822 If the current execution mode is not 32-bit paged mode, then ASSERT().
8823 If EntryPoint is NULL, then ASSERT().
8824 If NewStack is NULL, then ASSERT().
8826 There are a number of constraints that must be followed before calling this
8828 1) Interrupts must be disabled.
8829 2) The caller must be in 32-bit paged mode.
8830 3) CR0, CR3, and CR4 must be compatible with 32-bit paged mode.
8831 4) CR3 must point to valid page tables that guarantee that the pages for
8832 this function and the stack are identity mapped.
8834 @param EntryPoint A pointer to function to call with the new stack after
8836 @param Context1 A pointer to the context to pass into the EntryPoint
8837 function as the first parameter after paging is disabled.
8838 @param Context2 A pointer to the context to pass into the EntryPoint
8839 function as the second parameter after paging is
8841 @param NewStack A pointer to the new stack to use for the EntryPoint
8842 function after paging is disabled.
8847 AsmDisablePaging32 (
8848 IN SWITCH_STACK_ENTRY_POINT EntryPoint
,
8849 IN VOID
*Context1
, OPTIONAL
8850 IN VOID
*Context2
, OPTIONAL
8856 Enables the 64-bit paging mode on the CPU.
8858 Enables the 64-bit paging mode on the CPU. CR0, CR3, CR4, and the page tables
8859 must be properly initialized prior to calling this service. This function
8860 assumes the current execution mode is 32-bit protected mode with flat
8861 descriptors. This function is only available on IA-32. After the 64-bit
8862 paging mode is enabled, control is transferred to the function specified by
8863 EntryPoint using the new stack specified by NewStack and passing in the
8864 parameters specified by Context1 and Context2. Context1 and Context2 are
8865 optional and may be 0. The function EntryPoint must never return.
8867 If the current execution mode is not 32-bit protected mode with flat
8868 descriptors, then ASSERT().
8869 If EntryPoint is 0, then ASSERT().
8870 If NewStack is 0, then ASSERT().
8872 @param Cs The 16-bit selector to load in the CS before EntryPoint
8873 is called. The descriptor in the GDT that this selector
8874 references must be setup for long mode.
8875 @param EntryPoint The 64-bit virtual address of the function to call with
8876 the new stack after paging is enabled.
8877 @param Context1 The 64-bit virtual address of the context to pass into
8878 the EntryPoint function as the first parameter after
8880 @param Context2 The 64-bit virtual address of the context to pass into
8881 the EntryPoint function as the second parameter after
8883 @param NewStack The 64-bit virtual address of the new stack to use for
8884 the EntryPoint function after paging is enabled.
8891 IN UINT64 EntryPoint
,
8892 IN UINT64 Context1
, OPTIONAL
8893 IN UINT64 Context2
, OPTIONAL
8899 Disables the 64-bit paging mode on the CPU.
8901 Disables the 64-bit paging mode on the CPU and returns to 32-bit protected
8902 mode. This function assumes the current execution mode is 64-paging mode.
8903 This function is only available on x64. After the 64-bit paging mode is
8904 disabled, control is transferred to the function specified by EntryPoint
8905 using the new stack specified by NewStack and passing in the parameters
8906 specified by Context1 and Context2. Context1 and Context2 are optional and
8907 may be 0. The function EntryPoint must never return.
8909 If the current execution mode is not 64-bit paged mode, then ASSERT().
8910 If EntryPoint is 0, then ASSERT().
8911 If NewStack is 0, then ASSERT().
8913 @param Cs The 16-bit selector to load in the CS before EntryPoint
8914 is called. The descriptor in the GDT that this selector
8915 references must be setup for 32-bit protected mode.
8916 @param EntryPoint The 64-bit virtual address of the function to call with
8917 the new stack after paging is disabled.
8918 @param Context1 The 64-bit virtual address of the context to pass into
8919 the EntryPoint function as the first parameter after
8921 @param Context2 The 64-bit virtual address of the context to pass into
8922 the EntryPoint function as the second parameter after
8924 @param NewStack The 64-bit virtual address of the new stack to use for
8925 the EntryPoint function after paging is disabled.
8930 AsmDisablePaging64 (
8932 IN UINT32 EntryPoint
,
8933 IN UINT32 Context1
, OPTIONAL
8934 IN UINT32 Context2
, OPTIONAL
8940 // 16-bit thunking services
8944 Retrieves the properties for 16-bit thunk functions.
8946 Computes the size of the buffer and stack below 1MB required to use the
8947 AsmPrepareThunk16(), AsmThunk16() and AsmPrepareAndThunk16() functions. This
8948 buffer size is returned in RealModeBufferSize, and the stack size is returned
8949 in ExtraStackSize. If parameters are passed to the 16-bit real mode code,
8950 then the actual minimum stack size is ExtraStackSize plus the maximum number
8951 of bytes that need to be passed to the 16-bit real mode code.
8953 If RealModeBufferSize is NULL, then ASSERT().
8954 If ExtraStackSize is NULL, then ASSERT().
8956 @param RealModeBufferSize A pointer to the size of the buffer below 1MB
8957 required to use the 16-bit thunk functions.
8958 @param ExtraStackSize A pointer to the extra size of stack below 1MB
8959 that the 16-bit thunk functions require for
8960 temporary storage in the transition to and from
8966 AsmGetThunk16Properties (
8967 OUT UINT32
*RealModeBufferSize
,
8968 OUT UINT32
*ExtraStackSize
8973 Prepares all structures a code required to use AsmThunk16().
8975 Prepares all structures and code required to use AsmThunk16().
8977 This interface is limited to be used in either physical mode or virtual modes with paging enabled where the
8978 virtual to physical mappings for ThunkContext.RealModeBuffer is mapped 1:1.
8980 If ThunkContext is NULL, then ASSERT().
8982 @param ThunkContext A pointer to the context structure that describes the
8983 16-bit real mode code to call.
8989 IN OUT THUNK_CONTEXT
*ThunkContext
8994 Transfers control to a 16-bit real mode entry point and returns the results.
8996 Transfers control to a 16-bit real mode entry point and returns the results.
8997 AsmPrepareThunk16() must be called with ThunkContext before this function is used.
8998 This function must be called with interrupts disabled.
9000 The register state from the RealModeState field of ThunkContext is restored just prior
9001 to calling the 16-bit real mode entry point. This includes the EFLAGS field of RealModeState,
9002 which is used to set the interrupt state when a 16-bit real mode entry point is called.
9003 Control is transferred to the 16-bit real mode entry point specified by the CS and Eip fields of RealModeState.
9004 The stack is initialized to the SS and ESP fields of RealModeState. Any parameters passed to
9005 the 16-bit real mode code must be populated by the caller at SS:ESP prior to calling this function.
9006 The 16-bit real mode entry point is invoked with a 16-bit CALL FAR instruction,
9007 so when accessing stack contents, the 16-bit real mode code must account for the 16-bit segment
9008 and 16-bit offset of the return address that were pushed onto the stack. The 16-bit real mode entry
9009 point must exit with a RETF instruction. The register state is captured into RealModeState immediately
9010 after the RETF instruction is executed.
9012 If EFLAGS specifies interrupts enabled, or any of the 16-bit real mode code enables interrupts,
9013 or any of the 16-bit real mode code makes a SW interrupt, then the caller is responsible for making sure
9014 the IDT at address 0 is initialized to handle any HW or SW interrupts that may occur while in 16-bit real mode.
9016 If EFLAGS specifies interrupts enabled, or any of the 16-bit real mode code enables interrupts,
9017 then the caller is responsible for making sure the 8259 PIC is in a state compatible with 16-bit real mode.
9018 This includes the base vectors, the interrupt masks, and the edge/level trigger mode.
9020 If THUNK_ATTRIBUTE_BIG_REAL_MODE is set in the ThunkAttributes field of ThunkContext, then the user code
9021 is invoked in big real mode. Otherwise, the user code is invoked in 16-bit real mode with 64KB segment limits.
9023 If neither THUNK_ATTRIBUTE_DISABLE_A20_MASK_INT_15 nor THUNK_ATTRIBUTE_DISABLE_A20_MASK_KBD_CTRL are set in
9024 ThunkAttributes, then it is assumed that the user code did not enable the A20 mask, and no attempt is made to
9025 disable the A20 mask.
9027 If THUNK_ATTRIBUTE_DISABLE_A20_MASK_INT_15 is set and THUNK_ATTRIBUTE_DISABLE_A20_MASK_KBD_CTRL is clear in
9028 ThunkAttributes, then attempt to use the INT 15 service to disable the A20 mask. If this INT 15 call fails,
9029 then attempt to disable the A20 mask by directly accessing the 8042 keyboard controller I/O ports.
9031 If THUNK_ATTRIBUTE_DISABLE_A20_MASK_INT_15 is clear and THUNK_ATTRIBUTE_DISABLE_A20_MASK_KBD_CTRL is set in
9032 ThunkAttributes, then attempt to disable the A20 mask by directly accessing the 8042 keyboard controller I/O ports.
9034 If ThunkContext is NULL, then ASSERT().
9035 If AsmPrepareThunk16() was not previously called with ThunkContext, then ASSERT().
9036 If both THUNK_ATTRIBUTE_DISABLE_A20_MASK_INT_15 and THUNK_ATTRIBUTE_DISABLE_A20_MASK_KBD_CTRL are set in
9037 ThunkAttributes, then ASSERT().
9039 This interface is limited to be used in either physical mode or virtual modes with paging enabled where the
9040 virtual to physical mappings for ThunkContext.RealModeBuffer are mapped 1:1.
9042 @param ThunkContext A pointer to the context structure that describes the
9043 16-bit real mode code to call.
9049 IN OUT THUNK_CONTEXT
*ThunkContext
9054 Prepares all structures and code for a 16-bit real mode thunk, transfers
9055 control to a 16-bit real mode entry point, and returns the results.
9057 Prepares all structures and code for a 16-bit real mode thunk, transfers
9058 control to a 16-bit real mode entry point, and returns the results. If the
9059 caller only need to perform a single 16-bit real mode thunk, then this
9060 service should be used. If the caller intends to make more than one 16-bit
9061 real mode thunk, then it is more efficient if AsmPrepareThunk16() is called
9062 once and AsmThunk16() can be called for each 16-bit real mode thunk.
9064 This interface is limited to be used in either physical mode or virtual modes with paging enabled where the
9065 virtual to physical mappings for ThunkContext.RealModeBuffer is mapped 1:1.
9067 See AsmPrepareThunk16() and AsmThunk16() for the detailed description and ASSERT() conditions.
9069 @param ThunkContext A pointer to the context structure that describes the
9070 16-bit real mode code to call.
9075 AsmPrepareAndThunk16 (
9076 IN OUT THUNK_CONTEXT
*ThunkContext
9080 Generates a 16-bit random number through RDRAND instruction.
9082 if Rand is NULL, then ASSERT().
9084 @param[out] Rand Buffer pointer to store the random result.
9086 @retval TRUE RDRAND call was successful.
9087 @retval FALSE Failed attempts to call RDRAND.
9097 Generates a 32-bit random number through RDRAND instruction.
9099 if Rand is NULL, then ASSERT().
9101 @param[out] Rand Buffer pointer to store the random result.
9103 @retval TRUE RDRAND call was successful.
9104 @retval FALSE Failed attempts to call RDRAND.
9114 Generates a 64-bit random number through RDRAND instruction.
9116 if Rand is NULL, then ASSERT().
9118 @param[out] Rand Buffer pointer to store the random result.
9120 @retval TRUE RDRAND call was successful.
9121 @retval FALSE Failed attempts to call RDRAND.
9131 Load given selector into TR register.
9133 @param[in] Selector Task segment selector
9142 Patch the immediate operand of an IA32 or X64 instruction such that the byte,
9143 word, dword or qword operand is encoded at the end of the instruction's
9144 binary representation.
9146 This function should be used to update object code that was compiled with
9147 NASM from assembly source code. Example:
9151 mov eax, strict dword 0 ; the imm32 zero operand will be patched
9157 X86_ASSEMBLY_PATCH_LABEL gPatchCr3;
9158 PatchInstructionX86 (gPatchCr3, AsmReadCr3 (), 4);
9160 @param[out] InstructionEnd Pointer right past the instruction to patch. The
9161 immediate operand to patch is expected to
9162 comprise the trailing bytes of the instruction.
9163 If InstructionEnd is closer to address 0 than
9164 ValueSize permits, then ASSERT().
9166 @param[in] PatchValue The constant to write to the immediate operand.
9167 The caller is responsible for ensuring that
9168 PatchValue can be represented in the byte, word,
9169 dword or qword operand (as indicated through
9170 ValueSize); otherwise ASSERT().
9172 @param[in] ValueSize The size of the operand in bytes; must be 1, 2,
9173 4, or 8. ASSERT() otherwise.
9177 PatchInstructionX86 (
9178 OUT X86_ASSEMBLY_PATCH_LABEL
*InstructionEnd
,
9179 IN UINT64 PatchValue
,
9183 #endif // defined (MDE_CPU_IA32) || defined (MDE_CPU_X64)
9184 #endif // !defined (__BASE_LIB__)